⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ac_vld_decode_n.sa

📁 h263,jpeg,mpeg2编解码核心程序(TI DSP C64xx)
💻 SA
📖 第 1 页 / 共 4 页
字号:
* ========================================================================= **                                                                           **   TEXAS INSTRUMENTS, INC.                                                 **                                                                           **   NAME                                                                    **        ac_vld_decode                                                      **                                                                           **   USAGE                                                                   * *       This routine is C-callable and can be called as:                    * *                                                                           * *           unsigned char ac_vld_decode                                     * *           (                                                               * *               const unsigned char **data_ptr,                             * *               unsigned int        *data_word,                             * *               short               *run_level,                             * *               unsigned char       *num_of_rles,                           * *               unsigned char       *bit_position,                          * *               unsigned int        *used_up_bytes,                         * *               const AC_TBL_str    *ac_table                               * *           )                                                               * *                                                                           * *       data_ptr:      Points to the next byte of VLD buffer.               * *       data_word:     Pointer to word containing the first 32 bits of      * *                      bitstream.                                           * *       run_level:     Buffer where run/level pairs will be written         * *       num_of_rles:   Location to write number of run/level pairs          * *       bit_position:  Count of bits in "data_word" that are earlier        * *                      in the bitstream than the bits pointed to by         * *                      "data_ptr"                                           * *       used_up_bytes: Location to write number of bytes consumed.          * *       ac_table:      Structure containing pointers to the run, level,     * *                      and size tables, as well as the "eob_flag".          * *                      (The "eob_flag" is ignored.)                         * *                                                                           * *C          #ifndef AC_TBL_STRUCT_                                          * *C          #define AC_TBL_STRUCT_ 1                                        * *C                                                                          * *C          typedef struct AC_TBL_str                                       * *C          {                                                               * *C              unsigned char          eob_flag;                            * *C              const unsigned char    *run_ptr;                            * *C              const unsigned char    *sze_ptr;                            * *C              const unsigned char    *shf_ptr;                            * *C                                                                          * *C          } AC_TBL_str;                                                   * *C                                                                          * *C          #endif                                                          * *                                                                           * *       The pointer "data_ptr" points to the first byte in the data         * *       stream that is not completely contained within the state word.      * *                                                                           * *       The variable "bit_position" contains the count of bits that         * *       are in the "data_word" but which are before the "data_ptr" in       * *       the bitstream.                                                      * *                                                                           * *       The following diagram attempts to illustrate the relationship       * *       between the "data_word", "data_ptr", and "bit_position"             * *       arguments to ac_vld_decode().  (Each box is 1 byte / 8 bits.)       * *       In this example, we've already consumed 11 bits of the bitstream    * *       and are calling ac_vld_decode() to decode the remaining bits.       * *       (The 'x' denote bits that have already been consumed from the       * *       bitstream.)                                                         * *                                                                           * *                                                 data_ptr                  * *                                                points here                * *                                                     |                     * *                         1       2       3       4 __|__ 4       5         * *         0       8       6       4       2       0/     \8       6         * *         +-------+-------+-------+-------+-------+-------+-------+         * *         xxxxxxxxxxx     |       |       |       |       |       |         * *         +-------+--|----+-------+-------+-------+-|-----+-------+         * *                    |                              |                       * *                    |<-- contained in data_word -->|                       * *                                                                           * *                                                                           * *       In this example, "data_word" contains bits 11 through 42 of the     * *       bitstream, and "data_ptr" points to the byte containing bits        * *       40 through 47 of the bitstream.  In this setting, "bit_position"    * *       would contain "29", since three of the bits in "data_word"          * *       overlap bits in the byte pointed to by "data_ptr".                  * *                                                                           * *       In all circumstances, "bit_position" must be between 25 and 32 on   * *       entry to ac_vld_decode, and all 32 bits of "data_word" must be      * *       valid bits from the bitstream.                                      * *                                                                           * *       On exit from ac_vld_decode(), the "bit_position", "data_ptr", and   * *       "data_word" values are updated to reflect the current position in   * *       the bitstream, to allow chaining to other VLD routines that share   * *       this interface.                                                     * *                                                                           * *   DESCRIPTION                                                             * *       The encoded AC terms in a JPEG stream are in the following          * *       generalized format:                                                 * *                                                                           * *                       1 1 1 1 0 c c c c c l l l l l                       * *                                                                           * *       That is, zero or more leading 1's, a zero, some additional          * *       code-bits (which complete the Huffman code), followed by the        * *       non-sign bit portion of the "level" which this symbol encodes.      * *                                                                           * *       The JPEG VLD lookup tables are ordered according to Huffman         * *       codewords so that the left-most zero value can be used effectively  * *       as an index into the table.  Commonly occuring tables (such as      * *       tables K.5 and K.6 in the JPEG standard) have groups of codes       * *       which cluster naturally into four separate left-most zero ranges,   * *       as shown in the following table:                                    * *                                                                           * *           Left-Most Zero         Codewords                                * *           --------------         --------------------------------------   * *                                   0 x x x x x                             * *              0 thru 2             1 0 x x x x                             * *                                   1 1 0 x x x                             * *                                  |<---ofs--->|                            * *                                                                           * *                                   1 1 1 0 x x x x x                       * *              3 thru 5             1 1 1 1 0 x x x x                       * *                                   1 1 1 1 1 0 x x x                       * *                                        |<---ofs--->|                      * *                                                                           * *                                   1 1 1 1 1 1 0 x x x x x                 * *              6 thru 8             1 1 1 1 1 1 1 0 x x x x                 * *                                   1 1 1 1 1 1 1 1 0 x x x                 * *                                            |<----ofs---->|                * *                                                                           * *              9 thru 15            1 1 1 1 1 1 1 1 1 x x x x x x x         * *                                                  |<-----ofs----->|        * *                                                                           * *       This grouping lends itself to a lookup table which contains four    * *       subtables -- three using a 6-bit offset, and a fourth using a       * *       7-bit offset.  Additionally, the 6-bit subtables each have 8        * *       unused entries due to the slight overlap between left-most zero     * *       ranges.  The ranges marked "ofs" above denote the bits that are     * *       extracted for use as a table offset into the lookup table.          * *       (An extra leading '1' is extracted for two of the sub-tables, in    * *       order to simplify table-offset calculations.)                       * *                                                                           * *       As a result, the VLD lookup tables are laid out like so, for        * *       efficient lookups.                                                  * *                                                                           * *                0  +-----------------------------------+                   * *                   |                                   |                   * *                   |      0 <= left-most zero <= 2     |                   * *                   |                                   |                   * *               56  +-----------------------------------+                   * *                   |                                   |                   * *                   |      3 <= left-most zero <= 5     |                   * *                   |                                   |                   * *              112  +-----------------------------------+                   * *                   |            -- hole --             |                   * *              120  +-----------------------------------+                   * *                   |                                   |                   * *                   |      6 <= left-most zero <= 8     |                   * *                   |                                   |                   * *              176  +-----------------------------------+                   * *                   |            -- hole --             |                   * *              184  +-----------------------------------+                   * *                   |                                   |                   * *                   |                                   |                   * *                   |                                   |                   * *                   |                                   |                   * *                   |      9 <= left-most zero <= 15    |                   * *                   |                                   |                   * *                   |                                   |                   * *                   |                                   |                   * *                   |                                   |                   * *              312  +---+-------------------------------+                   * *                   |pad|                                                   * *              314  +---+                                                   * 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -