Commit 11e659c2 authored by Michael Niedermayer's avatar Michael Niedermayer

golomb rice codes

use gradients instead of prediction errors as context model
store independant quantization tables for each point
merge contexts with opposit sign

Originally committed as revision 1957 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 5dbafeb7
......@@ -15,8 +15,8 @@ extern "C" {
#define LIBAVCODEC_VERSION_INT 0x000406
#define LIBAVCODEC_VERSION "0.4.6"
#define LIBAVCODEC_BUILD 4668
#define LIBAVCODEC_BUILD_STR "4668"
#define LIBAVCODEC_BUILD 4669
#define LIBAVCODEC_BUILD_STR "4669"
#define LIBAVCODEC_IDENT "FFmpeg" LIBAVCODEC_VERSION "b" LIBAVCODEC_BUILD_STR
......@@ -1127,6 +1127,22 @@ typedef struct AVCodecContext {
* - decoding: unused
*/
int global_quality;
#define FF_CODER_TYPE_VLC 0
#define FF_CODER_TYPE_AC 1
/**
* coder type
* - encoding: set by user.
* - decoding: unused
*/
int coder_type;
/**
* context model
* - encoding: set by user.
* - decoding: unused
*/
int context_model;
} AVCodecContext;
......
This diff is collapsed.
......@@ -178,6 +178,37 @@ static inline int svq3_get_se_golomb(GetBitContext *gb){
}
}
/**
* read unsigned golomb rice code.
*/
static inline int get_ur_golomb(GetBitContext *gb, int k, int limit, int esc_len){
unsigned int buf;
int log;
OPEN_READER(re, gb);
UPDATE_CACHE(re, gb);
buf=GET_CACHE(re, gb);
log= av_log2(buf);
//printf("buf:%X log:%d\n", buf, log);
if(log > 31-limit){
buf >>= log - k;
buf += (30-log)<<k;
LAST_SKIP_BITS(re, gb, 32 + k - log);
CLOSE_READER(re, gb);
return buf;
}else if(log == 31-limit){
buf >>= log - esc_len;
buf -= 1<<esc_len;
LAST_SKIP_BITS(re, gb, esc_len + limit + 1);
CLOSE_READER(re, gb);
return buf + 1;
}else
return -1;
}
#ifdef TRACE
static inline int get_ue(GetBitContext *s, char *file, char *func, int line){
......@@ -279,3 +310,22 @@ static inline void set_se_golomb(PutBitContext *pb, int i){
#endif
set_ue_golomb(pb, i);
}
/**
* write unsigned golomb rice code.
*/
static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit, int esc_len){
int e;
assert(i>=0);
e= i>>k;
if(e<limit){
put_bits(pb, e + k + 1, (1<<k) + (i&((1<<k)-1)));
}else{
// printf("set %08X, %d\n", (1<<esc_len) + i - 1, limit + esc_len + 1);
put_bits(pb, limit + esc_len + 1, (1<<esc_len) + i - 1);
// put_bits(pb, 1, limit + 1);
// put_bits(pb, i - 1, esc_len);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment