aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Slobodeniuk <alenuke@yandex.ru>2017-11-10 13:51:07 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2017-11-11 14:15:15 +0100
commit85af60df89ed92c60fb1641cd01c6095eba6576e (patch)
tree74e7c32ae45c09a9be6dc22a22e7877fb00cd218
parentb197d83ca3f7316a4eb31bf60d9895835f7f2b4b (diff)
downloadffmpeg-85af60df89ed92c60fb1641cd01c6095eba6576e.tar.gz
avcodec: fix wrong duration of packets (dvd, bluray)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/utils.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 965b6c6276..b3a578110b 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1808,13 +1808,13 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
/* calc from frame_bytes, channels, and bits_per_coded_sample */
switch (id) {
case AV_CODEC_ID_PCM_DVD:
- if(bps<4)
+ if(bps<4 || frame_bytes<3)
return 0;
- return 2 * (frame_bytes / ((bps * 2 / 8) * ch));
+ return 2 * ((frame_bytes - 3) / ((bps * 2 / 8) * ch));
case AV_CODEC_ID_PCM_BLURAY:
- if(bps<4)
+ if(bps<4 || frame_bytes<4)
return 0;
- return frame_bytes / ((FFALIGN(ch, 2) * bps) / 8);
+ return (frame_bytes - 4) / ((FFALIGN(ch, 2) * bps) / 8);
case AV_CODEC_ID_S302M:
return 2 * (frame_bytes / ((bps + 4) / 4)) / ch;
}