aboutsummaryrefslogtreecommitdiff
path: root/system/codecs/c2/decoders/hevcdec/GoldfishHevcHelper.h
blob: 09de830161e144d304b12fe29bd55d1a583bd6fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef GOLDFISH_HEVC_HELPER_H_
#define GOLDFISH_HEVC_HELPER_H_

#include <inttypes.h>
#include "ihevc_typedefs.h"
#include "ihevcd_cxa.h"


namespace android {

// this class is just to provide some functions to decode header
// so that we know w/h of each sps
class GoldfishHevcHelper {
  public:
    GoldfishHevcHelper(int w, int h);
    ~GoldfishHevcHelper();

    // check whether the frame is vps; typical hevc will have
    // a frame that is vps/sps/pps together
    static bool isVpsFrame(const uint8_t* frame, int inSize);
  public:
    // return true if decoding finds out w/h changed;
    // otherwise false
    bool decodeHeader(const uint8_t *frame, int inSize);
    int getWidth() const { return mWidth; }
    int getHeight() const { return mHeight; }

  private:
    void createDecoder();
    void destroyDecoder();
    void resetDecoder();
    void setNumCores();
    void setParams(size_t stride, IVD_VIDEO_DECODE_MODE_T dec_mode);
    bool setDecodeArgs(ivd_video_decode_ip_t *ps_decode_ip,
                       ivd_video_decode_op_t *ps_decode_op,
                       const uint8_t *inBuffer, uint32_t displayStride,
                       size_t inOffset, size_t inSize, uint32_t tsMarker);

  private:
    iv_obj_t *mDecHandle = nullptr;
    int mWidth = 320;
    int mHeight = 240;
    int mNumCores = 1;
    int mStride = 16;
    int mOutputDelay = 8; // default
    IV_COLOR_FORMAT_T mIvColorformat = IV_YUV_420P;
};

} // namespace android
#endif