]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit 'a1c525f7eb0783d31ba7a653865b6cbd3dc880de'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 14 Jan 2013 13:36:17 +0000 (14:36 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 14 Jan 2013 13:43:32 +0000 (14:43 +0100)
* commit 'a1c525f7eb0783d31ba7a653865b6cbd3dc880de':
  pcx: return meaningful error codes.
  tmv: return meaningful error codes.
  msrle: return meaningful error codes.
  cscd: return meaningful error codes.
  yadif: x86: fix build for compilers without aligned stack
  lavc: introduce the convenience function init_get_bits8
  lavc: check for overflow in init_get_bits

Conflicts:
libavcodec/cscd.c
libavcodec/pcx.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/cscd.c
libavcodec/get_bits.h
libavcodec/msrle.c
libavcodec/pcx.c
libavcodec/tmv.c
libavfilter/x86/yadif.asm

index e7ebb37f58afb9ded569378dc1b4166d2289a1df,b982f5029c6a01405690c047a7cb2d2c5a6207eb..110b06fa2ba962f21509bd5c3231f0d91b75dd73
@@@ -71,15 -147,17 +72,15 @@@ static int decode_frame(AVCodecContext 
  
      if (buf_size < 2) {
          av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
-         return -1;
+         return AVERROR_INVALIDDATA;
      }
  
 -    if (c->pic.data[0])
 -        avctx->release_buffer(avctx, &c->pic);
 -    c->pic.reference = 1;
 +    c->pic.reference = 3;
      c->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_READABLE |
                            FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
-     if (avctx->reget_buffer(avctx, &c->pic) < 0) {
 -    if ((ret = ff_get_buffer(avctx, &c->pic)) < 0) {
++    if ((ret = avctx->reget_buffer(avctx, &c->pic)) < 0) {
          av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
-         return -1;
+         return ret;
      }
  
      // decompress data
index 777176dd30ffef3bd48695d066bd2b554d7b1225,12770a29a0e1c69602be8e6b19a9630fd18f97af..af7e156e59bf146b22d5b0014345126374dac5e4
@@@ -366,25 -362,51 +366,49 @@@ static inline int check_marker(GetBitCo
  }
  
  /**
-  * Inititalize GetBitContext.
-  * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger than the actual read bits
-  * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
+  * Initialize GetBitContext.
+  * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes
+  *        larger than the actual read bits because some optimized bitstream
+  *        readers read 32 or 64 bit at once and could read over the end
   * @param bit_size the size of the buffer in bits
+  * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
   */
- static inline void init_get_bits(GetBitContext *s, const uint8_t *buffer,
-                                  int bit_size)
+ static inline int init_get_bits(GetBitContext *s, const uint8_t *buffer,
+                                 int bit_size)
  {
-     int buffer_size = (bit_size+7)>>3;
-     if (buffer_size < 0 || bit_size < 0) {
+     int buffer_size;
+     int ret = 0;
 -    if (bit_size > INT_MAX - 7 || bit_size <= 0) {
++    if (bit_size > INT_MAX - 7 || bit_size < 0) {
          buffer_size = bit_size = 0;
          buffer = NULL;
+         ret = AVERROR_INVALIDDATA;
      }
  
+     buffer_size = (bit_size + 7) >> 3;
      s->buffer       = buffer;
      s->size_in_bits = bit_size;
 -#if !UNCHECKED_BITSTREAM_READER
      s->size_in_bits_plus8 = bit_size + 8;
 -#endif
      s->buffer_end   = buffer + buffer_size;
      s->index        = 0;
+     return ret;
+ }
+ /**
+  * Initialize GetBitContext.
+  * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes
+  *        larger than the actual read bits because some optimized bitstream
+  *        readers read 32 or 64 bit at once and could read over the end
+  * @param byte_size the size of the buffer in bytes
+  * @return 0 on success, AVERROR_INVALIDDATA if the buffer_size would overflow.
+  */
+ static inline int init_get_bits8(GetBitContext *s, const uint8_t *buffer,
+                                  int byte_size)
+ {
+     if (byte_size > INT_MAX / 8)
+         return AVERROR_INVALIDDATA;
+     return init_get_bits(s, buffer, byte_size * 8);
  }
  
  static inline void align_get_bits(GetBitContext *s)
index 5b7ba7fdad4b30bce2c1afcacf9d643ae997cbd2,7bca67f42e7054244840f06dca39281c13b2ae17..5c1fb5c32a023725d04797fbec26151167a2d80c
@@@ -67,16 -63,11 +67,16 @@@ static av_cold int msrle_decode_init(AV
          break;
      default:
          av_log(avctx, AV_LOG_ERROR, "unsupported bits per sample\n");
-         return -1;
+         return AVERROR_INVALIDDATA;
      }
  
 +    avcodec_get_frame_defaults(&s->frame);
      s->frame.data[0] = NULL;
  
 +    if (avctx->extradata_size >= 4)
 +        for (i = 0; i < FFMIN(avctx->extradata_size, AVPALETTE_SIZE)/4; i++)
 +            s->pal[i] = 0xFFU<<24 | AV_RL32(avctx->extradata+4*i);
 +
      return 0;
  }
  
@@@ -92,14 -84,14 +93,14 @@@ static int msrle_decode_frame(AVCodecCo
      s->buf = buf;
      s->size = buf_size;
  
 -    s->frame.reference = 1;
 +    s->frame.reference = 3;
      s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
-     if (avctx->reget_buffer(avctx, &s->frame)) {
+     if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0) {
          av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
-         return -1;
+         return ret;
      }
  
 -    if (avctx->bits_per_coded_sample <= 8) {
 +    if (avctx->bits_per_coded_sample > 1 && avctx->bits_per_coded_sample <= 8) {
          const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
  
          if (pal) {
Simple merge
Simple merge
Simple merge