Merge commit '50ec1db62d977b6e864f315a53c1c580a6d7efa4'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 13 Jun 2013 10:10:05 +0000 (12:10 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 13 Jun 2013 10:12:33 +0000 (12:12 +0200)
* commit '50ec1db62d977b6e864f315a53c1c580a6d7efa4':
  4xm: fold last_picture lazy allocation in decode_p_frame

Conflicts:
libavcodec/4xm.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/4xm.c

@@@ -416,6 -394,17 +416,16 @@@ static int decode_p_frame(FourXContext 
      uint16_t *src;
      unsigned int bitstream_size, bytestream_size, wordstream_size, extra,
                   bytestream_offset, wordstream_offset;
 -            av_log(f->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+     int ret;
+     if (!f->last_picture->data[0]) {
+         if ((ret = ff_get_buffer(f->avctx, f->last_picture,
+                                  AV_GET_BUFFER_FLAG_REF)) < 0) {
 -        memset(f->last_picture->data[0], 0,
 -               f->avctx->height * FFABS(f->last_picture->linesize[0]));
+             return ret;
+         }
++        for (y=0; y<f->avctx->height; y++)
++            memset(f->last_picture->data[0] + y*f->last_picture->linesize[0], 0, 2*f->avctx->width);
+     }
  
      src = (uint16_t *)f->last_picture->data[0];
  
@@@ -886,35 -839,23 +896,27 @@@ static int decode_frame(AVCodecContext 
      // alternatively we would have to use our own buffer management
      avctx->flags |= CODEC_FLAG_EMU_EDGE;
  
 -    if ((ret = ff_get_buffer(avctx, picture, AV_GET_BUFFER_FLAG_REF)) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 +    if ((ret = ff_reget_buffer(avctx, f->current_picture)) < 0)
          return ret;
 -    }
  
      if (frame_4cc == AV_RL32("ifr2")) {
 -        picture->pict_type = AV_PICTURE_TYPE_I;
 -        if ((ret = decode_i2_frame(f, picture, buf - 4, frame_size + 4)) < 0)
 +        f->current_picture->pict_type = AV_PICTURE_TYPE_I;
 +        if ((ret = decode_i2_frame(f, f->current_picture, buf - 4, frame_size + 4)) < 0) {
 +            av_log(f->avctx, AV_LOG_ERROR, "decode i2 frame failed\n");
              return ret;
 +        }
      } else if (frame_4cc == AV_RL32("ifrm")) {
 -        picture->pict_type = AV_PICTURE_TYPE_I;
 -        if ((ret = decode_i_frame(f, picture, buf, frame_size)) < 0)
 +        f->current_picture->pict_type = AV_PICTURE_TYPE_I;
 +        if ((ret = decode_i_frame(f, f->current_picture, buf, frame_size)) < 0) {
 +            av_log(f->avctx, AV_LOG_ERROR, "decode i frame failed\n");
              return ret;
 +        }
      } else if (frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")) {
-         if (!f->last_picture->data[0]) {
-             if ((ret = ff_get_buffer(avctx, f->last_picture,
-                                      AV_GET_BUFFER_FLAG_REF)) < 0)
-                 return ret;
-             for (i=0; i<avctx->height; i++)
-                 memset(f->last_picture->data[0] + i*f->last_picture->linesize[0], 0, 2*avctx->width);
-         }
 -        picture->pict_type = AV_PICTURE_TYPE_P;
 -        if ((ret = decode_p_frame(f, picture, buf, frame_size)) < 0)
 +        f->current_picture->pict_type = AV_PICTURE_TYPE_P;
 +        if ((ret = decode_p_frame(f, f->current_picture, buf, frame_size)) < 0) {
 +            av_log(f->avctx, AV_LOG_ERROR, "decode p frame failed\n");
              return ret;
 +        }
      } else if (frame_4cc == AV_RL32("snd_")) {
          av_log(avctx, AV_LOG_ERROR, "ignoring snd_ chunk length:%d\n",
                 buf_size);