1 /*
2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 *
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.
10 */
11
12 #ifndef AOM_AV1_ENCODER_ENCODEMB_H_
13 #define AOM_AV1_ENCODER_ENCODEMB_H_
14
15 #include "config/aom_config.h"
16
17 #include "av1/common/onyxc_int.h"
18 #include "av1/common/txb_common.h"
19 #include "av1/encoder/block.h"
20 #include "av1/encoder/tokenize.h"
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 struct optimize_ctx {
26 ENTROPY_CONTEXT ta[MAX_MB_PLANE][MAX_MIB_SIZE];
27 ENTROPY_CONTEXT tl[MAX_MB_PLANE][MAX_MIB_SIZE];
28 };
29
30 struct encode_b_args {
31 const struct AV1_COMP *cpi;
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
40 enum {
41 AV1_XFORM_QUANT_FP = 0,
42 AV1_XFORM_QUANT_B = 1,
43 AV1_XFORM_QUANT_DC = 2,
44 AV1_XFORM_QUANT_SKIP_QUANT,
45 AV1_XFORM_QUANT_TYPES,
46 } UENUM1BYTE(AV1_XFORM_QUANT);
47
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);
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
60 void av1_encode_sby_pass1(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
61
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,
64 TX_SIZE tx_size, TX_TYPE tx_type,
65 AV1_XFORM_QUANT xform_quant_idx);
66
67 int av1_optimize_b(const struct AV1_COMP *cpi, MACROBLOCK *mb, int plane,
68 int block, TX_SIZE tx_size, TX_TYPE tx_type,
69 const TXB_CTX *const txb_ctx, int fast_mode, int *rate_cost);
70
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
74 void av1_subtract_plane(MACROBLOCK *x, BLOCK_SIZE bsize, int plane);
75
av1_set_txb_context(MACROBLOCK * x,int plane,int block,TX_SIZE tx_size,ENTROPY_CONTEXT * a,ENTROPY_CONTEXT * l)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 }
83
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);
86
87 void av1_encode_intra_block_plane(const struct AV1_COMP *cpi, MACROBLOCK *x,
88 BLOCK_SIZE bsize, int plane,
89 int enable_optimize_b, int mi_row,
90 int mi_col);
91
92 #ifdef __cplusplus
93 } // extern "C"
94 #endif
95
96 #endif // AOM_AV1_ENCODER_ENCODEMB_H_
97