This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository legacy-imlib2.
View the commit online.
commit cd8c225ed0aebc9f93c52314c0062adfa2d8b4a0
Author: NRK <n...@disroot.org>
AuthorDate: Tue Jan 2 04:38:29 2024 +0000
Y4M loader: don't fail on newline
regression introduce in c08ae5f. if the color space was the last thing
in the header than it would be followed by a newline rather than space.
peek to ensure next char is either ' ' or newline to avoid falsly
matching problematic colorspaces. this will also work for other cases
like "mono-whatever" instead of working just for "420", "422" and "444".
also change the return code to unsupported instead of corrupted in these
cases.
---
src/modules/loaders/loader_y4m.c | 19 ++++++++++++++-----
test/images/icon-64.framerate_1_1.y4m | 2 +-
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/modules/loaders/loader_y4m.c b/src/modules/loaders/loader_y4m.c
index 43987f2..870236c 100644
--- a/src/modules/loaders/loader_y4m.c
+++ b/src/modules/loaders/loader_y4m.c
@@ -38,6 +38,7 @@ typedef struct {
ptrdiff_t w, h;
ptrdiff_t fps_num, fps_den;
enum {
+ Y4M_PARSE_CS_UNSUPPORTED = -1,
Y4M_PARSE_CS_420, /* default picked from ffmpeg */
Y4M_PARSE_CS_420JPEG,
Y4M_PARSE_CS_420MPEG2,
@@ -113,6 +114,7 @@ static enum Y4mParseStatus
y4m__parse_params(Y4mParse * res, const uint8_t ** start, const uint8_t * end)
{
const uint8_t *p = *start;
+ const uint8_t *peek;
for (;;)
{
@@ -173,6 +175,7 @@ y4m__parse_params(Y4mParse * res, const uint8_t ** start, const uint8_t * end)
}
break;
case 'C':
+ res->colour_space = Y4M_PARSE_CS_UNSUPPORTED;
if (y4m__match("mono", 4, &p, end))
res->colour_space = Y4M_PARSE_CS_MONO;
else if (y4m__match("420jpeg", 7, &p, end))
@@ -181,20 +184,26 @@ y4m__parse_params(Y4mParse * res, const uint8_t ** start, const uint8_t * end)
res->colour_space = Y4M_PARSE_CS_420MPEG2;
else if (y4m__match("420paldv", 8, &p, end))
res->colour_space = Y4M_PARSE_CS_420PALDV;
- else if (y4m__match("420 ", 4, &p, end))
+ else if (y4m__match("420", 3, &p, end))
res->colour_space = Y4M_PARSE_CS_420;
- else if (y4m__match("422 ", 4, &p, end))
+ else if (y4m__match("422", 3, &p, end))
res->colour_space = Y4M_PARSE_CS_422;
- else if (y4m__match("444 ", 4, &p, end))
+ else if (y4m__match("444", 3, &p, end))
res->colour_space = Y4M_PARSE_CS_444;
- else {
+
+ peek = p; /* peek to avoid falsly matching things like "420p16" */
+ if (res->colour_space == Y4M_PARSE_CS_UNSUPPORTED ||
+ (!y4m__match(" ", 1, &peek, end) &&
+ !y4m__match("\n", 1, &peek, end)))
+ {
#if IMLIB2_DEBUG
char str[1024];
sscanf(pp, "%s", str);
D("%s: unknown color type: '%s'\n", __func__, str);
#endif
- return Y4M_PARSE_CORRUPTED;
+ return Y4M_PARSE_UNSUPPORTED;
}
+
break;
case 'A':
if (y4m__match("0:0", 3, &p, end))
diff --git a/test/images/icon-64.framerate_1_1.y4m b/test/images/icon-64.framerate_1_1.y4m
index a392f4a..b07b30b 100644
--- a/test/images/icon-64.framerate_1_1.y4m
+++ b/test/images/icon-64.framerate_1_1.y4m
@@ -1,3 +1,3 @@
-YUV4MPEG2 W64 H64 F1:1 Ip A368:375 C444 XYSCSS=444 XCOLORRANGE=LIMITED
+YUV4MPEG2 W64 H64 F1:1 Ip A368:375 XCOLORRANGE=LIMITED XYSCSS=444 C444
FRAME
�������������������������뻗�h]]]\[���������������������������������������������������ǂ_DIJHHGFEDA=83/Cq������������������������������������������Ӄ_]jijmpw}�zvqjaWLB80*d��������������������������������������~^z|~���������þ�����n\L>3+?����������������������������������|e��������������������dz�zaN=1)>������������������������������c������������������������ж�rYE6,&c������������������
���������u���������������������������ս�y^J9.'1�������������������������d�����������������������������ɯ�v]I9.'%�� [...]
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.