2 * Copyright 2012 Michael Chen <omxcodec@gmail.com>
3 * Copyright 2015 The CyanogenMod Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef SOFT_FFMPEGVIDEO_H_
20 #define SOFT_FFMPEGVIDEO_H_
22 #include "SoftVideoDecoderOMXComponent.h"
24 #include "utils/ffmpeg_utils.h"
28 struct SoftFFmpegVideo : public SoftVideoDecoderOMXComponent {
29 SoftFFmpegVideo(const char *name,
30 const char *componentRole,
31 OMX_VIDEO_CODINGTYPE codingType,
32 const CodecProfileLevel *profileLevels,
33 size_t numProfileLevels,
34 const OMX_CALLBACKTYPE *callbacks,
36 OMX_COMPONENTTYPE **component,
37 enum AVCodecID codecID);
40 static SoftOMXComponent* createSoftOMXComponent(
41 const char *name, const OMX_CALLBACKTYPE *callbacks,
42 OMX_PTR appData, OMX_COMPONENTTYPE **component);
45 virtual ~SoftFFmpegVideo();
47 virtual OMX_ERRORTYPE internalGetParameter(
48 OMX_INDEXTYPE index, OMX_PTR params);
50 virtual OMX_ERRORTYPE internalSetParameter(
51 OMX_INDEXTYPE index, const OMX_PTR params);
53 virtual void onQueueFilled(OMX_U32 portIndex);
54 virtual void onPortFlushCompleted(OMX_U32 portIndex);
55 virtual void onReset();
62 kNumOutputBuffers = 2,
74 ERR_OK = 0, //No errors
75 ERR_OOM = -1, //Out of memmory
76 ERR_CODEC_NOT_FOUND = -2,
77 ERR_DECODER_OPEN_FAILED = -2,
81 OMX_VIDEO_CODINGTYPE mCodingType;
82 bool mFFmpegAlreadyInited;
83 bool mCodecAlreadyOpened;
85 struct SwsContext *mImgConvertCtx;
91 bool mIgnoreExtradata;
94 int32_t mOutputHeight;
98 void initInputFormat(uint32_t mode, OMX_PARAM_PORTDEFINITIONTYPE *def);
99 void getInputFormat(uint32_t mode, OMX_VIDEO_PARAM_PORTFORMATTYPE *formatParams);
100 void setDefaultCtx(AVCodecContext *avctx, const AVCodec *codec);
101 OMX_ERRORTYPE isRoleSupported(const OMX_PARAM_COMPONENTROLETYPE *roleParams);
103 status_t initDecoder(enum AVCodecID codecID);
104 void deInitDecoder();
106 bool isPortSettingChanged();
108 int32_t handleExtradata();
109 int32_t openDecoder();
110 void initPacket(AVPacket *pkt, OMX_BUFFERHEADERTYPE *inHeader);
111 int32_t decodeVideo();
112 int32_t preProcessVideoFrame(AVPicture *picture, void **bufp);
113 int32_t drainOneOutputBuffer();
114 void drainEOSOutputBuffer();
115 void drainAllOutputBuffers();
116 bool handlePortSettingsChange();
118 DISALLOW_EVIL_CONSTRUCTORS(SoftFFmpegVideo);
121 } // namespace android
123 #endif // SOFT_FFMPEGVIDEO_H_