Browse Source

libavcodec: Don't crash in avcodec_encode_audio if time_base isn't set

Earlier, calling avcodec_encode_audio worked fine even if time_base
wasn't set. Now it crashes due to trying to scale the output pts to
the codec context time base. This affects e.g. VLC.

If no time_base is set for audio codecs, set it to the sample
rate.

CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
(cherry picked from commit 9a7dc618c5)

Signed-off-by: Reinhard Tartler <siretart@tauware.de>
tags/n0.10.1
Martin Storsjö Reinhard Tartler 14 years ago
parent
commit
fc89f15497
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      libavcodec/utils.c

+ 6
- 0
libavcodec/utils.c View File

@@ -744,6 +744,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVD
avctx->error_recognition, avctx->err_recognition);
#endif

if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
(!avctx->time_base.num || !avctx->time_base.den)) {
avctx->time_base.num = 1;
avctx->time_base.den = avctx->sample_rate;
}

if (HAVE_THREADS && !avctx->thread_opaque) {
ret = ff_thread_init(avctx);
if (ret < 0) {


Loading…
Cancel
Save