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_VP8_H_
18 #define VIDEO_DECODER_VP8_H_
19 
20 #include "VideoDecoderBase.h"
21 
22 
23 class VideoDecoderVP8 : public VideoDecoderBase {
24 public:
25     VideoDecoderVP8(const char *mimeType);
26     virtual ~VideoDecoderVP8();
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 checkHardwareCapability();
35 
36 private:
37     Decode_Status decodeFrame(VideoDecodeBuffer* buffer, vbp_data_vp8 *data);
38     Decode_Status decodePicture(vbp_data_vp8 *data, int32_t picIndex);
39     Decode_Status setReference(VAPictureParameterBufferVP8 *picParam);
40     Decode_Status startVA(vbp_data_vp8 *data);
41     void updateReferenceFrames(vbp_data_vp8 *data);
42     void refreshLastReference(vbp_data_vp8 *data);
43     void refreshGoldenReference(vbp_data_vp8 *data);
44     void refreshAltReference(vbp_data_vp8 *data);
45     void updateFormatInfo(vbp_data_vp8 *data);
46     void invalidateReferenceFrames(int toggle);
47     void clearAsReference(int toggle, int ref_type);
48 
49 private:
50     enum {
51         VP8_SURFACE_NUMBER = 9,
52         VP8_REF_SIZE = 3,
53     };
54 
55     enum {
56         VP8_KEY_FRAME = 0,
57         VP8_INTER_FRAME,
58         VP8_SKIPPED_FRAME,
59     };
60 
61     enum {
62         VP8_LAST_REF_PIC = 0,
63         VP8_GOLDEN_REF_PIC,
64         VP8_ALT_REF_PIC,
65     };
66 
67     enum {
68         BufferCopied_NoneToGolden   = 0,
69         BufferCopied_LastToGolden   = 1,
70         BufferCopied_AltRefToGolden = 2
71     };
72 
73     enum {
74         BufferCopied_NoneToAltRef   = 0,
75         BufferCopied_LastToAltRef   = 1,
76         BufferCopied_GoldenToAltRef = 2
77     };
78 
79     struct ReferenceFrameBuffer {
80         VideoSurfaceBuffer *surfaceBuffer;
81         int32_t index;
82     };
83 
84     //[2] : [0 for current each reference frame, 1 for the previous each reference frame]
85     //[VP8_REF_SIZE] : [0 for last ref pic, 1 for golden ref pic, 2 for alt ref pic]
86     ReferenceFrameBuffer mRFBs[2][VP8_REF_SIZE];
87 };
88 
89 
90 
91 #endif /* VIDEO_DECODER_VP8_H_ */
92