summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorLoren Merritt <lorenm@u.washington.edu>2005-02-25 07:40:29 +0000
committerLoren Merritt <lorenm@u.washington.edu>2005-02-25 07:40:29 +0000
commit19fe8b4100dfe0323e351e474c54293bb4ae576e (patch)
treee40f9b17f51ddb49b7dcc9d6c8400459abf0a179 /libavcodec
parentcf344ec72cd3eac1075b7571b75dff625a9af3b0 (diff)
In-loop deblocking for B-frames.
Originally committed as revision 3979 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/h264.c47
1 files changed, 28 insertions, 19 deletions
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 1cb66d33a3..45c5eaf9d0 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -582,7 +582,7 @@ static inline void fill_caches(H264Context *h, int mb_type, int for_deblock){
if(IS_INTER(mb_type) || (IS_DIRECT(mb_type) && h->direct_spatial_mv_pred)){
int list;
for(list=0; list<2; list++){
- if((!IS_8X8(mb_type)) && !USES_LIST(mb_type, list) && !IS_DIRECT(mb_type)){
+ if((!IS_8X8(mb_type)) && !USES_LIST(mb_type, list) && !IS_DIRECT(mb_type) && !for_deblock){
/*if(!h->mv_cache_clean[list]){
memset(h->mv_cache [list], 0, 8*5*2*sizeof(int16_t)); //FIXME clean only input? clean at all?
memset(h->ref_cache[list], PART_NOT_AVAILABLE, 8*5*sizeof(int8_t));
@@ -4188,7 +4188,8 @@ decode_intra_mb:
if(IS_DIR(mb_type, 0, list)){
const int val= get_te0_golomb(&s->gb, h->ref_count[list]);
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1);
- }
+ }else
+ fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<2; list++){
@@ -4199,7 +4200,8 @@ decode_intra_mb:
tprintf("final mv:%d %d\n", mx, my);
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
- }
+ }else
+ fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, 0, 4);
}
}
else if(IS_16X8(mb_type)){
@@ -4209,7 +4211,7 @@ decode_intra_mb:
if(IS_DIR(mb_type, i, list)){
const int val= get_te0_golomb(&s->gb, h->ref_count[list]);
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1);
- }else // needed only for mixed refs (e.g. B_L0_L1_16x8)
+ }else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
}
}
@@ -4235,7 +4237,7 @@ decode_intra_mb:
if(IS_DIR(mb_type, i, list)){ //FIXME optimize
const int val= get_te0_golomb(&s->gb, h->ref_count[list]);
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1);
- }else // needed only for mixed refs
+ }else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
}
}
@@ -5135,7 +5137,8 @@ decode_intra_mb:
const int ref = h->ref_count[list] > 1 ? decode_cabac_mb_ref( h, list, 0 ) : 0;
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
}
- }
+ }else
+ fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (uint8_t)LIST_NOT_USED, 1);
}
for(list=0; list<2; list++){
if(IS_DIR(mb_type, 0, list)){
@@ -5147,7 +5150,8 @@ decode_intra_mb:
fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
- }
+ }else
+ fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, 0, 4);
}
}
else if(IS_16X8(mb_type)){
@@ -5172,7 +5176,7 @@ decode_intra_mb:
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
- }else{ // needed only for mixed refs
+ }else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
}
@@ -5201,7 +5205,7 @@ decode_intra_mb:
tprintf("final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx-mpx,my-mpy), 4);
fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
- }else{ // needed only for mixed refs
+ }else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
}
@@ -5652,16 +5656,21 @@ static void filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8
h->non_zero_count_cache[bn_idx] != 0 ) {
bS[i] = 2;
}
- else if( h->slice_type == P_TYPE ) {
- if( h->ref_cache[0][b_idx] != h->ref_cache[0][bn_idx] ||
- ABS( h->mv_cache[0][b_idx][0] - h->mv_cache[0][bn_idx][0] ) >= 4 ||
- ABS( h->mv_cache[0][b_idx][1] - h->mv_cache[0][bn_idx][1] ) >= 4 )
- bS[i] = 1;
- else
- bS[i] = 0;
- } else {
- /* FIXME Add support for B frame */
- return;
+ else
+ {
+ /* FIXME: A given frame may occupy more than one position in
+ * the reference list. So we should compare the frame numbers,
+ * not the indices in the ref list. */
+ int l;
+ bS[i] = 0;
+ for( l = 0; l < 1 + (h->slice_type == B_TYPE); l++ ) {
+ if( h->ref_cache[l][b_idx] != h->ref_cache[l][bn_idx] ||
+ ABS( h->mv_cache[l][b_idx][0] - h->mv_cache[l][bn_idx][0] ) >= 4 ||
+ ABS( h->mv_cache[l][b_idx][1] - h->mv_cache[l][bn_idx][1] ) >= 4 ) {
+ bS[i] = 1;
+ break;
+ }
+ }
}
}