FFmpeg
drawutils.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVFILTER_DRAWUTILS_H
20 #define AVFILTER_DRAWUTILS_H
21 
27 #include <stdint.h>
28 #include "avfilter.h"
29 #include "libavutil/pixfmt.h"
30 
31 int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt);
32 
33 int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w,
34  uint8_t dst_color[4],
35  enum AVPixelFormat pix_fmt, uint8_t rgba_color[4],
36  int *is_packed_rgba, uint8_t rgba_map[4]);
37 
38 void ff_draw_rectangle(uint8_t *dst[4], int dst_linesize[4],
39  uint8_t *src[4], int pixelstep[4],
40  int hsub, int vsub, int x, int y, int w, int h);
41 
42 void ff_copy_rectangle(uint8_t *dst[4], int dst_linesize[4],
43  uint8_t *src[4], int src_linesize[4], int pixelstep[4],
44  int hsub, int vsub, int x, int y, int y2, int w, int h);
45 
46 #define MAX_PLANES 4
47 
48 typedef struct FFDrawContext {
49  const struct AVPixFmtDescriptor *desc;
50  enum AVPixelFormat format;
51  unsigned nb_planes;
52  int pixelstep[MAX_PLANES]; /*< offset between pixels */
53  uint8_t comp_mask[MAX_PLANES]; /*< bitmask of used non-alpha components */
54  uint8_t hsub[MAX_PLANES]; /*< horizontal subsampling */
55  uint8_t vsub[MAX_PLANES]; /*< vertical subsampling */
56  uint8_t hsub_max;
57  uint8_t vsub_max;
58  unsigned flags;
60 
61 typedef struct FFDrawColor {
62  uint8_t rgba[4];
63  union {
64  uint32_t u32[4];
65  uint16_t u16[8];
66  uint8_t u8[16];
67  } comp[MAX_PLANES];
68 } FFDrawColor;
69 
73 #define FF_DRAW_PROCESS_ALPHA 1
74 
83 int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags);
84 
88 void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4]);
89 
96  uint8_t *dst[], int dst_linesize[],
97  uint8_t *src[], int src_linesize[],
98  int dst_x, int dst_y, int src_x, int src_y,
99  int w, int h);
100 
108  uint8_t *dst[], int dst_linesize[],
109  int dst_x, int dst_y, int w, int h);
110 
115  uint8_t *dst[], int dst_linesize[],
116  int dst_w, int dst_h,
117  int x0, int y0, int w, int h);
118 
138  uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h,
139  const uint8_t *mask, int mask_linesize, int mask_w, int mask_h,
140  int l2depth, unsigned endianness, int x0, int y0);
141 
151 int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir,
152  int value);
153 
160 
161 #endif /* AVFILTER_DRAWUTILS_H */
void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, const uint8_t *mask, int mask_linesize, int mask_w, int mask_h, int l2depth, unsigned endianness, int x0, int y0)
Blend an alpha mask with an uniform color.
Definition: drawutils.c:616
Main libavfilter public API header.
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context.
Definition: drawutils.c:178
Definition: vf_paletteuse.c:588
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
Definition: drawutils.c:725
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
Definition: drawutils.c:226
Definition: graph2dot.c:48
Definition: drawutils.h:61
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
Definition: drawutils.h:48
void ff_copy_rectangle2(FFDrawContext *draw, uint8_t *dst[], int dst_linesize[], uint8_t *src[], int src_linesize[], int dst_x, int dst_y, int src_x, int src_y, int w, int h)
Copy a rectangle from an image to another.
Definition: drawutils.c:290
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, int x0, int y0, int w, int h)
Blend a rectangle with an uniform color.
Definition: drawutils.c:439
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
Definition: drawutils.c:312
pixel format definitions
A list of supported formats for one end of a filter link.
Definition: formats.h:64
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir, int value)
Round a dimension according to subsampling.
Definition: drawutils.c:713