Signed-off-by: Grzegorz Rys <[email protected]>
---
libavcodec/jpegxs_parser.c | 106 +++++++++++++++++++++++++++++--------
1 file changed, 83 insertions(+), 23 deletions(-)
diff --git a/libavcodec/jpegxs_parser.c b/libavcodec/jpegxs_parser.c
index a9750b0a02..c7c5a83b9a 100644
--- a/libavcodec/jpegxs_parser.c
+++ b/libavcodec/jpegxs_parser.c
@@ -106,6 +106,7 @@ static int jpegxs_parse_frame(AVCodecParserContext *s,
AVCodecContext *avctx,
GetBitContext gb;
int8_t bpc[3], log2_chroma_w[3], log2_chroma_h[3];
int size, marker, components;
+ int has_cdt = 0, has_cts = 0, is_rgb = 0;
s->key_frame = 1;
s->pict_type = AV_PICTURE_TYPE_I;
@@ -170,42 +171,101 @@ static int jpegxs_parse_frame(AVCodecParserContext *s,
AVCodecContext *avctx,
log2_chroma_w[2] != log2_chroma_w[1]))
return 0;
}
+ has_cdt = 1;
+ bytestream2_skip(&gbc, FFMAX(size - 2, 0));
+ break;
+ case JPEGXS_MARKER_CTS:
+ size = bytestream2_get_be16(&gbc);
+ if (size >= 3) {
+ int colour_spec = bytestream2_get_byte(&gbc);
+
+ has_cts = 1;
+ is_rgb = colour_spec == 1;
+ }
+ bytestream2_skip(&gbc, FFMAX(size - 3, 0));
+ break;
+ default:
+ size = bytestream2_get_be16(&gbc);
+ bytestream2_skip(&gbc, FFMAX(size - 2, 0));
+ break;
+ }
- switch (bpc[0]) {
- case 8:
- if (components == 1)
s->format = AV_PIX_FMT_GRAY8;
- else if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1)
s->format = AV_PIX_FMT_YUV444P;
+ if (!has_cdt)
+ continue;
+
+ if (components == 3 &&
+ log2_chroma_w[1] == 1 &&
+ log2_chroma_h[1] == 1 &&
+ !has_cts)
+ continue;
+
+ switch (bpc[0]) {
+ case 8:
+ if (components == 1) {
+ s->format = AV_PIX_FMT_GRAY8;
+ } else if (is_rgb) {
+ if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1) {
+ s->format = AV_PIX_FMT_GBRP;
+ } else {
+ s->format = AV_PIX_FMT_NONE;
+ }
+ } else {
+ if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1) s->format
= AV_PIX_FMT_YUV444P;
else if (log2_chroma_w[1] == 2 && log2_chroma_h[1] == 1)
s->format = AV_PIX_FMT_YUV422P;
else
s->format = AV_PIX_FMT_YUV420P;
- break;
- case 10:
- if (components == 1)
s->format = AV_PIX_FMT_GRAY10;
- else if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1)
s->format = AV_PIX_FMT_YUV444P10;
+ }
+ break;
+ case 10:
+ if (components == 1) {
+ s->format = AV_PIX_FMT_GRAY10;
+ } else if (is_rgb) {
+ if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1) {
+ s->format = AV_PIX_FMT_GBRP10LE;
+ } else {
+ s->format = AV_PIX_FMT_NONE;
+ }
+ } else {
+ if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1) s->format
= AV_PIX_FMT_YUV444P10;
else if (log2_chroma_w[1] == 2 && log2_chroma_h[1] == 1)
s->format = AV_PIX_FMT_YUV422P10;
else
s->format = AV_PIX_FMT_YUV420P10;
- break;
- case 12:
- if (components == 1)
s->format = AV_PIX_FMT_GRAY12;
- else if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1)
s->format = AV_PIX_FMT_YUV444P12;
+ }
+ break;
+ case 12:
+ if (components == 1) {
+ s->format = AV_PIX_FMT_GRAY12;
+ } else if (is_rgb) {
+ if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1) {
+ s->format = AV_PIX_FMT_GBRP12LE;
+ } else {
+ s->format = AV_PIX_FMT_NONE;
+ }
+ } else {
+ if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1) s->format
= AV_PIX_FMT_YUV444P12;
else if (log2_chroma_w[1] == 2 && log2_chroma_h[1] == 1)
s->format = AV_PIX_FMT_YUV422P12;
else
s->format = AV_PIX_FMT_YUV420P12;
- break;
- case 14:
- if (components == 1)
s->format = AV_PIX_FMT_GRAY14;
- else if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1)
s->format = AV_PIX_FMT_YUV444P14;
+ }
+ break;
+ case 14:
+ if (components == 1) {
+ s->format = AV_PIX_FMT_GRAY14;
+ } else if (is_rgb) {
+ if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1) {
+ s->format = AV_PIX_FMT_GBRP14LE;
+ } else {
+ s->format = AV_PIX_FMT_NONE;
+ }
+ } else {
+ if (log2_chroma_w[1] == 1 && log2_chroma_h[1] == 1) s->format
= AV_PIX_FMT_YUV444P14;
else if (log2_chroma_w[1] == 2 && log2_chroma_h[1] == 1)
s->format = AV_PIX_FMT_YUV422P14;
else
s->format = AV_PIX_FMT_YUV420P14;
- break;
- default:
- s->format = AV_PIX_FMT_NONE;
- break;
}
- return 0;
+ break;
default:
- size = bytestream2_get_be16(&gbc);
- bytestream2_skip(&gbc, FFMAX(size - 2, 0));
+ s->format = AV_PIX_FMT_NONE;
break;
}
+
+ return 0;
}
return 0;
--
2.53.0
---------------------------------------------------------------------
Intel Technology Poland sp. z o.o.
ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial
Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 |
Kapital zakladowy 200.000 PLN.
Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z
dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach
handlowych.
Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i
moze zawierac informacje poufne. W razie przypadkowego otrzymania tej
wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie;
jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole
use of the intended recipient(s). If you are not the intended recipient, please
contact the sender and delete all copies; any review or distribution by others
is strictly prohibited.
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]