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
32 32
33enum { RED = 0, GREEN, BLUE, ALPHA };33enum { RED = 0, GREEN, BLUE, ALPHA };
34 34
35int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)35static int fill_map(const AVPixFmtDescriptor *desc, uint8_t *map)
36{36{
37 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);37 if (desc->flags & (AV_PIX_FMT_FLAG_BITSTREAM | AV_PIX_FMT_FLAG_HWACCEL |
38 if (!(desc->flags & AV_PIX_FMT_FLAG_RGB))38 AV_PIX_FMT_FLAG_BAYER | AV_PIX_FMT_FLAG_XYZ | AV_PIX_FMT_FLAG_PAL))
39 return AVERROR(EINVAL);
40 if (desc->flags & AV_PIX_FMT_FLAG_BITSTREAM)
41 return AVERROR(EINVAL);39 return AVERROR(EINVAL);
42 av_assert0(desc->nb_components == 3 + !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA));40 av_assert0(desc->nb_components == 3 + !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA));
43 if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) {41 if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) {
44 rgba_map[RED] = desc->comp[0].plane;42 map[RED] = desc->comp[0].plane;
45 rgba_map[GREEN] = desc->comp[1].plane;43 map[GREEN] = desc->comp[1].plane;
46 rgba_map[BLUE] = desc->comp[2].plane;44 map[BLUE] = desc->comp[2].plane;
47 rgba_map[ALPHA] = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) ? desc->comp[3].plane : 3;45 map[ALPHA] = (desc->flags & AV_PIX_FMT_FLAG_ALPHA) ? desc->comp[3].plane : 3;
48 } else {46 } else {
49 int had0 = 0;47 int had0 = 0;
50 unsigned depthb = 0;48 unsigned depthb = 0;
@@ -60,24 +58,40 @@ int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt) · 9 unmodified lines
60 return AVERROR(ENOSYS);58 return AVERROR(ENOSYS);
61 59
62 had0 |= pos == 0;60 had0 |= pos == 0;
63 rgba_map[i] = pos;61 map[i] = pos;
64 depthb = db;62 depthb = db;
65 }63 }
66 64
67 if (desc->nb_components == 3)65 if (desc->nb_components == 3)
68 rgba_map[ALPHA] = had0 ? 3 : 0;66 map[ALPHA] = had0 ? 3 : 0;
69 }67 }
70 68
71 av_assert0(rgba_map[RED] != rgba_map[GREEN]);69 av_assert0(map[RED] != map[GREEN]);
72 av_assert0(rgba_map[GREEN] != rgba_map[BLUE]);70 av_assert0(map[GREEN] != map[BLUE]);
73 av_assert0(rgba_map[BLUE] != rgba_map[RED]);71 av_assert0(map[BLUE] != map[RED]);
74 av_assert0(rgba_map[RED] != rgba_map[ALPHA]);72 av_assert0(map[RED] != map[ALPHA]);
75 av_assert0(rgba_map[GREEN] != rgba_map[ALPHA]);73 av_assert0(map[GREEN] != map[ALPHA]);
76 av_assert0(rgba_map[BLUE] != rgba_map[ALPHA]);74 av_assert0(map[BLUE] != map[ALPHA]);
77 75
78 return 0;76 return 0;
79}77}
80 78
79int 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
87int 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
81int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSpace csp,95int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSpace csp,
82 enum AVColorRange range, unsigned flags)96 enum AVColorRange range, unsigned flags)
83{97{

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