1 /* 2 * Copyright (c) 2017, 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_ENCODETXB_H_ 13 #define AOM_AV1_ENCODER_ENCODETXB_H_ 14 15 #include "config/aom_config.h" 16 17 #include "av1/common/blockd.h" 18 #include "av1/common/onyxc_int.h" 19 #include "av1/common/txb_common.h" 20 #include "av1/encoder/block.h" 21 #include "av1/encoder/encoder.h" 22 #include "aom_dsp/bitwriter.h" 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 typedef struct TxbInfo { 28 tran_low_t *qcoeff; 29 uint8_t *levels; // absolute values and clamped to 255. 30 tran_low_t *dqcoeff; 31 const tran_low_t *tcoeff; 32 const int16_t *dequant; 33 int shift; 34 TX_SIZE tx_size; 35 TX_SIZE txs_ctx; 36 TX_TYPE tx_type; 37 int bwl; 38 int width; 39 int height; 40 int eob; 41 int seg_eob; 42 const SCAN_ORDER *scan_order; 43 TXB_CTX *txb_ctx; 44 int64_t rdmult; 45 const qm_val_t *iqmatrix; 46 int tx_type_cost; 47 } TxbInfo; 48 49 void av1_alloc_txb_buf(AV1_COMP *cpi); 50 void av1_free_txb_buf(AV1_COMP *cpi); 51 int av1_cost_coeffs_txb(const AV1_COMMON *const cm, const MACROBLOCK *x, 52 const int plane, const int block, const TX_SIZE tx_size, 53 const TX_TYPE tx_type, const TXB_CTX *const txb_ctx); 54 void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd, 55 aom_writer *w, int blk_row, int blk_col, int plane, 56 TX_SIZE tx_size, const tran_low_t *tcoeff, 57 uint16_t eob, TXB_CTX *txb_ctx); 58 void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x, int mi_row, 59 int mi_col, aom_writer *w, BLOCK_SIZE bsize); 60 int av1_get_txb_entropy_context(const tran_low_t *qcoeff, 61 const SCAN_ORDER *scan_order, int eob); 62 void av1_update_txb_context(const AV1_COMP *cpi, ThreadData *td, 63 RUN_TYPE dry_run, BLOCK_SIZE bsize, int *rate, 64 int mi_row, int mi_col, uint8_t allow_update_cdf); 65 66 void av1_update_txb_context_b(int plane, int block, int blk_row, int blk_col, 67 BLOCK_SIZE plane_bsize, TX_SIZE tx_size, 68 void *arg); 69 70 void av1_update_and_record_txb_context(int plane, int block, int blk_row, 71 int blk_col, BLOCK_SIZE plane_bsize, 72 TX_SIZE tx_size, void *arg); 73 74 void av1_set_coeff_buffer(const AV1_COMP *const cpi, MACROBLOCK *const x, 75 int mi_row, int mi_col); 76 77 void hbt_destroy(); 78 int av1_optimize_txb_new(const struct AV1_COMP *cpi, MACROBLOCK *x, int plane, 79 int block, TX_SIZE tx_size, TX_TYPE tx_type, 80 const TXB_CTX *const txb_ctx, int *rate_cost, 81 int sharpness, int fast_mode); 82 83 // These numbers are empirically obtained. 84 static const int plane_rd_mult[REF_TYPES][PLANE_TYPES] = { 85 { 17, 13 }, 86 { 16, 10 }, 87 }; 88 89 #ifdef __cplusplus 90 } 91 #endif 92 93 #endif // AOM_AV1_ENCODER_ENCODETXB_H_ 94