mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
new signed golomb routines
Originally committed as revision 3444 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
b2a1c77162
commit
4579adb00c
@ -324,10 +324,8 @@ static inline void put_vlc_symbol(PutBitContext *pb, VlcState * const state, int
|
||||
code= v ^ ((2*state->drift + state->count)>>31);
|
||||
#endif
|
||||
|
||||
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, 12, bits);
|
||||
set_sr_golomb_ffv1(pb, code, k, 12, bits);
|
||||
|
||||
update_vlc_state(state, v);
|
||||
}
|
||||
@ -344,13 +342,9 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState * const state, int
|
||||
|
||||
assert(k<=8);
|
||||
|
||||
v= get_ur_golomb(gb, k, 12, bits);
|
||||
v= get_sr_golomb_ffv1(gb, k, 12, bits);
|
||||
//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);
|
||||
|
||||
#if 0 // JPEG LS
|
||||
if(k==0 && 2*state->drift <= - state->count) v ^= (-1);
|
||||
#else
|
||||
|
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* exp golomb vlc stuff
|
||||
* Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
|
||||
* Copyright (c) 2004 Alex Beregszaszi
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -22,7 +23,7 @@
|
||||
* @file golomb.h
|
||||
* @brief
|
||||
* exp golomb vlc stuff
|
||||
* @author Michael Niedermayer <michaelni@gmx.at>
|
||||
* @author Michael Niedermayer <michaelni@gmx.at> and Alex Beregszaszi
|
||||
*/
|
||||
|
||||
#define INVALID_VLC 0x80000000
|
||||
@ -260,13 +261,37 @@ static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit, int
|
||||
}
|
||||
|
||||
/**
|
||||
* read unsigned golomb rice code (flac).
|
||||
* read signed golomb rice code (ffv1).
|
||||
*/
|
||||
static inline int get_sr_golomb_ffv1(GetBitContext *gb, int k, int limit, int esc_len){
|
||||
int v= get_ur_golomb(gb, k, limit, esc_len);
|
||||
|
||||
v++;
|
||||
if (v&1) return v>>1;
|
||||
else return -(v>>1);
|
||||
|
||||
// return (v>>1) ^ -(v&1);
|
||||
}
|
||||
/**
|
||||
|
||||
* read signed golomb rice code (flac).
|
||||
*/
|
||||
static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit, int esc_len){
|
||||
int v= get_ur_golomb_jpegls(gb, k, limit, esc_len);
|
||||
return (v>>1) ^ -(v&1);
|
||||
}
|
||||
|
||||
/**
|
||||
* read signed golomb rice code (sonic).
|
||||
*/
|
||||
static inline int get_sr_golomb_sonic(GetBitContext *gb, int k, int limit, int esc_len){
|
||||
int v= get_ur_golomb(gb, k, limit, esc_len);
|
||||
|
||||
v++;
|
||||
if (v&1) return -(v>>1);
|
||||
else return v>>1;
|
||||
}
|
||||
|
||||
#ifdef TRACE
|
||||
|
||||
static inline int get_ue(GetBitContext *s, char *file, char *func, int line){
|
||||
@ -278,7 +303,7 @@ static inline int get_ue(GetBitContext *s, char *file, char *func, int line){
|
||||
|
||||
print_bin(bits, len);
|
||||
|
||||
printf("%5d %2d %3d ue @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
|
||||
av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d ue @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
|
||||
|
||||
return i;
|
||||
}
|
||||
@ -292,7 +317,7 @@ static inline int get_se(GetBitContext *s, char *file, char *func, int line){
|
||||
|
||||
print_bin(bits, len);
|
||||
|
||||
printf("%5d %2d %3d se @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
|
||||
av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d se @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
|
||||
|
||||
return i;
|
||||
}
|
||||
@ -306,7 +331,7 @@ static inline int get_te(GetBitContext *s, int r, char *file, char *func, int li
|
||||
|
||||
print_bin(bits, len);
|
||||
|
||||
printf("%5d %2d %3d te @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
|
||||
av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d te @%5d in %s %s:%d\n", bits, len, i, pos, file, func, line);
|
||||
|
||||
return i;
|
||||
}
|
||||
@ -403,3 +428,39 @@ static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k, int lim
|
||||
put_bits(pb, esc_len, i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* write signed golomb rice code (ffv1).
|
||||
*/
|
||||
static inline void set_sr_golomb_ffv1(PutBitContext *pb, int i, int k, int limit, int esc_len){
|
||||
int v;
|
||||
|
||||
v = -2*i-1;
|
||||
v ^= (v>>31);
|
||||
|
||||
set_ur_golomb(pb, v, k, limit, esc_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* write signed golomb rice code (flac).
|
||||
*/
|
||||
static inline void set_sr_golomb_flac(PutBitContext *pb, int i, int k, int limit, int esc_len){
|
||||
int v;
|
||||
|
||||
v = -2*i-1;
|
||||
v ^= (v>>31);
|
||||
|
||||
set_ur_golomb_jpegls(pb, v, k, limit, esc_len);
|
||||
}
|
||||
|
||||
/**
|
||||
* write signed golomb rice code (sonic).
|
||||
*/
|
||||
static inline void set_sr_golomb_sonic(PutBitContext *pb, int i, int k, int limit, int esc_len){
|
||||
int v;
|
||||
|
||||
v = 2*i-1;
|
||||
if (v<0) v ^= -1;
|
||||
|
||||
set_ur_golomb(pb, v, k, limit, esc_len);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user