Merge commit 'c755870d52c8c29676e5ba7ee9557adf4a7ca934'
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 1 Nov 2013 14:34:49 +0000 (15:34 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 1 Nov 2013 14:34:49 +0000 (15:34 +0100)
* commit 'c755870d52c8c29676e5ba7ee9557adf4a7ca934':
  sgidec: stop using deprecated avcodec_set_dimensions
  rv34: stop using deprecated avcodec_set_dimensions
  rv10: stop using deprecated avcodec_set_dimensions
  ptx: stop using deprecated avcodec_set_dimensions

Conflicts:
libavcodec/ptx.c
libavcodec/rv10.c
libavcodec/sgidec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/ptx.c
libavcodec/rv10.c
libavcodec/rv34.c
libavcodec/sgidec.c

@@@ -55,12 -55,13 +55,11 @@@ static int ptx_decode_frame(AVCodecCont
  
      buf += offset;
  
-     if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)
+     if ((ret = ff_set_dimensions(avctx, w, h)) < 0)
          return ret;
-     if (w != avctx->width || h != avctx->height)
-         avcodec_set_dimensions(avctx, w, h);
 -    if ((ret = ff_get_buffer(avctx, p, 0)) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 +    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
          return ret;
 -    }
  
      p->pict_type = AV_PICTURE_TYPE_I;
  
@@@ -360,21 -357,14 +361,23 @@@ static int rv20_decode_picture_header(R
              new_h = s->orig_height;
          }
          if (new_w != s->width || new_h != s->height) {
 +            AVRational old_aspect = s->avctx->sample_aspect_ratio;
              av_log(s->avctx, AV_LOG_DEBUG,
                     "attempting to change resolution to %dx%d\n", new_w, new_h);
-             if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0)
-                 return AVERROR_INVALIDDATA;
              ff_MPV_common_end(s);
  
-             avcodec_set_dimensions(s->avctx, new_w, new_h);
 +            // attempt to keep aspect during typical resolution switches
 +            if (!old_aspect.num)
 +                old_aspect = (AVRational){1, 1};
 +            if (2 * new_w * s->height == new_h * s->width)
 +                s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){2, 1});
 +            if (new_w * s->height == 2 * new_h * s->width)
 +                s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){1, 2});
++
+             ret = ff_set_dimensions(s->avctx, new_w, new_h);
+             if (ret < 0)
+                 return ret;
              s->width  = new_w;
              s->height = new_h;
              if ((ret = ff_MPV_common_init(s)) < 0)
@@@ -1685,15 -1665,13 +1685,19 @@@ int ff_rv34_decode_frame(AVCodecContex
              av_log(s->avctx, AV_LOG_WARNING, "Changing dimensions to %dx%d\n",
                     si.width, si.height);
  
 +            if (av_image_check_size(si.width, si.height, 0, s->avctx))
 +                return AVERROR_INVALIDDATA;
 +
 +            s->avctx->sample_aspect_ratio = update_sar(
 +                s->width, s->height, s->avctx->sample_aspect_ratio,
 +                si.width, si.height);
              s->width  = si.width;
              s->height = si.height;
-             avcodec_set_dimensions(s->avctx, s->width, s->height);
+             err = ff_set_dimensions(s->avctx, s->width, s->height);
+             if (err < 0)
+                 return err;
              if ((err = ff_MPV_common_frame_size_change(s)) < 0)
                  return err;
              if ((err = rv34_decoder_realloc(r)) < 0)
@@@ -195,19 -193,21 +195,19 @@@ static int decode_frame(AVCodecContext 
          avctx->pix_fmt = s->bytes_per_channel == 2 ? AV_PIX_FMT_GRAY16BE : AV_PIX_FMT_GRAY8;
      } else if (s->depth == SGI_RGB) {
          avctx->pix_fmt = s->bytes_per_channel == 2 ? AV_PIX_FMT_RGB48BE : AV_PIX_FMT_RGB24;
 -    } else if (s->depth == SGI_RGBA && s->bytes_per_channel == 1) {
 -        avctx->pix_fmt = AV_PIX_FMT_RGBA;
 +    } else if (s->depth == SGI_RGBA) {
 +        avctx->pix_fmt = s->bytes_per_channel == 2 ? AV_PIX_FMT_RGBA64BE : AV_PIX_FMT_RGBA;
      } else {
          av_log(avctx, AV_LOG_ERROR, "wrong picture format\n");
 -        return -1;
 +        return AVERROR_INVALIDDATA;
      }
  
-     if (av_image_check_size(s->width, s->height, 0, avctx))
-         return AVERROR_INVALIDDATA;
-     avcodec_set_dimensions(avctx, s->width, s->height);
+     ret = ff_set_dimensions(avctx, s->width, s->height);
+     if (ret < 0)
+         return ret;
  
 -    if (ff_get_buffer(avctx, p, 0) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed.\n");
 -        return -1;
 -    }
 +    if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
 +        return ret;
  
      p->pict_type = AV_PICTURE_TYPE_I;
      p->key_frame = 1;