1 /*
2  * Copyright (C) 2019 The Android Open Source Project
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 __C2_DECODER_H__
18 #define __C2_DECODER_H__
19 
20 #include "BenchmarkC2Common.h"
21 
22 #define ALIGN(_sz, _align) (((_sz) + ((_align) - 1)) & ~((_align) - 1))
23 
24 class C2Decoder : public BenchmarkC2Common {
25   public:
C2Decoder()26     C2Decoder() : mOffset(0), mNumInputFrame(0), mComponent(nullptr) {}
27 
28     int32_t createCodec2Component(string codecName, AMediaFormat *format);
29 
30     int32_t decodeFrames(uint8_t *inputBuffer, vector<AMediaCodecBufferInfo> &frameInfo);
31 
32     void deInitCodec();
33 
34     void dumpStatistics(string inputReference, int64_t durationUs, string componentName,
35                         string statsFile);
36 
37     void resetDecoder();
38 
39   private:
40     int32_t mOffset;
41     int32_t mNumInputFrame;
42     vector<AMediaCodecBufferInfo> mFrameMetaData;
43 
44     std::shared_ptr<android::Codec2Client::Listener> mListener;
45     std::shared_ptr<android::Codec2Client::Component> mComponent;
46 };
47 
48 #endif  // __C2_DECODER_H__
49