diff options
author | Chandu Babu N <chandu@amd.com> | 2017-10-05 19:53:16 +0530 |
---|---|---|
committer | Leo Liu <leo.liu@amd.com> | 2017-10-06 09:11:16 -0400 |
commit | b0a03765a183d6d4633d7e71f46797f91a3c0951 (patch) | |
tree | 295251efa59347afb447261cc527e8b6a1621809 | |
parent | b8a2f3dd5aa0e3fb29ffaf67dcd24b36f6e4c17b (diff) |
omx: handle frame reodering for tunneling
when tunneling is enabled, input frame is returned to framework
in decode order instead of display order. Because of this some
muxers(avmux_mpegts) are giving corrupted output.
-rw-r--r-- | omx/gstomxvideodec.c | 8 | ||||
-rw-r--r-- | omx/gstomxvideodec.h | 3 | ||||
-rw-r--r-- | omx/gstomxvideoenc.c | 21 |
3 files changed, 26 insertions, 6 deletions
diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 3bd5be4..d5bdf06 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1002,7 +1002,7 @@ gst_omx_video_dec_change_state (GstElement * element, GstStateChange transition) return ret; } -static GstVideoCodecFrame * +GstVideoCodecFrame * gst_omx_video_dec_find_nearest_frame (GstOMXVideoDec * self, GstOMXBuffer * buf) { GstVideoCodecFrame *best = NULL; @@ -2959,11 +2959,7 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, goto release_error; } - if (self->dec_out_port->tunneled) { - frame->output_buffer = gst_buffer_new (); - gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame); - } else - gst_video_codec_frame_unref (frame); + gst_video_codec_frame_unref (frame); GST_DEBUG_OBJECT (self, "Passed frame to component"); diff --git a/omx/gstomxvideodec.h b/omx/gstomxvideodec.h index 3978865..eabcf81 100644 --- a/omx/gstomxvideodec.h +++ b/omx/gstomxvideodec.h @@ -98,6 +98,9 @@ struct _GstOMXVideoDecClass GType gst_omx_video_dec_get_type (void); +GstVideoCodecFrame * +gst_omx_video_dec_find_nearest_frame (GstOMXVideoDec * self, GstOMXBuffer * buf); + G_END_DECLS #endif /* __GST_OMX_VIDEO_DEC_H__ */ diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 48a365e..e0b6802 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -27,6 +27,7 @@ #include <string.h> #include "gstomxvideoenc.h" +#include "gstomxvideodec.h" GST_DEBUG_CATEGORY_STATIC (gst_omx_video_enc_debug_category); #define GST_CAT_DEFAULT gst_omx_video_enc_debug_category @@ -1029,6 +1030,26 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self) goto flushing; } + if(self->enc_in_port->tunneled){ + GstPad *peer = gst_pad_get_peer (GST_VIDEO_ENCODER_SINK_PAD (self)); + GstElement *element = peer ? gst_pad_get_parent_element (peer) : NULL; + + if (element && GST_IS_OMX_VIDEO_DEC (element)) { + GstOMXVideoDec *dec = GST_OMX_VIDEO_DEC (element); + GstVideoCodecFrame *decframe; + GST_DEBUG_OBJECT (self, "Handling decoder buffer: 0x%08x %" G_GUINT64_FORMAT, + (guint) buf->omx_buf->nFlags, (guint64) buf->omx_buf->nTimeStamp); + + GST_VIDEO_DECODER_STREAM_LOCK (dec); + decframe = gst_omx_video_dec_find_nearest_frame (dec, buf); + if(decframe){ + decframe->output_buffer = gst_buffer_new (); + gst_video_decoder_finish_frame (GST_VIDEO_DECODER (dec), decframe); + } + GST_VIDEO_DECODER_STREAM_UNLOCK (dec); + } + } + GST_DEBUG_OBJECT (self, "Handling buffer: 0x%08x %" G_GUINT64_FORMAT, (guint) buf->omx_buf->nFlags, (guint64) buf->omx_buf->nTimeStamp); |