FFmpeg 5.1.6
rpi_sand_fns.h
Go to the documentation of this file.
1/*
2Copyright (c) 2018 Raspberry Pi (Trading) Ltd.
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27Authors: John Cox
28*/
29
30#ifndef AVUTIL_RPI_SAND_FNS
31#define AVUTIL_RPI_SAND_FNS
32
33#include "libavutil/frame.h"
34
35// For all these fns _x & _w are measured as coord * PW
36// For the C fns coords are in chroma pels (so luma / 2)
37// Strides are in bytes
38
39void av_rpi_sand_to_planar_y8(uint8_t * dst, const unsigned int dst_stride,
40 const uint8_t * src,
41 unsigned int stride1, unsigned int stride2,
42 unsigned int _x, unsigned int y,
43 unsigned int _w, unsigned int h);
44void av_rpi_sand_to_planar_y16(uint8_t * dst, const unsigned int dst_stride,
45 const uint8_t * src,
46 unsigned int stride1, unsigned int stride2,
47 unsigned int _x, unsigned int y,
48 unsigned int _w, unsigned int h);
49
50void av_rpi_sand_to_planar_c8(uint8_t * dst_u, const unsigned int dst_stride_u,
51 uint8_t * dst_v, const unsigned int dst_stride_v,
52 const uint8_t * src,
53 unsigned int stride1, unsigned int stride2,
54 unsigned int _x, unsigned int y,
55 unsigned int _w, unsigned int h);
56void av_rpi_sand_to_planar_c16(uint8_t * dst_u, const unsigned int dst_stride_u,
57 uint8_t * dst_v, const unsigned int dst_stride_v,
58 const uint8_t * src,
59 unsigned int stride1, unsigned int stride2,
60 unsigned int _x, unsigned int y,
61 unsigned int _w, unsigned int h);
62
63void av_rpi_planar_to_sand_c8(uint8_t * dst_c,
64 unsigned int stride1, unsigned int stride2,
65 const uint8_t * src_u, const unsigned int src_stride_u,
66 const uint8_t * src_v, const unsigned int src_stride_v,
67 unsigned int _x, unsigned int y,
68 unsigned int _w, unsigned int h);
69void av_rpi_planar_to_sand_c16(uint8_t * dst_c,
70 unsigned int stride1, unsigned int stride2,
71 const uint8_t * src_u, const unsigned int src_stride_u,
72 const uint8_t * src_v, const unsigned int src_stride_v,
73 unsigned int _x, unsigned int y,
74 unsigned int _w, unsigned int h);
75
76void av_rpi_sand30_to_planar_y16(uint8_t * dst, const unsigned int dst_stride,
77 const uint8_t * src,
78 unsigned int stride1, unsigned int stride2,
79 unsigned int _x, unsigned int y,
80 unsigned int _w, unsigned int h);
81void av_rpi_sand30_to_planar_c16(uint8_t * dst_u, const unsigned int dst_stride_u,
82 uint8_t * dst_v, const unsigned int dst_stride_v,
83 const uint8_t * src,
84 unsigned int stride1, unsigned int stride2,
85 unsigned int _x, unsigned int y,
86 unsigned int _w, unsigned int h);
87
88void av_rpi_sand30_to_planar_y8(uint8_t * dst, const unsigned int dst_stride,
89 const uint8_t * src,
90 unsigned int stride1, unsigned int stride2,
91 unsigned int _x, unsigned int y,
92 unsigned int _w, unsigned int h);
93
94// w/h in pixels
95void av_rpi_sand16_to_sand8(uint8_t * dst, const unsigned int dst_stride1, const unsigned int dst_stride2,
96 const uint8_t * src, const unsigned int src_stride1, const unsigned int src_stride2,
97 unsigned int w, unsigned int h, const unsigned int shr);
98
99
100// dst must contain required pixel format & allocated data buffers
101// Cropping on the src buffer will be honoured and dst crop will be set to zero
102int av_rpi_sand_to_planar_frame(AVFrame * const dst, const AVFrame * const src);
103
104
105static inline unsigned int av_rpi_sand_frame_stride1(const AVFrame * const frame)
106{
107#ifdef RPI_ZC_SAND128_ONLY
108 // If we are sure we only only support 128 byte sand formats replace the
109 // var with a constant which should allow for better optimisation
110 return 128;
111#else
112 return frame->linesize[0];
113#endif
114}
115
116static inline unsigned int av_rpi_sand_frame_stride2_y(const AVFrame * const frame)
117{
118 return frame->linesize[3];
119}
120
121static inline unsigned int av_rpi_sand_frame_stride2_c(const AVFrame * const frame)
122{
123 return frame->linesize[4];
124}
125
126static inline int av_rpi_is_sand_format(const int format)
127{
128 return (format >= AV_PIX_FMT_SAND128 && format <= AV_PIX_FMT_RPI4_10);
129}
130
131static inline int av_rpi_is_sand_frame(const AVFrame * const frame)
132{
134}
135
136static inline int av_rpi_is_sand8_frame(const AVFrame * const frame)
137{
139}
140
141static inline int av_rpi_is_sand16_frame(const AVFrame * const frame)
142{
144}
145
146static inline int av_rpi_is_sand30_frame(const AVFrame * const frame)
147{
148 return (frame->format == AV_PIX_FMT_RPI4_10);
149}
150
151static inline int av_rpi_sand_frame_xshl(const AVFrame * const frame)
152{
153 return av_rpi_is_sand8_frame(frame) ? 0 : 1;
154}
155
156#endif
157
static AVFrame * frame
reference-counted frame API
@ AV_PIX_FMT_SAND128
4:2:0 8-bit 128x*Y stripe, 64x*UV stripe, then next x stripe, mysterious padding
Definition: pixfmt.h:355
@ AV_PIX_FMT_RPI4_8
Definition: pixfmt.h:358
@ AV_PIX_FMT_RPI4_10
Definition: pixfmt.h:359
@ AV_PIX_FMT_SAND64_10
4:2:0 10-bit 64x*Y stripe, 32x*UV stripe, then next x stripe, mysterious padding
Definition: pixfmt.h:356
@ AV_PIX_FMT_SAND64_16
4:2:0 16-bit 64x*Y stripe, 32x*UV stripe, then next x stripe, mysterious padding
Definition: pixfmt.h:357
static unsigned int av_rpi_sand_frame_stride2_y(const AVFrame *const frame)
Definition: rpi_sand_fns.h:116
static int av_rpi_is_sand16_frame(const AVFrame *const frame)
Definition: rpi_sand_fns.h:141
void av_rpi_sand_to_planar_y8(uint8_t *dst, const unsigned int dst_stride, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int _x, unsigned int y, unsigned int _w, unsigned int h)
void av_rpi_sand_to_planar_y16(uint8_t *dst, const unsigned int dst_stride, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int _x, unsigned int y, unsigned int _w, unsigned int h)
static unsigned int av_rpi_sand_frame_stride2_c(const AVFrame *const frame)
Definition: rpi_sand_fns.h:121
static int av_rpi_is_sand8_frame(const AVFrame *const frame)
Definition: rpi_sand_fns.h:136
void av_rpi_planar_to_sand_c8(uint8_t *dst_c, unsigned int stride1, unsigned int stride2, const uint8_t *src_u, const unsigned int src_stride_u, const uint8_t *src_v, const unsigned int src_stride_v, unsigned int _x, unsigned int y, unsigned int _w, unsigned int h)
void av_rpi_sand_to_planar_c8(uint8_t *dst_u, const unsigned int dst_stride_u, uint8_t *dst_v, const unsigned int dst_stride_v, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int _x, unsigned int y, unsigned int _w, unsigned int h)
void av_rpi_sand30_to_planar_y8(uint8_t *dst, const unsigned int dst_stride, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int _x, unsigned int y, unsigned int _w, unsigned int h)
int av_rpi_sand_to_planar_frame(AVFrame *const dst, const AVFrame *const src)
void av_rpi_sand_to_planar_c16(uint8_t *dst_u, const unsigned int dst_stride_u, uint8_t *dst_v, const unsigned int dst_stride_v, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int _x, unsigned int y, unsigned int _w, unsigned int h)
static int av_rpi_is_sand30_frame(const AVFrame *const frame)
Definition: rpi_sand_fns.h:146
static int av_rpi_is_sand_frame(const AVFrame *const frame)
Definition: rpi_sand_fns.h:131
static int av_rpi_is_sand_format(const int format)
Definition: rpi_sand_fns.h:126
void av_rpi_sand30_to_planar_c16(uint8_t *dst_u, const unsigned int dst_stride_u, uint8_t *dst_v, const unsigned int dst_stride_v, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int _x, unsigned int y, unsigned int _w, unsigned int h)
void av_rpi_planar_to_sand_c16(uint8_t *dst_c, unsigned int stride1, unsigned int stride2, const uint8_t *src_u, const unsigned int src_stride_u, const uint8_t *src_v, const unsigned int src_stride_v, unsigned int _x, unsigned int y, unsigned int _w, unsigned int h)
void av_rpi_sand16_to_sand8(uint8_t *dst, const unsigned int dst_stride1, const unsigned int dst_stride2, const uint8_t *src, const unsigned int src_stride1, const unsigned int src_stride2, unsigned int w, unsigned int h, const unsigned int shr)
static int av_rpi_sand_frame_xshl(const AVFrame *const frame)
Definition: rpi_sand_fns.h:151
void av_rpi_sand30_to_planar_y16(uint8_t *dst, const unsigned int dst_stride, const uint8_t *src, unsigned int stride1, unsigned int stride2, unsigned int _x, unsigned int y, unsigned int _w, unsigned int h)
static unsigned int av_rpi_sand_frame_stride1(const AVFrame *const frame)
Definition: rpi_sand_fns.h:105
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition: frame.h:370
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:412