mp3
play

MP3 - PowerPoint PPT Presentation

MP3 V L S I / C A D Outline MPEG1 Audio Layer III Encoding MP3 Encoder Design MPEG1 Audio Layer III Decoding MP3


  1. MP3 系統設計與驗證 報告人 :林士生 指導教授:周哲民 成功大學電機研究所V L S I / C A D 組

  2. Outline � MPEG1 Audio Layer III Encoding � MP3 Encoder Design � MPEG1 Audio Layer III Decoding � MP3 Decoder Design � Synthesis Result and Verification 2

  3. Introduction to MPEG Audio Layer III Encoding MDCTin s i MDCTout X i PolyIn(ch0) X m Poly phase filter bank channel 0 pre- subband reorder MDCT processing PolyIn(ch1) X m channel 1 MDCToutR A/D converter Stereo Aliasing Psychoacoustic PCM win_type Processing reducing sample model MDCToutRA Loop side information Quantization SMR Scfsi Side Code & Bitstream table used encoder information formater Huffman encoder encoder scfsi Header CRC Side information Main data(gr0 ch0) Main data(gr0 ch1) … 3

  4. Poly Phase Analysis Filter Bank π = ∑∑ 63 7 = × + × − × × = M ik cos[ ( 2 i 1 ) ( k 16 )] s M ( C X ) for i 0 to 31 + + i ik k 64 j k 64 j 64 = = k 0 j 0 C k+64j window can be found in standard X k+64j is the input sample Shift 32 samples Shift 32 new samples into 512 512 buffer FIFO buffer X m …… X[i] multiply by C window c window …… For m=0 to 511 do Z m =C m *X m z vector 0 63 0 0 Calculate Y vector For k=0 to 63 + + …… + + = For j=0 to 7 Y k +=Z k+j*64 63 63 Multiply by MDCT vector 0 For i=0 to 31 SMDCT For k=0 to 63 31 s i +=M ik *Y k 4

  5. MDCT � Before MDCT, the subband output must pass through a window function. The window function is determined by the psychoacoustic model. As shown in Fig.3-6, Layer III has 4 MDCT windows: normal window (block_type=0), start window (block_type=1), short window (block_type=2), and stop window (block_type=3). π  1 π + = 1  sin( ( i )) for i 0 to 17 = + w sin( ( i )) 36 2  i 36 2  = 1 for i 18 to 23 =  for i 0 to 35 =  w π i 1  − + = sin( ( i 18 )) for i 24 to 29  12 2  =  0 for i 30 to 35   = 0 for i 0 to 5  π 1  = + π w sin( ( i ) ) 1  − + = i sin( ( i 6 )) for i 6 to 11 12 2  = 12 2  = = w i for i 0 to 11, k 0 to 2  = 1 for i 12 to 17  π  1 + = sin( ( i )) for i 18 to 35   36 2 5

  6. MDCT (cont.) � After windowing, the result will be as following in long block: z = s w s where is subband output i i i i � In short block, the result will be: = = = ( k ) ( k ) z y w for i 0 to 11 for k 0 to 2 i i i = = ( 0 ) y s for i 0 to 11 + i i 6 = = ( 1 ) y s for i 0 to 11 where + i i 12 = = ( 2 ) y s for i 0 to 11 + i i 18 s and is subband output i � The MDCT is calculated by − π n 1 n n ∑ = + + + = − x z cos( ( 2 k 1 )( 2 i 1 )) for i 0 to 1 i k 2 n 2 2 = k 0 for long block, n=36, for short block, n=18 6

  7. MDCT (cont.) 1 . 2 w i 1 0 . 8 0 . 6 z = s w 0 . 4 i i i 0 . 2 8 7 0 6 0 5 1 0 1 5 2 0 2 5 3 0 3 5 4 0 5 4 3 9 s i 2 8 7 1 6 0 5 0 5 1 0 1 5 2 0 2 5 3 0 3 5 4 0 - 1 4 3 2 1 0 - 1 0 1 0 2 0 3 0 4 0 7

  8. Reordering � Before reordering, in long window, frequency lines ordered firstby subband and then by frequency. � Before reordering, in short window , frequency lines ordered first by subband and then by window and at last by frequency. � In order to increase the efficiency of the Huffman coding the fr equency lines for the short windows case were reordered into subbands first , then frequency and at last by window. Reordering is needed only in short window(type= 2) sb0 sb1 sb31 Long 0 1 2 … 5 6 7 … 11 12 … 17 0 1 2 … 5 6 7 … 11 12 … 17 0 1 2 … 5 6 7 … 11 12 … 17 window Short 0 1 … 5 6 7 … 11 12 … 17 0 1 … 5 6 7 … 11 12 … 17 0 1 … 5 6 7 … 11 12 … 17 window 0 6 12 1 7 13 .. 5 11 17 0 6 12 1 7 13 .. 5 11 17 0 6 12 1 7 13 .. 5 11 17 sb0 sb1 sb31 8

  9. Alias Reduction for Long Block � After MDCT, an alias reduction is processed for long block to remove some artifacts caused by the overlapping bands of the poly phase filter bank. The calculation is done by a butterfly form, which is shown as following: cs i + xr i xra i 1 c ca i = = = — i 0 ~ 7 cs ca i i i + + 2 2 1 c 1 c i i + ca i c xr i+k xra i+k where are constants, which can be found in the standard. i cs i + = × − × xra xr cs xr ca + i i i i k i = × + × xra xr cs xr ca + + i k i k i i i spectral index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 9

  10. Scfsi Encoder scfsi= 1 xr (i),block type N all spectrum != 0? Y ∑ − < en ( sb ) en ( sb ) en ( scfsi _ band ) 0 1 krit N No short block ? Y Y N − < en _ tot en _ tot en _ tot ∑ 0 1 krit − < xm ( sb ) xm ( sb ) xm ( scfsi _ band ) 0 1 krit Y Y N ∑ − < en ( sb ) en ( sb ) en _ dif 0 1 krit all scalefacto r band Y scfsi= 0 10

  11. Scfsi Encoder C a l c u l a t e t h e t o t a l e n e r g y o f e a c h g r a n u l e for ( temp = 0, i = samp_per_frame2; i--; ) for ( temp = 0, i = samp_per_frame2; i--; ) temp + = sq(xr[ i] ); temp + = sq(xr[ i] ); n ∑ 2 if ( temp ) log xr ( i ) if ( temp ) n ∑ = 2 = en_tot[gr] [ch] = log( temp ) / log2 ; = i 1 en _ tot log xr ( i ) en_tot[gr] [ch] = log( temp ) / log2 ; 2 log 2 else = else i 1 en_tot[gr] [ch] = 0; W h e r e x r ( i ) a r e t h e s p e c t r a l v a l u e s en_tot[gr] [ch] = 0; for(sfb= 21; sfb--; ){ for(sfb= 21; sfb--; ){ C a l c u l a t e t h e e n e r g y o f e a c h start = scalefac_band_long[ sfb ] ; start = scalefac_band_long[ sfb ] ; s c a l e f a c t o rb a n d end = scalefac_band_long[ sfb+ 1 ]; end = scalefac_band_long[ sfb+ 1 ]; for ( temp = 0.0, i = start; i < end; i+ + ) for ( temp = 0.0, i = start; i < end; i+ + ) + − lbl ( sb ) bw ( sb ) 1 ∑ temp + = xr[i] * xr[ i] ; 2 = temp + = xr[i] * xr[ i] ; en ( sb ) log xr ( i ) 2 if ( !temp ) if ( !temp ) = i lbl ( sb ) en[gr] [ ch][sfb] = 0.0; en[gr] [ ch][sfb] = 0.0; W h e r e l b l ( s f b ) i s t h e l o w e r else else b o u n d a r y o f s c a l e f a c t o rb a n d en[gr] [ ch][sfb] = log( temp )/ log2; en[gr] [ ch][sfb] = log( temp )/ log2; s f b , b w ( s f b ) i s t h e w i d t h o f if ( l3_xmin-> l[gr] [ ch] [sfb] ) if ( l3_xmin-> l[gr] [ ch] [sfb] ) s c a l e f a c t o r s f b xm[gr] [ ch][sfb] = log( l3_xmin-> l[gr][ ch][sfb] ) / log2; xm[gr] [ ch][sfb] = log( l3_xmin-> l[gr][ ch][sfb] ) / log2; else else xm[gr] [ ch][sfb] = 0.0; xm[gr] [ ch][sfb] = 0.0; } } 11

  12. Scfsi Encoder for ( sfb = cod_info-> sfb_lmax; sfb--; ) { for ( sfb = cod_info-> sfb_lmax; sfb--; ) { C a l c u l a t e t h e a l l o w e d d i s t o r t i o n o f start = scalefac_band_long[ sfb ] ; start = scalefac_band_long[ sfb ] ; e a c h s c a l e f a c t o rb a n d end = scalefac_band_long[ sfb+ 1 ]; end = scalefac_band_long[ sfb+ 1 ]; = bw = end - start; xm ( sfb ) int{log x min( sfb )} bw = end - start; 2 + − lbl ( sb ) bw ( sb ) 1 i ∑ 2 xr ( i ) for ( en = 0, l = start; l < end; l+ + ) for ( en = 0, l = start; l < end; l+ + ) = = × lbl ( sb ) x min( sfb ) ratio en + = xr[gr] [ ch][l] * xr[gr][ ch][l]; en + = xr[gr] [ ch][l] * xr[gr][ ch][l]; bw ( sb ) l3_xmin-> l[gr] [ ch] [sfb] = l3_xmin-> l[gr] [ ch] [sfb] = ratio-> l[gr] [ch][sfb] * en / bw; ratio-> l[gr] [ch][sfb] * en / bw; } } 內定值 = en _ tot 10 krit = en _ dif 100 krit = en ( scfsi _ band ) 10 for all band krit = xm ( scfsi _ band ) 10 for all band krit 12

  13. Scale factor length sample frequency = 44.1kHz Long block (block type=0,1,3) : scfsi 0 1 2 3 band 0 1 … 5 6 … 10 11 … 15 16 … 20 21 範圍 0~3 4~7 … 20~2 24~2 … 52~6 62~7 … 134~1 162~1 … 342~4 418~57 3 9 1 3 61 95 17 5 全部填 0 scalefactor 長度 =slen1 scalefactor 長度 =slen2 = × + × part 2 _ length 11 slen 1 10 slen 2 Short block (block type=2 and mixed_block_flag=0) : band 0 … 5 6 … 11 12 範圍 0~3 4~7 8~11 … … … 66~ 90~ … … … 318~ 348~ 378~ 408~ 89 119 347 377 407 575 全部填 0 scalefactor 長度 =slen1 scalefactor 長度 =slen2 = × × + × × part 2 _ length ( 6 3 ) slen 1 ( 6 3 ) slen 2 13

Recommend


More recommend