1 /* 2 * Copyright 2022 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 GOLDFISH_H264_HELPER_H_ 18 #define GOLDFISH_H264_HELPER_H_ 19 20 #include <inttypes.h> 21 #include "ih264_typedefs.h" 22 #include "ih264d.h" 23 24 25 namespace android { 26 27 // this class is just to provide some functions to decode header 28 // so that we know w/h of each sps 29 class GoldfishH264Helper { 30 public: 31 GoldfishH264Helper(int w, int h); 32 ~GoldfishH264Helper(); 33 34 // check whether the frame is sps; typical h264 will have 35 // a frame that is sps/pps together 36 static bool isSpsFrame(const uint8_t* frame, int inSize); 37 public: 38 // return true if decoding finds out w/h changed; 39 // otherwise false 40 bool decodeHeader(const uint8_t *frame, int inSize); getWidth()41 int getWidth() const { return mWidth; } getHeight()42 int getHeight() const { return mHeight; } 43 44 private: 45 void createDecoder(); 46 void destroyDecoder(); 47 void resetDecoder(); 48 void setNumCores(); 49 void setParams(size_t stride, IVD_VIDEO_DECODE_MODE_T dec_mode); 50 bool setDecodeArgs(ivd_video_decode_ip_t *ps_decode_ip, 51 ivd_video_decode_op_t *ps_decode_op, 52 const uint8_t *inBuffer, uint32_t displayStride, 53 size_t inOffset, size_t inSize, uint32_t tsMarker); 54 55 private: 56 iv_obj_t *mDecHandle = nullptr; 57 int mWidth = 320; 58 int mHeight = 240; 59 int mNumCores = 1; 60 int mStride = 16; 61 int mOutputDelay = 8; // default 62 IV_COLOR_FORMAT_T mIvColorformat = IV_YUV_420P; 63 }; 64 65 } // namespace android 66 #endif 67