Lines Matching +full:3 +full:- +full:d

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 Decompression for chipset version 2 et 3
4 (C) 2004-2006 Luc Saillard (luc@saillard.org)
9 The decompression routines have been implemented by reverse-engineering the
15 #include "pwc-timon.h"
16 #include "pwc-kiara.h"
17 #include "pwc-dec23.h"
44 -0x526500, -0x221200, 0x221200, 0x526500, in build_subblock_pattern()
45 -0x3de200, 0x3de200, in build_subblock_pattern()
46 -0x6db480, -0x2d5d00, 0x2d5d00, 0x6db480, in build_subblock_pattern()
47 -0x12c200, 0x12c200 in build_subblock_pattern()
51 0xa4ca, 0x4424, -0x4424, -0xa4ca, in build_subblock_pattern()
52 0x7bc4, -0x7bc4, in build_subblock_pattern()
53 0xdb69, 0x5aba, -0x5aba, -0xdb69, in build_subblock_pattern()
54 0x2584, -0x2584 in build_subblock_pattern()
62 pdec->table_subblock[i][j] = temp_values[j]; in build_subblock_pattern()
75 mask = bitpower - 1; in build_bit_powermask_table()
76 p = pdec->table_bitpowermask[bit]; in build_bit_powermask_table()
80 val = -val; in build_bit_powermask_table()
107 else if (k >= 1 && k < 3) in build_table_color()
109 else if (k >= 3 && k < 6) in build_table_color()
116 bit = (r[0] >> 3) & 7; in build_table_color()
122 *p8++ = j - bit; in build_table_color()
128 p0[k + 0x20] = (3 * pw) + 0x80; in build_table_color()
130 p0[k + 0x40] = (-1 * pw) + 0x80; in build_table_color()
131 p0[k + 0x50] = (-2 * pw) + 0x80; in build_table_color()
132 p0[k + 0x60] = (-3 * pw) + 0x80; in build_table_color()
133 p0[k + 0x70] = (-4 * pw) + 0x80; in build_table_color()
145 #define ONE_HALF (1UL << (SCALEBITS - 1)) in fill_table_dc00_d800()
151 pdec->table_dc00[i] = offset1 & ~(ONE_HALF); in fill_table_dc00_d800()
152 pdec->table_d800[i] = offset2; in fill_table_dc00_d800()
164 * elif look_bits(3) == 7: # op == 1 in the lookup table
165 * skip_bits(3)
258 {0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3,},
259 {0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,},
263 {1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2,},
264 {0, 3, 3, 0, 1, 2, 2, 1, 2, 1, 1, 2, 3, 0, 0, 3,},
265 {0, 1, 2, 3, 3, 2, 1, 0, 3, 2, 1, 0, 0, 1, 2, 3,},
266 {1, 1, 1, 1, 3, 3, 3, 3, 0, 0, 0, 0, 2, 2, 2, 2,},
270 {1, 3, 0, 2, 2, 0, 3, 1, 2, 0, 3, 1, 1, 3, 0, 2,},
271 {1, 2, 2, 1, 3, 0, 0, 3, 0, 3, 3, 0, 2, 1, 1, 2,},
288 struct pwc_dec23_private *pdec = &pdev->dec23; in pwc_dec23_init()
290 mutex_init(&pdec->lock); in pwc_dec23_init()
292 if (pdec->last_cmd_valid && pdec->last_cmd == cmd[2]) in pwc_dec23_init()
295 if (DEVICE_USE_CODEC3(pdev->type)) { in pwc_dec23_init()
298 pdec->nbits = 7; /* More bits, mean more bits to encode the stream, but better quality */ in pwc_dec23_init()
300 pdec->nbits = 8; in pwc_dec23_init()
302 pdec->nbits = 6; in pwc_dec23_init()
305 build_table_color(KiaraRomTable[version][0], pdec->table_0004_pass1, pdec->table_8004_pass1); in pwc_dec23_init()
306 build_table_color(KiaraRomTable[version][1], pdec->table_0004_pass2, pdec->table_8004_pass2); in pwc_dec23_init()
312 pdec->nbits = 7; in pwc_dec23_init()
314 pdec->nbits = 8; in pwc_dec23_init()
316 pdec->nbits = 6; in pwc_dec23_init()
318 version = cmd[2] >> 3; in pwc_dec23_init()
319 build_table_color(TimonRomTable[version][0], pdec->table_0004_pass1, pdec->table_8004_pass1); in pwc_dec23_init()
320 build_table_color(TimonRomTable[version][1], pdec->table_0004_pass2, pdec->table_8004_pass2); in pwc_dec23_init()
324 shift = 8 - pdec->nbits; in pwc_dec23_init()
325 pdec->scalebits = SCALEBITS - shift; in pwc_dec23_init()
326 pdec->nbitsmask = 0xFF >> shift; in pwc_dec23_init()
333 /* Build the static table to clamp value [0-255] */ in pwc_dec23_init()
342 pdec->last_cmd = cmd[2]; in pwc_dec23_init()
343 pdec->last_cmd_valid = 1; in pwc_dec23_init()
354 unsigned char *d = dst; in copy_image_block_Y() local
356 *d++ = cm[c[0] >> scalebits]; in copy_image_block_Y()
357 *d++ = cm[c[1] >> scalebits]; in copy_image_block_Y()
358 *d++ = cm[c[2] >> scalebits]; in copy_image_block_Y()
359 *d++ = cm[c[3] >> scalebits]; in copy_image_block_Y()
361 d = dst + bytes_per_line; in copy_image_block_Y()
362 *d++ = cm[c[4] >> scalebits]; in copy_image_block_Y()
363 *d++ = cm[c[5] >> scalebits]; in copy_image_block_Y()
364 *d++ = cm[c[6] >> scalebits]; in copy_image_block_Y()
365 *d++ = cm[c[7] >> scalebits]; in copy_image_block_Y()
367 d = dst + bytes_per_line*2; in copy_image_block_Y()
368 *d++ = cm[c[8] >> scalebits]; in copy_image_block_Y()
369 *d++ = cm[c[9] >> scalebits]; in copy_image_block_Y()
370 *d++ = cm[c[10] >> scalebits]; in copy_image_block_Y()
371 *d++ = cm[c[11] >> scalebits]; in copy_image_block_Y()
373 d = dst + bytes_per_line*3; in copy_image_block_Y()
374 *d++ = cm[c[12] >> scalebits]; in copy_image_block_Y()
375 *d++ = cm[c[13] >> scalebits]; in copy_image_block_Y()
376 *d++ = cm[c[14] >> scalebits]; in copy_image_block_Y()
377 *d++ = cm[c[15] >> scalebits]; in copy_image_block_Y()
381 unsigned char *d = dst; in copy_image_block_Y()
383 *d++ = CLAMP((*c) >> scalebits); in copy_image_block_Y()
385 d = dst + bytes_per_line; in copy_image_block_Y()
387 *d++ = CLAMP((*c) >> scalebits); in copy_image_block_Y()
389 d = dst + bytes_per_line*2; in copy_image_block_Y()
391 *d++ = CLAMP((*c) >> scalebits); in copy_image_block_Y()
393 d = dst + bytes_per_line*3; in copy_image_block_Y()
395 *d++ = CLAMP((*c) >> scalebits); in copy_image_block_Y()
409 unsigned char *d = dst; in copy_image_block_CrCb() local
411 *d++ = cm[c[0] >> scalebits]; in copy_image_block_CrCb()
412 *d++ = cm[c[4] >> scalebits]; in copy_image_block_CrCb()
413 *d++ = cm[c[1] >> scalebits]; in copy_image_block_CrCb()
414 *d++ = cm[c[5] >> scalebits]; in copy_image_block_CrCb()
415 *d++ = cm[c[2] >> scalebits]; in copy_image_block_CrCb()
416 *d++ = cm[c[6] >> scalebits]; in copy_image_block_CrCb()
417 *d++ = cm[c[3] >> scalebits]; in copy_image_block_CrCb()
418 *d++ = cm[c[7] >> scalebits]; in copy_image_block_CrCb()
420 d = dst + bytes_per_line; in copy_image_block_CrCb()
421 *d++ = cm[c[12] >> scalebits]; in copy_image_block_CrCb()
422 *d++ = cm[c[8] >> scalebits]; in copy_image_block_CrCb()
423 *d++ = cm[c[13] >> scalebits]; in copy_image_block_CrCb()
424 *d++ = cm[c[9] >> scalebits]; in copy_image_block_CrCb()
425 *d++ = cm[c[14] >> scalebits]; in copy_image_block_CrCb()
426 *d++ = cm[c[10] >> scalebits]; in copy_image_block_CrCb()
427 *d++ = cm[c[15] >> scalebits]; in copy_image_block_CrCb()
428 *d++ = cm[c[11] >> scalebits]; in copy_image_block_CrCb()
433 unsigned char *d = dst; in copy_image_block_CrCb()
436 *d++ = CLAMP((*c1) >> scalebits); in copy_image_block_CrCb()
437 *d++ = CLAMP((*c2) >> scalebits); in copy_image_block_CrCb()
440 d = dst + bytes_per_line; in copy_image_block_CrCb()
442 *d++ = CLAMP((*c1) >> scalebits); in copy_image_block_CrCb()
443 *d++ = CLAMP((*c2) >> scalebits); in copy_image_block_CrCb()
458 while (pdec->nbits_in_reservoir<(nbits_wanted)) \
460 pdec->reservoir |= (*(pdec->stream)++) << (pdec->nbits_in_reservoir); \
461 pdec->nbits_in_reservoir += 8; \
466 pdec->reservoir >>= (nbits_to_skip); \
467 pdec->nbits_in_reservoir -= (nbits_to_skip); \
472 result = (pdec->reservoir) & ((1U<<(nbits_wanted))-1); \
477 result = (pdec->reservoir) & ((1U<<(nbits_wanted))-1); \
482 ((pdec->reservoir) & ((1U<<(nbits_wanted))-1))
496 __get_nbits(pdec, pdec->nbits, primary_color); in decode_block()
502 pdec->temp_colors[i] = pdec->table_dc00[primary_color]; in decode_block()
509 pdec->temp_colors[i] = pdec->table_d800[primary_color]; in decode_block()
511 __get_nbits(pdec, 3, channel_v); in decode_block()
545 skip_nbits(pdec, 3); in decode_block()
556 mask = pdec->table_bitpowermask[nbits][col1]; in decode_block()
560 block = pdec->table_subblock[rows]; in decode_block()
562 pdec->temp_colors[i] += block[MulIdx[offset1][i]]; in decode_block()
566 * offset1 is coded on 3 bits in decode_block()
573 rows = ptable0004[offset1 + hash_table_ops [htable_idx * 4 + 3]]; in decode_block()
574 block = pdec->table_subblock[rows]; in decode_block()
576 pdec->temp_colors[i] += block[MulIdx[offset1][i]]; in decode_block()
598 pdec->reservoir = 0; in DecompressBand23()
599 pdec->nbits_in_reservoir = 0; in DecompressBand23()
600 pdec->stream = rawyuv + 1; /* The first byte of the stream is skipped */ in DecompressBand23()
607 ptable0004 = pdec->table_0004_pass1[compression_index]; in DecompressBand23()
608 ptable8004 = pdec->table_8004_pass1[compression_index]; in DecompressBand23()
613 copy_image_block_Y(pdec->temp_colors, planar_y, real_image_width, pdec->scalebits); in DecompressBand23()
615 nblocks--; in DecompressBand23()
621 ptable0004 = pdec->table_0004_pass2[compression_index]; in DecompressBand23()
622 ptable8004 = pdec->table_8004_pass2[compression_index]; in DecompressBand23()
627 copy_image_block_CrCb(pdec->temp_colors, planar_u, real_image_width/2, pdec->scalebits); in DecompressBand23()
630 copy_image_block_CrCb(pdec->temp_colors, planar_v, real_image_width/2, pdec->scalebits); in DecompressBand23()
634 nblocks -= 2; in DecompressBand23()
640 * pwc_dec23_decompress - Uncompress a pwc23 buffer.
650 struct pwc_dec23_private *pdec = &pdev->dec23; in pwc_dec23_decompress()
658 mutex_lock(&pdec->lock); in pwc_dec23_decompress()
660 bandlines_left = pdev->height / 4; in pwc_dec23_decompress()
661 bytes_per_block = pdev->width * 4; in pwc_dec23_decompress()
662 plane_size = pdev->height * pdev->width; in pwc_dec23_decompress()
668 while (bandlines_left--) { in pwc_dec23_decompress()
671 pdev->width, pdev->width); in pwc_dec23_decompress()
672 src += pdev->vbandlength; in pwc_dec23_decompress()
674 pout_planar_u += pdev->width; in pwc_dec23_decompress()
675 pout_planar_v += pdev->width; in pwc_dec23_decompress()
677 mutex_unlock(&pdec->lock); in pwc_dec23_decompress()