Path: blob/21.2-virgl/src/gallium/frontends/omx/tizonia/h264eoutport.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>3233#include "vl/vl_winsys.h"3435#include "h264eoutport.h"36#include "h264eoutport_decls.h"37#include "vid_enc_common.h"3839/*40* h264eoutport class41*/4243static void * h264e_outport_ctor(void * ap_obj, va_list * app)44{45return super_ctor(typeOf(ap_obj, "h264eoutport"), ap_obj, app);46}4748static void * h264e_outport_dtor(void * ap_obj)49{50return super_dtor(typeOf(ap_obj, "h264eoutport"), ap_obj);51}5253/*54* from tiz_api55*/5657static OMX_ERRORTYPE h264e_outport_AllocateBuffer(const void * ap_obj, OMX_HANDLETYPE ap_hdl,58OMX_BUFFERHEADERTYPE ** buf, OMX_U32 idx,59OMX_PTR private, OMX_U32 size)60{61OMX_ERRORTYPE r;6263r = super_UseBuffer(typeOf(ap_obj, "h264eoutport"), ap_obj, ap_hdl,64buf, idx, private, size, NULL);65if (r)66return r;6768(*buf)->pBuffer = NULL;69(*buf)->pOutputPortPrivate = CALLOC(1, sizeof(struct output_buf_private));70if (!(*buf)->pOutputPortPrivate) {71super_FreeBuffer(typeOf(ap_obj, "h264eoutport"), ap_obj, ap_hdl, idx, *buf);72return OMX_ErrorInsufficientResources;73}7475return OMX_ErrorNone;76}7778static OMX_ERRORTYPE h264e_outport_FreeBuffer(const void * ap_obj, OMX_HANDLETYPE ap_hdl,79OMX_U32 idx, OMX_BUFFERHEADERTYPE *buf)80{81vid_enc_PrivateType *priv = tiz_get_prc(ap_hdl);82struct output_buf_private *outp = buf->pOutputPortPrivate;8384if (outp) {85if (outp->transfer)86pipe_buffer_unmap(priv->t_pipe, outp->transfer);87pipe_resource_reference(&outp->bitstream, NULL);88FREE(outp);89buf->pOutputPortPrivate = NULL;90}91buf->pBuffer = NULL;9293return super_FreeBuffer(typeOf(ap_obj, "h264eoutport"), ap_obj, ap_hdl, idx, buf);94}9596/*97* h264e_outport_class98*/99100static void * h264e_outport_class_ctor(void * ap_obj, va_list * app)101{102/* NOTE: Class methods might be added in the future. None for now. */103return super_ctor(typeOf(ap_obj, "h264eoutport_class"), ap_obj, app);104}105106/*107* initialization108*/109110void * h264e_outport_class_init(void * ap_tos, void * ap_hdl)111{112void * tizavcport = tiz_get_type(ap_hdl, "tizavcport");113void * h264eoutport_class114= factory_new (classOf(tizavcport), "h264eoutport_class",115classOf(tizavcport), sizeof(h264e_outport_class_t),116ap_tos, ap_hdl, ctor, h264e_outport_class_ctor, 0);117return h264eoutport_class;118}119120void * h264e_outport_init(void * ap_tos, void * ap_hdl)121{122void * tizavcport = tiz_get_type(ap_hdl, "tizavcport");123void * h264eoutport_class = tiz_get_type(ap_hdl, "h264eoutport_class");124void * h264eoutport = factory_new125/* TIZ_CLASS_COMMENT: class type, class name, parent, size */126(h264eoutport_class, "h264eoutport", tizavcport,127sizeof(h264e_outport_t),128/* TIZ_CLASS_COMMENT: class constructor */129ap_tos, ap_hdl,130/* TIZ_CLASS_COMMENT: class constructor */131ctor, h264e_outport_ctor,132/* TIZ_CLASS_COMMENT: class destructor */133dtor, h264e_outport_dtor,134/* TIZ_CLASS_COMMENT: */135tiz_api_AllocateBuffer, h264e_outport_AllocateBuffer,136/* TIZ_CLASS_COMMENT: */137tiz_api_FreeBuffer, h264e_outport_FreeBuffer,138/* TIZ_CLASS_COMMENT: stop value*/1390);140141return h264eoutport;142}143144145