Hi,
2012/1/4 Jason Garrett-Glaser <[email protected]>:
> + if(!code || code==27 || code==54 || code==81){
>
> Can't you use modulo_three_table for this?
You mean, like in check_modulo_three_table.diff? (only relevant change present)
I'm contemplating cutting some work in that path by extracting from
the modulo_three_table a tweaked module_27_table (instead of
duplicating it and adding an extra 108b table) as in the
split_and_check.diff
The later is more intrusive, and both don't make a difference in
speed, so it's more about judging on face value.
Best regards,
Christophe
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 8b2a813..b901ea4 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -300,13 +300,15 @@ static inline int rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rv
pattern = code & 0x7;
code >>= 3;
- if(!code || code==27 || code==54 || code==81){
+ //if(AV_RB24(modulo_three_table[code]+1)){
+ if(AV_RB32(modulo_three_table[code])&0xFFFFFF){
+ decode_subblock3(dst, code, 0, gb, &rvlc->coefficient, q_dc, q_ac1, q_ac2);
+ } else {
decode_subblock1(dst, code, gb, &rvlc->coefficient, q_dc);
if (!pattern)
return 0;
has_ac = 0;
- } else
- decode_subblock3(dst, code, 0, gb, &rvlc->coefficient, q_dc, q_ac1, q_ac2);
+ }
if(pattern & 4){
code = get_vlc2(gb, rvlc->second_pattern[sc].table, 9, 2);
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 8b2a813..37ce231 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -199,8 +199,14 @@ static int rv34_decode_cbp(GetBitContext *gb, RV34VLC *vlc, int table)
cbp |= get_vlc2(gb, vlc->cbp[table][ones].table, vlc->cbp[table][ones].bits, 1) << curshift[0];
}
- for(i = 0; i < 4; i++){
- t = modulo_three_table[code][i];
+ t = modulo_27_table[code]&3;
+ if(t == 1)
+ cbp |= cbp_masks[get_bits1(gb)];
+ if(t == 2)
+ cbp |= cbp_masks[2];
+
+ for(i = 1; i < 4; i++){
+ t = modulo_three_table[code][i-1];
if(t == 1)
cbp |= cbp_masks[get_bits1(gb)] << i;
if(t == 2)
@@ -236,10 +242,10 @@ static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2,
{
int coeffs[4];
- coeffs[0] = modulo_three_table[code][0];
- coeffs[1] = modulo_three_table[code][1];
- coeffs[2] = modulo_three_table[code][2];
- coeffs[3] = modulo_three_table[code][3];
+ coeffs[0] = modulo_27_table[code]&3;
+ coeffs[1] = modulo_three_table[code][0];
+ coeffs[2] = modulo_three_table[code][1];
+ coeffs[3] = modulo_three_table[code][2];
decode_coeff(dst , coeffs[0], 3, gb, vlc, q);
if(is_block2){
decode_coeff(dst+4, coeffs[1], 2, gb, vlc, q);
@@ -251,24 +257,15 @@ static inline void decode_subblock(DCTELEM *dst, int code, const int is_block2,
decode_coeff(dst+5, coeffs[3], 2, gb, vlc, q);
}
-/**
- * Decode a single coefficient.
- */
-static inline void decode_subblock1(DCTELEM *dst, int code, GetBitContext *gb, VLC *vlc, int q)
-{
- int coeff = modulo_three_table[code][0];
- decode_coeff(dst, coeff, 3, gb, vlc, q);
-}
-
static inline void decode_subblock3(DCTELEM *dst, int code, const int is_block2, GetBitContext *gb, VLC *vlc,
int q_dc, int q_ac1, int q_ac2)
{
int coeffs[4];
- coeffs[0] = modulo_three_table[code][0];
- coeffs[1] = modulo_three_table[code][1];
- coeffs[2] = modulo_three_table[code][2];
- coeffs[3] = modulo_three_table[code][3];
+ coeffs[0] = modulo_27_table[code]&3;
+ coeffs[1] = modulo_three_table[code][0];
+ coeffs[2] = modulo_three_table[code][1];
+ coeffs[3] = modulo_three_table[code][2];
decode_coeff(dst , coeffs[0], 3, gb, vlc, q_dc);
if(is_block2){
decode_coeff(dst+4, coeffs[1], 2, gb, vlc, q_ac1);
@@ -293,15 +290,16 @@ static inline void decode_subblock3(DCTELEM *dst, int code, const int is_block2,
static inline int rv34_decode_block(DCTELEM *dst, GetBitContext *gb, RV34VLC *rvlc, int fc, int sc, int q_dc, int q_ac1, int q_ac2)
{
- int code, pattern, has_ac = 1;
+ int coeff, code, pattern, has_ac = 1;
code = get_vlc2(gb, rvlc->first_pattern[fc].table, 9, 2);
pattern = code & 0x7;
code >>= 3;
- if(!code || code==27 || code==54 || code==81){
- decode_subblock1(dst, code, gb, &rvlc->coefficient, q_dc);
+ coeff = modulo_27_table[code];
+ if(coeff&4){
+ decode_coeff(dst, coeff, 3, gb, &rvlc->coefficient, q_dc);
if (!pattern)
return 0;
has_ac = 0;
diff --git a/libavcodec/rv34data.h b/libavcodec/rv34data.h
index fa41a88..931a177 100644
--- a/libavcodec/rv34data.h
+++ b/libavcodec/rv34data.h
@@ -44,40 +44,47 @@ static const uint8_t rv34_cbp_code[16] = {
0x01, 0x21, 0x11, 0x31, 0x03, 0x23, 0x13, 0x33
};
+static const int8_t modulo_27_table[108] = {
+ 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 2, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
+};
+
/**
* precalculated results of division by three and modulo three for values 0-107
*
* A lot of four-tuples in RV40 are represented as c0*27+c1*9+c2*3+c3.
* This table allows conversion from a value back to a vector.
*/
-static const uint8_t modulo_three_table[108][4] = {
- { 0, 0, 0, 0 }, { 0, 0, 0, 1 }, { 0, 0, 0, 2 }, { 0, 0, 1, 0 },
- { 0, 0, 1, 1 }, { 0, 0, 1, 2 }, { 0, 0, 2, 0 }, { 0, 0, 2, 1 },
- { 0, 0, 2, 2 }, { 0, 1, 0, 0 }, { 0, 1, 0,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 }, { 2, 2, 2, 0 }, { 2, 2, 2, 1 },
- { 2, 2, 2, 2 }, { 3, 0, 0, 0 }, { 3, 0, 0, 1 }, { 3, 0, 0, 2 },
- { 3, 0, 1, 0 }, { 3, 0, 1, 1 }, { 3, 0, 1, 2 }, { 3, 0, 2, 0 },
- { 3, 0, 2, 1 }, { 3, 0, 2, 2 }, { 3, 1, 0, 0 }, { 3, 1, 0, 1 },
- { 3, 1, 0, 2 }, { 3, 1, 1, 0 }, { 3, 1, 1, 1 }, { 3, 1, 1, 2 },
- { 3, 1, 2, 0 }, { 3, 1, 2, 1 }, { 3, 1, 2, 2 }, { 3, 2, 0, 0 },
- { 3, 2, 0, 1 }, { 3, 2, 0, 2 }, { 3, 2, 1, 0 }, { 3, 2, 1, 1 },
- { 3, 2, 1, 2 }, { 3, 2, 2, 0 }, { 3, 2, 2, 1 }, { 3, 2, 2, 2 },
+static const uint8_t modulo_three_table[108][3] = {
+ { 0, 0, 0 }, { 0, 0, 1 }, { 0, 0, 2 }, { 0, 1, 0 },
+ { 0, 1, 1 }, { 0, 1, 2 }, { 0, 2, 0 }, { 0, 2, 1 },
+ { 0, 2, 2 }, { 1, 0, 0 }, { 1, 0, 1 }, { 1, 0, 2 },
+ { 1, 1, 0 }, { 1, 1, 1 }, { 1, 1, 2 }, { 1, 2, 0 },
+ { 1, 2, 1 }, { 1, 2, 2 }, { 2, 0, 0 }, { 2, 0, 1 },
+ { 2, 0, 2 }, { 2, 1, 0 }, { 2, 1, 1 }, { 2, 1, 2 },
+ { 2, 2, 0 }, { 2, 2, 1 }, { 2, 2, 2 }, { 0, 0, 0 },
+ { 0, 0, 1 }, { 0, 0, 2 }, { 0, 1, 0 }, { 0, 1, 1 },
+ { 0, 1, 2 }, { 0, 2, 0 }, { 0, 2, 1 }, { 0, 2, 2 },
+ { 1, 0, 0 }, { 1, 0, 1 }, { 1, 0, 2 }, { 1, 1, 0 },
+ { 1, 1, 1 }, { 1, 1, 2 }, { 1, 2, 0 }, { 1, 2, 1 },
+ { 1, 2, 2 }, { 2, 0, 0 }, { 2, 0, 1 }, { 2, 0, 2 },
+ { 2, 1, 0 }, { 2, 1, 1 }, { 2, 1, 2 }, { 2, 2, 0 },
+ { 2, 2, 1 }, { 2, 2, 2 }, { 0, 0, 0 }, { 0, 0, 1 },
+ { 0, 0, 2 }, { 0, 1, 0 }, { 0, 1, 1 }, { 0, 1, 2 },
+ { 0, 2, 0 }, { 0, 2, 1 }, { 0, 2, 2 }, { 1, 0, 0 },
+ { 1, 0, 1 }, { 1, 0, 2 }, { 1, 1, 0 }, { 1, 1, 1 },
+ { 1, 1, 2 }, { 1, 2, 0 }, { 1, 2, 1 }, { 1, 2, 2 },
+ { 2, 0, 0 }, { 2, 0, 1 }, { 2, 0, 2 }, { 2, 1, 0 },
+ { 2, 1, 1 }, { 2, 1, 2 }, { 2, 2, 0 }, { 2, 2, 1 },
+ { 2, 2, 2 }, { 0, 0, 0 }, { 0, 0, 1 }, { 0, 0, 2 },
+ { 0, 1, 0 }, { 0, 1, 1 }, { 0, 1, 2 }, { 0, 2, 0 },
+ { 0, 2, 1 }, { 0, 2, 2 }, { 1, 0, 0 }, { 1, 0, 1 },
+ { 1, 0, 2 }, { 1, 1, 0 }, { 1, 1, 1 }, { 1, 1, 2 },
+ { 1, 2, 0 }, { 1, 2, 1 }, { 1, 2, 2 }, { 2, 0, 0 },
+ { 2, 0, 1 }, { 2, 0, 2 }, { 2, 1, 0 }, { 2, 1, 1 },
+ { 2, 1, 2 }, { 2, 2, 0 }, { 2, 2, 1 }, { 2, 2, 2 },
};
/**
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel