Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 1 | /* |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 3 | * |
Yaowu Xu | 2ab7ff0 | 2016-09-02 12:04:54 -0700 | [diff] [blame] | 4 | * This source code is subject to the terms of the BSD 2 Clause License and |
| 5 | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
| 6 | * was not distributed with this source code in the LICENSE file, you can |
| 7 | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
| 8 | * Media Patent License 1.0 was not distributed with this source code in the |
| 9 | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 12 | #ifndef AOM_AV1_ENCODER_ENCODEMB_H_ |
| 13 | #define AOM_AV1_ENCODER_ENCODEMB_H_ |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 14 | |
Tom Finegan | 60e653d | 2018-05-22 11:34:58 -0700 | [diff] [blame] | 15 | #include "config/aom_config.h" |
| 16 | |
Yaowu Xu | d6ea71c | 2016-11-07 10:24:14 -0800 | [diff] [blame] | 17 | #include "av1/common/onyxc_int.h" |
Xing Jin | bd91e94 | 2018-06-21 13:43:17 +0800 | [diff] [blame] | 18 | #include "av1/common/txb_common.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 19 | #include "av1/encoder/block.h" |
Angie Chiang | 5b5f4df | 2017-12-06 10:41:12 -0800 | [diff] [blame] | 20 | #include "av1/encoder/tokenize.h" |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 21 | #ifdef __cplusplus |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
| 25 | struct optimize_ctx { |
Wan-Teh Chang | 660f8ed | 2018-05-11 17:28:08 -0700 | [diff] [blame] | 26 | ENTROPY_CONTEXT ta[MAX_MB_PLANE][MAX_MIB_SIZE]; |
| 27 | ENTROPY_CONTEXT tl[MAX_MB_PLANE][MAX_MIB_SIZE]; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | struct encode_b_args { |
Michelle Findlay-Olynyk | fbab062 | 2017-12-13 14:10:56 -0800 | [diff] [blame] | 31 | const struct AV1_COMP *cpi; |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 32 | MACROBLOCK *x; |
| 33 | struct optimize_ctx *ctx; |
| 34 | int8_t *skip; |
| 35 | ENTROPY_CONTEXT *ta; |
| 36 | ENTROPY_CONTEXT *tl; |
| 37 | int8_t enable_optimize_b; |
| 38 | }; |
| 39 | |
Satish Kumar Suman | 4667aa1 | 2018-12-14 18:28:19 +0530 | [diff] [blame] | 40 | enum { |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 41 | AV1_XFORM_QUANT_FP = 0, |
| 42 | AV1_XFORM_QUANT_B = 1, |
| 43 | AV1_XFORM_QUANT_DC = 2, |
Debargha Mukherjee | f030558 | 2016-11-24 09:55:34 -0800 | [diff] [blame] | 44 | AV1_XFORM_QUANT_SKIP_QUANT, |
| 45 | AV1_XFORM_QUANT_TYPES, |
Satish Kumar Suman | 4667aa1 | 2018-12-14 18:28:19 +0530 | [diff] [blame] | 46 | } UENUM1BYTE(AV1_XFORM_QUANT); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 47 | |
Michelle Findlay-Olynyk | fbab062 | 2017-12-13 14:10:56 -0800 | [diff] [blame] | 48 | void av1_encode_sb(const struct AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize, |
| 49 | int mi_row, int mi_col, RUN_TYPE dry_run); |
Urvang Joshi | 10df032 | 2018-07-31 14:03:30 -0700 | [diff] [blame] | 50 | |
| 51 | void av1_foreach_transformed_block_in_plane( |
| 52 | const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane, |
| 53 | foreach_transformed_block_visitor visit, void *arg); |
| 54 | |
| 55 | void av1_foreach_transformed_block(const MACROBLOCKD *const xd, |
| 56 | BLOCK_SIZE bsize, int mi_row, int mi_col, |
| 57 | foreach_transformed_block_visitor visit, |
| 58 | void *arg, const int num_planes); |
| 59 | |
Angie Chiang | ff6d890 | 2016-10-21 11:02:09 -0700 | [diff] [blame] | 60 | void av1_encode_sby_pass1(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize); |
Urvang Joshi | 10df032 | 2018-07-31 14:03:30 -0700 | [diff] [blame] | 61 | |
Angie Chiang | ff6d890 | 2016-10-21 11:02:09 -0700 | [diff] [blame] | 62 | void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block, |
| 63 | int blk_row, int blk_col, BLOCK_SIZE plane_bsize, |
Peng Bin | 130cf1d | 2018-06-07 13:34:26 +0800 | [diff] [blame] | 64 | TX_SIZE tx_size, TX_TYPE tx_type, |
| 65 | AV1_XFORM_QUANT xform_quant_idx); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 66 | |
Michelle Findlay-Olynyk | fbab062 | 2017-12-13 14:10:56 -0800 | [diff] [blame] | 67 | int av1_optimize_b(const struct AV1_COMP *cpi, MACROBLOCK *mb, int plane, |
Xing Jin | bd91e94 | 2018-06-21 13:43:17 +0800 | [diff] [blame] | 68 | int block, TX_SIZE tx_size, TX_TYPE tx_type, |
| 69 | const TXB_CTX *const txb_ctx, int fast_mode, int *rate_cost); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 70 | |
Angie Chiang | 62e54cd | 2017-04-06 10:45:56 -0700 | [diff] [blame] | 71 | void av1_subtract_txb(MACROBLOCK *x, int plane, BLOCK_SIZE plane_bsize, |
| 72 | int blk_col, int blk_row, TX_SIZE tx_size); |
| 73 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 74 | void av1_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 75 | |
Hui Su | db0301e | 2018-04-02 10:57:21 -0700 | [diff] [blame] | 76 | static INLINE void av1_set_txb_context(MACROBLOCK *x, int plane, int block, |
| 77 | TX_SIZE tx_size, ENTROPY_CONTEXT *a, |
| 78 | ENTROPY_CONTEXT *l) { |
| 79 | const uint8_t ctx = x->plane[plane].txb_entropy_ctx[block]; |
| 80 | memset(a, ctx, tx_size_wide_unit[tx_size] * sizeof(*a)); |
| 81 | memset(l, ctx, tx_size_high_unit[tx_size] * sizeof(*l)); |
| 82 | } |
Angie Chiang | 36aca33 | 2017-03-23 14:16:24 -0700 | [diff] [blame] | 83 | |
Yaowu Xu | f883b42 | 2016-08-30 14:01:10 -0700 | [diff] [blame] | 84 | void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col, |
| 85 | BLOCK_SIZE plane_bsize, TX_SIZE tx_size, void *arg); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 86 | |
Michelle Findlay-Olynyk | fbab062 | 2017-12-13 14:10:56 -0800 | [diff] [blame] | 87 | void av1_encode_intra_block_plane(const struct AV1_COMP *cpi, MACROBLOCK *x, |
Angie Chiang | ff6d890 | 2016-10-21 11:02:09 -0700 | [diff] [blame] | 88 | BLOCK_SIZE bsize, int plane, |
Yaowu Xu | 4ff59b5 | 2017-04-24 12:41:56 -0700 | [diff] [blame] | 89 | int enable_optimize_b, int mi_row, |
| 90 | int mi_col); |
Yaowu Xu | c27fc14 | 2016-08-22 16:08:15 -0700 | [diff] [blame] | 91 | |
| 92 | #ifdef __cplusplus |
| 93 | } // extern "C" |
| 94 | #endif |
| 95 | |
James Zern | e1cbb13 | 2018-08-22 14:10:36 -0700 | [diff] [blame] | 96 | #endif // AOM_AV1_ENCODER_ENCODEMB_H_ |