xref: /rockchip-linux_mpp/mpp/codec/dec/vp9/vpx_rac.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2 *
3 * Copyright 2015 Rockchip Electronics Co. LTD
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 
18 /**
19  * @file
20  * VPX RangeCoder dec (common features)
21  */
22 
23 #ifndef VPX_RAC_H
24 #define VPX_RAC_H
25 
26 #include <stdint.h>
27 #include <stdlib.h>
28 
29 #include "mpp_common.h"
30 
31 #define DECLARE_ALIGNED(n,t,v)      t v
32 
33 typedef struct Vpxmv {
34     DECLARE_ALIGNED(4, int16_t, x);
35     int16_t y;
36 } Vpxmv;
37 
38 typedef struct VpxRangeCoder {
39     int high;
40     int bits; /* stored negated (i.e. negative "bits" is a positive number of
41                  bits left) in order to eliminate a negate in cache refilling */
42     const uint8_t *buffer;
43     const uint8_t *end;
44     unsigned int code_word;
45 } VpxRangeCoder;
46 
47 /**
48  * vp56 specific range coder implementation
49  */
50 
51 extern const uint8_t vpx_norm_shift[256];
52 void vpx_init_range_decoder(VpxRangeCoder *c, const uint8_t *buf, int buf_size);
53 unsigned int vpx_rac_renorm(VpxRangeCoder *c);
54 int vpx_rac_get_prob(VpxRangeCoder *c, uint8_t prob);
55 int vpx_rac_get_prob_branchy(VpxRangeCoder *c, int prob);
56 // rounding is different than vpx_rac_get, is vpx_rac_get wrong?
57 int vpx_rac_get(VpxRangeCoder *c);
58 int vpx_rac_get_uint(VpxRangeCoder *c, int bits);
59 
60 #endif /* VPX_RAC_H */
61