Module: libav
Branch: release/0.8
Commit: fc89f15497c2b5b78a992c98eaba9fca7cc82f8f

Author:    Martin Storsjö <[email protected]>
Committer: Reinhard Tartler <[email protected]>
Date:      Thu Jan 26 21:37:38 2012 +0200

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: [email protected]
Signed-off-by: Martin Storsjö <[email protected]>
(cherry picked from commit 9a7dc618c50902e7a171f2deda6430d52c277a95)

Signed-off-by: Reinhard Tartler <[email protected]>

---

 libavcodec/utils.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 5109bf8..f64bff8 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -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) {

_______________________________________________
libav-commits mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to