Home | History | Annotate | Download | only in libheif
      1 /*
      2  * Copyright (C) 2017 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 _HEIF_DECODER_IMPL_
     18 #define _HEIF_DECODER_IMPL_
     19 
     20 #include "include/HeifDecoderAPI.h"
     21 #include <system/graphics.h>
     22 #include <utils/RefBase.h>
     23 
     24 namespace android {
     25 
     26 class IDataSource;
     27 class IMemory;
     28 class MediaMetadataRetriever;
     29 
     30 /*
     31  * An implementation of HeifDecoder based on Android's MediaMetadataRetriever.
     32  */
     33 class HeifDecoderImpl : public HeifDecoder {
     34 public:
     35 
     36     HeifDecoderImpl();
     37     ~HeifDecoderImpl() override;
     38 
     39     bool init(HeifStream* stream, HeifFrameInfo* frameInfo) override;
     40 
     41     bool getEncodedColor(HeifEncodedColor* outColor) const override;
     42 
     43     bool setOutputColor(HeifColorFormat heifColor) override;
     44 
     45     bool decode(HeifFrameInfo* frameInfo) override;
     46 
     47     bool getScanline(uint8_t* dst) override;
     48 
     49     size_t skipScanlines(size_t count) override;
     50 
     51 private:
     52     sp<IDataSource> mDataSource;
     53     sp<MediaMetadataRetriever> mRetriever;
     54     sp<IMemory> mFrameMemory;
     55     android_pixel_format_t mOutputColor;
     56     size_t mCurScanline;
     57     bool mFrameDecoded;
     58 };
     59 
     60 } // namespace android
     61 
     62 #endif // _HEIF_DECODER_IMPL_
     63