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@gmail.com>

Reported-by: Jean-Baptiste Kempf <jb@videolan.org>
CC: libav-stable@libav.org
(cherry picked from commit 93370d1216)
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
Anton Khirnov 2013-09-28 16:56:54 +02:00 committed by Luca Barbato
parent d92c908e23
commit 90294e31a1
3 changed files with 27 additions and 17 deletions

View File

@ -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)

View File

@ -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

View File

@ -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