64                             int *is_packed_rgba, 
uint8_t rgba_map_ptr[4])
 
   73     if (*is_packed_rgba) {
 
   75         for (i = 0; i < 4; i++)
 
   76             dst_color[rgba_map[i]] = rgba_color[i];
 
   81         for (i = 0; i < w; i++)
 
   82             memcpy(line[0] + i * pixel_step[0], dst_color, pixel_step[0]);
 
   84             memcpy(rgba_map_ptr, rgba_map, 
sizeof(rgba_map[0]) * 4);
 
   88         dst_color[0] = 
RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
 
   89         dst_color[1] = 
RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
 
   90         dst_color[2] = 
RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
 
   91         dst_color[3] = rgba_color[3];
 
   93         for (plane = 0; plane < 4; plane++) {
 
   95             int hsub1 = (plane == 1 || plane == 2) ? hsub : 0;
 
   97             pixel_step[
plane] = 1;
 
  101                 while(plane && line[plane-1])
 
  105             memset(line[plane], dst_color[plane], line_size);
 
  114                        int hsub, 
int vsub, 
int x, 
int y, 
int w, 
int h)
 
  119     for (plane = 0; plane < 4 && dst[
plane]; plane++) {
 
  120         int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
 
  121         int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
 
  125         p = dst[
plane] + (y >> vsub1) * dst_linesize[plane];
 
  126         for (i = 0; i < 
height; i++) {
 
  127             memcpy(p + (x >> hsub1) * pixelstep[plane],
 
  128                    src[plane], width * pixelstep[plane]);
 
  129             p += dst_linesize[
plane];
 
  135                        uint8_t *
src[4], 
int src_linesize[4], 
int pixelstep[4],
 
  136                        int hsub, 
int vsub, 
int x, 
int y, 
int y2, 
int w, 
int h)
 
  141     for (plane = 0; plane < 4 && dst[
plane]; plane++) {
 
  142         int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
 
  143         int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
 
  147         p = dst[
plane] + (y >> vsub1) * dst_linesize[plane];
 
  148         for (i = 0; i < 
height; i++) {
 
  149             memcpy(p + (x >> hsub1) * pixelstep[plane],
 
  150                    src[plane] + src_linesize[plane]*(i+(y2>>vsub1)), width * pixelstep[plane]);
 
  151             p += dst_linesize[
plane];
 
  160     unsigned i, nb_planes = 0;
 
  175         if (pixelstep[c->
plane] != 0 &&
 
  179         if (pixelstep[c->
plane] >= 8)
 
  185     memset(draw, 0, 
sizeof(*draw));
 
  203     if (rgba != color->
rgba)
 
  204         memcpy(color->
rgba, rgba, 
sizeof(color->
rgba));
 
  208         for (i = 0; i < 4; i++)
 
  209             color->
comp[0].
u8[rgba_map[i]] = rgba[i];
 
  211             for (i = 0; i < 4; i++)
 
  212                 color->
comp[rgba_map[i]].
u8[0] = rgba[i];
 
  219         color->
comp[3].
u8[0] = rgba[3];
 
  222         color->
comp[1].
u8[0] = rgba[3];
 
  225                "Color conversion not implemented for %s\n", draw->
desc->
name);
 
  226         memset(color, 128, 
sizeof(*color));
 
  234            (y >> draw->
vsub[
plane]) * linesize[plane] +
 
  239                         uint8_t *dst[], 
int dst_linesize[],
 
  241                         int dst_x, 
int dst_y, 
int src_x, 
int src_y,
 
  247     for (plane = 0; plane < draw->
nb_planes; plane++) {
 
  248         p = 
pointer_at(draw, src, src_linesize, plane, src_x, src_y);
 
  249         q = 
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
 
  252         for (y = 0; y < hp; y++) {
 
  254             p += src_linesize[
plane];
 
  255             q += dst_linesize[
plane];
 
  261                        uint8_t *dst[], 
int dst_linesize[],
 
  262                        int dst_x, 
int dst_y, 
int w, 
int h)
 
  267     for (plane = 0; plane < draw->
nb_planes; plane++) {
 
  268         p0 = 
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
 
  275         for (x = 0; x < wp; x++) {
 
  281         p = p0 + dst_linesize[
plane];
 
  282         for (y = 1; y < hp; y++) {
 
  284             p += dst_linesize[
plane];
 
  315     int mask = (1 << sub) - 1;
 
  317     *start = (-*x) & mask;
 
  319     *start = 
FFMIN(*start, *w);
 
  327     return (draw->
comp_mask[plane] >> comp) & 1;
 
  334                        int dx, 
int w, 
unsigned hsub, 
int left, 
int right)
 
  336     unsigned asrc = alpha * 
src;
 
  337     unsigned tau = 0x1010101 - 
alpha;
 
  341         unsigned suba = (left * 
alpha) >> hsub;
 
  342         *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
 
  345     for (x = 0; x < w; x++) {
 
  346         *dst = (*dst * tau + asrc) >> 24;
 
  350         unsigned suba = (right * 
alpha) >> hsub;
 
  351         *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
 
  356                         uint8_t *dst[], 
int dst_linesize[],
 
  357                         int dst_w, 
int dst_h,
 
  358                         int x0, 
int y0, 
int w, 
int h)
 
  361     int w_sub, h_sub, x_sub, y_sub, left, right, top, bottom, 
y;
 
  367     if (w <= 0 || h <= 0 || !color->rgba[3])
 
  370     alpha = 0x10203 * color->
rgba[3] + 0x2;
 
  372     for (plane = 0; plane < nb_planes; plane++) {
 
  374         p0 = 
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
 
  381         for (comp = 0; comp < nb_comp; comp++) {
 
  388                            draw->
hsub[plane], left, right);
 
  389                 p += dst_linesize[
plane];
 
  391             for (y = 0; y < h_sub; y++) {
 
  394                            draw->
hsub[plane], left, right);
 
  395                 p += dst_linesize[
plane];
 
  400                            draw->
hsub[plane], left, right);
 
  407                         unsigned w, 
unsigned h, 
unsigned shift, 
unsigned xm0)
 
  409     unsigned xm, x, 
y, t = 0;
 
  410     unsigned xmshf = 3 - l2depth;
 
  411     unsigned xmmod = 7 >> l2depth;
 
  412     unsigned mbits = (1 << (1 << l2depth)) - 1;
 
  413     unsigned mmult = 255 / mbits;
 
  415     for (y = 0; y < 
h; y++) {
 
  417         for (x = 0; x < w; x++) {
 
  418             t += ((mask[xm >> xmshf] >> ((~xm & xmmod) << l2depth)) & mbits)
 
  422         mask += mask_linesize;
 
  424     alpha = (t >> 
shift) * alpha;
 
  425     *dst = ((0x1010101 - 
alpha) * *dst + alpha * src) >> 24;
 
  430                           uint8_t *
mask, 
int mask_linesize, 
int l2depth, 
int w,
 
  431                           unsigned hsub, 
unsigned vsub,
 
  432                           int xm, 
int left, 
int right, 
int hband)
 
  437         blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
 
  438                     left, hband, hsub + vsub, xm);
 
  442     for (x = 0; x < w; x++) {
 
  443         blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
 
  444                     1 << hsub, hband, hsub + vsub, xm);
 
  449         blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
 
  450                     right, hband, hsub + vsub, xm);
 
  454                    uint8_t *dst[], 
int dst_linesize[], 
int dst_w, 
int dst_h,
 
  455                    uint8_t *
mask,  
int mask_linesize, 
int mask_w, 
int mask_h,
 
  456                    int l2depth, 
unsigned endianness, 
int x0, 
int y0)
 
  459     int xm0, ym0, w_sub, h_sub, x_sub, y_sub, left, right, top, bottom, 
y;
 
  464     mask += ym0 * mask_linesize;
 
  465     if (mask_w <= 0 || mask_h <= 0 || !color->rgba[3])
 
  469     alpha = (0x10307 * color->
rgba[3] + 0x3) >> 8;
 
  471     for (plane = 0; plane < nb_planes; plane++) {
 
  473         p0 = 
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
 
  480         for (comp = 0; comp < nb_comp; comp++) {
 
  487                               color->
comp[plane].
u8[comp], alpha,
 
  488                               m, mask_linesize, l2depth, w_sub,
 
  489                               draw->
hsub[plane], draw->
vsub[plane],
 
  490                               xm0, left, right, top);
 
  491                 p += dst_linesize[
plane];
 
  492                 m += top * mask_linesize;
 
  494             for (y = 0; y < h_sub; y++) {
 
  496                               color->
comp[plane].
u8[comp], alpha,
 
  497                               m, mask_linesize, l2depth, w_sub,
 
  498                               draw->
hsub[plane], draw->
vsub[plane],
 
  499                               xm0, left, right, 1 << draw->
vsub[plane]);
 
  500                 p += dst_linesize[
plane];
 
  505                               color->
comp[plane].
u8[comp], alpha,
 
  506                               m, mask_linesize, l2depth, w_sub,
 
  507                               draw->
hsub[plane], draw->
vsub[plane],
 
  508                               xm0, left, right, bottom);
 
  521         value += round_dir ? (1 << 
shift) - 1 : 1 << (shift - 1);
 
  522     return (value >> shift) << 
shift;
 
  553         printf(
"Testing %s...%*s", desc->
name,
 
  554                (
int)(16 - strlen(desc->
name)), 
"");
 
  559             printf(
"no: %s\n", buf);
 
  563         for (i = 0; i < 
sizeof(
color); i++)
 
  564             if (((
uint8_t *)&color)[i] != 128)
 
  566         if (i == 
sizeof(color)) {
 
  567             printf(
"fallback color\n");
 
void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, 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. 
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions. 
static enum AVPixelFormat pix_fmt
static int shift(int a, int b)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
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. 
ptrdiff_t const GLvoid * data
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
#define AV_LOG_WARNING
Something somehow does not look correct. 
packed RGB 8:8:8, 24bpp, RGBRGB... 
memory handling functions 
int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel used by the pixel format described by pixdesc. 
packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is st...
Various defines for YUV<->RGB conversion. 
static void blend_line(uint8_t *dst, unsigned src, unsigned alpha, int dx, int w, unsigned hsub, int left, int right)
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined 
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width. 
static void clip_interval(int wmax, int *x, int *w, int *dx)
Clip interval [x; x+w[ within [0; wmax[. 
int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir, int value)
Round a dimension according to subsampling. 
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed. 
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel. 
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined 
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
static av_cold int end(AVCodecContext *avctx)
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
packed ABGR 8:8:8:8, 32bpp, ABGRABGR... 
uint8_t comp_mask[MAX_PLANES]
uint16_t depth_minus1
Number of bits in the component minus 1. 
static double alpha(void *priv, double x, double y)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height. 
static const uint16_t mask[17]
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale). 
packed BGRA 8:8:8:8, 32bpp, BGRABGRA... 
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color. 
packed ARGB 8:8:8:8, 32bpp, ARGBARGB... 
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as lit...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA... 
uint8_t nb_components
The number of components each pixel has, (1-4) 
GLsizei GLboolean const GLfloat * value
#define FF_CEIL_RSHIFT(a, b)
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted". 
union FFDrawColor::@122 comp[MAX_PLANES]
static void blend_line_hv(uint8_t *dst, int dst_delta, unsigned src, unsigned alpha, uint8_t *mask, int mask_linesize, int l2depth, int w, unsigned hsub, unsigned vsub, int xm, int left, int right, int hband)
packed RGB 8:8:8, 24bpp, BGRBGR... 
packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big...
static uint8_t * pointer_at(FFDrawContext *draw, uint8_t *data[], int linesize[], int plane, int x, int y)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
static void subsampling_bounds(int sub, int *x, int *w, int *start, int *end)
Decompose w pixels starting at x into start + (w starting at x) + end with x and w aligned on multipl...
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
BYTE int const BYTE int int int height
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. 
void ff_copy_rectangle(uint8_t *dst[4], int dst_linesize[4], uint8_t *src[4], int src_linesize[4], int pixelstep[4], int hsub, int vsub, int x, int y, int y2, int w, int h)
uint16_t step_minus1
Number of elements between 2 horizontally consecutive pixels minus 1. 
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined 
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
Init a draw context. 
static int component_used(FFDrawContext *draw, int plane, int comp)
#define RGB_TO_U_CCIR(r1, g1, b1, shift)
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf. 
#define RGB_TO_V_CCIR(r1, g1, b1, shift)
uint16_t plane
Which of the 4 planes contains the component. 
planar GBRA 4:4:4:4 32bpp 
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
static void blend_pixel(uint8_t *dst, unsigned src, unsigned alpha, uint8_t *mask, int mask_linesize, int l2depth, unsigned w, unsigned h, unsigned shift, unsigned xm0)
#define RGB_TO_Y_CCIR(r, g, b)
uint16_t offset_plus1
Number of elements before the component of the first pixel plus 1. 
int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4], enum AVPixelFormat pix_fmt, uint8_t rgba_color[4], int *is_packed_rgba, uint8_t rgba_map_ptr[4])
int pixelstep[MAX_PLANES]
const struct AVPixFmtDescriptor * desc
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. 
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
#define av_malloc_array(a, b)
int main(int argc, char **argv)
void ff_draw_rectangle(uint8_t *dst[4], int dst_linesize[4], uint8_t *src[4], int pixelstep[4], int hsub, int vsub, int x, int y, int w, int h)
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined 
AVPixelFormat
Pixel format. 
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane. 
enum AVPixelFormat format
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...