Home | History | Annotate | Download | only in videodecoder
      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 VIDEO_DECODER_AVC_H_
     18 #define VIDEO_DECODER_AVC_H_
     19 
     20 #include "VideoDecoderBase.h"
     21 
     22 
     23 class VideoDecoderAVC : public VideoDecoderBase {
     24 public:
     25     VideoDecoderAVC(const char *mimeType);
     26     virtual ~VideoDecoderAVC();
     27 
     28     virtual Decode_Status start(VideoConfigBuffer *buffer);
     29     virtual void stop(void);
     30     virtual void flush(void);
     31     virtual Decode_Status decode(VideoDecodeBuffer *buffer);
     32 
     33 protected:
     34     virtual Decode_Status decodeFrame(VideoDecodeBuffer *buffer, vbp_data_h264 *data);
     35     virtual Decode_Status beginDecodingFrame(vbp_data_h264 *data);
     36     virtual Decode_Status continueDecodingFrame(vbp_data_h264 *data);
     37     virtual Decode_Status decodeSlice(vbp_data_h264 *data, uint32_t picIndex, uint32_t sliceIndex);
     38     Decode_Status setReference(VASliceParameterBufferH264 *sliceParam);
     39     Decode_Status updateDPB(VAPictureParameterBufferH264 *picParam);
     40     Decode_Status updateReferenceFrames(vbp_picture_data_h264 *picData);
     41     void removeReferenceFromDPB(VAPictureParameterBufferH264 *picParam);
     42     int32_t getPOC(VAPictureH264 *pic); // Picture Order Count
     43     inline VASurfaceID findSurface(VAPictureH264 *pic);
     44     inline VideoSurfaceBuffer* findSurfaceBuffer(VAPictureH264 *pic);
     45     inline VideoSurfaceBuffer* findRefSurfaceBuffer(VAPictureH264 *pic);
     46     inline void invalidateDPB(int toggle);
     47     inline void clearAsReference(int toggle);
     48     Decode_Status startVA(vbp_data_h264 *data);
     49     void updateFormatInfo(vbp_data_h264 *data);
     50     Decode_Status handleNewSequence(vbp_data_h264 *data);
     51     bool isNewFrame(vbp_data_h264 *data, bool equalPTS);
     52     int32_t getDPBSize(vbp_data_h264 *data);
     53     virtual Decode_Status checkHardwareCapability();
     54 #ifdef USE_AVC_SHORT_FORMAT
     55     virtual Decode_Status getCodecSpecificConfigs(VAProfile profile, VAConfigID*config);
     56 #endif
     57     bool isWiDiStatusChanged();
     58 
     59 private:
     60     struct DecodedPictureBuffer {
     61         VideoSurfaceBuffer *surfaceBuffer;
     62         int32_t poc; // Picture Order Count
     63     };
     64 
     65     enum {
     66         AVC_EXTRA_SURFACE_NUMBER = 11,
     67         // maximum DPB (Decoded Picture Buffer) size
     68         MAX_REF_NUMBER = 16,
     69         DPB_SIZE = 17,         // DPB_SIZE = MAX_REF_NUMBER + 1,
     70         REF_LIST_SIZE = 32,
     71     };
     72 
     73     // maintain 2 ping-pong decoded picture buffers
     74     DecodedPictureBuffer mDPBs[2][DPB_SIZE];
     75     uint8_t mToggleDPB; // 0 or 1
     76     bool mErrorConcealment;
     77     uint32_t mLastPictureFlags;
     78     VideoExtensionBuffer mExtensionBuffer;
     79     PackedFrameData mPackedFrame;
     80     bool mAdaptive;
     81 };
     82 
     83 
     84 
     85 #endif /* VIDEO_DECODER_AVC_H_ */
     86