• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
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 VGS_IMG_H
17 #define VGS_IMG_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #include "hi_common.h"
23 #include "hi_comm_video.h"
24 #include "hi_comm_venc.h"
25 #include "ai_infer_process.h"
26 
27 #if __cplusplus
28 extern "C" {
29 #endif
30 
31 /*
32  * 常用数字单位
33  * Commonly used numerical units
34  */
35 #define HI_KB               1024
36 #define HI_MB               (1024 * 1024)
37 #define HI_MS_OF_SEC        1000 // 1s in milliseconds
38 #define HI_NS_OF_MS         1000000 // Nanoseconds in 1ms
39 #define HI_BYTE_BITS        8 // Number of bits in 1 byte
40 #define HI_INT8_BITS        8 // 8-bit integer number of bits
41 #define HI_INT16_BITS       16 // 16-bit integer number of bits
42 #define HI_INT32_BITS       32 // 32-bit integer number of bits
43 #define HI_INT64_BITS       64 // The number of bits of a 64-bit integer
44 
45 /*
46  * 帧缩放
47  * 多次调用vgs_resize以实现任意比例的缩放
48  * 为简化实现,约定每次缩放最大14倍,此时宽、高仅需2像素对齐
49  * 当两个方向缩放方向不同时,例如一向(如X)放大,另一向缩小倍,无需特别处理
50  * 此时某个方向或两个方向缩放比例均超标,也不需要特别处理
51  *
52  * resize frame.
53  * Call vgs_resize multiple times to achieve arbitrary scaling.
54  * In order to simplify the implementation, it is agreed that each zoom is up to 14 times,
55  * and at this time, the width and height only need to be aligned by 2 pixels.
56  * When the zoom directions are different in the two directions, for example,
57  * zooming in one direction (such as X) and zooming out in the other direction,
58  * no special processing is required. At this time, the zoom ratio in one direction or
59  * both directions exceeds the standard, and no special treatment is required.
60  */
61 int MppFrmResize(
62     const VIDEO_FRAME_INFO_S* src,
63     VIDEO_FRAME_INFO_S* dst,
64     uint32_t dstWidth, uint32_t dstHeight);
65 
66 /*
67  * 销毁帧
68  * Destory frame
69  */
70 void MppFrmDestroy(VIDEO_FRAME_INFO_S* frm);
71 
72 /*
73  * 在框架中叠加一个或多个矩形框
74  * Superimpose one or more rectangular boxes in the frame
75  */
76 int MppFrmDrawRects(VIDEO_FRAME_INFO_S *frm,
77     const RectBox *boxes, int boxesNum, uint32_t color, int thick);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 #endif
83