1 /**************************************************************************
2 *
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:
10 *
11 * The above copyright notice and this permission notice (including the
12 * next paragraph) shall be included in all copies or substantial portions
13 * of the Software.
14 *
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.
22 *
23 **************************************************************************/
24
25 #include <tizport_decls.h>
26
27 #include "h264eprc.h"
28 #include "h264e.h"
29 #include "names.h"
30 #include "vid_enc_common.h"
31
32 static OMX_VERSIONTYPE h264e_encoder_version = {{0, 0, 0, 1}};
33
instantiate_h264e_input_port(OMX_HANDLETYPE ap_hdl)34 OMX_PTR instantiate_h264e_input_port(OMX_HANDLETYPE ap_hdl)
35 {
36 OMX_VIDEO_PORTDEFINITIONTYPE portdef;
37 OMX_VIDEO_CODINGTYPE encodings[] = {
38 OMX_VIDEO_CodingUnused,
39 OMX_VIDEO_CodingMax
40 };
41 OMX_COLOR_FORMATTYPE formats[] = {
42 OMX_COLOR_FormatYUV420SemiPlanar,
43 OMX_COLOR_FormatMax
44 };
45 tiz_port_options_t rawvideo_port_opts = {
46 OMX_PortDomainVideo,
47 OMX_DirInput,
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},
54 1 /* Slave port */
55 };
56
57 portdef.pNativeRender = NULL;
58 portdef.nFrameWidth = OMX_VID_ENC_AVC_DEFAULT_FRAME_WIDTH;
59 portdef.nFrameHeight = OMX_VID_ENC_AVC_DEFAULT_FRAME_HEIGHT;
60 portdef.nStride = 0;
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;
68
69 return factory_new(tiz_get_type(ap_hdl, "h264einport"),
70 &rawvideo_port_opts, &portdef,
71 &encodings, &formats);
72 }
73
instantiate_h264e_output_port(OMX_HANDLETYPE ap_hdl)74 OMX_PTR instantiate_h264e_output_port(OMX_HANDLETYPE ap_hdl)
75 {
76 OMX_VIDEO_PORTDEFINITIONTYPE portdef;
77 OMX_VIDEO_PARAM_AVCTYPE avctype;
78 OMX_VIDEO_PARAM_BITRATETYPE bitrate;
79 OMX_VIDEO_PARAM_QUANTIZATIONTYPE quant;
80
81 OMX_VIDEO_CODINGTYPE encodings[] = {
82 OMX_VIDEO_CodingAVC,
83 OMX_VIDEO_CodingMax
84 };
85 OMX_COLOR_FORMATTYPE formats[] = {
86 OMX_COLOR_FormatUnused,
87 OMX_COLOR_FormatMax
88 };
89 tiz_port_options_t avc_port_opts = {
90 OMX_PortDomainVideo,
91 OMX_DirOutput,
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},
98 0 /* Master port */
99 };
100 OMX_VIDEO_AVCLEVELTYPE levels[] = {
101 OMX_VIDEO_AVCLevel51,
102 OMX_VIDEO_AVCLevel1,
103 OMX_VIDEO_AVCLevel1b,
104 OMX_VIDEO_AVCLevel11,
105 OMX_VIDEO_AVCLevel12,
106 OMX_VIDEO_AVCLevel13,
107 OMX_VIDEO_AVCLevel2,
108 OMX_VIDEO_AVCLevel21,
109 OMX_VIDEO_AVCLevel22,
110 OMX_VIDEO_AVCLevel3,
111 OMX_VIDEO_AVCLevel31,
112 OMX_VIDEO_AVCLevel32,
113 OMX_VIDEO_AVCLevel4,
114 OMX_VIDEO_AVCLevel41,
115 OMX_VIDEO_AVCLevel42,
116 OMX_VIDEO_AVCLevel5,
117 OMX_VIDEO_AVCLevelMax
118 };
119
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;
124 portdef.nStride = 0;
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;
132
133 bitrate.eControlRate = OMX_Video_ControlRateDisable;
134 bitrate.nTargetBitrate = 0;
135
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;
139
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;
167
168 return factory_new(tiz_get_type(ap_hdl, "h264eoutport"),
169 &avc_port_opts, &portdef,
170 &encodings, &formats, &avctype, &levels,
171 &bitrate, &quant);
172 }
173
instantiate_h264e_config_port(OMX_HANDLETYPE ap_hdl)174 OMX_PTR instantiate_h264e_config_port(OMX_HANDLETYPE ap_hdl)
175 {
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);
179 }
180
instantiate_h264e_processor(OMX_HANDLETYPE ap_hdl)181 OMX_PTR instantiate_h264e_processor(OMX_HANDLETYPE ap_hdl)
182 {
183 return factory_new(tiz_get_type(ap_hdl, "h264eprc"));
184 }
185