[FFmpeg-devel] [PATCH] mxfdec: set audio packet pts

Michael Niedermayer michaelni at gmx.at
Wed Sep 12 13:06:01 CEST 2012


From: Matthieu Bouron <matthieu.bouron at gmail.com>

Fix audio/video desync with NTSC samples

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/mxfdec.c |    7 +++++--
 tests/ref/lavf/mxf   |    6 +++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 3ddeb99..794e1ee 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2007,6 +2007,7 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
             int64_t next_ofs, next_klv;
             AVStream *st;
             MXFTrack *track;
+            enum AVMediaType codec_type;
 
             if (index < 0) {
                 av_log(s, AV_LOG_ERROR, "error getting stream index %d\n", AV_RB32(klv.key+12));
@@ -2045,12 +2046,14 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
             pkt->stream_index = index;
             pkt->pos = klv.offset;
 
-            if (s->streams[index]->codec->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
+            codec_type = s->streams[index]->codec->codec_type;
+            if ((codec_type == AVMEDIA_TYPE_AUDIO || codec_type == AVMEDIA_TYPE_VIDEO) && next_ofs >= 0) {
                 /* mxf->current_edit_unit good - see if we have an index table to derive timestamps from */
                 MXFIndexTable *t = &mxf->index_tables[0];
 
                 if (mxf->nb_index_tables >= 1 && mxf->current_edit_unit < t->nb_ptses) {
-                    pkt->dts = mxf->current_edit_unit + t->first_dts;
+                    if (codec_type == AVMEDIA_TYPE_VIDEO)
+                        pkt->dts = mxf->current_edit_unit + t->first_dts;
                     pkt->pts = t->ptses[mxf->current_edit_unit];
                 } else if (track->intra_only) {
                     /* intra-only -> PTS = EditUnit.
diff --git a/tests/ref/lavf/mxf b/tests/ref/lavf/mxf
index 2253329..5b1b5cc 100644
--- a/tests/ref/lavf/mxf
+++ b/tests/ref/lavf/mxf
@@ -1,9 +1,9 @@
 4cc269e1d2066fac03a3d7466f011c8e *./tests/data/lavf/lavf.mxf
 525881 ./tests/data/lavf/lavf.mxf
-./tests/data/lavf/lavf.mxf CRC=0x4ace0849
+./tests/data/lavf/lavf.mxf CRC=0xca6a0849
 88ab06201db1953329bfb4aa04a4fe05 *./tests/data/lavf/lavf.mxf
 553529 ./tests/data/lavf/lavf.mxf
-./tests/data/lavf/lavf.mxf CRC=0xdb9bdf92
+./tests/data/lavf/lavf.mxf CRC=0xe30cdf92
 52c5b74ecfdc48bd77d79a6bbe62d2de *./tests/data/lavf/lavf.mxf
 525881 ./tests/data/lavf/lavf.mxf
-./tests/data/lavf/lavf.mxf CRC=0x4ace0849
+./tests/data/lavf/lavf.mxf CRC=0xca6a0849
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list