80                             int *is_packed_rgba, 
uint8_t rgba_map_ptr[4])
 
   93     if (*is_packed_rgba) {
 
   95         for (i = 0; i < 4; i++)
 
   96             dst_color[rgba_map[i]] = rgba_color[i];
 
  101         for (i = 0; i < w; i++)
 
  102             memcpy(line[0] + i * pixel_step[0], dst_color, pixel_step[0]);
 
  104             memcpy(rgba_map_ptr, rgba_map, 
sizeof(rgba_map[0]) * 4);
 
  108         dst_color[0] = 
RGB_TO_Y_CCIR(rgba_color[0], rgba_color[1], rgba_color[2]);
 
  109         dst_color[1] = 
RGB_TO_U_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
 
  110         dst_color[2] = 
RGB_TO_V_CCIR(rgba_color[0], rgba_color[1], rgba_color[2], 0);
 
  111         dst_color[3] = rgba_color[3];
 
  113         for (plane = 0; plane < 4; plane++) {
 
  115             int hsub1 = (plane == 1 || plane == 2) ? hsub : 0;
 
  117             pixel_step[
plane] = 1;
 
  121                 while(plane && line[plane-1])
 
  125             memset(line[plane], dst_color[plane], line_size);
 
  134                        int hsub, 
int vsub, 
int x, 
int y, 
int w, 
int h)
 
  139     for (plane = 0; plane < 4 && dst[
plane]; plane++) {
 
  140         int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
 
  141         int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
 
  145         p = dst[
plane] + (y >> vsub1) * dst_linesize[plane];
 
  146         for (i = 0; i < 
height; i++) {
 
  147             memcpy(p + (x >> hsub1) * pixelstep[plane],
 
  148                    src[plane], width * pixelstep[plane]);
 
  149             p += dst_linesize[
plane];
 
  155                        uint8_t *
src[4], 
int src_linesize[4], 
int pixelstep[4],
 
  156                        int hsub, 
int vsub, 
int x, 
int y, 
int y2, 
int w, 
int h)
 
  161     for (plane = 0; plane < 4 && dst[
plane]; plane++) {
 
  162         int hsub1 = plane == 1 || plane == 2 ? hsub : 0;
 
  163         int vsub1 = plane == 1 || plane == 2 ? vsub : 0;
 
  167         p = dst[
plane] + (y >> vsub1) * dst_linesize[plane];
 
  168         for (i = 0; i < 
height; i++) {
 
  169             memcpy(p + (x >> hsub1) * pixelstep[plane],
 
  170                    src[plane] + src_linesize[plane]*(i+(y2>>vsub1)), width * pixelstep[plane]);
 
  171             p += dst_linesize[
plane];
 
  180     unsigned i, nb_planes = 0;
 
  183     if (!desc || !desc->
name)
 
  197         if (pixelstep[c->
plane] != 0 &&
 
  200         if (pixelstep[c->
plane] == 6 &&
 
  204         if (pixelstep[c->
plane] >= 8)
 
  208     memset(draw, 0, 
sizeof(*draw));
 
  226     if (rgba != color->
rgba)
 
  227         memcpy(color->
rgba, rgba, 
sizeof(color->
rgba));
 
  231             for (i = 0; i < 4; i++) {
 
  232                 color->
comp[0].
u8[rgba_map[i]] = rgba[i];
 
  234                     color->
comp[0].
u16[rgba_map[i]] = color->
comp[0].
u8[rgba_map[i]] << 8;
 
  238             for (i = 0; i < 4; i++) {
 
  239                 color->
comp[rgba_map[i]].
u8[0] = rgba[i];
 
  250         color->
comp[3].
u8[0] = rgba[3];
 
  251 #define EXPAND(compn) \ 
  252         if (desc->comp[compn].depth > 8) \ 
  253             color->comp[desc->comp[compn].plane].u16[desc->comp[compn].offset] = \ 
  254             color->comp[desc->comp[compn].plane].u8[desc->comp[compn].offset] << (draw->desc->comp[compn].depth - 8) 
  261         color->
comp[1].
u8[0] = rgba[3];
 
  265         color->
comp[1].
u8[0] = rgba[3];
 
  269                "Color conversion not implemented for %s\n", draw->
desc->
name);
 
  270         memset(color, 128, 
sizeof(*color));
 
  275                            int plane, 
int x, 
int y)
 
  278            (y >> draw->
vsub[
plane]) * linesize[plane] +
 
  283                         uint8_t *dst[], 
int dst_linesize[],
 
  285                         int dst_x, 
int dst_y, 
int src_x, 
int src_y,
 
  288     int plane, y, wp, hp;
 
  291     for (plane = 0; plane < draw->
nb_planes; plane++) {
 
  292         p = 
pointer_at(draw, src, src_linesize, plane, src_x, src_y);
 
  293         q = 
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
 
  296         for (y = 0; y < hp; y++) {
 
  298             p += src_linesize[
plane];
 
  299             q += dst_linesize[
plane];
 
  305                        uint8_t *dst[], 
int dst_linesize[],
 
  306                        int dst_x, 
int dst_y, 
int w, 
int h)
 
  308     int plane, x, y, wp, hp;
 
  312     for (plane = 0; plane < draw->
nb_planes; plane++) {
 
  313         p0 = 
pointer_at(draw, dst, dst_linesize, plane, dst_x, dst_y);
 
  326         for (x = 0; x < wp; x++) {
 
  332         p = p0 + dst_linesize[
plane];
 
  333         for (y = 1; y < hp; y++) {
 
  335             p += dst_linesize[
plane];
 
  366     int mask = (1 << sub) - 1;
 
  368     *start = (-*x) & mask;
 
  370     *start = 
FFMIN(*start, *w);
 
  378     return (draw->
comp_mask[plane] >> comp) & 1;
 
  385                        int dx, 
int w, 
unsigned hsub, 
int left, 
int right)
 
  387     unsigned asrc = alpha * 
src;
 
  388     unsigned tau = 0x1010101 - 
alpha;
 
  392         unsigned suba = (left * 
alpha) >> hsub;
 
  393         *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
 
  396     for (x = 0; x < w; x++) {
 
  397         *dst = (*dst * tau + asrc) >> 24;
 
  401         unsigned suba = (right * 
alpha) >> hsub;
 
  402         *dst = (*dst * (0x1010101 - suba) + src * suba) >> 24;
 
  407                          int dx, 
int w, 
unsigned hsub, 
int left, 
int right)
 
  409     unsigned asrc = alpha * 
src;
 
  410     unsigned tau = 0x10001 - 
alpha;
 
  414         unsigned suba = (left * 
alpha) >> hsub;
 
  416         AV_WL16(dst, (value * (0x10001 - suba) + src * suba) >> 16);
 
  419     for (x = 0; x < w; x++) {
 
  421         AV_WL16(dst, (value * tau + asrc) >> 16);
 
  425         unsigned suba = (right * 
alpha) >> hsub;
 
  427         AV_WL16(dst, (value * (0x10001 - suba) + src * suba) >> 16);
 
  432                         uint8_t *dst[], 
int dst_linesize[],
 
  433                         int dst_w, 
int dst_h,
 
  434                         int x0, 
int y0, 
int w, 
int h)
 
  437     int w_sub, h_sub, x_sub, y_sub, left, right, top, bottom, y;
 
  443     if (w <= 0 || h <= 0 || !color->rgba[3])
 
  447         alpha = 0x10203 * color->
rgba[3] + 0x2;
 
  450         alpha = 0x101 * color->
rgba[3] + 0x2;
 
  453     for (plane = 0; plane < nb_planes; plane++) {
 
  455         p0 = 
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
 
  462         for (comp = 0; comp < nb_comp; comp++) {
 
  472                                draw->
hsub[plane], left, right);
 
  476                                  draw->
hsub[plane], left, right);
 
  478                 p += dst_linesize[
plane];
 
  481                 for (y = 0; y < h_sub; y++) {
 
  484                                draw->
hsub[plane], left, right);
 
  485                     p += dst_linesize[
plane];
 
  488                 for (y = 0; y < h_sub; y++) {
 
  491                                  draw->
hsub[plane], left, right);
 
  492                     p += dst_linesize[
plane];
 
  499                                draw->
hsub[plane], left, right);
 
  503                                  draw->
hsub[plane], left, right);
 
  511                           const uint8_t *
mask, 
int mask_linesize, 
int l2depth,
 
  512                           unsigned w, 
unsigned h, 
unsigned shift, 
unsigned xm0)
 
  514     unsigned xm, x, y, t = 0;
 
  515     unsigned xmshf = 3 - l2depth;
 
  516     unsigned xmmod = 7 >> l2depth;
 
  517     unsigned mbits = (1 << (1 << l2depth)) - 1;
 
  518     unsigned mmult = 255 / mbits;
 
  521     for (y = 0; y < 
h; y++) {
 
  523         for (x = 0; x < w; x++) {
 
  524             t += ((mask[xm >> xmshf] >> ((~xm & xmmod) << l2depth)) & mbits)
 
  528         mask += mask_linesize;
 
  530     alpha = (t >> 
shift) * alpha;
 
  531     AV_WL16(dst, ((0x10001 - alpha) * value + alpha * src) >> 16);
 
  535                         const uint8_t *
mask, 
int mask_linesize, 
int l2depth,
 
  536                         unsigned w, 
unsigned h, 
unsigned shift, 
unsigned xm0)
 
  538     unsigned xm, x, y, t = 0;
 
  539     unsigned xmshf = 3 - l2depth;
 
  540     unsigned xmmod = 7 >> l2depth;
 
  541     unsigned mbits = (1 << (1 << l2depth)) - 1;
 
  542     unsigned mmult = 255 / mbits;
 
  544     for (y = 0; y < 
h; y++) {
 
  546         for (x = 0; x < w; x++) {
 
  547             t += ((mask[xm >> xmshf] >> ((~xm & xmmod) << l2depth)) & mbits)
 
  551         mask += mask_linesize;
 
  553     alpha = (t >> 
shift) * alpha;
 
  554     *dst = ((0x1010101 - 
alpha) * *dst + alpha * src) >> 24;
 
  559                             const uint8_t *
mask, 
int mask_linesize, 
int l2depth, 
int w,
 
  560                             unsigned hsub, 
unsigned vsub,
 
  561                             int xm, 
int left, 
int right, 
int hband)
 
  567                       left, hband, hsub + vsub, xm);
 
  571     for (x = 0; x < w; x++) {
 
  573                       1 << hsub, hband, hsub + vsub, xm);
 
  579                       right, hband, hsub + vsub, xm);
 
  584                           const uint8_t *
mask, 
int mask_linesize, 
int l2depth, 
int w,
 
  585                           unsigned hsub, 
unsigned vsub,
 
  586                           int xm, 
int left, 
int right, 
int hband)
 
  591         blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
 
  592                     left, hband, hsub + vsub, xm);
 
  596     for (x = 0; x < w; x++) {
 
  597         blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
 
  598                     1 << hsub, hband, hsub + vsub, xm);
 
  603         blend_pixel(dst, src, alpha, mask, mask_linesize, l2depth,
 
  604                     right, hband, hsub + vsub, xm);
 
  608                    uint8_t *dst[], 
int dst_linesize[], 
int dst_w, 
int dst_h,
 
  609                    const uint8_t *
mask,  
int mask_linesize, 
int mask_w, 
int mask_h,
 
  610                    int l2depth, 
unsigned endianness, 
int x0, 
int y0)
 
  613     int xm0, ym0, w_sub, h_sub, x_sub, y_sub, left, right, top, bottom, y;
 
  619     mask += ym0 * mask_linesize;
 
  620     if (mask_w <= 0 || mask_h <= 0 || !color->rgba[3])
 
  625         alpha = (0x10307 * color->
rgba[3] + 0x3) >> 8;
 
  627         alpha = (0x101 * color->
rgba[3] + 0x2) >> 8;
 
  630     for (plane = 0; plane < nb_planes; plane++) {
 
  632         p0 = 
pointer_at(draw, dst, dst_linesize, plane, x0, y0);
 
  639         for (comp = 0; comp < nb_comp; comp++) {
 
  649                                   color->
comp[plane].
u8[comp], alpha,
 
  650                                   m, mask_linesize, l2depth, w_sub,
 
  651                                   draw->
hsub[plane], draw->
vsub[plane],
 
  652                                   xm0, left, right, top);
 
  655                                     color->
comp[plane].
u16[comp], alpha,
 
  656                                     m, mask_linesize, l2depth, w_sub,
 
  657                                     draw->
hsub[plane], draw->
vsub[plane],
 
  658                                     xm0, left, right, top);
 
  660                 p += dst_linesize[
plane];
 
  661                 m += top * mask_linesize;
 
  664                 for (y = 0; y < h_sub; y++) {
 
  666                                   color->
comp[plane].
u8[comp], alpha,
 
  667                                   m, mask_linesize, l2depth, w_sub,
 
  668                                   draw->
hsub[plane], draw->
vsub[plane],
 
  669                                   xm0, left, right, 1 << draw->
vsub[plane]);
 
  670                     p += dst_linesize[
plane];
 
  674                 for (y = 0; y < h_sub; y++) {
 
  676                                     color->
comp[plane].
u16[comp], alpha,
 
  677                                     m, mask_linesize, l2depth, w_sub,
 
  678                                     draw->
hsub[plane], draw->
vsub[plane],
 
  679                                     xm0, left, right, 1 << draw->
vsub[plane]);
 
  680                     p += dst_linesize[
plane];
 
  687                                   color->
comp[plane].
u8[comp], alpha,
 
  688                                   m, mask_linesize, l2depth, w_sub,
 
  689                                   draw->
hsub[plane], draw->
vsub[plane],
 
  690                                   xm0, left, right, bottom);
 
  693                                     color->
comp[plane].
u16[comp], alpha,
 
  694                                     m, mask_linesize, l2depth, w_sub,
 
  695                                     draw->
hsub[plane], draw->
vsub[plane],
 
  696                                     xm0, left, right, bottom);
 
  711         value += round_dir ? (1 << 
shift) - 1 : 1 << (shift - 1);
 
  712     return (value >> shift) << 
shift;
 
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions. 
 
int plane
Which of the 4 planes contains the component. 
 
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. 
 
planar GBR 4:4:4 36bpp, little-endian 
 
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 
 
planar GBR 4:4:4 36bpp, big-endian 
 
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
 
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. 
 
#define av_assert0(cond)
assert() equivalent, that is always enabled. 
 
planar GBRA 4:4:4:4 64bpp, big-endian 
 
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]
 
planar GBR 4:4:4 48bpp, big-endian 
 
planar GBR 4:4:4 27bpp, big-endian 
 
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... 
 
static void blend_line16(uint8_t *dst, unsigned src, unsigned alpha, int dx, int w, unsigned hsub, int left, int right)
 
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color. 
 
simple assert() macros that are a bit more flexible than ISO C assert(). 
 
static void blend_line_hv(uint8_t *dst, int dst_delta, unsigned src, unsigned alpha, const uint8_t *mask, int mask_linesize, int l2depth, int w, unsigned hsub, unsigned vsub, int xm, int left, int right, int hband)
 
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... 
 
union FFDrawColor::@154 comp[MAX_PLANES]
 
uint64_t flags
Combination of AV_PIX_FMT_FLAG_... 
 
planar GBR 4:4:4:4 48bpp, big-endian 
 
uint8_t nb_components
The number of components each pixel has, (1-4) 
 
static void blend_line_hv16(uint8_t *dst, int dst_delta, unsigned src, unsigned alpha, const uint8_t *mask, int mask_linesize, int l2depth, int w, unsigned hsub, unsigned vsub, int xm, int left, int right, int hband)
 
GLsizei GLboolean const GLfloat * value
 
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted". 
 
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...
 
planar GBR 4:4:4:4 48bpp, little-endian 
 
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. 
 
static void blend_pixel(uint8_t *dst, unsigned src, unsigned alpha, const uint8_t *mask, int mask_linesize, int l2depth, unsigned w, unsigned h, unsigned shift, unsigned xm0)
 
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
 
planar GBR 4:4:4 30bpp, big-endian 
 
planar GBR 4:4:4 42bpp, little-endian 
 
static const char * format
 
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)
 
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. 
 
planar GBR 4:4:4 42bpp, big-endian 
 
static int component_used(FFDrawContext *draw, int plane, int comp)
 
#define RGB_TO_U_CCIR(r1, g1, b1, shift)
 
int offset
Number of elements before the component of the first pixel. 
 
#define RGB_TO_V_CCIR(r1, g1, b1, shift)
 
planar GBRA 4:4:4:4 32bpp 
 
planar GBR 4:4:4 27bpp, little-endian 
 
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_pixel16(uint8_t *dst, unsigned src, unsigned alpha, const uint8_t *mask, int mask_linesize, int l2depth, unsigned w, unsigned h, unsigned shift, unsigned xm0)
 
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian. 
 
#define RGB_TO_Y_CCIR(r, g, b)
 
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])
 
Y , 16bpp, little-endian. 
 
int pixelstep[MAX_PLANES]
 
16 bits gray, 16 bits alpha (little-endian) 
 
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)
 
planar GBR 4:4:4 48bpp, little-endian 
 
#define av_malloc_array(a, b)
 
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)
 
int depth
Number of bits in the component. 
 
planar GBRA 4:4:4:4 64bpp, little-endian 
 
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
 
planar GBR 4:4:4 30bpp, little-endian 
 
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
 
int step
Number of elements between 2 horizontally consecutive pixels. 
 
#define AV_CEIL_RSHIFT(a, b)