Merge commit 'a1599f3f7ea8478d1f6a95e59e3bc6bc86d5f812'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 6 Aug 2014 23:29:42 +0000 (01:29 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 6 Aug 2014 23:45:22 +0000 (01:45 +0200)
* commit 'a1599f3f7ea8478d1f6a95e59e3bc6bc86d5f812':
  cdgraphics: switch to bytestream2

Conflicts:
libavcodec/cdgraphics.c

See: ad002e1a13a8df934bd6cb2c84175a4780ab8942
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/cdgraphics.c

@@@ -269,29 -269,22 +269,29 @@@ static int cdg_decode_frame(AVCodecCont
      AVFrame *frame = data;
      CDGraphicsContext *cc = avctx->priv_data;
  
 -    bytestream2_init(&gb, avpkt->data, avpkt->size);
 +    if (buf_size < CDG_MINIMUM_PKT_SIZE) {
 +        av_log(avctx, AV_LOG_ERROR, "buffer too small for decoder\n");
 +        return AVERROR(EINVAL);
 +    }
 +    if (buf_size > CDG_HEADER_SIZE + CDG_DATA_SIZE) {
 +        av_log(avctx, AV_LOG_ERROR, "buffer too big for decoder\n");
 +        return AVERROR(EINVAL);
 +    }
  
 -    ret = ff_reget_buffer(avctx, cc->frame);
 -    if (ret) {
 -        av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
++    bytestream2_init(&gb, avpkt->data, avpkt->size);
 +    if ((ret = ff_reget_buffer(avctx, cc->frame)) < 0)
          return ret;
 -    }
 -    if (!avctx->frame_number)
 +    if (!avctx->frame_number) {
          memset(cc->frame->data[0], 0, cc->frame->linesize[0] * avctx->height);
 +        memset(cc->frame->data[1], 0, AVPALETTE_SIZE);
 +    }
  
-     command = bytestream_get_byte(&buf);
-     inst    = bytestream_get_byte(&buf);
+     command = bytestream2_get_byte(&gb);
+     inst    = bytestream2_get_byte(&gb);
      inst    &= CDG_MASK;
-     buf += 2;  /// skipping 2 unneeded bytes
-     if (buf_size > CDG_HEADER_SIZE)
-         bytestream_get_buffer(&buf, cdg_data, buf_size - CDG_HEADER_SIZE);
+     bytestream2_skip(&gb, 2);
+     bytestream2_get_buffer(&gb, cdg_data, sizeof(cdg_data));
  
      if ((command & CDG_MASK) == CDG_COMMAND) {
          switch (inst) {