1 /*
2     This file is provided under a dual BSD/GPLv2 license.  When using or
3     redistributing this file, you may do so under either license.
4 
5     GPL LICENSE SUMMARY
6 
7     Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
8 
9     This program is free software; you can redistribute it and/or modify
10     it under the terms of version 2 of the GNU General Public License as
11     published by the Free Software Foundation.
12 
13     This program is distributed in the hope that it will be useful, but
14     WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16     General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21     The full GNU General Public License is included in this distribution
22     in the file called LICENSE.GPL.
23 
24     Contact Information:
25 
26     BSD LICENSE
27 
28     Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
29     All rights reserved.
30 
31     Redistribution and use in source and binary forms, with or without
32     modification, are permitted provided that the following conditions
33     are met:
34 
35     * Redistributions of source code must retain the above copyright
36     notice, this list of conditions and the following disclaimer.
37     * Redistributions in binary form must reproduce the above copyright
38     notice, this list of conditions and the following disclaimer in
39     the documentation and/or other materials provided with the
40     distribution.
41     * Neither the name of Intel Corporation nor the names of its
42     contributors may be used to endorse or promote products derived
43     from this software without specific prior written permission.
44 
45     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 
57 */
58 #ifndef VIDDEC_FW_ITEM_TYPES_H
59 #define VIDDEC_FW_ITEM_TYPES_H
60 
61 
62 /* The following macros are defined to pack data into 32 bit words.
63    mask:    A 32 bit value of N 1 bits starting from lsb where N represents the length of data we are packing.
64    start:   Bit start position of data we want.
65           ex:  If we want to pack Height(16bits), width(16bits) where width is from (1:16) and height is from (17:32), these are
66           the start and mask values for width and height.
67           width: start = 0 mask=0xFFFF
68           Height:start=  16 mask=0xFFFF
69 
70    extract: will extract data from x_32 of unsigned integer type from bit start offset(0 to 31) of length based on mask and returns in
71             unsigned integer type.
72    insert:  Will insert N bits from val_32 ,where N is length based on mask, into x_32 from bit offset based on start. val_32 is expected to
73            be a unsigned int of N bits starting with lsb.
74 */
75 
76 #define viddec_fw_bitfields_extract(x_32, start, mask)     (((x_32) >> (start)) & (mask) )
77 #define viddec_fw_bitfields_insert(x_32, val_32, start, mask) ((x_32) = (((x_32) & ~( (mask) << (start))) | (((val_32) & (mask)) << (start))))
78 
79 /* Workload items type. Each item here represents data that Parser detected ex:slice data which
80  is used either by host or decoder.*/
81 enum workload_item_type
82 {
83     VIDDEC_WORKLOAD_INVALID=0x0,                   /* Unknown type */
84     VIDDEC_WORKLOAD_PIXEL_ES=0x100,                /* Slice data tag */
85     VIDDEC_WORKLOAD_TAG=0x200,                     /* Frame association tag */
86     VIDDEC_WORKLOAD_USERDATA=0x300,                /* user data tag */
87     VIDDEC_WORKLOAD_DECODER_INFO=0x400,            /* decoder specific data tag which decoder module understands*/
88     VIDDEC_WORKLOAD_IBUF_DONE=0x500,               /* Es buffer completely used tag */
89     VIDDEC_WORKLOAD_IBUF_CONTINUED=0x600,          /* Es buffer partially used tag */
90     VIDDEC_WORKLOAD_TAG_BUFFER_LOOSE_START=0x700,  /* ??? */
91     VIDDEC_WORKLOAD_REFERENCE_FRAME_REORDER=0x800, /* Reorder frames in DPB tag */
92     VIDDEC_WORKLOAD_DISPLAY_FRAME=0x900,           /* Display order in DPB tag, for H264 NOT required??? */
93 
94     VIDDEC_WORKLOAD_SEQUENCE_INFO=0xa00,           /* MPEG2 Seq Hdr, H264 SPS, VC1 SeqLayer */
95     VIDDEC_WORKLOAD_DISPLAY_INFO=0xb00,            /* MPEG2 Seq Disp Ext, H264 VUI */
96     VIDDEC_WORKLOAD_GOP_INFO=0xc00,                /* MPEG2 GOP, VC1 Entrypoint */
97     VIDDEC_WORKLOAD_SEQ_USER_DATA=0xd00,           /* MPEG2, VC1 Sequence Level User data */
98     VIDDEC_WORKLOAD_GOP_USER_DATA=0xe00,           /* MPEG2, VC1 Gop Level User data */
99     VIDDEC_WORKLOAD_FRM_USER_DATA=0xf00,           /* MPEG2 Picture User data, VC1 Frame User data */
100     VIDDEC_WORKLOAD_FLD_USER_DATA=0x1000,          /* MPEG2, VC1 Field User data */
101     VIDDEC_WORKLOAD_SLC_USER_DATA=0x1100,          /* VC1 Slice User data */
102     VIDDEC_WORKLOAD_VISUAL_OBJ_USER_DATA=0x1200,   /* MPEG4 Visual Object User data */
103     VIDDEC_WORKLOAD_VIDEO_OBJ_USER_DATA=0x1300,    /* MPEG4 Video Object Layer User data */
104 
105     VIDDEC_WORKLOAD_MPEG2_SEQ_EXT=0x1150,              /* MPEG2 Only - Sequence Extension */
106     VIDDEC_WORKLOAD_VC1_SEQ_HDR_STRUCT_A_C=0x1200,     /* VC1 Only */
107 
108     VIDDEC_WORKLOAD_H264_CROPPING=0x1400,              /* H264 only */
109     VIDDEC_WORKLOAD_H264_PAN_SCAN=0x1500,              /* H264 only */
110     VIDDEC_WORKLOAD_H264_VUI_TIMING_INFO=0x2100,       /* H264 only */
111     VIDDEC_WORKLOAD_SEI_PIC_TIMING=0x1600,             /* H264 only */
112     VIDDEC_WORKLOAD_SEI_PAN_SCAN_RECT=0x1700,          /* H264 only */
113     VIDDEC_WORKLOAD_SEI_USER_DATA_REGISTERED=0x1800,   /* H264 only */
114     VIDDEC_WORKLOAD_SEI_USER_DATA_UNREGISTERED=0x1900, /* H264 only */
115     VIDDEC_WORKLOAD_SEI_RECOVERY_POINT=0x1a00,         /* H264 only */
116     VIDDEC_WORKLOAD_IBUF_EOS=0x1b00,          /* EOS tag on last workload used for current stream */
117     VIDDEC_WORKLOAD_IBUF_DISCONTINUITY=0x1c00,           /* Discontinuity tag on first workload after discontinuity */
118 
119     VIDDEC_WORKLOAD_MPEG4_VISUAL_SEQ_OBJ=0x1d00,       /* MPEG4 Only - Visual Sequence */
120     VIDDEC_WORKLOAD_MPEG4_VIDEO_OBJ=0x1e00,            /* MPEG4 Only - Video Object Layer */
121     VIDDEC_WORKLOAD_MPEG4_GRP_VIDEO_OBJ=0x1f00,        /* MPEG4 Only - Group of Video Object Planes */
122     VIDDEC_WORKLOAD_MPEG4_VIDEO_PLANE_SHORT=0x2000,    /* MPEG4 Only - Video Plane with Short Header */
123 
124     VIDDEC_WORKLOAD_REF_FRAME_SOURCE_0 = 0x10000,   	/* required reference frames tag, last eight bits tell the id of frame in dpb */
125     VIDDEC_WORKLOAD_REF_FRAME_RELEASE_0 = 0x20000,  	/* release frames tag, last eight bits tell the id of frame in dpb */
126     VIDDEC_WORKLOAD_REF_FRAME_DISPLAY_0 = 0x30000,  	/* Display order in DPB tag, for H264 */
127 	 VIDDEC_WORKLOAD_REF_FRAME_DROPOUT_0 = 0x40000,  	   /* Release frames but not display, for H264 */
128 	 VIDDEC_WORKLOAD_EOS_RELEASE_FRAME_0 = 0x50000,		/* Release list while EOS, last eight bits tell the id of frame in dpb */
129 	 VIDDEC_WORKLOAD_EOS_DISPLAY_FRAME_0 = 0x60000,		/* Diaplay list while EOS, last eight bits tell the id of frame in dpb */
130 
131     VIDDEC_WORKLOAD_DPB_ACTIVE_FRAME_0  = 0x70000,   	/* required for H264 as it needs whole DPB for each frame */
132     VIDDEC_WORKLOAD_H264_REFR_LIST_0    =  0x80000,   /* ref list 0 for H264 */
133     VIDDEC_WORKLOAD_H264_REFR_LIST_1    =  0x90000,   /* ref list 1 for H264 */
134     VIDDEC_WORKLOAD_EOS_BEGIN_BOUNDARY  =  0xa0000,   /* eos items begin after this */
135     VIDDEC_WORKLOAD_DECODER_SPECIFIC = 0x100000,    /* pvt info for decoder tags */
136     VIDDEC_WORKLOAD_MAX,
137 };
138 
139 /* 16-byte workload */
140 typedef struct viddec_workload_item
141 {
142     enum workload_item_type vwi_type;
143     union
144     {
145         struct
146         {
147             unsigned int    es_phys_addr;
148             unsigned int    es_phys_len;
149             unsigned int    es_flags;
150         }es;
151         struct
152         {
153             unsigned int    tag_phys_addr;
154             unsigned int    tag_phys_len;
155             unsigned int    tag_value;
156         }tag;
157         struct
158         {
159             unsigned int    data_offset;
160             unsigned int    data_payload[2];
161         }data;
162         struct
163         {
164             signed int      reference_id;     /* Assigned by parser */
165             unsigned int    luma_phys_addr;   /* assigned by host, for DM */
166             unsigned int    chroma_phys_addr; /* assigned by host, for DM */
167         }ref_frame;
168         struct   /* when vwi_type == VIDDEC_WORKLOAD_REFERENCE_FRAME_REORDER */
169         {
170             signed int      ref_table_offset;    /* Index of first "reordered" */
171             /* index from Current[] for Next[offset+0], Ref[offset+1], Ref[offset+2], Ref[offset+3] */
172             unsigned int    ref_reorder_00010203;
173             /* index from Current[] for Next[offset+4], Ref[offset+5], Ref[offset+6], Ref[offset+7] */
174             unsigned int    ref_reorder_04050607;
175         } ref_reorder;
176         struct
177         {
178             /* we pack a maximum of 11 bytes of user data and 1 byte for size */
179             /* TODO: we can pack 12 bytes and use bottom 8 bits of type to indicate size */
180 #define viddec_fw_get_user_data_size(x)  ((x)->user_data.size)
181 #define viddec_fw_get_user_data(x)   (unsigned char *)&((x)->user_data.data_payload[0])
182             unsigned char size;
183             unsigned char data_payload[11];
184             /*
185               ITEM TYPES WHICH use this:
186               VIDDEC_WORKLOAD_SEI_USER_DATA_UNREGISTERED, VIDDEC_WORKLOAD_SEI_USER_DATA_REGISTERED,
187               VIDDEC_WORKLOAD_SEQ_USER_DATA, VIDDEC_WORKLOAD_GOP_USER_DATA,
188               VIDDEC_WORKLOAD_FRM_USER_DATA, VIDDEC_WORKLOAD_FLD_USER_DATA, VIDDEC_WORKLOAD_SLC_USER_DATA,
189             */
190         }user_data;
191         struct
192         {
193             // Sequence Header Item I (From LSB):
194             //    - horizontal_size_value    - 12 bits
195             //    - vertical_size_value      - 12 bits
196             //    - aspect_ratio_information - 4 bits
197             //    - frame_rate_code          - 4 bits
198             #define viddec_fw_mp2_sh_get_horizontal_size_value(x)    viddec_fw_bitfields_extract( (x)->seq_hdr_item_1,  0, 0xFFF)
199             #define viddec_fw_mp2_sh_get_vertical_size_value(x)      viddec_fw_bitfields_extract( (x)->seq_hdr_item_1, 12, 0xFFF)
200             #define viddec_fw_mp2_sh_get_aspect_ratio_information(x) viddec_fw_bitfields_extract( (x)->seq_hdr_item_1, 24, 0xF)
201             #define viddec_fw_mp2_sh_get_frame_rate_code(x)          viddec_fw_bitfields_extract( (x)->seq_hdr_item_1, 28, 0xF)
202             #define viddec_fw_mp2_sh_set_horizontal_size_value(x, val)    viddec_fw_bitfields_insert ( (x)->seq_hdr_item_1, val,  0, 0xFFF)
203             #define viddec_fw_mp2_sh_set_vertical_size_value(x, val)      viddec_fw_bitfields_insert ( (x)->seq_hdr_item_1, val, 12, 0xFFF)
204             #define viddec_fw_mp2_sh_set_aspect_ratio_information(x, val) viddec_fw_bitfields_insert ( (x)->seq_hdr_item_1, val, 24, 0xF)
205             #define viddec_fw_mp2_sh_set_frame_rate_code(x, val)          viddec_fw_bitfields_insert ( (x)->seq_hdr_item_1, val, 28, 0xF)
206             unsigned int seq_hdr_item_1;
207 
208             // Sequence Header Item II (From LSB):
209             //    - bit_rate_value        - 18 bits
210             //    - vbv_buffer_size_value - 10 bits
211             //    - remaining pad bits
212             #define viddec_fw_mp2_sh_get_bit_rate_value(x)        viddec_fw_bitfields_extract( (x)->seq_hdr_item_2,  0, 0x3FFFF)
213             #define viddec_fw_mp2_sh_get_vbv_buffer_size_value(x) viddec_fw_bitfields_extract( (x)->seq_hdr_item_2, 18, 0x3FF)
214             #define viddec_fw_mp2_sh_set_bit_rate_value(x, val)        viddec_fw_bitfields_insert ( (x)->seq_hdr_item_2, val,  0, 0x3FFFF)
215             #define viddec_fw_mp2_sh_set_vbv_buffer_size_value(x, val) viddec_fw_bitfields_insert ( (x)->seq_hdr_item_2, val, 18, 0x3FF)
216             unsigned int seq_hdr_item_2;
217 
218             unsigned int pad;
219         } mp2_sh; // mp2 item of type VIDDEC_WORKLOAD_SEQUENCE_INFO
220         struct
221         {
222             // Sequence Extension Item I (From LSB):
223             //    - profile_and_level_indication - 8 bits
224             //    - progressive_sequence         - 1 bit
225             //    - chroma_format                - 2 bits
226             //    - horizontal_size_extension    - 2 bits
227             //    - vertical_size_extension      - 2 bits
228             //    - bit_rate_extension           - 12 bits
229             //    - remaining pad bits
230             #define viddec_fw_mp2_se_get_profile_and_level_indication(x) viddec_fw_bitfields_extract( (x)->seq_ext_item_1,  0, 0xFF)
231             #define viddec_fw_mp2_se_get_progressive_sequence(x)         viddec_fw_bitfields_extract( (x)->seq_ext_item_1,  8, 0x1)
232             #define viddec_fw_mp2_se_get_chroma_format(x)                viddec_fw_bitfields_extract( (x)->seq_ext_item_1,  9, 0x3)
233             #define viddec_fw_mp2_se_get_horizontal_size_extension(x)    viddec_fw_bitfields_extract( (x)->seq_ext_item_1, 11, 0x3)
234             #define viddec_fw_mp2_se_get_vertical_size_extension(x)      viddec_fw_bitfields_extract( (x)->seq_ext_item_1, 13, 0x3)
235             #define viddec_fw_mp2_se_get_bit_rate_extension(x)           viddec_fw_bitfields_extract( (x)->seq_ext_item_1, 15, 0xFFF)
236             #define viddec_fw_mp2_se_set_profile_and_level_indication(x, val) viddec_fw_bitfields_insert ( (x)->seq_ext_item_1, val,  0, 0xFF)
237             #define viddec_fw_mp2_se_set_progressive_sequence(x, val)         viddec_fw_bitfields_insert ( (x)->seq_ext_item_1, val,  8, 0x1)
238             #define viddec_fw_mp2_se_set_chroma_format(x, val)                viddec_fw_bitfields_insert ( (x)->seq_ext_item_1, val,  9, 0x3)
239             #define viddec_fw_mp2_se_set_horizontal_size_extension(x, val)    viddec_fw_bitfields_insert ( (x)->seq_ext_item_1, val, 11, 0x3)
240             #define viddec_fw_mp2_se_set_vertical_size_extension(x, val)      viddec_fw_bitfields_insert ( (x)->seq_ext_item_1, val, 13, 0x3)
241             #define viddec_fw_mp2_se_set_bit_rate_extension(x, val)           viddec_fw_bitfields_insert ( (x)->seq_ext_item_1, val, 15, 0xFFF)
242             unsigned int seq_ext_item_1;
243 
244             // Sequence Extension Item II (From LSB):
245             //    - vbv_buffer_size_extension - 8 bits
246             //    - frame_rate_extension_n    - 2 bits
247             //    - frame_rate_extension_d    - 5 bits
248             //    - remaining pad bits
249             #define viddec_fw_mp2_se_get_vbv_buffer_size_extension(x) viddec_fw_bitfields_extract( (x)->seq_ext_item_2,  0, 0xFF)
250             #define viddec_fw_mp2_se_get_frame_rate_extension_n(x)    viddec_fw_bitfields_extract( (x)->seq_ext_item_2,  8, 0x3)
251             #define viddec_fw_mp2_se_get_frame_rate_extension_d(x)    viddec_fw_bitfields_extract( (x)->seq_ext_item_2, 10, 0x1F)
252             #define viddec_fw_mp2_se_set_vbv_buffer_size_extension(x, val) viddec_fw_bitfields_insert ( (x)->seq_ext_item_2, val,  0, 0xFF)
253             #define viddec_fw_mp2_se_set_frame_rate_extension_n(x, val)    viddec_fw_bitfields_insert ( (x)->seq_ext_item_2, val,  8, 0x3)
254             #define viddec_fw_mp2_se_set_frame_rate_extension_d(x, val)    viddec_fw_bitfields_insert ( (x)->seq_ext_item_2, val, 10, 0x1F)
255             unsigned int seq_ext_item_2;
256 
257             unsigned int pad;
258         } mp2_se; // mp2 item of type VIDDEC_WORKLOAD_MPEG2_SEQ_EXT
259         struct
260         {
261             // Sequence Display Extension Item I (From LSB):
262             //   - display_horizontal_size - 14 bits
263             //   - display_vertical_size   - 14 bits
264             //   - video_format            - 3 bits
265             //   - color_description       - 1 bit
266             #define viddec_fw_mp2_sde_get_display_horizontal_size(x) viddec_fw_bitfields_extract( (x)->seq_disp_ext_item_1,  0, 0x3FFF)
267             #define viddec_fw_mp2_sde_get_display_vertical_size(x)   viddec_fw_bitfields_extract( (x)->seq_disp_ext_item_1, 14, 0x3FFF)
268             #define viddec_fw_mp2_sde_get_video_format(x)            viddec_fw_bitfields_extract( (x)->seq_disp_ext_item_1, 28, 0x7)
269             #define viddec_fw_mp2_sde_get_color_description(x)       viddec_fw_bitfields_extract( (x)->seq_disp_ext_item_1, 31, 0x1)
270             #define viddec_fw_mp2_sde_set_display_horizontal_size(x, val) viddec_fw_bitfields_insert ( (x)->seq_disp_ext_item_1, val,  0, 0x3FFF)
271             #define viddec_fw_mp2_sde_set_display_vertical_size(x, val)   viddec_fw_bitfields_insert ( (x)->seq_disp_ext_item_1, val, 14, 0x3FFF)
272             #define viddec_fw_mp2_sde_set_video_format(x, val)            viddec_fw_bitfields_insert ( (x)->seq_disp_ext_item_1, val, 28, 0x7)
273             #define viddec_fw_mp2_sde_set_color_description(x, val)       viddec_fw_bitfields_insert ( (x)->seq_disp_ext_item_1, val, 31, 0x1)
274             unsigned int seq_disp_ext_item_1;
275 
276             // Sequence Display Extension II (From LSB):
277             //   - color_primaries - 8 bits
278             //   - transfer_characteristics - 8 bits
279             //   - remaining pad bits
280             #define viddec_fw_mp2_sde_get_color_primaries(x)          viddec_fw_bitfields_extract( (x)->seq_disp_ext_item_2,  0, 0xFF)
281             #define viddec_fw_mp2_sde_get_transfer_characteristics(x) viddec_fw_bitfields_extract( (x)->seq_disp_ext_item_2,  8, 0xFF)
282             #define viddec_fw_mp2_sde_set_color_primaries(x, val)          viddec_fw_bitfields_insert ( (x)->seq_disp_ext_item_2, val,  0, 0xFF)
283             #define viddec_fw_mp2_sde_set_transfer_characteristics(x, val) viddec_fw_bitfields_insert ( (x)->seq_disp_ext_item_2, val,  8, 0xFF)
284             unsigned int seq_disp_ext_item_2;
285 
286             unsigned int pad;
287         } mp2_sde; // mp2 item of type VIDDEC_WORKLOAD_DISPLAY_INFO
288         struct
289         {
290             // Group of Pictures Header Item I (From LSB):
291             //   - closed_gop - 1 bit
292             //   - broken_link - 1 bit
293             //   - remaining pad bits
294             #define viddec_fw_mp2_gop_get_closed_gop(x)  viddec_fw_bitfields_extract( (x)->gop_hdr_item_1,  0, 0x1)
295             #define viddec_fw_mp2_gop_get_broken_link(x) viddec_fw_bitfields_extract( (x)->gop_hdr_item_1,  1, 0x1)
296             #define viddec_fw_mp2_gop_set_closed_gop(x, val)  viddec_fw_bitfields_insert ( (x)->gop_hdr_item_1, val,  0, 0x1)
297             #define viddec_fw_mp2_gop_set_broken_link(x, val) viddec_fw_bitfields_insert ( (x)->gop_hdr_item_1, val,  1, 0x1)
298             unsigned int gop_hdr_item_1;
299 
300             unsigned int pad1;
301             unsigned int pad2;
302         } mp2_gop; // mp2 item of type VIDDEC_WORKLOAD_GOP_INFO
303         struct
304         {
305             #define viddec_fw_vc1_get_profile(x) viddec_fw_bitfields_extract((x)->size, 30, 0x3)
306             #define viddec_fw_vc1_set_profile(x, val) viddec_fw_bitfields_insert((x)->size, val, 30, 0x3)
307 
308             #define viddec_fw_vc1_get_level(x) viddec_fw_bitfields_extract((x)->size, 27, 0x7)
309             #define viddec_fw_vc1_set_level(x, val) viddec_fw_bitfields_insert((x)->size, val, 27, 0x7)
310 
311             #define viddec_fw_vc1_get_colordiff_format(x) viddec_fw_bitfields_extract((x)->size, 25, 0x3)
312             #define viddec_fw_vc1_set_colordiff_format(x, val) viddec_fw_bitfields_insert((x)->size, val, 25, 0x3)
313 
314             #define viddec_fw_vc1_get_pulldown(x) viddec_fw_bitfields_extract((x)->size, 24, 0x1)
315             #define viddec_fw_vc1_set_pulldown(x, val) viddec_fw_bitfields_insert((x)->size, val, 24, 0x1)
316 
317             #define viddec_fw_vc1_get_max_coded_width(x) viddec_fw_bitfields_extract((x)->size, 12, 0xFFF)
318             #define viddec_fw_vc1_set_max_coded_width(x, val) viddec_fw_bitfields_insert((x)->size, val, 12, 0xFFF)
319 
320             #define viddec_fw_vc1_get_max_coded_height(x) viddec_fw_bitfields_extract((x)->size, 0, 0xFFF)
321             #define viddec_fw_vc1_set_max_coded_height(x, val) viddec_fw_bitfields_insert((x)->size, val, 0, 0xFFF)
322 
323             #define viddec_fw_vc1_get_bitrtq_postproc(x) viddec_fw_bitfields_extract((x)->flags, 8, 0x1F)
324             #define viddec_fw_vc1_set_bitrtq_postproc(x, val) viddec_fw_bitfields_insert((x)->flags, val, 8, 0x1F)
325 
326             #define viddec_fw_vc1_get_frmrtq_postproc(x) viddec_fw_bitfields_extract((x)->flags, 5, 0x7)
327             #define viddec_fw_vc1_set_frmrtq_postproc(x, val) viddec_fw_bitfields_insert((x)->flags, val, 5, 0x7)
328 
329             #define viddec_fw_vc1_get_interlace(x) viddec_fw_bitfields_extract((x)->flags, 4, 0x1)
330             #define viddec_fw_vc1_set_interlace(x, val) viddec_fw_bitfields_insert((x)->flags, val, 4, 0x1)
331 
332             #define viddec_fw_vc1_get_tfcntrflag(x) viddec_fw_bitfields_extract((x)->flags, 3, 0x1)
333             #define viddec_fw_vc1_set_tfcntrflag(x, val) viddec_fw_bitfields_insert((x)->flags, val, 3, 0x1)
334 
335             #define viddec_fw_vc1_get_finterpflag(x) viddec_fw_bitfields_extract((x)->flags, 2, 0x1)
336             #define viddec_fw_vc1_set_finterpflag(x, val) viddec_fw_bitfields_insert((x)->flags, val, 2, 0x1)
337 
338             #define viddec_fw_vc1_get_psf(x) viddec_fw_bitfields_extract((x)->flags, 1, 0x1)
339             #define viddec_fw_vc1_set_psf(x, val) viddec_fw_bitfields_insert((x)->flags, val, 1, 0x1)
340 
341             #define viddec_fw_vc1_get_display_ext(x) viddec_fw_bitfields_extract((x)->flags, 0, 0x1)
342             #define viddec_fw_vc1_set_display_ext(x, val) viddec_fw_bitfields_insert((x)->flags, val, 0, 0x1)
343 
344             uint32_t size;    // profile:2, level:3, colordiff_format:2, pulldown:1, max_coded_width:12, max_coded_height:12
345             uint32_t flags;   // bitrtq_postproc:5, frmrtq_postproc:3, interlace:1, tfcntrflag:1, finterpflag:1, psf:1, display_ext:1
346             uint32_t pad;
347         } vc1_sl; // vc1 item of type VIDDEC_WORKLOAD_SEQUENCE_INFO
348         struct
349         {
350             // This item is populated when display_ext flag is set in the sequence layer
351             // therefore, no need to provide this flag
352             #define viddec_fw_vc1_get_disp_horiz_size(x) viddec_fw_bitfields_extract((x)->size, 18, 0x3FFF)
353             #define viddec_fw_vc1_set_disp_horiz_size(x, val) viddec_fw_bitfields_insert((x)->size, val, 18, 0x3FFF)
354 
355             #define viddec_fw_vc1_get_disp_vert_size(x) viddec_fw_bitfields_extract((x)->size, 4, 0x3FFF)
356             #define viddec_fw_vc1_set_disp_vert_size(x, val) viddec_fw_bitfields_insert((x)->size, val, 4, 0x3FFF)
357 
358             #define viddec_fw_vc1_get_disp_aspect_ratio_flag(x) viddec_fw_bitfields_extract((x)->size, 3, 0x1)
359             #define viddec_fw_vc1_set_disp_aspect_ratio_flag(x, val) viddec_fw_bitfields_insert((x)->size, val, 3, 0x1)
360 
361             #define viddec_fw_vc1_get_disp_color_format_flag(x) viddec_fw_bitfields_extract((x)->size, 2, 0x1)
362             #define viddec_fw_vc1_set_disp_color_format_flag(x, val) viddec_fw_bitfields_insert((x)->size, val, 2, 0x1)
363 
364             #define viddec_fw_vc1_get_disp_framerate_flag(x) viddec_fw_bitfields_extract((x)->size, 1, 0x1)
365             #define viddec_fw_vc1_set_disp_framerate_flag(x, val) viddec_fw_bitfields_insert((x)->size, val, 1, 0x1)
366 
367             #define viddec_fw_vc1_get_disp_framerateind(x) viddec_fw_bitfields_extract((x)->size, 0, 0x1)
368             #define viddec_fw_vc1_set_disp_framerateind(x, val) viddec_fw_bitfields_insert((x)->size, val, 0, 0x1)
369 
370             #define viddec_fw_vc1_get_disp_aspect_ratio(x) viddec_fw_bitfields_extract((x)->framerate, 28, 0xF)
371             #define viddec_fw_vc1_set_disp_aspect_ratio(x, val) viddec_fw_bitfields_insert((x)->framerate, val, 28, 0xF)
372 
373             #define viddec_fw_vc1_get_disp_frameratenr(x) viddec_fw_bitfields_extract((x)->framerate, 20, 0xFF)
374             #define viddec_fw_vc1_set_disp_frameratenr(x, val) viddec_fw_bitfields_insert((x)->framerate, val, 20, 0xFF)
375 
376             #define viddec_fw_vc1_get_disp_frameratedr(x) viddec_fw_bitfields_extract((x)->framerate, 16, 0xF)
377             #define viddec_fw_vc1_set_disp_frameratedr(x, val) viddec_fw_bitfields_insert((x)->framerate, val, 16, 0xF)
378 
379             #define viddec_fw_vc1_get_disp_framerateexp(x) viddec_fw_bitfields_extract((x)->framerate, 0, 0xFFFF)
380             #define viddec_fw_vc1_set_disp_framerateexp(x, val) viddec_fw_bitfields_insert((x)->framerate, val, 0, 0xFFFF)
381 
382             #define viddec_fw_vc1_get_disp_aspect_ratio_horiz_size(x) viddec_fw_bitfields_extract((x)->aspectsize, 24, 0xFF)
383             #define viddec_fw_vc1_set_disp_aspect_ratio_horiz_size(x, val) viddec_fw_bitfields_insert((x)->aspectsize, val, 24, 0xFF)
384 
385             #define viddec_fw_vc1_get_disp_aspect_ratio_vert_size(x) viddec_fw_bitfields_extract((x)->aspectsize, 16, 0xFF)
386             #define viddec_fw_vc1_set_disp_aspect_ratio_vert_size(x, val) viddec_fw_bitfields_insert((x)->aspectsize, val, 16, 0xFF)
387 
388             #define viddec_fw_vc1_get_disp_color_prim(x) viddec_fw_bitfields_extract((x)->aspectsize, 8, 0xFF)
389             #define viddec_fw_vc1_set_disp_color_prim(x, val) viddec_fw_bitfields_insert((x)->aspectsize, val, 8, 0xFF)
390 
391             #define viddec_fw_vc1_get_disp_transfer_char(x) viddec_fw_bitfields_extract((x)->aspectsize, 0, 0xFF)
392             #define viddec_fw_vc1_set_disp_transfer_char(x, val) viddec_fw_bitfields_insert((x)->aspectsize, val, 0, 0xFF)
393 
394             uint32_t size; // disp_horiz_size:14, disp_vert_size:14, aspect_ratio_flag:1, color_format_flag:1, framerate_flag:1, framerateind:1
395             uint32_t framerate;  // aspect_ratio:4, frameratenr:8, frameratedr:4, framerateexp:16
396             uint32_t aspectsize; // aspect_ratio_horiz_size:8, aspect_ratio_vert_size:8, color_prim:8, transfer_char:8
397         } vc1_sl_de; // vc1 item of type VIDDEC_WORKLOAD_DISPLAY_INFO
398         struct
399         {
400             #define viddec_fw_vc1_get_rcv_horiz_size(x) viddec_fw_bitfields_extract((x)->size, 16, 0xFFFF)
401             #define viddec_fw_vc1_set_rcv_horiz_size(x, val) viddec_fw_bitfields_insert((x)->size, val, 16, 0xFFFF)
402 
403             #define viddec_fw_vc1_get_rcv_vert_size(x) viddec_fw_bitfields_extract((x)->size, 0, 0xFFFF)
404             #define viddec_fw_vc1_set_rcv_vert_size(x, val) viddec_fw_bitfields_insert((x)->size, val, 0, 0xFFFF)
405 
406             #define viddec_fw_vc1_get_rcv_bitrtq_postproc(x) viddec_fw_bitfields_extract((x)->flags, 16, 0x1F)
407             #define viddec_fw_vc1_set_rcv_bitrtq_postproc(x, val) viddec_fw_bitfields_insert((x)->flags, val, 16, 0x1F)
408 
409             #define viddec_fw_vc1_get_rcv_frmrtq_postproc(x) viddec_fw_bitfields_extract((x)->flags, 13, 0x7)
410             #define viddec_fw_vc1_set_rcv_frmrtq_postproc(x, val) viddec_fw_bitfields_insert((x)->flags, val, 13, 0x7)
411 
412             #define viddec_fw_vc1_get_rcv_profile(x) viddec_fw_bitfields_extract((x)->flags, 9, 0xF)
413             #define viddec_fw_vc1_set_rcv_profile(x, val) viddec_fw_bitfields_insert((x)->flags, val, 9, 0xF)
414 
415             #define viddec_fw_vc1_get_rcv_level(x) viddec_fw_bitfields_extract((x)->flags, 6, 0x7)
416             #define viddec_fw_vc1_set_rcv_level(x, val) viddec_fw_bitfields_insert((x)->flags, val, 6, 0x7)
417 
418             #define viddec_fw_vc1_get_rcv_cbr(x) viddec_fw_bitfields_extract((x)->flags, 5, 0x1)
419             #define viddec_fw_vc1_set_rcv_cbr(x, val) viddec_fw_bitfields_insert((x)->flags, val, 5, 0x1)
420 
421             #define viddec_fw_vc1_get_rcv_rangered(x) viddec_fw_bitfields_extract((x)->flags, 4, 0x1)
422             #define viddec_fw_vc1_set_rcv_rangered(x, val) viddec_fw_bitfields_insert((x)->flags, val, 4, 0x1)
423 
424             #define viddec_fw_vc1_get_rcv_maxbframes(x) viddec_fw_bitfields_extract((x)->flags, 1, 0x7)
425             #define viddec_fw_vc1_set_rcv_maxbframes(x, val) viddec_fw_bitfields_insert((x)->flags, val, 1, 0x7)
426 
427             #define viddec_fw_vc1_get_rcv_finterpflag(x) viddec_fw_bitfields_extract((x)->flags, 0, 0x1)
428             #define viddec_fw_vc1_set_rcv_finterpflag(x, val) viddec_fw_bitfields_insert((x)->flags, val, 0, 0x1)
429 
430             uint32_t size;    // horiz_size:16, vert_size:16
431             uint32_t flags;   // bitrtq_postproc:5, frmrtq_postproc:3, profile:4, level:3, cbr:1, rangered:1, maxbframes:3, finterpflag:1
432             uint32_t pad;
433         } vc1_sh_struct_a_c; // vc1 item of type VIDDEC_WORKLOAD_VC1_SEQ_HDR_STRUCT_A_C
434         struct
435         {
436             #define viddec_fw_vc1_get_ep_size_flag(x) viddec_fw_bitfields_extract((x)->size, 24, 0x1)
437             #define viddec_fw_vc1_set_ep_size_flag(x, val) viddec_fw_bitfields_insert((x)->size, val, 24, 0x1)
438 
439             #define viddec_fw_vc1_get_ep_horiz_size(x) viddec_fw_bitfields_extract((x)->size, 12, 0xFFF)
440             #define viddec_fw_vc1_set_ep_horiz_size(x, val) viddec_fw_bitfields_insert((x)->size, val, 12, 0xFFF)
441 
442             #define viddec_fw_vc1_get_ep_vert_size(x) viddec_fw_bitfields_extract((x)->size, 0, 0xFFF)
443             #define viddec_fw_vc1_set_ep_vert_size(x, val) viddec_fw_bitfields_insert((x)->size, val, 0, 0xFFF)
444 
445             #define viddec_fw_vc1_get_ep_broken_link(x) viddec_fw_bitfields_extract((x)->flags, 10, 0x1)
446             #define viddec_fw_vc1_set_ep_broken_link(x, val) viddec_fw_bitfields_insert((x)->flags, val, 10, 0x1)
447 
448             #define viddec_fw_vc1_get_ep_closed_entry(x) viddec_fw_bitfields_extract((x)->flags, 9, 0x1)
449             #define viddec_fw_vc1_set_ep_closed_entry(x, val) viddec_fw_bitfields_insert((x)->flags, val, 9, 0x1)
450 
451             #define viddec_fw_vc1_get_ep_panscan_flag(x) viddec_fw_bitfields_extract((x)->flags, 8, 0x1)
452             #define viddec_fw_vc1_set_ep_panscan_flag(x, val) viddec_fw_bitfields_insert((x)->flags, val, 8, 0x1)
453 
454             #define viddec_fw_vc1_get_ep_range_mapy_flag(x) viddec_fw_bitfields_extract((x)->flags, 7, 0x1)
455             #define viddec_fw_vc1_set_ep_range_mapy_flag(x, val) viddec_fw_bitfields_insert((x)->flags, val, 7, 0x1)
456 
457             #define viddec_fw_vc1_get_ep_range_mapy(x) viddec_fw_bitfields_extract((x)->flags, 4, 0x7)
458             #define viddec_fw_vc1_set_ep_range_mapy(x, val) viddec_fw_bitfields_insert((x)->flags, val, 4, 0x7)
459 
460             #define viddec_fw_vc1_get_ep_range_mapuv_flag(x) viddec_fw_bitfields_extract((x)->flags, 3, 0x1)
461             #define viddec_fw_vc1_set_ep_range_mapuv_flag(x, val) viddec_fw_bitfields_insert((x)->flags, val, 3, 0x1)
462 
463             #define viddec_fw_vc1_get_ep_range_mapuv(x) viddec_fw_bitfields_extract((x)->flags, 0, 0x7)
464             #define viddec_fw_vc1_set_ep_range_mapuv(x, val) viddec_fw_bitfields_insert((x)->flags, val, 0, 0x7)
465 
466             uint32_t size;    // coded_size_flag:1, coded_width:12, coded_height:12
467             uint32_t flags;   // broken_link:1, closed_entry:1, panscan_flag:1, range_mapy_flag:1, range_mapy:3, range_mapuv_flag:1, range_mapuv:3
468             uint32_t pad;
469         } vc1_ep; // vc1 item of type VIDDEC_WORKLOAD_GOP_INFO
470         struct
471         {
472             /*
473               0-7 bits for profile_idc.
474               8-15 bits for level_idc.
475               16-17 bits for chroma_format_idc.
476               18-22 bits for num_ref_frames.
477               23  for gaps_in_frame_num_value_allowed_flag.
478               24 for frame_mbs_only_flag.
479               25 for frame_cropping_flag.
480               26 for vui_parameters_present_flag.
481              */
482 #define viddec_fw_h264_sps_get_profile_idc(x)  viddec_fw_bitfields_extract( (x)->sps_messages, 0, 0xFF)
483 #define viddec_fw_h264_sps_set_profile_idc(x, val)  viddec_fw_bitfields_insert( (x)->sps_messages, val, 0, 0xFF)
484 #define viddec_fw_h264_sps_get_level_idc(x)  viddec_fw_bitfields_extract( (x)->sps_messages, 8, 0xFF)
485 #define viddec_fw_h264_sps_set_level_idc(x, val)  viddec_fw_bitfields_insert( (x)->sps_messages, val, 8, 0xFF)
486 #define viddec_fw_h264_sps_get_chroma_format_idc(x)  viddec_fw_bitfields_extract( (x)->sps_messages, 16, 0x3)
487 #define viddec_fw_h264_sps_set_chroma_format_idc(x, val)  viddec_fw_bitfields_insert( (x)->sps_messages, val, 16, 0x3)
488 #define viddec_fw_h264_sps_get_num_ref_frames(x)  viddec_fw_bitfields_extract( (x)->sps_messages, 18, 0x1F)
489 #define viddec_fw_h264_sps_set_num_ref_frames(x, val)  viddec_fw_bitfields_insert( (x)->sps_messages, val, 18, 0x1F)
490 #define viddec_fw_h264_sps_get_gaps_in_frame_num_value_allowed_flag(x)  viddec_fw_bitfields_extract( (x)->sps_messages, 23, 0x1)
491 #define viddec_fw_h264_sps_set_gaps_in_frame_num_value_allowed_flag(x, val)  viddec_fw_bitfields_insert( (x)->sps_messages, val, 23, 0x1)
492 #define viddec_fw_h264_sps_get_frame_mbs_only_flag(x)  viddec_fw_bitfields_extract( (x)->sps_messages, 24, 0x1)
493 #define viddec_fw_h264_sps_set_frame_mbs_only_flag(x, val)  viddec_fw_bitfields_insert( (x)->sps_messages, val, 24, 0x1)
494 #define viddec_fw_h264_sps_get_frame_cropping_flag(x)  viddec_fw_bitfields_extract( (x)->sps_messages, 25, 0x1)
495 #define viddec_fw_h264_sps_set_frame_cropping_flag(x, val)  viddec_fw_bitfields_insert( (x)->sps_messages, val, 25, 0x1)
496 #define viddec_fw_h264_sps_get_vui_parameters_present_flag(x)  viddec_fw_bitfields_extract( (x)->sps_messages, 26, 0x1)
497 #define viddec_fw_h264_sps_set_vui_parameters_present_flag(x, val)  viddec_fw_bitfields_insert( (x)->sps_messages, val, 26, 0x1)
498             unsigned int sps_messages;
499             unsigned int pic_width_in_mbs_minus1;
500             unsigned int pic_height_in_map_units_minus1;
501         } h264_sps; // h264 item of type VIDDEC_WORKLOAD_SEQUENCE_INFO
502 
503         struct
504         {
505 #define viddec_fw_h264_cropping_get_left(x)  viddec_fw_bitfields_extract( (x)->left_right, 16, 0xFFFF)
506 #define viddec_fw_h264_cropping_get_right(x) viddec_fw_bitfields_extract( (x)->left_right, 0, 0xFFFF)
507 #define viddec_fw_h264_cropping_set_left(x, val)  viddec_fw_bitfields_insert( (x)->left_right, val, 16, 0xFFFF)
508 #define viddec_fw_h264_cropping_set_right(x, val) viddec_fw_bitfields_insert( (x)->left_right, val, 0, 0xFFFF)
509             unsigned int left_right; /* Left in upper 16 bits and right in Lower 16 bits */
510 #define viddec_fw_h264_cropping_get_top(x)  viddec_fw_bitfields_extract( (x)->top_bottom, 16, 0xFFFF)
511 #define viddec_fw_h264_cropping_get_bottom(x) viddec_fw_bitfields_extract( (x)->top_bottom, 0, 0xFFFF)
512 #define viddec_fw_h264_cropping_set_top(x, val)  viddec_fw_bitfields_insert( (x)->top_bottom, val, 16, 0xFFFF)
513 #define viddec_fw_h264_cropping_set_bottom(x, val) viddec_fw_bitfields_insert( (x)->top_bottom, val, 0, 0xFFFF)
514             unsigned int top_bottom; /* top in upper 16 bits and bottom in lower 16 bits */
515             unsigned int pad;
516         } h264_cropping; // h264 item of type VIDDEC_WORKLOAD_H264_CROPPING
517 
518         struct
519         {
520             /* 0 bit for aspect_ratio_info_present_flag
521                1 st bit for video_signal_type_present_flag
522                2 nd bit for colour_description_present_flag
523                3 rd bit for timing_info_present_flag
524                4 th bit for nal_hrd_parameters_present_flag
525                5 th bit for vcl_hrd_parameters_present_flag
526                6 th bit for fixed_frame_rate_flag
527                7 th bit for pic_struct_present_flag
528                8 th bit for low_delay_hrd_flag
529                9,10,11 bits for video_format
530             */
531 #define viddec_fw_h264_vui_get_aspect_ratio_info_present_flag(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 0, 0x1)
532 #define viddec_fw_h264_vui_set_aspect_ratio_info_present_flag(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 0, 0x1)
533 #define viddec_fw_h264_vui_get_video_signal_type_present_flag(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 1, 0x1)
534 #define viddec_fw_h264_vui_set_video_signal_type_present_flag(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 1, 0x1)
535 #define viddec_fw_h264_vui_get_colour_description_present_flag(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 2, 0x1)
536 #define viddec_fw_h264_vui_set_colour_description_present_flag(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 2, 0x1)
537 #define viddec_fw_h264_vui_get_timing_info_present_flag(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 3, 0x1)
538 #define viddec_fw_h264_vui_set_timing_info_present_flag(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 3, 0x1)
539 #define viddec_fw_h264_vui_get_nal_hrd_parameters_present_flag(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 4, 0x1)
540 #define viddec_fw_h264_vui_set_nal_hrd_parameters_present_flag(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 4, 0x1)
541 #define viddec_fw_h264_vui_get_vcl_hrd_parameters_present_flag(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 5, 0x1)
542 #define viddec_fw_h264_vui_set_vcl_hrd_parameters_present_flag(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 5, 0x1)
543 #define viddec_fw_h264_vui_get_fixed_frame_rate_flag(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 6, 0x1)
544 #define viddec_fw_h264_vui_set_fixed_frame_rate_flag(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 6, 0x1)
545 #define viddec_fw_h264_vui_get_pic_struct_present_flag(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 7, 0x1)
546 #define viddec_fw_h264_vui_set_pic_struct_present_flag(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 7, 0x1)
547 #define viddec_fw_h264_vui_get_low_delay_hrd_flag(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 8, 0x1)
548 #define viddec_fw_h264_vui_set_low_delay_hrd_flag(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 8, 0x1)
549 #define viddec_fw_h264_vui_get_video_format(x)  viddec_fw_bitfields_extract( (x)->vui_flags_and_format, 9, 0x7)
550 #define viddec_fw_h264_vui_set_video_format(x, val)  viddec_fw_bitfields_insert( (x)->vui_flags_and_format, val, 9, 0x7)
551             unsigned int vui_flags_and_format;
552 
553 #define viddec_fw_h264_vui_get_aspect_ratio_idc(x)  viddec_fw_bitfields_extract( (x)->aspc_color_transfer, 0, 0xFF)
554 #define viddec_fw_h264_vui_set_aspect_ratio_idc(x, val)  viddec_fw_bitfields_insert( (x)->aspc_color_transfer, val, 0, 0xFF)
555 #define viddec_fw_h264_vui_get_colour_primaries(x)  viddec_fw_bitfields_extract( (x)->aspc_color_transfer, 8, 0xFF)
556 #define viddec_fw_h264_vui_set_colour_primaries(x, val)  viddec_fw_bitfields_insert( (x)->aspc_color_transfer, val, 8, 0xFF)
557 #define viddec_fw_h264_vui_get_transfer_characteristics(x)  viddec_fw_bitfields_extract( (x)->aspc_color_transfer, 16, 0xFF)
558 #define viddec_fw_h264_vui_set_transfer_characteristics(x, val)  viddec_fw_bitfields_insert( (x)->aspc_color_transfer, val, 16, 0xFF)
559             /* lower 8 bits for aspect_ratio, next 8bits for color primaries and next 8 bits for transfer characteristics */
560             unsigned int aspc_color_transfer;
561 
562 #define viddec_fw_h264_vui_get_sar_width(x)  viddec_fw_bitfields_extract( (x)->sar_width_height, 16, 0xFFFF)
563 #define viddec_fw_h264_vui_get_sar_height(x) viddec_fw_bitfields_extract( (x)->sar_width_height, 0, 0xFFFF)
564 #define viddec_fw_h264_vui_set_sar_width(x, val)  viddec_fw_bitfields_insert( (x)->sar_width_height, val, 16, 0xFFFF)
565 #define viddec_fw_h264_vui_set_sar_height(x, val) viddec_fw_bitfields_insert( (x)->sar_width_height, val, 0, 0xFFFF)
566             unsigned int sar_width_height; /* Lower 16 for height upper 16 for width */
567         } h264_vui; // h264 item of type VIDDEC_WORKLOAD_DISPLAY_INFO
568         struct
569         {
570 #define viddec_fw_h264_vui_get_num_units_in_tick_flag(x)  viddec_fw_bitfields_extract( (x)->num_units_in_tick, 0, 0xFFFFFFFF)
571 #define viddec_fw_h264_vui_set_num_units_in_tick_flag(x, val)  viddec_fw_bitfields_insert( (x)->num_units_in_tick, val, 0, 0xFFFFFFFF)
572 #define viddec_fw_h264_vui_get_time_scale_flag(x)  viddec_fw_bitfields_extract( (x)->time_scale, 0, 0xFFFFFFFF)
573 #define viddec_fw_h264_vui_set_time_scale_flag(x, val)  viddec_fw_bitfields_insert( (x)->time_scale, val, 0, 0xFFFFFFFF)
574             unsigned int num_units_in_tick;
575             unsigned int time_scale;
576             unsigned int pad1;
577         } h264_vui_time_info; // VIDDEC_WORKLOAD_H264_VUI_TIMING_INFO
578         struct
579         {
580             unsigned int pic_struct; /* 4 bit length */
581             unsigned int pad1;
582             unsigned int pad2;
583         } h264_sei_pic_timing; // h264 item of type VIDDEC_WORKLOAD_SEI_PIC_TIMING
584         struct
585         {
586             unsigned int pan_scan_rect_id;
587 
588 #define viddec_fw_h264_sei_pan_scan_get_cancel_flag(x)  viddec_fw_bitfields_extract( (x)->pan_scan_cancel_and_cnt, 0, 0x1)
589 #define viddec_fw_h264_sei_pan_scan_get_cnt_minus1(x) viddec_fw_bitfields_extract( (x)->pan_scan_cancel_and_cnt, 1, 0x3)
590 #define viddec_fw_h264_sei_pan_scan_set_cancel_flag(x, val)  viddec_fw_bitfields_insert( (x)->pan_scan_cancel_and_cnt, val, 0, 0x1)
591 #define viddec_fw_h264_sei_pan_scan_set_cnt_minus1(x, val) viddec_fw_bitfields_insert( (x)->pan_scan_cancel_and_cnt, val, 1, 0x3)
592             unsigned int pan_scan_cancel_and_cnt; /* 0 bit for cancel flag and 2 bits for cnt_minus1 */
593             unsigned int pan_scan_rect_repetition_period;
594         } h264_sei_pan_scan; // h264 item of type VIDDEC_WORKLOAD_H264_PAN_SCAN
595 
596         struct
597         {
598 
599 #define viddec_fw_h264_pan_scan_get_left(x)  viddec_fw_bitfields_extract( (x)->left_right, 16, 0xFFFF)
600 #define viddec_fw_h264_pan_scan_get_right(x) viddec_fw_bitfields_extract( (x)->left_right, 0, 0xFFFF)
601 #define viddec_fw_h264_pan_scan_set_left(x, val)  viddec_fw_bitfields_insert( (x)->left_right, val, 16, 0xFFFF)
602 #define viddec_fw_h264_pan_scan_set_right(x, val) viddec_fw_bitfields_insert( (x)->left_right, val, 0, 0xFFFF)
603             unsigned int left_right; /* Left in upper 16 bits and right in Lower 16 bits */
604 
605 #define viddec_fw_h264_pan_scan_get_top(x)  viddec_fw_bitfields_extract( (x)->top_bottom, 16, 0xFFFF)
606 #define viddec_fw_h264_pan_scan_get_bottom(x) viddec_fw_bitfields_extract( (x)->top_bottom, 0, 0xFFFF)
607 #define viddec_fw_h264_pan_scan_set_top(x, val)  viddec_fw_bitfields_insert( (x)->top_bottom, val, 16, 0xFFFF)
608 #define viddec_fw_h264_pan_scan_set_bottom(x, val) viddec_fw_bitfields_insert( (x)->top_bottom, val, 0, 0xFFFF)
609             unsigned int top_bottom; /* top in upper 16 bits and bottom in lower 16 bits */
610 
611             unsigned int pad;
612         } h264_pan_scan_rect; // h264 item of type VIDDEC_WORKLOAD_SEI_PAN_SCAN_RECT
613         struct
614         {
615             unsigned int recovery_frame_cnt;
616 #define viddec_fw_h264_h264_sei_recovery_get_exact_match_flag(x)  viddec_fw_bitfields_extract( (x)->broken_and_exctmatch_flags, 0, 0x1)
617 #define viddec_fw_h264_h264_sei_recovery_get_broken_link_flag(x) viddec_fw_bitfields_extract( (x)->broken_and_exctmatch_flags, 1, 0x1)
618 #define viddec_fw_h264_h264_sei_recovery_set_exact_match_flag(x, val)  viddec_fw_bitfields_insert( (x)->broken_and_exctmatch_flags, val, 0, 0x1)
619 #define viddec_fw_h264_h264_sei_recovery_set_broken_link_flag(x, val) viddec_fw_bitfields_insert( (x)->broken_and_exctmatch_flags, val, 1, 0x1)
620             unsigned int broken_and_exctmatch_flags; /* 0 bit for exact match, 1 bit for brokenlink */
621 
622             unsigned int changing_slice_group_idc; /* 2bit value for slice_group idc */
623 
624         } h264_sei_recovery_point; // h264 item of type VIDDEC_WORKLOAD_SEI_RECOVERY_POINT
625 
626         struct
627         {
628             // Visual Sequence (From LSB):
629             //   - profile_and_level_indication - 8 bits
630             #define viddec_fw_mp4_vs_get_profile_and_level_indication(x)      viddec_fw_bitfields_extract( (x)->vs_item,  0, 0xFF)
631             #define viddec_fw_mp4_vs_set_profile_and_level_indication(x, val) viddec_fw_bitfields_insert ( (x)->vs_item, val,  0, 0xFF)
632             unsigned int vs_item;
633 
634             // Visual Object - video_signal_type
635             //   - video_signal_type - 1b
636             //   - video_format - 3b
637             //   - video_range - 1b
638             //   - colour_description - 1b
639             #define viddec_fw_mp4_vo_get_colour_description(x)      viddec_fw_bitfields_extract( (x)->video_signal_type, 5, 0x1)
640             #define viddec_fw_mp4_vo_set_colour_description(x, val) viddec_fw_bitfields_insert ( (x)->video_signal_type, val, 5, 0x1)
641             #define viddec_fw_mp4_vo_get_video_range(x)      viddec_fw_bitfields_extract( (x)->video_signal_type, 4, 0x1)
642             #define viddec_fw_mp4_vo_set_video_range(x, val) viddec_fw_bitfields_insert ( (x)->video_signal_type, val, 4, 0x1)
643             #define viddec_fw_mp4_vo_get_video_format(x)      viddec_fw_bitfields_extract( (x)->video_signal_type,  1, 0x7)
644             #define viddec_fw_mp4_vo_set_video_format(x, val) viddec_fw_bitfields_insert ( (x)->video_signal_type, val,  1, 0x7)
645             #define viddec_fw_mp4_vo_get_video_signal_type(x)      viddec_fw_bitfields_extract( (x)->video_signal_type,  0, 0x1)
646             #define viddec_fw_mp4_vo_set_video_signal_type(x, val) viddec_fw_bitfields_insert ( (x)->video_signal_type, val,  0, 0x1)
647             unsigned int video_signal_type;
648 
649             // Visual Object - video_signal_type
650             //   - color_primaries - 8 bits
651             //   - transfer_characteristics - 8 bits
652             #define viddec_fw_mp4_vo_get_transfer_char(x)      viddec_fw_bitfields_extract( (x)->color_desc,  8, 0xFF)
653             #define viddec_fw_mp4_vo_set_transfer_char(x, val) viddec_fw_bitfields_insert ( (x)->color_desc, val,  8, 0xFF)
654             #define viddec_fw_mp4_vo_get_color_primaries(x)      viddec_fw_bitfields_extract( (x)->color_desc,  0, 0xFF)
655             #define viddec_fw_mp4_vo_set_color_primaries(x, val) viddec_fw_bitfields_insert ( (x)->color_desc, val,  0, 0xFF)
656             unsigned int color_desc;
657         } mp4_vs_vo; // mp4 item of type VIDDEC_WORKLOAD_MPEG4_VISUAL_SEQ_OBJ
658 
659         struct
660         {
661             // Video Object Layer(From LSB):
662             //   - aspect_ratio_info - 4b
663             //   - par_width - 8b
664             //   - par_height - 8b
665             //   - vol_control_param - 1b
666             //   - chroma_format - 2b
667             //   - interlaced - 1b
668             //   - fixed_vop_rate - 1b
669             #define viddec_fw_mp4_vol_get_fixed_vop_rate(x)      viddec_fw_bitfields_extract( (x)->vol_aspect_ratio, 24, 0x1)
670             #define viddec_fw_mp4_vol_set_fixed_vop_rate(x, val) viddec_fw_bitfields_insert ( (x)->vol_aspect_ratio, val, 24, 0x1)
671             #define viddec_fw_mp4_vol_get_interlaced(x)      viddec_fw_bitfields_extract( (x)->vol_aspect_ratio, 23, 0x1)
672             #define viddec_fw_mp4_vol_set_interlaced(x, val) viddec_fw_bitfields_insert ( (x)->vol_aspect_ratio, val, 23, 0x1)
673             #define viddec_fw_mp4_vol_get_chroma_format(x)      viddec_fw_bitfields_extract( (x)->vol_aspect_ratio, 21, 0x3)
674             #define viddec_fw_mp4_vol_set_chroma_format(x, val) viddec_fw_bitfields_insert ( (x)->vol_aspect_ratio, val, 21, 0x3)
675             #define viddec_fw_mp4_vol_get_control_param(x)      viddec_fw_bitfields_extract( (x)->vol_aspect_ratio, 20, 0x1)
676             #define viddec_fw_mp4_vol_set_control_param(x, val) viddec_fw_bitfields_insert ( (x)->vol_aspect_ratio, val, 20, 0x1)
677             #define viddec_fw_mp4_vol_get_par_height(x)      viddec_fw_bitfields_extract( (x)->vol_aspect_ratio, 12, 0xFF)
678             #define viddec_fw_mp4_vol_set_par_height(x, val) viddec_fw_bitfields_insert ( (x)->vol_aspect_ratio, val, 12, 0xFF)
679             #define viddec_fw_mp4_vol_get_par_width(x)      viddec_fw_bitfields_extract( (x)->vol_aspect_ratio, 4, 0xFF)
680             #define viddec_fw_mp4_vol_set_par_width(x, val) viddec_fw_bitfields_insert ( (x)->vol_aspect_ratio, val, 4, 0xFF)
681             #define viddec_fw_mp4_vol_get_aspect_ratio_info(x)      viddec_fw_bitfields_extract( (x)->vol_aspect_ratio, 0, 0xF)
682             #define viddec_fw_mp4_vol_set_aspect_ratio_info(x, val) viddec_fw_bitfields_insert ( (x)->vol_aspect_ratio, val, 0, 0xF)
683             unsigned int vol_aspect_ratio;
684 
685             // Video Object Layer(From LSB):
686             //   - vbv_parameters - 1b
687             //   - bit_rate - 30b
688             #define viddec_fw_mp4_vol_get_bit_rate(x)      viddec_fw_bitfields_extract( (x)->vol_bit_rate, 1, 0x3FFFFFFF)
689             #define viddec_fw_mp4_vol_set_bit_rate(x, val) viddec_fw_bitfields_insert ( (x)->vol_bit_rate, val, 1, 0x3FFFFFFF)
690             #define viddec_fw_mp4_vol_get_vbv_param(x)      viddec_fw_bitfields_extract( (x)->vol_bit_rate, 0, 0x1)
691             #define viddec_fw_mp4_vol_set_vbv_param(x, val) viddec_fw_bitfields_insert ( (x)->vol_bit_rate, val, 0, 0x1)
692             unsigned int vol_bit_rate;
693 
694             // Video Object Layer(From LSB):
695             //   - fixed_vop_time_increment - 16b
696             //   - vop_time_increment_resolution - 16b
697             #define viddec_fw_mp4_vol_get_vop_time_increment_resolution(x) viddec_fw_bitfields_extract((x)->vol_frame_rate, 16, 0xFFFF)
698             #define viddec_fw_mp4_vol_set_vop_time_increment_resolution(x, val) viddec_fw_bitfields_insert((x)->vol_frame_rate, val, 16, 0xFFFF)
699             #define viddec_fw_mp4_vol_get_fixed_vop_time_increment(x)      viddec_fw_bitfields_extract((x)->vol_frame_rate, 1, 0xFFFF)
700             #define viddec_fw_mp4_vol_set_fixed_vop_time_increment(x, val) viddec_fw_bitfields_insert((x)->vol_frame_rate, val, 1, 0xFFFF)
701             unsigned int vol_frame_rate;
702         } mp4_vol; // mp4 item of type VIDDEC_WORKLOAD_MPEG4_VIDEO_OBJ
703 
704         struct
705         {
706             // Group of Video Object Planes(From LSB):
707             //   - time_code - 18b
708             //   - closed_gov - 1b
709             //   - broken_link - 1b
710             #define viddec_fw_mp4_gvop_get_broken_link(x)      viddec_fw_bitfields_extract((x)->gvop_info, 19, 0x1)
711             #define viddec_fw_mp4_gvop_set_broken_link(x, val) viddec_fw_bitfields_insert((x)->gvop_info, val, 19, 0x1)
712             #define viddec_fw_mp4_gvop_get_closed_gov(x)      viddec_fw_bitfields_extract((x)->gvop_info, 18, 0x1)
713             #define viddec_fw_mp4_gvop_set_closed_gov(x, val) viddec_fw_bitfields_insert((x)->gvop_info, val, 18, 0x1)
714             #define viddec_fw_mp4_gvop_get_time_code(x)      viddec_fw_bitfields_extract((x)->gvop_info, 0, 0x3FFFF)
715             #define viddec_fw_mp4_gvop_set_time_code(x, val) viddec_fw_bitfields_insert((x)->gvop_info, val, 0, 0x3FFFF)
716             unsigned int gvop_info;
717 
718             unsigned int pad1;
719             unsigned int pad2;
720         } mp4_gvop; // mp4 item of type VIDDEC_WORKLOAD_MPEG4_GRP_VIDEO_OBJ
721 
722         struct
723         {
724             // Group of Video Object Planes(From LSB):
725             //   - source_format - 3b
726             #define viddec_fw_mp4_vpsh_get_source_format(x)      viddec_fw_bitfields_extract((x)->info, 0, 0x7)
727             #define viddec_fw_mp4_vpsh_set_source_format(x, val) viddec_fw_bitfields_insert((x)->info, val, 0, 0x7)
728             unsigned int info;
729 
730             unsigned int pad1;
731             unsigned int pad2;
732         } mp4_vpsh; // mp4 item of type VIDDEC_WORKLOAD_MPEG4_VIDEO_PLANE_SHORT
733 
734         unsigned int    vwi_payload[3];
735     };
736 }viddec_workload_item_t;
737 
738 #endif /* VIDDEC_ITEM_TYPES_H */
739