1 /***************************************************************************** 2 * omxil.h: helper functions 3 ***************************************************************************** 4 * Copyright (C) 2010 VLC authors and VideoLAN 5 * $Id: 66b75a41d3f2f67d4c738822c657b1b2bf7c28d2 $ 6 * 7 * Authors: Gildas Bazin <gbazin@videolan.org> 8 * 9 * This program is free software; you can redistribute it and/or modify it 10 * under the terms of the GNU Lesser General Public License as published by 11 * the Free Software Foundation; either version 2.1 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public License 20 * along with this program; if not, write to the Free Software Foundation, 21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 22 *****************************************************************************/ 23 24 #ifdef RPI_OMX 25 #define OMX_SKIP64BIT 26 #endif 27 28 /***************************************************************************** 29 * Includes 30 *****************************************************************************/ 31 #include "OMX_Core.h" 32 #include "OMX_Index.h" 33 #include "OMX_Component.h" 34 #include "OMX_Video.h" 35 36 #include "omxil_utils.h" 37 #include "omxil_core.h" 38 39 #if defined(USE_IOMX) 40 #include "../../video_output/android/utils.h" 41 #endif 42 43 enum 44 { 45 BUF_STATE_NOT_OWNED = 0, 46 BUF_STATE_OWNED, 47 }; 48 49 /***************************************************************************** 50 * decoder_sys_t : omxil decoder descriptor 51 *****************************************************************************/ 52 typedef struct OmxFifo 53 { 54 vlc_mutex_t lock; 55 vlc_cond_t wait; 56 57 OMX_BUFFERHEADERTYPE *p_first; 58 OMX_BUFFERHEADERTYPE **pp_last; 59 60 int offset; 61 62 } OmxFifo; 63 64 typedef struct HwBuffer 65 { 66 vlc_thread_t dequeue_thread; 67 bool b_run; 68 vlc_mutex_t lock; 69 vlc_cond_t wait; 70 picture_sys_t** inflight_picture; /**< stores the inflight picture for each output buffer or NULL */ 71 72 unsigned int i_buffers; 73 void **pp_handles; 74 int *i_states; 75 unsigned int i_max_owned; 76 unsigned int i_owned; 77 78 #if defined(USE_IOMX) 79 native_window_priv_api_t anwpriv; 80 native_window_priv *window_priv; 81 #endif 82 83 } HwBuffer; 84 85 typedef struct OmxPort 86 { 87 bool b_valid; 88 OMX_U32 i_port_index; 89 OMX_HANDLETYPE omx_handle; 90 OMX_PARAM_PORTDEFINITIONTYPE definition; 91 es_format_t *p_fmt; 92 93 unsigned int i_frame_size; 94 unsigned int i_frame_stride; 95 unsigned int i_frame_stride_chroma_div; 96 97 unsigned int i_buffers; 98 OMX_BUFFERHEADERTYPE **pp_buffers; 99 100 OmxFifo fifo; 101 102 OmxFormatParam format_param; 103 104 OMX_BOOL b_reconfigure; 105 OMX_BOOL b_update_def; 106 OMX_BOOL b_direct; 107 OMX_BOOL b_flushed; 108 109 HwBuffer *p_hwbuf; 110 111 } OmxPort; 112 113 struct decoder_sys_t 114 { 115 OMX_HANDLETYPE omx_handle; 116 117 bool b_enc; 118 119 char psz_component[OMX_MAX_STRINGNAME_SIZE]; 120 char ppsz_components[MAX_COMPONENTS_LIST_SIZE][OMX_MAX_STRINGNAME_SIZE]; 121 unsigned int components; 122 int i_quirks; 123 124 OmxEventQueue event_queue; 125 126 OmxPort *p_ports; 127 unsigned int ports; 128 OmxPort in; 129 OmxPort out; 130 131 bool b_error; 132 133 bool b_aspect_ratio_handled; 134 135 date_t end_date; 136 137 uint8_t i_nal_size_length; /* Length of the NAL size field for H264 */ 138 int b_use_pts; 139 140 }; 141