Merge commit '0f21d8b1b40848973558c737aebe800c46e93a3d'
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 1 Nov 2013 14:25:09 +0000 (15:25 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 1 Nov 2013 14:25:09 +0000 (15:25 +0100)
* commit '0f21d8b1b40848973558c737aebe800c46e93a3d':
  pictordec: stop using deprecated avcodec_set_dimensions
  pgssubdec: stop using deprecated avcodec_set_dimensions
  pcx: stop using deprecated avcodec_set_dimensions
  mpegvideo_parser: stop using deprecated avcodec_set_dimensions

Conflicts:
libavcodec/pcx.c
libavcodec/pgssubdec.c
libavcodec/pictordec.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/mpegvideo_parser.c
libavcodec/pcx.c
libavcodec/pgssubdec.c
libavcodec/pictordec.c

@@@ -92,9 -88,9 +92,9 @@@ static void mpegvideo_extract_headers(A
  
                          pc->width  |=(horiz_size_ext << 12);
                          pc->height |=( vert_size_ext << 12);
 -                        avctx->bit_rate += (bit_rate_ext << 18) * 400;
 +                        bit_rate = (bit_rate&0x3FFFF) | (bit_rate_ext << 18);
                          if(did_set_size)
-                             avcodec_set_dimensions(avctx, pc->width, pc->height);
+                             ff_set_dimensions(avctx, pc->width, pc->height);
                          avctx->time_base.den = pc->frame_rate.den * (frame_rate_ext_n + 1) * 2;
                          avctx->time_base.num = pc->frame_rate.num * (frame_rate_ext_d + 1);
                          avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;
@@@ -130,14 -133,15 +130,13 @@@ static int pcx_decode_frame(AVCodecCont
          return AVERROR_INVALIDDATA;
      }
  
 -    buf += 128;
 +    bytestream2_skipu(&gb, 60);
  
-     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;
  
  #include "avcodec.h"
  #include "dsputil.h"
  #include "bytestream.h"
+ #include "internal.h"
  #include "libavutil/colorspace.h"
  #include "libavutil/imgutils.h"
 +#include "libavutil/opt.h"
  
  #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
  
@@@ -293,12 -272,15 +295,13 @@@ static void parse_palette_segment(AVCod
   * @param buf pointer to the packet to process
   * @param buf_size size of packet to process
   * @todo TODO: Implement cropping
 - * @todo TODO: Implement forcing of subtitles
   */
- static void parse_presentation_segment(AVCodecContext *avctx,
-                                        const uint8_t *buf, int buf_size,
-                                        int64_t pts)
+ static int parse_presentation_segment(AVCodecContext *avctx,
+                                       const uint8_t *buf, int buf_size,
+                                       int64_t pts)
  {
      PGSSubContext *ctx = avctx->priv_data;
 -
 -    int x, y, ret;
++    int ret;
  
      int w = bytestream_get_be16(&buf);
      int h = bytestream_get_be16(&buf);
       */
      buf += 3;
  
 -    ctx->presentation.object_number = bytestream_get_byte(&buf);
 -    ctx->presentation.composition_flag = 0;
 -    if (!ctx->presentation.object_number)
 +    ctx->presentation.object_count = bytestream_get_byte(&buf);
 +    if (!ctx->presentation.object_count)
-         return;
+         return 0;
  
 -    /*
 -     * Skip 3 bytes of unknown:
 -     *     object_id_ref (2 bytes),
 -     *     window_id_ref,
 -     */
 -    buf += 3;
 -    ctx->presentation.composition_flag = bytestream_get_byte(&buf);
 +    /* Verify that enough bytes are remaining for all of the objects. */
 +    buf_size -= 11;
 +    if (buf_size < ctx->presentation.object_count * 8) {
 +        ctx->presentation.object_count = 0;
-         return;
++        return AVERROR_INVALIDDATA;
 +    }
 +
 +    av_freep(&ctx->presentation.objects);
 +    ctx->presentation.objects = av_malloc(sizeof(PGSSubPictureReference) * ctx->presentation.object_count);
 +    if (!ctx->presentation.objects) {
 +        ctx->presentation.object_count = 0;
-         return;
++        return AVERROR(ENOMEM);
 +    }
  
 -    x = bytestream_get_be16(&buf);
 -    y = bytestream_get_be16(&buf);
 +    for (object_index = 0; object_index < ctx->presentation.object_count; ++object_index) {
 +        PGSSubPictureReference *reference = &ctx->presentation.objects[object_index];
 +        reference->picture_id             = bytestream_get_be16(&buf);
  
 -    /* TODO If cropping, cropping_x, cropping_y, cropping_width, cropping_height (all 2 bytes).*/
 +        /* Skip window_id_ref */
 +        buf++;
 +        /* composition_flag (0x80 - object cropped, 0x40 - object forced) */
 +        reference->composition = bytestream_get_byte(&buf);
  
 -    av_dlog(avctx, "Subtitle Placement x=%d, y=%d\n", x, y);
 +        reference->x = bytestream_get_be16(&buf);
 +        reference->y = bytestream_get_be16(&buf);
  
 -    if (x > avctx->width || y > avctx->height) {
 -        av_log(avctx, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
 -               x, y, avctx->width, avctx->height);
 -        x = 0; y = 0;
 -    }
 +        /* TODO If cropping, cropping_x, cropping_y, cropping_width, cropping_height (all 2 bytes).*/
 +        av_dlog(avctx, "Subtitle Placement ID=%d, x=%d, y=%d\n", reference->picture_id, reference->x, reference->y);
  
 -    /* Fill in dimensions */
 -    ctx->presentation.x = x;
 -    ctx->presentation.y = y;
 +        if (reference->x > avctx->width || reference->y > avctx->height) {
 +            av_log(avctx, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
 +                   reference->x, reference->y, avctx->width, avctx->height);
 +            reference->x = 0;
 +            reference->y = 0;
 +        }
 +    }
+     return 0;
  }
  
  /**
@@@ -495,7 -457,9 +501,9 @@@ static int decode(AVCodecContext *avctx
              parse_picture_segment(avctx, buf, segment_length);
              break;
          case PRESENTATION_SEGMENT:
-             parse_presentation_segment(avctx, buf, segment_length, sub->pts);
 -            ret = parse_presentation_segment(avctx, buf, segment_length, avpkt->pts);
++            ret = parse_presentation_segment(avctx, buf, segment_length, sub->pts);
+             if (ret < 0)
+                 return ret;
              break;
          case WINDOW_SEGMENT:
              /*
@@@ -140,14 -140,16 +140,16 @@@ static int decode_frame(AVCodecContext 
  
      avctx->pix_fmt = AV_PIX_FMT_PAL8;
  
 +    if (av_image_check_size(s->width, s->height, 0, avctx) < 0)
 +        return -1;
      if (s->width != avctx->width && s->height != avctx->height) {
-         avcodec_set_dimensions(avctx, s->width, s->height);
+         ret = ff_set_dimensions(avctx, s->width, s->height);
+         if (ret < 0)
+             return ret;
      }
  
 -    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
 -        av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
 +    if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
          return ret;
 -    }
      memset(frame->data[0], 0, s->height * frame->linesize[0]);
      frame->pict_type           = AV_PICTURE_TYPE_I;
      frame->palette_has_changed = 1;