]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/scpr.c
avcodec/prosumer: Remove unneeded ()
[ffmpeg] / libavcodec / scpr.c
index ee6bf21b71e6b951529ed2ea499b3c1658d517cf..e41fbbec13c7b9051f6589125011a38b6678dd3b 100644 (file)
@@ -136,7 +136,7 @@ static int decode(GetByteContext *gb, RangeCoder *rc, unsigned cumFreq, unsigned
     rc->range *= freq;
 
     while (rc->range < TOP && bytestream2_get_bytes_left(gb) > 0) {
-        unsigned byte = bytestream2_get_byte(gb);
+        unsigned byte = bytestream2_get_byteu(gb);
         rc->code = (rc->code << 8) | byte;
         rc->range <<= 8;
     }
@@ -172,7 +172,7 @@ static int decode0(GetByteContext *gb, RangeCoder *rc, unsigned cumFreq, unsigne
     rc->range = rc->range * (uint64_t)(freq + cumFreq) / total_freq - (t + 1);
 
     while (rc->range < TOP && bytestream2_get_bytes_left(gb) > 0) {
-        unsigned byte = bytestream2_get_byte(gb);
+        unsigned byte = bytestream2_get_byteu(gb);
         rc->code = (rc->code << 8) | byte;
         rc->code1 <<= 8;
         rc->range <<= 8;
@@ -516,7 +516,7 @@ static int decompress_p(AVCodecContext *avctx,
     int backstep = linesize - avctx->width;
 
     if (bytestream2_get_byte(gb) == 0)
-        return 0;
+        return 1;
     bytestream2_skip(gb, 1);
     init_rangecoder(&s->rc, gb);
 
@@ -529,7 +529,7 @@ static int decompress_p(AVCodecContext *avctx,
         return ret;
 
     max += temp << 8;
-    if (min > max)
+    if (min > max || min >= s->nbcount)
         return AVERROR_INVALIDDATA;
 
     memset(s->blocks, 0, sizeof(*s->blocks) * s->nbcount);
@@ -541,6 +541,8 @@ static int decompress_p(AVCodecContext *avctx,
         ret |= decode_value(s, s->count_model, 256, 20, &count);
         if (ret < 0)
             return ret;
+        if (count <= 0)
+            return AVERROR_INVALIDDATA;
 
         while (min < s->nbcount && count-- > 0) {
             s->blocks[min++] = fill;
@@ -811,6 +813,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
                            s->current_frame->linesize[0] / 4,
                            (uint32_t *)s->last_frame->data[0],
                            s->last_frame->linesize[0] / 4);
+        if (ret == 1)
+            return avpkt->size;
     } else {
         return AVERROR_PATCHWELCOME;
     }