aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/rv34.c
diff options
context:
space:
mode:
authorKostya Shishkov <kostya.shishkov@gmail.com>2008-11-07 07:18:22 +0000
committerKostya Shishkov <kostya.shishkov@gmail.com>2008-11-07 07:18:22 +0000
commite1223112615cfc35779b9d0380332ed7c4085bb0 (patch)
tree2e38c40032978f611b6b6c9db8e791bc1b0fe52c /libavcodec/rv34.c
parente3b07e1a74abea3534f6e922d364c70c47521f2c (diff)
downloadffmpeg-e1223112615cfc35779b9d0380332ed7c4085bb0.tar.gz
Calculating an additional MV-based deblocking pattern is the same
for both RV3 and RV4, so move it into common code. Originally committed as revision 15786 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/rv34.c')
-rw-r--r--libavcodec/rv34.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index e21d224428..cee84a0acd 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1067,6 +1067,38 @@ static void rv34_apply_differences(RV34DecContext *r, int cbp)
s->dsp.add_pixels_clamped(s->block[5], s->dest[2], s->uvlinesize);
}
+static int is_mv_diff_gt_3(int16_t (*motion_val)[2], int step)
+{
+ int d;
+ d = motion_val[0][0] - motion_val[-step][0];
+ if(d < -3 || d > 3)
+ return 1;
+ d = motion_val[0][1] - motion_val[-step][1];
+ if(d < -3 || d > 3)
+ return 1;
+ return 0;
+}
+
+static int rv34_set_deblock_coef(RV34DecContext *r)
+{
+ MpegEncContext *s = &r->s;
+ int mvmask = 0, i, j;
+ int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
+ int16_t (*motion_val)[2] = s->current_picture_ptr->motion_val[0][midx];
+ if(s->pict_type == FF_I_TYPE)
+ return 0;
+ for(j = 0; j < 16; j += 8){
+ for(i = 0; i < 2; i++){
+ if(is_mv_diff_gt_3(motion_val + i, 1))
+ mvmask |= 0x11 << (j + i*2);
+ if(is_mv_diff_gt_3(motion_val + i, s->b8_stride))
+ mvmask |= 0x03 << (j + i*2);
+ }
+ motion_val += s->b8_stride;
+ }
+ return mvmask;
+}
+
static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
{
MpegEncContext *s = &r->s;
@@ -1097,8 +1129,10 @@ static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
cbp = cbp2 = rv34_decode_mb_header(r, intra_types);
r->cbp_luma [s->mb_x + s->mb_y * s->mb_stride] = cbp;
r->cbp_chroma[s->mb_x + s->mb_y * s->mb_stride] = cbp >> 16;
- if(r->set_deblock_coef)
- r->deblock_coefs[s->mb_x + s->mb_y * s->mb_stride] = r->set_deblock_coef(r);
+ if(s->pict_type == FF_I_TYPE)
+ r->deblock_coefs[mb_pos] = 0;
+ else
+ r->deblock_coefs[mb_pos] = rv34_set_deblock_coef(r);
s->current_picture.qscale_table[s->mb_x + s->mb_y * s->mb_stride] = s->qscale;
if(cbp == -1)