Home | History | Annotate | Download | only in videocodec
      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 #ifndef OMX_VIDEO_DECODER_AVC_H_
     18 #define OMX_VIDEO_DECODER_AVC_H_
     19 
     20 
     21 #include "OMXVideoDecoderBase.h"
     22 
     23 class OMXVideoDecoderAVC : public OMXVideoDecoderBase {
     24 public:
     25     OMXVideoDecoderAVC();
     26     virtual ~OMXVideoDecoderAVC();
     27 
     28 protected:
     29     virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput);
     30     virtual OMX_ERRORTYPE ProcessorInit(void);
     31     virtual OMX_ERRORTYPE ProcessorDeinit(void);
     32     virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 portIndex);
     33     virtual OMX_ERRORTYPE ProcessorProcess(
     34             OMX_BUFFERHEADERTYPE ***pBuffers,
     35             buffer_retain_t *retains,
     36             OMX_U32 numberBuffers);
     37 
     38    virtual OMX_ERRORTYPE PrepareConfigBuffer(VideoConfigBuffer *p);
     39    virtual OMX_ERRORTYPE PrepareDecodeBuffer(OMX_BUFFERHEADERTYPE *buffer, buffer_retain_t *retain, VideoDecodeBuffer *p);
     40 
     41    virtual OMX_ERRORTYPE BuildHandlerList(void);
     42    virtual OMX_ERRORTYPE SetMaxOutputBufferCount(OMX_PARAM_PORTDEFINITIONTYPE *p);
     43    virtual OMX_COLOR_FORMATTYPE GetOutputColorFormat(int width);
     44    DECLARE_HANDLER(OMXVideoDecoderAVC, ParamVideoAvc);
     45    DECLARE_HANDLER(OMXVideoDecoderAVC, ParamIntelAVCDecodeSettings);
     46    DECLARE_HANDLER(OMXVideoDecoderAVC, ParamVideoAVCProfileLevel);
     47 
     48 private:
     49     inline OMX_ERRORTYPE AccumulateBuffer(OMX_BUFFERHEADERTYPE *buffer);
     50     inline OMX_ERRORTYPE FillDecodeBuffer(VideoDecodeBuffer *p);
     51 
     52 private:
     53     enum {
     54         // OMX_PARAM_PORTDEFINITIONTYPE
     55         INPORT_MIN_BUFFER_COUNT = 1,
     56         INPORT_ACTUAL_BUFFER_COUNT = 5,
     57         INPORT_BUFFER_SIZE = 1382400,
     58 
     59         // for OMX_VIDEO_PARAM_INTEL_AVC_DECODE_SETTINGS
     60         // default number of reference frame
     61         NUM_REFERENCE_FRAME = 4,
     62 
     63         // extra number of reference frame to allocate for video conferencing use case.
     64         // total number of reference frame allocated by default  in video conferencing use case is 10.
     65         EXTRA_REFERENCE_FRAME = 6,
     66 
     67         // a typical value for 1080p clips
     68         OUTPORT_NATIVE_BUFFER_COUNT = 11,
     69 
     70         MAX_OUTPORT_BUFFER_COUNT = 23,
     71     };
     72 
     73     OMX_VIDEO_PARAM_AVCTYPE mParamAvc;
     74 
     75     // This parameter is used for video conferencing use case. Application or OMX client can preset
     76     // maximum video size and maximum reference frame (default value is NUM_REFERENCE_FRAME). Using these
     77     // information OMX AVC decoder can start up video decoder library without paring configuration data, or start up
     78     // video decoder at earlier stage.
     79     // If actual video size is less than the maximum video size, frame cropping will be used in the encoder side.
     80     OMX_VIDEO_PARAM_INTEL_AVC_DECODE_SETTINGS mDecodeSettings;
     81 
     82 private:
     83     OMX_U8 *mAccumulateBuffer;
     84     OMX_U32 mBufferSize;
     85     OMX_U32 mFilledLen;
     86     OMX_TICKS mTimeStamp;
     87 };
     88 
     89 #endif /* OMX_VIDEO_DECODER_AVC_H_ */
     90