[FFmpeg-devel] [PATCH v3 1/2] avutil/pixdesc: add alpha component information to pixfmts with reserved but undefined alpha bits
James Almer
jamrial at gmail.com
Thu Oct 17 23:20:14 EEST 2024
This can be useful to simplify certain processes that need to know how many
reserved bits there are and where they are placed, even if they are ultimately
unused, as will be shown in the next commit.
For any other case where the user simply looks at nb_components components, it
will make no difference.
Signed-off-by: James Almer <jamrial at gmail.com>
---
Now passing fate-pixelutils after updating it
libavutil/pixdesc.c | 19 +++++++++++++++++--
libavutil/tests/pixelutils.c | 4 ----
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c
index d73c3f0d58..12a8b9acf9 100644
--- a/libavutil/pixdesc.c
+++ b/libavutil/pixdesc.c
@@ -46,7 +46,7 @@ void av_read_image_line2(void *dst,
uint32_t *dst32 = dst;
if (flags & AV_PIX_FMT_FLAG_BITSTREAM) {
- if (depth == 10) {
+ if (step > 8) {
// Assume all channels are packed into a 32bit value
const uint8_t *byte_p = data[plane] + y * linesize[plane];
const uint32_t *p = (uint32_t *)byte_p;
@@ -125,7 +125,7 @@ void av_write_image_line2(const void *src,
const uint16_t *src16 = src;
if (flags & AV_PIX_FMT_FLAG_BITSTREAM) {
- if (depth == 10) {
+ if (step > 8) {
// Assume all channels are packed into a 32bit value
const uint8_t *byte_p = data[plane] + y * linesize[plane];
uint32_t *p = (uint32_t *)byte_p;
@@ -285,6 +285,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 2, 4, 10 }, /* R */
{ 0, 4, 1, 2, 10 }, /* G */
{ 0, 4, 0, 0, 10 }, /* B */
+ { 0, 4, 3, 6, 2 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_RGB,
},
@@ -297,6 +298,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 0, 4, 10 }, /* R */
{ 0, 4, 1, 2, 10 }, /* G */
{ 0, 4, 2, 0, 10 }, /* B */
+ { 0, 4, 3, 6, 2 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
},
@@ -309,6 +311,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 0, 0, 10 }, /* R */
{ 0, 4, 1, 2, 10 }, /* G */
{ 0, 4, 2, 4, 10 }, /* B */
+ { 0, 4, 3, 6, 2 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_RGB,
},
@@ -321,6 +324,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 2, 0, 10 }, /* R */
{ 0, 4, 1, 2, 10 }, /* G */
{ 0, 4, 0, 4, 10 }, /* B */
+ { 0, 4, 3, 6, 2 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE,
},
@@ -639,6 +643,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 1, 0, 8 }, /* R */
{ 0, 4, 2, 0, 8 }, /* G */
{ 0, 4, 3, 0, 8 }, /* B */
+ { 0, 4, 0, 0, 8 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_RGB,
},
@@ -651,6 +656,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 0, 0, 8 }, /* R */
{ 0, 4, 1, 0, 8 }, /* G */
{ 0, 4, 2, 0, 8 }, /* B */
+ { 0, 4, 3, 0, 8 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_RGB,
},
@@ -663,6 +669,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 3, 0, 8 }, /* R */
{ 0, 4, 2, 0, 8 }, /* G */
{ 0, 4, 1, 0, 8 }, /* B */
+ { 0, 4, 0, 0, 8 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_RGB,
},
@@ -675,6 +682,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 2, 0, 8 }, /* R */
{ 0, 4, 1, 0, 8 }, /* G */
{ 0, 4, 0, 0, 8 }, /* B */
+ { 0, 4, 3, 0, 8 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_RGB,
},
@@ -2628,6 +2636,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 2, 0, 8 }, /* Y */
{ 0, 4, 1, 0, 8 }, /* U */
{ 0, 4, 0, 0, 8 }, /* V */
+ { 0, 4, 3, 0, 8 }, /* X */
},
},
[AV_PIX_FMT_RGBF16BE] = {
@@ -2715,6 +2724,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 1, 2, 10 }, /* Y */
{ 0, 4, 0, 0, 10 }, /* U */
{ 0, 4, 2, 4, 10 }, /* V */
+ { 0, 4, 3, 6, 2 }, /* X */
},
},
[AV_PIX_FMT_XV30BE] = {
@@ -2726,6 +2736,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 32, 10, 0, 10 }, /* Y */
{ 0, 32, 0, 0, 10 }, /* U */
{ 0, 32, 20, 0, 10 }, /* V */
+ { 0, 32, 30, 0, 2 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_BITSTREAM,
},
@@ -2738,6 +2749,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 8, 2, 4, 12 }, /* Y */
{ 0, 8, 0, 4, 12 }, /* U */
{ 0, 8, 4, 4, 12 }, /* V */
+ { 0, 8, 6, 4, 12 }, /* X */
},
},
[AV_PIX_FMT_XV36BE] = {
@@ -2749,6 +2761,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 8, 2, 4, 12 }, /* Y */
{ 0, 8, 0, 4, 12 }, /* U */
{ 0, 8, 4, 4, 12 }, /* V */
+ { 0, 8, 6, 4, 12 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_BE,
},
@@ -2761,6 +2774,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 4, 1, 4, 10 }, /* Y */
{ 0, 4, 0, 2, 10 }, /* U */
{ 0, 4, 2, 6, 10 }, /* V */
+ { 0, 4, 0, 0, 2 }, /* X */
},
},
[AV_PIX_FMT_V30XBE] = {
@@ -2772,6 +2786,7 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = {
{ 0, 32, 12, 0, 10 }, /* Y */
{ 0, 32, 2, 0, 10 }, /* U */
{ 0, 32, 22, 0, 10 }, /* V */
+ { 0, 32, 0, 0, 2 }, /* X */
},
.flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_BITSTREAM,
},
diff --git a/libavutil/tests/pixelutils.c b/libavutil/tests/pixelutils.c
index 828a7580d2..f6ba5f0a79 100644
--- a/libavutil/tests/pixelutils.c
+++ b/libavutil/tests/pixelutils.c
@@ -58,10 +58,6 @@ static void check_pixfmt_descriptors(void)
for (int j = 0; j < FF_ARRAY_ELEMS(d->comp); j++) {
const AVComponentDescriptor *c = &d->comp[j];
- if (j >= d->nb_components) {
- av_assert0(!c->plane && !c->step && !c->offset && !c->shift && !c->depth);
- continue;
- }
if (d->flags & AV_PIX_FMT_FLAG_BITSTREAM) {
av_assert0(c->step >= c->depth);
} else {
--
2.47.0
More information about the ffmpeg-devel
mailing list