xref: /rockchip-linux_mpp/mpp/common/mpg4d_syntax.h (revision 437bfbeb9567cca9cd9080e3f6954aa9d6a94f18)
1 /*
2  *
3  * Copyright 2010 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        mpeg4d_syntax.h
20  * @brief
21  * @author      gzl(gzl@rock-chips.com)
22  * @version     1.0.0
23  * @history
24  *   2016.04.06 : Create
25  */
26 #ifndef __MPG4D_SYNTAX__
27 #define __MPG4D_SYNTAX__
28 
29 #include "dxva_syntax.h"
30 
31 #define MPEG4_VIDOBJLAY_AR_SQUARE           1
32 #define MPEG4_VIDOBJLAY_AR_625TYPE_43       2
33 #define MPEG4_VIDOBJLAY_AR_525TYPE_43       3
34 #define MPEG4_VIDOBJLAY_AR_625TYPE_169      8
35 #define MPEG4_VIDOBJLAY_AR_525TYPE_169      9
36 #define MPEG4_VIDOBJLAY_AR_EXTPAR           15
37 
38 #define MPEG4_VIDOBJLAY_SHAPE_RECTANGULAR   0
39 #define MPEG4_VIDOBJLAY_SHAPE_BINARY        1
40 #define MPEG4_VIDOBJLAY_SHAPE_BINARY_ONLY   2
41 #define MPEG4_VIDOBJLAY_SHAPE_GRAYSCALE     3
42 
43 /*video sprite specific*/
44 #define MPEG4_SPRITE_NONE                   0
45 #define MPEG4_SPRITE_STATIC                 1
46 #define MPEG4_SPRITE_GMC                    2
47 
48 /*video vop specific*/
49 typedef enum {
50     MPEG4_RESYNC_VOP    = -2,
51     MPEG4_INVALID_VOP   = -1,
52     MPEG4_I_VOP         = 0,
53     MPEG4_P_VOP         = 1,
54     MPEG4_B_VOP         = 2,
55     MPEG4_S_VOP         = 3,
56     MPEG4_N_VOP         = 4,
57     MPEG4_D_VOP         = 5,                /*Drop Frame*/
58 } MPEG4VOPType;
59 
60 #define MPEG4_HDR_ERR       -2
61 #define MPEG4_DEC_ERR       -4
62 #define MPEG4_VLD_ERR       -5
63 #define MPEG4_FORMAT_ERR    -6
64 #define MPEG4_DIVX_PBBI     -7
65 #define MPEG4_INFO_CHANGE   -10
66 
67 /* MPEG4PT2 Picture Parameter structure */
68 typedef struct _DXVA_PicParams_MPEG4_PART2 {
69     RK_U8   short_video_header;
70     RK_U8   vop_coding_type;
71     RK_U8   vop_quant;
72     RK_U16  wDecodedPictureIndex;
73     RK_U16  wDeblockedPictureIndex;
74     RK_U16  wForwardRefPictureIndex;
75     RK_U16  wBackwardRefPictureIndex;
76     RK_U16  vop_time_increment_resolution;
77     RK_U32  TRB[2];
78     RK_U32  TRD[2];
79 
80     union {
81         struct {
82             RK_U16  unPicPostProc                 : 2;
83             RK_U16  interlaced                    : 1;
84             RK_U16  quant_type                    : 1;
85             RK_U16  quarter_sample                : 1;
86             RK_U16  resync_marker_disable         : 1;
87             RK_U16  data_partitioned              : 1;
88             RK_U16  reversible_vlc                : 1;
89             RK_U16  reduced_resolution_vop_enable : 1;
90             RK_U16  vop_coded                     : 1;
91             RK_U16  vop_rounding_type             : 1;
92             RK_U16  intra_dc_vlc_thr              : 3;
93             RK_U16  top_field_first               : 1;
94             RK_U16  alternate_vertical_scan_flag  : 1;
95         };
96         RK_U16 wPicFlagBitFields;
97     };
98     RK_U8   profile_and_level_indication;
99     RK_U8   video_object_layer_verid;
100     RK_U16  vop_width;
101     RK_U16  vop_height;
102     union {
103         struct {
104             RK_U16  sprite_enable               : 2;
105             RK_U16  no_of_sprite_warping_points : 6;
106             RK_U16  sprite_warping_accuracy     : 2;
107         };
108         RK_U16 wSpriteBitFields;
109     };
110     RK_S16  warping_mv[4][2];
111     union {
112         struct {
113             RK_U8  vop_fcode_forward   : 3;
114             RK_U8  vop_fcode_backward  : 3;
115         };
116         RK_U8 wFcodeBitFields;
117     };
118     RK_U16  StatusReportFeedbackNumber;
119     RK_U16  Reserved16BitsA;
120     RK_U16  Reserved16BitsB;
121 
122     // FIXME: added for rockchip hardware information
123     RK_U32  custorm_version;
124     RK_U32  prev_coding_type;
125     RK_U32  time_bp;
126     RK_U32  time_pp;
127     RK_U32  header_bits;
128 } DXVA_PicParams_MPEG4_PART2, *LPDXVA_PicParams_MPEG4_PART2;
129 
130 typedef struct _DXVA_QmatrixData {
131     RK_U8   bNewQmatrix[4]; // intra Y, inter Y, intra chroma, inter chroma
132     RK_U8   Qmatrix[4][64]; // NOTE: here we change U16 to U8
133 } DXVA_QmatrixData, *LPDXVA_QmatrixData;
134 
135 typedef struct mpeg4d_dxva2_picture_context {
136     DXVA_PicParams_MPEG4_PART2  pp;
137     DXVA_QmatrixData            qm;
138 
139     // pointer and storage for buffer descriptor
140     DXVA2_DecodeBufferDesc      *data[3];
141     DXVA2_DecodeBufferDesc      desc[3];
142 
143     RK_U32                      frame_count;
144     const RK_U8                 *bitstream;
145     RK_U32                      bitstream_size;
146 } mpeg4d_dxva2_picture_context_t;
147 
148 #endif /*__MPG4D_SYNTAX__*/
149