1 /**************************************************************************
3 * Copyright 2013 Advanced Micro Devices, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
32 #include <tizplatform.h>
34 #include "vl/vl_winsys.h"
36 #include "h264eoutport.h"
37 #include "h264eoutport_decls.h"
38 #include "vid_enc_common.h"
44 static void * h264e_outport_ctor(void * ap_obj
, va_list * app
)
46 return super_ctor(typeOf(ap_obj
, "h264eoutport"), ap_obj
, app
);
49 static void * h264e_outport_dtor(void * ap_obj
)
51 return super_dtor(typeOf(ap_obj
, "h264eoutport"), ap_obj
);
58 static OMX_ERRORTYPE
h264e_outport_AllocateBuffer(const void * ap_obj
, OMX_HANDLETYPE ap_hdl
,
59 OMX_BUFFERHEADERTYPE
** buf
, OMX_U32 idx
,
60 OMX_PTR
private, OMX_U32 size
)
64 r
= super_UseBuffer(typeOf(ap_obj
, "h264eoutport"), ap_obj
, ap_hdl
,
65 buf
, idx
, private, size
, NULL
);
69 (*buf
)->pBuffer
= NULL
;
70 (*buf
)->pOutputPortPrivate
= CALLOC(1, sizeof(struct output_buf_private
));
71 if (!(*buf
)->pOutputPortPrivate
) {
72 super_FreeBuffer(typeOf(ap_obj
, "h264eoutport"), ap_obj
, ap_hdl
, idx
, *buf
);
73 return OMX_ErrorInsufficientResources
;
79 static OMX_ERRORTYPE
h264e_outport_FreeBuffer(const void * ap_obj
, OMX_HANDLETYPE ap_hdl
,
80 OMX_U32 idx
, OMX_BUFFERHEADERTYPE
*buf
)
82 vid_enc_PrivateType
*priv
= tiz_get_prc(ap_hdl
);
83 struct output_buf_private
*outp
= buf
->pOutputPortPrivate
;
87 pipe_transfer_unmap(priv
->t_pipe
, outp
->transfer
);
88 pipe_resource_reference(&outp
->bitstream
, NULL
);
90 buf
->pOutputPortPrivate
= NULL
;
94 return super_FreeBuffer(typeOf(ap_obj
, "h264eoutport"), ap_obj
, ap_hdl
, idx
, buf
);
101 static void * h264e_outport_class_ctor(void * ap_obj
, va_list * app
)
103 /* NOTE: Class methods might be added in the future. None for now. */
104 return super_ctor(typeOf(ap_obj
, "h264eoutport_class"), ap_obj
, app
);
111 void * h264e_outport_class_init(void * ap_tos
, void * ap_hdl
)
113 void * tizavcport
= tiz_get_type(ap_hdl
, "tizavcport");
114 void * h264eoutport_class
115 = factory_new (classOf(tizavcport
), "h264eoutport_class",
116 classOf(tizavcport
), sizeof(h264e_outport_class_t
),
117 ap_tos
, ap_hdl
, ctor
, h264e_outport_class_ctor
, 0);
118 return h264eoutport_class
;
121 void * h264e_outport_init(void * ap_tos
, void * ap_hdl
)
123 void * tizavcport
= tiz_get_type(ap_hdl
, "tizavcport");
124 void * h264eoutport_class
= tiz_get_type(ap_hdl
, "h264eoutport_class");
125 void * h264eoutport
= factory_new
126 /* TIZ_CLASS_COMMENT: class type, class name, parent, size */
127 (h264eoutport_class
, "h264eoutport", tizavcport
,
128 sizeof(h264e_outport_t
),
129 /* TIZ_CLASS_COMMENT: class constructor */
131 /* TIZ_CLASS_COMMENT: class constructor */
132 ctor
, h264e_outport_ctor
,
133 /* TIZ_CLASS_COMMENT: class destructor */
134 dtor
, h264e_outport_dtor
,
135 /* TIZ_CLASS_COMMENT: */
136 tiz_api_AllocateBuffer
, h264e_outport_AllocateBuffer
,
137 /* TIZ_CLASS_COMMENT: */
138 tiz_api_FreeBuffer
, h264e_outport_FreeBuffer
,
139 /* TIZ_CLASS_COMMENT: stop value*/