1/************************************************************************** 2 * 3 * Permission is hereby granted, free of charge, to any person obtaining a 4 * copy of this software and associated documentation files (the 5 * "Software"), to deal in the Software without restriction, including 6 * without limitation the rights to use, copy, modify, merge, publish, 7 * distribute, sub license, and/or sell copies of the Software, and to 8 * permit persons to whom the Software is furnished to do so, subject to 9 * the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the 12 * next paragraph) shall be included in all copies or substantial portions 13 * of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 18 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR 19 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 * 23 **************************************************************************/ 24 25#include <tizport_decls.h> 26 27#include "vid_dec_h264_common.h" 28 29#include "h264dprc.h" 30#include "h264d.h" 31#include "names.h" 32 33static OMX_VERSIONTYPE h264_decoder_version = {{0, 0, 0, 1}}; 34 35OMX_PTR instantiate_h264d_input_port(OMX_HANDLETYPE ap_hdl) 36{ 37 OMX_VIDEO_PORTDEFINITIONTYPE portdef; 38 OMX_VIDEO_PARAM_AVCTYPE avctype; 39 OMX_VIDEO_CODINGTYPE encodings[] = { 40 OMX_VIDEO_CodingAVC, 41 OMX_VIDEO_CodingMax 42 }; 43 OMX_COLOR_FORMATTYPE formats[] = { 44 OMX_COLOR_FormatUnused, 45 OMX_COLOR_FormatMax 46 }; 47 tiz_port_options_t avc_port_opts = { 48 OMX_PortDomainVideo, 49 OMX_DirInput, 50 OMX_VID_DEC_AVC_INPUT_PORT_MIN_BUF_COUNT, 51 OMX_VID_DEC_AVC_PORT_MIN_INPUT_BUF_SIZE, 52 OMX_VID_DEC_AVC_PORT_NONCONTIGUOUS, 53 OMX_VID_DEC_AVC_PORT_ALIGNMENT, 54 OMX_VID_DEC_AVC_PORT_SUPPLIERPREF, 55 {OMX_VID_DEC_AVC_INPUT_PORT_INDEX, NULL, NULL, NULL}, 56 1 /* slave port */ 57 }; 58 OMX_VIDEO_AVCLEVELTYPE levels[] = { 59 OMX_VIDEO_AVCLevel1, 60 OMX_VIDEO_AVCLevel1b, 61 OMX_VIDEO_AVCLevel11, 62 OMX_VIDEO_AVCLevel12, 63 OMX_VIDEO_AVCLevel13, 64 OMX_VIDEO_AVCLevel2, 65 OMX_VIDEO_AVCLevel21, 66 OMX_VIDEO_AVCLevel22, 67 OMX_VIDEO_AVCLevel3, 68 OMX_VIDEO_AVCLevel31, 69 OMX_VIDEO_AVCLevel32, 70 OMX_VIDEO_AVCLevel4, 71 OMX_VIDEO_AVCLevel41, 72 OMX_VIDEO_AVCLevel42, 73 OMX_VIDEO_AVCLevel5, 74 OMX_VIDEO_AVCLevel51, 75 OMX_VIDEO_AVCLevelMax 76 }; 77 78 portdef.pNativeRender = NULL; 79 portdef.nFrameWidth = OMX_VID_DEC_AVC_DEFAULT_FRAME_WIDTH; 80 portdef.nFrameHeight = OMX_VID_DEC_AVC_DEFAULT_FRAME_HEIGHT; 81 portdef.nStride = 0; 82 portdef.nSliceHeight = 0; 83 portdef.nBitrate = 64000; 84 portdef.xFramerate = OMX_VID_DEC_AVC_DEFAULT_FRAME_RATE; 85 portdef.bFlagErrorConcealment = OMX_FALSE; 86 portdef.eCompressionFormat = OMX_VIDEO_CodingAVC; 87 portdef.eColorFormat = OMX_COLOR_FormatUnused; 88 portdef.pNativeWindow = NULL; 89 90 avctype.nSize = sizeof (OMX_VIDEO_PARAM_AVCTYPE); 91 avctype.nVersion.nVersion = OMX_VERSION; 92 avctype.nPortIndex = OMX_VID_DEC_AVC_INPUT_PORT_INDEX; 93 avctype.eProfile = OMX_VIDEO_AVCProfileHigh; 94 /* Encoder related, decide if need to initialise these */ 95 avctype.nSliceHeaderSpacing = 0; 96 avctype.nPFrames = 0; 97 avctype.nBFrames = 0; 98 avctype.bUseHadamard = OMX_FALSE; 99 avctype.nRefFrames = 1; 100 avctype.nRefIdx10ActiveMinus1 = 1; 101 avctype.nRefIdx11ActiveMinus1 = 0; 102 avctype.bEnableUEP = OMX_FALSE; 103 avctype.bEnableFMO = OMX_FALSE; 104 avctype.bEnableASO = OMX_FALSE; 105 avctype.bEnableRS = OMX_FALSE; 106 avctype.eLevel = OMX_VIDEO_AVCLevel51; 107 avctype.nAllowedPictureTypes = 2; 108 avctype.bFrameMBsOnly = OMX_FALSE; 109 avctype.bMBAFF = OMX_FALSE; 110 avctype.bEntropyCodingCABAC = OMX_FALSE; 111 avctype.bWeightedPPrediction = OMX_FALSE; 112 avctype.nWeightedBipredicitonMode = 0; 113 avctype.bconstIpred = OMX_FALSE; 114 avctype.bDirect8x8Inference = OMX_FALSE; 115 avctype.bDirectSpatialTemporal = OMX_FALSE; 116 avctype.nCabacInitIdc = 0; 117 avctype.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable; 118 119 return factory_new (tiz_get_type(ap_hdl, "h264dinport"), 120 &avc_port_opts, &portdef, 121 &encodings, &formats, &avctype, &levels, 122 NULL /* OMX_VIDEO_PARAM_BITRATETYPE */, 123 NULL /* OMX_VIDEO_PARAM_QUANTIZATIONTYPE */); 124} 125 126OMX_PTR instantiate_h264d_output_port(OMX_HANDLETYPE ap_hdl) 127{ 128 OMX_VIDEO_PORTDEFINITIONTYPE portdef; 129 OMX_VIDEO_CODINGTYPE encodings[] = { 130 OMX_VIDEO_CodingUnused, 131 OMX_VIDEO_CodingMax 132 }; 133 OMX_COLOR_FORMATTYPE formats[] = { 134 OMX_COLOR_FormatYUV420SemiPlanar, 135 OMX_COLOR_FormatMax 136 }; 137 tiz_port_options_t rawvideo_port_opts = { 138 OMX_PortDomainVideo, 139 OMX_DirOutput, 140 OMX_VID_DEC_AVC_OUTPUT_PORT_MIN_BUF_COUNT, 141 OMX_VID_DEC_AVC_PORT_MIN_OUTPUT_BUF_SIZE, 142 OMX_VID_DEC_AVC_PORT_NONCONTIGUOUS, 143 OMX_VID_DEC_AVC_PORT_ALIGNMENT, 144 OMX_VID_DEC_AVC_PORT_SUPPLIERPREF, 145 {OMX_VID_DEC_AVC_OUTPUT_PORT_INDEX, NULL, NULL, NULL}, 146 0 /* Master port */ 147 }; 148 149 portdef.pNativeRender = NULL; 150 portdef.nFrameWidth = OMX_VID_DEC_AVC_DEFAULT_FRAME_WIDTH; 151 portdef.nFrameHeight = OMX_VID_DEC_AVC_DEFAULT_FRAME_HEIGHT; 152 portdef.nStride = 0; 153 portdef.nSliceHeight = 0; 154 portdef.nBitrate = 64000; 155 portdef.xFramerate = OMX_VID_DEC_AVC_DEFAULT_FRAME_RATE; 156 portdef.bFlagErrorConcealment = OMX_FALSE; 157 portdef.eCompressionFormat = OMX_VIDEO_CodingUnused; 158 portdef.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; 159 portdef.pNativeWindow = NULL; 160 161 return factory_new(tiz_get_type(ap_hdl, "tizvideoport"), 162 &rawvideo_port_opts, &portdef, 163 &encodings, &formats); 164} 165 166OMX_PTR instantiate_h264d_config_port(OMX_HANDLETYPE ap_hdl) 167{ 168 return factory_new(tiz_get_type(ap_hdl, "tizconfigport"), 169 NULL, /* this port does not take options */ 170 OMX_VID_COMP_NAME, h264_decoder_version); 171} 172 173OMX_PTR instantiate_h264d_processor(OMX_HANDLETYPE ap_hdl) 174{ 175 return factory_new(tiz_get_type(ap_hdl, "h264dprc")); 176} 177