aboutsummaryrefslogtreecommitdiffstats
path: root/psb-dec/psb.h
blob: b36b5cf6f726595bd4c2e9cc0ca89353b7b6068d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/*
 * psb.h, omx psb component header
 *
 * Copyright (c) 2009-2010 Wind River Systems, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __WRS_OMXIL_INTEL_MRST_PSB
#define __WRS_OMXIL_INTEL_MRST_PSB

#include <OMX_Core.h>
#include <OMX_Component.h>

#include <cmodule.h>
#include <portbase.h>
#include <componentbase.h>
#define oscl_memset	memset
class MrstPsbComponent : public ComponentBase
{
public:
    /*
     * constructor & destructor
     */
    MrstPsbComponent();
    ~MrstPsbComponent();

private:
    /*
     * component methods & helpers
     */
    /* implement ComponentBase::ComponentAllocatePorts */
    virtual OMX_ERRORTYPE ComponentAllocatePorts(void);

    OMX_ERRORTYPE __AllocateAvcPort(OMX_U32 port_index, OMX_DIRTYPE dir);
    OMX_ERRORTYPE __AllocateMpeg4Port(OMX_U32 port_index, OMX_DIRTYPE dir);
    OMX_ERRORTYPE __AllocateH263Port(OMX_U32 port_index, OMX_DIRTYPE dir);
    OMX_ERRORTYPE __AllocateRawPort(OMX_U32 port_index, OMX_DIRTYPE dir);
    OMX_ERRORTYPE __AllocateRawVAPort(OMX_U32 port_index, OMX_DIRTYPE dir);

    /* implement ComponentBase::ComponentGet/SetPatameter */
    virtual OMX_ERRORTYPE
    ComponentGetParameter(OMX_INDEXTYPE nParamIndex,
                          OMX_PTR pComponentParameterStructure);
    virtual OMX_ERRORTYPE
    ComponentSetParameter(OMX_INDEXTYPE nIndex,
                          OMX_PTR pComponentParameterStructure);

    /* implement ComponentBase::ComponentGet/SetConfig */
    virtual OMX_ERRORTYPE
    ComponentGetConfig(OMX_INDEXTYPE nIndex,
                       OMX_PTR pComponentConfigStructure);
    virtual OMX_ERRORTYPE
    ComponentSetConfig(OMX_INDEXTYPE nIndex,
                       OMX_PTR pComponentConfigStructure);

    /* implement ComponentBase::Processor[*] */
    virtual OMX_ERRORTYPE ProcessorInit(void);  /* Loaded to Idle */
    virtual OMX_ERRORTYPE ProcessorDeinit(void);/* Idle to Loaded */
    virtual OMX_ERRORTYPE ProcessorStart(void); /* Idle to Executing/Pause */
    virtual OMX_ERRORTYPE ProcessorStop(void);  /* Executing/Pause to Idle */
    virtual OMX_ERRORTYPE ProcessorPause(void); /* Executing to Pause */
    virtual OMX_ERRORTYPE ProcessorResume(void);/* Pause to Executing */
    virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 port_index);
    virtual OMX_ERRORTYPE ProcessorProcess(OMX_BUFFERHEADERTYPE **buffers,
                                           buffer_retain_t *retain,
                                           OMX_U32 nr_buffers);

    /* end of component methods & helpers */

    /*
     * vcp setting helpers
     */
    OMX_ERRORTYPE __RawChangePortParamWithVcp(MixVideoConfigParams *vcp,
            PortVideo *port);
    OMX_ERRORTYPE __AvcChangePortParamWithVcp(MixVideoConfigParams *vcp,
            PortAvc *port);
    OMX_ERRORTYPE __Mpeg4ChangePortParamWithVcp(MixVideoConfigParams *vcp,
            PortMpeg4 *port);
    OMX_ERRORTYPE ChangePortParamWithVcp(void);

    OMX_ERRORTYPE __AvcChangeVcpWithPortParam(MixVideoConfigParams *vcp,
            PortAvc *port, bool *vcp_changed);
    OMX_ERRORTYPE __Mpeg4ChangeVcpWithPortParam(MixVideoConfigParams *vcp,
            PortMpeg4 *port, bool *vcp_changed);
    OMX_ERRORTYPE __H263ChangeVcpWithPortParam(MixVideoConfigParams *vcp,
            PortH263 *port, bool *vcp_changed);
    OMX_ERRORTYPE ChangeVcpWithPortParam(MixVideoConfigParams *vcp,
                                         PortVideo *port, bool *vcp_changed);

    OMX_ERRORTYPE __AvcChangePortParamWithCodecData(const OMX_U8 *codec_data,
            OMX_U32 size,
            PortBase **ports);
    OMX_ERRORTYPE __Mpeg4ChangePortParamWithCodecData(const OMX_U8 *codec_data,
            OMX_U32 size,
            PortBase **ports);
    OMX_ERRORTYPE __H263ChangePortParamWithCodecData(const OMX_U8 *codec_data,
            OMX_U32 size,
            PortBase **ports);
    OMX_ERRORTYPE ChangePortParamWithCodecData(const OMX_U8 *codec_data,
            OMX_U32 size,
            PortBase **ports);

    static void AvcEncMixBufferCallback(ulong token, uchar *data);

    /* end of vcp setting helpers */

    /* mix video */
    MixVideo *mix;
    MixVideoInitParams *vip;
    MixParams *mvp;
    MixVideoConfigParams *vcp;
    MixDisplayAndroid *display;
    MixBuffer *mixbuffer_in[1];
    MixIOVec *mixiovec_out[1];

    OMX_VIDEO_CODINGTYPE coding_type;
    MixCodecMode codec_mode;

    OMX_BOOL is_mixvideodec_configured;

    OMX_U32 inframe_counter;
    OMX_U32 outframe_counter;

    /* for fps */
    OMX_TICKS last_ts;
    float last_fps;

    OMX_U8 *avc_enc_buffer;
    OMX_U32 avc_enc_buffer_offset;
    OMX_U32 avc_enc_buffer_length;
    OMX_U32 avc_enc_frame_size_left;

    OMX_NALUFORMATSTYPE avcEncNaluFormatType;
    OMX_U32 avcEncIDRPeriod;
    OMX_U32 avcEncPFrames;

    OMX_VIDEO_PARAM_INTEL_BITRATETYPE avcEncParamIntelBitrateType;
    OMX_VIDEO_CONFIG_INTEL_BITRATETYPE avcEncConfigIntelBitrateType;
    OMX_VIDEO_CONFIG_NALSIZE avcEncConfigNalSize;
    OMX_VIDEO_CONFIG_INTEL_SLICE_NUMBERS avcEncConfigSliceNumbers;
    OMX_VIDEO_CONFIG_INTEL_AIR avcEncConfigAir;
    OMX_CONFIG_FRAMERATETYPE avcEncFramerate;

    OMX_VIDEO_PARAM_INTEL_AVC_DECODE_SETTINGS avcDecodeSettings;
    OMX_U32 avcDecFrameWidth;
    OMX_U32 avcDecFrameHeight;
    OMX_BOOL avcDecGotRes;

    /* constant */
    /* ports */
    const static OMX_U32 NR_PORTS = 2;
    const static OMX_U32 INPORT_INDEX = 0;
    const static OMX_U32 OUTPORT_INDEX = 1;

    /* default buffer */
    //BZ 1286: change inport buffer number from 256 to 10 to cut down buffering time
    const static OMX_U32 INPORT_AVC_ACTUAL_BUFFER_COUNT = 10;
    const static OMX_U32 INPORT_AVC_MIN_BUFFER_COUNT = 1;
    const static OMX_U32 INPORT_AVC_BUFFER_SIZE = 1382400; //40960;
    const static OMX_U32 OUTPORT_AVC_ACTUAL_BUFFER_COUNT = 10;
    const static OMX_U32 OUTPORT_AVC_MIN_BUFFER_COUNT = 1;
    const static OMX_U32 OUTPORT_AVC_BUFFER_SIZE = 1382400; //480000;

    const static OMX_U32 INPORT_RAW_ACTUAL_BUFFER_COUNT = 5; //2;
    const static OMX_U32 INPORT_RAW_MIN_BUFFER_COUNT = 1;
    const static OMX_U32 INPORT_RAW_BUFFER_SIZE = 1382400;
    const static OMX_U32 OUTPORT_RAW_ACTUAL_BUFFER_COUNT = 2;
    const static OMX_U32 OUTPORT_RAW_MIN_BUFFER_COUNT = 1;
    const static OMX_U32 OUTPORT_RAW_BUFFER_SIZE = 1382400;

    const static OMX_U32 INPORT_MPEG4_ACTUAL_BUFFER_COUNT = 10;
    const static OMX_U32 INPORT_MPEG4_MIN_BUFFER_COUNT = 1;
//    const static OMX_U32 INPORT_MPEG4_BUFFER_SIZE = 16000;
    const static OMX_U32 INPORT_MPEG4_BUFFER_SIZE = 1382400;
    const static OMX_U32 OUTPORT_MPEG4_ACTUAL_BUFFER_COUNT = 2;
    const static OMX_U32 OUTPORT_MPEG4_MIN_BUFFER_COUNT = 1;
    const static OMX_U32 OUTPORT_MPEG4_BUFFER_SIZE = 1382400;

    const static OMX_U32 INPORT_H263_ACTUAL_BUFFER_COUNT = 10;
    const static OMX_U32 INPORT_H263_MIN_BUFFER_COUNT = 1;
    const static OMX_U32 INPORT_H263_BUFFER_SIZE = 1382400;
    const static OMX_U32 OUTPORT_H263_ACTUAL_BUFFER_COUNT = 2;
    const static OMX_U32 OUTPORT_H263_MIN_BUFFER_COUNT = 1;
    const static OMX_U32 OUTPORT_H263_BUFFER_SIZE = 1382400;
};

#endif /* __WRS_OMXIL_INTEL_MRST_PSB */