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