Commit 4320a309 authored by Jason Garrett-Glaser's avatar 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.
parent abc78a5a
...@@ -215,19 +215,20 @@ static void av_always_inline filter_mb_edgech( uint8_t *pix, int stride, int16_t ...@@ -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) { 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; MpegEncContext * const s = &h->s;
int mb_xy; 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 qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh;
int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY)); int chroma = !(CONFIG_GRAY && (s->flags&CODEC_FLAG_GRAY));
int chroma444 = CHROMA444; int chroma444 = CHROMA444;
mb_xy = h->mb_xy; 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); ff_h264_filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize);
return; return;
} }
assert(!FRAME_MBAFF); assert(!FRAME_MBAFF);
left_type= h->left_type[0]; left_type= h->left_type[0];
top_type= h->top_type;
mb_type = s->current_picture.mb_type[mb_xy]; mb_type = s->current_picture.mb_type[mb_xy];
qp = s->current_picture.qscale_table[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, ...@@ -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); filter_mb_edgev( &img_y[4*0], linesize, bS4, qp0, h);
if( IS_8x8DCT(mb_type) ) { if( IS_8x8DCT(mb_type) ) {
filter_mb_edgev( &img_y[4*2], linesize, bS3, qp, h); 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); filter_mb_edgeh( &img_y[4*2*linesize], linesize, bS3, qp, h);
} else { } else {
filter_mb_edgev( &img_y[4*1], linesize, bS3, qp, h); 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*2], linesize, bS3, qp, h);
filter_mb_edgev( &img_y[4*3], 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*1*linesize], linesize, bS3, qp, h);
filter_mb_edgeh( &img_y[4*2*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); 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, ...@@ -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) ) { if( IS_8x8DCT(mb_type) ) {
filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h); filter_mb_edgev( &img_cb[4*2], linesize, bS3, qpc, h);
filter_mb_edgev( &img_cr[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); if(top_type){
filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, 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);
}
filter_mb_edgeh( &img_cb[4*2*linesize], linesize, bS3, qpc, 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); filter_mb_edgeh( &img_cr[4*2*linesize], linesize, bS3, qpc, h);
} else { } else {
...@@ -284,8 +291,10 @@ void ff_h264_filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, ...@@ -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_cr[4*2], linesize, bS3, qpc, h);
filter_mb_edgev( &img_cb[4*3], 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_edgev( &img_cr[4*3], linesize, bS3, qpc, h);
filter_mb_edgeh( &img_cb[4*0*linesize], linesize, bSH, qpc1, h); if(top_type){
filter_mb_edgeh( &img_cr[4*0*linesize], linesize, bSH, qpc1, 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);
}
filter_mb_edgeh( &img_cb[4*1*linesize], linesize, bS3, qpc, 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_cr[4*1*linesize], linesize, bS3, qpc, h);
filter_mb_edgeh( &img_cb[4*2*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, ...@@ -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_cb[2*2], uvlinesize, bS3, qpc, h);
filter_mb_edgecv( &img_cr[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_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); 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, ...@@ -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) ) if( IS_INTRA(left_type) )
AV_WN64A(bS[0][0], 0x0004000400040004ULL); 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); AV_WN64A(bS[1][0], FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL);
#define FILTER(hv,dir,edge)\ #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, ...@@ -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) if(left_type)
FILTER(v,0,0); FILTER(v,0,0);
if( edges == 1 ) { if( edges == 1 ) {
FILTER(h,1,0); if(top_type)
FILTER(h,1,0);
} else if( IS_8x8DCT(mb_type) ) { } else if( IS_8x8DCT(mb_type) ) {
FILTER(v,0,2); FILTER(v,0,2);
FILTER(h,1,0); if(top_type)
FILTER(h,1,0);
FILTER(h,1,2); FILTER(h,1,2);
} else { } else {
FILTER(v,0,1); FILTER(v,0,1);
FILTER(v,0,2); FILTER(v,0,2);
FILTER(v,0,3); FILTER(v,0,3);
FILTER(h,1,0); if(top_type)
FILTER(h,1,0);
FILTER(h,1,1); FILTER(h,1,1);
FILTER(h,1,2); FILTER(h,1,2);
FILTER(h,1,3); FILTER(h,1,3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment