aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/h263.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-09-24 20:35:59 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-09-24 20:35:59 +0000
commit15c5fa7b7f63c81e6c7cd987ab10d9bc8b1fb557 (patch)
tree29497d86f606b3cb222fc3f54da1806239b1e4b3 /libavcodec/h263.c
parentd7d51926dde9732650788b170dbcf964f44235e3 (diff)
downloadffmpeg-15c5fa7b7f63c81e6c7cd987ab10d9bc8b1fb557.tar.gz
trellis quantization for h263(p)
Originally committed as revision 3503 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/h263.c')
-rw-r--r--libavcodec/h263.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index f7421ca0c6..922cb1f3b4 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -91,6 +91,8 @@ static uint32_t uni_mpeg4_intra_rl_bits[64*64*2*2];
static uint8_t uni_mpeg4_intra_rl_len [64*64*2*2];
static uint32_t uni_mpeg4_inter_rl_bits[64*64*2*2];
static uint8_t uni_mpeg4_inter_rl_len [64*64*2*2];
+static uint8_t uni_h263_intra_aic_rl_len [64*64*2*2];
+static uint8_t uni_h263_inter_rl_len [64*64*2*2];
//#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128 + (run)*256 + (level))
//#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run) + (level)*64)
#define UNI_MPEG4_ENC_INDEX(last,run,level) ((last)*128*64 + (run)*128 + (level))
@@ -1876,6 +1878,50 @@ static void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_
}
}
+static void init_uni_h263_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab){
+ int slevel, run, last;
+
+ assert(MAX_LEVEL >= 64);
+ assert(MAX_RUN >= 63);
+
+ for(slevel=-64; slevel<64; slevel++){
+ if(slevel==0) continue;
+ for(run=0; run<64; run++){
+ for(last=0; last<=1; last++){
+ const int index= UNI_MPEG4_ENC_INDEX(last, run, slevel+64);
+ int level= slevel < 0 ? -slevel : slevel;
+ int sign= slevel < 0 ? 1 : 0;
+ int bits, len, code;
+ int level1, run1;
+
+ len_tab[index]= 100;
+
+ /* ESC0 */
+ code= get_rl_index(rl, last, run, level);
+ bits= rl->table_vlc[code][0];
+ len= rl->table_vlc[code][1];
+ bits=bits*2+sign; len++;
+
+ if(code!=rl->n && len < len_tab[index]){
+ if(bits_tab) bits_tab[index]= bits;
+ len_tab [index]= len;
+ }
+ /* ESC */
+ bits= rl->table_vlc[rl->n][0];
+ len = rl->table_vlc[rl->n][1];
+ bits=bits*2+last; len++;
+ bits=bits*64+run; len+=6;
+ bits=bits*256+(level&0xff); len+=8;
+
+ if(len < len_tab[index]){
+ if(bits_tab) bits_tab[index]= bits;
+ len_tab [index]= len;
+ }
+ }
+ }
+ }
+}
+
void h263_encode_init(MpegEncContext *s)
{
static int done = 0;
@@ -1892,10 +1938,21 @@ void h263_encode_init(MpegEncContext *s)
init_uni_mpeg4_rl_tab(&rl_intra, uni_mpeg4_intra_rl_bits, uni_mpeg4_intra_rl_len);
init_uni_mpeg4_rl_tab(&rl_inter, uni_mpeg4_inter_rl_bits, uni_mpeg4_inter_rl_len);
+ init_uni_h263_rl_tab(&rl_intra_aic, NULL, uni_h263_intra_aic_rl_len);
+ init_uni_h263_rl_tab(&rl_inter , NULL, uni_h263_inter_rl_len);
+
init_mv_penalty_and_fcode(s);
}
s->me.mv_penalty= mv_penalty; //FIXME exact table for msmpeg4 & h263p
+ s->intra_ac_vlc_length =s->inter_ac_vlc_length = uni_h263_inter_rl_len;
+ s->intra_ac_vlc_last_length=s->inter_ac_vlc_last_length= uni_h263_inter_rl_len + 128*64;
+ if(s->h263_aic){
+ s->intra_ac_vlc_length = uni_h263_intra_aic_rl_len;
+ s->intra_ac_vlc_last_length= uni_h263_intra_aic_rl_len + 128*64;
+ }
+ s->ac_esc_length= 7+1+6+8;
+
// use fcodes >1 only for mpeg4 & h263 & h263p FIXME
switch(s->codec_id){
case CODEC_ID_MPEG4: