From 1b58fa487e5b194b20192b805e993504ec3d07e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 15 Nov 2011 08:40:07 -0800 Subject: [PATCH] omxh264enc: Detect bytestream stream format and don't put SPS/PPS into the caps for this format --- omx/gstomxh264enc.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/omx/gstomxh264enc.c b/omx/gstomxh264enc.c index 0b82a2346d..af1ad6c218 100644 --- a/omx/gstomxh264enc.c +++ b/omx/gstomxh264enc.c @@ -35,6 +35,8 @@ static gboolean gst_omx_h264_enc_set_format (GstOMXVideoEnc * enc, GstOMXPort * port, GstVideoState * state); static GstCaps *gst_omx_h264_enc_get_caps (GstOMXVideoEnc * enc, GstOMXPort * port, GstVideoState * state); +static GstFlowReturn gst_omx_h264_enc_handle_output_frame (GstOMXVideoEnc * + self, GstOMXPort * port, GstOMXBuffer * buf, GstVideoFrame * frame); enum { @@ -81,6 +83,8 @@ gst_omx_h264_enc_class_init (GstOMXH264EncClass * klass) videoenc_class->default_src_template_caps = "video/x-h264, " "width=(int) [ 16, 4096 ], " "height=(int) [ 16, 4096 ]"; + videoenc_class->handle_output_frame = + GST_DEBUG_FUNCPTR (gst_omx_h264_enc_handle_output_frame); } static void @@ -324,3 +328,23 @@ gst_omx_h264_enc_get_caps (GstOMXVideoEnc * enc, GstOMXPort * port, return caps; } + +static GstFlowReturn +gst_omx_h264_enc_handle_output_frame (GstOMXVideoEnc * self, GstOMXPort * port, + GstOMXBuffer * buf, GstVideoFrame * frame) +{ + if (buf->omx_buf->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { + /* The codec data is SPS/PPS with a startcode => bytestream stream format + * For bytestream stream format the SPS/PPS is only in-stream and not + * in the caps! + */ + if (buf->omx_buf->nFilledLen >= 4 && + GST_READ_UINT32_BE (buf->omx_buf->pBuffer + + buf->omx_buf->nOffset) == 0x00000001) { + buf->omx_buf->nFlags &= ~OMX_BUFFERFLAG_CODECCONFIG; + } + } + + return GST_OMX_VIDEO_ENC_CLASS (parent_class)->handle_output_frame (self, + port, buf, frame); +}