aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Garrett-Glaser <darkshikari@gmail.com>2010-08-07 12:30:44 +0000
committerJason Garrett-Glaser <darkshikari@gmail.com>2010-08-07 12:30:44 +0000
commitb70c95e05a9a344e06fc4db896217ee372913d39 (patch)
tree82f0c456831081bb88f8b280283c89034888f631
parent91af5601c14908c3d23d881c4cd2b725d5ad2bde (diff)
downloadffmpeg-b70c95e05a9a344e06fc4db896217ee372913d39.tar.gz
H.264: 8% faster CAVLC zero-run decoding
Originally committed as revision 24736 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/h264_cavlc.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index 0475e9454a..6f3bcad782 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -367,7 +367,7 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
MpegEncContext * const s = &h->s;
static const int coeff_token_table_index[17]= {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3};
int level[16];
- int zeros_left, coeff_num, coeff_token, total_coeff, i, j, trailing_ones, run_before;
+ int zeros_left, coeff_token, total_coeff, i, trailing_ones, run_before;
//FIXME put trailing_onex into the context
@@ -488,39 +488,36 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
zeros_left= get_vlc2(gb, (total_zeros_vlc-1)[ total_coeff ].table, TOTAL_ZEROS_VLC_BITS, 1);
}
- coeff_num = zeros_left + total_coeff - 1;
- j = scantable[coeff_num];
+ scantable += zeros_left + total_coeff - 1;
if(n > 24){
- block[j] = level[0];
- for(i=1;i<total_coeff;i++) {
- if(zeros_left <= 0)
- run_before = 0;
- else if(zeros_left < 7){
+ block[*scantable] = level[0];
+ for(i=1;i<total_coeff && zeros_left > 0;i++) {
+ if(zeros_left < 7)
run_before= get_vlc2(gb, (run_vlc-1)[zeros_left].table, RUN_VLC_BITS, 1);
- }else{
+ else
run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2);
- }
zeros_left -= run_before;
- coeff_num -= 1 + run_before;
- j= scantable[ coeff_num ];
-
- block[j]= level[i];
+ scantable -= 1 + run_before;
+ block[*scantable]= level[i];
+ }
+ for(;i<total_coeff;i++) {
+ scantable--;
+ block[*scantable]= level[i];
}
}else{
- block[j] = (level[0] * qmul[j] + 32)>>6;
- for(i=1;i<total_coeff;i++) {
- if(zeros_left <= 0)
- run_before = 0;
- else if(zeros_left < 7){
+ block[*scantable] = (level[0] * qmul[*scantable] + 32)>>6;
+ for(i=1;i<total_coeff && zeros_left > 0;i++) {
+ if(zeros_left < 7)
run_before= get_vlc2(gb, (run_vlc-1)[zeros_left].table, RUN_VLC_BITS, 1);
- }else{
+ else
run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2);
- }
zeros_left -= run_before;
- coeff_num -= 1 + run_before;
- j= scantable[ coeff_num ];
-
- block[j]= (level[i] * qmul[j] + 32)>>6;
+ scantable -= 1 + run_before;
+ block[*scantable]= (level[i] * qmul[*scantable] + 32)>>6;
+ }
+ for(;i<total_coeff;i++) {
+ scantable--;
+ block[*scantable]= (level[i] * qmul[*scantable] + 32)>>6;
}
}