1 /*
2  * Copyright (c) 2001-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 /* clang-format off */
13 
14 #if !defined(_state_H)
15 # define _state_H (1)
16 
17 typedef struct od_state     od_state;
18 typedef struct od_adapt_ctx od_adapt_ctx;
19 
20 # include "generic_code.h"
21 # include "odintrin.h"
22 # include "pvq.h"
23 
24 /*Adaptation speed of scalar Laplace encoding.*/
25 # define OD_SCALAR_ADAPT_SPEED (4)
26 
27 struct od_adapt_ctx {
28   /* Support for PVQ encode/decode */
29   od_pvq_adapt_ctx pvq;
30 
31   generic_encoder model_dc[OD_NPLANES_MAX];
32 
33   int ex_dc[OD_NPLANES_MAX][OD_TXSIZES][3];
34   int ex_g[OD_NPLANES_MAX][OD_TXSIZES];
35 
36   /* Joint skip flag for DC and AC */
37   uint16_t skip_cdf[OD_TXSIZES*2][CDF_SIZE(4)];
38 };
39 
40 struct od_state {
41   od_adapt_ctx *adapt;
42   unsigned char pvq_qm_q4[OD_NPLANES_MAX][OD_QM_SIZE];
43   /* Quantization matrices and their inverses. */
44   int16_t qm[OD_QM_BUFFER_SIZE];
45   int16_t qm_inv[OD_QM_BUFFER_SIZE];
46 };
47 
48 void od_adapt_ctx_reset(od_adapt_ctx *state, int is_keyframe);
49 void od_init_skipped_coeffs(int16_t *d, int16_t *pred, int is_keyframe,
50  int bo, int n, int w);
51 
52 #endif
53