📄 img_mpeg2_vld_inter.h
字号:
/* */
/* 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. */
/* */
/* NOTES */
/* This code is little ENDIAN. */
/* This code is interrupt-tolerant but not interruptible. */
/* */
/* MEMORY NOTES */
/* No bank conflicts */
/* */
/* CYCLES */
/* 10 * (S - CB) + 37 * CB + 15 * NCB + 34 */
/* where S: Number of symbols in MB, CB: Number of coded blocks, */
/* NCB: Number of not-coded blocks, and CB+NCB=6 */
/* */
/* CODE SIZE */
/* 1248 bytes */
/* */
/* MEMORY REQUIREMENTS */
/* 1792 bytes for the lookup tables */
/* (can be shared with mpeg2_vld_intra) */
/* */
/* */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2003 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
#ifndef IMG_MPEG2_VLD_INTER_H_
#define IMG_MPEG2_VLD_INTER_H_ 1
#ifndef IMG_MPEG2_VLD_STRUCT_
#define IMG_MPEG2_VLD_STRUCT_ 1
typedef struct {
unsigned int *bsbuf; // pointer to bitstream buffer
unsigned int next_wptr; // next word to read from buffer
unsigned int bptr; // bit position within word
unsigned int word1; // word aligned buffer
unsigned int word2; // word aligned buffer
unsigned int top0; // top 32 bits of bitstream
unsigned int top1; // next 32 bits of bitstream
const unsigned char *scan; // inverse zigzag scan matrix
unsigned int intravlc; // intra_vlc_format
unsigned int quant_scale; // quant_scale
unsigned int dc_prec; // intra_dc_precision
unsigned int cbp; // coded_block_pattern
unsigned int fault; // fault condition (returned)
unsigned int reserved; // reserved
} IMG_mpeg2_vld;
#endif
void IMG_mpeg2_vld_inter
(
const short *restrict Wptr,
short *restrict outi,
IMG_mpeg2_vld *restrict Mpeg2v,
int mode_12Q4,
int num_blocks,
int bsbuf_words
);
#endif
/* ======================================================================== */
/* End of file: img_mpeg2_vld_inter.h */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2003 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -