OSDN Git Service

Merge commit '4a4841d4e0f0dc50998511bf6c48b518012024db'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 17 Nov 2013 01:24:27 +0000 (02:24 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 17 Nov 2013 01:24:27 +0000 (02:24 +0100)
* commit '4a4841d4e0f0dc50998511bf6c48b518012024db':
  fraps: use the AVFrame API properly.
  rpza: use the AVFrame API properly.
  motionpixels: use the AVFrame API properly.
  vmdvideo: use the AVFrame API properly.

Conflicts:
libavcodec/fraps.c
libavcodec/motionpixels.c
libavcodec/rpza.c
libavcodec/vmdav.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/motionpixels.c
libavcodec/rpza.c
libavcodec/vmdav.c

@@@ -68,14 -76,14 +81,20 @@@ static av_cold int mp_decode_init(AVCod
      mp->offset_bits_len = av_log2(avctx->width * avctx->height) + 1;
      mp->vpt = av_mallocz(avctx->height * sizeof(YuvPixel));
      mp->hpt = av_mallocz(h4 * w4 / 16 * sizeof(YuvPixel));
 +    if (!mp->changes_map || !mp->vpt || !mp->hpt) {
 +        av_freep(&mp->changes_map);
 +        av_freep(&mp->vpt);
 +        av_freep(&mp->hpt);
 +        return AVERROR(ENOMEM);
 +    }
      avctx->pix_fmt = AV_PIX_FMT_RGB555;
-     avcodec_get_frame_defaults(&mp->frame);
+     mp->frame = av_frame_alloc();
+     if (!mp->frame) {
+         mp_decode_end(avctx);
+         return AVERROR(ENOMEM);
+     }
      return 0;
  }
  
@@@ -271,11 -267,13 +290,11 @@@ static int mp_decode_frame(AVCodecConte
      GetBitContext gb;
      int i, count1, count2, sz, ret;
  
-     if ((ret = ff_reget_buffer(avctx, &mp->frame)) < 0)
 -    if ((ret = ff_reget_buffer(avctx, mp->frame)) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
++    if ((ret = ff_reget_buffer(avctx, mp->frame)) < 0)
          return ret;
 -    }
  
      /* le32 bitstream msb first */
 -    av_fast_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
 +    av_fast_padded_malloc(&mp->bswapbuf, &mp->bswapbuf_size, buf_size);
      if (!mp->bswapbuf)
          return AVERROR(ENOMEM);
      mp->dsp.bswap_buf((uint32_t *)mp->bswapbuf, (const uint32_t *)buf, buf_size / 4);
          goto end;
  
      if (mp->changes_map[0] == 0) {
-         *(uint16_t *)mp->frame.data[0] = get_bits(&gb, 15);
+         *(uint16_t *)mp->frame->data[0] = get_bits(&gb, 15);
          mp->changes_map[0] = 1;
      }
 -    mp_read_codes_table(mp, &gb);
 +    if (mp_read_codes_table(mp, &gb) < 0)
 +        goto end;
  
      sz = get_bits(&gb, 18);
      if (avctx->extradata[0] != 5)
@@@ -82,10 -82,10 +82,10 @@@ static void rpza_decode_stream(RpzaCont
      unsigned short color4[4];
      unsigned char index, idx;
      unsigned short ta, tb;
-     unsigned short *pixels = (unsigned short *)s->frame.data[0];
+     unsigned short *pixels = (unsigned short *)s->frame->data[0];
  
      int row_ptr = 0;
 -    int pixel_ptr = 0;
 +    int pixel_ptr = -4;
      int block_ptr;
      int pixel_x, pixel_y;
      int total_blocks;
@@@ -256,8 -258,10 +258,8 @@@ static int rpza_decode_frame(AVCodecCon
      s->buf = buf;
      s->size = buf_size;
  
-     if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0)
 -    if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
++    if ((ret = ff_reget_buffer(avctx, s->frame)) < 0)
          return ret;
 -    }
  
      rpza_decode_stream(s);
  
@@@ -242,9 -232,18 +242,9 @@@ static int vmd_decode(VmdVideoContext *
          return AVERROR_INVALIDDATA;
      }
  
 -    if ((frame_width == s->avctx->width && frame_height == s->avctx->height) &&
 -        (frame_x || frame_y)) {
 -
 -        s->x_off = frame_x;
 -        s->y_off = frame_y;
 -    }
 -    frame_x -= s->x_off;
 -    frame_y -= s->y_off;
 -
      /* if only a certain region will be updated, copy the entire previous
       * frame before the decode */
-     if (s->prev_frame.data[0] &&
+     if (s->prev_frame->data[0] &&
          (frame_x || frame_y || (frame_width != s->avctx->width) ||
          (frame_height != s->avctx->height))) {
  
      return 0;
  }
  
 -    av_free(s->unpack_buffer);
+ static av_cold int vmdvideo_decode_end(AVCodecContext *avctx)
+ {
+     VmdVideoContext *s = avctx->priv_data;
+     av_frame_free(&s->prev_frame);
++    av_freep(&s->unpack_buffer);
++    s->unpack_buffer_size = 0;
+     return 0;
+ }
  static av_cold int vmdvideo_decode_init(AVCodecContext *avctx)
  {
      VmdVideoContext *s = avctx->priv_data;
          r = raw_palette[palette_index++] * 4;
          g = raw_palette[palette_index++] * 4;
          b = raw_palette[palette_index++] * 4;
 -        palette32[i] = (r << 16) | (g << 8) | (b);
 +        palette32[i] = 0xFFU << 24 | (r << 16) | (g << 8) | (b);
 +        palette32[i] |= palette32[i] >> 6 & 0x30303;
      }
  
-     avcodec_get_frame_defaults(&s->prev_frame);
+     s->prev_frame = av_frame_alloc();
+     if (!s->prev_frame) {
+         vmdvideo_decode_end(avctx);
+         return AVERROR(ENOMEM);
+     }
  
      return 0;
  }
@@@ -453,18 -467,7 +468,6 @@@ static int vmdvideo_decode_frame(AVCode
      return buf_size;
  }
  
- static av_cold int vmdvideo_decode_end(AVCodecContext *avctx)
- {
-     VmdVideoContext *s = avctx->priv_data;
-     av_frame_unref(&s->prev_frame);
-     av_freep(&s->unpack_buffer);
-     s->unpack_buffer_size = 0;
-     return 0;
- }
--
  /*
   * Audio Decoder
   */