[FFmpeg-cvslog] mxfdec: set audio timebase to 1/samplerate

Anton Khirnov git at videolan.org
Thu Jan 16 22:49:47 CET 2014


ffmpeg | branch: release/0.10 | Anton Khirnov <anton at khirnov.net> | Sat Sep 28 16:56:54 2013 +0200| [90294e31a199b457bba77da2f73183d2d154faf4] | committer: Luca Barbato

mxfdec: set audio timebase to 1/samplerate

Fixes sync in some samples (e.g. bugs 7581 and 8374 in VLC).
Based on a commit by Matthieu Bouron <matthieu.bouron at gmail.com>

Reported-by: Jean-Baptiste Kempf <jb at videolan.org>
CC: libav-stable at libav.org
(cherry picked from commit 93370d12164236d59645314871a1d6808b2a8ddb)
Signed-off-by: Luca Barbato <lu_zero at gentoo.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=90294e31a199b457bba77da2f73183d2d154faf4
---

 libavformat/mxfdec.c        |   12 +++++++++++-
 tests/ref/seek/lavf_mxf     |   16 ++++++++--------
 tests/ref/seek/lavf_mxf_d10 |   16 ++++++++--------
 3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index cb2ae86..c0f7113 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -830,7 +830,17 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
                 st->codec->codec_id = container_ul->id;
             st->codec->channels = descriptor->channels;
             st->codec->bits_per_coded_sample = descriptor->bits_per_sample;
-            st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
+            if (descriptor->sample_rate.den > 0) {
+                st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den;
+                avpriv_set_pts_info(st, 64, descriptor->sample_rate.den, descriptor->sample_rate.num);
+            } else {
+                av_log(mxf->fc, AV_LOG_WARNING, "invalid sample rate (%d/%d) "
+                       "found for stream #%d, time base forced to 1/48000\n",
+                       descriptor->sample_rate.num, descriptor->sample_rate.den,
+                       st->index);
+                avpriv_set_pts_info(st, 64, 1, 48000);
+            }
+
             /* TODO: implement CODEC_ID_RAWAUDIO */
             if (st->codec->codec_id == CODEC_ID_PCM_S16LE) {
                 if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24)
diff --git a/tests/ref/seek/lavf_mxf b/tests/ref/seek/lavf_mxf
index 4c1aecc..ce0d6ed 100644
--- a/tests/ref/seek/lavf_mxf
+++ b/tests/ref/seek/lavf_mxf
@@ -7,9 +7,9 @@ ret: 0         st: 0 flags:0  ts: 0.800000
 ret:-1
 ret: 0         st: 0 flags:1  ts:-0.320000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   6144 size: 24801
-ret: 0         st: 1 flags:0  ts: 2.560000
+ret: 0         st: 1 flags:0  ts: 2.576667
 ret:-1
-ret: 0         st: 1 flags:1  ts: 1.480000
+ret: 0         st: 1 flags:1  ts: 1.470833
 ret:-1
 ret: 0         st:-1 flags:0  ts: 0.365002
 ret: 0         st: 0 flags:1 dts: 0.360000 pts: NOPTS    pos:   6144 size: 24801
@@ -19,9 +19,9 @@ ret: 0         st: 0 flags:0  ts: 2.160000
 ret:-1
 ret: 0         st: 0 flags:1  ts: 1.040000
 ret:-1
-ret: 0         st: 1 flags:0  ts:-0.040000
+ret: 0         st: 1 flags:0  ts:-0.058333
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   6144 size: 24801
-ret: 0         st: 1 flags:1  ts: 2.840000
+ret: 0         st: 1 flags:1  ts: 2.835833
 ret:-1
 ret: 0         st:-1 flags:0  ts: 1.730004
 ret:-1
@@ -31,9 +31,9 @@ ret: 0         st: 0 flags:0  ts:-0.480000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   6144 size: 24801
 ret: 0         st: 0 flags:1  ts: 2.400000
 ret:-1
-ret: 0         st: 1 flags:0  ts: 1.320000
+ret: 0         st: 1 flags:0  ts: 1.306667
 ret:-1
-ret: 0         st: 1 flags:1  ts: 0.200000
+ret: 0         st: 1 flags:1  ts: 0.200833
 ret: 0         st: 0 flags:1 dts: 0.200000 pts: NOPTS    pos:   6144 size: 24801
 ret: 0         st:-1 flags:0  ts:-0.904994
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   6144 size: 24801
@@ -43,9 +43,9 @@ ret: 0         st: 0 flags:0  ts: 0.880000
 ret:-1
 ret: 0         st: 0 flags:1  ts:-0.240000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: NOPTS    pos:   6144 size: 24801
-ret: 0         st: 1 flags:0  ts: 2.680000
+ret: 0         st: 1 flags:0  ts: 2.671667
 ret:-1
-ret: 0         st: 1 flags:1  ts: 1.560000
+ret: 0         st: 1 flags:1  ts: 1.565833
 ret:-1
 ret: 0         st:-1 flags:0  ts: 0.460008
 ret: 0         st: 0 flags:1 dts: 0.480000 pts: NOPTS    pos:   6144 size: 24801
diff --git a/tests/ref/seek/lavf_mxf_d10 b/tests/ref/seek/lavf_mxf_d10
index c05870f..dba05ce 100644
--- a/tests/ref/seek/lavf_mxf_d10
+++ b/tests/ref/seek/lavf_mxf_d10
@@ -7,9 +7,9 @@ ret: 0         st: 0 flags:0  ts: 0.800000
 ret:-1
 ret: 0         st: 0 flags:1  ts:-0.320000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   6144 size:150000
-ret: 0         st: 1 flags:0  ts: 2.560000
+ret: 0         st: 1 flags:0  ts: 2.576667
 ret:-1
-ret: 0         st: 1 flags:1  ts: 1.480000
+ret: 0         st: 1 flags:1  ts: 1.470833
 ret:-1
 ret: 0         st:-1 flags:0  ts: 0.365002
 ret: 0         st: 0 flags:1 dts: 0.360000 pts: 0.360000 pos:   6144 size:150000
@@ -19,9 +19,9 @@ ret: 0         st: 0 flags:0  ts: 2.160000
 ret:-1
 ret: 0         st: 0 flags:1  ts: 1.040000
 ret:-1
-ret: 0         st: 1 flags:0  ts:-0.040000
+ret: 0         st: 1 flags:0  ts:-0.058333
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   6144 size:150000
-ret: 0         st: 1 flags:1  ts: 2.840000
+ret: 0         st: 1 flags:1  ts: 2.835833
 ret:-1
 ret: 0         st:-1 flags:0  ts: 1.730004
 ret:-1
@@ -31,9 +31,9 @@ ret: 0         st: 0 flags:0  ts:-0.480000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   6144 size:150000
 ret: 0         st: 0 flags:1  ts: 2.400000
 ret:-1
-ret: 0         st: 1 flags:0  ts: 1.320000
+ret: 0         st: 1 flags:0  ts: 1.306667
 ret:-1
-ret: 0         st: 1 flags:1  ts: 0.200000
+ret: 0         st: 1 flags:1  ts: 0.200833
 ret: 0         st: 0 flags:1 dts: 0.200000 pts: 0.200000 pos:   6144 size:150000
 ret: 0         st:-1 flags:0  ts:-0.904994
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   6144 size:150000
@@ -43,9 +43,9 @@ ret: 0         st: 0 flags:0  ts: 0.880000
 ret:-1
 ret: 0         st: 0 flags:1  ts:-0.240000
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   6144 size:150000
-ret: 0         st: 1 flags:0  ts: 2.680000
+ret: 0         st: 1 flags:0  ts: 2.671667
 ret:-1
-ret: 0         st: 1 flags:1  ts: 1.560000
+ret: 0         st: 1 flags:1  ts: 1.565833
 ret:-1
 ret: 0         st:-1 flags:0  ts: 0.460008
 ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:   6144 size:150000



More information about the ffmpeg-cvslog mailing list