Path: blob/21.2-virgl/src/gallium/frontends/omx/tizonia/h264dinport.c
4561 views
/**************************************************************************1*2* Copyright 2013 Advanced Micro Devices, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#include <assert.h>28#include <string.h>29#include <limits.h>3031#include <tizplatform.h>32#include <tizkernel.h>3334#include "vl/vl_winsys.h"3536#include "h264d.h"37#include "h264dinport.h"38#include "h264dinport_decls.h"39#include "vid_dec_common.h"4041/*42* h264dinport class43*/4445static void * h264d_inport_ctor(void * ap_obj, va_list * app)46{47return super_ctor(typeOf(ap_obj, "h264dinport"), ap_obj, app);48}4950static void * h264d_inport_dtor(void * ap_obj)51{52return super_dtor(typeOf(ap_obj, "h264dinport"), ap_obj);53}5455/*56* from tiz_api57*/5859static OMX_ERRORTYPE h264d_inport_SetParameter(const void * ap_obj, OMX_HANDLETYPE ap_hdl,60OMX_INDEXTYPE a_index, OMX_PTR ap_struct)61{62OMX_ERRORTYPE err = OMX_ErrorNone;6364assert(ap_obj);65assert(ap_hdl);66assert(ap_struct);6768if (a_index == OMX_IndexParamPortDefinition) {69vid_dec_PrivateType * p_prc = tiz_get_prc(ap_hdl);70OMX_VIDEO_PORTDEFINITIONTYPE * p_def = &(p_prc->out_port_def_.format.video);71OMX_PARAM_PORTDEFINITIONTYPE * i_def = (OMX_PARAM_PORTDEFINITIONTYPE *) ap_struct;7273/* Make changes only if there is a resolution change */74if ((p_def->nFrameWidth == i_def->format.video.nFrameWidth) &&75(p_def->nFrameHeight == i_def->format.video.nFrameHeight) &&76(p_def->eCompressionFormat == i_def->format.video.eCompressionFormat))77return err;7879/* Set some default values if not set */80if (i_def->format.video.nStride == 0)81i_def->format.video.nStride = i_def->format.video.nFrameWidth;82if (i_def->format.video.nSliceHeight == 0)83i_def->format.video.nSliceHeight = i_def->format.video.nFrameHeight;8485err = super_SetParameter(typeOf (ap_obj, "h264dinport"), ap_obj,86ap_hdl, a_index, ap_struct);87if (err == OMX_ErrorNone) {88tiz_port_t * p_obj = (tiz_port_t *) ap_obj;8990/* Set desired buffer size that will be used when allocating input buffers */91p_obj->portdef_.nBufferSize = i_def->format.video.nFrameWidth * i_def->format.video.nFrameHeight * 512 / (16*16);9293/* Get a locally copy of port def. Useful for the early return above */94tiz_check_omx(tiz_api_GetParameter(tiz_get_krn(handleOf(p_prc)), handleOf(p_prc),95OMX_IndexParamPortDefinition, &(p_prc->out_port_def_)));96}97}9899return err;100}101102/*103* h264dinport_class104*/105106static void * h264d_inport_class_ctor(void * ap_obj, va_list * app)107{108/* NOTE: Class methods might be added in the future. None for now. */109return super_ctor (typeOf (ap_obj, "h264dinport_class"), ap_obj, app);110}111112/*113* initialization114*/115116void * h264d_inport_class_init(void * ap_tos, void * ap_hdl)117{118void * tizavcport = tiz_get_type(ap_hdl, "tizavcport");119void * h264dinport_class120= factory_new(classOf(tizavcport), "h264dinport_class",121classOf(tizavcport), sizeof(h264d_inport_class_t),122ap_tos, ap_hdl, ctor, h264d_inport_class_ctor, 0);123return h264dinport_class;124}125126void * h264d_inport_init(void * ap_tos, void * ap_hdl)127{128void * tizavcport = tiz_get_type (ap_hdl, "tizavcport");129void * h264dinport_class = tiz_get_type (ap_hdl, "h264dinport_class");130void * h264dinport = factory_new131/* TIZ_CLASS_COMMENT: class type, class name, parent, size */132(h264dinport_class, "h264dinport", tizavcport,133sizeof (h264d_inport_t),134/* TIZ_CLASS_COMMENT: class constructor */135ap_tos, ap_hdl,136/* TIZ_CLASS_COMMENT: class constructor */137ctor, h264d_inport_ctor,138/* TIZ_CLASS_COMMENT: class destructor */139dtor, h264d_inport_dtor,140/* TIZ_CLASS_COMMENT: */141tiz_api_SetParameter, h264d_inport_SetParameter,142/* TIZ_CLASS_COMMENT: stop value*/1430);144145return h264dinport;146}147148149