From 337fa0dbe7b12977ba11d0ba0e6088daa6917453 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 4 Mar 2012 04:06:49 +0100 Subject: [PATCH] lavf: Do not compute the packet duration based on the bitrate if the frame_size can be determined. This fixes issues when the bitrate is variable or inaccurate but the frame size has not been determined yet. Signed-off-by: Michael Niedermayer --- libavformat/utils.c | 2 +- tests/ref/fate/wtv-demux | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index bf8abeec68..dce34449ba 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -779,7 +779,7 @@ static int get_audio_frame_size(AVCodecContext *enc, int size) frame_size = (size << 3) / (bits_per_sample * enc->channels); } else { /* used for example by ADPCM codecs */ - if (enc->bit_rate == 0) + if (enc->bit_rate == 0 || determinable_frame_size(enc)) return -1; frame_size = ((int64_t)size * 8 * enc->sample_rate) / enc->bit_rate; } diff --git a/tests/ref/fate/wtv-demux b/tests/ref/fate/wtv-demux index d20d041432..fadc4ef20d 100644 --- a/tests/ref/fate/wtv-demux +++ b/tests/ref/fate/wtv-demux @@ -1,11 +1,11 @@ #tb 0: 1/10000000 #tb 1: 1/10000000 -1, -2, -2, 180000, 576, 0x9b6e1638 -1, 179998, 179998, 240000, 576, 0x0ca91183 -1, 419998, 419998, 240000, 576, 0xec6a180f -1, 659998, 659998, 240000, 576, 0x478a2b9b -1, 899998, 899998, 240000, 576, 0x00fa15b3 -1, 1139998, 1139998, 240000, 576, 0xfb551816 +1, -2, -2, 240000, 576, 0x9b6e1638 +1, 239998, 239998, 240000, 576, 0x0ca91183 +1, 479998, 479998, 240000, 576, 0xec6a180f +1, 719998, 719998, 240000, 576, 0x478a2b9b +1, 959998, 959998, 240000, 576, 0x00fa15b3 +1, 1199998, 1199998, 240000, 576, 0xfb551816 1, 1439998, 1439998, 240000, 576, 0x422e12bd 1, 1679998, 1679998, 240000, 576, 0xa7581b29 1, 1919998, 1919998, 240000, 576, 0xd4b31a74