[FFmpeg-cvslog] H.264: make filter_mb_fast support the case of unavailable top mb

Jason Garrett-Glaser git at videolan.org
Mon Jul 4 00:53:50 CEST 2011


ffmpeg | branch: master | Jason Garrett-Glaser <jason at x264.com> | Mon Jun 27 13:07:26 2011 -0700| [4320a309ce10a7eec93aef239a0776a33b1a5a34] | committer: Jason Garrett-Glaser

H.264: make filter_mb_fast support the case of unavailable top mb

Significantly faster deblocking in streams with lots of slices.

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

 libavcodec/h264_loopfilter.c |   42 ++++++++++++++++++++++++++++--------------
 1 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/libavcodec/h264_loopfilter.c b/libavcodec/h264_loopfilter.c
index bdfbce7..1575b1b 100644
--- a/libavcodec/h264_loopfilter.c
+++ b/libavcodec/h264_loopfilter.c
@@ -215,19 +215,20 @@ static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, int16_t
 void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) {
     MpegEncContext * const s = &h->s;
     int mb_xy;
-    int mb_type, left_type;
+    int mb_type, left_type, top_type;
     int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh;
     int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
     int chroma444 = CHROMA444;
 
     mb_xy = h->mb_xy;
 
-    if(!h->top_type || !h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) {
+    if(!h->h264dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff) {
         ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize);
         return;
     }
     assert(!FRAME_MBAFF);
     left_type= h->left_type[0];
+    top_type= h->top_type;
 
     mb_type = s->current_picture.mb_type[mb_xy];
     qp = s->current_picture.qscale_table[mb_xy];
@@ -253,13 +254,17 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
             filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h);
         if( IS_8x8DCT(mb_type) ) {
             filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h);
-            filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h);
+            if(top_type){
+                filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h);
+            }
             filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h);
         } else {
             filter_mb_edgev( &img_y[4*1], linesize, bS3, qp, h);
             filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h);
             filter_mb_edgev( &img_y[4*3], linesize, bS3, qp, h);
-            filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h);
+            if(top_type){
+                filter_mb_edgeh( &img_y[4*0*linesize], linesize, bSH, qp1, h);
+            }
             filter_mb_edgeh( &img_y[4*1*linesize], linesize, bS3, qp, h);
             filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h);
             filter_mb_edgeh( &img_y[4*3*linesize], linesize, bS3, qp, h);
@@ -273,8 +278,10 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
                 if( IS_8x8DCT(mb_type) ) {
                     filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h);
                     filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h);
-                    filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h);
-                    filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h);
+                    if(top_type){
+                        filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h);
+                        filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h);
+                    }
                     filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h);
                     filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h);
                 } else {
@@ -284,8 +291,10 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
                     filter_mb_edgev( &img_cr[4*2], linesize, bS3, qpc, h);
                     filter_mb_edgev( &img_cb[4*3], linesize, bS3, qpc, h);
                     filter_mb_edgev( &img_cr[4*3], linesize, bS3, qpc, h);
-                    filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h);
-                    filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h);
+                    if(top_type){
+                        filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h);
+                        filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, h);
+                    }
                     filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, h);
                     filter_mb_edgeh( &img_cr[4*1*linesize], linesize, bS3, qpc, h);
                     filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, h);
@@ -300,9 +309,11 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
                 }
                 filter_mb_edgecv( &img_cb[2*2], uvlinesize, bS3, qpc, h);
                 filter_mb_edgecv( &img_cr[2*2], uvlinesize, bS3, qpc, h);
-                filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h);
+                if(top_type){
+                    filter_mb_edgech( &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1, h);
+                    filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h);
+                }
                 filter_mb_edgech( &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc, h);
-                filter_mb_edgech( &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1, h);
                 filter_mb_edgech( &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc, h);
             }
         }
@@ -326,7 +337,7 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
         }
         if( IS_INTRA(left_type) )
             AV_WN64A(bS[0][0], 0x0004000400040004ULL);
-        if( IS_INTRA(h->top_type) )
+        if( IS_INTRA(top_type) )
             AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL);
 
 #define FILTER(hv,dir,edge)\
@@ -345,16 +356,19 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y,
         if(left_type)
             FILTER(v,0,0);
         if( edges == 1 ) {
-            FILTER(h,1,0);
+            if(top_type)
+                FILTER(h,1,0);
         } else if( IS_8x8DCT(mb_type) ) {
             FILTER(v,0,2);
-            FILTER(h,1,0);
+            if(top_type)
+                FILTER(h,1,0);
             FILTER(h,1,2);
         } else {
             FILTER(v,0,1);
             FILTER(v,0,2);
             FILTER(v,0,3);
-            FILTER(h,1,0);
+            if(top_type)
+                FILTER(h,1,0);
             FILTER(h,1,1);
             FILTER(h,1,2);
             FILTER(h,1,3);



More information about the ffmpeg-cvslog mailing list