• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
33 #include "vl/vl_compositor.h"
34 #include "vl/vl_rbsp.h"
35 #include "vl/vl_zscan.h"
36 
37 #include <OMX_Core.h>
38 #include <OMX_Types.h>
39 
40 #if ENABLE_ST_OMX_BELLAGIO
41 
42 #include <bellagio/st_static_component_loader.h>
43 #include <bellagio/omx_base_filter.h>
44 #include <bellagio/omx_base_video_port.h>
45 
46 DERIVEDCLASS(vid_dec_PrivateType, omx_base_filter_PrivateType)
47 #define vid_dec_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \
48    enum pipe_video_profile profile; \
49    struct vl_screen *screen; \
50    struct pipe_context *pipe; \
51    struct pipe_video_codec *codec; \
52    void (*Decode)(vid_dec_PrivateType *priv, struct vl_vlc *vlc, unsigned min_bits_left); \
53    void (*EndFrame)(vid_dec_PrivateType *priv); \
54    struct pipe_video_buffer *(*Flush)(vid_dec_PrivateType *priv, OMX_TICKS *timestamp); \
55    struct pipe_video_buffer *target, *shadow; \
56    union { \
57       struct { \
58          uint8_t intra_matrix[64]; \
59          uint8_t non_intra_matrix[64]; \
60       } mpeg12; \
61       struct { \
62          unsigned nal_ref_idc; \
63          bool IdrPicFlag; \
64          unsigned idr_pic_id; \
65          unsigned pic_order_cnt_lsb; \
66          unsigned pic_order_cnt_msb; \
67          unsigned delta_pic_order_cnt_bottom; \
68          unsigned delta_pic_order_cnt[2]; \
69          unsigned prevFrameNumOffset; \
70          struct pipe_h264_sps sps[32]; \
71          struct pipe_h264_pps pps[256]; \
72          struct list_head dpb_list; \
73          unsigned dpb_num; \
74       } h264; \
75       struct { \
76          unsigned temporal_id; \
77          unsigned level_idc; \
78          unsigned pic_width_in_luma_samples; \
79          unsigned pic_height_in_luma_samples; \
80          bool IdrPicFlag; \
81          int slice_prev_poc; \
82          void *ref_pic_set_list; \
83          void *rps; \
84          struct pipe_h265_sps sps[16]; \
85          struct pipe_h265_pps pps[64]; \
86          struct list_head dpb_list; \
87          unsigned dpb_num; \
88       } h265; \
89    } codec_data; \
90    union { \
91       struct pipe_picture_desc base; \
92       struct pipe_mpeg12_picture_desc mpeg12; \
93       struct pipe_h264_picture_desc h264; \
94       struct pipe_h265_picture_desc h265; \
95    } picture; \
96    unsigned num_in_buffers; \
97    OMX_BUFFERHEADERTYPE *in_buffers[2]; \
98    const void *inputs[2]; \
99    unsigned sizes[2]; \
100    OMX_TICKS timestamps[2]; \
101    OMX_TICKS timestamp; \
102    bool first_buf_in_frame; \
103    bool frame_finished; \
104    bool frame_started; \
105    unsigned bytes_left; \
106    const void *slice; \
107    bool disable_tunnel; \
108    struct vl_compositor compositor; \
109    struct vl_compositor_state cstate;
110 ENDCLASS(vid_dec_PrivateType)
111 
112 #else
113 
114 #include <tizprc_decls.h>
115 #include <tizport_decls.h>
116 
117 #include "util/list.h"
118 #include "util/u_hash_table.h"
119 
120 #include "pipe/p_video_state.h"
121 
122 typedef struct h264d_prc_class h264d_prc_class_t;
123 struct h264d_prc_class
124 {
125    /* Class */
126    const tiz_prc_class_t _;
127    /* NOTE: Class methods might be added in the future */
128 };
129 
130 typedef struct h264d_stream_info h264d_stream_info_t;
131 struct h264d_stream_info
132 {
133    unsigned int width;
134    unsigned int height;
135 };
136 
137 typedef struct h264d_prc vid_dec_PrivateType;
138 struct h264d_prc
139 {
140    /* Object */
141    const tiz_prc_t _;
142    OMX_BUFFERHEADERTYPE *in_buffers[2];
143    OMX_BUFFERHEADERTYPE *p_inhdr_;
144    OMX_BUFFERHEADERTYPE *p_outhdr_;
145    OMX_PARAM_PORTDEFINITIONTYPE out_port_def_;
146    const void *inputs[2];
147    unsigned sizes[2];
148    OMX_TICKS timestamps[2];
149    OMX_TICKS timestamp;
150    bool eos_;
151    bool in_port_disabled_;
152    bool out_port_disabled_;
153    struct vl_screen *screen;
154    struct pipe_context *pipe;
155    struct pipe_video_codec *codec;
156    struct pipe_video_buffer *target;
157    enum pipe_video_profile profile;
158    struct hash_table *video_buffer_map;
159    union {
160          struct {
161             unsigned nal_ref_idc;
162             bool IdrPicFlag;
163             unsigned idr_pic_id;
164             unsigned pic_order_cnt_lsb;
165             unsigned pic_order_cnt_msb;
166             unsigned delta_pic_order_cnt_bottom;
167             unsigned delta_pic_order_cnt[2];
168             unsigned prevFrameNumOffset;
169             struct pipe_h264_sps sps[32];
170             struct pipe_h264_pps pps[256];
171             struct list_head dpb_list;
172             unsigned dpb_num;
173          } h264;
174    } codec_data;
175    union {
176       struct pipe_picture_desc base;
177       struct pipe_h264_picture_desc h264;
178    } picture;
179    h264d_stream_info_t stream_info;
180    unsigned num_in_buffers;
181    bool first_buf_in_frame;
182    bool frame_finished;
183    bool frame_started;
184    unsigned bytes_left;
185    const void *slice;
186    bool disable_tunnel;
187    struct vl_compositor compositor;
188    struct vl_compositor_state cstate;
189    bool use_eglimage;
190 };
191 
192 #endif
193 
194 void vid_dec_NeedTarget(vid_dec_PrivateType* priv);
195 void vid_dec_FillOutput(vid_dec_PrivateType* priv, struct pipe_video_buffer* buf,
196                         OMX_BUFFERHEADERTYPE* output);
197 #endif
198