[SCM] libav/experimental: check sample_fmt in avcodec_open

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 17:23:28 UTC 2013


The following commit has been merged in the experimental branch:
commit 2cfa2d925808e6cc6fb7a7c133b7cb7622afd37e
Author: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
Date:   Wed Feb 9 10:52:33 2011 -0500

    check sample_fmt in avcodec_open
    
    check AVCodecContext->sample_fmt against AVCodec->sample_fmts[] to ensure
    that the encoder supports the specified sample format. Error out if it doesn't.
    Previously, it would continue and output garbage. Fixes issue 2587.

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index eede431..0816b39 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -551,6 +551,16 @@ int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
                avctx->codec->max_lowres);
         goto free_and_end;
     }
+    if (avctx->codec->sample_fmts && avctx->codec->encode) {
+        int i;
+        for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
+            if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
+                break;
+        if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
+            av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
+            goto free_and_end;
+        }
+    }
 
     if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){
         ret = avctx->codec->init(avctx);

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list