Home | History | Annotate | Download | only in omx_bellagio
      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 /*
     29  * Authors:
     30  *      Christian Knig <christian.koenig (at) amd.com>
     31  *
     32  */
     33 
     34 #ifndef OMX_VID_DEC_H
     35 #define OMX_VID_DEC_H
     36 
     37 #include <string.h>
     38 
     39 #include <OMX_Types.h>
     40 #include <OMX_Component.h>
     41 #include <OMX_Core.h>
     42 
     43 #include <bellagio/st_static_component_loader.h>
     44 #include <bellagio/omx_base_filter.h>
     45 #include <bellagio/omx_base_video_port.h>
     46 
     47 #include "pipe/p_video_state.h"
     48 #include "os/os_thread.h"
     49 #include "util/list.h"
     50 
     51 #include "vl/vl_compositor.h"
     52 
     53 #define OMX_VID_DEC_BASE_NAME "OMX.mesa.video_decoder"
     54 
     55 #define OMX_VID_DEC_MPEG2_NAME "OMX.mesa.video_decoder.mpeg2"
     56 #define OMX_VID_DEC_MPEG2_ROLE "video_decoder.mpeg2"
     57 
     58 #define OMX_VID_DEC_AVC_NAME "OMX.mesa.video_decoder.avc"
     59 #define OMX_VID_DEC_AVC_ROLE "video_decoder.avc"
     60 
     61 #define OMX_VID_DEC_HEVC_NAME "OMX.mesa.video_decoder.hevc"
     62 #define OMX_VID_DEC_HEVC_ROLE "video_decoder.hevc"
     63 
     64 #define OMX_VID_DEC_TIMESTAMP_INVALID ((OMX_TICKS) -1)
     65 
     66 struct vl_vlc;
     67 
     68 DERIVEDCLASS(vid_dec_PrivateType, omx_base_filter_PrivateType)
     69 #define vid_dec_PrivateType_FIELDS omx_base_filter_PrivateType_FIELDS \
     70    enum pipe_video_profile profile; \
     71    struct vl_screen *screen; \
     72    struct pipe_context *pipe; \
     73    struct pipe_video_codec *codec; \
     74    void (*Decode)(vid_dec_PrivateType *priv, struct vl_vlc *vlc, unsigned min_bits_left); \
     75    void (*EndFrame)(vid_dec_PrivateType *priv); \
     76    struct pipe_video_buffer *(*Flush)(vid_dec_PrivateType *priv, OMX_TICKS *timestamp); \
     77    struct pipe_video_buffer *target, *shadow; \
     78    union { \
     79       struct { \
     80          uint8_t intra_matrix[64]; \
     81          uint8_t non_intra_matrix[64]; \
     82       } mpeg12; \
     83       struct { \
     84          unsigned nal_ref_idc; \
     85          bool IdrPicFlag; \
     86          unsigned idr_pic_id; \
     87          unsigned pic_order_cnt_lsb; \
     88          unsigned pic_order_cnt_msb; \
     89          unsigned delta_pic_order_cnt_bottom; \
     90          unsigned delta_pic_order_cnt[2]; \
     91          unsigned prevFrameNumOffset; \
     92          struct pipe_h264_sps sps[32]; \
     93          struct pipe_h264_pps pps[256]; \
     94          struct list_head dpb_list; \
     95          unsigned dpb_num; \
     96       } h264; \
     97       struct { \
     98          unsigned temporal_id; \
     99          unsigned level_idc; \
    100          unsigned pic_width_in_luma_samples; \
    101          unsigned pic_height_in_luma_samples; \
    102          bool IdrPicFlag; \
    103          int slice_prev_poc; \
    104          void *ref_pic_set_list; \
    105          void *rps; \
    106          struct pipe_h265_sps sps[16]; \
    107          struct pipe_h265_pps pps[64]; \
    108          struct list_head dpb_list; \
    109          unsigned dpb_num; \
    110       } h265; \
    111    } codec_data; \
    112    union { \
    113       struct pipe_picture_desc base; \
    114       struct pipe_mpeg12_picture_desc mpeg12; \
    115       struct pipe_h264_picture_desc h264; \
    116       struct pipe_h265_picture_desc h265; \
    117    } picture; \
    118    unsigned num_in_buffers; \
    119    OMX_BUFFERHEADERTYPE *in_buffers[2]; \
    120    const void *inputs[2]; \
    121    unsigned sizes[2]; \
    122    OMX_TICKS timestamps[2]; \
    123    OMX_TICKS timestamp; \
    124    bool first_buf_in_frame; \
    125    bool frame_finished; \
    126    bool frame_started; \
    127    unsigned bytes_left; \
    128    const void *slice; \
    129    bool disable_tunnel; \
    130    struct vl_compositor compositor; \
    131    struct vl_compositor_state cstate;
    132 ENDCLASS(vid_dec_PrivateType)
    133 
    134 OMX_ERRORTYPE vid_dec_LoaderComponent(stLoaderComponentType *comp);
    135 
    136 /* used by MPEG12 and H264 implementation */
    137 void vid_dec_NeedTarget(vid_dec_PrivateType *priv);
    138 
    139 /* vid_dec_mpeg12.c */
    140 void vid_dec_mpeg12_Init(vid_dec_PrivateType *priv);
    141 
    142 /* vid_dec_h264.c */
    143 void vid_dec_h264_Init(vid_dec_PrivateType *priv);
    144 
    145 /* vid_dec_h265.c */
    146 void vid_dec_h265_Init(vid_dec_PrivateType *priv);
    147 
    148 #endif
    149