History

avfilter/vsdc_testsrc: simplify yuvtest_fill_picture

Copy what's done for rgbtest_fill_picture. It will be useful for the following commit.

James Almer committed 2 years ago

Commit 667e22e1 parent e347b4f3 files · +75 −119Browse files

Showing the changes to libavfilter/drawutils.c (1 of 3 files). Show all

Unified · Split

libavfilter/drawutils.c+31−17
@@ -32,19 +32,17 @@ · 31 unmodified lines
3232
3333 enum { RED = 0, GREEN, BLUE, ALPHA };
3434
35−int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
35+static int fill_map(const AVPixFmtDescriptor *desc, uint8_t *map)
3636 {
37− const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
38− if (!(desc->flags & AV_PIX_FMT_FLAG_RGB))
39− return AVERROR(EINVAL);
40− if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)
37+ if (desc->flags & (AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_HWACCEL |
38+ AV_PIX_FMT_FLAG_BAYER | AV_PIX_FMT_FLAG_XYZ | AV_PIX_FMT_FLAG_PAL))
4139 return AVERROR(EINVAL);
4240 av_assert0(desc->nb_components == 3 + !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA));
4341 if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) {
44− rgba_map[RED] = desc->comp[0].plane;
45− rgba_map[GREEN] = desc->comp[1].plane;
46− rgba_map[BLUE] = desc->comp[2].plane;
47− rgba_map[ALPHA] = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) ? desc->comp[3].plane : 3;
42+ map[RED] = desc->comp[0].plane;
43+ map[GREEN] = desc->comp[1].plane;
44+ map[BLUE] = desc->comp[2].plane;
45+ map[ALPHA] = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) ? desc->comp[3].plane : 3;
4846 } else {
4947 int had0 = 0;
5048 unsigned depthb = 0;
@@ -60,24 +58,40 @@ int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt) · 9 unmodified lines
6058 return AVERROR(ENOSYS);
6159
6260 had0 |= pos == 0;
63− rgba_map[i] = pos;
61+ map[i] = pos;
6462 depthb = db;
6563 }
6664
6765 if (desc->nb_components == 3)
68− rgba_map[ALPHA] = had0 ? 3 : 0;
66+ map[ALPHA] = had0 ? 3 : 0;
6967 }
7068
71− av_assert0(rgba_map[RED] != rgba_map[GREEN]);
72− av_assert0(rgba_map[GREEN] != rgba_map[BLUE]);
73− av_assert0(rgba_map[BLUE] != rgba_map[RED]);
74− av_assert0(rgba_map[RED] != rgba_map[ALPHA]);
75− av_assert0(rgba_map[GREEN] != rgba_map[ALPHA]);
76− av_assert0(rgba_map[BLUE] != rgba_map[ALPHA]);
69+ av_assert0(map[RED] != map[GREEN]);
70+ av_assert0(map[GREEN] != map[BLUE]);
71+ av_assert0(map[BLUE] != map[RED]);
72+ av_assert0(map[RED] != map[ALPHA]);
73+ av_assert0(map[GREEN] != map[ALPHA]);
74+ av_assert0(map[BLUE] != map[ALPHA]);
7775
7876 return 0;
7977 }
8078
79+int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
80+{
81+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
82+ if (!(desc->flags & AV_PIX_FMT_FLAG_RGB))
83+ return AVERROR(EINVAL);
84+ return fill_map(desc, rgba_map);
85+}
86+
87+int ff_fill_ayuv_map(uint8_t *ayuv_map, enum AVPixelFormat pix_fmt)
88+{
89+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
90+ if (desc->flags & AV_PIX_FMT_FLAG_RGB)
91+ return AVERROR(EINVAL);
92+ return fill_map(desc, ayuv_map);
93+}
94+
8195 int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSpace csp,
8296 enum AVColorRange range, unsigned flags)
8397 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t