hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
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
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * Copyright 2021 Rockchip Electronics Co., Ltd
 *     Author: Jeffy Chen <jeffy.chen@rock-chips.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 */
 
#ifndef  __GST_MPP_H__
#define  __GST_MPP_H__
 
#include <gst/video/video.h>
 
#ifdef HAVE_RGA
#include <rga/rga.h>
#include <rga/RgaApi.h>
#endif
 
#include <rockchip/rk_mpi.h>
 
G_BEGIN_DECLS;
 
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#endif
 
#ifndef SWAP
#define SWAP(x, y) ({ x ^= y; y ^= x; x ^= y; })
#endif
 
#define MPP_FMT_LE(f) (f | MPP_FRAME_FMT_LE_MASK)
#define MPP_FMT_RGB565LE MPP_FMT_LE(MPP_FMT_RGB565)
#define MPP_FMT_BGR565LE MPP_FMT_LE(MPP_FMT_BGR565)
 
#define GST_MPP_VIDEO_INFO_HSTRIDE(i) GST_VIDEO_INFO_PLANE_STRIDE(i, 0)
#define GST_MPP_VIDEO_INFO_VSTRIDE(i) \
    (GST_VIDEO_INFO_N_PLANES(i) == 1 ? GST_VIDEO_INFO_HEIGHT(i) : \
    (gint) (GST_VIDEO_INFO_PLANE_OFFSET(i, 1) / GST_MPP_VIDEO_INFO_HSTRIDE(i)))
 
#ifndef GST_VIDEO_FLAG_ARM_AFBC
#define GST_VIDEO_FLAG_ARM_AFBC (1UL << 31)
#define GST_VIDEO_INFO_SET_AFBC(i) \
  GST_VIDEO_INFO_FLAG_SET (i, GST_VIDEO_FLAG_ARM_AFBC)
#define GST_VIDEO_INFO_UNSET_AFBC(i) \
  GST_VIDEO_INFO_FLAG_UNSET (i, GST_VIDEO_FLAG_ARM_AFBC)
#define GST_VIDEO_INFO_IS_AFBC(i) \
  GST_VIDEO_INFO_FLAG_IS_SET (i, GST_VIDEO_FLAG_ARM_AFBC)
#endif
 
/* The MPP requires alignment 16 by default */
#define GST_MPP_ALIGNMENT 16
#define GST_MPP_ALIGN(v) GST_ROUND_UP_N (v, GST_MPP_ALIGNMENT)
 
#ifdef HAVE_RGA
#define GST_RGA_FORMATS \
    "NV12, NV21, I420, YV12, NV16, NV61, " \
    "BGR16, RGB, BGR, RGBA, BGRA, RGBx, BGRx"
#endif
 
gboolean gst_mpp_use_rga ();
 
const gchar *gst_mpp_video_format_to_string (GstVideoFormat format);
 
GstVideoFormat gst_mpp_mpp_format_to_gst_format (MppFrameFormat mpp_format);
 
MppFrameFormat gst_mpp_gst_format_to_mpp_format (GstVideoFormat format);
 
#ifdef HAVE_RGA
gboolean gst_mpp_rga_convert (GstBuffer * inbuf, GstVideoInfo * src_vinfo,
    GstMemory * out_mem, GstVideoInfo * dst_vinfo, gint rotation);
 
gboolean gst_mpp_rga_convert_from_mpp_frame (MppFrame * mframe,
    GstMemory * out_mem, GstVideoInfo * dst_vinfo, gint rotation);
#endif
 
gboolean gst_mpp_video_info_align (GstVideoInfo * info,
    gint hstride, gint vstride);
 
guint gst_mpp_get_pixel_stride (GstVideoInfo * info);
 
G_END_DECLS;
 
#endif /* __GST_MPP_H__ */