hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright 2019 Fuzhou Rockchip Electronics Co., Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
 
#ifndef EASYMEDIA_IMAGE_H_
#define EASYMEDIA_IMAGE_H_
 
#ifdef __cplusplus
extern "C" {
#endif
 
typedef enum
{
    PIX_FMT_NONE = -1,
    PIX_FMT_YUV420P,
    PIX_FMT_NV12,
    PIX_FMT_NV21,
    PIX_FMT_YUV422P,
    PIX_FMT_NV16,
    PIX_FMT_NV61,
    PIX_FMT_YUYV422,
    PIX_FMT_UYVY422,
    PIX_FMT_RGB332,
    PIX_FMT_RGB565,
    PIX_FMT_BGR565,
    PIX_FMT_RGB888,
    PIX_FMT_BGR888,
    PIX_FMT_ARGB8888,
    PIX_FMT_ABGR8888,
    // Compound type
    PIX_FMT_FBC0,
    PIX_FMT_FBC2,
    PIX_FMT_NB
} PixelFormat;
 
typedef struct {
    PixelFormat pix_fmt;
    int width;     // valid pixel width
    int height;    // valid pixel height
    int vir_width; // stride width, same to buffer_width, must greater than
    // width, often set vir_width=(width+15)&(~15)
    int vir_height; // stride height, same to buffer_height, must greater than
                    // height, often set vir_height=(height+15)&(~15)
} ImageInfo;
 
typedef struct {
    int x, y; // left, top
    int w, h; // width, height
} ImageRect;
 
#ifdef __cplusplus
}
#endif
 
#include "utils.h"
 
_API void GetPixFmtNumDen(const PixelFormat& fmt, int& num, int& den);
_API int CalPixFmtSize(const PixelFormat& fmt, const int width, const int height, int align = 0);
_API inline int CalPixFmtSize(const ImageInfo& ii)
{
    return CalPixFmtSize(ii.pix_fmt, ii.vir_width, ii.vir_height, 0);
}
_API PixelFormat StringToPixFmt(const char* type);
_API const char* PixFmtToString(PixelFormat fmt);
 
#include <map>
#include <string>
#include <vector>
 
namespace easymedia
{
    bool ParseImageInfoFromMap(std::map<std::string, std::string>& params, ImageInfo& ii, bool input = true);
    _API std::string to_param_string(const ImageInfo& ii, bool input = true);
 
    _API std::string TwoImageRectToString(const std::vector<ImageRect>& src_dst);
    std::vector<ImageRect> StringToTwoImageRect(const std::string& str_rect);
 
    _API std::string ImageRectToString(const ImageRect& src_dst);
    std::vector<ImageRect> StringToImageRect(const std::string& str_rect);
 
} // namespace easymedia
 
#endif // #ifndef EASYMEDIA_IMAGE_H_