Unified · Split
| @@ -64,6 +64,12 @@ extern "C" · 63 unmodified lines | |||
| 64 | FRAMEFLAGS_ALTREF = 4, | 64 | FRAMEFLAGS_ALTREF = 4, |
| 65 | } FRAMETYPE_FLAGS; | 65 | } FRAMETYPE_FLAGS; |
| 66 | 66 | ||
| 67 | typedef enum { | ||
| 68 | NO_AQ = 0, | ||
| 69 | VARIANCE_AQ = 1, | ||
| 70 | AQ_MODES_COUNT // This should always be the last member of the enum | ||
| 71 | } AQ_MODES; | ||
| 72 | |||
| 67 | typedef struct { | 73 | typedef struct { |
| 68 | int version; // 4 versions of bitstream defined: | 74 | int version; // 4 versions of bitstream defined: |
| 69 | // 0 - best quality/slowest decode, | 75 | // 0 - best quality/slowest decode, |
| @@ -128,6 +134,7 @@ extern "C" · 58 unmodified lines | |||
| 128 | int best_allowed_q; | 134 | int best_allowed_q; |
| 129 | int cq_level; | 135 | int cq_level; |
| 130 | int lossless; | 136 | int lossless; |
| 137 | int aq_mode; // Adaptive Quantization mode | ||
| 131 | 138 | ||
| 132 | // two pass datarate control | 139 | // two pass datarate control |
| 133 | int two_pass_vbrbias; // two pass datarate control tweaks | 140 | int two_pass_vbrbias; // two pass datarate control tweaks |
| @@ -409,7 +409,7 @@ static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, · 408 unmodified lines | |||
| 409 | && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) | 409 | && (xd->mb_to_bottom_edge >> (3 + MI_SIZE_LOG2)) + mi_height > y) |
| 410 | xd->mi_8x8[x_idx + y * mis] = mi_addr; | 410 | xd->mi_8x8[x_idx + y * mis] = mi_addr; |
| 411 | 411 | ||
| 412 | if (cpi->sf.variance_adaptive_quantization) { | 412 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 413 | vp9_mb_init_quantizer(cpi, x); | 413 | vp9_mb_init_quantizer(cpi, x); |
| 414 | } | 414 | } |
| 415 | 415 | ||
| @@ -558,7 +558,7 @@ static void set_offsets(VP9_COMP *cpi, const TileInfo *const tile, · 142 unmodified lines | |||
| 558 | 558 | ||
| 559 | /* segment ID */ | 559 | /* segment ID */ |
| 560 | if (seg->enabled) { | 560 | if (seg->enabled) { |
| 561 | if (!cpi->sf.variance_adaptive_quantization) { | 561 | if (!cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 562 | uint8_t *map = seg->update_map ? cpi->segmentation_map | 562 | uint8_t *map = seg->update_map ? cpi->segmentation_map |
| 563 | : cm->last_frame_seg_map; | 563 | : cm->last_frame_seg_map; |
| 564 | mbmi->segment_id = vp9_get_segment_id(cm, map, bsize, mi_row, mi_col); | 564 | mbmi->segment_id = vp9_get_segment_id(cm, map, bsize, mi_row, mi_col); |
| @@ -635,7 +635,7 @@ static void pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, · 70 unmodified lines | |||
| 635 | 635 | ||
| 636 | x->source_variance = get_sby_perpixel_variance(cpi, x, bsize); | 636 | x->source_variance = get_sby_perpixel_variance(cpi, x, bsize); |
| 637 | 637 | ||
| 638 | if (cpi->sf.variance_adaptive_quantization) { | 638 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 639 | int energy; | 639 | int energy; |
| 640 | if (bsize <= BLOCK_16X16) { | 640 | if (bsize <= BLOCK_16X16) { |
| 641 | energy = x->mb_energy; | 641 | energy = x->mb_energy; |
| @@ -651,7 +651,7 @@ static void pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, · 9 unmodified lines | |||
| 651 | if (cpi->oxcf.tuning == VP8_TUNE_SSIM) | 651 | if (cpi->oxcf.tuning == VP8_TUNE_SSIM) |
| 652 | vp9_activity_masking(cpi, x); | 652 | vp9_activity_masking(cpi, x); |
| 653 | 653 | ||
| 654 | if (cpi->sf.variance_adaptive_quantization) { | 654 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 655 | vp9_clear_system_state(); // __asm emms; | 655 | vp9_clear_system_state(); // __asm emms; |
| 656 | x->rdmult = round(x->rdmult * rdmult_ratio); | 656 | x->rdmult = round(x->rdmult * rdmult_ratio); |
| 657 | } | 657 | } |
| @@ -670,7 +670,7 @@ static void pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, · 12 unmodified lines | |||
| 670 | totaldist, bsize, ctx, best_rd); | 670 | totaldist, bsize, ctx, best_rd); |
| 671 | } | 671 | } |
| 672 | 672 | ||
| 673 | if (cpi->sf.variance_adaptive_quantization) { | 673 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 674 | x->rdmult = orig_rdmult; | 674 | x->rdmult = orig_rdmult; |
| 675 | if (*totalrate != INT_MAX) { | 675 | if (*totalrate != INT_MAX) { |
| 676 | vp9_clear_system_state(); // __asm emms; | 676 | vp9_clear_system_state(); // __asm emms; |
| @@ -602,14 +602,14 @@ void vp9_first_pass(VP9_COMP *cpi) { · 601 unmodified lines | |||
| 602 | num_8x8_blocks_wide_lookup[xd->mi_8x8[0]->mbmi.sb_type], | 602 | num_8x8_blocks_wide_lookup[xd->mi_8x8[0]->mbmi.sb_type], |
| 603 | cm->mi_rows, cm->mi_cols); | 603 | cm->mi_rows, cm->mi_cols); |
| 604 | 604 | ||
| 605 | if (cpi->sf.variance_adaptive_quantization) { | 605 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 606 | int energy = vp9_block_energy(cpi, x, xd->mi_8x8[0]->mbmi.sb_type); | 606 | int energy = vp9_block_energy(cpi, x, xd->mi_8x8[0]->mbmi.sb_type); |
| 607 | error_weight = vp9_vaq_inv_q_ratio(energy); | 607 | error_weight = vp9_vaq_inv_q_ratio(energy); |
| 608 | } | 608 | } |
| 609 | 609 | ||
| 610 | // do intra 16x16 prediction | 610 | // do intra 16x16 prediction |
| 611 | this_error = vp9_encode_intra(x, use_dc_pred); | 611 | this_error = vp9_encode_intra(x, use_dc_pred); |
| 612 | if (cpi->sf.variance_adaptive_quantization) { | 612 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 613 | vp9_clear_system_state(); // __asm emms; | 613 | vp9_clear_system_state(); // __asm emms; |
| 614 | this_error *= error_weight; | 614 | this_error *= error_weight; |
| 615 | } | 615 | } |
| @@ -647,7 +647,7 @@ void vp9_first_pass(VP9_COMP *cpi) { · 31 unmodified lines | |||
| 647 | first_pass_motion_search(cpi, x, &best_ref_mv, | 647 | first_pass_motion_search(cpi, x, &best_ref_mv, |
| 648 | &mv.as_mv, lst_yv12, | 648 | &mv.as_mv, lst_yv12, |
| 649 | &motion_error, recon_yoffset); | 649 | &motion_error, recon_yoffset); |
| 650 | if (cpi->sf.variance_adaptive_quantization) { | 650 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 651 | vp9_clear_system_state(); // __asm emms; | 651 | vp9_clear_system_state(); // __asm emms; |
| 652 | motion_error *= error_weight; | 652 | motion_error *= error_weight; |
| 653 | } | 653 | } |
| @@ -658,7 +658,7 @@ void vp9_first_pass(VP9_COMP *cpi) { · 4 unmodified lines | |||
| 658 | tmp_err = INT_MAX; | 658 | tmp_err = INT_MAX; |
| 659 | first_pass_motion_search(cpi, x, &zero_ref_mv, &tmp_mv.as_mv, | 659 | first_pass_motion_search(cpi, x, &zero_ref_mv, &tmp_mv.as_mv, |
| 660 | lst_yv12, &tmp_err, recon_yoffset); | 660 | lst_yv12, &tmp_err, recon_yoffset); |
| 661 | if (cpi->sf.variance_adaptive_quantization) { | 661 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 662 | vp9_clear_system_state(); // __asm emms; | 662 | vp9_clear_system_state(); // __asm emms; |
| 663 | tmp_err *= error_weight; | 663 | tmp_err *= error_weight; |
| 664 | } | 664 | } |
| @@ -678,7 +678,7 @@ void vp9_first_pass(VP9_COMP *cpi) { · 13 unmodified lines | |||
| 678 | first_pass_motion_search(cpi, x, &zero_ref_mv, | 678 | first_pass_motion_search(cpi, x, &zero_ref_mv, |
| 679 | &tmp_mv.as_mv, gld_yv12, | 679 | &tmp_mv.as_mv, gld_yv12, |
| 680 | &gf_motion_error, recon_yoffset); | 680 | &gf_motion_error, recon_yoffset); |
| 681 | if (cpi->sf.variance_adaptive_quantization) { | 681 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 682 | vp9_clear_system_state(); // __asm emms; | 682 | vp9_clear_system_state(); // __asm emms; |
| 683 | gf_motion_error *= error_weight; | 683 | gf_motion_error *= error_weight; |
| 684 | } | 684 | } |
| @@ -764,8 +764,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) { · 763 unmodified lines | |||
| 764 | sf->static_segmentation = 0; | 764 | sf->static_segmentation = 0; |
| 765 | #endif | 765 | #endif |
| 766 | 766 | ||
| 767 | sf->variance_adaptive_quantization = 0; | ||
| 768 | |||
| 769 | switch (mode) { | 767 | switch (mode) { |
| 770 | case 0: // This is the best quality mode. | 768 | case 0: // This is the best quality mode. |
| 771 | break; | 769 | break; |
| @@ -3188,7 +3186,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, · 2416 unmodified lines | |||
| 3188 | } | 3186 | } |
| 3189 | } | 3187 | } |
| 3190 | 3188 | ||
| 3191 | if (cpi->sf.variance_adaptive_quantization) { | 3189 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 3192 | vp9_vaq_frame_setup(cpi); | 3190 | vp9_vaq_frame_setup(cpi); |
| 3193 | } | 3191 | } |
| 3194 | 3192 | ||
| @@ -3975,7 +3973,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, · 780 unmodified lines | |||
| 3975 | 3973 | ||
| 3976 | vp9_setup_interp_filters(&cpi->mb.e_mbd, DEFAULT_INTERP_FILTER, cm); | 3974 | vp9_setup_interp_filters(&cpi->mb.e_mbd, DEFAULT_INTERP_FILTER, cm); |
| 3977 | 3975 | ||
| 3978 | if (cpi->sf.variance_adaptive_quantization) { | 3976 | if (cpi->oxcf.aq_mode == VARIANCE_AQ) { |
| 3979 | vp9_vaq_init(); | 3977 | vp9_vaq_init(); |
| 3980 | } | 3978 | } |
| 3981 | 3979 | ||
| @@ -248,7 +248,6 @@ typedef struct { · 247 unmodified lines | |||
| 248 | int auto_mv_step_size; | 248 | int auto_mv_step_size; |
| 249 | int optimize_coefficients; | 249 | int optimize_coefficients; |
| 250 | int static_segmentation; | 250 | int static_segmentation; |
| 251 | int variance_adaptive_quantization; | ||
| 252 | int comp_inter_joint_search_thresh; | 251 | int comp_inter_joint_search_thresh; |
| 253 | int adaptive_rd_thresh; | 252 | int adaptive_rd_thresh; |
| 254 | int skip_encode_sb; | 253 | int skip_encode_sb; |
| @@ -38,6 +38,7 @@ struct vp9_extracfg { · 37 unmodified lines | |||
| 38 | unsigned int rc_max_intra_bitrate_pct; | 38 | unsigned int rc_max_intra_bitrate_pct; |
| 39 | unsigned int lossless; | 39 | unsigned int lossless; |
| 40 | unsigned int frame_parallel_decoding_mode; | 40 | unsigned int frame_parallel_decoding_mode; |
| 41 | unsigned int aq_mode; | ||
| 41 | }; | 42 | }; |
| 42 | 43 | ||
| 43 | struct extraconfig_map { | 44 | struct extraconfig_map { |
| @@ -66,6 +67,7 @@ static const struct extraconfig_map extracfg_map[] = { · 22 unmodified lines | |||
| 66 | 0, /* rc_max_intra_bitrate_pct */ | 67 | 0, /* rc_max_intra_bitrate_pct */ |
| 67 | 0, /* lossless */ | 68 | 0, /* lossless */ |
| 68 | 0, /* frame_parallel_decoding_mode */ | 69 | 0, /* frame_parallel_decoding_mode */ |
| 70 | 0, /* aq_mode */ | ||
| 69 | } | 71 | } |
| 70 | } | 72 | } |
| 71 | }; | 73 | }; |
| @@ -157,6 +159,7 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, · 85 unmodified lines | |||
| 157 | RANGE_CHECK_HI(cfg, rc_max_quantizer, 0); | 159 | RANGE_CHECK_HI(cfg, rc_max_quantizer, 0); |
| 158 | RANGE_CHECK_HI(cfg, rc_min_quantizer, 0); | 160 | RANGE_CHECK_HI(cfg, rc_min_quantizer, 0); |
| 159 | } | 161 | } |
| 162 | RANGE_CHECK(vp8_cfg, aq_mode, 0, AQ_MODES_COUNT - 1); | ||
| 160 | 163 | ||
| 161 | RANGE_CHECK_HI(cfg, g_threads, 64); | 164 | RANGE_CHECK_HI(cfg, g_threads, 64); |
| 162 | RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS); | 165 | RANGE_CHECK_HI(cfg, g_lag_in_frames, MAX_LAG_BUFFERS); |
| @@ -335,6 +338,8 @@ static vpx_codec_err_t set_vp9e_config(VP9_CONFIG *oxcf, · 172 unmodified lines | |||
| 335 | oxcf->error_resilient_mode = cfg.g_error_resilient; | 338 | oxcf->error_resilient_mode = cfg.g_error_resilient; |
| 336 | oxcf->frame_parallel_decoding_mode = vp8_cfg.frame_parallel_decoding_mode; | 339 | oxcf->frame_parallel_decoding_mode = vp8_cfg.frame_parallel_decoding_mode; |
| 337 | 340 | ||
| 341 | oxcf->aq_mode = vp8_cfg.aq_mode; | ||
| 342 | |||
| 338 | oxcf->ss_number_layers = cfg.ss_number_layers; | 343 | oxcf->ss_number_layers = cfg.ss_number_layers; |
| 339 | /* | 344 | /* |
| 340 | printf("Current VP9 Settings: \n"); | 345 | printf("Current VP9 Settings: \n"); |
| @@ -445,6 +450,7 @@ static vpx_codec_err_t set_param(vpx_codec_alg_priv_t *ctx, · 104 unmodified lines | |||
| 445 | MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct); | 450 | MAP(VP8E_SET_MAX_INTRA_BITRATE_PCT, xcfg.rc_max_intra_bitrate_pct); |
| 446 | MAP(VP9E_SET_LOSSLESS, xcfg.lossless); | 451 | MAP(VP9E_SET_LOSSLESS, xcfg.lossless); |
| 447 | MAP(VP9E_SET_FRAME_PARALLEL_DECODING, xcfg.frame_parallel_decoding_mode); | 452 | MAP(VP9E_SET_FRAME_PARALLEL_DECODING, xcfg.frame_parallel_decoding_mode); |
| 453 | MAP(VP9E_SET_AQ_MODE, xcfg.aq_mode); | ||
| 448 | } | 454 | } |
| 449 | 455 | ||
| 450 | res = validate_config(ctx, &ctx->cfg, &xcfg); | 456 | res = validate_config(ctx, &ctx->cfg, &xcfg); |
| @@ -1071,6 +1077,7 @@ static vpx_codec_ctrl_fn_map_t vp9e_ctf_maps[] = { · 620 unmodified lines | |||
| 1071 | {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param}, | 1077 | {VP8E_SET_MAX_INTRA_BITRATE_PCT, set_param}, |
| 1072 | {VP9E_SET_LOSSLESS, set_param}, | 1078 | {VP9E_SET_LOSSLESS, set_param}, |
| 1073 | {VP9E_SET_FRAME_PARALLEL_DECODING, set_param}, | 1079 | {VP9E_SET_FRAME_PARALLEL_DECODING, set_param}, |
| 1080 | {VP9E_SET_AQ_MODE, set_param}, | ||
| 1074 | {VP9_GET_REFERENCE, get_reference}, | 1081 | {VP9_GET_REFERENCE, get_reference}, |
| 1075 | {VP9E_SET_SVC, vp9e_set_svc}, | 1082 | {VP9E_SET_SVC, vp9e_set_svc}, |
| 1076 | {VP9E_SET_SVC_PARAMETERS, vp9e_set_svc_parameters}, | 1083 | {VP9E_SET_SVC_PARAMETERS, vp9e_set_svc_parameters}, |
| @@ -193,6 +193,7 @@ enum vp8e_enc_control_id { · 192 unmodified lines | |||
| 193 | VP9E_SET_TILE_COLUMNS, | 193 | VP9E_SET_TILE_COLUMNS, |
| 194 | VP9E_SET_TILE_ROWS, | 194 | VP9E_SET_TILE_ROWS, |
| 195 | VP9E_SET_FRAME_PARALLEL_DECODING, | 195 | VP9E_SET_FRAME_PARALLEL_DECODING, |
| 196 | VP9E_SET_AQ_MODE, | ||
| 196 | 197 | ||
| 197 | VP9E_SET_SVC, | 198 | VP9E_SET_SVC, |
| 198 | VP9E_SET_SVC_PARAMETERS | 199 | VP9E_SET_SVC_PARAMETERS |
| @@ -343,6 +344,8 @@ VPX_CTRL_USE_TYPE(VP9E_SET_LOSSLESS, unsigned int) · 144 unmodified lines | |||
| 343 | 344 | ||
| 344 | VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PARALLEL_DECODING, unsigned int) | 345 | VPX_CTRL_USE_TYPE(VP9E_SET_FRAME_PARALLEL_DECODING, unsigned int) |
| 345 | 346 | ||
| 347 | VPX_CTRL_USE_TYPE(VP9E_SET_AQ_MODE, unsigned int) | ||
| 348 | |||
| 346 | /*! @} - end defgroup vp8_encoder */ | 349 | /*! @} - end defgroup vp8_encoder */ |
| 347 | #ifdef __cplusplus | 350 | #ifdef __cplusplus |
| 348 | } // extern "C" | 351 | } // extern "C" |
| @@ -561,6 +561,9 @@ static const arg_def_t lossless = ARG_DEF(NULL, "lossless", 1, "Lossless mode"); · 560 unmodified lines | |||
| 561 | #if CONFIG_VP9_ENCODER | 561 | #if CONFIG_VP9_ENCODER |
| 562 | static const arg_def_t frame_parallel_decoding = ARG_DEF( | 562 | static const arg_def_t frame_parallel_decoding = ARG_DEF( |
| 563 | NULL, "frame-parallel", 1, "Enable frame parallel decodability features"); | 563 | NULL, "frame-parallel", 1, "Enable frame parallel decodability features"); |
| 564 | static const arg_def_t aq_mode = ARG_DEF( | ||
| 565 | NULL, "aq-mode", 1, | ||
| 566 | "Adaptive quantization mode (0: disabled (by default), 1: variance based)"); | ||
| 564 | #endif | 567 | #endif |
| 565 | 568 | ||
| 566 | #if CONFIG_VP8_ENCODER | 569 | #if CONFIG_VP8_ENCODER |
| @@ -585,7 +588,7 @@ static const arg_def_t *vp9_args[] = { · 18 unmodified lines | |||
| 585 | &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh, | 588 | &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh, |
| 586 | &tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &arnr_type, | 589 | &tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &arnr_type, |
| 587 | &tune_ssim, &cq_level, &max_intra_rate_pct, &lossless, | 590 | &tune_ssim, &cq_level, &max_intra_rate_pct, &lossless, |
| 588 | &frame_parallel_decoding, | 591 | &frame_parallel_decoding, &aq_mode, |
| 589 | NULL | 592 | NULL |
| 590 | }; | 593 | }; |
| 591 | static const int vp9_arg_ctrl_map[] = { | 594 | static const int vp9_arg_ctrl_map[] = { |
| @@ -594,7 +597,7 @@ static const int vp9_arg_ctrl_map[] = { · 2 unmodified lines | |||
| 594 | VP9E_SET_TILE_COLUMNS, VP9E_SET_TILE_ROWS, | 597 | VP9E_SET_TILE_COLUMNS, VP9E_SET_TILE_ROWS, |
| 595 | VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, | 598 | VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, |
| 596 | VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, | 599 | VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, |
| 597 | VP9E_SET_LOSSLESS, VP9E_SET_FRAME_PARALLEL_DECODING, | 600 | VP9E_SET_LOSSLESS, VP9E_SET_FRAME_PARALLEL_DECODING, VP9E_SET_AQ_MODE, |
| 598 | 0 | 601 | 0 |
| 599 | }; | 602 | }; |
| 600 | #endif | 603 | #endif |