]> git.sesse.net Git - ffmpeg/blob - libavcodec/cavs.h
Add a bounds check on AVProbeData input.
[ffmpeg] / libavcodec / cavs.h
1 /*
2  * Chinese AVS video (AVS1-P2, JiZhun profile) decoder.
3  * Copyright (c) 2006  Stefan Gehrer <stefan.gehrer@gmx.de>
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21
22 #ifndef CAVS_H
23 #define CAVS_H
24
25 #include "dsputil.h"
26
27 #define SLICE_MIN_START_CODE    0x00000101
28 #define SLICE_MAX_START_CODE    0x000001af
29 #define EXT_START_CODE          0x000001b5
30 #define USER_START_CODE         0x000001b2
31 #define CAVS_START_CODE         0x000001b0
32 #define PIC_I_START_CODE        0x000001b3
33 #define PIC_PB_START_CODE       0x000001b6
34
35 #define A_AVAIL                          1
36 #define B_AVAIL                          2
37 #define C_AVAIL                          4
38 #define D_AVAIL                          8
39 #define NOT_AVAIL                       -1
40 #define REF_INTRA                       -2
41 #define REF_DIR                         -3
42
43 #define ESCAPE_CODE                     59
44
45 #define FWD0                          0x01
46 #define FWD1                          0x02
47 #define BWD0                          0x04
48 #define BWD1                          0x08
49 #define SYM0                          0x10
50 #define SYM1                          0x20
51 #define SPLITH                        0x40
52 #define SPLITV                        0x80
53
54 #define MV_BWD_OFFS                     12
55 #define MV_STRIDE                        4
56
57 enum mb_t {
58   I_8X8 = 0,
59   P_SKIP,
60   P_16X16,
61   P_16X8,
62   P_8X16,
63   P_8X8,
64   B_SKIP,
65   B_DIRECT,
66   B_FWD_16X16,
67   B_BWD_16X16,
68   B_SYM_16X16,
69   B_8X8 = 29
70 };
71
72 enum sub_mb_t {
73   B_SUB_DIRECT,
74   B_SUB_FWD,
75   B_SUB_BWD,
76   B_SUB_SYM
77 };
78
79 enum intra_luma_t {
80   INTRA_L_VERT,
81   INTRA_L_HORIZ,
82   INTRA_L_LP,
83   INTRA_L_DOWN_LEFT,
84   INTRA_L_DOWN_RIGHT,
85   INTRA_L_LP_LEFT,
86   INTRA_L_LP_TOP,
87   INTRA_L_DC_128
88 };
89
90 enum intra_chroma_t {
91   INTRA_C_LP,
92   INTRA_C_HORIZ,
93   INTRA_C_VERT,
94   INTRA_C_PLANE,
95   INTRA_C_LP_LEFT,
96   INTRA_C_LP_TOP,
97   INTRA_C_DC_128,
98 };
99
100 enum mv_pred_t {
101   MV_PRED_MEDIAN,
102   MV_PRED_LEFT,
103   MV_PRED_TOP,
104   MV_PRED_TOPRIGHT,
105   MV_PRED_PSKIP,
106   MV_PRED_BSKIP
107 };
108
109 enum block_t {
110   BLK_16X16,
111   BLK_16X8,
112   BLK_8X16,
113   BLK_8X8
114 };
115
116 enum mv_loc_t {
117   MV_FWD_D3 = 0,
118   MV_FWD_B2,
119   MV_FWD_B3,
120   MV_FWD_C2,
121   MV_FWD_A1,
122   MV_FWD_X0,
123   MV_FWD_X1,
124   MV_FWD_A3 = 8,
125   MV_FWD_X2,
126   MV_FWD_X3,
127   MV_BWD_D3 = MV_BWD_OFFS,
128   MV_BWD_B2,
129   MV_BWD_B3,
130   MV_BWD_C2,
131   MV_BWD_A1,
132   MV_BWD_X0,
133   MV_BWD_X1,
134   MV_BWD_A3 = MV_BWD_OFFS+8,
135   MV_BWD_X2,
136   MV_BWD_X3
137 };
138
139 DECLARE_ALIGNED_8(typedef, struct) {
140     int16_t x;
141     int16_t y;
142     int16_t dist;
143     int16_t ref;
144 } vector_t;
145
146 typedef struct residual_vlc_t {
147   int8_t rltab[59][3];
148   int8_t level_add[27];
149   int8_t golomb_order;
150   int inc_limit;
151   int8_t max_run;
152 } residual_vlc_t;
153
154 #endif /* CAVS_H */