]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dirac_arith.h
avfilter/avfilter: Remove compatibility code for old filter options
[ffmpeg] / libavcodec / dirac_arith.h
index 24a7ca390e704bec11e8f45435ff95b370f809b2..350a58fca6b44beacd49309372a0bafa721c635b 100644 (file)
@@ -81,10 +81,11 @@ typedef struct {
     const uint8_t *bytestream_end;
 
     uint16_t contexts[DIRAC_CTX_COUNT];
+    int error;
+    int overread;
 } DiracArith;
 
 extern const uint8_t ff_dirac_next_ctx[DIRAC_CTX_COUNT];
-extern const uint16_t ff_dirac_prob[256];
 extern int16_t ff_dirac_prob_branchless[256][2];
 
 static inline void renorm(DiracArith *c)
@@ -118,6 +119,9 @@ static inline void refill(DiracArith *c)
                 new |= 0xff00;
 
             c->bytestream = c->bytestream_end;
+            c->overread ++;
+            if (c->overread > 4)
+                c->error = AVERROR_INVALIDDATA;
         }
 
         c->low += new << counter;
@@ -173,6 +177,7 @@ static inline int dirac_get_arith_uint(DiracArith *c, int follow_ctx, int data_c
     while (!dirac_get_arith_bit(c, follow_ctx)) {
         if (ret >= 0x40000000) {
             av_log(NULL, AV_LOG_ERROR, "dirac_get_arith_uint overflow\n");
+            c->error = AVERROR_INVALIDDATA;
             return -1;
         }
         ret <<= 1;