• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * Copyright (C) 2015 Amlogic, Inc. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13  * more details.
14  *
15  */
16 
17 #ifndef AV1_GLOBAL_H_
18 #define AV1_GLOBAL_H_
19 #define AOM_AV1_MMU_DW
20 #ifndef HAVE_NEON
21 #define HAVE_NEON 0
22 #endif
23 #ifndef CONFIG_ACCOUNTING
24 #define CONFIG_ACCOUNTING 0
25 #endif
26 #ifndef CONFIG_INSPECTION
27 #define CONFIG_INSPECTION 0
28 #endif
29 #ifndef CONFIG_LPF_MASK
30 #define CONFIG_LPF_MASK 0
31 #endif
32 #ifndef CONFIG_SIZE_LIMIT
33 #define CONFIG_SIZE_LIMIT 0
34 #endif
35 
36 #define SUPPORT_SCALE_FACTOR
37 #define USE_SCALED_WIDTH_FROM_UCODE
38 #define AML
39 #ifdef CONFIG_AMLOGIC_MEDIA_MULTI_DEC
40 #define AML_DEVICE
41 #endif
42 #ifdef BUFMGR_FOR_SIM
43 #define printf io_printf
44 #endif
45 
46 #ifndef INT_MAX
47 #define INT_MAX 0x7FFFFFFF
48 #endif
49 #define AOMMIN(x, y) (((x) < (y)) ? (x) : (y))
50 #define AOMMAX(x, y) (((x) > (y)) ? (x) : (y))
51 
52 //typedef char int8_t;
53 //#ifndef BUFMGR_FOR_SIM
54 typedef unsigned char uint8_t;
55 //#endif
56 typedef unsigned int uint32_t;
57 //typedef int int32_t;
58 //typedef long long int64_t;
59 
60 #ifdef AML
61 #define AOM_AV1_MMU
62 #define FILM_GRAIN_REG_SIZE  39
63 typedef struct buff_s
64 {
65     uint32_t buf_start;
66     uint32_t buf_size;
67     uint32_t buf_end;
68 } buff_t;
69 
70 typedef struct BuffInfo_s
71 {
72     uint32_t max_width;
73     uint32_t max_height;
74     uint32_t start_adr;
75     uint32_t end_adr;
76     buff_t ipp;
77     buff_t sao_abv;
78     buff_t sao_vb;
79     buff_t short_term_rps;
80     buff_t vps;
81     buff_t seg_map;
82     buff_t daala_top;
83     buff_t sao_up;
84     buff_t swap_buf;
85     buff_t cdf_buf;
86     buff_t gmc_buf;
87     buff_t scalelut;
88     buff_t dblk_para;
89     buff_t dblk_data;
90     buff_t cdef_data;
91     buff_t ups_data;
92 #ifdef AOM_AV1_MMU
93     buff_t mmu_vbh;
94     buff_t cm_header;
95 #endif
96 #ifdef AOM_AV1_MMU_DW
97     buff_t mmu_vbh_dw;
98     buff_t cm_header_dw;
99 #endif
100     buff_t fgs_table;
101     buff_t mpred_above;
102     buff_t mpred_mv;
103     buff_t rpm;
104     buff_t lmem;
105 } BuffInfo_t;
106 #endif
107 
108 #define va_start(v,l)   __builtin_va_start(v,l)
109 #define va_end(v)       __builtin_va_end(v)
110 #define va_arg(v,l)     __builtin_va_arg(v,l)
111 /*
112 mem.h
113 */
114 #if (defined(__GNUC__) && __GNUC__) || defined(__SUNPRO_C)
115 #define DECLARE_ALIGNED(n, typ, val) typ val __attribute__((aligned(n)))
116 #elif defined(_MSC_VER)
117 #define DECLARE_ALIGNED(n, typ, val) __declspec(align(n)) typ val
118 #else
119 #warning No alignment directives known for this compiler.
120 #define DECLARE_ALIGNED(n, typ, val) typ val
121 #endif
122 
123 /* Indicates that the usage of the specified variable has been audited to assure
124  * that it's safe to use uninitialized. Silences 'may be used uninitialized'
125  * warnings on gcc.
126  */
127 #if defined(__GNUC__) && __GNUC__
128 #define UNINITIALIZED_IS_SAFE(x) x = x
129 #else
130 #define UNINITIALIZED_IS_SAFE(x) x
131 #endif
132 
133 #if HAVE_NEON && defined(_MSC_VER)
134 #define __builtin_prefetch(x)
135 #endif
136 
137 /* Shift down with rounding for use when n >= 0, value >= 0 */
138 #define ROUND_POWER_OF_TWO(value, n) (((value) + (((1 << (n)) >> 1))) >> (n))
139 
140 /* Shift down with rounding for signed integers, for use when n >= 0 */
141 #define ROUND_POWER_OF_TWO_SIGNED(value, n)           \
142   (((value) < 0) ? -ROUND_POWER_OF_TWO(-(value), (n)) \
143                  : ROUND_POWER_OF_TWO((value), (n)))
144 
145 /* Shift down with rounding for use when n >= 0, value >= 0 for (64 bit) */
146 #define ROUND_POWER_OF_TWO_64(value, n) \
147   (((value) + ((((int64_t)1 << (n)) >> 1))) >> (n))
148 /* Shift down with rounding for signed integers, for use when n >= 0 (64 bit) */
149 #define ROUND_POWER_OF_TWO_SIGNED_64(value, n)           \
150   (((value) < 0) ? -ROUND_POWER_OF_TWO_64(-(value), (n)) \
151                  : ROUND_POWER_OF_TWO_64((value), (n)))
152 
153 /* shift right or left depending on sign of n */
154 #define RIGHT_SIGNED_SHIFT(value, n) \
155   ((n) < 0 ? ((value) << (-(n))) : ((value) >> (n)))
156 
157 #define ALIGN_POWER_OF_TWO(value, n) \
158   (((value) + ((1 << (n)) - 1)) & ~((1 << (n)) - 1))
159 
160 #define DIVIDE_AND_ROUND(x, y) (((x) + ((y) >> 1)) / (y))
161 
162 #define CONVERT_TO_SHORTPTR(x) ((uint16_t *)(((uintptr_t)(x)) << 1))
163 #define CONVERT_TO_BYTEPTR(x) ((uint8_t *)(((uintptr_t)(x)) >> 1))
164 
165 #ifdef AML
166 #define TYPEDEF typedef
167 #define UENUM1BYTE(enumvar) enumvar
168 #define SENUM1BYTE(enumvar) enumvar
169 #define UENUM2BYTE(enumvar) enumvar
170 #define SENUM2BYTE(enumvar) enumvar
171 #define UENUM4BYTE(enumvar) enumvar
172 #define SENUM4BYTE(enumvar) enumvar
173 
174 #else
175 #define TYPEDEF
176 /*!\brief force enum to be unsigned 1 byte*/
177 #define UENUM1BYTE(enumvar) \
178   ;                         \
179   typedef uint8_t enumvar
180 
181 /*!\brief force enum to be signed 1 byte*/
182 #define SENUM1BYTE(enumvar) \
183   ;                         \
184   typedef int8_t enumvar
185 
186 /*!\brief force enum to be unsigned 2 byte*/
187 #define UENUM2BYTE(enumvar) \
188   ;                         \
189   typedef uint16_t enumvar
190 
191 /*!\brief force enum to be signed 2 byte*/
192 #define SENUM2BYTE(enumvar) \
193   ;                         \
194   typedef int16_t enumvar
195 
196 /*!\brief force enum to be unsigned 4 byte*/
197 #define UENUM4BYTE(enumvar) \
198   ;                         \
199   typedef uint32_t enumvar
200 
201 /*!\brief force enum to be unsigned 4 byte*/
202 #define SENUM4BYTE(enumvar) \
203   ;                         \
204   typedef int32_t enumvar
205 #endif
206 
207 
208 /*
209 #include "enums.h"
210 */
211 #undef MAX_SB_SIZE
212 
213 // Max superblock size
214 #define MAX_SB_SIZE_LOG2 7
215 #define MAX_SB_SIZE (1 << MAX_SB_SIZE_LOG2)
216 #define MAX_SB_SQUARE (MAX_SB_SIZE * MAX_SB_SIZE)
217 
218 // Min superblock size
219 #define MIN_SB_SIZE_LOG2 6
220 
221 // Pixels per Mode Info (MI) unit
222 #define MI_SIZE_LOG2 2
223 #define MI_SIZE (1 << MI_SIZE_LOG2)
224 
225 // MI-units per max superblock (MI Block - MIB)
226 #define MAX_MIB_SIZE_LOG2 (MAX_SB_SIZE_LOG2 - MI_SIZE_LOG2)
227 #define MAX_MIB_SIZE (1 << MAX_MIB_SIZE_LOG2)
228 
229 // MI-units per min superblock
230 #define MIN_MIB_SIZE_LOG2 (MIN_SB_SIZE_LOG2 - MI_SIZE_LOG2)
231 
232 // Mask to extract MI offset within max MIB
233 #define MAX_MIB_MASK (MAX_MIB_SIZE - 1)
234 
235 // Maximum number of tile rows and tile columns
236 #define MAX_TILE_ROWS 64
237 #define MAX_TILE_COLS 64
238 
239 #define MAX_VARTX_DEPTH 2
240 
241 #define MI_SIZE_64X64 (64 >> MI_SIZE_LOG2)
242 #define MI_SIZE_128X128 (128 >> MI_SIZE_LOG2)
243 
244 #define MAX_PALETTE_SQUARE (64 * 64)
245 // Maximum number of colors in a palette.
246 #define PALETTE_MAX_SIZE 8
247 // Minimum number of colors in a palette.
248 #define PALETTE_MIN_SIZE 2
249 
250 #define FRAME_OFFSET_BITS 5
251 #define MAX_FRAME_DISTANCE ((1 << FRAME_OFFSET_BITS) - 1)
252 
253 // 4 frame filter levels: y plane vertical, y plane horizontal,
254 // u plane, and v plane
255 #define FRAME_LF_COUNT 4
256 #define DEFAULT_DELTA_LF_MULTI 0
257 #define MAX_MODE_LF_DELTAS 2
258 
259 #define DIST_PRECISION_BITS 4
260 #define DIST_PRECISION (1 << DIST_PRECISION_BITS)  // 16
261 
262 #define PROFILE_BITS 3
263 // The following three profiles are currently defined.
264 // Profile 0.  8-bit and 10-bit 4:2:0 and 4:0:0 only.
265 // Profile 1.  8-bit and 10-bit 4:4:4
266 // Profile 2.  8-bit and 10-bit 4:2:2
267 //            12-bit  4:0:0, 4:2:2 and 4:4:4
268 // Since we have three bits for the profiles, it can be extended later.
269 TYPEDEF enum {
270   PROFILE_0,
271   PROFILE_1,
272   PROFILE_2,
273   MAX_PROFILES,
274 } SENUM1BYTE(BITSTREAM_PROFILE);
275 
276 #define OP_POINTS_CNT_MINUS_1_BITS 5
277 #define OP_POINTS_IDC_BITS 12
278 
279 // Note: Some enums use the attribute 'packed' to use smallest possible integer
280 // type, so that we can save memory when they are used in structs/arrays.
281 
282 typedef enum ATTRIBUTE_PACKED {
283   BLOCK_4X4,
284   BLOCK_4X8,
285   BLOCK_8X4,
286   BLOCK_8X8,
287   BLOCK_8X16,
288   BLOCK_16X8,
289   BLOCK_16X16,
290   BLOCK_16X32,
291   BLOCK_32X16,
292   BLOCK_32X32,
293   BLOCK_32X64,
294   BLOCK_64X32,
295   BLOCK_64X64,
296   BLOCK_64X128,
297   BLOCK_128X64,
298   BLOCK_128X128,
299   BLOCK_4X16,
300   BLOCK_16X4,
301   BLOCK_8X32,
302   BLOCK_32X8,
303   BLOCK_16X64,
304   BLOCK_64X16,
305   BLOCK_SIZES_ALL,
306   BLOCK_SIZES = BLOCK_4X16,
307   BLOCK_INVALID = 255,
308   BLOCK_LARGEST = (BLOCK_SIZES - 1)
309 } BLOCK_SIZE2;
310 
311 // 4X4, 8X8, 16X16, 32X32, 64X64, 128X128
312 #define SQR_BLOCK_SIZES 6
313 
314 TYPEDEF enum {
315   PARTITION_NONE,
316   PARTITION_HORZ,
317   PARTITION_VERT,
318   PARTITION_SPLIT,
319   PARTITION_HORZ_A,  // HORZ split and the top partition is split again
320   PARTITION_HORZ_B,  // HORZ split and the bottom partition is split again
321   PARTITION_VERT_A,  // VERT split and the left partition is split again
322   PARTITION_VERT_B,  // VERT split and the right partition is split again
323   PARTITION_HORZ_4,  // 4:1 horizontal partition
324   PARTITION_VERT_4,  // 4:1 vertical partition
325   EXT_PARTITION_TYPES,
326   PARTITION_TYPES = PARTITION_SPLIT + 1,
327   PARTITION_INVALID = 255
328 } UENUM1BYTE(PARTITION_TYPE);
329 
330 typedef char PARTITION_CONTEXT;
331 #define PARTITION_PLOFFSET 4  // number of probability models per block size
332 #define PARTITION_BLOCK_SIZES 5
333 #define PARTITION_CONTEXTS (PARTITION_BLOCK_SIZES * PARTITION_PLOFFSET)
334 
335 // block transform size
336 TYPEDEF enum {
337   TX_4X4,             // 4x4 transform
338   TX_8X8,             // 8x8 transform
339   TX_16X16,           // 16x16 transform
340   TX_32X32,           // 32x32 transform
341   TX_64X64,           // 64x64 transform
342   TX_4X8,             // 4x8 transform
343   TX_8X4,             // 8x4 transform
344   TX_8X16,            // 8x16 transform
345   TX_16X8,            // 16x8 transform
346   TX_16X32,           // 16x32 transform
347   TX_32X16,           // 32x16 transform
348   TX_32X64,           // 32x64 transform
349   TX_64X32,           // 64x32 transform
350   TX_4X16,            // 4x16 transform
351   TX_16X4,            // 16x4 transform
352   TX_8X32,            // 8x32 transform
353   TX_32X8,            // 32x8 transform
354   TX_16X64,           // 16x64 transform
355   TX_64X16,           // 64x16 transform
356   TX_SIZES_ALL,       // Includes rectangular transforms
357   TX_SIZES = TX_4X8,  // Does NOT include rectangular transforms
358   TX_SIZES_LARGEST = TX_64X64,
359   TX_INVALID = 255  // Invalid transform size
360 } UENUM1BYTE(TX_SIZE);
361 
362 #define TX_SIZE_LUMA_MIN (TX_4X4)
363 /* We don't need to code a transform size unless the allowed size is at least
364    one more than the minimum. */
365 #define TX_SIZE_CTX_MIN (TX_SIZE_LUMA_MIN + 1)
366 
367 // Maximum tx_size categories
368 #define MAX_TX_CATS (TX_SIZES - TX_SIZE_CTX_MIN)
369 #define MAX_TX_DEPTH 2
370 
371 #define MAX_TX_SIZE_LOG2 (6)
372 #define MAX_TX_SIZE (1 << MAX_TX_SIZE_LOG2)
373 #define MIN_TX_SIZE_LOG2 2
374 #define MIN_TX_SIZE (1 << MIN_TX_SIZE_LOG2)
375 #define MAX_TX_SQUARE (MAX_TX_SIZE * MAX_TX_SIZE)
376 
377 // Pad 4 extra columns to remove horizontal availability check.
378 #define TX_PAD_HOR_LOG2 2
379 #define TX_PAD_HOR 4
380 // Pad 6 extra rows (2 on top and 4 on bottom) to remove vertical availability
381 // check.
382 #define TX_PAD_TOP 0
383 #define TX_PAD_BOTTOM 4
384 #define TX_PAD_VER (TX_PAD_TOP + TX_PAD_BOTTOM)
385 // Pad 16 extra bytes to avoid reading overflow in SIMD optimization.
386 #define TX_PAD_END 16
387 #define TX_PAD_2D ((32 + TX_PAD_HOR) * (32 + TX_PAD_VER) + TX_PAD_END)
388 
389 // Number of maxium size transform blocks in the maximum size superblock
390 #define MAX_TX_BLOCKS_IN_MAX_SB_LOG2 ((MAX_SB_SIZE_LOG2 - MAX_TX_SIZE_LOG2) * 2)
391 #define MAX_TX_BLOCKS_IN_MAX_SB (1 << MAX_TX_BLOCKS_IN_MAX_SB_LOG2)
392 
393 // frame transform mode
394 TYPEDEF enum {
395   ONLY_4X4,         // use only 4x4 transform
396   TX_MODE_LARGEST,  // transform size is the largest possible for pu size
397   TX_MODE_SELECT,   // transform specified for each block
398   TX_MODES,
399 } UENUM1BYTE(TX_MODE);
400 
401 // 1D tx types
402 TYPEDEF enum {
403   DCT_1D,
404   ADST_1D,
405   FLIPADST_1D,
406   IDTX_1D,
407   TX_TYPES_1D,
408 } UENUM1BYTE(TX_TYPE_1D);
409 
410 TYPEDEF enum {
411   DCT_DCT,            // DCT in both horizontal and vertical
412   ADST_DCT,           // ADST in vertical, DCT in horizontal
413   DCT_ADST,           // DCT in vertical, ADST in horizontal
414   ADST_ADST,          // ADST in both directions
415   FLIPADST_DCT,       // FLIPADST in vertical, DCT in horizontal
416   DCT_FLIPADST,       // DCT in vertical, FLIPADST in horizontal
417   FLIPADST_FLIPADST,  // FLIPADST in both directions
418   ADST_FLIPADST,      // ADST in vertical, FLIPADST in horizontal
419   FLIPADST_ADST,      // FLIPADST in vertical, ADST in horizontal
420   IDTX,               // Identity in both directions
421   V_DCT,              // DCT in vertical, identity in horizontal
422   H_DCT,              // Identity in vertical, DCT in horizontal
423   V_ADST,             // ADST in vertical, identity in horizontal
424   H_ADST,             // Identity in vertical, ADST in horizontal
425   V_FLIPADST,         // FLIPADST in vertical, identity in horizontal
426   H_FLIPADST,         // Identity in vertical, FLIPADST in horizontal
427   TX_TYPES,
428 } UENUM1BYTE(TX_TYPE);
429 
430 TYPEDEF enum {
431   REG_REG,
432   REG_SMOOTH,
433   REG_SHARP,
434   SMOOTH_REG,
435   SMOOTH_SMOOTH,
436   SMOOTH_SHARP,
437   SHARP_REG,
438   SHARP_SMOOTH,
439   SHARP_SHARP,
440 } UENUM1BYTE(DUAL_FILTER_TYPE);
441 
442 TYPEDEF enum {
443   // DCT only
444   EXT_TX_SET_DCTONLY,
445   // DCT + Identity only
446   EXT_TX_SET_DCT_IDTX,
447   // Discrete Trig transforms w/o flip (4) + Identity (1)
448   EXT_TX_SET_DTT4_IDTX,
449   // Discrete Trig transforms w/o flip (4) + Identity (1) + 1D Hor/vert DCT (2)
450   EXT_TX_SET_DTT4_IDTX_1DDCT,
451   // Discrete Trig transforms w/ flip (9) + Identity (1) + 1D Hor/Ver DCT (2)
452   EXT_TX_SET_DTT9_IDTX_1DDCT,
453   // Discrete Trig transforms w/ flip (9) + Identity (1) + 1D Hor/Ver (6)
454   EXT_TX_SET_ALL16,
455   EXT_TX_SET_TYPES
456 } UENUM1BYTE(TxSetType);
457 
458 #define IS_2D_TRANSFORM(tx_type) (tx_type < IDTX)
459 
460 #define EXT_TX_SIZES 4       // number of sizes that use extended transforms
461 #define EXT_TX_SETS_INTER 4  // Sets of transform selections for INTER
462 #define EXT_TX_SETS_INTRA 3  // Sets of transform selections for INTRA
463 
464 TYPEDEF enum {
465   AOM_LAST_FLAG = 1 << 0,
466   AOM_LAST2_FLAG = 1 << 1,
467   AOM_LAST3_FLAG = 1 << 2,
468   AOM_GOLD_FLAG = 1 << 3,
469   AOM_BWD_FLAG = 1 << 4,
470   AOM_ALT2_FLAG = 1 << 5,
471   AOM_ALT_FLAG = 1 << 6,
472   AOM_REFFRAME_ALL = (1 << 7) - 1
473 } UENUM1BYTE(AOM_REFFRAME);
474 
475 TYPEDEF enum {
476   UNIDIR_COMP_REFERENCE,
477   BIDIR_COMP_REFERENCE,
478   COMP_REFERENCE_TYPES,
479 } UENUM1BYTE(COMP_REFERENCE_TYPE);
480 
481 /*enum { PLANE_TYPE_Y, PLANE_TYPE_UV, PLANE_TYPES } UENUM1BYTE(PLANE_TYPE);*/
482 
483 #define CFL_ALPHABET_SIZE_LOG2 4
484 #define CFL_ALPHABET_SIZE (1 << CFL_ALPHABET_SIZE_LOG2)
485 #define CFL_MAGS_SIZE ((2 << CFL_ALPHABET_SIZE_LOG2) + 1)
486 #define CFL_IDX_U(idx) (idx >> CFL_ALPHABET_SIZE_LOG2)
487 #define CFL_IDX_V(idx) (idx & (CFL_ALPHABET_SIZE - 1))
488 
489 /*enum { CFL_PRED_U, CFL_PRED_V, CFL_PRED_PLANES } UENUM1BYTE(CFL_PRED_TYPE);*/
490 
491 TYPEDEF enum {
492   CFL_SIGN_ZERO,
493   CFL_SIGN_NEG,
494   CFL_SIGN_POS,
495   CFL_SIGNS
496 } UENUM1BYTE(CFL_SIGN_TYPE);
497 
498 TYPEDEF enum {
499   CFL_DISALLOWED,
500   CFL_ALLOWED,
501   CFL_ALLOWED_TYPES
502 } UENUM1BYTE(CFL_ALLOWED_TYPE);
503 
504 // CFL_SIGN_ZERO,CFL_SIGN_ZERO is invalid
505 #define CFL_JOINT_SIGNS (CFL_SIGNS * CFL_SIGNS - 1)
506 // CFL_SIGN_U is equivalent to (js + 1) / 3 for js in 0 to 8
507 #define CFL_SIGN_U(js) (((js + 1) * 11) >> 5)
508 // CFL_SIGN_V is equivalent to (js + 1) % 3 for js in 0 to 8
509 #define CFL_SIGN_V(js) ((js + 1) - CFL_SIGNS * CFL_SIGN_U(js))
510 
511 // There is no context when the alpha for a given plane is zero.
512 // So there are 2 fewer contexts than joint signs.
513 #define CFL_ALPHA_CONTEXTS (CFL_JOINT_SIGNS + 1 - CFL_SIGNS)
514 #define CFL_CONTEXT_U(js) (js + 1 - CFL_SIGNS)
515 // Also, the contexts are symmetric under swapping the planes.
516 #define CFL_CONTEXT_V(js) \
517   (CFL_SIGN_V(js) * CFL_SIGNS + CFL_SIGN_U(js) - CFL_SIGNS)
518 
519 TYPEDEF enum {
520   PALETTE_MAP,
521   COLOR_MAP_TYPES,
522 } UENUM1BYTE(COLOR_MAP_TYPE);
523 
524 TYPEDEF enum {
525   TWO_COLORS,
526   THREE_COLORS,
527   FOUR_COLORS,
528   FIVE_COLORS,
529   SIX_COLORS,
530   SEVEN_COLORS,
531   EIGHT_COLORS,
532   PALETTE_SIZES
533 } UENUM1BYTE(PALETTE_SIZE);
534 
535 TYPEDEF enum {
536   PALETTE_COLOR_ONE,
537   PALETTE_COLOR_TWO,
538   PALETTE_COLOR_THREE,
539   PALETTE_COLOR_FOUR,
540   PALETTE_COLOR_FIVE,
541   PALETTE_COLOR_SIX,
542   PALETTE_COLOR_SEVEN,
543   PALETTE_COLOR_EIGHT,
544   PALETTE_COLORS
545 } UENUM1BYTE(PALETTE_COLOR);
546 
547 // Note: All directional predictors must be between V_PRED and D67_PRED (both
548 // inclusive).
549 TYPEDEF enum {
550   DC_PRED,        // Average of above and left pixels
551   V_PRED,         // Vertical
552   H_PRED,         // Horizontal
553   D45_PRED,       // Directional 45  degree
554   D135_PRED,      // Directional 135 degree
555   D113_PRED,      // Directional 113 degree
556   D157_PRED,      // Directional 157 degree
557   D203_PRED,      // Directional 203 degree
558   D67_PRED,       // Directional 67  degree
559   SMOOTH_PRED,    // Combination of horizontal and vertical interpolation
560   SMOOTH_V_PRED,  // Vertical interpolation
561   SMOOTH_H_PRED,  // Horizontal interpolation
562   PAETH_PRED,     // Predict from the direction of smallest gradient
563   NEARESTMV,
564   NEARMV,
565   GLOBALMV,
566   NEWMV,
567   // Compound ref compound modes
568   NEAREST_NEARESTMV,
569   NEAR_NEARMV,
570   NEAREST_NEWMV,
571   NEW_NEARESTMV,
572   NEAR_NEWMV,
573   NEW_NEARMV,
574   GLOBAL_GLOBALMV,
575   NEW_NEWMV,
576   MB_MODE_COUNT,
577   INTRA_MODE_START = DC_PRED,
578   INTRA_MODE_END = NEARESTMV,
579   INTRA_MODE_NUM = INTRA_MODE_END - INTRA_MODE_START,
580   SINGLE_INTER_MODE_START = NEARESTMV,
581   SINGLE_INTER_MODE_END = NEAREST_NEARESTMV,
582   SINGLE_INTER_MODE_NUM = SINGLE_INTER_MODE_END - SINGLE_INTER_MODE_START,
583   COMP_INTER_MODE_START = NEAREST_NEARESTMV,
584   COMP_INTER_MODE_END = MB_MODE_COUNT,
585   COMP_INTER_MODE_NUM = COMP_INTER_MODE_END - COMP_INTER_MODE_START,
586   INTER_MODE_START = NEARESTMV,
587   INTER_MODE_END = MB_MODE_COUNT,
588   INTRA_MODES = PAETH_PRED + 1,  // PAETH_PRED has to be the last intra mode.
589   INTRA_INVALID = MB_MODE_COUNT  // For uv_mode in inter blocks
590 } UENUM1BYTE(PREDICTION_MODE);
591 
592 // TODO(ltrudeau) Do we really want to pack this?
593 // TODO(ltrudeau) Do we match with PREDICTION_MODE?
594 TYPEDEF enum {
595   UV_DC_PRED,        // Average of above and left pixels
596   UV_V_PRED,         // Vertical
597   UV_H_PRED,         // Horizontal
598   UV_D45_PRED,       // Directional 45  degree
599   UV_D135_PRED,      // Directional 135 degree
600   UV_D113_PRED,      // Directional 113 degree
601   UV_D157_PRED,      // Directional 157 degree
602   UV_D203_PRED,      // Directional 203 degree
603   UV_D67_PRED,       // Directional 67  degree
604   UV_SMOOTH_PRED,    // Combination of horizontal and vertical interpolation
605   UV_SMOOTH_V_PRED,  // Vertical interpolation
606   UV_SMOOTH_H_PRED,  // Horizontal interpolation
607   UV_PAETH_PRED,     // Predict from the direction of smallest gradient
608   UV_CFL_PRED,       // Chroma-from-Luma
609   UV_INTRA_MODES,
610   UV_MODE_INVALID,  // For uv_mode in inter blocks
611 } UENUM1BYTE(UV_PREDICTION_MODE);
612 
613 TYPEDEF enum {
614   SIMPLE_TRANSLATION,
615   OBMC_CAUSAL,    // 2-sided OBMC
616   WARPED_CAUSAL,  // 2-sided WARPED
617   MOTION_MODES
618 } UENUM1BYTE(MOTION_MODE);
619 
620 TYPEDEF enum {
621   II_DC_PRED,
622   II_V_PRED,
623   II_H_PRED,
624   II_SMOOTH_PRED,
625   INTERINTRA_MODES
626 } UENUM1BYTE(INTERINTRA_MODE);
627 
628 TYPEDEF enum {
629   COMPOUND_AVERAGE,
630   COMPOUND_DISTWTD,
631   COMPOUND_WEDGE,
632   COMPOUND_DIFFWTD,
633   COMPOUND_TYPES,
634   MASKED_COMPOUND_TYPES = 2,
635 } UENUM1BYTE(COMPOUND_TYPE);
636 
637 TYPEDEF enum {
638   FILTER_DC_PRED,
639   FILTER_V_PRED,
640   FILTER_H_PRED,
641   FILTER_D157_PRED,
642   FILTER_PAETH_PRED,
643   FILTER_INTRA_MODES,
644 } UENUM1BYTE(FILTER_INTRA_MODE);
645 
646 TYPEDEF enum {
647   SEQ_LEVEL_2_0,
648   SEQ_LEVEL_2_1,
649   SEQ_LEVEL_2_2,
650   SEQ_LEVEL_2_3,
651   SEQ_LEVEL_3_0,
652   SEQ_LEVEL_3_1,
653   SEQ_LEVEL_3_2,
654   SEQ_LEVEL_3_3,
655   SEQ_LEVEL_4_0,
656   SEQ_LEVEL_4_1,
657   SEQ_LEVEL_4_2,
658   SEQ_LEVEL_4_3,
659   SEQ_LEVEL_5_0,
660   SEQ_LEVEL_5_1,
661   SEQ_LEVEL_5_2,
662   SEQ_LEVEL_5_3,
663   SEQ_LEVEL_6_0,
664   SEQ_LEVEL_6_1,
665   SEQ_LEVEL_6_2,
666   SEQ_LEVEL_6_3,
667   SEQ_LEVEL_7_0,
668   SEQ_LEVEL_7_1,
669   SEQ_LEVEL_7_2,
670   SEQ_LEVEL_7_3,
671   SEQ_LEVELS,
672   SEQ_LEVEL_MAX = 31
673 } UENUM1BYTE(AV1_LEVEL);
674 
675 #define LEVEL_BITS 5
676 
677 #define DIRECTIONAL_MODES 8
678 #define MAX_ANGLE_DELTA 3
679 #define ANGLE_STEP 3
680 
681 #define INTER_MODES (1 + NEWMV - NEARESTMV)
682 
683 #define INTER_COMPOUND_MODES (1 + NEW_NEWMV - NEAREST_NEARESTMV)
684 
685 #define SKIP_CONTEXTS 3
686 #define SKIP_MODE_CONTEXTS 3
687 
688 #define COMP_INDEX_CONTEXTS 6
689 #define COMP_GROUP_IDX_CONTEXTS 6
690 
691 #define NMV_CONTEXTS 3
692 
693 #define NEWMV_MODE_CONTEXTS 6
694 #define GLOBALMV_MODE_CONTEXTS 2
695 #define REFMV_MODE_CONTEXTS 6
696 #define DRL_MODE_CONTEXTS 3
697 
698 #define GLOBALMV_OFFSET 3
699 #define REFMV_OFFSET 4
700 
701 #define NEWMV_CTX_MASK ((1 << GLOBALMV_OFFSET) - 1)
702 #define GLOBALMV_CTX_MASK ((1 << (REFMV_OFFSET - GLOBALMV_OFFSET)) - 1)
703 #define REFMV_CTX_MASK ((1 << (8 - REFMV_OFFSET)) - 1)
704 
705 #define COMP_NEWMV_CTXS 5
706 #define INTER_MODE_CONTEXTS 8
707 
708 #define DELTA_Q_SMALL 3
709 #define DELTA_Q_PROBS (DELTA_Q_SMALL)
710 #define DEFAULT_DELTA_Q_RES_PERCEPTUAL 4
711 #define DEFAULT_DELTA_Q_RES_OBJECTIVE 4
712 
713 #define DELTA_LF_SMALL 3
714 #define DELTA_LF_PROBS (DELTA_LF_SMALL)
715 #define DEFAULT_DELTA_LF_RES 2
716 
717 /* Segment Feature Masks */
718 #define MAX_MV_REF_CANDIDATES 2
719 
720 #define MAX_REF_MV_STACK_SIZE 8
721 #define REF_CAT_LEVEL 640
722 
723 #define INTRA_INTER_CONTEXTS 4
724 #define COMP_INTER_CONTEXTS 5
725 #define REF_CONTEXTS 3
726 
727 #define COMP_REF_TYPE_CONTEXTS 5
728 #define UNI_COMP_REF_CONTEXTS 3
729 
730 #define TXFM_PARTITION_CONTEXTS ((TX_SIZES - TX_8X8) * 6 - 3)
731 #ifdef ORI_CODE
732 typedef uint8_t TXFM_CONTEXT;
733 #endif
734 // An enum for single reference types (and some derived values).
735 enum {
736   NONE_FRAME = -1,
737   INTRA_FRAME,
738   LAST_FRAME,
739   LAST2_FRAME,
740   LAST3_FRAME,
741   GOLDEN_FRAME,
742   BWDREF_FRAME,
743   ALTREF2_FRAME,
744   ALTREF_FRAME,
745   REF_FRAMES,
746 
747   // Extra/scratch reference frame. It may be:
748   // - used to update the ALTREF2_FRAME ref (see lshift_bwd_ref_frames()), or
749   // - updated from ALTREF2_FRAME ref (see rshift_bwd_ref_frames()).
750   EXTREF_FRAME = REF_FRAMES,
751 
752   // Number of inter (non-intra) reference types.
753   INTER_REFS_PER_FRAME = ALTREF_FRAME - LAST_FRAME + 1,
754 
755   // Number of forward (aka past) reference types.
756   FWD_REFS = GOLDEN_FRAME - LAST_FRAME + 1,
757 
758   // Number of backward (aka future) reference types.
759   BWD_REFS = ALTREF_FRAME - BWDREF_FRAME + 1,
760 
761   SINGLE_REFS = FWD_REFS + BWD_REFS,
762 };
763 
764 #define REF_FRAMES_LOG2 3
765 
766 // REF_FRAMES for the cm->ref_frame_map array, 1 scratch frame for the new
767 // frame in cm->cur_frame, INTER_REFS_PER_FRAME for scaled references on the
768 // encoder in the cpi->scaled_ref_buf array.
769 #define FRAME_BUFFERS (REF_FRAMES + 1 + INTER_REFS_PER_FRAME)
770 
771 #define FWD_RF_OFFSET(ref) (ref - LAST_FRAME)
772 #define BWD_RF_OFFSET(ref) (ref - BWDREF_FRAME)
773 
774 TYPEDEF enum {
775   LAST_LAST2_FRAMES,      // { LAST_FRAME, LAST2_FRAME }
776   LAST_LAST3_FRAMES,      // { LAST_FRAME, LAST3_FRAME }
777   LAST_GOLDEN_FRAMES,     // { LAST_FRAME, GOLDEN_FRAME }
778   BWDREF_ALTREF_FRAMES,   // { BWDREF_FRAME, ALTREF_FRAME }
779   LAST2_LAST3_FRAMES,     // { LAST2_FRAME, LAST3_FRAME }
780   LAST2_GOLDEN_FRAMES,    // { LAST2_FRAME, GOLDEN_FRAME }
781   LAST3_GOLDEN_FRAMES,    // { LAST3_FRAME, GOLDEN_FRAME }
782   BWDREF_ALTREF2_FRAMES,  // { BWDREF_FRAME, ALTREF2_FRAME }
783   ALTREF2_ALTREF_FRAMES,  // { ALTREF2_FRAME, ALTREF_FRAME }
784   TOTAL_UNIDIR_COMP_REFS,
785   // NOTE: UNIDIR_COMP_REFS is the number of uni-directional reference pairs
786   //       that are explicitly signaled.
787   UNIDIR_COMP_REFS = BWDREF_ALTREF_FRAMES + 1,
788 } UENUM1BYTE(UNIDIR_COMP_REF);
789 
790 #define TOTAL_COMP_REFS (FWD_REFS * BWD_REFS + TOTAL_UNIDIR_COMP_REFS)
791 
792 #define COMP_REFS (FWD_REFS * BWD_REFS + UNIDIR_COMP_REFS)
793 
794 // NOTE: A limited number of unidirectional reference pairs can be signalled for
795 //       compound prediction. The use of skip mode, on the other hand, makes it
796 //       possible to have a reference pair not listed for explicit signaling.
797 #define MODE_CTX_REF_FRAMES (REF_FRAMES + TOTAL_COMP_REFS)
798 
799 // Note: It includes single and compound references. So, it can take values from
800 // NONE_FRAME to (MODE_CTX_REF_FRAMES - 1). Hence, it is not defined as an enum.
801 typedef int8_t MV_REFERENCE_FRAME;
802 
803 TYPEDEF enum {
804   RESTORE_NONE,
805   RESTORE_WIENER,
806   RESTORE_SGRPROJ,
807   RESTORE_SWITCHABLE,
808   RESTORE_SWITCHABLE_TYPES = RESTORE_SWITCHABLE,
809   RESTORE_TYPES = 4,
810 } UENUM1BYTE(RestorationType);
811 
812 // Picture prediction structures (0-12 are predefined) in scalability metadata.
813 TYPEDEF enum {
814   SCALABILITY_L1T2 = 0,
815   SCALABILITY_L1T3 = 1,
816   SCALABILITY_L2T1 = 2,
817   SCALABILITY_L2T2 = 3,
818   SCALABILITY_L2T3 = 4,
819   SCALABILITY_S2T1 = 5,
820   SCALABILITY_S2T2 = 6,
821   SCALABILITY_S2T3 = 7,
822   SCALABILITY_L2T1h = 8,
823   SCALABILITY_L2T2h = 9,
824   SCALABILITY_L2T3h = 10,
825   SCALABILITY_S2T1h = 11,
826   SCALABILITY_S2T2h = 12,
827   SCALABILITY_S2T3h = 13,
828   SCALABILITY_SS = 14
829 } UENUM1BYTE(SCALABILITY_STRUCTURES);
830 
831 #define SUPERRES_SCALE_BITS 3
832 #define SUPERRES_SCALE_DENOMINATOR_MIN (SCALE_NUMERATOR + 1)
833 
834 // In large_scale_tile coding, external references are used.
835 #define MAX_EXTERNAL_REFERENCES 128
836 #define MAX_TILES 512
837 
838 
839 #define CONFIG_MULTITHREAD 0
840 #define CONFIG_ENTROPY_STATS 0
841 
842 #define CONFIG_MAX_DECODE_PROFILE 2
843 
844 /*
845 from:
846 seg_common.h
847 */
848 #ifdef ORI_CODE
849 
850 #define MAX_SEGMENTS 8
851 #define SEG_TREE_PROBS (MAX_SEGMENTS - 1)
852 
853 #define SEG_TEMPORAL_PRED_CTXS 3
854 #define SPATIAL_PREDICTION_PROBS 3
855 
856 enum {
857   SEG_LVL_ALT_Q,       // Use alternate Quantizer ....
858   SEG_LVL_ALT_LF_Y_V,  // Use alternate loop filter value on y plane vertical
859   SEG_LVL_ALT_LF_Y_H,  // Use alternate loop filter value on y plane horizontal
860   SEG_LVL_ALT_LF_U,    // Use alternate loop filter value on u plane
861   SEG_LVL_ALT_LF_V,    // Use alternate loop filter value on v plane
862   SEG_LVL_REF_FRAME,   // Optional Segment reference frame
863   SEG_LVL_SKIP,        // Optional Segment (0,0) + skip mode
864   SEG_LVL_GLOBALMV,
865   SEG_LVL_MAX
866 } UENUM1BYTE(SEG_LVL_FEATURES);
867 
868 struct segmentation {
869   uint8_t enabled;
870   uint8_t update_map;
871   uint8_t update_data;
872   uint8_t temporal_update;
873 
874   int16_t feature_data[MAX_SEGMENTS][SEG_LVL_MAX];
875   unsigned int feature_mask[MAX_SEGMENTS];
876   int last_active_segid;  // The highest numbered segment id that has some
877                           // enabled feature.
878   uint8_t segid_preskip;  // Whether the segment id will be read before the
879                           // skip syntax element.
880                           // 1: the segment id will be read first.
881                           // 0: the skip syntax element will be read first.
882 };
883 
884 /*
885 from av1_loopfilter.h
886 */
887 #define MAX_LOOP_FILTER 63
888 
889 
890 /* from
891 quant_common.h:
892 */
893 #define MAXQ 255
894 
895 #endif
896 
897 /*
898 from:
899 aom/av1/common/common.h
900 */
901 #define av1_zero(dest) memset(&(dest), 0, sizeof(dest))
902 #define av1_zero_array(dest, n) memset(dest, 0, n * sizeof(*(dest)))
903 /*
904 from:
905 aom/av1/common/alloccommon.h
906 */
907 #define INVALID_IDX -1  // Invalid buffer index.
908 
909 /*
910 from:
911 aom/av1/common/timing.h
912 */
913 typedef struct aom_timing {
914   uint32_t num_units_in_display_tick;
915   uint32_t time_scale;
916   int equal_picture_interval;
917   uint32_t num_ticks_per_picture;
918 } aom_timing_info_t;
919 
920 typedef struct aom_dec_model_info {
921   uint32_t num_units_in_decoding_tick;
922   int encoder_decoder_buffer_delay_length;
923   int buffer_removal_time_length;
924   int frame_presentation_time_length;
925 } aom_dec_model_info_t;
926 
927 typedef struct aom_dec_model_op_parameters {
928   int decoder_model_param_present_flag;
929   int64_t bitrate;
930   int64_t buffer_size;
931   uint32_t decoder_buffer_delay;
932   uint32_t encoder_buffer_delay;
933   int low_delay_mode_flag;
934   int display_model_param_present_flag;
935   int initial_display_delay;
936 } aom_dec_model_op_parameters_t;
937 
938 typedef struct aom_op_timing_info_t {
939   uint32_t buffer_removal_time;
940 } aom_op_timing_info_t;
941 /*
942 from:
943 aom/aom_codec.h
944 */
945 /*!\brief OBU types. */
946 typedef enum {
947   OBU_SEQUENCE_HEADER = 1,
948   OBU_TEMPORAL_DELIMITER = 2,
949   OBU_FRAME_HEADER = 3,
950   OBU_TILE_GROUP = 4,
951   OBU_METADATA = 5,
952   OBU_FRAME = 6,
953   OBU_REDUNDANT_FRAME_HEADER = 7,
954   OBU_TILE_LIST = 8,
955   OBU_PADDING = 15,
956 } OBU_TYPE;
957 
958 typedef enum aom_bit_depth {
959   AOM_BITS_8 = 8,   /**<  8 bits */
960   AOM_BITS_10 = 10, /**< 10 bits */
961   AOM_BITS_12 = 12, /**< 12 bits */
962 } aom_bit_depth_t;
963 
964 /*!\brief Algorithm return codes */
965 typedef enum {
966   /*!\brief Operation completed without error */
967   AOM_CODEC_OK,
968 
969   /*!\brief Unspecified error */
970   AOM_CODEC_ERROR,
971 
972   /*!\brief Memory operation failed */
973   AOM_CODEC_MEM_ERROR,
974 
975   /*!\brief ABI version mismatch */
976   AOM_CODEC_ABI_MISMATCH,
977 
978   /*!\brief Algorithm does not have required capability */
979   AOM_CODEC_INCAPABLE,
980 
981   /*!\brief The given bitstream is not supported.
982    *
983    * The bitstream was unable to be parsed at the highest level. The decoder
984    * is unable to proceed. This error \ref SHOULD be treated as fatal to the
985    * stream. */
986   AOM_CODEC_UNSUP_BITSTREAM,
987 
988   /*!\brief Encoded bitstream uses an unsupported feature
989    *
990    * The decoder does not implement a feature required by the encoder. This
991    * return code should only be used for features that prevent future
992    * pictures from being properly decoded. This error \ref MAY be treated as
993    * fatal to the stream or \ref MAY be treated as fatal to the current GOP.
994    */
995   AOM_CODEC_UNSUP_FEATURE,
996 
997   /*!\brief The coded data for this stream is corrupt or incomplete
998    *
999    * There was a problem decoding the current frame.  This return code
1000    * should only be used for failures that prevent future pictures from
1001    * being properly decoded. This error \ref MAY be treated as fatal to the
1002    * stream or \ref MAY be treated as fatal to the current GOP. If decoding
1003    * is continued for the current GOP, artifacts may be present.
1004    */
1005   AOM_CODEC_CORRUPT_FRAME,
1006 
1007   /*!\brief An application-supplied parameter is not valid.
1008    *
1009    */
1010   AOM_CODEC_INVALID_PARAM,
1011 
1012   /*!\brief An iterator reached the end of list.
1013    *
1014    */
1015   AOM_CODEC_LIST_END
1016 
1017 } aom_codec_err_t;
1018 
1019 typedef struct cfg_options {
1020   /*!\brief Reflects if ext_partition should be enabled
1021    *
1022    * If this value is non-zero it enabled the feature
1023    */
1024   unsigned int ext_partition;
1025 } cfg_options_t;
1026 
1027 /*
1028 from:
1029 aom/av1/common/obu_util.h
1030 */
1031 typedef struct {
1032   size_t size;  // Size (1 or 2 bytes) of the OBU header (including the
1033                 // optional OBU extension header) in the bitstream.
1034   OBU_TYPE type;
1035   int has_size_field;
1036   int has_extension;
1037   // The following fields come from the OBU extension header and therefore are
1038   // only used if has_extension is true.
1039   int temporal_layer_id;
1040   int spatial_layer_id;
1041 } ObuHeader;
1042 
1043 
1044 /*
1045 from:
1046 aom/internal/aom_codec_internal.h
1047 */
1048 
1049 struct aom_internal_error_info {
1050   aom_codec_err_t error_code;
1051   int has_detail;
1052   char detail[80];
1053   int setjmp;  // Boolean: whether 'jmp' is valid.
1054 #ifdef ORI_CODE
1055   jmp_buf jmp;
1056 #endif
1057 };
1058 
1059 /*
1060 from:
1061 aom/aom_frame_buffer.h
1062 */
1063 typedef struct aom_codec_frame_buffer {
1064   uint8_t *data; /**< Pointer to the data buffer */
1065   size_t size;   /**< Size of data in bytes */
1066   void *priv;    /**< Frame's private data */
1067 } aom_codec_frame_buffer_t;
1068 
1069 /*
1070 from:
1071 aom/aom_image.h
1072 */
1073 #define AOM_IMAGE_ABI_VERSION (5) /**<\hideinitializer*/
1074 
1075 #define AOM_IMG_FMT_PLANAR 0x100  /**< Image is a planar format. */
1076 #define AOM_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
1077 /** 0x400 used to signal alpha channel, skipping for backwards compatibility. */
1078 #define AOM_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
1079 
1080 /*!\brief List of supported image formats */
1081 typedef enum aom_img_fmt {
1082   AOM_IMG_FMT_NONE,
1083   AOM_IMG_FMT_YV12 =
1084       AOM_IMG_FMT_PLANAR | AOM_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
1085   AOM_IMG_FMT_I420 = AOM_IMG_FMT_PLANAR | 2,
1086   AOM_IMG_FMT_AOMYV12 = AOM_IMG_FMT_PLANAR | AOM_IMG_FMT_UV_FLIP |
1087                         3, /** < planar 4:2:0 format with aom color space */
1088   AOM_IMG_FMT_AOMI420 = AOM_IMG_FMT_PLANAR | 4,
1089   AOM_IMG_FMT_I422 = AOM_IMG_FMT_PLANAR | 5,
1090   AOM_IMG_FMT_I444 = AOM_IMG_FMT_PLANAR | 6,
1091   AOM_IMG_FMT_I42016 = AOM_IMG_FMT_I420 | AOM_IMG_FMT_HIGHBITDEPTH,
1092   AOM_IMG_FMT_YV1216 = AOM_IMG_FMT_YV12 | AOM_IMG_FMT_HIGHBITDEPTH,
1093   AOM_IMG_FMT_I42216 = AOM_IMG_FMT_I422 | AOM_IMG_FMT_HIGHBITDEPTH,
1094   AOM_IMG_FMT_I44416 = AOM_IMG_FMT_I444 | AOM_IMG_FMT_HIGHBITDEPTH,
1095 } aom_img_fmt_t; /**< alias for enum aom_img_fmt */
1096 
1097 /*!\brief List of supported color primaries */
1098 typedef enum aom_color_primaries {
1099   AOM_CICP_CP_RESERVED_0 = 0,  /**< For future use */
1100   AOM_CICP_CP_BT_709 = 1,      /**< BT.709 */
1101   AOM_CICP_CP_UNSPECIFIED = 2, /**< Unspecified */
1102   AOM_CICP_CP_RESERVED_3 = 3,  /**< For future use */
1103   AOM_CICP_CP_BT_470_M = 4,    /**< BT.470 System M (historical) */
1104   AOM_CICP_CP_BT_470_B_G = 5,  /**< BT.470 System B, G (historical) */
1105   AOM_CICP_CP_BT_601 = 6,      /**< BT.601 */
1106   AOM_CICP_CP_SMPTE_240 = 7,   /**< SMPTE 240 */
1107   AOM_CICP_CP_GENERIC_FILM =
1108       8, /**< Generic film (color filters using illuminant C) */
1109   AOM_CICP_CP_BT_2020 = 9,      /**< BT.2020, BT.2100 */
1110   AOM_CICP_CP_XYZ = 10,         /**< SMPTE 428 (CIE 1921 XYZ) */
1111   AOM_CICP_CP_SMPTE_431 = 11,   /**< SMPTE RP 431-2 */
1112   AOM_CICP_CP_SMPTE_432 = 12,   /**< SMPTE EG 432-1  */
1113   AOM_CICP_CP_RESERVED_13 = 13, /**< For future use (values 13 - 21)  */
1114   AOM_CICP_CP_EBU_3213 = 22,    /**< EBU Tech. 3213-E  */
1115   AOM_CICP_CP_RESERVED_23 = 23  /**< For future use (values 23 - 255)  */
1116 } aom_color_primaries_t;        /**< alias for enum aom_color_primaries */
1117 
1118 /*!\brief List of supported transfer functions */
1119 typedef enum aom_transfer_characteristics {
1120   AOM_CICP_TC_RESERVED_0 = 0,  /**< For future use */
1121   AOM_CICP_TC_BT_709 = 1,      /**< BT.709 */
1122   AOM_CICP_TC_UNSPECIFIED = 2, /**< Unspecified */
1123   AOM_CICP_TC_RESERVED_3 = 3,  /**< For future use */
1124   AOM_CICP_TC_BT_470_M = 4,    /**< BT.470 System M (historical)  */
1125   AOM_CICP_TC_BT_470_B_G = 5,  /**< BT.470 System B, G (historical) */
1126   AOM_CICP_TC_BT_601 = 6,      /**< BT.601 */
1127   AOM_CICP_TC_SMPTE_240 = 7,   /**< SMPTE 240 M */
1128   AOM_CICP_TC_LINEAR = 8,      /**< Linear */
1129   AOM_CICP_TC_LOG_100 = 9,     /**< Logarithmic (100 : 1 range) */
1130   AOM_CICP_TC_LOG_100_SQRT10 =
1131       10,                     /**< Logarithmic (100 * Sqrt(10) : 1 range) */
1132   AOM_CICP_TC_IEC_61966 = 11, /**< IEC 61966-2-4 */
1133   AOM_CICP_TC_BT_1361 = 12,   /**< BT.1361 */
1134   AOM_CICP_TC_SRGB = 13,      /**< sRGB or sYCC*/
1135   AOM_CICP_TC_BT_2020_10_BIT = 14, /**< BT.2020 10-bit systems */
1136   AOM_CICP_TC_BT_2020_12_BIT = 15, /**< BT.2020 12-bit systems */
1137   AOM_CICP_TC_SMPTE_2084 = 16,     /**< SMPTE ST 2084, ITU BT.2100 PQ */
1138   AOM_CICP_TC_SMPTE_428 = 17,      /**< SMPTE ST 428 */
1139   AOM_CICP_TC_HLG = 18,            /**< BT.2100 HLG, ARIB STD-B67 */
1140   AOM_CICP_TC_RESERVED_19 = 19     /**< For future use (values 19-255) */
1141 } aom_transfer_characteristics_t;  /**< alias for enum aom_transfer_function */
1142 
1143 /*!\brief List of supported matrix coefficients */
1144 typedef enum aom_matrix_coefficients {
1145   AOM_CICP_MC_IDENTITY = 0,    /**< Identity matrix */
1146   AOM_CICP_MC_BT_709 = 1,      /**< BT.709 */
1147   AOM_CICP_MC_UNSPECIFIED = 2, /**< Unspecified */
1148   AOM_CICP_MC_RESERVED_3 = 3,  /**< For future use */
1149   AOM_CICP_MC_FCC = 4,         /**< US FCC 73.628 */
1150   AOM_CICP_MC_BT_470_B_G = 5,  /**< BT.470 System B, G (historical) */
1151   AOM_CICP_MC_BT_601 = 6,      /**< BT.601 */
1152   AOM_CICP_MC_SMPTE_240 = 7,   /**< SMPTE 240 M */
1153   AOM_CICP_MC_SMPTE_YCGCO = 8, /**< YCgCo */
1154   AOM_CICP_MC_BT_2020_NCL =
1155       9, /**< BT.2020 non-constant luminance, BT.2100 YCbCr  */
1156   AOM_CICP_MC_BT_2020_CL = 10, /**< BT.2020 constant luminance */
1157   AOM_CICP_MC_SMPTE_2085 = 11, /**< SMPTE ST 2085 YDzDx */
1158   AOM_CICP_MC_CHROMAT_NCL =
1159       12, /**< Chromaticity-derived non-constant luminance */
1160   AOM_CICP_MC_CHROMAT_CL = 13, /**< Chromaticity-derived constant luminance */
1161   AOM_CICP_MC_ICTCP = 14,      /**< BT.2100 ICtCp */
1162   AOM_CICP_MC_RESERVED_15 = 15 /**< For future use (values 15-255)  */
1163 } aom_matrix_coefficients_t;
1164 
1165 /*!\brief List of supported color range */
1166 typedef enum aom_color_range {
1167   AOM_CR_STUDIO_RANGE = 0, /**< Y [16..235], UV [16..240] */
1168   AOM_CR_FULL_RANGE = 1    /**< YUV/RGB [0..255] */
1169 } aom_color_range_t;       /**< alias for enum aom_color_range */
1170 
1171 /*!\brief List of chroma sample positions */
1172 typedef enum aom_chroma_sample_position {
1173   AOM_CSP_UNKNOWN = 0,          /**< Unknown */
1174   AOM_CSP_VERTICAL = 1,         /**< Horizontally co-located with luma(0, 0)*/
1175                                 /**< sample, between two vertical samples */
1176   AOM_CSP_COLOCATED = 2,        /**< Co-located with luma(0, 0) sample */
1177   AOM_CSP_RESERVED = 3          /**< Reserved value */
1178 } aom_chroma_sample_position_t; /**< alias for enum aom_transfer_function */
1179 
1180 /*
1181 from:
1182 aom/aom_scale/yv12config.h
1183 */
1184 typedef struct PIC_BUFFER_CONFIG_s {
1185   union {
1186     struct {
1187       int y_width;
1188       int uv_width;
1189     };
1190     int widths[2];
1191   };
1192   union {
1193     struct {
1194       int y_height;
1195       int uv_height;
1196     };
1197     int heights[2];
1198   };
1199   union {
1200     struct {
1201       int y_crop_width;
1202       int uv_crop_width;
1203     };
1204     int crop_widths[2];
1205   };
1206   union {
1207     struct {
1208       int y_crop_height;
1209       int uv_crop_height;
1210     };
1211     int crop_heights[2];
1212   };
1213   union {
1214     struct {
1215       int y_stride;
1216       int uv_stride;
1217     };
1218     int strides[2];
1219   };
1220   union {
1221     struct {
1222       uint8_t *y_buffer;
1223       uint8_t *u_buffer;
1224       uint8_t *v_buffer;
1225     };
1226     uint8_t *buffers[3];
1227   };
1228 
1229   // Indicate whether y_buffer, u_buffer, and v_buffer points to the internally
1230   // allocated memory or external buffers.
1231   int use_external_reference_buffers;
1232   // This is needed to store y_buffer, u_buffer, and v_buffer when set reference
1233   // uses an external refernece, and restore those buffer pointers after the
1234   // external reference frame is no longer used.
1235   uint8_t *store_buf_adr[3];
1236 
1237   // If the frame is stored in a 16-bit buffer, this stores an 8-bit version
1238   // for use in global motion detection. It is allocated on-demand.
1239   uint8_t *y_buffer_8bit;
1240   int buf_8bit_valid;
1241 
1242   uint8_t *buffer_alloc;
1243   size_t buffer_alloc_sz;
1244   int border;
1245   size_t frame_size;
1246   int subsampling_x;
1247   int subsampling_y;
1248   unsigned int bit_depth;
1249   aom_color_primaries_t color_primaries;
1250   aom_transfer_characteristics_t transfer_characteristics;
1251   aom_matrix_coefficients_t matrix_coefficients;
1252   uint8_t monochrome;
1253   aom_chroma_sample_position_t chroma_sample_position;
1254   aom_color_range_t color_range;
1255   int render_width;
1256   int render_height;
1257 
1258   int corrupted;
1259   int flags;
1260 
1261 #ifdef AML
1262     int32_t index;
1263     int32_t decode_idx;
1264     int32_t slice_type;
1265     int32_t RefNum_L0;
1266     int32_t RefNum_L1;
1267     int32_t num_reorder_pic;
1268         int32_t stream_offset;
1269     uint8_t referenced;
1270     uint8_t output_mark;
1271     uint8_t recon_mark;
1272     uint8_t output_ready;
1273     uint8_t error_mark;
1274     /**/
1275     int32_t slice_idx;
1276     /*buffer*/
1277     uint32_t fgs_table_adr;
1278 #ifdef AOM_AV1_MMU
1279     uint32_t header_adr;
1280 #endif
1281 #ifdef AOM_AV1_MMU_DW
1282     uint32_t header_dw_adr;
1283 #endif
1284     uint32_t mpred_mv_wr_start_addr;
1285     uint32_t mc_y_adr;
1286     uint32_t mc_u_v_adr;
1287     int32_t mc_canvas_y;
1288     int32_t mc_canvas_u_v;
1289 
1290     int32_t lcu_total;
1291     /**/
1292     unsigned int order_hint;
1293 #endif
1294 #ifdef AML_DEVICE
1295      int mv_buf_index;
1296       unsigned long cma_alloc_addr;
1297       int BUF_index;
1298       int buf_size;
1299       int comp_body_size;
1300       unsigned int dw_y_adr;
1301       unsigned int dw_u_v_adr;
1302       int double_write_mode;
1303       int y_canvas_index;
1304       int uv_canvas_index;
1305       int vf_ref;
1306   struct canvas_config_s canvas_config[2];
1307     char *aux_data_buf;
1308     int aux_data_size;
1309     u32 pts;
1310   u64 pts64;
1311   /* picture qos infomation*/
1312   int max_qp;
1313   int avg_qp;
1314   int min_qp;
1315   int max_skip;
1316   int avg_skip;
1317   int min_skip;
1318   int max_mv;
1319   int min_mv;
1320   int avg_mv;
1321 #endif
1322 } PIC_BUFFER_CONFIG;
1323 
1324 /*
1325 from:
1326 common/blockd.h
1327 */
1328 TYPEDEF enum {
1329   KEY_FRAME = 0,
1330   INTER_FRAME = 1,
1331   INTRA_ONLY_FRAME = 2,  // replaces intra-only
1332   S_FRAME = 3,
1333   FRAME_TYPES,
1334 } UENUM1BYTE(FRAME_TYPE);
1335 
1336 /*from:
1337 mv.h
1338 */
1339 #ifdef ORI_CODE
1340 typedef struct mv32 {
1341   int32_t row;
1342   int32_t col;
1343 } MV32;
1344 #endif
1345 /*from:
1346  aom_filter.h
1347 */
1348 #define SUBPEL_BITS 4
1349 #define SUBPEL_MASK ((1 << SUBPEL_BITS) - 1)
1350 #define SUBPEL_SHIFTS (1 << SUBPEL_BITS)
1351 #define SUBPEL_TAPS 8
1352 
1353 #define SCALE_SUBPEL_BITS 10
1354 #define SCALE_SUBPEL_SHIFTS (1 << SCALE_SUBPEL_BITS)
1355 #define SCALE_SUBPEL_MASK (SCALE_SUBPEL_SHIFTS - 1)
1356 #define SCALE_EXTRA_BITS (SCALE_SUBPEL_BITS - SUBPEL_BITS)
1357 #define SCALE_EXTRA_OFF ((1 << SCALE_EXTRA_BITS) / 2)
1358 
1359 #define RS_SUBPEL_BITS 6
1360 #define RS_SUBPEL_MASK ((1 << RS_SUBPEL_BITS) - 1)
1361 #define RS_SCALE_SUBPEL_BITS 14
1362 #define RS_SCALE_SUBPEL_MASK ((1 << RS_SCALE_SUBPEL_BITS) - 1)
1363 #define RS_SCALE_EXTRA_BITS (RS_SCALE_SUBPEL_BITS - RS_SUBPEL_BITS)
1364 #define RS_SCALE_EXTRA_OFF (1 << (RS_SCALE_EXTRA_BITS - 1))
1365 
1366 /*from:
1367 scale.h
1368 */
1369 #define SCALE_NUMERATOR 8
1370 
1371 #define REF_SCALE_SHIFT 14
1372 #define REF_NO_SCALE (1 << REF_SCALE_SHIFT)
1373 #define REF_INVALID_SCALE -1
1374 
1375 struct scale_factors {
1376   int x_scale_fp;  // horizontal fixed point scale factor
1377   int y_scale_fp;  // vertical fixed point scale factor
1378   int x_step_q4;
1379   int y_step_q4;
1380 
1381   int (*scale_value_x)(int val, const struct scale_factors *sf);
1382   int (*scale_value_y)(int val, const struct scale_factors *sf);
1383 #ifdef ORI_CODE
1384   // convolve_fn_ptr[subpel_x != 0][subpel_y != 0][is_compound]
1385   aom_convolve_fn_t convolve[2][2][2];
1386   aom_highbd_convolve_fn_t highbd_convolve[2][2][2];
1387 #endif
1388 };
1389 
1390 #ifdef ORI_CODE
1391 MV32 av1_scale_mv(const MV *mv, int x, int y, const struct scale_factors *sf);
1392 #endif
1393 void av1_setup_scale_factors_for_frame(struct scale_factors *sf, int other_w,
1394                                        int other_h, int this_w, int this_h);
1395 
av1_is_valid_scale(const struct scale_factors * sf)1396 static inline int av1_is_valid_scale(const struct scale_factors *sf) {
1397 #ifdef ORI_CODE
1398   assert(sf != NULL);
1399 #endif
1400   return sf->x_scale_fp != REF_INVALID_SCALE &&
1401          sf->y_scale_fp != REF_INVALID_SCALE;
1402 }
1403 
av1_is_scaled(const struct scale_factors * sf)1404 static inline int av1_is_scaled(const struct scale_factors *sf) {
1405 #ifdef ORI_CODE
1406   assert(sf != NULL);
1407 #endif
1408   return av1_is_valid_scale(sf) &&
1409          (sf->x_scale_fp != REF_NO_SCALE || sf->y_scale_fp != REF_NO_SCALE);
1410 }
1411 
1412 
1413 /*
1414 from:
1415 common/onyxc_int.h
1416 */
1417 
1418 #define CDEF_MAX_STRENGTHS 16
1419 
1420 /* Constant values while waiting for the sequence header */
1421 #define FRAME_ID_LENGTH 15
1422 #define DELTA_FRAME_ID_LENGTH 14
1423 
1424 #define FRAME_CONTEXTS (FRAME_BUFFERS + 1)
1425 // Extra frame context which is always kept at default values
1426 #define FRAME_CONTEXT_DEFAULTS (FRAME_CONTEXTS - 1)
1427 #define PRIMARY_REF_BITS 3
1428 #define PRIMARY_REF_NONE 7
1429 
1430 #define NUM_PING_PONG_BUFFERS 2
1431 
1432 #define MAX_NUM_TEMPORAL_LAYERS 8
1433 #define MAX_NUM_SPATIAL_LAYERS 4
1434 /* clang-format off */
1435 // clang-format seems to think this is a pointer dereference and not a
1436 // multiplication.
1437 #define MAX_NUM_OPERATING_POINTS \
1438   MAX_NUM_TEMPORAL_LAYERS * MAX_NUM_SPATIAL_LAYERS
1439 /* clang-format on*/
1440 
1441 // TODO(jingning): Turning this on to set up transform coefficient
1442 // processing timer.
1443 #define TXCOEFF_TIMER 0
1444 #define TXCOEFF_COST_TIMER 0
1445 
1446 TYPEDEF enum {
1447   SINGLE_REFERENCE = 0,
1448   COMPOUND_REFERENCE = 1,
1449   REFERENCE_MODE_SELECT = 2,
1450   REFERENCE_MODES = 3,
1451 } UENUM1BYTE(REFERENCE_MODE);
1452 
1453 TYPEDEF enum {
1454   /**
1455    * Frame context updates are disabled
1456    */
1457   REFRESH_FRAME_CONTEXT_DISABLED,
1458   /**
1459    * Update frame context to values resulting from backward probability
1460    * updates based on entropy/counts in the decoded frame
1461    */
1462   REFRESH_FRAME_CONTEXT_BACKWARD,
1463 } UENUM1BYTE(REFRESH_FRAME_CONTEXT_MODE);
1464 
1465 #define MFMV_STACK_SIZE 3
1466 
1467 #ifdef AML
1468 #define MV_REF_SIZE 8
1469 #endif
1470 
1471 #ifdef ORI_CODE
1472 typedef struct {
1473   int_mv mfmv0;
1474   uint8_t ref_frame_offset;
1475 } TPL_MV_REF;
1476 typedef struct {
1477   int_mv mv;
1478   MV_REFERENCE_FRAME ref_frame;
1479 } MV_REF;
1480 #endif
1481 
1482 typedef struct RefCntBuffer_s {
1483   // For a RefCntBuffer, the following are reference-holding variables:
1484   // - cm->ref_frame_map[]
1485   // - cm->cur_frame
1486   // - cm->scaled_ref_buf[] (encoder only)
1487   // - cm->next_ref_frame_map[] (decoder only)
1488   // - pbi->output_frame_index[] (decoder only)
1489   // With that definition, 'ref_count' is the number of reference-holding
1490   // variables that are currently referencing this buffer.
1491   // For example:
1492   // - suppose this buffer is at index 'k' in the buffer pool, and
1493   // - Total 'n' of the variables / array elements above have value 'k' (that
1494   // is, they are pointing to buffer at index 'k').
1495   // Then, pool->frame_bufs[k].ref_count = n.
1496   int ref_count;
1497 
1498   unsigned int order_hint;
1499   unsigned int ref_order_hints[INTER_REFS_PER_FRAME];
1500 
1501   int intra_only;
1502   int segmentation_enabled;
1503   unsigned int segment_feature[8];
1504 #ifdef AML
1505   int segmentation_update_map;
1506   int prev_segmentation_enabled;
1507   int seg_mi_rows;
1508   int seg_mi_cols;
1509 
1510   unsigned int seg_lf_info_y[8];
1511   unsigned int seg_lf_info_c[8];
1512   int8_t ref_deltas[REF_FRAMES];
1513   int8_t mode_deltas[MAX_MODE_LF_DELTAS];
1514 #endif
1515   //MV_REF *mvs;
1516   uint8_t *seg_map;
1517 #ifdef ORI_CODE
1518   struct segmentation seg;
1519 #endif
1520 
1521   int mi_rows;
1522   int mi_cols;
1523   // Width and height give the size of the buffer (before any upscaling, unlike
1524   // the sizes that can be derived from the buf structure)
1525   int width;
1526   int height;
1527 #ifdef ORI_CODE
1528   WarpedMotionParams global_motion[REF_FRAMES];
1529 #endif
1530   int showable_frame;  // frame can be used as show existing frame in future
1531   uint8_t film_grain_params_present;
1532 #ifdef ORI_CODE
1533   aom_film_grain_t film_grain_params;
1534 #endif
1535 #ifdef AML
1536   int dec_width;
1537   uint8_t film_grain_reg_valid;
1538   uint32_t film_grain_reg[FILM_GRAIN_REG_SIZE];
1539 #endif
1540   aom_codec_frame_buffer_t raw_frame_buffer;
1541   PIC_BUFFER_CONFIG buf;
1542 #ifdef ORI_CODE
1543   hash_table hash_table;
1544 #endif
1545   FRAME_TYPE frame_type;
1546 
1547   // This is only used in the encoder but needs to be indexed per ref frame
1548   // so it's extremely convenient to keep it here.
1549 #ifdef ORI_CODE
1550   int interp_filter_selected[SWITCHABLE];
1551 #endif
1552   // Inter frame reference frame delta for loop filter
1553 #ifndef AML
1554   int8_t ref_deltas[REF_FRAMES];
1555 #endif
1556 #ifdef ORI_CODE
1557   // 0 = ZERO_MV, MV
1558   int8_t mode_deltas[MAX_MODE_LF_DELTAS];
1559 
1560   FRAME_CONTEXT frame_context;
1561 #endif
1562 } RefCntBuffer;
1563 
1564 typedef struct BufferPool_s {
1565 // Protect BufferPool from being accessed by several FrameWorkers at
1566 // the same time during frame parallel decode.
1567 // TODO(hkuang): Try to use atomic variable instead of locking the whole pool.
1568 // TODO(wtc): Remove this. See
1569 // https://chromium-review.googlesource.com/c/webm/libvpx/+/560630.
1570 #if CONFIG_MULTITHREAD
1571   pthread_mutex_t pool_mutex;
1572 #endif
1573 
1574   // Private data associated with the frame buffer callbacks.
1575   void *cb_priv;
1576 #ifdef ORI_CODE
1577   aom_get_frame_buffer_cb_fn_t get_fb_cb;
1578   aom_release_frame_buffer_cb_fn_t release_fb_cb;
1579 #endif
1580   RefCntBuffer frame_bufs[FRAME_BUFFERS];
1581 
1582 #ifdef ORI_CODE
1583   // Frame buffers allocated internally by the codec.
1584   InternalFrameBufferList int_frame_buffers;
1585 #endif
1586 #ifdef AML_DEVICE
1587     spinlock_t lock;
1588 #endif
1589 } BufferPool;
1590 
1591 typedef struct {
1592   int cdef_pri_damping;
1593   int cdef_sec_damping;
1594   int nb_cdef_strengths;
1595   int cdef_strengths[CDEF_MAX_STRENGTHS];
1596   int cdef_uv_strengths[CDEF_MAX_STRENGTHS];
1597   int cdef_bits;
1598 } CdefInfo;
1599 
1600 typedef struct {
1601   int delta_q_present_flag;
1602   // Resolution of delta quant
1603   int delta_q_res;
1604   int delta_lf_present_flag;
1605   // Resolution of delta lf level
1606   int delta_lf_res;
1607   // This is a flag for number of deltas of loop filter level
1608   // 0: use 1 delta, for y_vertical, y_horizontal, u, and v
1609   // 1: use separate deltas for each filter level
1610   int delta_lf_multi;
1611 } DeltaQInfo;
1612 
1613 typedef struct {
1614   int enable_order_hint;           // 0 - disable order hint, and related tools
1615   int order_hint_bits_minus_1;     // dist_wtd_comp, ref_frame_mvs,
1616                                    // frame_sign_bias
1617                                    // if 0, enable_dist_wtd_comp and
1618                                    // enable_ref_frame_mvs must be set as 0.
1619   int enable_dist_wtd_comp;        // 0 - disable dist-wtd compound modes
1620                                    // 1 - enable it
1621   int enable_ref_frame_mvs;        // 0 - disable ref frame mvs
1622                                    // 1 - enable it
1623 } OrderHintInfo;
1624 
1625 // Sequence header structure.
1626 // Note: All syntax elements of sequence_header_obu that need to be
1627 // bit-identical across multiple sequence headers must be part of this struct,
1628 // so that consistency is checked by are_seq_headers_consistent() function.
1629 typedef struct SequenceHeader {
1630   int num_bits_width;
1631   int num_bits_height;
1632   int max_frame_width;
1633   int max_frame_height;
1634   uint8_t frame_id_numbers_present_flag;
1635   int frame_id_length;
1636   int delta_frame_id_length;
1637   BLOCK_SIZE2 sb_size;  // Size of the superblock used for this frame
1638   int mib_size;        // Size of the superblock in units of MI blocks
1639   int mib_size_log2;   // Log 2 of above.
1640 
1641   OrderHintInfo order_hint_info;
1642 
1643   uint8_t force_screen_content_tools;  // 0 - force off
1644                                        // 1 - force on
1645                                        // 2 - adaptive
1646   uint8_t still_picture;               // Video is a single frame still picture
1647   uint8_t reduced_still_picture_hdr;   // Use reduced header for still picture
1648   uint8_t force_integer_mv;            // 0 - Don't force. MV can use subpel
1649                                        // 1 - force to integer
1650                                        // 2 - adaptive
1651   uint8_t enable_filter_intra;         // enables/disables filterintra
1652   uint8_t enable_intra_edge_filter;    // enables/disables edge upsampling
1653   uint8_t enable_interintra_compound;  // enables/disables interintra_compound
1654   uint8_t enable_masked_compound;      // enables/disables masked compound
1655   uint8_t enable_dual_filter;          // 0 - disable dual interpolation filter
1656                                        // 1 - enable vert/horz filter selection
1657   uint8_t enable_warped_motion;        // 0 - disable warp for the sequence
1658                                        // 1 - enable warp for the sequence
1659   uint8_t enable_superres;             // 0 - Disable superres for the sequence
1660                                        //     and no frame level superres flag
1661                                        // 1 - Enable superres for the sequence
1662                                        //     enable per-frame superres flag
1663   uint8_t enable_cdef;                 // To turn on/off CDEF
1664   uint8_t enable_restoration;          // To turn on/off loop restoration
1665   BITSTREAM_PROFILE profile;
1666 
1667   // Operating point info.
1668   int operating_points_cnt_minus_1;
1669   int operating_point_idc[MAX_NUM_OPERATING_POINTS];
1670   uint8_t display_model_info_present_flag;
1671   uint8_t decoder_model_info_present_flag;
1672   AV1_LEVEL seq_level_idx[MAX_NUM_OPERATING_POINTS];
1673   uint8_t tier[MAX_NUM_OPERATING_POINTS];  // seq_tier in the spec. One bit: 0
1674                                            // or 1.
1675 
1676   // Color config.
1677   aom_bit_depth_t bit_depth;  // AOM_BITS_8 in profile 0 or 1,
1678                               // AOM_BITS_10 or AOM_BITS_12 in profile 2 or 3.
1679   uint8_t use_highbitdepth;   // If true, we need to use 16bit frame buffers.
1680   uint8_t monochrome;         // Monochorme video
1681   aom_color_primaries_t color_primaries;
1682   aom_transfer_characteristics_t transfer_characteristics;
1683   aom_matrix_coefficients_t matrix_coefficients;
1684   int color_range;
1685   int subsampling_x;          // Chroma subsampling for x
1686   int subsampling_y;          // Chroma subsampling for y
1687   aom_chroma_sample_position_t chroma_sample_position;
1688   uint8_t separate_uv_delta_q;
1689   uint8_t film_gry_dequant_QTXain_params_present;
1690 } SequenceHeader;
1691 
1692 typedef struct {
1693     int skip_mode_allowed;
1694     int skip_mode_flag;
1695     int ref_frame_idx_0;
1696     int ref_frame_idx_1;
1697 } SkipModeInfo;
1698 
1699 typedef struct {
1700   FRAME_TYPE frame_type;
1701   REFERENCE_MODE reference_mode;
1702 
1703   unsigned int order_hint;
1704   unsigned int frame_number;
1705   SkipModeInfo skip_mode_info;
1706   int refresh_frame_flags;  // Which ref frames are overwritten by this frame
1707   int frame_refs_short_signaling;
1708 } CurrentFrame;
1709 
1710 typedef struct AV1_Common_s {
1711   CurrentFrame current_frame;
1712   struct aom_internal_error_info error;
1713   int width;
1714   int height;
1715   int render_width;
1716   int render_height;
1717   int timing_info_present;
1718   aom_timing_info_t timing_info;
1719   int buffer_removal_time_present;
1720   aom_dec_model_info_t buffer_model;
1721   aom_dec_model_op_parameters_t op_params[MAX_NUM_OPERATING_POINTS + 1];
1722   aom_op_timing_info_t op_frame_timing[MAX_NUM_OPERATING_POINTS + 1];
1723   uint32_t frame_presentation_time;
1724 
1725   int context_update_tile_id;
1726 #ifdef SUPPORT_SCALE_FACTOR
1727   // Scale of the current frame with respect to itself.
1728   struct scale_factors sf_identity;
1729 #endif
1730   RefCntBuffer *prev_frame;
1731 
1732   // TODO(hkuang): Combine this with cur_buf in macroblockd.
1733   RefCntBuffer *cur_frame;
1734 
1735   // For encoder, we have a two-level mapping from reference frame type to the
1736   // corresponding buffer in the buffer pool:
1737   // * 'remapped_ref_idx[i - 1]' maps reference type 'i' (range: LAST_FRAME ...
1738   // EXTREF_FRAME) to a remapped index 'j' (in range: 0 ... REF_FRAMES - 1)
1739   // * Later, 'cm->ref_frame_map[j]' maps the remapped index 'j' to a pointer to
1740   // the reference counted buffer structure RefCntBuffer, taken from the buffer
1741   // pool cm->buffer_pool->frame_bufs.
1742   //
1743   // LAST_FRAME,                        ...,      EXTREF_FRAME
1744   //      |                                           |
1745   //      v                                           v
1746   // remapped_ref_idx[LAST_FRAME - 1],  ...,  remapped_ref_idx[EXTREF_FRAME - 1]
1747   //      |                                           |
1748   //      v                                           v
1749   // ref_frame_map[],                   ...,     ref_frame_map[]
1750   //
1751   // Note: INTRA_FRAME always refers to the current frame, so there's no need to
1752   // have a remapped index for the same.
1753   int remapped_ref_idx[REF_FRAMES];
1754 
1755 #ifdef SUPPORT_SCALE_FACTOR
1756   struct scale_factors ref_scale_factors[REF_FRAMES];
1757 #endif
1758   // For decoder, ref_frame_map[i] maps reference type 'i' to a pointer to
1759   // the buffer in the buffer pool 'cm->buffer_pool.frame_bufs'.
1760   // For encoder, ref_frame_map[j] (where j = remapped_ref_idx[i]) maps
1761   // remapped reference index 'j' (that is, original reference type 'i') to
1762   // a pointer to the buffer in the buffer pool 'cm->buffer_pool.frame_bufs'.
1763   RefCntBuffer *ref_frame_map[REF_FRAMES];
1764 
1765   // Prepare ref_frame_map for the next frame.
1766   // Only used in frame parallel decode.
1767   RefCntBuffer *next_ref_frame_map[REF_FRAMES];
1768 #ifdef AML
1769   RefCntBuffer *next_used_ref_frame_map[REF_FRAMES];
1770 #endif
1771   FRAME_TYPE last_frame_type; /* last frame's frame type for motion search.*/
1772 
1773   int show_frame;
1774   int showable_frame;  // frame can be used as show existing frame in future
1775   int show_existing_frame;
1776 
1777   uint8_t disable_cdf_update;
1778   int allow_high_precision_mv;
1779   uint8_t cur_frame_force_integer_mv;  // 0 the default in AOM, 1 only integer
1780 
1781   uint8_t allow_screen_content_tools;
1782   int allow_intrabc;
1783   int allow_warped_motion;
1784 
1785   // MBs, mb_rows/cols is in 16-pixel units; mi_rows/cols is in
1786   // MB_MODE_INFO (8-pixel) units.
1787   int MBs;
1788   int mb_rows, mi_rows;
1789   int mb_cols, mi_cols;
1790   int mi_stride;
1791 
1792   /* profile settings */
1793   TX_MODE tx_mode;
1794 
1795 #if CONFIG_ENTROPY_STATS
1796   int coef_cdf_category;
1797 #endif
1798 
1799   int base_qindex;
1800   int y_dc_delta_q;
1801   int u_dc_delta_q;
1802   int v_dc_delta_q;
1803   int u_ac_delta_q;
1804   int v_ac_delta_q;
1805 
1806 #ifdef ORI_CODE
1807   // The dequantizers below are true dequantizers used only in the
1808   // dequantization process.  They have the same coefficient
1809   // shift/scale as TX.
1810   int16_t y_dequant_QTX[MAX_SEGMENTS][2];
1811   int16_t u_dequant_QTX[MAX_SEGMENTS][2];
1812   int16_t v_dequant_QTX[MAX_SEGMENTS][2];
1813 
1814   // Global quant matrix tables
1815   const qm_val_t *giqmatrix[NUM_QM_LEVELS][3][TX_SIZES_ALL];
1816   const qm_val_t *gqmatrix[NUM_QM_LEVELS][3][TX_SIZES_ALL];
1817 
1818   // Local quant matrix tables for each frame
1819   const qm_val_t *y_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
1820   const qm_val_t *u_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
1821   const qm_val_t *v_iqmatrix[MAX_SEGMENTS][TX_SIZES_ALL];
1822 #endif
1823   // Encoder
1824   int using_qmatrix;
1825   int qm_y;
1826   int qm_u;
1827   int qm_v;
1828   int min_qmlevel;
1829   int max_qmlevel;
1830   int use_quant_b_adapt;
1831 
1832   /* We allocate a MB_MODE_INFO struct for each macroblock, together with
1833      an extra row on top and column on the left to simplify prediction. */
1834   int mi_alloc_size;
1835 
1836 #ifdef ORI_CODE
1837   MB_MODE_INFO *mip; /* Base of allocated array */
1838   MB_MODE_INFO *mi;  /* Corresponds to upper left visible macroblock */
1839 
1840   // TODO(agrange): Move prev_mi into encoder structure.
1841   // prev_mip and prev_mi will only be allocated in encoder.
1842   MB_MODE_INFO *prev_mip; /* MB_MODE_INFO array 'mip' from last decoded frame */
1843   MB_MODE_INFO *prev_mi;  /* 'mi' from last frame (points into prev_mip) */
1844 
1845   // Separate mi functions between encoder and decoder.
1846   int (*alloc_mi)(struct AV1Common *cm, int mi_size);
1847   void (*free_mi)(struct AV1Common *cm);
1848   void (*setup_mi)(struct AV1Common *cm);
1849 
1850   // Grid of pointers to 8x8 MB_MODE_INFO structs.  Any 8x8 not in the visible
1851   // area will be NULL.
1852   MB_MODE_INFO **mi_grid_base;
1853   MB_MODE_INFO **mi_grid_visible;
1854   MB_MODE_INFO **prev_mi_grid_base;
1855   MB_MODE_INFO **prev_mi_grid_visible;
1856 #endif
1857   // Whether to use previous frames' motion vectors for prediction.
1858   int allow_ref_frame_mvs;
1859 
1860   uint8_t *last_frame_seg_map;
1861 
1862 #ifdef ORI_CODE
1863   InterpFilter interp_filter;
1864 #endif
1865   int switchable_motion_mode;
1866 #ifdef ORI_CODE
1867   loop_filter_info_n lf_info;
1868 #endif
1869   // The denominator of the superres scale; the numerator is fixed.
1870   uint8_t superres_scale_denominator;
1871   int superres_upscaled_width;
1872   int superres_upscaled_height;
1873 
1874 #ifdef ORI_CODE
1875   RestorationInfo rst_info[MAX_MB_PLANE];
1876 #endif
1877   // Pointer to a scratch buffer used by self-guided restoration
1878   int32_t *rst_tmpbuf;
1879 #ifdef ORI_CODE
1880   RestorationLineBuffers *rlbs;
1881 #endif
1882   // Output of loop restoration
1883   PIC_BUFFER_CONFIG rst_frame;
1884 
1885   // Flag signaling how frame contexts should be updated at the end of
1886   // a frame decode
1887   REFRESH_FRAME_CONTEXT_MODE refresh_frame_context;
1888 
1889   int ref_frame_sign_bias[REF_FRAMES]; /* Two state 0, 1 */
1890 
1891 #ifdef ORI_CODE
1892   struct loopfilter lf;
1893   struct segmentation seg;
1894 #endif
1895 
1896   int coded_lossless;  // frame is fully lossless at the coded resolution.
1897   int all_lossless;    // frame is fully lossless at the upscaled resolution.
1898 
1899   int reduced_tx_set_used;
1900 
1901 #ifdef ORI_CODE
1902   // Context probabilities for reference frame prediction
1903   MV_REFERENCE_FRAME comp_fwd_ref[FWD_REFS];
1904   MV_REFERENCE_FRAME comp_bwd_ref[BWD_REFS];
1905 
1906   FRAME_CONTEXT *fc;              /* this frame entropy */
1907   FRAME_CONTEXT *default_frame_context;
1908 #endif
1909   int primary_ref_frame;
1910 
1911   int error_resilient_mode;
1912 
1913   int tile_cols, tile_rows;
1914 
1915   int max_tile_width_sb;
1916   int min_log2_tile_cols;
1917   int max_log2_tile_cols;
1918   int max_log2_tile_rows;
1919   int min_log2_tile_rows;
1920   int min_log2_tiles;
1921   int max_tile_height_sb;
1922   int uniform_tile_spacing_flag;
1923   int log2_tile_cols;                        // only valid for uniform tiles
1924   int log2_tile_rows;                        // only valid for uniform tiles
1925   int tile_col_start_sb[MAX_TILE_COLS + 1];  // valid for 0 <= i <= tile_cols
1926   int tile_row_start_sb[MAX_TILE_ROWS + 1];  // valid for 0 <= i <= tile_rows
1927   int tile_width, tile_height;               // In MI units
1928   int min_inner_tile_width;                  // min width of non-rightmost tile
1929 
1930   unsigned int large_scale_tile;
1931   unsigned int single_tile_decoding;
1932 
1933   int byte_alignment;
1934   int skip_loop_filter;
1935   int skip_film_grain;
1936 
1937   // External BufferPool passed from outside.
1938   BufferPool *buffer_pool;
1939 
1940 #ifdef ORI_CODE
1941   PARTITION_CONTEXT **above_seg_context;
1942   ENTROPY_CONTEXT **above_context[MAX_MB_PLANE];
1943   TXFM_CONTEXT **above_txfm_context;
1944   WarpedMotionParams global_motion[REF_FRAMES];
1945   aom_film_grain_t film_grain_params;
1946 
1947   CdefInfo cdef_info;
1948   DeltaQInfo delta_q_info;  // Delta Q and Delta LF parameters
1949 #endif
1950   int num_tg;
1951   SequenceHeader seq_params;
1952   int current_frame_id;
1953   int ref_frame_id[REF_FRAMES];
1954   int valid_for_referencing[REF_FRAMES];
1955 #ifdef ORI_CODE
1956   TPL_MV_REF *tpl_mvs;
1957 #endif
1958   int tpl_mvs_mem_size;
1959   // TODO(jingning): This can be combined with sign_bias later.
1960   int8_t ref_frame_side[REF_FRAMES];
1961 
1962   int is_annexb;
1963 
1964   int temporal_layer_id;
1965   int spatial_layer_id;
1966   unsigned int number_temporal_layers;
1967   unsigned int number_spatial_layers;
1968   int num_allocated_above_context_mi_col;
1969   int num_allocated_above_contexts;
1970   int num_allocated_above_context_planes;
1971 
1972 #if TXCOEFF_TIMER
1973   int64_t cum_txcoeff_timer;
1974   int64_t txcoeff_timer;
1975   int txb_count;
1976 #endif
1977 
1978 #if TXCOEFF_COST_TIMER
1979   int64_t cum_txcoeff_cost_timer;
1980   int64_t txcoeff_cost_timer;
1981   int64_t txcoeff_cost_count;
1982 #endif
1983   const cfg_options_t *options;
1984   int is_decoding;
1985 #ifdef AML
1986   int mv_ref_offset[MV_REF_SIZE][REF_FRAMES];
1987   int mv_ref_id[MV_REF_SIZE];
1988   unsigned char mv_cal_tpl_mvs[MV_REF_SIZE];
1989   int mv_ref_id_index;
1990       int prev_fb_idx;
1991     int new_fb_idx;
1992     int32_t dec_width;
1993 #endif
1994 #ifdef AML_DEVICE
1995       int cur_fb_idx_mmu;
1996 #ifdef AOM_AV1_MMU_DW
1997       int cur_fb_idx_mmu_dw;
1998 #endif
1999       int current_video_frame;
2000       int use_prev_frame_mvs;
2001       int frame_type;
2002       int intra_only;
2003   struct RefCntBuffer_s frame_refs[INTER_REFS_PER_FRAME];
2004 
2005 #endif
2006 } AV1_COMMON;
2007 
2008 
2009 /*
2010 from:
2011 	decoder/decoder.h
2012 */
2013 
2014 typedef struct EXTERNAL_REFERENCES {
2015   PIC_BUFFER_CONFIG refs[MAX_EXTERNAL_REFERENCES];
2016   int num;
2017 } EXTERNAL_REFERENCES;
2018 
2019 typedef struct AV1Decoder {
2020   //DECLARE_ALIGNED(32, MACROBLOCKD, mb);
2021 
2022   //DECLARE_ALIGNED(32, AV1_COMMON, common);
2023   AV1_COMMON common;
2024 
2025 #ifdef ORI_CODE
2026   AVxWorker lf_worker;
2027   AV1LfSync lf_row_sync;
2028   AV1LrSync lr_row_sync;
2029   AV1LrStruct lr_ctxt;
2030   AVxWorker *tile_workers;
2031   int num_workers;
2032   DecWorkerData *thread_data;
2033   ThreadData td;
2034   TileDataDec *tile_data;
2035   int allocated_tiles;
2036   TileBufferDec tile_buffers[MAX_TILE_ROWS][MAX_TILE_COLS];
2037   AV1DecTileMT tile_mt_info;
2038 #endif
2039 
2040   // Each time the decoder is called, we expect to receive a full temporal unit.
2041   // This can contain up to one shown frame per spatial layer in the current
2042   // operating point (note that some layers may be entirely omitted).
2043   // If the 'output_all_layers' option is true, we save all of these shown
2044   // frames so that they can be returned to the application. If the
2045   // 'output_all_layers' option is false, then we only output one image per
2046   // temporal unit.
2047   //
2048   // Note: The saved buffers are released at the start of the next time the
2049   // application calls aom_codec_decode().
2050   int output_all_layers;
2051   RefCntBuffer *output_frames[MAX_NUM_SPATIAL_LAYERS];
2052   size_t num_output_frames;  // How many frames are queued up so far?
2053 
2054   // In order to properly support random-access decoding, we need
2055   // to behave slightly differently for the very first frame we decode.
2056   // So we track whether this is the first frame or not.
2057   int decoding_first_frame;
2058 
2059   int allow_lowbitdepth;
2060   int max_threads;
2061   int inv_tile_order;
2062   int need_resync;   // wait for key/intra-only frame.
2063   int hold_ref_buf;  // Boolean: whether we are holding reference buffers in
2064                      // common.next_ref_frame_map.
2065   int reset_decoder_state;
2066 
2067   int tile_size_bytes;
2068   int tile_col_size_bytes;
2069   int dec_tile_row, dec_tile_col;  // always -1 for non-VR tile encoding
2070 #if CONFIG_ACCOUNTING
2071   int acct_enabled;
2072   Accounting accounting;
2073 #endif
2074   int tg_size;   // Number of tiles in the current tilegroup
2075   int tg_start;  // First tile in the current tilegroup
2076   int tg_size_bit_offset;
2077   int sequence_header_ready;
2078   int sequence_header_changed;
2079 #if CONFIG_INSPECTION
2080   aom_inspect_cb inspect_cb;
2081   void *inspect_ctx;
2082 #endif
2083   int operating_point;
2084   int current_operating_point;
2085   int seen_frame_header;
2086 
2087   // State if the camera frame header is already decoded while
2088   // large_scale_tile = 1.
2089   int camera_frame_header_ready;
2090   size_t frame_header_size;
2091 #ifdef ORI_CODE
2092   DataBuffer obu_size_hdr;
2093 #endif
2094   int output_frame_width_in_tiles_minus_1;
2095   int output_frame_height_in_tiles_minus_1;
2096   int tile_count_minus_1;
2097   uint32_t coded_tile_data_size;
2098   unsigned int ext_tile_debug;  // for ext-tile software debug & testing
2099   unsigned int row_mt;
2100   EXTERNAL_REFERENCES ext_refs;
2101   PIC_BUFFER_CONFIG tile_list_outbuf;
2102 
2103 #ifdef ORI_CODE
2104   CB_BUFFER *cb_buffer_base;
2105 #endif
2106   int cb_buffer_alloc_size;
2107 
2108   int allocated_row_mt_sync_rows;
2109 
2110 #if CONFIG_MULTITHREAD
2111   pthread_mutex_t *row_mt_mutex_;
2112   pthread_cond_t *row_mt_cond_;
2113 #endif
2114 
2115 #ifdef ORI_CODE
2116   AV1DecRowMTInfo frame_row_mt_info;
2117 #endif
2118 
2119 #ifdef AML
2120   unsigned char pred_inter_read_enable;
2121   int cur_obu_type;
2122   int decode_idx;
2123   int bufmgr_proc_count;
2124   int obu_frame_frame_head_come_after_tile;
2125     uint32_t frame_width;
2126     uint32_t frame_height;
2127     BuffInfo_t* work_space_buf;
2128     buff_t* mc_buf;
2129     //unsigned short *rpm_ptr;
2130     void *private_data;
2131     u32 pre_stream_offset;
2132 #endif
2133 } AV1Decoder;
2134 
2135 #define RPM_BEGIN                                              0x200
2136 #define RPM_END                                                0x280
2137 
2138 typedef union param_u {
2139     struct {
2140         unsigned short data[RPM_END - RPM_BEGIN];
2141     } l;
2142     struct {
2143         /*sequence head*/
2144         unsigned short profile;
2145         unsigned short still_picture;
2146         unsigned short reduced_still_picture_hdr;
2147         unsigned short decoder_model_info_present_flag;
2148         unsigned short max_frame_width;
2149         unsigned short max_frame_height;
2150         unsigned short frame_id_numbers_present_flag;
2151         unsigned short delta_frame_id_length;
2152         unsigned short frame_id_length;
2153         unsigned short order_hint_bits_minus_1;
2154         unsigned short enable_order_hint;
2155         unsigned short enable_dist_wtd_comp;
2156         unsigned short enable_ref_frame_mvs;
2157 
2158         /*frame head*/
2159         unsigned short show_existing_frame;
2160         unsigned short frame_type;
2161         unsigned short show_frame;
2162         unsigned short error_resilient_mode;
2163         unsigned short refresh_frame_flags;
2164         unsigned short showable_frame;
2165         unsigned short current_frame_id;
2166         unsigned short frame_size_override_flag;
2167         unsigned short order_hint;
2168         unsigned short primary_ref_frame;
2169         unsigned short frame_refs_short_signaling;
2170         unsigned short frame_width;
2171         unsigned short dec_frame_width;
2172         unsigned short frame_width_scaled;
2173         unsigned short frame_height;
2174         unsigned short reference_mode;
2175         unsigned short allow_ref_frame_mvs;
2176         unsigned short superres_scale_denominator;
2177         unsigned short lst_ref;
2178         unsigned short gld_ref;
2179         unsigned short existing_frame_idx;
2180 
2181         unsigned short remapped_ref_idx[INTER_REFS_PER_FRAME];
2182         unsigned short delta_frame_id_minus_1[INTER_REFS_PER_FRAME];
2183         unsigned short ref_order_hint[REF_FRAMES];
2184         /*other not in reference*/
2185         unsigned short bit_depth;
2186         unsigned short seq_flags;
2187         unsigned short update_parameters;
2188         unsigned short film_grain_params_ref_idx;
2189 
2190         /*loop_filter & segmentation*/
2191         unsigned short loop_filter_sharpness_level;
2192         unsigned short loop_filter_mode_ref_delta_enabled;
2193         unsigned short loop_filter_ref_deltas_0;
2194         unsigned short loop_filter_ref_deltas_1;
2195         unsigned short loop_filter_ref_deltas_2;
2196         unsigned short loop_filter_ref_deltas_3;
2197         unsigned short loop_filter_ref_deltas_4;
2198         unsigned short loop_filter_ref_deltas_5;
2199         unsigned short loop_filter_ref_deltas_6;
2200         unsigned short loop_filter_ref_deltas_7;
2201         unsigned short loop_filter_mode_deltas_0;
2202         unsigned short loop_filter_mode_deltas_1;
2203         unsigned short loop_filter_level_0;
2204         unsigned short loop_filter_level_1;
2205         unsigned short loop_filter_level_u;
2206         unsigned short loop_filter_level_v;
2207 
2208         unsigned short segmentation_enabled;
2209           /*
2210            SEG_LVL_ALT_LF_Y_V feature_enable: seg_lf_info_y[bit7]
2211            SEG_LVL_ALT_LF_Y_V data: seg_lf_info_y[bit0~6]
2212            SEG_LVL_ALT_LF_Y_H feature enable: seg_lf_info_y[bit15]
2213            SEG_LVL_ALT_LF_Y_H data: seg_lf_info_y[bit8~14]
2214            */
2215         unsigned short seg_lf_info_y[8];
2216           /*
2217            SEG_LVL_ALT_LF_U feature_enable: seg_lf_info_y[bit7]
2218            SEG_LVL_ALT_LF_U data: seg_lf_info_y[bit0~6]
2219            SEG_LVL_ALT_LF_V feature enable: seg_lf_info_y[bit15]
2220            SEG_LVL_ALT_LF_V data: seg_lf_info_y[bit8~14]
2221            */
2222         unsigned short seg_lf_info_c[8];
2223 		unsigned short video_signal_type;
2224 		unsigned short color_description;
2225 
2226         /*ucode end*/
2227         /*other*/
2228         unsigned short enable_superres;
2229 
2230         /*seqence not use*/
2231         unsigned short operating_points_cnt_minus_1;
2232         unsigned short operating_point_idc[MAX_NUM_OPERATING_POINTS];
2233         unsigned short seq_level_idx[MAX_NUM_OPERATING_POINTS];
2234         unsigned short decoder_model_param_present_flag[MAX_NUM_OPERATING_POINTS];
2235         unsigned short timing_info_present;
2236         /*frame head not use*/
2237         unsigned short display_frame_id;
2238         unsigned short frame_presentation_time;
2239         unsigned short buffer_removal_time_present;
2240         unsigned short op_frame_timing[MAX_NUM_OPERATING_POINTS + 1];
2241         unsigned short valid_ref_frame_bits;
2242 
2243     } p;
2244 }param_t;
2245 
2246 PIC_BUFFER_CONFIG *av1_get_ref_frame_spec_buf(
2247     const AV1_COMMON *const cm, const MV_REFERENCE_FRAME ref_frame);
2248 
2249 int av1_bufmgr_process(AV1Decoder *pbi, union param_u *params,
2250     unsigned char new_compressed_data, int obu_type);
2251 
2252 struct scale_factors *av1_get_ref_scale_factors(
2253   AV1_COMMON *const cm, const MV_REFERENCE_FRAME ref_frame);
2254 
2255 void av1_set_next_ref_frame_map(AV1Decoder *pbi);
2256 
2257 unsigned int av1_get_next_used_ref_info(
2258     const AV1_COMMON *const cm, int i);
2259 
2260 void av1_release_buf(AV1Decoder *pbi, RefCntBuffer *const buf);
2261 
2262 int av1_bufmgr_postproc(AV1Decoder *pbi, unsigned char frame_decoded);
2263 
2264 AV1Decoder *av1_decoder_create(BufferPool *const pool);
2265 
2266 unsigned char av1_frame_is_inter(const AV1_COMMON *const cm);
2267 
2268 RefCntBuffer *av1_get_primary_ref_frame_buf(
2269   const AV1_COMMON *const cm);
2270 
2271 void av1_raw_write_image(AV1Decoder *pbi, PIC_BUFFER_CONFIG *sd);
2272 
2273 #if 1
2274 #define lock_buffer_pool(pool, flags) \
2275     spin_lock_irqsave(&pool->lock, flags)
2276 
2277 #define unlock_buffer_pool(pool, flags) \
2278     spin_unlock_irqrestore(&pool->lock, flags)
2279 #else
2280 #define lock_buffer_pool(pool, flags) flags=1;
2281 
2282 #define unlock_buffer_pool(pool, flags) flags=0;
2283 
2284 #endif
2285 
2286 #define AV1_DEBUG_BUFMGR                   0x01
2287 #define AV1_DEBUG_BUFMGR_MORE              0x02
2288 #define AV1_DEBUG_BUFMGR_DETAIL            0x04
2289 #define AV1_DEBUG_OUT_PTS                  0x10
2290 #define AOM_DEBUG_HW_MORE                  0x20
2291 #define AOM_DEBUG_VFRAME                   0x40
2292 #define AOM_DEBUG_PRINT_LIST_INFO          0x80
2293 #define AOM_AV1_DEBUG_SEND_PARAM_WITH_REG      0x100
2294 #define AV1_DEBUG_IGNORE_VF_REF            0x200
2295 #define AV1_DEBUG_DBG_LF_PRINT             0x400
2296 #define AV1_DEBUG_REG                      0x800
2297 #define AOM_DEBUG_BUFMGR_ONLY              0x1000
2298 #define AOM_DEBUG_AUX_DATA                 0x2000
2299 #define AV1_DEBUG_QOS_INFO                 0x4000
2300 #define AOM_DEBUG_DW_DISP_MAIN             0x8000
2301 #define AV1_DEBUG_DIS_LOC_ERROR_PROC       0x10000
2302 #define AOM_DEBUG_DIS_RECYCLE_MMU_TAIL     0x20000
2303 #define AV1_DEBUG_DUMP_PIC_LIST       0x40000
2304 #define AV1_DEBUG_TRIG_SLICE_SEGMENT_PROC 0x80000
2305 #define AOM_DEBUG_USE_FIXED_MV_BUF_SIZE  0x100000
2306 #define AV1_DEBUG_LOAD_UCODE_FROM_FILE   0x200000
2307 #define AV1_DEBUG_FORCE_SEND_AGAIN       0x400000
2308 #define AV1_DEBUG_DUMP_DATA              0x800000
2309 #define AV1_DEBUG_CACHE                  0x1000000
2310 #define AV1_DEBUG_CACHE_HIT_RATE         0x2000000
2311 #define IGNORE_PARAM_FROM_CONFIG         0x8000000
2312 #if 1
2313 /*def MULTI_INSTANCE_SUPPORT*/
2314 #define PRINT_FLAG_ERROR    0x0
2315 #define PRINT_FLAG_V4L_DETAIL   0x10000000
2316 #define PRINT_FLAG_VDEC_STATUS    0x20000000
2317 #define PRINT_FLAG_VDEC_DETAIL    0x40000000
2318 #define PRINT_FLAG_VDEC_DATA    0x80000000
2319 #endif
2320 
2321 int av1_print2(int flag, const char *fmt, ...);
2322 
2323 unsigned char av1_is_debug(int flag);
2324 
2325 #endif
2326 
2327