Merge commit '146b187113e3cc20c2a97c5f264da13e701ca247' into release/1.1
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 8 Aug 2014 12:45:18 +0000 (14:45 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 8 Aug 2014 12:54:53 +0000 (14:54 +0200)
* commit '146b187113e3cc20c2a97c5f264da13e701ca247':
  lavc: Check the image size before calling get_buffer

Conflicts:
libavcodec/utils.c

See: 668494acd8b20f974c7722895d4a6a14c1005f1e
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/utils.c

@@@ -507,40 -461,27 +507,45 @@@ int avcodec_default_get_buffer(AVCodecC
      }
  }
  
 -int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
 +void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame)
  {
 -    switch (avctx->codec_type) {
 +    if (s->pkt) {
 +        frame->pkt_pts = s->pkt->pts;
 +        frame->pkt_pos = s->pkt->pos;
 +        frame->pkt_duration = s->pkt->duration;
 +        frame->pkt_size = s->pkt->size;
 +    } else {
 +        frame->pkt_pts = AV_NOPTS_VALUE;
 +        frame->pkt_pos = -1;
 +        frame->pkt_duration = 0;
 +        frame->pkt_size = -1;
 +    }
 +    frame->reordered_opaque = s->reordered_opaque;
 +
 +    switch (s->codec->type) {
      case AVMEDIA_TYPE_VIDEO:
 -        if (av_image_check_size(avctx->width, avctx->height, 0, avctx))
 -             return AVERROR_INVALIDDATA;
 -        frame->width               = avctx->width;
 -        frame->height              = avctx->height;
 -        frame->format              = avctx->pix_fmt;
 -        frame->sample_aspect_ratio = avctx->sample_aspect_ratio;
 +        frame->width               = s->width;
 +        frame->height              = s->height;
 +        frame->format              = s->pix_fmt;
 +        frame->sample_aspect_ratio = s->sample_aspect_ratio;
          break;
      case AVMEDIA_TYPE_AUDIO:
 -        frame->sample_rate    = avctx->sample_rate;
 -        frame->format         = avctx->sample_fmt;
 -        frame->channel_layout = avctx->channel_layout;
 +        frame->sample_rate    = s->sample_rate;
 +        frame->format         = s->sample_fmt;
 +        frame->channel_layout = s->channel_layout;
 +        frame->channels       = s->channels;
          break;
 -    default: return AVERROR(EINVAL);
 +    }
 +}
 +
 +int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
 +{
++    if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
++        if (av_image_check_size(avctx->width, avctx->height, 0, avctx))
++            return AVERROR_INVALIDDATA;
+     }
 -    frame->pkt_pts = avctx->pkt ? avctx->pkt->pts : AV_NOPTS_VALUE;
 -    frame->reordered_opaque = avctx->reordered_opaque;
 +    ff_init_buffer_info(avctx, frame);
  
      return avctx->get_buffer(avctx, frame);
  }