PEZW_textureLayerBQ.cpp
上传用户:sun1608
上传日期:2007-02-02
资源大小:6116k
文件大小:22k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /****************************************************************************/
  2. /*   MPEG4 Visual Texture Coding (VTC) Mode Software                        */
  3. /*                                                                          */
  4. /*   This software was jointly developed by the following participants:     */
  5. /*                                                                          */
  6. /*   Single-quant,  multi-quant and flow control                            */
  7. /*   are provided by  Sarnoff Corporation                                   */
  8. /*     Iraj Sodagar   (iraj@sarnoff.com)                                    */
  9. /*     Hung-Ju Lee    (hjlee@sarnoff.com)                                   */
  10. /*     Paul Hatrack   (hatrack@sarnoff.com)                                 */
  11. /*     Shipeng Li     (shipeng@sarnoff.com)                                 */
  12. /*     Bing-Bing Chai (bchai@sarnoff.com)                                   */
  13. /*     B.S. Srinivas  (bsrinivas@sarnoff.com)                               */
  14. /*                                                                          */
  15. /*   Bi-level is provided by Texas Instruments                              */
  16. /*     Jie Liang      (liang@ti.com)                                        */
  17. /*                                                                          */
  18. /*   Shape Coding is provided by  OKI Electric Industry Co., Ltd.           */
  19. /*     Zhixiong Wu    (sgo@hlabs.oki.co.jp)                                 */
  20. /*     Yoshihiro Ueda (yueda@hlabs.oki.co.jp)                               */
  21. /*     Toshifumi Kanamaru (kanamaru@hlabs.oki.co.jp)                        */
  22. /*                                                                          */
  23. /*   OKI, Sharp, Sarnoff, TI and Microsoft contributed to bitstream         */
  24. /*   exchange and bug fixing.                                               */
  25. /*                                                                          */
  26. /*                                                                          */
  27. /* In the course of development of the MPEG-4 standard, this software       */
  28. /* module is an implementation of a part of one or more MPEG-4 tools as     */
  29. /* specified by the MPEG-4 standard.                                        */
  30. /*                                                                          */
  31. /* The copyright of this software belongs to ISO/IEC. ISO/IEC gives use     */
  32. /* of the MPEG-4 standard free license to use this  software module or      */
  33. /* modifications thereof for hardware or software products claiming         */
  34. /* conformance to the MPEG-4 standard.                                      */
  35. /*                                                                          */
  36. /* Those intending to use this software module in hardware or software      */
  37. /* products are advised that use may infringe existing  patents. The        */
  38. /* original developers of this software module and their companies, the     */
  39. /* subsequent editors and their companies, and ISO/IEC have no liability    */
  40. /* and ISO/IEC have no liability for use of this software module or         */
  41. /* modification thereof in an implementation.                               */
  42. /*                                                                          */
  43. /* Permission is granted to MPEG members to use, copy, modify,              */
  44. /* and distribute the software modules ( or portions thereof )              */
  45. /* for standardization activity within ISO/IEC JTC1/SC29/WG11.              */
  46. /*                                                                          */
  47. /* Copyright 1995, 1996, 1997, 1998 ISO/IEC                                 */
  48. /****************************************************************************/
  49. /****************************************************************************/
  50. /*     Texas Instruments Predictive Embedded Zerotree (PEZW) Image Codec    */
  51. /*    Developed by Jie Liang (liang@ti.com)                                */
  52. /*                         */ 
  53. /*     Copyright 1996, 1997, 1998 Texas Instruments                    */
  54. /****************************************************************************/
  55. /****************************************************************************
  56.    File name:         PEZW_textureLayerBQ.c
  57.    Author:            Jie Liang  (liang@ti.com)
  58.    Functions:         main control module for PEZW coding. Functions in this
  59.                       file are the only interface with other parts of MPEG4 
  60.                       code along with the global variables in wvtPEZW.h.
  61.    Revisions:         v1.0 (10/04/98)
  62. *****************************************************************************/
  63. #include "wvtPEZW.hpp"
  64. #include "PEZW_mpeg4.hpp"
  65. #include "PEZW_zerotree.hpp"
  66. #include "wvtpezw_tree_codec.hpp"
  67. #include <PEZW_functions.hpp>
  68. #include "dataStruct.hpp"
  69. #include "globals.hpp"
  70. #include "msg.hpp"
  71. #include "bitpack.hpp"
  72. #include "startcode.hpp"
  73. /* decoding parameters imported form main.c.
  74.    they should be defined before calling PEZW decoder. */
  75. int PEZW_target_spatial_levels=10;
  76. int PEZW_target_snr_levels=20;
  77. int PEZW_target_bitrate=0;
  78. void CVTCEncoder::textureLayerBQ_Enc(FILE *bitfile)
  79. {
  80.   PEZW_SPATIAL_LAYER *SPlayer[3];
  81.   int h,w;
  82.   int Quant[3];
  83.   int levels, col;
  84.   static short **wvt_coeffs;
  85.   int snrlev,splev;
  86.   int dc_w, dc_h;
  87.   int temp;
  88.   int i,j,bplane;
  89.    
  90.   /*------- AC: encode all color components -------*/
  91.   for (col=0; col<mzte_codec.m_iColors; col++)
  92.     { 
  93.       printf("Bilevel-Quant Mode - Color %dn",col);
  94.       
  95.       if (col ==0)  /* Lum */
  96.     {
  97.         h = mzte_codec.m_iHeight;
  98.         w = mzte_codec.m_iWidth;
  99.         levels = mzte_codec.m_iWvtDecmpLev;
  100.     }
  101.       else { /* should depend on mzte_codec.color_format;
  102. not implemented yet, only support 4:2:0  */
  103.     h = mzte_codec.m_iHeight/2;
  104.     w = mzte_codec.m_iWidth/2;
  105.     levels = mzte_codec.m_iWvtDecmpLev-1;
  106.       }
  107.       
  108.       /* initialize data */
  109.       SPlayer[col] = Init_PEZWdata (col,levels,w,h);
  110.       wvt_coeffs = (WINT **)calloc(h,sizeof(WINT *));
  111.       wvt_coeffs[0] = (WINT *)(SPlayer[col][0].SNRlayer[0].snr_image.data);
  112.       for(i=1;i<h;i++)
  113.         wvt_coeffs[i] = wvt_coeffs[0]+i*w;
  114.       /* quantization */
  115.       Quant[col] = mzte_codec.m_Qinfo[col]->Quant[0];
  116.       dc_w = w>>levels;
  117.       dc_h = h>>levels;
  118.       for(i=0;i<h;i++)
  119.           for(j=0;j<w;j++)
  120.               {
  121.                 if((i<dc_h) && (j<dc_w))
  122.                     continue;
  123.                 temp = abs(wvt_coeffs[i][j])/Quant[col];
  124.                 wvt_coeffs[i][j] = (wvt_coeffs[i][j]>0)?temp:-temp;
  125.               }
  126.       
  127.       /* encode this color componenet */
  128.       /* initialize the PEZW codec */
  129.       PEZW_encode_init (levels, w, h);
  130.       setbuffer_PEZW_encode ();
  131.       /* encode the AC bands */
  132.       PEZW_encode_block (wvt_coeffs,w,h);
  133.       /* done coding */ 
  134.       PEZW_encode_done ();
  135.       /* copy bitstream to data structure */
  136.       for (splev=0;splev<levels;splev++)   /* from coarse scale to fine scale */
  137.           {
  138.           SPlayer[col][splev].SNR_scalability_levels = Max_Bitplane;
  139.           for(snrlev=SPlayer[col][splev].SNR_scalability_levels-1;snrlev>=0;snrlev--) /* from msb to lsb */
  140.               {
  141.                 /* for SPlayer, snrlayer 0 means msb bits, need to invert order */
  142.                 bplane = SPlayer[col][splev].SNR_scalability_levels-snrlev-1;
  143.                 SPlayer[col][splev].SNRlayer[bplane].Quant = Quant[col];
  144.                 SPlayer[col][splev].SNRlayer[bplane].snr_bitstream.data = PEZW_bitstream[splev][snrlev];
  145.                 SPlayer[col][splev].SNRlayer[bplane].snr_bitstream.length = Init_Bufsize[splev][snrlev];
  146.                 SPlayer[col][splev].SNRlayer[bplane].bits_to_go = bits_to_go_inBuffer[splev][snrlev];
  147.               }
  148.           }
  149.       /* free memory */
  150.       free (wvt_coeffs);      
  151.       /* free memory */
  152.       free (wvt_coeffs);      
  153.       for (i=0;i<levels;i++)
  154.           free(Init_Bufsize[i]);
  155.       free(Init_Bufsize);
  156.       for (i=0;i<levels;i++)
  157.           free(PEZW_bitstream[i]);
  158.       free(PEZW_bitstream);
  159.       for (i=0;i<levels;i++)
  160.           free(bits_to_go_inBuffer[i]);
  161.       free(bits_to_go_inBuffer);
  162.     }        
  163.   
  164.   /* package the bitstream and write to bitfile */
  165.   PEZW_bitpack (SPlayer);
  166.   flush_bits();
  167.   flush_bytes();
  168.   fclose(bitfile);
  169.   /* free memory */
  170.   PEZW_freeEnc (SPlayer);  
  171. }
  172. void CVTCDecoder::textureLayerBQ_Dec(FILE *bitfile)
  173. {
  174.    PEZW_SPATIAL_LAYER **SPlayer;
  175.    int col,snrlev,splev;
  176.    static short **wvt_coeffs;
  177.    int levels = 0,h,w;
  178.    int i,j,bplane;
  179.    int Quant[3];
  180.    int dc_w, dc_h, temp;
  181.    int all_zero[3]={0,0,0};
  182.    int all_non_zero[3]={1,1,1};
  183.    int LH_zero[3]={0,0,0}, HL_zero[3]={0,0,0}, HH_zero[3]={0,0,0};
  184.    int splev_start;
  185.    unsigned char **splev0_bitstream = NULL;
  186.    int *splev0_bitstream_len = NULL;
  187.    long total_decoded_bytes=0, bytes_decoded=0;
  188.    SPlayer = (PEZW_SPATIAL_LAYER **)calloc(mzte_codec.m_iColors, sizeof(void *))
  189. ;
  190.    mzte_codec.m_iScanOrder = mzte_codec.m_iScanDirection;
  191.    
  192.    /* bytes already decoded for DC and header */
  193.    bytes_decoded = decoded_bytes_from_bitstream ();
  194.    /* parse the bitstreams into spatial and snr layers */
  195.    PEZW_bit_unpack (SPlayer);
  196.    /* rate control according to target_bit_rate */
  197.    PEZW_decode_ratecontrol (SPlayer, bytes_decoded);
  198.    /* decode each color component */
  199.    for (col=0; col<mzte_codec.m_iColors; col++)
  200.     { 
  201.       printf("Bilevel-Quant Mode - Color %dn",col);
  202.       
  203.       if (col ==0)  /* Lum */
  204.     {
  205.         h = mzte_codec.m_iHeight;
  206.         w = mzte_codec.m_iWidth;
  207.         levels = mzte_codec.m_iWvtDecmpLev;
  208.     }
  209.       else { /* should depend on mzte_codec.color_format;
  210. not implemented yet, only support 4:2:0  */
  211.     h = mzte_codec.m_iHeight/2;
  212.     w = mzte_codec.m_iWidth/2;
  213.     levels = mzte_codec.m_iWvtDecmpLev-1;
  214.       }
  215.       
  216.       /* decode the bitstream */
  217.       /* initialize the PEZW codec */
  218.       Max_Bitplane = SPlayer[col][0].SNR_scalability_levels;
  219.       PEZW_decode_init (levels, w, h);
  220.       if(col==0)    /* the bitplane level of Y is assumed to be larger than U,V */
  221.           {
  222.             PEZW_bitstream = (unsigned char ***) calloc(levels,sizeof(int **));
  223.             for(i=0;i<levels;i++)
  224.                 PEZW_bitstream[i]= (unsigned char **)calloc(Max_Bitplane,sizeof(int *));
  225.             splev0_bitstream = (unsigned char **)calloc(Max_Bitplane,sizeof(char *));
  226.             splev0_bitstream_len = (int *)calloc(Max_Bitplane,sizeof(int));
  227.             Init_Bufsize = (int **) calloc(levels,sizeof(int *));
  228.             for(i=0;i<levels;i++)
  229.                 Init_Bufsize[i]= (int *)calloc(Max_Bitplane,sizeof(int));
  230.             /* decoded bytes */
  231.             decoded_bytes = (int **)calloc(tree_depth,sizeof(int *));
  232.             for (i=0;i<tree_depth;i++)
  233.           decoded_bytes[i]=(int *)calloc(Max_Bitplane,sizeof(int));
  234.             /* bits_to_go structure */
  235.             bits_to_go_inBuffer = (unsigned char **)calloc(tree_depth,sizeof(char *));
  236.             for (i=0;i<tree_depth;i++)
  237.           bits_to_go_inBuffer[i]=(unsigned char *)calloc(Max_Bitplane,sizeof(char));         
  238.           }
  239.        
  240.      /* get the bitstreams for each color */
  241.      /* for YUV420, the U,V color component has one less level */
  242.      if(col==1)
  243.          splev_start=1;
  244.      else
  245.          splev_start=0;
  246.      for (splev=0;splev<levels-spatial_leveloff;splev++)   /* from coarse scale to fine scale */
  247.           {
  248.           for(snrlev=SPlayer[0][splev].SNR_scalability_levels-1;snrlev>=Min_Bitplane;snrlev--) /* from msb to lsb */
  249.               {
  250.                 /* for SPlayer, snrlayer 0 means msb bits, need to invert order */
  251.                 bplane = SPlayer[col][splev].SNR_scalability_levels-snrlev-1;
  252.                 if(col==0)
  253.                     {
  254.                         Init_Bufsize[splev][snrlev] = SPlayer[0][splev].SNRlayer[bplane].snr_bitstream.length;  
  255.                         PEZW_bitstream[splev][snrlev] = (unsigned char *) SPlayer[0][splev].SNRlayer[bplane].snr_bitstream.data;
  256.                         if(splev==0){
  257.                             splev0_bitstream[snrlev] = PEZW_bitstream[0][snrlev];
  258.                             splev0_bitstream_len[snrlev] = Init_Bufsize[0][snrlev];
  259.                         }
  260.                     }
  261.                 else{
  262.                         Init_Bufsize[splev][snrlev] = Init_Bufsize[splev+splev_start][snrlev];
  263.                         PEZW_bitstream[splev][snrlev] = PEZW_bitstream[splev+splev_start][snrlev];
  264.                         reach_budget[splev][snrlev] = reach_budget[splev+splev_start][snrlev];
  265.                     }  
  266.                 
  267.                 /* get all zero and subband skipping info. */
  268.                 if(splev==0){
  269.                     all_non_zero[col] = lshift_by_NBit (splev0_bitstream[snrlev], splev0_bitstream_len[snrlev], 1);
  270.                     if(!all_non_zero[col]){
  271.                         all_zero[col] = lshift_by_NBit (splev0_bitstream[snrlev], splev0_bitstream_len[snrlev], 1);
  272.                         if(!all_zero[col]){
  273.                             LH_zero[col] = lshift_by_NBit (splev0_bitstream[snrlev], splev0_bitstream_len[snrlev], 1);
  274.                             HL_zero[col] = lshift_by_NBit (splev0_bitstream[snrlev], splev0_bitstream_len[snrlev], 1);
  275.                             HH_zero[col] = lshift_by_NBit (splev0_bitstream[snrlev], splev0_bitstream_len[snrlev], 1);
  276.                         }
  277.                      }
  278.                     else
  279.                         all_zero[col]=0;
  280.                  }
  281.                 if(all_zero[col] && (splev==0))
  282.                     Max_Bitplane--;
  283.                 if(all_zero[col]){
  284.                     decoded_bytes[splev][snrlev] = 0;
  285.                     continue;
  286.                     }
  287.                 else    /* skip the leading '1' */
  288.                     lshift_by_NBit (PEZW_bitstream[splev][snrlev], Init_Bufsize[splev][snrlev], 1);                                     
  289.               }  /* end of snrlev */
  290.          }  /* end of splev */
  291.       /* allocate wvt_coeffs */
  292.       wvt_coeffs = (WINT **)calloc(h,sizeof(WINT *));
  293.       wvt_coeffs[0] = (WINT *)(SPlayer[col][0].SNRlayer[0].snr_image.data);
  294.       for(i=1;i<h;i++)
  295.         wvt_coeffs[i] = wvt_coeffs[0]+i*w;
  296.       if(Max_Bitplane>0){
  297.          /* this step must follow the previous step */
  298.          setbuffer_PEZW_decode ();
  299.         /* decode the bitstream for this color component */
  300.         PEZW_decode_block (wvt_coeffs,w,h);
  301.         /* finish PEZW coding for this color component
  302.             retrun the number of bytes decoded in Init_Bufsize */
  303.         PEZW_decode_done ( );
  304.         for(splev=0;splev<levels-spatial_leveloff;splev++)
  305.             for(snrlev=Min_Bitplane;snrlev<Max_Bitplane;snrlev++)
  306.                 {
  307.                 total_decoded_bytes += decoded_bytes[splev][snrlev];
  308.                 if(col<2){
  309.                      /* adjust for residue bits in last byte */
  310.                         unsigned char Bit;
  311.                         //unsigned char *data;
  312.                         PEZW_bitstream[splev][snrlev] += decoded_bytes[splev][snrlev];
  313.                         Init_Bufsize[splev][snrlev] -= decoded_bytes[splev][snrlev];
  314.                         
  315.                         Bit = (*(PEZW_bitstream[splev][snrlev]-1)>>bits_to_go_inBuffer[splev][snrlev])&0x01;
  316.                 if(bits_to_go_inBuffer[splev][snrlev]>0){
  317.                     PEZW_bitstream[splev][snrlev]--;
  318.                     Init_Bufsize[splev][snrlev]++;
  319.                     lshift_by_NBit(PEZW_bitstream[splev][snrlev],Init_Bufsize[splev][snrlev],
  320.                                 8-bits_to_go_inBuffer[splev][snrlev]);
  321.                 }
  322.                 /* check last bit */
  323.                 if(!Bit)
  324.                     lshift_by_NBit(PEZW_bitstream[splev][snrlev],Init_Bufsize[splev][snrlev],1);
  325.                         if((splev==0)&&(col==0)){
  326.                             splev0_bitstream[snrlev] = PEZW_bitstream[0][snrlev];
  327.                             splev0_bitstream_len[snrlev] = Init_Bufsize[0][snrlev];
  328.                         }
  329.                 }
  330.               }
  331.       }
  332.      /* dequantize */
  333.      Quant[col] = SPlayer[col][0].SNRlayer[0].Quant;
  334.      dc_w = w>>levels;
  335.      dc_h = h>>levels;
  336.      for(i=0;i<h;i++)
  337.           for(j=0;j<w;j++)
  338.               {
  339.                 if((i<dc_h) && (j<dc_w))
  340.                     continue;
  341.                 if(wvt_coeffs[i][j]==0)
  342.                     temp = 0;
  343.                 else
  344.                     temp = (int)((abs(wvt_coeffs[i][j])+0.5)*Quant[col]);
  345.                 wvt_coeffs[i][j] =  (wvt_coeffs[i][j]>0)?temp:-temp;
  346.              }
  347.     /* copy data to structure */
  348.     (SPlayer[col][0].SNRlayer[0].snr_image.data) = (WINT *) wvt_coeffs[0];
  349.      /* free memory */
  350.      free(wvt_coeffs);
  351.     }
  352.    
  353.     printf("total actually decoded bits:          %ldn", (total_decoded_bytes+bytes_decoded)*8);
  354.     printf("total actually decoded AC band bits:  %ld", total_decoded_bytes*8);
  355.     /* put the decoded wavelet coefficients back into the data structure */
  356.     restore_PEZWdata (SPlayer);
  357.    
  358.     /* free memory */
  359.     PEZW_freeDec (SPlayer);
  360.     free(SPlayer);
  361.     for(i=0;i<levels;i++)
  362.          free(PEZW_bitstream[i]);
  363.     free(PEZW_bitstream);
  364.     for (i=0;i<levels;i++)
  365.          free(Init_Bufsize[i]);
  366.     free(Init_Bufsize);
  367.     for (i=0;i<levels;i++)
  368.        free(reach_budget[i]);
  369.     free(reach_budget);
  370.     for (i=0;i<levels+1;i++)
  371.        free(bits_to_go_inBuffer[i]);
  372.     free(bits_to_go_inBuffer);
  373.     for (i=0;i<levels+1;i++)
  374.        free(decoded_bytes[i]);
  375.     free(decoded_bytes);
  376.     free(splev0_bitstream);
  377.     free(splev0_bitstream_len); 
  378. }
  379. /* rate control at decoding */
  380. void CVTCDecoder::PEZW_decode_ratecontrol (PEZW_SPATIAL_LAYER **SPlayer, int bytes_decoded)
  381. {
  382.     int i, levels;
  383.     long decoded_bits=bytes_decoded;
  384.     int splayer, snrlev, bplane;
  385.     int MaxBitplanes;
  386.     int last_bplane = 0, last_splayer = 0, adjusted_rate=0;
  387.     int diffrate;
  388.     int min_snrlev;
  389.     levels = mzte_codec.m_iWvtDecmpLev;
  390.     /* allocate rate control structure */
  391.     reach_budget = (unsigned char **) calloc(levels,sizeof(char *));
  392.     for(i=0;i<levels;i++)
  393.         reach_budget[i]= (unsigned char *)calloc(Max_Bitplane,sizeof(char));
  394. /* target bitplane */
  395. Min_Bitplane  = SPlayer[0][0].SNR_scalability_levels-PEZW_target_snr_levels;
  396. if ( Min_Bitplane < 0)
  397.     Min_Bitplane  = 0;
  398. /* target spatial level */
  399. spatial_leveloff = mzte_codec.m_iWvtDecmpLev-PEZW_target_spatial_levels;
  400. if (spatial_leveloff <0)
  401.         spatial_leveloff=0;
  402.     /* figure out the target snr and spatial layer
  403.        and the length for the last layer for target_bitrate options */
  404.     MaxBitplanes = SPlayer[0][0].SNR_scalability_levels;
  405.     if ((decoded_bits < PEZW_target_bitrate/8) && (PEZW_target_bitrate >0)){
  406.         if(mzte_codec.m_iScanOrder==1)
  407.             {
  408.                 for (splayer=0;splayer<mzte_codec.m_iWvtDecmpLev-spatial_leveloff ;splayer++)
  409.                     for (snrlev=MaxBitplanes-1;snrlev>=Min_Bitplane;snrlev--)              
  410.                             {
  411.                                 /* for SPlayer, snrlayer 0 means msb bits, need to invert order */
  412.                                 bplane = SPlayer[0][splayer].SNR_scalability_levels
  413.                                             -snrlev-1;
  414.                                 decoded_bits += SPlayer[0][splayer].SNRlayer[bplane].snr_bitstream.length;
  415.                                 if ( decoded_bits >= mzte_codec.m_iTargetBitrate/8){
  416.                                        adjusted_rate = 1;
  417.                                        last_bplane = bplane;
  418.                                        last_splayer = splayer;
  419.                                        goto outside;
  420.                                      }
  421.                             }
  422.             }
  423.         else if (mzte_codec.m_iScanOrder==0)
  424.             {
  425.                for (snrlev=MaxBitplanes-1;snrlev>=Min_Bitplane;snrlev--)              
  426.                  for (splayer=0;splayer<mzte_codec.m_iWvtDecmpLev-spatial_leveloff ;splayer++)
  427.                      {
  428.                        /* for SPlayer, snrlayer 0 means msb bits, need to invert order */
  429.                        bplane = SPlayer[0][splayer].SNR_scalability_levels
  430.                                   -snrlev-1;
  431.                        decoded_bits += SPlayer[0][splayer].SNRlayer[bplane].snr_bitstream.length;
  432.                        if ( decoded_bits >= PEZW_target_bitrate/8){
  433.                             adjusted_rate = 1;
  434.                             last_bplane = bplane;
  435.                             last_splayer = splayer;
  436.                             goto outside;
  437.                            }
  438.                      }
  439.             }
  440.      }
  441. outside:
  442.      if(adjusted_rate){
  443.         diffrate = decoded_bits - PEZW_target_bitrate/8;
  444.         SPlayer[0][last_splayer].SNRlayer[last_bplane].snr_bitstream.length
  445.             -= diffrate;
  446.         /* set up target snr and spatial levels, as well as
  447.            the rate control matrix */
  448.         if (mzte_codec.m_iScanOrder==0){
  449.             min_snrlev = MaxBitplanes-1-last_bplane;
  450.             for (splayer=last_splayer;splayer<mzte_codec.m_iWvtDecmpLev-spatial_leveloff;splayer++)                
  451.                         reach_budget[splayer][min_snrlev] = 1;
  452.             reach_budget[last_splayer][min_snrlev]=0;
  453.             Min_Bitplane = min_snrlev;
  454.         }
  455.         else if (mzte_codec.m_iScanOrder==1){
  456.             min_snrlev = MaxBitplanes-1-last_bplane;
  457.             for (bplane=min_snrlev;bplane>=Min_Bitplane;bplane--)               
  458.                      reach_budget[last_splayer][bplane] = 1;
  459.             reach_budget[last_splayer][min_snrlev]=0;
  460.             spatial_leveloff = mzte_codec.m_iWvtDecmpLev-1-last_splayer;
  461.         }
  462.         decoded_bits = PEZW_target_bitrate;
  463.      }
  464.     return;
  465. }