(options?: {
cIcpAfterIdat?: boolean;
invalidCrc?: boolean;
longCicp?: boolean;
})
| 32 | } |
| 33 | |
| 34 | function buildMinimalPng(options?: { |
| 35 | cIcpAfterIdat?: boolean; |
| 36 | invalidCrc?: boolean; |
| 37 | longCicp?: boolean; |
| 38 | }) { |
| 39 | const ihdr = pngChunk("IHDR", [0, 0, 0, 1, 0, 0, 0, 1, 16, 2, 0, 0, 0]); |
| 40 | const cicpData = options?.longCicp ? [9, 16, 0, 1, 255] : [9, 16, 0, 1]; |
| 41 | let cicp = pngChunk("cICP", cicpData); |
| 42 | if (options?.invalidCrc) { |
| 43 | cicp = Buffer.from(cicp); |
| 44 | cicp[cicp.length - 1] ^= 0xff; |
| 45 | } |
| 46 | const idat = pngChunk( |
| 47 | "IDAT", |
| 48 | [0x78, 0x9c, 0x63, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01], |
| 49 | ); |
| 50 | const iend = pngChunk("IEND", []); |
| 51 | return options?.cIcpAfterIdat |
| 52 | ? buildPngWithChunks([ihdr, idat, cicp, iend]) |
| 53 | : buildPngWithChunks([ihdr, cicp, idat, iend]); |
| 54 | } |
| 55 | |
| 56 | describe("extractMediaMetadata", () => { |
| 57 | it("reads HDR PNG cICP metadata when ffprobe color fields are absent", async () => { |
no test coverage detected