• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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 /**
17 * @addtogroup Codec
18 * @{
19 *
20 * @brief Defines APIs of the image Codec module.
21 *
22 * The Codec module provides APIs for image codec, setting codec parameters,
23 * and controlling and transferring image data.
24 *
25 * @since 4.0
26 * @version 1.0
27 */
28
29/**
30 * @file CodecImageTypes.idl
31 *
32 * @brief Defines custom data types used in the image Codec module APIs,
33 * including the codec image parameters, types and buffers.
34 *
35 *
36 * @since 4.0
37 * @version 1.0
38 */
39
40/**
41 * @brief Defines the path for the package of the image Codec module APIs.
42 *
43 * @since 4.0
44 * @version 1.0
45 */
46package ohos.hdi.codec.image.v1_0;
47
48/**
49 * @brief Defines the image region information.
50 */
51struct CodecImageRegion {
52    unsigned int left;      /**< Distance to the left of the image. */
53    unsigned int right;     /**< Distance to the right of the image. */
54    unsigned int top;       /**< Distance to the top of the image. */
55    unsigned int bottom;    /**< Distance to the bottom of the image. */
56    unsigned int flag;      /**< True is use regionInfo. */
57    unsigned int rsv;       /**< Reserved for extend. */
58};
59
60/**
61 * @brief Enumerates the types of image that can be encoded or decoded
62 */
63enum CodecImageRole {
64    CODEC_IMAGE_JPEG = 0,       /**< Jpeg image. */
65    CODEC_IMAGE_HEIF,           /**< Heif image. */
66    CODEC_IMAGE_INVALID,        /**< Invalid image type. */
67};
68
69/**
70 * @brief Defines the codec image buffer information.
71 */
72struct CodecImageBuffer {
73    unsigned int id;            /**< Buffer ID. */
74    unsigned int size;          /**< Size of buffer. */
75    NativeBuffer buffer;        /**< Buffer handle used for encoding or decoding. For details,
76                                     see {@link NativeBuffer}. */
77    FileDescriptor fenceFd;     /**< Fence file descriptor. */
78    CodecImageRole bufferRole;  /**< Image buffer role, see {@link CodecImageRole}. */
79};
80
81/**
82 * @brief Defines the image codec type.
83 */
84enum CodecImageType {
85    CODEC_IMAGE_TYPE_DECODER = 0,     /**< Image decoder. */
86    CODEC_IMAGE_TYPE_ENCODER,         /**< Image encoder. */
87    CODEC_IMAGE_TYPE_INVALID,         /**< Invalid type. */
88};
89
90/**
91 * @brief Defines the image codec capabilities.
92 */
93struct CodecImageCapability {
94    String name;                        /**< Name of the image codec. */
95    enum CodecImageRole role;           /**< Role of the image codec. */
96    enum CodecImageType type;           /**< Type of the image codec. */
97    unsigned int widthAlignment;        /**< Alignment value of the width. */
98    unsigned int heightAlignment;       /**< Alignment value of the height. */
99    unsigned int maxSample;             /**< Maximum sample. */
100    unsigned int maxWidth;              /**< Maximum width. */
101    unsigned int maxHeight;             /**< Maximum height. */
102    unsigned int minWidth;              /**< Minimum width. */
103    unsigned int minHeight;             /**< Minimum height. */
104    unsigned int maxInst;               /**< Maximum instance. */
105    unsigned int[] supportPixFmts;      /**< Supported PixFormat. For details, see {@link PixFormat}. */
106    boolean isSoftwareCodec;            /**< Whether it is a software codec. */
107};
108
109/**
110 * @brief Defines the jpeg image quant table information.
111 */
112struct CodecJpegQuantTable {
113    unsigned short[] quantVal;          /**< Quant table value. */
114    boolean tableFlag;                  /**< True when quant has been output. */
115};
116
117/**
118 * @brief Defines the jpeg image huff table information.
119 */
120struct CodecJpegHuffTable {
121    unsigned char[] bits;               /**< Bits value, bits[0] is unused. */
122    unsigned char[] huffVal;            /**< Huff table value. */
123    boolean tableFlag;                  /**< True when huff table valid. */
124};
125
126/**
127 * @brief Defines the jpeg image huff table information.
128 */
129struct CodecJpegCompInfo {
130    unsigned int componentId;           /**< CompInfo index in JpegDecInfo. */
131    unsigned int componentIndex;        /**< CompInfo index in JpegDecInfo. */
132    unsigned int hSampFactor;           /**< Horizontal sample factor. */
133    unsigned int vSampFactor;           /**< vertical sample factor. */
134    unsigned int quantTableNo;          /**< Quant table value. */
135    unsigned int dcTableNo;             /**< Dc table index. */
136    unsigned int acTableNo;             /**< Ac table index. */
137    boolean infoFlag;
138};
139
140/**
141 * @brief Defines the jpeg image decode information.
142 */
143struct CodecJpegDecInfo {
144    unsigned int imageWidth;                        /**< Image width. */
145    unsigned int imageHeight;                       /**< Image height. */
146    unsigned int dataPrecision;                     /**< Bit height. */
147    unsigned int numComponents;                     /**< Num of color component in jpeg image. */
148    unsigned int restartInterval;                   /**< MCUs per restart. */
149    boolean arithCode;                              /**< False is Huff coding,
150                                                         true is arithmetic coding. */
151    boolean progressiveMode;                        /**< If SOF specifiy progressive mode. */
152    struct CodecJpegCompInfo[] compInfo;            /**< Jpeg compress information. */
153    struct CodecJpegHuffTable[] dcHuffTbl;          /**< Dc huffman table information. */
154    struct CodecJpegHuffTable[] acHuffTbl;          /**< Ac huffman table information. */
155    struct CodecJpegQuantTable[] quantTbl;          /**< Quant table information. */
156    struct CodecImageRegion region;                 /**< Image region information. */
157    unsigned int sampleSize;                        /**< Image sample size. */
158    unsigned int compressPos;                       /**< The offset of Jpeg compressed data. */
159};
160