1 /**************************************************************************
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the
5 * "Software"), to deal in the Software without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sub license, and/or sell copies of the Software, and to
8 * permit persons to whom the Software is furnished to do so, subject to
9 * the following conditions:
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
18 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
19 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 **************************************************************************/
25 #include <tizport_decls.h>
30 #include "vid_enc_common.h"
32 static OMX_VERSIONTYPE h264e_encoder_version
= {{0, 0, 0, 1}};
34 OMX_PTR
instantiate_h264e_input_port(OMX_HANDLETYPE ap_hdl
)
36 OMX_VIDEO_PORTDEFINITIONTYPE portdef
;
37 OMX_VIDEO_CODINGTYPE encodings
[] = {
38 OMX_VIDEO_CodingUnused
,
41 OMX_COLOR_FORMATTYPE formats
[] = {
42 OMX_COLOR_FormatYUV420SemiPlanar
,
45 tiz_port_options_t rawvideo_port_opts
= {
48 OMX_VID_ENC_AVC_INPUT_PORT_MIN_BUF_COUNT
,
49 OMX_VID_ENC_AVC_PORT_MIN_INPUT_BUF_SIZE
,
50 OMX_VID_ENC_AVC_PORT_NONCONTIGUOUS
,
51 OMX_VID_ENC_AVC_PORT_ALIGNMENT
,
52 OMX_VID_ENC_AVC_PORT_SUPPLIERPREF
,
53 {OMX_VID_ENC_AVC_INPUT_PORT_INDEX
, NULL
, NULL
, NULL
},
57 portdef
.pNativeRender
= NULL
;
58 portdef
.nFrameWidth
= OMX_VID_ENC_AVC_DEFAULT_FRAME_WIDTH
;
59 portdef
.nFrameHeight
= OMX_VID_ENC_AVC_DEFAULT_FRAME_HEIGHT
;
61 portdef
.nSliceHeight
= 0;
62 portdef
.nBitrate
= 64000;
63 portdef
.xFramerate
= 15;
64 portdef
.bFlagErrorConcealment
= OMX_FALSE
;
65 portdef
.eCompressionFormat
= OMX_VIDEO_CodingUnused
;
66 portdef
.eColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
67 portdef
.pNativeWindow
= NULL
;
69 return factory_new(tiz_get_type(ap_hdl
, "h264einport"),
70 &rawvideo_port_opts
, &portdef
,
71 &encodings
, &formats
);
74 OMX_PTR
instantiate_h264e_output_port(OMX_HANDLETYPE ap_hdl
)
76 OMX_VIDEO_PORTDEFINITIONTYPE portdef
;
77 OMX_VIDEO_PARAM_AVCTYPE avctype
;
78 OMX_VIDEO_PARAM_BITRATETYPE bitrate
;
79 OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant
;
81 OMX_VIDEO_CODINGTYPE encodings
[] = {
85 OMX_COLOR_FORMATTYPE formats
[] = {
86 OMX_COLOR_FormatUnused
,
89 tiz_port_options_t avc_port_opts
= {
92 OMX_VID_ENC_AVC_OUTPUT_PORT_MIN_BUF_COUNT
,
93 OMX_VID_ENC_AVC_PORT_MIN_OUTPUT_BUF_SIZE
,
94 OMX_VID_ENC_AVC_PORT_NONCONTIGUOUS
,
95 OMX_VID_ENC_AVC_PORT_ALIGNMENT
,
96 OMX_VID_ENC_AVC_PORT_SUPPLIERPREF
,
97 {OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX
, NULL
, NULL
, NULL
},
100 OMX_VIDEO_AVCLEVELTYPE levels
[] = {
101 OMX_VIDEO_AVCLevel51
,
103 OMX_VIDEO_AVCLevel1b
,
104 OMX_VIDEO_AVCLevel11
,
105 OMX_VIDEO_AVCLevel12
,
106 OMX_VIDEO_AVCLevel13
,
108 OMX_VIDEO_AVCLevel21
,
109 OMX_VIDEO_AVCLevel22
,
111 OMX_VIDEO_AVCLevel31
,
112 OMX_VIDEO_AVCLevel32
,
114 OMX_VIDEO_AVCLevel41
,
115 OMX_VIDEO_AVCLevel42
,
117 OMX_VIDEO_AVCLevelMax
120 /* Values set from as given in specification */
121 portdef
.pNativeRender
= NULL
;
122 portdef
.nFrameWidth
= OMX_VID_ENC_AVC_DEFAULT_FRAME_WIDTH
;
123 portdef
.nFrameHeight
= OMX_VID_ENC_AVC_DEFAULT_FRAME_HEIGHT
;
125 portdef
.nSliceHeight
= 0;
126 portdef
.nBitrate
= 64000;
127 portdef
.xFramerate
= 15;
128 portdef
.bFlagErrorConcealment
= OMX_FALSE
;
129 portdef
.eCompressionFormat
= OMX_VIDEO_CodingAVC
;
130 portdef
.eColorFormat
= OMX_COLOR_FormatUnused
;
131 portdef
.pNativeWindow
= NULL
;
133 bitrate
.eControlRate
= OMX_Video_ControlRateDisable
;
134 bitrate
.nTargetBitrate
= 0;
136 quant
.nQpI
= OMX_VID_ENC_QUANT_I_FRAMES_DEFAULT
;
137 quant
.nQpP
= OMX_VID_ENC_QUANT_P_FRAMES_DEFAULT
;
138 quant
.nQpB
= OMX_VID_ENC_QUANT_B_FRAMES_DEFAULT
;
140 avctype
.nSize
= sizeof (OMX_VIDEO_PARAM_AVCTYPE
);
141 avctype
.nVersion
.nVersion
= OMX_VERSION
;
142 avctype
.nPortIndex
= OMX_VID_ENC_AVC_OUTPUT_PORT_INDEX
;
143 avctype
.eProfile
= OMX_VIDEO_AVCProfileBaseline
;
144 avctype
.nSliceHeaderSpacing
= 0;
145 avctype
.nPFrames
= 0;
146 avctype
.nBFrames
= 0;
147 avctype
.bUseHadamard
= OMX_TRUE
;
148 avctype
.nRefFrames
= 1;
149 avctype
.nRefIdx10ActiveMinus1
= 1;
150 avctype
.nRefIdx11ActiveMinus1
= 0;
151 avctype
.bEnableUEP
= OMX_FALSE
;
152 avctype
.bEnableFMO
= OMX_FALSE
;
153 avctype
.bEnableASO
= OMX_FALSE
;
154 avctype
.bEnableRS
= OMX_FALSE
;
155 avctype
.eLevel
= OMX_VIDEO_AVCLevel51
;
156 avctype
.nAllowedPictureTypes
= 2;
157 avctype
.bFrameMBsOnly
= OMX_FALSE
;
158 avctype
.bMBAFF
= OMX_FALSE
;
159 avctype
.bEntropyCodingCABAC
= OMX_FALSE
;
160 avctype
.bWeightedPPrediction
= OMX_FALSE
;
161 avctype
.nWeightedBipredicitonMode
= 0;
162 avctype
.bconstIpred
= OMX_FALSE
;
163 avctype
.bDirect8x8Inference
= OMX_FALSE
;
164 avctype
.bDirectSpatialTemporal
= OMX_FALSE
;
165 avctype
.nCabacInitIdc
= 0;
166 avctype
.eLoopFilterMode
= OMX_VIDEO_AVCLoopFilterEnable
;
168 return factory_new(tiz_get_type(ap_hdl
, "h264eoutport"),
169 &avc_port_opts
, &portdef
,
170 &encodings
, &formats
, &avctype
, &levels
,
174 OMX_PTR
instantiate_h264e_config_port(OMX_HANDLETYPE ap_hdl
)
176 return factory_new(tiz_get_type(ap_hdl
, "tizconfigport"),
177 NULL
, /* this port does not take options */
178 OMX_VID_COMP_NAME
, h264e_encoder_version
);
181 OMX_PTR
instantiate_h264e_processor(OMX_HANDLETYPE ap_hdl
)
183 return factory_new(tiz_get_type(ap_hdl
, "h264eprc"));