OMXVideoDecoderBase.h revision 747c717e9477b5b660f39a2b737de5e968fa7f9d
1/*
2* Copyright (c) 2009-2011 Intel Corporation.  All rights reserved.
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
18#ifndef OMX_VIDEO_DECODER_BASE_H_
19#define OMX_VIDEO_DECODER_BASE_H_
20
21
22#include "OMXComponentCodecBase.h"
23#include "VideoDecoderInterface.h"
24#include "VideoDecoderHost.h"
25
26static const char* VA_VED_RAW_MIME_TYPE = "video/x-raw-vaved";
27static const uint32_t VA_VED_COLOR_FORMAT = 0x20;
28
29
30class OMXVideoDecoderBase : public OMXComponentCodecBase {
31public:
32    OMXVideoDecoderBase();
33    virtual ~OMXVideoDecoderBase();
34
35protected:
36    virtual OMX_ERRORTYPE InitInputPort(void);
37    virtual OMX_ERRORTYPE InitOutputPort(void);
38    virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *input) = 0;
39    virtual OMX_ERRORTYPE InitOutputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *output);
40
41    virtual OMX_ERRORTYPE ProcessorInit(void);
42    virtual OMX_ERRORTYPE ProcessorDeinit(void);
43    //virtual OMX_ERRORTYPE ProcessorStart(void);
44    virtual OMX_ERRORTYPE ProcessorStop(void);
45    //virtual OMX_ERRORTYPE ProcessorPause(void);
46    //virtual OMX_ERRORTYPE ProcessorResume(void);
47    virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 portIndex);
48    virtual OMX_ERRORTYPE ProcessorProcess(
49            OMX_BUFFERHEADERTYPE ***pBuffers,
50            buffer_retain_t *retains,
51            OMX_U32 numberBuffers);
52
53    virtual bool IsAllBufferAvailable(void);
54    virtual OMX_ERRORTYPE ProcessorPreFillBuffer(OMX_BUFFERHEADERTYPE* buffer);
55    virtual OMX_ERRORTYPE ProcessorPreFreeBuffer(OMX_U32 nPortIndex,OMX_BUFFERHEADERTYPE * pBuffer);
56    virtual OMX_ERRORTYPE PrepareConfigBuffer(VideoConfigBuffer *p);
57    virtual OMX_ERRORTYPE PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p);
58    virtual OMX_ERRORTYPE FillRenderBuffer(OMX_BUFFERHEADERTYPE **pBuffer,  buffer_retain_t *retain, OMX_U32 inportBufferFlags);
59    virtual OMX_ERRORTYPE HandleFormatChange(void);
60    virtual OMX_ERRORTYPE TranslateDecodeStatus(Decode_Status status);
61    virtual OMX_ERRORTYPE MapRawNV12(const VideoRenderBuffer* renderBuffer, OMX_U8 *rawData, OMX_U32& size);
62
63    virtual OMX_ERRORTYPE BuildHandlerList(void);
64    DECLARE_HANDLER(OMXVideoDecoderBase, ParamVideoPortFormat);
65    DECLARE_HANDLER(OMXVideoDecoderBase, CapabilityFlags);
66    DECLARE_HANDLER(OMXVideoDecoderBase, NativeBufferUsage);
67    DECLARE_HANDLER(OMXVideoDecoderBase, NativeBuffer);
68    DECLARE_HANDLER(OMXVideoDecoderBase, NativeBufferMode);
69
70private:
71    enum {
72        // OMX_PARAM_PORTDEFINITIONTYPE
73        INPORT_MIN_BUFFER_COUNT = 1,
74        INPORT_ACTUAL_BUFFER_COUNT = 256,
75        INPORT_BUFFER_SIZE = 1382400,
76
77        // OMX_PARAM_PORTDEFINITIONTYPE
78        OUTPORT_MIN_BUFFER_COUNT = 1,
79        OUTPORT_ACTUAL_BUFFER_COUNT = 4,
80        OUTPORT_BUFFER_SIZE = 1382400,
81
82        OUTPORT_NATIVE_BUFFER_COUNT = 10,
83    };
84    uint32_t mOMXBufferHeaderTypePtrNum;
85    OMX_BUFFERHEADERTYPE *mOMXBufferHeaderTypePtrArray[MAX_GRAPHIC_NUM];
86    uint32_t mGraphicBufferStride;
87    uint32_t mGraphicBuffercolorformat;
88
89protected:
90    IVideoDecoder *mVideoDecoder;
91    bool mNativeBufferMode;
92    int  mNativeBufferCount;
93};
94
95#endif /* OMX_VIDEO_DECODER_BASE_H_ */
96