Path: blob/21.2-virgl/src/gallium/frontends/omx/tizonia/h264e.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 "h264eprc.h"27#include "h264e.h"28#include "names.h"29#include "vid_enc_common.h"3031static OMX_VERSIONTYPE h264e_encoder_version = {{0, 0, 0, 1}};3233OMX_PTR instantiate_h264e_input_port(OMX_HANDLETYPE ap_hdl)34{35OMX_VIDEO_PORTDEFINITIONTYPE portdef;36OMX_VIDEO_CODINGTYPE encodings[] = {37OMX_VIDEO_CodingUnused,38OMX_VIDEO_CodingMax39};40OMX_COLOR_FORMATTYPE formats[] = {41OMX_COLOR_FormatYUV420SemiPlanar,42OMX_COLOR_FormatMax43};44tiz_port_options_t rawvideo_port_opts = {45OMX_PortDomainVideo,46OMX_DirInput,47OMX_VID_ENC_AVC_INPUT_PORT_MIN_BUF_COUNT,48OMX_VID_ENC_AVC_PORT_MIN_INPUT_BUF_SIZE,49OMX_VID_ENC_AVC_PORT_NONCONTIGUOUS,50OMX_VID_ENC_AVC_PORT_ALIGNMENT,51OMX_VID_ENC_AVC_PORT_SUPPLIERPREF,52{OMX_VID_ENC_AVC_INPUT_PORT_INDEX, NULL, NULL, NULL},531 /* Slave port */54};5556portdef.pNativeRender = NULL;57portdef.nFrameWidth = OMX_VID_ENC_AVC_DEFAULT_FRAME_WIDTH;58portdef.nFrameHeight = OMX_VID_ENC_AVC_DEFAULT_FRAME_HEIGHT;59portdef.nStride = 0;60portdef.nSliceHeight = 0;61portdef.nBitrate = 64000;62portdef.xFramerate = 15;63portdef.bFlagErrorConcealment = OMX_FALSE;64portdef.eCompressionFormat = OMX_VIDEO_CodingUnused;65portdef.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;66portdef.pNativeWindow = NULL;6768return factory_new(tiz_get_type(ap_hdl, "h264einport"),69&rawvideo_port_opts, &portdef,70&encodings, &formats);71}7273OMX_PTR instantiate_h264e_output_port(OMX_HANDLETYPE ap_hdl)74{75OMX_VIDEO_PORTDEFINITIONTYPE portdef;76OMX_VIDEO_PARAM_AVCTYPE avctype;77OMX_VIDEO_PARAM_BITRATETYPE bitrate;78OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant;7980OMX_VIDEO_CODINGTYPE encodings[] = {81OMX_VIDEO_CodingAVC,82OMX_VIDEO_CodingMax83};84OMX_COLOR_FORMATTYPE formats[] = {85OMX_COLOR_FormatUnused,86OMX_COLOR_FormatMax87};88tiz_port_options_t avc_port_opts = {89OMX_PortDomainVideo,90OMX_DirOutput,91OMX_VID_ENC_AVC_OUTPUT_PORT_MIN_BUF_COUNT,92OMX_VID_ENC_AVC_PORT_MIN_OUTPUT_BUF_SIZE,93OMX_VID_ENC_AVC_PORT_NONCONTIGUOUS,94OMX_VID_ENC_AVC_PORT_ALIGNMENT,95OMX_VID_ENC_AVC_PORT_SUPPLIERPREF,96{OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX, NULL, NULL, NULL},970 /* Master port */98};99OMX_VIDEO_AVCLEVELTYPE levels[] = {100OMX_VIDEO_AVCLevel51,101OMX_VIDEO_AVCLevel1,102OMX_VIDEO_AVCLevel1b,103OMX_VIDEO_AVCLevel11,104OMX_VIDEO_AVCLevel12,105OMX_VIDEO_AVCLevel13,106OMX_VIDEO_AVCLevel2,107OMX_VIDEO_AVCLevel21,108OMX_VIDEO_AVCLevel22,109OMX_VIDEO_AVCLevel3,110OMX_VIDEO_AVCLevel31,111OMX_VIDEO_AVCLevel32,112OMX_VIDEO_AVCLevel4,113OMX_VIDEO_AVCLevel41,114OMX_VIDEO_AVCLevel42,115OMX_VIDEO_AVCLevel5,116OMX_VIDEO_AVCLevelMax117};118119/* Values set from as given in specification */120portdef.pNativeRender = NULL;121portdef.nFrameWidth = OMX_VID_ENC_AVC_DEFAULT_FRAME_WIDTH;122portdef.nFrameHeight = OMX_VID_ENC_AVC_DEFAULT_FRAME_HEIGHT;123portdef.nStride = 0;124portdef.nSliceHeight = 0;125portdef.nBitrate = 64000;126portdef.xFramerate = 15;127portdef.bFlagErrorConcealment = OMX_FALSE;128portdef.eCompressionFormat = OMX_VIDEO_CodingAVC;129portdef.eColorFormat = OMX_COLOR_FormatUnused;130portdef.pNativeWindow = NULL;131132bitrate.eControlRate = OMX_Video_ControlRateDisable;133bitrate.nTargetBitrate = 0;134135quant.nQpI = OMX_VID_ENC_QUANT_I_FRAMES_DEFAULT;136quant.nQpP = OMX_VID_ENC_QUANT_P_FRAMES_DEFAULT;137quant.nQpB = OMX_VID_ENC_QUANT_B_FRAMES_DEFAULT;138139avctype.nSize = sizeof (OMX_VIDEO_PARAM_AVCTYPE);140avctype.nVersion.nVersion = OMX_VERSION;141avctype.nPortIndex = OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX;142avctype.eProfile = OMX_VIDEO_AVCProfileBaseline;143avctype.nSliceHeaderSpacing = 0;144avctype.nPFrames = 0;145avctype.nBFrames = 0;146avctype.bUseHadamard = OMX_TRUE;147avctype.nRefFrames = 1;148avctype.nRefIdx10ActiveMinus1 = 1;149avctype.nRefIdx11ActiveMinus1 = 0;150avctype.bEnableUEP = OMX_FALSE;151avctype.bEnableFMO = OMX_FALSE;152avctype.bEnableASO = OMX_FALSE;153avctype.bEnableRS = OMX_FALSE;154avctype.eLevel = OMX_VIDEO_AVCLevel51;155avctype.nAllowedPictureTypes = 2;156avctype.bFrameMBsOnly = OMX_FALSE;157avctype.bMBAFF = OMX_FALSE;158avctype.bEntropyCodingCABAC = OMX_FALSE;159avctype.bWeightedPPrediction = OMX_FALSE;160avctype.nWeightedBipredicitonMode = 0;161avctype.bconstIpred = OMX_FALSE;162avctype.bDirect8x8Inference = OMX_FALSE;163avctype.bDirectSpatialTemporal = OMX_FALSE;164avctype.nCabacInitIdc = 0;165avctype.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable;166167return factory_new(tiz_get_type(ap_hdl, "h264eoutport"),168&avc_port_opts, &portdef,169&encodings, &formats, &avctype, &levels,170&bitrate, &quant);171}172173OMX_PTR instantiate_h264e_config_port(OMX_HANDLETYPE ap_hdl)174{175return factory_new(tiz_get_type(ap_hdl, "tizconfigport"),176NULL, /* this port does not take options */177OMX_VID_COMP_NAME, h264e_encoder_version);178}179180OMX_PTR instantiate_h264e_processor(OMX_HANDLETYPE ap_hdl)181{182return factory_new(tiz_get_type(ap_hdl, "h264eprc"));183}184185186