diff options
author | Jason Garrett-Glaser <jason@x264.com> | 2011-02-03 19:17:13 -0800 |
---|---|---|
committer | Jason Garrett-Glaser <jason@x264.com> | 2011-02-03 19:55:02 -0800 |
commit | dd18c9a050ac1f1437151ceb2d2afbc96c5602d8 (patch) | |
tree | d2d7d86ce707fbcb0c399701de659e1d31e9a248 /libavcodec/vp8.c | |
parent | 4359288c565705d1734f63d277f8918ee5af5e54 (diff) | |
download | ffmpeg-dd18c9a050ac1f1437151ceb2d2afbc96c5602d8.tar.gz |
VP8: simplify lf_delta mb mode logic
Diffstat (limited to 'libavcodec/vp8.c')
-rw-r--r-- | libavcodec/vp8.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index effeb4ed2f..bcf623790c 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -162,13 +162,14 @@ typedef struct { /** * filter strength adjustment for the following macroblock modes: - * [0] - i4x4 - * [1] - zero mv - * [2] - inter modes except for zero or split mv - * [3] - split mv + * [0-3] - i16x16 (always zero) + * [4] - i4x4 + * [5] - zero mv + * [6] - inter modes except for zero or split mv + * [7] - split mv * i16x16 modes never have any adjustment */ - int8_t mode[4]; + int8_t mode[VP8_MVMODE_SPLIT+1]; /** * filter strength adjustment for macroblocks that reference: @@ -278,7 +279,7 @@ static void update_lf_deltas(VP8Context *s) for (i = 0; i < 4; i++) s->lf_delta.ref[i] = vp8_rac_get_sint(c, 6); - for (i = 0; i < 4; i++) + for (i = MODE_I4x4; i <= VP8_MVMODE_SPLIT; i++) s->lf_delta.mode[i] = vp8_rac_get_sint(c, 6); } @@ -762,6 +763,7 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_ // motion vectors, 16.3 find_near_mvs(s, mb, near, &best, cnt); if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[0]][0])) { + mb->mode = VP8_MVMODE_MV; if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[1]][1])) { if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[2]][2])) { if (vp56_rac_get_prob_branchy(c, vp8_mode_contexts[cnt[3]][3])) { @@ -769,19 +771,14 @@ void decode_mb_mode(VP8Context *s, VP8Macroblock *mb, int mb_x, int mb_y, uint8_ clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); mb->mv = mb->bmv[decode_splitmvs(s, c, mb) - 1]; } else { - mb->mode = VP8_MVMODE_NEW; clamp_mv(s, &mb->mv, &mb->mv, mb_x, mb_y); mb->mv.y += read_mv_component(c, s->prob->mvc[0]); mb->mv.x += read_mv_component(c, s->prob->mvc[1]); } - } else { - mb->mode = VP8_MVMODE_NEAR; + } else clamp_mv(s, &mb->mv, &near[1], mb_x, mb_y); - } - } else { - mb->mode = VP8_MVMODE_NEAREST; + } else clamp_mv(s, &mb->mv, &near[0], mb_x, mb_y); - } } else { mb->mode = VP8_MVMODE_ZERO; AV_ZERO32(&mb->mv); @@ -1481,18 +1478,7 @@ static av_always_inline void filter_level_for_mb(VP8Context *s, VP8Macroblock *m if (s->lf_delta.enabled) { filter_level += s->lf_delta.ref[mb->ref_frame]; - - if (mb->ref_frame == VP56_FRAME_CURRENT) { - if (mb->mode == MODE_I4x4) - filter_level += s->lf_delta.mode[0]; - } else { - if (mb->mode == VP8_MVMODE_ZERO) - filter_level += s->lf_delta.mode[1]; - else if (mb->mode == VP8_MVMODE_SPLIT) - filter_level += s->lf_delta.mode[3]; - else - filter_level += s->lf_delta.mode[2]; - } + filter_level += s->lf_delta.mode[mb->mode]; } filter_level = av_clip(filter_level, 0, 63); |