/* C1V2 video decoder (the format is specified in r32x/c1.py). Portable C99: the same * file builds for the SH-2 and for the host test (player32x/c1/host_test.c). */ #ifndef C1DEC_H #define C1DEC_H #include #define C1_W 320 #define C1_ROWS 192 #define C1_MBX (C1_W / 16) #define C1_MBY (C1_ROWS / 16) #define C1_NMB (C1_MBX * C1_MBY) #define C1_HALF (C1_NMB / 2) #define C1_LINES 224 typedef struct { uint8_t *y; /* C1_ROWS x C1_W */ uint8_t *cb; /* C1_ROWS/2 x C1_W/2 */ uint8_t *cr; } c1_planes; /* Scratch and table copies, one per CPU (the two SH-2s decode at the same time); * c1_fast_init fills the tables. */ typedef struct { /* offsets are fixed: c1asm.s uses them */ int32_t t[64]; /* +0 IDCT pass 1 (the assembly keeps int16 tT[c*8+u] here) */ int32_t res[64]; /* +256 IDCT output */ int16_t coef[64]; /* +512 dequantised block */ int16_t si[64]; /* +640 intra steps for this frame's q */ int16_t kt[64]; /* +768 IDCT basis transposed: kt[c*8+v] = C1_K[v*8+c] */ uint8_t zigzag[64]; /* +896 */ uint8_t mintra[64]; /* +960 */ uint8_t cl5[768]; /* +1024 C1_CL5; the conversion tables start here */ int32_t cbt[256]; /* +1792 (BCB[u] << 16) | (GCB[u] & 0xFFFF) */ int32_t crt[256]; /* +2816 (RCR[v] << 16) | (GCR[v] & 0xFFFF) */ } c1_fast_t; void c1_fast_init(c1_fast_t *f); /* Decode half h (0: MB rows 0-5, 1: MB rows 6-11) of one payload against ref into cur * (cur != ref; every MB of that half is written). changed[mb] = 1 for each MB of the * half that is not a SKIP, else 0. Returns 0, or negative on a malformed payload. * The halves are independent: one SH-2 can decode each. */ int c1_decode_half(c1_fast_t *f, const uint8_t *payload, int h, const c1_planes *ref, c1_planes *cur, uint8_t *changed); /* RGB555 words of the MBs with mask[mb] != 0 in MB rows [mby0, mby1) into dst (stored * row r at dst + r * C1_W; dst 4-byte aligned). */ void c1_to_rgb555(const c1_fast_t *f, const c1_planes *p, volatile uint16_t *dst, const uint8_t *mask, int mby0, int mby1); /* The 32X line table for direct colour: line i -> word offset base + row(i) * C1_W. */ void c1_line_table(volatile uint16_t *table, uint16_t base); #endif