Home | History | Annotate | Download | only in include
      1 #ifndef VIDDEC_FW_MP4_H
      2 #define VIDDEC_FW_MP4_H
      3 
      4 #include "viddec_fw_workload.h"
      5 
      6 enum viddec_fw_mp4_ref_frame_id
      7 {
      8    VIDDEC_MP4_FRAME_CURRENT = 0,
      9    VIDDEC_MP4_FRAME_PAST = 1,
     10    VIDDEC_MP4_FRAME_FUTURE = 2,
     11    VIDDEC_MP4_FRAME_MAX = 3,
     12 };
     13 
     14 enum mp4_workload_item_type
     15 {
     16    VIDDEC_WORKLOAD_MP4_PAST_FRAME = VIDDEC_WORKLOAD_REF_FRAME_SOURCE_0,
     17    VIDDEC_WORKLOAD_MP4_FUTURE_FRAME,
     18    VIDDEC_WORKLOAD_MP4_VOL_INFO = VIDDEC_WORKLOAD_DECODER_SPECIFIC,
     19    VIDDEC_WORKLOAD_MP4_VOP_INFO,
     20    VIDDEC_WORKLOAD_MP4_BVOP_INFO,
     21    VIDDEC_WORKLOAD_MP4_SPRT_TRAJ,
     22    VIDDEC_WORKLOAD_MP4_IQUANT,
     23    VIDDEC_WORKLOAD_MP4_NIQUANT,
     24    VIDDEC_WORKLOAD_MP4_SVH,
     25 };
     26 
     27 enum viddec_fw_mp4_vop_coding_type_t
     28 {
     29     VIDDEC_MP4_VOP_TYPE_I = 0,
     30     VIDDEC_MP4_VOP_TYPE_P,
     31     VIDDEC_MP4_VOP_TYPE_B,
     32     VIDDEC_MP4_VOP_TYPE_S
     33 };
     34 
     35 // This structure contains the information extracted from the Video Object Layer.
     36 // This info will be populated in the workload as item type VIDDEC_WORKLOAD_MP4_VOL_INFO, using
     37 // the "vwi_payload" array in viddec_workload_item_t.
     38 // TODO: Add default values in the comments for each item
     39 typedef struct
     40 {
     41     // Flags extracted from the Video Object Layer
     42     // 0:0 - short_video_header
     43     // 1:2 - vol_shape
     44     // 3:3 - interlaced
     45     // 4:4 - obmc_disable
     46     // 5:5 - quarter_sample
     47     // 6:6 - resync_marker_disable
     48     // 7:7 - data_partitioned
     49     // 8:8 - reversible_vlc
     50     #define viddec_fw_mp4_get_reversible_vlc(x)      viddec_fw_bitfields_extract((x)->vol_flags,  8, 0x1)
     51     #define viddec_fw_mp4_set_reversible_vlc(x, val) viddec_fw_bitfields_insert((x)->vol_flags, val, 8, 0x1)
     52     #define viddec_fw_mp4_get_data_partitioned(x)      viddec_fw_bitfields_extract((x)->vol_flags,  7, 0x1)
     53     #define viddec_fw_mp4_set_data_partitioned(x, val) viddec_fw_bitfields_insert((x)->vol_flags, val, 7, 0x1)
     54     #define viddec_fw_mp4_get_resync_marker_disable(x)      viddec_fw_bitfields_extract((x)->vol_flags,  6, 0x1)
     55     #define viddec_fw_mp4_set_resync_marker_disable(x, val) viddec_fw_bitfields_insert((x)->vol_flags, val, 6, 0x1)
     56     #define viddec_fw_mp4_get_quarter_sample(x)      viddec_fw_bitfields_extract((x)->vol_flags,  5, 0x1)
     57     #define viddec_fw_mp4_set_quarter_sample(x, val) viddec_fw_bitfields_insert((x)->vol_flags, val, 5, 0x1)
     58     #define viddec_fw_mp4_get_obmc_disable(x)      viddec_fw_bitfields_extract((x)->vol_flags,  4, 0x1)
     59     #define viddec_fw_mp4_set_obmc_disable(x, val) viddec_fw_bitfields_insert((x)->vol_flags, val, 4, 0x1)
     60     #define viddec_fw_mp4_get_interlaced(x)      viddec_fw_bitfields_extract((x)->vol_flags,  3, 0x1)
     61     #define viddec_fw_mp4_set_interlaced(x, val) viddec_fw_bitfields_insert((x)->vol_flags, val, 3, 0x1)
     62     #define viddec_fw_mp4_get_vol_shape(x)      viddec_fw_bitfields_extract((x)->vol_flags,  1, 0x3)
     63     #define viddec_fw_mp4_set_vol_shape(x, val) viddec_fw_bitfields_insert((x)->vol_flags, val, 1, 0x3)
     64     #define viddec_fw_mp4_get_short_video_header_flag(x)      viddec_fw_bitfields_extract((x)->vol_flags,  0, 0x1)
     65     #define viddec_fw_mp4_set_short_video_header_flag(x, val) viddec_fw_bitfields_insert((x)->vol_flags, val, 0, 0x1)
     66     unsigned int vol_flags;
     67 
     68     // Size extracted from the Video Object Layer
     69     // 0:12 - width
     70     // 13:25 - height
     71     // MFD_MPG4VD_MB_PER_ROW can be calculated as (width+15) >> 4
     72     // MFD_MPG4VD_MB_ROWS can be calculated as (height+15) >> 4
     73     #define viddec_fw_mp4_get_vol_width(x)      viddec_fw_bitfields_extract((x)->vol_size,  13, 0x1FFF)
     74     #define viddec_fw_mp4_set_vol_width(x, val) viddec_fw_bitfields_insert((x)->vol_size, val, 13, 0x1FFF)
     75     #define viddec_fw_mp4_get_vol_height(x)      viddec_fw_bitfields_extract((x)->vol_size,  0, 0x1FFF)
     76     #define viddec_fw_mp4_set_vol_height(x, val) viddec_fw_bitfields_insert((x)->vol_size, val, 0, 0x1FFF)
     77     unsigned int vol_size;
     78 
     79     // Sprite, time increments and quantization details from the Video Object Layer
     80     // 0:15 - vop_time_increment_resolution
     81     // 16:17 - sprite_enable
     82     // 18:23 - sprite_warping_points
     83     // 24:25 - sprite_warping_accuracy
     84     // 26:29 - quant_precision
     85     // 30:30 - quant_type
     86     #define viddec_fw_mp4_get_quant_type(x)      viddec_fw_bitfields_extract((x)->vol_item,  30, 0x1)
     87     #define viddec_fw_mp4_set_quant_type(x, val) viddec_fw_bitfields_insert((x)->vol_item, val, 30, 0x1)
     88     #define viddec_fw_mp4_get_quant_precision(x)      viddec_fw_bitfields_extract((x)->vol_item,  26, 0xF)
     89     #define viddec_fw_mp4_set_quant_precision(x, val) viddec_fw_bitfields_insert((x)->vol_item, val, 26, 0xF)
     90     #define viddec_fw_mp4_get_sprite_warping_accuracy(x)      viddec_fw_bitfields_extract((x)->vol_item,  24, 0x3)
     91     #define viddec_fw_mp4_set_sprite_warping_accuracy(x, val) viddec_fw_bitfields_insert((x)->vol_item, val, 24, 0x3)
     92     #define viddec_fw_mp4_get_sprite_warping_points(x)      viddec_fw_bitfields_extract((x)->vol_item,  18, 0x3F)
     93     #define viddec_fw_mp4_set_sprite_warping_points(x, val) viddec_fw_bitfields_insert((x)->vol_item, val, 18, 0x3F)
     94     #define viddec_fw_mp4_get_sprite_enable(x)      viddec_fw_bitfields_extract((x)->vol_item,  16, 0x3)
     95     #define viddec_fw_mp4_set_sprite_enable(x, val) viddec_fw_bitfields_insert((x)->vol_item, val, 16, 0x3)
     96     #define viddec_fw_mp4_get_vop_time_increment_resolution(x)      viddec_fw_bitfields_extract((x)->vol_item,  0, 0xFFFF)
     97     #define viddec_fw_mp4_set_vop_time_increment_resolution(x, val) viddec_fw_bitfields_insert((x)->vol_item, val, 0, 0xFFFF)
     98     unsigned int vol_item;
     99 
    100 } viddec_fw_mp4_vol_info_t;
    101 
    102 // This structure contains the information extracted from the Video Object Layer.
    103 // This info will be populated in the workload as item type VIDDEC_WORKLOAD_MP4_VOP_INFO, using
    104 // the "vwi_payload" array in viddec_workload_item_t.
    105 // TODO: Add default values in the comments for each item
    106 typedef struct
    107 {
    108     // Frame Info - to populate register MFD_MPG4VD_BSP_FRAME_INFO
    109     // 0:4 - current_frame_id
    110     // 5:5 - current_field_frame
    111     // 6:10 - future_frame_id
    112     // 11:11 - future_field_frame
    113     // 12:16 - past_frame_id
    114     // 17:17 - past_field_frame
    115     #define viddec_fw_mp4_get_past_field_frame(x)      viddec_fw_bitfields_extract((x)->frame_info,  17, 0x1)
    116     #define viddec_fw_mp4_set_past_field_frame(x, val) viddec_fw_bitfields_insert((x)->frame_info, val, 17, 0x1)
    117     #define viddec_fw_mp4_get_past_frame_id(x)         viddec_fw_bitfields_extract((x)->frame_info,  12, 0x1F)
    118     #define viddec_fw_mp4_set_past_frame_id(x, val)    viddec_fw_bitfields_insert((x)->frame_info, val, 12, 0x1F)
    119     #define viddec_fw_mp4_get_future_field_frame(x)      viddec_fw_bitfields_extract((x)->frame_info,  11, 0x1)
    120     #define viddec_fw_mp4_set_future_field_frame(x, val) viddec_fw_bitfields_insert((x)->frame_info, val, 11, 0x1)
    121     #define viddec_fw_mp4_get_future_frame_id(x)         viddec_fw_bitfields_extract((x)->frame_info,  6, 0x1F)
    122     #define viddec_fw_mp4_set_future_frame_id(x, val)    viddec_fw_bitfields_insert((x)->frame_info, val, 6, 0x1F)
    123     #define viddec_fw_mp4_get_current_field_frame(x)      viddec_fw_bitfields_extract((x)->frame_info,  5, 0x1)
    124     #define viddec_fw_mp4_set_current_field_frame(x, val) viddec_fw_bitfields_insert((x)->frame_info, val, 5, 0x1)
    125     #define viddec_fw_mp4_get_current_frame_id(x)         viddec_fw_bitfields_extract((x)->frame_info,  0, 0x1F)
    126     #define viddec_fw_mp4_set_current_frame_id(x, val)    viddec_fw_bitfields_insert((x)->frame_info, val, 0, 0x1F)
    127     unsigned int frame_info;
    128 
    129     // Video Object Plane Info
    130     // 0:1 - vop_coding_type
    131     // 2:2 - vop_rounding_type
    132     // 3:5 - intra_dc_vlc_thr
    133     // 6:6 - top_field_first
    134     // 7:7 - alternate_vertical_scan_flag
    135     // 8:16 - vop_quant
    136     // 17:19 - vop_fcode_forward
    137     // 20:22 - vop_fcode_backward
    138     // 23:31 - quant_scale
    139     #define viddec_fw_mp4_get_vop_quant_scale(x)      viddec_fw_bitfields_extract((x)->vop_data, 23, 0x1FF)
    140     #define viddec_fw_mp4_set_vop_quant_scale(x, val) viddec_fw_bitfields_insert((x)->vop_data, val, 23, 0x1FF)
    141     #define viddec_fw_mp4_get_vop_fcode_backward(x)      viddec_fw_bitfields_extract((x)->vop_data, 20, 0x7)
    142     #define viddec_fw_mp4_set_vop_fcode_backward(x, val) viddec_fw_bitfields_insert((x)->vop_data, val, 20, 0x7)
    143     #define viddec_fw_mp4_get_vop_fcode_forward(x)      viddec_fw_bitfields_extract((x)->vop_data, 17, 0x7)
    144     #define viddec_fw_mp4_set_vop_fcode_forward(x, val) viddec_fw_bitfields_insert((x)->vop_data, val, 17, 0x7)
    145     #define viddec_fw_mp4_get_vop_quant(x)      viddec_fw_bitfields_extract((x)->vop_data, 8, 0x1FF)
    146     #define viddec_fw_mp4_set_vop_quant(x, val) viddec_fw_bitfields_insert((x)->vop_data, val, 8, 0x1FF)
    147     #define viddec_fw_mp4_get_alternate_vertical_scan_flag(x)      viddec_fw_bitfields_extract((x)->vop_data, 7, 0x1)
    148     #define viddec_fw_mp4_set_alternate_vertical_scan_flag(x, val) viddec_fw_bitfields_insert((x)->vop_data, val, 7, 0x1)
    149     #define viddec_fw_mp4_get_top_field_first(x)      viddec_fw_bitfields_extract((x)->vop_data, 6, 0x1)
    150     #define viddec_fw_mp4_set_top_field_first(x, val) viddec_fw_bitfields_insert((x)->vop_data, val, 6, 0x1)
    151     #define viddec_fw_mp4_get_intra_dc_vlc_thr(x)      viddec_fw_bitfields_extract((x)->vop_data, 3, 0x7)
    152     #define viddec_fw_mp4_set_intra_dc_vlc_thr(x, val) viddec_fw_bitfields_insert((x)->vop_data, val, 3, 0x7)
    153     #define viddec_fw_mp4_get_vop_rounding_type(x)      viddec_fw_bitfields_extract((x)->vop_data, 2, 0x1)
    154     #define viddec_fw_mp4_set_vop_rounding_type(x, val) viddec_fw_bitfields_insert((x)->vop_data, val, 2, 0x1)
    155     #define viddec_fw_mp4_get_vop_coding_type(x)      viddec_fw_bitfields_extract((x)->vop_data, 0, 0x3)
    156     #define viddec_fw_mp4_set_vop_coding_type(x, val) viddec_fw_bitfields_insert((x)->vop_data, val, 0, 0x3)
    157     unsigned int vop_data;
    158 
    159     // No of bits used in first byte of MB data
    160     unsigned int bit_offset;
    161 
    162 } viddec_fw_mp4_vop_info_t;
    163 
    164 // This structure contains the information extracted from the Video Object Layer.
    165 // This info will be populated in the workload as item type VIDDEC_WORKLOAD_MP4_BVOP_INFO, using
    166 // the "vwi_payload" array in viddec_workload_item_t.
    167 // TODO: Add default values in the comments for each item
    168 typedef struct
    169 {
    170     // Frame period = T(first B-VOP after VOL) - T(past reference of first B-VOP after VOL)
    171     unsigned int Tframe;
    172 
    173     // TRD is the difference in temporal reference of the temporally next reference VOP with
    174     // temporally previous reference VOP, assuming B-VOPs or skipped VOPs in between.
    175     unsigned int TRD;
    176 
    177     // TRB is the difference in temporal reference of the B-VOP and the previous reference VOP.
    178     unsigned int TRB;
    179 
    180 } viddec_fw_mp4_bvop_info_t;
    181 
    182 // This structure contains the information extracted from the sprite trajectory.
    183 // This info will be populated in the workload as item type VIDDEC_WORKLOAD_MP4_SPRT_TRAJ,
    184 // using the fields vwi_payload in viddec_workload_item_t.
    185 // TODO: Add default values in the comments for each item
    186 typedef struct
    187 {
    188     // Sprite Trajectory can have dmv_codes for each warping point.
    189     // 0:13 - warping_mv_code_dv
    190     // 14:27 - warping_mv_code_du
    191     // 28:31 - warping_point_index - identifies which warping point the warping code refers to.
    192     // The default value for index is 0xF which should be treated as invalid.
    193     #define viddec_fw_mp4_get_warping_point_index(x)      viddec_fw_bitfields_extract((x), 28, 0xF)
    194     #define viddec_fw_mp4_set_warping_point_index(x, val) viddec_fw_bitfields_insert((x), val, 28, 0xF)
    195     #define viddec_fw_mp4_get_warping_mv_code_du(x)      viddec_fw_bitfields_extract((x), 14, 0x3FFF)
    196     #define viddec_fw_mp4_set_warping_mv_code_du(x, val) viddec_fw_bitfields_insert((x), val, 14, 0x3FFF)
    197     #define viddec_fw_mp4_get_warping_mv_code_dv(x)      viddec_fw_bitfields_extract((x), 0, 0x3FFF)
    198     #define viddec_fw_mp4_set_warping_mv_code_dv(x, val) viddec_fw_bitfields_insert((x), val, 0, 0x3FFF)
    199     unsigned int warping_mv_code[3];
    200 } viddec_fw_mp4_sprite_trajectory_t;
    201 
    202 // IQUANT entries will be populated in the workload using items of type VIDDEC_WORKLOAD_MP4_IQUANT and the
    203 // vwi_payload array. The entries will be in the order in which they need to be programmed in the registers.
    204 // There is no need for a separate structure for these values.
    205 
    206 // This structure contains the information extracted from the Video Plane with Short Header.
    207 // This info will be populated in the workload as item type VIDDEC_WORKLOAD_MP4_SVH, using
    208 // the "vwi_payload" array in viddec_workload_item_t.
    209 // TODO: Add default values in the comments for each item
    210 typedef struct
    211 {
    212     // Video Plane with Short Header
    213     // 0:7 - temporal_reference
    214     // 8:19 - num_macroblocks_in_gob
    215     // 20:24 - num_gobs_in_vop
    216     // 25:27 - num_rows_in_gob
    217     #define viddec_fw_mp4_get_num_rows_in_gob(x)      viddec_fw_bitfields_extract((x)->svh_data, 25, 0x7)
    218     #define viddec_fw_mp4_set_num_rows_in_gob(x, val) viddec_fw_bitfields_insert((x)->svh_data, val, 25, 0x7)
    219     #define viddec_fw_mp4_get_num_gobs_in_vop(x)      viddec_fw_bitfields_extract((x)->svh_data, 20, 0x1F)
    220     #define viddec_fw_mp4_set_num_gobs_in_vop(x, val) viddec_fw_bitfields_insert((x)->svh_data, val, 20, 0x1F)
    221     #define viddec_fw_mp4_get_num_macroblocks_in_gob(x)      viddec_fw_bitfields_extract((x)->svh_data, 8, 0xFFF)
    222     #define viddec_fw_mp4_set_num_macroblocks_in_gob(x, val) viddec_fw_bitfields_insert((x)->svh_data, val, 8, 0xFFF)
    223     #define viddec_fw_mp4_get_temporal_reference(x)      viddec_fw_bitfields_extract((x)->svh_data, 0, 0xFF)
    224     #define viddec_fw_mp4_set_temporal_reference(x, val) viddec_fw_bitfields_insert((x)->svh_data, val, 0, 0xFF)
    225     unsigned int svh_data;
    226 
    227     unsigned int pad1;
    228     unsigned int pad2;
    229 } viddec_fw_mp4_svh_t;
    230 
    231 #endif
    232