Compare commits

...

2 Commits

Author SHA1 Message Date
Kim Woelders a2e6beb37c test_load_2: Add full range color y4m image
Renamed the image as it isn't the usual 64x64 one.
2024-04-11 20:55:30 +02:00
Chema Gonzalez 98339a5708 Y4M loader: add support for full range color 2024-04-11 20:54:02 +02:00
3 changed files with 38 additions and 6 deletions

View File

@ -62,6 +62,11 @@ typedef struct {
Y4M_PARSE_ASPECT_32_27, Y4M_PARSE_ASPECT_32_27,
Y4M_PARSE_ASPECT_OTHER, Y4M_PARSE_ASPECT_OTHER,
} aspect; } aspect;
enum {
Y4M_PARSE_RANGE_UNSPECIFIED,
Y4M_PARSE_RANGE_LIMITED,
Y4M_PARSE_RANGE_FULL,
} range;
const void *frame_data; const void *frame_data;
ptrdiff_t frame_data_len; ptrdiff_t frame_data_len;
@ -224,9 +229,26 @@ y4m__parse_params(Y4mParse *res, const uint8_t **start, const uint8_t *end)
; ;
} }
break; break;
case 'X': /* comments ignored */ case 'X':
for (; p < end && *p != ' ' && *p != '\n'; ++p) if (y4m__match("COLORRANGE=LIMITED", 18, &p, end))
; res->range = Y4M_PARSE_RANGE_LIMITED;
else if (y4m__match("COLORRANGE=FULL", 15, &p, end))
res->range = Y4M_PARSE_RANGE_FULL;
else if (y4m__match("COLORRANGE=", 11, &p, end))
{
#if IMLIB2_DEBUG
char str[1024];
sscanf(pp, "%s", str);
D("%s: unknown color range: '%s'\n", __func__, str);
#endif
return Y4M_PARSE_UNSUPPORTED;
}
else
{
/* other comments ignored */
for (; p < end && *p != ' ' && *p != '\n'; ++p)
;
}
break; break;
default: default:
return Y4M_PARSE_CORRUPTED; return Y4M_PARSE_CORRUPTED;
@ -402,16 +424,25 @@ _load(ImlibImage *im, int load_data)
conv = conv_mono; conv = conv_mono;
break; break;
case Y4M_PARSE_CS_422: case Y4M_PARSE_CS_422:
conv = I422ToARGB; if (y4m.range == Y4M_PARSE_RANGE_FULL)
conv = J422ToARGB;
else
conv = I422ToARGB;
break; break;
case Y4M_PARSE_CS_444: case Y4M_PARSE_CS_444:
conv = I444ToARGB; if (y4m.range == Y4M_PARSE_RANGE_FULL)
conv = J444ToARGB;
else
conv = I444ToARGB;
break; break;
case Y4M_PARSE_CS_420JPEG: case Y4M_PARSE_CS_420JPEG:
case Y4M_PARSE_CS_420MPEG2: case Y4M_PARSE_CS_420MPEG2:
case Y4M_PARSE_CS_420PALDV: case Y4M_PARSE_CS_420PALDV:
case Y4M_PARSE_CS_420: case Y4M_PARSE_CS_420:
conv = I420ToARGB; if (y4m.range == Y4M_PARSE_RANGE_FULL)
conv = J420ToARGB;
else
conv = I420ToARGB;
break; break;
default: default:
DL("colour_space: %d\n", y4m.colour_space); DL("colour_space: %d\n", y4m.colour_space);

Binary file not shown.

View File

@ -106,6 +106,7 @@ static tii_t tii[] = {
{ "icon-64.yuv420paldv.y4m", 3810593176 }, { "icon-64.yuv420paldv.y4m", 3810593176 },
{ "icon-64.aspect_unsupported.y4m", 2400380696 }, { "icon-64.aspect_unsupported.y4m", 2400380696 },
{ "icon-64.framerate_1_1.y4m", 2400380696 }, { "icon-64.framerate_1_1.y4m", 2400380696 },
{ "img-17x14.full_range.y4m", 839224907 },
#endif #endif
{ "icon-128.ico", 218415319 }, { "icon-128.ico", 218415319 },