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_MPEG2_H_
18 #define VIDEO_DECODER_MPEG2_H_
19 
20 #include "VideoDecoderBase.h"
21 
22 #ifndef TIANMI_DEBUG
23 #define TIANMI_DEBUG
24 #endif
25 
26 
27 class VideoDecoderMPEG2 : public VideoDecoderBase {
28 public:
29     VideoDecoderMPEG2(const char *mimeType);
30     virtual ~VideoDecoderMPEG2();
31 
32     virtual Decode_Status start(VideoConfigBuffer *buffer);
33     virtual void stop(void);
34     virtual void flush(void);
35     virtual Decode_Status decode(VideoDecodeBuffer *buffer);
36 
37 protected:
38     virtual Decode_Status checkHardwareCapability();
39 
40 private:
41     Decode_Status decodeFrame(VideoDecodeBuffer *buffer, vbp_data_mpeg2 *data);
42     //Decode_Status beginDecodingFrame(vbp_data_mp42 *data);
43     //Decode_Status continueDecodingFrame(vbp_data_mp42 *data);
44     Decode_Status decodePicture(vbp_data_mpeg2 *data, int picIndex);
45     Decode_Status decodeSlice(vbp_data_mpeg2 *data, int picIndex, int slcIndex);
46     Decode_Status setReference(VAPictureParameterBufferMPEG2 *picParam);
47     Decode_Status startVA(vbp_data_mpeg2 *data);
48     void updateFormatInfo(vbp_data_mpeg2 *data);
49     inline Decode_Status allocateVABufferIDs(int32_t number);
50 
51 private:
52     enum {
53         MPEG2_PICTURE_TYPE_I = 1,
54         MPEG2_PICTURE_TYPE_P = 2,
55         MPEG2_PICTURE_TYPE_B = 3
56     };
57 
58     enum {
59         MPEG2_PIC_STRUCT_TOP       = 1,
60         MPEG2_PIC_STRUCT_BOTTOM    = 2,
61         MPEG2_PIC_STRUCT_FRAME     = 3
62     };
63 
64     enum {
65         MPEG2_SURFACE_NUMBER = 10,
66     };
67 
68     VABufferID *mBufferIDs;
69     int32_t mNumBufferIDs;
70 };
71 
72 #endif /* VIDEO_DECODER_MPEG2_H_ */
73