]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/faxcompr.c
Fix a typo in the documentation.
[ffmpeg] / libavcodec / faxcompr.c
index 54428e7d8cfa831e23b7346f6d8263bab41f2bde..9a9d1f55286a1dbfdd685f3674135d1dd80ef92f 100644 (file)
 
 /**
  * CCITT Fax Group 3 and 4 decompression
- * @file faxcompr.c
+ * @file libavcodec/faxcompr.c
  * @author Konstantin Shishkov
  */
 #include "avcodec.h"
-#include "bitstream.h"
+#include "get_bits.h"
+#include "put_bits.h"
 #include "faxcompr.h"
 
 #define CCITT_SYMS 104
@@ -95,7 +96,7 @@ static const uint8_t ccitt_group3_2d_lens[11] = {
 
 static VLC ccitt_vlc[2], ccitt_group3_2d_vlc;
 
-av_cold void ff_ccitt_unpack_init()
+av_cold void ff_ccitt_unpack_init(void)
 {
     static VLC_TYPE code_table1[528][2];
     static VLC_TYPE code_table2[648][2];
@@ -156,10 +157,11 @@ static int decode_group3_1d_line(AVCodecContext *avctx, GetBitContext *gb,
 }
 
 static int decode_group3_2d_line(AVCodecContext *avctx, GetBitContext *gb,
-                                 int width, int *runs, const int *runend, const int *ref)
+                                 unsigned int width, int *runs, const int *runend, const int *ref)
 {
-    int mode = 0, offs = 0, run = 0, saved_run = 0, t;
+    int mode = 0, saved_run = 0, t;
     int run_off = *ref++;
+    unsigned int offs=0, run= 0;
 
     runend--; // for the last written 0
 
@@ -200,7 +202,7 @@ static int decode_group3_2d_line(AVCodecContext *avctx, GetBitContext *gb,
                 }
                 saved_run = 0;
                 offs += run;
-                if(offs > width){
+                if(offs > width || run > width){
                     av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n");
                     return -1;
                 }
@@ -211,12 +213,9 @@ static int decode_group3_2d_line(AVCodecContext *avctx, GetBitContext *gb,
             return -1;
         }else{//vertical mode
             run = run_off - offs + (cmode - 5);
-            if(cmode >= 5)
-                run_off += *ref++;
-            else
-                run_off -= *--ref;
+            run_off -= *--ref;
             offs += run;
-            if(offs > width){
+            if(offs > width || run > width){
                 av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n");
                 return -1;
             }