diff options
author | hui su <huisu@google.com> | 2015-09-15 12:44:13 -0700 |
---|---|---|
committer | hui su <huisu@google.com> | 2015-10-12 10:02:17 -0700 |
commit | 5d011cb2785016de7f1cbf9a284cdd768a8a6229 (patch) | |
tree | 5a014b52aaffab1f7b07303f234b13deb9170464 /vp10/decoder/decodemv.c | |
parent | ba7ea4456f175bb23e86456abf95da8256d17c09 (diff) | |
download | libvpx-5d011cb2785016de7f1cbf9a284cdd768a8a6229.tar libvpx-5d011cb2785016de7f1cbf9a284cdd768a8a6229.tar.gz libvpx-5d011cb2785016de7f1cbf9a284cdd768a8a6229.tar.bz2 libvpx-5d011cb2785016de7f1cbf9a284cdd768a8a6229.zip |
VP10: Add palette mode part 1
Add palette mode for keyframe luma channel. Palette mode is enabled
when using "--tune-content=screen" in encoding config parameters.
on screen_content testset: +6.89%
on derlr : +0.00%
Design doc (WIP):
https://goo.gl/lD4yJw
Change-Id: Ib368b216bfd3ea21c6c27436934ad87afdaa6f88
Diffstat (limited to 'vp10/decoder/decodemv.c')
-rw-r--r-- | vp10/decoder/decodemv.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/vp10/decoder/decodemv.c b/vp10/decoder/decodemv.c index f157ada20..b334a3ec6 100644 --- a/vp10/decoder/decodemv.c +++ b/vp10/decoder/decodemv.c @@ -24,6 +24,19 @@ #include "vpx_dsp/vpx_dsp_common.h" +static INLINE int read_uniform(vpx_reader *r, int n) { + int l = get_unsigned_bits(n); + int m = (1 << l) - n; + int v = vpx_read_literal(r, l-1); + + assert(l != 0); + + if (v < m) + return v; + else + return (v << 1) - m + vpx_read_literal(r, 1); +} + static PREDICTION_MODE read_intra_mode(vpx_reader *r, const vpx_prob *p) { return (PREDICTION_MODE)vpx_read_tree(r, vp10_intra_mode_tree, p); } @@ -196,6 +209,38 @@ static int read_skip(VP10_COMMON *cm, const MACROBLOCKD *xd, } } +static void read_palette_mode_info(VP10_COMMON *const cm, + MACROBLOCKD *const xd, + vpx_reader *r) { + MODE_INFO *const mi = xd->mi[0]; + MB_MODE_INFO *const mbmi = &mi->mbmi; + const MODE_INFO *above_mi = xd->above_mi; + const MODE_INFO *left_mi = xd->left_mi; + const BLOCK_SIZE bsize = mbmi->sb_type; + int i, palette_ctx = 0; + + if (above_mi) + palette_ctx += (above_mi->mbmi.palette_mode_info.palette_size[0] > 0); + if (left_mi) + palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0); + if (vpx_read(r, vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8] + [palette_ctx])) { + int n; + PALETTE_MODE_INFO *pmi = &mbmi->palette_mode_info; + + pmi->palette_size[0] = + vpx_read_tree(r, vp10_palette_size_tree, + vp10_default_palette_y_size_prob[bsize - BLOCK_8X8]) + 2; + n = pmi->palette_size[0]; + + for (i = 0; i < n; ++i) + pmi->palette_colors[i] = vpx_read_literal(r, cm->bit_depth); + + xd->plane[0].color_index_map[0] = read_uniform(r, n); + assert(xd->plane[0].color_index_map[0] < n); + } +} + static void read_intra_frame_mode_info(VP10_COMMON *const cm, MACROBLOCKD *const xd, int mi_row, int mi_col, vpx_reader *r) { @@ -244,6 +289,12 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm, } mbmi->uv_mode = read_intra_mode(r, vp10_kf_uv_mode_prob[mbmi->mode]); + + mbmi->palette_mode_info.palette_size[0] = 0; + mbmi->palette_mode_info.palette_size[1] = 0; + if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools && + mbmi->mode == DC_PRED) + read_palette_mode_info(cm, xd, r); } static int read_mv_component(vpx_reader *r, @@ -407,6 +458,9 @@ static void read_intra_block_mode_info(VP10_COMMON *const cm, } mbmi->uv_mode = read_intra_mode_uv(cm, xd, r, mbmi->mode); + + mbmi->palette_mode_info.palette_size[0] = 0; + mbmi->palette_mode_info.palette_size[1] = 0; } static INLINE int is_mv_valid(const MV *mv) { |