1 /*
2  * Copyright (C) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FRAMEWORKS_INNERKITSIMPL_ACCESSOR_INCLUDE_TIFF_PARSER_H
17 #define FRAMEWORKS_INNERKITSIMPL_ACCESSOR_INCLUDE_TIFF_PARSER_H
18 
19 #include <algorithm>
20 #include <cstddef>
21 #include <cstdint>
22 #include <fstream>
23 #include <map>
24 #include <stdint.h>
25 #include <vector>
26 
27 #include <libexif/exif-data.h>
28 
29 #include "data_buf.h"
30 
31 namespace OHOS {
32 namespace Media {
33 namespace {
34     using uint_8 = byte;
35 }
36 class TiffParser {
37 public:
38     // For tiff exif, decode exif buffer to ExifData struct.
39     static void Decode(const unsigned char *dataPtr, const uint32_t &size, ExifData **exifData);
40     // For tiff exif, encode ExifData struct to exif buffer
41     static void Encode(unsigned char **dataPtr, uint32_t &size, ExifData *exifData);
42 
43     // For jpeg exif, decode exif buffer to ExifData struct
44     static void DecodeJpegExif(const unsigned char *dataPtr, const uint32_t &size, ExifData **exifData);
45     // For jpeg exif, encode ExifData struct to exif buffer
46     static void EncodeJpegExif(unsigned char **dataPtr, uint32_t &size, ExifData *exifData);
47 
48     // For tiff, find tiff header pos
49     static size_t FindTiffPos(const DataBuf &dataBuf);
50     static size_t FindTiffPos(const byte *dataBuf, size_t bufLength);
51 };
52 
53 
54 } // namespace Media
55 } // namespace OHOS
56 #endif // FRAMEWORKS_INNERKITSIMPL_ACCESSOR_INCLUDE_TIFF_PARSER_H
57