From 283f97cb79bb834b8caaaaf361bd84671ae945ba Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 1 Feb 2012 12:23:23 +0100 Subject: [PATCH] h264parse: also mind SEI position for config data insertion Fixes #668627. --- gst/videoparsers/gsth264parse.c | 16 ++++++++++++++++ gst/videoparsers/gsth264parse.h | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index d5e3473589..182b00e929 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -186,6 +186,7 @@ gst_h264_parse_reset_frame (GstH264Parse * h264parse) h264parse->picture_start = FALSE; h264parse->update_caps = FALSE; h264parse->idr_pos = -1; + h264parse->sei_pos = -1; h264parse->keyframe = FALSE; h264parse->frame_start = FALSE; gst_adapter_clear (h264parse->frame_out); @@ -504,6 +505,15 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu) GST_TIME_ARGS (h264parse->ts_trn_nb)); break; } + /* mark SEI pos */ + if (h264parse->sei_pos == -1) { + if (h264parse->format == GST_H264_PARSE_FORMAT_AVC) + h264parse->sei_pos = gst_adapter_available (h264parse->frame_out); + else + h264parse->sei_pos = nalu->offset - 4; + GST_DEBUG_OBJECT (h264parse, "marking SEI in frame at offset %d", + h264parse->sei_pos); + } break; case GST_H264_NAL_SLICE: @@ -547,6 +557,12 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu) GST_DEBUG_OBJECT (h264parse, "marking IDR in frame at offset %d", h264parse->idr_pos); } + /* if SEI preceeds (faked) IDR, then we have to insert config there */ + if (h264parse->sei_pos >= 0 && h264parse->idr_pos > h264parse->sei_pos) { + h264parse->idr_pos = h264parse->sei_pos; + GST_DEBUG_OBJECT (h264parse, "moved IDR mark to SEI position %d", + h264parse->idr_pos); + } break; default: gst_h264_parser_parse_nal (nalparser, nalu); diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h index a97dfcb15f..812ac4fb88 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -98,7 +98,7 @@ struct _GstH264Parse /* frame parsing */ /*guint last_nal_pos;*/ /*guint next_sc_pos;*/ - gint idr_pos; + gint idr_pos, sei_pos; gboolean update_caps; GstAdapter *frame_out; gboolean keyframe;