/* * Copyright (C) 2019 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 ANDROID_SERVERS_CAMERA_HEICENCODER_INFO_MANAGER_H #define ANDROID_SERVERS_CAMERA_HEICENCODER_INFO_MANAGER_H #include #include #include #include #include #include namespace android { namespace camera3 { class HeicEncoderInfoManager { public: static HeicEncoderInfoManager& getInstance() { static HeicEncoderInfoManager instance; return instance; } bool isSizeSupported(int32_t width, int32_t height, bool* useHeic, bool* useGrid, int64_t* stall, AString* hevcName) const; // kGridWidth and kGridHeight should be 2^n static const auto kGridWidth = 512; static const auto kGridHeight = 512; private: struct SizePairHash { std::size_t operator () (const std::pair &p) const { return p.first * 31 + p.second; } }; typedef std::unordered_map, std::pair, SizePairHash> FrameRateMaps; HeicEncoderInfoManager(); virtual ~HeicEncoderInfoManager(); status_t initialize(); status_t getFrameRateMaps(sp details, FrameRateMaps* maps); status_t getCodecSizeRange(const char* codecName, sp details, std::pair* minSize, std::pair* maxSize, FrameRateMaps* frameRateMaps); FrameRateMaps::const_iterator findClosestSize(const FrameRateMaps& maps, int32_t width, int32_t height) const; sp getCodecDetails(sp codecsList, const char* name); bool getHevcCodecDetails(sp codecsList, const char* mime); bool mIsInited; std::pair mMinSizeHeic, mMaxSizeHeic; std::pair mMinSizeHevc, mMaxSizeHevc; bool mHasHEVC, mHasHEIC; AString mHevcName; FrameRateMaps mHeicFrameRateMaps, mHevcFrameRateMaps; bool mDisableGrid; }; } // namespace camera3 } // namespace android #endif // ANDROID_SERVERS_CAMERA_HEICENCODER_INFO_MANAGER_H