drivers/media/test-drivers/vicodec/codec-fwht.c
Source file repositories/reference/linux-study-clean/drivers/media/test-drivers/vicodec/codec-fwht.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/media/test-drivers/vicodec/codec-fwht.c- Extension
.c- Size
- 25011 bytes
- Lines
- 960
- Domain
- Driver Families
- Bucket
- drivers/media
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/string.hlinux/kernel.hlinux/videodev2.hcodec-fwht.h
Detected Declarations
function rlcfunction derlcfunction quantize_intrafunction dequantize_intrafunction quantize_interfunction dequantize_interfunction fwhtfunction fwht16function ifwhtfunction fill_encoder_blockfunction var_intrafunction var_interfunction decide_blocktypefunction fill_decoder_blockfunction add_deltasfunction encode_planefunction fwht_encode_framefunction decode_planefunction fwht_decode_frame
Annotated Snippet
while ((tmp = block[zigzag[i]]) == 0 && cnt < 14) {
cnt++;
i++;
if (i == to_encode) {
cnt--;
break;
}
}
/* 4 bits for run, 12 for coefficient (quantization by 4) */
*output++ = htons((cnt | tmp << 4));
i++;
ret++;
}
if (lastzero_run > 14) {
*output = htons(ALL_ZEROS | 0);
ret++;
}
return ret;
}
/*
* This function will worst-case increase rlc_in by 65*2 bytes:
* one s16 value for the header and 8 * 8 coefficients of type s16.
*/
static noinline_for_stack u16
derlc(const __be16 **rlc_in, s16 *dwht_out, const __be16 *end_of_input)
{
/* header */
const __be16 *input = *rlc_in;
u16 stat;
int dec_count = 0;
s16 block[8 * 8 + 16];
s16 *wp = block;
int i;
if (input > end_of_input)
return OVERFLOW_BIT;
stat = ntohs(*input++);
/*
* Now de-compress, it expands one byte to up to 15 bytes
* (or fills the remainder of the 64 bytes with zeroes if it
* is the last byte to expand).
*
* So block has to be 8 * 8 + 16 bytes, the '+ 16' is to
* allow for overflow if the incoming data was malformed.
*/
while (dec_count < 8 * 8) {
s16 in;
int length;
int coeff;
if (input > end_of_input)
return OVERFLOW_BIT;
in = ntohs(*input++);
length = in & 0xf;
coeff = in >> 4;
/* fill remainder with zeros */
if (length == 15) {
for (i = 0; i < 64 - dec_count; i++)
*wp++ = 0;
break;
}
for (i = 0; i < length; i++)
*wp++ = 0;
*wp++ = coeff;
dec_count += length + 1;
}
wp = block;
for (i = 0; i < 64; i++) {
int pos = zigzag[i];
int y = pos / 8;
int x = pos % 8;
dwht_out[x + y * 8] = *wp++;
}
*rlc_in = input;
return stat;
}
static const int quant_table[] = {
2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 3,
2, 2, 2, 2, 2, 2, 3, 6,
Annotation
- Immediate include surface: `linux/string.h`, `linux/kernel.h`, `linux/videodev2.h`, `codec-fwht.h`.
- Detected declarations: `function rlc`, `function derlc`, `function quantize_intra`, `function dequantize_intra`, `function quantize_inter`, `function dequantize_inter`, `function fwht`, `function fwht16`, `function ifwht`, `function fill_encoder_block`.
- Atlas domain: Driver Families / drivers/media.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.