]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ffv1.c
move mmx quantizer matrixes out of MpegEncContext (23k -> 7k) (no meassureable slowdown)
[ffmpeg] / libavcodec / ffv1.c
index 7e6f18e7a36e1ad904baf6539b74ac48985fb001..2ff994e53d658d45a7b410decfbf1db7dca76be9 100644 (file)
@@ -21,7 +21,7 @@
  
 /**
  * @file ffv1.c
- * FF Video Codec 1 (a experimental lossless codec)
+ * FF Video Codec 1 (an experimental lossless codec)
  */
 
 #include "common.h"
@@ -185,10 +185,8 @@ static inline int predict(uint8_t *src, uint8_t *last){
     const int LT= last[-1];
     const int  T= last[ 0];
     const int L =  src[-1];
-    uint8_t *cm = cropTbl + MAX_NEG_CROP;    
-    const int gradient= cm[L + T - LT];
 
-    return mid_pred(L, gradient, T);
+    return mid_pred(L, L + T - LT, T);
 }
 
 static inline int get_context(FFV1Context *f, uint8_t *src, uint8_t *last, uint8_t *last2){
@@ -302,6 +300,9 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState * const state, int
         k++;
         i += i;
     }
+
+    assert(k<=8);
+
 #if 0 // JPEG LS
     if(k==0 && 2*state->drift <= - state->count) code= v ^ (-1);
     else                                         code= v;
@@ -312,7 +313,7 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState * const state, int
     code = -2*code-1;
     code^= (code>>31);
 //printf("v:%d/%d bias:%d error:%d drift:%d count:%d k:%d\n", v, code, state->bias, state->error_sum, state->drift, state->count, k);
-    set_ur_golomb(pb, code, k, 8, 8);
+    set_ur_golomb(pb, code, k, 12, 8);
 
     update_vlc_state(state, v);
 }
@@ -326,10 +327,12 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState * const state){
         k++;
         i += i;
     }
-    
-    v= get_ur_golomb(gb, k, 8, 8);
+
+    assert(k<=8);
+
+    v= get_ur_golomb(gb, k, 12, 8);
 //printf("v:%d bias:%d error:%d drift:%d count:%d k:%d", v, state->bias, state->error_sum, state->drift, state->count, k);
-    
+
     v++;
     if(v&1) v=  (v>>1);
     else    v= -(v>>1);
@@ -596,7 +599,7 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size,
     if(!f->ac){
         used_count += put_cabac_terminate(c, 1);
 //printf("pos=%d\n", used_count);
-        init_put_bits(&f->pb, buf + used_count, buf_size - used_count, NULL, NULL);
+        init_put_bits(&f->pb, buf + used_count, buf_size - used_count);
     }
     
     if(1){
@@ -862,6 +865,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
         if(bytes_read ==0) printf("error at end of AC stream\n");
 //printf("pos=%d\n", bytes_read);
         init_get_bits(&f->gb, buf + bytes_read, buf_size - bytes_read);
+    } else {
+        bytes_read = 0; /* avoid warning */
     }
     
     if(1){