1 /************************************************************************** 2 * 3 * Copyright 2013 Advanced Micro Devices, Inc. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28 #ifndef VID_DEC_COMMON_H 29 #define VID_DEC_COMMON_H 30 31 #include "util/list.h" 32 #include "util/vl_rbsp.h" 33 34 #include "vl/vl_compositor.h" 35 #include "vl/vl_zscan.h" 36 37 #include "bellagio/vid_dec_av1.h" 38 39 #include <OMX_Core.h> 40 #include <OMX_Types.h> 41 42 #if ENABLE_ST_OMX_BELLAGIO 43 44 #include <bellagio/st_static_component_loader.h> 45 #include <bellagio/omx_base_filter.h> 46 #include <bellagio/omx_base_video_port.h> 47 48 DERIVEDCLASS(vid_dec_PrivateType, omx_base_filter_PrivateType) 49 #define vid_dec_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \ 50 enum pipe_video_profile profile; \ 51 struct vl_screen *screen; \ 52 struct pipe_context *pipe; \ 53 struct pipe_video_codec *codec; \ 54 void (*Decode)(vid_dec_PrivateType *priv, struct vl_vlc *vlc, unsigned min_bits_left); \ 55 void (*EndFrame)(vid_dec_PrivateType *priv); \ 56 struct pipe_video_buffer *(*Flush)(vid_dec_PrivateType *priv, OMX_TICKS *timestamp); \ 57 struct pipe_video_buffer *target, *shadow; \ 58 union { \ 59 struct { \ 60 uint8_t intra_matrix[64]; \ 61 uint8_t non_intra_matrix[64]; \ 62 } mpeg12; \ 63 struct { \ 64 unsigned nal_ref_idc; \ 65 bool IdrPicFlag; \ 66 unsigned idr_pic_id; \ 67 unsigned pic_order_cnt_lsb; \ 68 unsigned pic_order_cnt_msb; \ 69 unsigned delta_pic_order_cnt_bottom; \ 70 unsigned delta_pic_order_cnt[2]; \ 71 unsigned prevFrameNumOffset; \ 72 struct pipe_h264_sps sps[32]; \ 73 struct pipe_h264_pps pps[256]; \ 74 struct list_head dpb_list; \ 75 unsigned dpb_num; \ 76 } h264; \ 77 struct { \ 78 unsigned temporal_id; \ 79 unsigned level_idc; \ 80 unsigned pic_width_in_luma_samples; \ 81 unsigned pic_height_in_luma_samples; \ 82 bool IdrPicFlag; \ 83 int slice_prev_poc; \ 84 void *ref_pic_set_list; \ 85 void *rps; \ 86 struct pipe_h265_sps sps[16]; \ 87 struct pipe_h265_pps pps[64]; \ 88 struct list_head dpb_list; \ 89 unsigned dpb_num; \ 90 } h265; \ 91 struct dec_av1 av1; \ 92 } codec_data; \ 93 union { \ 94 struct pipe_picture_desc base; \ 95 struct pipe_mpeg12_picture_desc mpeg12; \ 96 struct pipe_h264_picture_desc h264; \ 97 struct pipe_h265_picture_desc h265; \ 98 struct pipe_av1_picture_desc av1; \ 99 } picture; \ 100 unsigned num_in_buffers; \ 101 OMX_BUFFERHEADERTYPE *in_buffers[2]; \ 102 const void *inputs[2]; \ 103 unsigned sizes[2]; \ 104 OMX_TICKS timestamps[2]; \ 105 OMX_TICKS timestamp; \ 106 bool first_buf_in_frame; \ 107 bool frame_finished; \ 108 bool frame_started; \ 109 unsigned bytes_left; \ 110 const void *slice; \ 111 bool disable_tunnel; \ 112 struct vl_compositor compositor; \ 113 struct vl_compositor_state cstate; 114 ENDCLASS(vid_dec_PrivateType) 115 116 #else 117 118 #include <tizprc_decls.h> 119 #include <tizport_decls.h> 120 121 #include "util/list.h" 122 #include "util/u_hash_table.h" 123 124 #include "pipe/p_video_state.h" 125 126 typedef struct h264d_prc_class h264d_prc_class_t; 127 struct h264d_prc_class 128 { 129 /* Class */ 130 const tiz_prc_class_t _; 131 /* NOTE: Class methods might be added in the future */ 132 }; 133 134 typedef struct h264d_stream_info h264d_stream_info_t; 135 struct h264d_stream_info 136 { 137 unsigned int width; 138 unsigned int height; 139 }; 140 141 typedef struct h264d_prc vid_dec_PrivateType; 142 struct h264d_prc 143 { 144 /* Object */ 145 const tiz_prc_t _; 146 OMX_BUFFERHEADERTYPE *in_buffers[2]; 147 OMX_BUFFERHEADERTYPE *p_inhdr_; 148 OMX_BUFFERHEADERTYPE *p_outhdr_; 149 OMX_PARAM_PORTDEFINITIONTYPE out_port_def_; 150 const void *inputs[2]; 151 unsigned sizes[2]; 152 OMX_TICKS timestamps[2]; 153 OMX_TICKS timestamp; 154 bool eos_; 155 bool in_port_disabled_; 156 bool out_port_disabled_; 157 struct vl_screen *screen; 158 struct pipe_context *pipe; 159 struct pipe_video_codec *codec; 160 struct pipe_video_buffer *target; 161 enum pipe_video_profile profile; 162 struct hash_table *video_buffer_map; 163 union { 164 struct { 165 unsigned nal_ref_idc; 166 bool IdrPicFlag; 167 unsigned idr_pic_id; 168 unsigned pic_order_cnt_lsb; 169 unsigned pic_order_cnt_msb; 170 unsigned delta_pic_order_cnt_bottom; 171 unsigned delta_pic_order_cnt[2]; 172 unsigned prevFrameNumOffset; 173 struct pipe_h264_sps sps[32]; 174 struct pipe_h264_pps pps[256]; 175 struct list_head dpb_list; 176 unsigned dpb_num; 177 } h264; 178 } codec_data; 179 union { 180 struct pipe_picture_desc base; 181 struct pipe_h264_picture_desc h264; 182 } picture; 183 h264d_stream_info_t stream_info; 184 unsigned num_in_buffers; 185 bool first_buf_in_frame; 186 bool frame_finished; 187 bool frame_started; 188 unsigned bytes_left; 189 const void *slice; 190 bool disable_tunnel; 191 struct vl_compositor compositor; 192 struct vl_compositor_state cstate; 193 bool use_eglimage; 194 }; 195 196 #endif 197 198 void vid_dec_NeedTarget(vid_dec_PrivateType* priv); 199 void vid_dec_FillOutput(vid_dec_PrivateType* priv, struct pipe_video_buffer* buf, 200 OMX_BUFFERHEADERTYPE* output); 201 #endif 202