blob: 1594b4d0d45be1cf89f4ed7a91ea6152795afc78 [file] [log] [blame]
Andreas Huber4b3913a2011-05-11 14:13:42 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SOFT_AVC_H_
18
19#define SOFT_AVC_H_
20
21#include "SimpleSoftOMXComponent.h"
22
23struct tagAVCHandle;
24
25namespace android {
26
27struct SoftAVC : public SimpleSoftOMXComponent {
28 SoftAVC(const char *name,
29 const OMX_CALLBACKTYPE *callbacks,
30 OMX_PTR appData,
31 OMX_COMPONENTTYPE **component);
32
33protected:
34 virtual ~SoftAVC();
35
36 virtual OMX_ERRORTYPE internalGetParameter(
37 OMX_INDEXTYPE index, OMX_PTR params);
38
39 virtual OMX_ERRORTYPE internalSetParameter(
40 OMX_INDEXTYPE index, const OMX_PTR params);
41
42 virtual OMX_ERRORTYPE getConfig(OMX_INDEXTYPE index, OMX_PTR params);
43
44 virtual void onQueueFilled(OMX_U32 portIndex);
45 virtual void onPortFlushCompleted(OMX_U32 portIndex);
46 virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
47
48private:
49 enum {
50 kNumInputBuffers = 4,
51 kNumOutputBuffers = 18,
52 };
53
54 enum EOSStatus {
55 INPUT_DATA_AVAILABLE,
56 INPUT_EOS_SEEN,
57 OUTPUT_FRAMES_FLUSHED,
58 };
59
60 tagAVCHandle *mHandle;
61
62 size_t mInputBufferCount;
63
64 int32_t mWidth, mHeight;
65 int32_t mCropLeft, mCropTop, mCropRight, mCropBottom;
66
67 bool mSPSSeen, mPPSSeen;
68
69 int64_t mCurrentTimeUs;
70
71 EOSStatus mEOSStatus;
72
73 enum {
74 NONE,
75 AWAITING_DISABLED,
76 AWAITING_ENABLED
77 } mOutputPortSettingsChange;
78
79 void initPorts();
80 status_t initDecoder();
81
82 status_t decodeFragment(
83 const uint8_t *fragPtr, size_t fragSize,
84 bool *releaseFrames,
85 OMX_BUFFERHEADERTYPE **outHeader);
86
87 void updatePortDefinitions();
88 bool drainOutputBuffer(OMX_BUFFERHEADERTYPE **outHeader);
89
90 static int32_t ActivateSPSWrapper(
91 void *userData, unsigned int sizeInMbs, unsigned int numBuffers);
92
93 static int32_t BindFrameWrapper(
94 void *userData, int32_t index, uint8_t **yuv);
95
96 static void UnbindFrame(void *userData, int32_t index);
97
98 int32_t activateSPS(
99 unsigned int sizeInMbs, unsigned int numBuffers);
100
101 int32_t bindFrame(int32_t index, uint8_t **yuv);
102
103 DISALLOW_EVIL_CONSTRUCTORS(SoftAVC);
104};
105
106} // namespace android
107
108#endif // SOFT_AVC_H_
109