• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TOKENIZE_H_
13 #define AOM_AV1_ENCODER_TOKENIZE_H_
14 
15 #include "av1/common/entropy.h"
16 #include "av1/encoder/block.h"
17 #include "aom_dsp/bitwriter.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 typedef struct {
24   aom_cdf_prob *color_map_cdf;
25   // TODO(yaowu: use packed enum type if appropriate)
26   uint8_t token;
27 } TOKENEXTRA;
28 
29 struct AV1_COMP;
30 struct ThreadData;
31 struct FRAME_COUNTS;
32 
33 struct tokenize_b_args {
34   const struct AV1_COMP *cpi;
35   struct ThreadData *td;
36   TOKENEXTRA **tp;
37   int this_rate;
38   uint8_t allow_update_cdf;
39 };
40 
41 enum {
42   OUTPUT_ENABLED = 0,
43   DRY_RUN_NORMAL,
44   DRY_RUN_COSTCOEFFS,
45 } UENUM1BYTE(RUN_TYPE);
46 
47 // Note in all the tokenize functions rate if non NULL is incremented
48 // with the coefficient token cost only if dry_run = DRY_RUN_COSTCOEFS,
49 // otherwise rate is not incremented.
50 void av1_tokenize_sb_vartx(const struct AV1_COMP *cpi, struct ThreadData *td,
51                            TOKENEXTRA **t, RUN_TYPE dry_run, int mi_row,
52                            int mi_col, BLOCK_SIZE bsize, int *rate,
53                            uint8_t allow_update_cdf);
54 
55 int av1_cost_color_map(const MACROBLOCK *const x, int plane, BLOCK_SIZE bsize,
56                        TX_SIZE tx_size, COLOR_MAP_TYPE type);
57 
58 void av1_tokenize_color_map(const MACROBLOCK *const x, int plane,
59                             TOKENEXTRA **t, BLOCK_SIZE bsize, TX_SIZE tx_size,
60                             COLOR_MAP_TYPE type, int allow_update_cdf,
61                             struct FRAME_COUNTS *counts);
62 
av1_get_tx_eob(const struct segmentation * seg,int segment_id,TX_SIZE tx_size)63 static INLINE int av1_get_tx_eob(const struct segmentation *seg, int segment_id,
64                                  TX_SIZE tx_size) {
65   const int eob_max = av1_get_max_eob(tx_size);
66   return segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
67 }
68 
69 #ifdef __cplusplus
70 }  // extern "C"
71 #endif
72 
73 #endif  // AOM_AV1_ENCODER_TOKENIZE_H_
74