📄 h263_vld_c.h
字号:
/* *//* Last(1/0) RUNVALUE LEVEL *//* 14 13....8 7....0 *//* *//* The code word used in this context refers to the run, level *//* associated with each Huffman code word that is decoded and not *//* to the Huffman code word itself. *//* *//* Each code word thus has a pad of 2 bits and is stored as a half *//* word *//* *//* Example: *//* *//* 1) Code: 0000 0000 110s Run: 0 Level: 11 *//* *//* Clearly for this code f5 the first 5 bits from the left are zero. *//* first 12 bits from the left are extracted in idx1. If the upper *//* 5 bits are zero then idx1 can have a maximum value of upto 127. *//* In this case this value will be either 13 or 14 depending on the *//* sign bit. *//* 0 000000 001011 -------------> 0x0b *//* *//* *//* The length table is a set of values constructed as follows. The *//* code words are taken and divided into two categories for this *//* purpose: *//* Class 1: Codes 00000xxxxx...00011xxxxx *//* Class 2: Codes 001xxxxx...1xxxxx *//* Therfore it can be seen that under class 2 there can be a set of *//* 32 codes and under class 1 there are 60 enties that the given *//* code table maps into. Therfore there are a total of 32 entries. *//* This can be seen by way of example: *//* *//* Code at Index: 50 of the Table 16 in H.263 spec *//* *//* Run: 19 Level: 1 Code: 0000 1110 1s and falls under Class 1 *//* When the 9 left most bits are examined this gives us 29. The *//* 29th entry in the length table gives us the length of the code *//* word as 10. *//* *//* *//* Similarly a code at Index 40 of the Table 16 in H.263 spec *//* *//* Run: 10 Level: 1 Code: 0010110s. This comes under Class 2 and *//* hence the 5 left most bits are extracted to give an index of 5 *//* The code lengths for these class of codes is stored with an *//* implicit offset of 60 and hence this code's length is actually *//* stored at location 65. The 65 th entry from the length table is *//* 8 and corresponds to the length of the code. *//* *//* *//* The entries in the Zig-Zag table are expected to be in the range *//* 0 .. 63, with no repeated entries. The VLD starts reading the *//* Zig-Zag table at zz[1], and under normal circumstances will not *//* read past element zz[63]. However, when an invalid bitstream is *//* encountered, elements as high as zz[126] may be accessed. See *//* the MEMORY NOTE below for more information. *//* *//* INVERSE QUANTIZATION *//* This is specified in Section 6.2.1 where the reconstructed level *//* is specified as follows: *//* *//* |REC| = Quant * (2* |Level| + 1) if Quant = 'odd' *//* |REC| = Quant * (2* |Level| + 1) - 1 if Quant = 'even' *//* *//* The terms are expanded out to: *//* *//* |REC| = (Quant*2)*Level + Quant if Quant = 'odd' *//* |REC| = (Quant*2)*Level + Quant - 1 if Quant = 'even' *//* *//* |REC| = Q * Level + dQ *//* *//* Note that in both cases dQ is odd. This process for generating *//* dQ is sometimes referred to as "oddification", as it results in *//* IDCT coeffficients that are all odd. The goal of oddification is *//* to reduce IDCT mismatch errors. *//* *//* ASSUMPTIONS *//* Speculative reads are OK. See MEMORY NOTE below. *//* *//* Short (as in, invalid due to truncation) bitstreams are followed *//* by sentinel values to halt VLD with an error condition, to prevent *//* underflow. *//* *//* MEMORY NOTE *//* The VLD routine will read up to two full words beyond the final *//* position of the bitstream word pointer, as part of its lookahead. *//* The user must ensure that two words of valid memory exist there. *//* *//* Speculative reads are performed to each of the following arrays: *//* (Ranges are in bytes, and are inclusive.) *//* *//* Table/Array Valid Range Accessed Range *//* *//* Zig-Zag Table 0..63 0..127 *//* Length Table 0..91 0..511 *//* Coef/Run Table 0..607 0..607 *//* *//* The user should ensure that valid (eg. CPU readable) memory *//* exists in the required ranges past the end of each table. *//* *//* Alternately, to ensure that these reads do not reduce cache *//* effectiveness (C6211) and do not access invalid memory, the *//* following table layout is recommended, as it causes all *//* speculative reads to land inside other valid table entries: *//* *//* Bytes 0 .. 63 'zz' Zig-Zag table *//* Bytes 64 .. 159 'len' Huffman-code Length table *//* Bytes 160 .. 767 'tab' Huffman-code Coefficient/Run Table *//* *//* NOTES *//* The input bitstream must be "word order", meaning that it is *//* accessed with word-wide reads. *//* *//* ------------------------------------------------------------------------ *//* Copyright (c) 2002 Texas Instruments, Incorporated. *//* All Rights Reserved. *//* ======================================================================== */#ifndef H263_VLD_C_H_#define H263_VLD_C_H_ 1int h263_vld_cn( unsigned int *restrict *restrict bufPtr, int *restrict bitPtr, const unsigned short *restrict tab, const unsigned char *restrict len, short Q, int dq, const unsigned char *restrict zz, short *restrict idct, int inter);#endif/* ======================================================================== *//* End of file: h263_vld_c.h *//* ------------------------------------------------------------------------ *//* Copyright (c) 2002 Texas Instruments, Incorporated. *//* All Rights Reserved. *//* ======================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -