[FFmpeg-cvslog] avcodec/h264_cavlc: Drop local_ref_count

Michael Niedermayer git at videolan.org
Sun Mar 22 15:03:06 CET 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Mar 22 14:30:51 2015 +0100| [797ba4d53b080962a9efca95c96bdf525cc2f787] | committer: Michael Niedermayer

avcodec/h264_cavlc: Drop local_ref_count

This basically switches to the implementation from f6f7d1504134683c435e2c7d804279d982e52bb4
which seems faster

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=797ba4d53b080962a9efca95c96bdf525cc2f787
---

 libavcodec/h264_cavlc.c |   27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/libavcodec/h264_cavlc.c b/libavcodec/h264_cavlc.c
index ce14dce..42afce9 100644
--- a/libavcodec/h264_cavlc.c
+++ b/libavcodec/h264_cavlc.c
@@ -714,7 +714,6 @@ int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl)
     int dct8x8_allowed= h->pps.transform_8x8_mode;
     int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2;
     const int pixel_shift = h->pixel_shift;
-    unsigned local_ref_count[2];
 
     mb_xy = sl->mb_xy = sl->mb_x + sl->mb_y*h->mb_stride;
 
@@ -799,9 +798,6 @@ decode_intra_mb:
         return 0;
     }
 
-    local_ref_count[0] = sl->ref_count[0] << MB_MBAFF(sl);
-    local_ref_count[1] = sl->ref_count[1] << MB_MBAFF(sl);
-
     fill_decode_neighbors(h, sl, mb_type);
     fill_decode_caches(h, sl, mb_type);
 
@@ -881,7 +877,7 @@ decode_intra_mb:
         }
 
         for (list = 0; list < sl->list_count; list++) {
-            int ref_count = IS_REF0(mb_type) ? 1 : local_ref_count[list];
+            int ref_count = IS_REF0(mb_type) ? 1 : sl->ref_count[list] << MB_MBAFF(sl);
             for(i=0; i<4; i++){
                 if(IS_DIRECT(sl->sub_mb_type[i])) continue;
                 if(IS_DIR(sl->sub_mb_type[i], 0, list)){
@@ -961,13 +957,14 @@ decode_intra_mb:
             for (list = 0; list < sl->list_count; list++) {
                     unsigned int val;
                     if(IS_DIR(mb_type, 0, list)){
-                        if(local_ref_count[list]==1){
+                        unsigned rc = sl->ref_count[list] << MB_MBAFF(sl);
+                        if (rc == 1) {
                             val= 0;
-                        } else if(local_ref_count[list]==2){
+                        } else if (rc == 2) {
                             val= get_bits1(&sl->gb)^1;
                         }else{
                             val= get_ue_golomb_31(&sl->gb);
-                            if (val >= local_ref_count[list]){
+                            if (val >= rc) {
                                 av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
                                 return -1;
                             }
@@ -991,13 +988,14 @@ decode_intra_mb:
                     for(i=0; i<2; i++){
                         unsigned int val;
                         if(IS_DIR(mb_type, i, list)){
-                            if(local_ref_count[list] == 1) {
+                            unsigned rc = sl->ref_count[list] << MB_MBAFF(sl);
+                            if (rc == 1) {
                                 val= 0;
-                            } else if(local_ref_count[list] == 2) {
+                            } else if (rc == 2) {
                                 val= get_bits1(&sl->gb)^1;
                             }else{
                                 val= get_ue_golomb_31(&sl->gb);
-                                if (val >= local_ref_count[list]){
+                                if (val >= rc) {
                                     av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
                                     return -1;
                                 }
@@ -1028,13 +1026,14 @@ decode_intra_mb:
                     for(i=0; i<2; i++){
                         unsigned int val;
                         if(IS_DIR(mb_type, i, list)){ //FIXME optimize
-                            if(local_ref_count[list]==1){
+                            unsigned rc = sl->ref_count[list] << MB_MBAFF(sl);
+                            if (rc == 1) {
                                 val= 0;
-                            } else if(local_ref_count[list]==2){
+                            } else if (rc == 2) {
                                 val= get_bits1(&sl->gb)^1;
                             }else{
                                 val= get_ue_golomb_31(&sl->gb);
-                                if (val >= local_ref_count[list]){
+                                if (val >= rc) {
                                     av_log(h->avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
                                     return -1;
                                 }



More information about the ffmpeg-cvslog mailing list