0012-combine-sps-pps-header-to-idr.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Combine SPS/PPS header to IDR frame.
  2. Signed-off-by: Windsome Zeng <windsome.zeng@starfivetech.com>
  3. diff -purN a/meson.build b/meson.build
  4. --- a/meson.build 2022-05-13 11:31:02.725614796 +0800
  5. +++ b/meson.build 2022-05-13 11:32:26.213975419 +0800
  6. @@ -218,6 +218,7 @@ elif omx_target == 'tizonia'
  7. omx_inc = []
  8. elif omx_target == 'stf'
  9. cdata.set('USE_OMX_TARGET_STARFIVE', 1)
  10. + gst_omx_args += ['-DCOMBINE_SPS_PPS_HEADERS']
  11. warning('stf selected')
  12. else
  13. error ('Unsupported omx target specified. Use the -Dtarget option')
  14. diff -purN a/omx/gstomx.c b/omx/gstomx.c
  15. --- a/omx/gstomx.c 2022-05-13 11:31:02.725614796 +0800
  16. +++ b/omx/gstomx.c 2022-05-13 11:33:15.461950978 +0800
  17. @@ -70,6 +70,11 @@ static GHashTable *core_handles;
  18. G_LOCK_DEFINE_STATIC (buffer_flags_str);
  19. static GHashTable *buffer_flags_str;
  20. +#ifdef COMBINE_SPS_PPS_HEADERS
  21. +static OMX_U8 *sps_pps_header = NULL;
  22. +static OMX_U32 sps_pps_header_size = 0;
  23. +#endif
  24. +
  25. GstOMXCore *
  26. gst_omx_core_acquire (const gchar * filename)
  27. {
  28. @@ -903,6 +908,36 @@ FillBufferDone (OMX_HANDLETYPE hComponen
  29. g_assert (buf->omx_buf == pBuffer);
  30. +#ifdef COMBINE_SPS_PPS_HEADERS
  31. + if (pBuffer->nFlags == 0x80) {
  32. + g_assert (sps_pps_header == NULL);
  33. + if (sps_pps_header)
  34. + g_free (sps_pps_header);
  35. +
  36. + sps_pps_header = g_new (OMX_U8, pBuffer->nFilledLen);
  37. + if (sps_pps_header) {
  38. + sps_pps_header_size = pBuffer->nFilledLen;
  39. + memcpy(sps_pps_header, pBuffer->pBuffer + pBuffer->nOffset, pBuffer->nFilledLen);
  40. + }
  41. + return OMX_ErrorNone;
  42. + }
  43. +
  44. + if (sps_pps_header) {
  45. + g_assert (sps_pps_header_size + pBuffer->nFilledLen <= pBuffer->nAllocLen);
  46. + if (sps_pps_header_size + pBuffer->nFilledLen <= pBuffer->nAllocLen) {
  47. + OMX_U8 *buf;
  48. + buf = pBuffer->pBuffer + pBuffer->nOffset;
  49. + memmove (buf + sps_pps_header_size, buf, pBuffer->nFilledLen);
  50. + memcpy (buf, sps_pps_header, sps_pps_header_size);
  51. + pBuffer->nFilledLen += sps_pps_header_size;
  52. +
  53. + g_free (sps_pps_header);
  54. + sps_pps_header = NULL;
  55. + sps_pps_header_size = 0;
  56. + }
  57. + }
  58. +#endif /* COMBINE_SPS_PPS_HEADERS */
  59. +
  60. if (buf->port->tunneled) {
  61. GST_ERROR ("FillBufferDone on tunneled port");
  62. return OMX_ErrorBadParameter;