From 2a7359b5d9167447fc6b61e7c7b26c9deda2fea2 Mon Sep 17 00:00:00 2001 From: vlad Date: Mon, 30 Nov 2026 20:03:47 +0200 Subject: [PATCH] media: apple: prores: fix 1-byte shift in v1 frame header colour offsets In apr_build_desc() (v1 descriptor), D_FH_PRIMARIES..D_FH_ALPHA were defined at 0x089..0x08c, omitting the SMPTE RDD 36 aspect/frame-rate byte at 0x089 (which apr_build_desc_v0() leaves at 0x065 and apr_parse_frame() skips at header[13]). As a result, v1 hardware encodes on T6050 (J714s M5 Pro) signalled frame-rate code 1 (23.976 fps) at header[13] and wrote the constant alpha byte (0) into the matrix slot at header[16], causing decoders/ffprobe to report color_space=gbr. Shift D_FH_PRIMARIES..D_FH_ALPHA up by one byte to 0x08a..0x08d so 0x089 stays zero (unspecified aspect/rate), matching SMPTE RDD 36 and apr_build_desc_v0(). Update the KUnit test to use distinct colour codes (1, 16, 9) and assert every byte from format (0x88) through flags (0x8f). Signed-off-by: vlad --- .../media/platform/apple/prores/apple-prores-desc.c | 9 +++++---- .../media/platform/apple/prores/apple-prores-test.c | 10 +++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/apple/prores/apple-prores-desc.c b/drivers/media/platform/apple/prores/apple-prores-desc.c index f73923e584806..69e3d8ed93d91 100644 --- a/drivers/media/platform/apple/prores/apple-prores-desc.c +++ b/drivers/media/platform/apple/prores/apple-prores-desc.c @@ -200,10 +200,11 @@ EXPORT_SYMBOL_IF_KUNIT(apr_dc_scale_reg); #define D_FH_WIDTH 0x084 #define D_FH_HEIGHT 0x086 #define D_FH_FORMAT 0x088 -#define D_FH_PRIMARIES 0x089 -#define D_FH_TRANSFER 0x08a -#define D_FH_MATRIX 0x08b -#define D_FH_ALPHA 0x08c +/* 0x089: aspect and frame rate, both unspecified (zero). */ +#define D_FH_PRIMARIES 0x08a +#define D_FH_TRANSFER 0x08b +#define D_FH_MATRIX 0x08c +#define D_FH_ALPHA 0x08d #define D_FH_FLAGS 0x08f #define D_FH_BYTES 0x94 /* Rate control: coefficient budgets in bytes per macroblock, Q3 */ diff --git a/drivers/media/platform/apple/prores/apple-prores-test.c b/drivers/media/platform/apple/prores/apple-prores-test.c index b2f1f22c75d82..952d074e0b0be 100644 --- a/drivers/media/platform/apple/prores/apple-prores-test.c +++ b/drivers/media/platform/apple/prores/apple-prores-test.c @@ -85,7 +85,7 @@ static struct apr_frame apr_test_frame(void) .luma_stride = 640, .chroma_stride = 640, .luma = 0x10000100000ULL, .chroma = 0x10000200000ULL, .output = 0x10000400000ULL, .output_size = SZ_1M, - .primaries = 1, .transfer = 1, .matrix = 1, + .primaries = 1, .transfer = 16, .matrix = 9, }; } @@ -113,8 +113,12 @@ static void apr_test_desc_422(struct kunit *test) KUNIT_EXPECT_EQ(test, get_unaligned_be16(d + 0x84), 320); KUNIT_EXPECT_EQ(test, get_unaligned_be16(d + 0x86), 240); KUNIT_EXPECT_EQ(test, d[0x88], 0x80); - KUNIT_EXPECT_EQ(test, d[0x89], 1); - KUNIT_EXPECT_EQ(test, d[0x8b], 1); + KUNIT_EXPECT_EQ(test, d[0x89], 0); + KUNIT_EXPECT_EQ(test, d[0x8a], f.primaries); + KUNIT_EXPECT_EQ(test, d[0x8b], f.transfer); + KUNIT_EXPECT_EQ(test, d[0x8c], f.matrix); + KUNIT_EXPECT_EQ(test, d[0x8d], 0); + KUNIT_EXPECT_EQ(test, d[0x8e], 0); KUNIT_EXPECT_EQ(test, d[0x8f], 0x03); /* 20 macroblocks per row: two 8-wide slices and one 4-wide. */ KUNIT_EXPECT_EQ(test, get_unaligned_be16(d + 0x78), 45);