Mercurial > libavcodec.hg
comparison ffv1.c @ 1361:8479b875a989 libavcodec
golomb rice code cleanup / simplify (~0.5% compression gain and slightly faster)
jpegls style golomb rice coder
author | michaelni |
---|---|
date | Sun, 13 Jul 2003 11:06:45 +0000 |
parents | 047b1dff5976 |
children | 20a79b0e6d2a |
comparison
equal
deleted
inserted
replaced
1360:047b1dff5976 | 1361:8479b875a989 |
---|---|
298 k=0; | 298 k=0; |
299 while(i < state->error_sum){ //FIXME optimize | 299 while(i < state->error_sum){ //FIXME optimize |
300 k++; | 300 k++; |
301 i += i; | 301 i += i; |
302 } | 302 } |
303 | |
304 assert(k<=8); | |
305 | |
303 #if 0 // JPEG LS | 306 #if 0 // JPEG LS |
304 if(k==0 && 2*state->drift <= - state->count) code= v ^ (-1); | 307 if(k==0 && 2*state->drift <= - state->count) code= v ^ (-1); |
305 else code= v; | 308 else code= v; |
306 #else | 309 #else |
307 code= v ^ ((2*state->drift + state->count)>>31); | 310 code= v ^ ((2*state->drift + state->count)>>31); |
308 #endif | 311 #endif |
309 | 312 |
310 code = -2*code-1; | 313 code = -2*code-1; |
311 code^= (code>>31); | 314 code^= (code>>31); |
312 //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); | 315 //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); |
313 set_ur_golomb(pb, code, k, 8, 8); | 316 set_ur_golomb(pb, code, k, 12, 8); |
314 | 317 |
315 update_vlc_state(state, v); | 318 update_vlc_state(state, v); |
316 } | 319 } |
317 | 320 |
318 static inline int get_vlc_symbol(GetBitContext *gb, VlcState * const state){ | 321 static inline int get_vlc_symbol(GetBitContext *gb, VlcState * const state){ |
322 k=0; | 325 k=0; |
323 while(i < state->error_sum){ //FIXME optimize | 326 while(i < state->error_sum){ //FIXME optimize |
324 k++; | 327 k++; |
325 i += i; | 328 i += i; |
326 } | 329 } |
327 | 330 |
328 v= get_ur_golomb(gb, k, 8, 8); | 331 assert(k<=8); |
332 | |
333 v= get_ur_golomb(gb, k, 12, 8); | |
329 //printf("v:%d bias:%d error:%d drift:%d count:%d k:%d", v, state->bias, state->error_sum, state->drift, state->count, k); | 334 //printf("v:%d bias:%d error:%d drift:%d count:%d k:%d", v, state->bias, state->error_sum, state->drift, state->count, k); |
330 | 335 |
331 v++; | 336 v++; |
332 if(v&1) v= (v>>1); | 337 if(v&1) v= (v>>1); |
333 else v= -(v>>1); | 338 else v= -(v>>1); |
334 | 339 |
335 #if 0 // JPEG LS | 340 #if 0 // JPEG LS |