]> git.sesse.net Git - ffmpeg/commitdiff
lavc: allow decoders to override frame parameters.
authorAnton Khirnov <anton@khirnov.net>
Mon, 11 Feb 2013 07:09:02 +0000 (08:09 +0100)
committerAnton Khirnov <anton@khirnov.net>
Fri, 8 Mar 2013 06:39:44 +0000 (07:39 +0100)
libavcodec/utils.c

index 7e451bfa0b578f8ef66df82527860bd906dd1f57..90f25377f6336d02fa36947cf5f182b59078a38f 100644 (file)
@@ -552,18 +552,25 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
 
     switch (avctx->codec_type) {
     case AVMEDIA_TYPE_VIDEO:
-        frame->width               = avctx->width;
-        frame->height              = avctx->height;
-        frame->format              = avctx->pix_fmt;
-        frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
+        if (!frame->width)
+            frame->width               = avctx->width;
+        if (!frame->height)
+            frame->height              = avctx->height;
+        if (frame->format < 0)
+            frame->format              = avctx->pix_fmt;
+        if (!frame->sample_aspect_ratio.num)
+            frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
 
         if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0)
             return ret;
         break;
     case AVMEDIA_TYPE_AUDIO:
-        frame->sample_rate    = avctx->sample_rate;
-        frame->format         = avctx->sample_fmt;
-        frame->channel_layout = avctx->channel_layout;
+        if (!frame->sample_rate)
+            frame->sample_rate    = avctx->sample_rate;
+        if (frame->format < 0)
+            frame->format         = avctx->sample_fmt;
+        if (!frame->channel_layout)
+            frame->channel_layout = avctx->channel_layout;
         break;
     default: return AVERROR(EINVAL);
     }