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>
33 #include <tizkernel.h>
35 #include "vl/vl_winsys.h"
38 #include "h264dinport.h"
39 #include "h264dinport_decls.h"
40 #include "vid_dec_common.h"
46 static void * h264d_inport_ctor(void * ap_obj
, va_list * app
)
48 return super_ctor(typeOf(ap_obj
, "h264dinport"), ap_obj
, app
);
51 static void * h264d_inport_dtor(void * ap_obj
)
53 return super_dtor(typeOf(ap_obj
, "h264dinport"), ap_obj
);
60 static OMX_ERRORTYPE
h264d_inport_SetParameter(const void * ap_obj
, OMX_HANDLETYPE ap_hdl
,
61 OMX_INDEXTYPE a_index
, OMX_PTR ap_struct
)
63 OMX_ERRORTYPE err
= OMX_ErrorNone
;
69 if (a_index
== OMX_IndexParamPortDefinition
) {
70 vid_dec_PrivateType
* p_prc
= tiz_get_prc(ap_hdl
);
71 OMX_VIDEO_PORTDEFINITIONTYPE
* p_def
= &(p_prc
->out_port_def_
.format
.video
);
72 OMX_PARAM_PORTDEFINITIONTYPE
* i_def
= (OMX_PARAM_PORTDEFINITIONTYPE
*) ap_struct
;
74 /* Make changes only if there is a resolution change */
75 if ((p_def
->nFrameWidth
== i_def
->format
.video
.nFrameWidth
) &&
76 (p_def
->nFrameHeight
== i_def
->format
.video
.nFrameHeight
) &&
77 (p_def
->eCompressionFormat
== i_def
->format
.video
.eCompressionFormat
))
80 /* Set some default values if not set */
81 if (i_def
->format
.video
.nStride
== 0)
82 i_def
->format
.video
.nStride
= i_def
->format
.video
.nFrameWidth
;
83 if (i_def
->format
.video
.nSliceHeight
== 0)
84 i_def
->format
.video
.nSliceHeight
= i_def
->format
.video
.nFrameHeight
;
86 err
= super_SetParameter(typeOf (ap_obj
, "h264dinport"), ap_obj
,
87 ap_hdl
, a_index
, ap_struct
);
88 if (err
== OMX_ErrorNone
) {
89 tiz_port_t
* p_obj
= (tiz_port_t
*) ap_obj
;
91 /* Set desired buffer size that will be used when allocating input buffers */
92 p_obj
->portdef_
.nBufferSize
= i_def
->format
.video
.nFrameWidth
* i_def
->format
.video
.nFrameHeight
* 512 / (16*16);
94 /* Get a locally copy of port def. Useful for the early return above */
95 tiz_check_omx(tiz_api_GetParameter(tiz_get_krn(handleOf(p_prc
)), handleOf(p_prc
),
96 OMX_IndexParamPortDefinition
, &(p_prc
->out_port_def_
)));
107 static void * h264d_inport_class_ctor(void * ap_obj
, va_list * app
)
109 /* NOTE: Class methods might be added in the future. None for now. */
110 return super_ctor (typeOf (ap_obj
, "h264dinport_class"), ap_obj
, app
);
117 void * h264d_inport_class_init(void * ap_tos
, void * ap_hdl
)
119 void * tizavcport
= tiz_get_type(ap_hdl
, "tizavcport");
120 void * h264dinport_class
121 = factory_new(classOf(tizavcport
), "h264dinport_class",
122 classOf(tizavcport
), sizeof(h264d_inport_class_t
),
123 ap_tos
, ap_hdl
, ctor
, h264d_inport_class_ctor
, 0);
124 return h264dinport_class
;
127 void * h264d_inport_init(void * ap_tos
, void * ap_hdl
)
129 void * tizavcport
= tiz_get_type (ap_hdl
, "tizavcport");
130 void * h264dinport_class
= tiz_get_type (ap_hdl
, "h264dinport_class");
131 void * h264dinport
= factory_new
132 /* TIZ_CLASS_COMMENT: class type, class name, parent, size */
133 (h264dinport_class
, "h264dinport", tizavcport
,
134 sizeof (h264d_inport_t
),
135 /* TIZ_CLASS_COMMENT: class constructor */
137 /* TIZ_CLASS_COMMENT: class constructor */
138 ctor
, h264d_inport_ctor
,
139 /* TIZ_CLASS_COMMENT: class destructor */
140 dtor
, h264d_inport_dtor
,
141 /* TIZ_CLASS_COMMENT: */
142 tiz_api_SetParameter
, h264d_inport_SetParameter
,
143 /* TIZ_CLASS_COMMENT: stop value*/