OSDN Git Service

compile fixes, include bug "error: 'INT64_MIN' was not declared in this scope"
[android-x86/external-stagefright-plugins.git] / libstagefright / codecs / ffmpegdec / vdec / SoftFFmpegVideo.h
1 /*
2  * Copyright 2012 Michael Chen <omxcodec@gmail.com>
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_FFMPEGVIDEO_H_
18
19 #define SOFT_FFMPEGVIDEO_H_
20
21 #include "SimpleSoftOMXComponent.h"
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <inttypes.h>
28 #include <math.h>
29 #include <limits.h>
30 #include <signal.h>
31 #include <limits.h> /* INT_MAX */
32
33 #include "config.h"
34 #include "libavutil/avstring.h"
35 #include "libavutil/colorspace.h"
36 #include "libavutil/mathematics.h"
37 #include "libavutil/pixdesc.h"
38 #include "libavutil/imgutils.h"
39 #include "libavutil/dict.h"
40 #include "libavutil/parseutils.h"
41 #include "libavutil/samplefmt.h"
42 #include "libavutil/avassert.h"
43 #include "libavutil/intreadwrite.h"
44 #include "libavformat/avformat.h"
45 #include "libavdevice/avdevice.h"
46 #include "libswscale/swscale.h"
47 #include "libavcodec/audioconvert.h"
48 #include "libavutil/opt.h"
49 #include "libavutil/internal.h"
50 #include "libavcodec/avfft.h"
51 #include "libswresample/swresample.h"
52
53 #include "cmdutils.h"
54
55 #include <SDL.h>
56 #include <SDL_thread.h>
57
58 #ifdef __cplusplus
59 }
60 #endif
61
62 namespace android {
63
64 struct SoftFFmpegVideo : public SimpleSoftOMXComponent {
65     SoftFFmpegVideo(const char *name,
66             const OMX_CALLBACKTYPE *callbacks,
67             OMX_PTR appData,
68             OMX_COMPONENTTYPE **component);
69
70 protected:
71     virtual ~SoftFFmpegVideo();
72
73     virtual OMX_ERRORTYPE internalGetParameter(
74             OMX_INDEXTYPE index, OMX_PTR params);
75
76     virtual OMX_ERRORTYPE internalSetParameter(
77             OMX_INDEXTYPE index, const OMX_PTR params);
78
79     virtual void onQueueFilled(OMX_U32 portIndex);
80     virtual void onPortFlushCompleted(OMX_U32 portIndex);
81     virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
82
83 private:
84     enum {
85         kNumInputBuffers  = 5,
86         kNumOutputBuffers = 2,
87     };
88
89     enum {
90         MODE_H264,
91         MODE_MPEG4,
92         MODE_MPEG2,
93         MODE_H263,
94         MODE_VC1
95     } mMode;
96
97     enum {
98         kPortIndexInput  = 0,
99         kPortIndexOutput = 1,
100     };
101
102     AVCodecContext *mCtx;
103     struct SwsContext *mImgConvertCtx;
104
105     bool mExtradataReady;
106     bool mIgnoreExtradata;
107     bool mSignalledError;
108     int32_t mWidth, mHeight, mStride;
109
110     enum {
111         NONE,
112         AWAITING_DISABLED,
113         AWAITING_ENABLED
114     } mOutputPortSettingsChange;
115
116
117     status_t initFFmpeg();
118     void deInitFFmpeg();
119     void setAVCtxToDefault(AVCodecContext *avctx, const AVCodec *codec);
120
121     void initPorts();
122     status_t initDecoder();
123     void deInitDecoder();
124
125     void updatePortDefinitions();
126
127     DISALLOW_EVIL_CONSTRUCTORS(SoftFFmpegVideo);
128 };
129
130 }  // namespace android
131
132 #endif  // SOFT_FFMPEGVIDEO_H_