From de7985d46abd382b64a6f11ccf3c5a9c57d43e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 24 Jul 2017 17:00:02 +0300 Subject: mxfdemux: Correctly consider frame reordering for timecode calculation --- gst/mxf/mxfdemux.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'gst/mxf') diff --git a/gst/mxf/mxfdemux.c b/gst/mxf/mxfdemux.c index 1118d1f6d..bed7e59b8 100644 --- a/gst/mxf/mxfdemux.c +++ b/gst/mxf/mxfdemux.c @@ -1940,10 +1940,26 @@ gst_mxf_demux_handle_generic_container_essence_element (GstMXFDemux * demux, if (pad->material_track->parent.type == MXF_METADATA_TRACK_PICTURE_ESSENCE && pad->start_timecode.config.fps_n != 0 && pad->start_timecode.config.fps_d != 0) { - GstVideoTimeCode timecode = pad->start_timecode; - gst_video_time_code_add_frames (&timecode, - pad->current_material_track_position); - gst_buffer_add_video_time_code_meta (outbuf, &timecode); + if (etrack->intra_only) { + GstVideoTimeCode timecode = pad->start_timecode; + + gst_video_time_code_add_frames (&timecode, + pad->current_material_track_position); + gst_buffer_add_video_time_code_meta (outbuf, &timecode); + } else if (pts != G_MAXUINT64) { + GstVideoTimeCode timecode = pad->start_timecode; + + gst_video_time_code_add_frames (&timecode, + pad->current_component_start_position); + gst_video_time_code_add_frames (&timecode, + gst_util_uint64_scale (pts, + pad->material_track->edit_rate.n * + pad->current_essence_track->source_track->edit_rate.d, + pad->material_track->edit_rate.d * + pad->current_essence_track->source_track->edit_rate.n)); + gst_buffer_add_video_time_code_meta (outbuf, &timecode); + } + } /* Update accumulated error and compensate */ -- cgit v1.2.1