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

📄 mpeg2_vld_inter_n.sa

📁 h263,jpeg,mpeg2编解码核心程序(TI DSP C64xx)
💻 SA
📖 第 1 页 / 共 3 页
字号:
* ========================================================================= **   TEXAS INSTRUMENTS, INC.                                                 **                                                                           **   NAME                                                                    **       mpeg2_vld_inter                                                     **                                                                           **   PLATFORM                                                                **       C6400                                                               **                                                                           **   DESCRIPTION                                                             * *       This routine takes a bitstream of an MPEG-2 non-intra coded         * *       macroblock and returns the decoded IDCT coefficients. The routine   * *       is implemented as specified in the MPEG-2 standard text (ISO/IEC    * *       13818-2). The routine checks the coded block pattern (cbp),         * *       performs coefficient decoding inlcuding, variable length decode,    * *       run-length expansion, inverse zigzag, dequantization, saturation    * *       and mismatch control.                                               * *                                                                           * *   USAGE                                                                   * *       This routine is C callable, and has the following C prototype:      * *                                                                           * *       void mpeg2_vld_inter                                                * *       (                                                                   * *           const short    *restrict Wptr,                                  * *           short          *restrict outi,                                  * *           IMG_mpeg2_vld  *restrict Mpeg2v,                                * *           int            mode_12Q4,                                       * *           int            num_blocks,                                      * *           int            bsbuf_words                                      * *       );                                                                  * *                                                                           * *         Wptr:   Pointer to array that contains quantization matrix. The   * *                 elements of the quantization matrix in *Wptr must be      * *                 ordered according to the scan pattern used (zigzag or     * *                 alternate scan). Video format 4:2:0 requires one          * *                 quantization matrix (64 array elements).  For formats     * *                 4:2:2 and 4:4:4 two quantization matrices (one for luma   * *                 and one for chroma) must specified in the array (128      * *                 array elements).                                          * *                                                                           * *         outi:   Pointer to the IDCT coefficients output array             * *                 (6*64 elements), elements must be set to zero prior to    * *                 function call.                                            * *                                                                           * *         Mpeg2v: Pointer to the context object containing the coding       * *                 parameters of the MB to be decoded and the current state  * *                 of the bitstream buffer. The structure is described       * *                 below.                                                    * *                                                                           * *      mode_12Q4: 0: Coefficients are returned in normal 16-bit integer     * *                 format.                                                   * *                 Otherwise: Coefficients are returned in 12Q4 format       * *                 (normal 16-bit integer format left shifted by 4). This    * *                 mode is useful for directly passing the coefficients      * *                 into the IMG_idct_8x8 routine.                            * *                                                                           * *     num_blocks: Number of blocks that the MB contains. Valid values are   * *                 6 for 4:2:0, 8 for 4:2:2 and 12 for 4:4:4 format.         * *                                                                           * *    bsbuf_words: Size of bitstream buffer in words. Must be a power of 2.  * *                 Bitstream buffer must be aligned at an address boundary   * *                 equal to its size in bytes (bitstream buffer is           * *                 addressed circularly by this routine.)                    * *                                                                           * *       The structure Mpeg2v is defined as follows:                         * *                                                                           * *C          #ifndef IMG_MPEG2_VLD_STRUCT_                                   * *C          #define IMG_MPEG2_VLD_STRUCT_ 1                                 * *C                                                                          * *C          typedef struct {                                                * *C            unsigned int  *bsbuf;      // pointer to bitstream buffer     * *C            unsigned int  next_wptr;   // next word to read from buffer   * *C            unsigned int  bptr;        // bit position within word        * *C            unsigned int  word1;       // word aligned buffer             * *C            unsigned int  word2;       // word aligned buffer             * *C            unsigned int  top0;        // top 32 bits of bitstream        * *C            unsigned int  top1;        // next 32 bits of bitstream       * *C            const unsigned char *scan; // inverse zigzag scan matrix      * *C            unsigned int  intravlc;    // intra_vlc_format                * *C            unsigned int  quant_scale; // quant_scale                     * *C            unsigned int  dc_prec;     // intra_dc_precision              * *C            unsigned int  cbp;         // coded_block_pattern             * *C            unsigned int  fault;       // fault condition (returned)      * *C            unsigned int  reserved;    // reserved                        * *C          } IMG_mpeg2_vld;                                                * *C                                                                          * *C          #endif                                                          * *                                                                           * *       The Mpeg2v variables should  have a fixed layout since they are     * *       accessed by this routine. If the layout is changed, the             * *       corresponding changes have to be made in the assembly code too.     * *                                                                           * *       The routine sets the fault flag Mpeg2v.fault to 1 if an invalid     * *       VLC code was encountered or the total run went beyond 63. In        * *       theses cases the decoder has to resynchronize.                      * *S                                                                          * *S      The following files contain the required VLD look-up tables:        * *S          b14s_tbl.c    : run-level VLD table (1152 bytes, Table B-14)    * *S          b14_len_tbl.c : code word length table (640 bytes, Table B-14)  * *                                                                           * *       Before calling the routine the bitstream varaibles in Mpeg2v        * *       have to be initialized. If bsbuf is a circular buffer and bsptr     * *       contains the number of bits in the buffer that already have         * *       been consumed, then next_wptr, bptr, word1, word2, top0 and         * *       top1 are initialized as follows:                                    * *                                                                           * *       1. nextwptr: bsptr may not be a multiple of 32, therefore obtain    * *       the next lower multiple of 32.                                      * *                                                                           * *           next_wptr = (bsptr >> 5);                                       * *                                                                           * *       2. bptr: bptr is the bit pointer which points to the current        * *       bit WITHIN the word pointed to by next_wptr.                        * *                                                                           * *           bptr = bsptr & 31;                                              * *           bptr_cmpl = 32 - bptr;                                          * *                                                                           * *       3. word1 and word2: read next 3 words from the bitstream buffer     * *       (word0 is a temporary variable). bsbuf_words is the size of the     * *       bitstream buffer in words.                                          * *                                                                           * *           word0 = bsbuf[next_wptr];                                       * *           next_wptr = (next_wptr + 1) & (bsbuf_words-1);                  * *                                                                           * *           word1 = bsbuf[next_wptr];                                       * *           next_wptr = (next_wptr + 1) & (bsbuf_words-1);                  * *                                                                           * *           word2 = bsbuf[next_wptr];                                       * *           next_wptr = (next_wptr + 1) & (bsbuf_words-1);                  * *                                                                           * *       4. top0 and top1: Shift words word0, word1, word2 by bptr to the    * *       left so that the current bit becomes the MSB in word0. word0 can    * *       simply be shifted by bptr; the then empty LSBs of word0 have to be  * *       filled with the MSBs of word1. To do that the required MSBs are     * *       brought into the position of empty LSBs of word0 by shifting word1  * *       to the right by (32-bptr). The result is then copied into word0 by  * *       an addition. Rather than overwriting word0, top0 is used to hold    * *       the new bit aligned word. The same procedure is used to obtain      * *       top1. top0 and top1 contain the next 64 bits of the bitstream.      * *                                                                           * *           s1 = word0 << bptr;                                             * *           s2 = word1 >> bptr_cmpl;  // unsigned right-shift //            * *           top0 = s1 + s2;                                                 * *                                                                           * *           s3 = word1 << bptr;                                             * *           s4 = word2 >> bptr_cmpl;  // unsigned right-shift //            * *           top1 = s3 + s4;                                                 * *                                                                           * *       Note that the routine returns the updated state of the bitstream    * *       buffer variables, top0, top1, word1, word2, bptr and next_wptr. If  * *       all other functions which access the bitstream in a decoder system  * *       maintain the buffer variables in the same way, then the above       * *       initialization procedure has to be performed only once at the       * *       beginning.                                                          * *                                                                           * *                                                                           * *   TECHNIQUES                                                              * *       The instruction NORM is used to detect the number of leading zeros  * *       or ones in a code word. This value together with additional bits    * *       extracted from the codeword is then used as an index into look-up   * *       tables to determine the length, run, level and sign. Escape code    * *       sequences are directly extracted from the code word.                * *                                                                           * *   ASSUMPTIONS                                                             * *       The bitstream must be stored in memory in 32-bit words which are    * *       in little endian byte order.                                        * *                                                                           * *       Wptr is allowed to overrun once (to detect total run overrun), so   * *       maximum overrun that can occur is 66 (Error mark). Therefore,       * *       in memory 66+1 halfwords behind the weighting matrix should be      * *       valid (e.g. peripherals). No memory is overwritten,                 * *       only loads occurr.                                                  * *                                                                           * *       Note that the AMR register is set to zero on exit.                  * *                                                                           * *   MEMORY REQUIREMENTS                                                     * *       1792 bytes for the lookup tables                                    * *       (can be shared with mpeg2_vld_intra)                                * *                                                                           * *                                                                           * * ------------------------------------------------------------------------- **             Copyright (c) 2002 Texas Instruments, Incorporated.           **                            All Rights Reserved.                           ** ========================================================================= *            .sect ".text:nsa"            .global _mpeg2_vld_inter_nsa            .global _IMG_len_tbl0            .global _IMG_rld_table0_mpeg2_vld_inter_nsa .cproc Wptr, outi, Mpeg2v, m12Q4, num_blocks, bsbuf_size                    .no_mdep;                          A4,   B4,   A6,     B6,    A8,         B8* ========================================================================= **  Registers* ========================================================================= *    .reg block                      ; block number (0-3: lum, 4, 5: chrom)     .reg cnt, cnt_sav    .reg flag        .reg const1, const24, const31, const32, const63, const128, const36    .reg const65     .reg amr_config, csr_bk, no_gie* ------------------------------------------------------------------------- *

⌨️ 快捷键说明

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