cdplayer.c
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:6k
源码类别:

DVD

开发平台:

C/C++

  1. /**********************************************************
  2. **  Description: for cd player
  3. **  Creater:liweihua
  4. **  Date:2003-9-3
  5. ***********************************************************/
  6. #include "global.h"
  7. #include "memmap0.h"
  8. #include "ircmd.h"
  9. #ifdef CD_PLAYER
  10. //declare the extern vars and consts
  11. extern BYTE bEqMaxKeepTm;
  12. extern void  osd_init_cdplayer(); 
  13. extern UINT8 *get_osdbuf_region_ptr(int _region, int _field);
  14. extern const UINT8 osd_header_offset[8];
  15. #define OSD_DATA_OFFSET(f)     (osd_header_offset[(f)&OSD_FORMAT_MASK])
  16. void osd_print_cdeq(UINT8 r,BYTE *p);
  17. void DisplaycdEq(void);
  18. //setting the band color
  19. #define GREENCOL        0xcccc
  20. #define BLUECOL       0xbbbb
  21. #define BLACKCOL        0xdddd
  22. //setting the region of band
  23. #define AUDBAND_R       3
  24. //display the video in the player interface according to spectrum value(7 bands)
  25. void show_cdplayer(void)
  26. {
  27.     osd_init_cdplayer();
  28.     unEqMaxRef=0;
  29.     //bEqDisplay=1;
  30.     //setup_eq_display(1);//terry,2003/9/26 04:43PM
  31.     setup_eq_display(0xf);//nono 2003-10-22 15:14 change for new dsp code.
  32. }
  33. //Draw EQ status on screen by OSD
  34. // r : region for draw
  35. // *p: input 7 band EQ value 
  36. //Each band energy range is 0 ~ 71 
  37. void osd_print_cdeq(UINT8 r,BYTE *p)
  38. {
  39.     UINT16  iWidth;
  40.     UINT16  i,j,iBlock,step,k;
  41.     UINT16  *pTopLine,*pBtmLine;
  42.     UINT16  unColor;    
  43.     BYTE    bChannelVal[14];    //byte 13 is garbage
  44.     BYTE barlen;
  45.     iWidth = region[r].osd_w/4;
  46.     if(p_scan==0)
  47.     {
  48.      barlen=72;    
  49.     }
  50.     else
  51.     {
  52.      barlen=144;
  53.     }
  54.     
  55.     //calcuate the interpolate data
  56.     //The data is mapping to 0 ~ 71    
  57.     for (i=0;i<14;i=i+2)
  58.     {
  59.         bChannelVal[i]=*p;
  60.         bChannelVal[i+1]=(*(p)+*(p+1))/2;
  61.         p++;
  62.     }
  63.     
  64.     //check the last max value
  65.     for (i=0;i<13;i++)
  66.     {
  67.         if (bEqEnergyMax[i]<=bChannelVal[i])
  68.         {
  69.             bEqEnergyMax[i]=bChannelVal[i];
  70.         }
  71.         else
  72.         {                
  73.             if(p_scan==0)             
  74.             {
  75.             if ( (bEqEnergyMax[i]!=0) && (bEqMaxKeepTm==0) )
  76.                 {
  77.                     bEqEnergyMax[i]=bEqEnergyMax[i]-1;    //reduce 1  
  78.                 } 
  79.             }
  80.             else
  81.             {
  82.             if ( (bEqEnergyMax[i]>=2) && (bEqMaxKeepTm==0) )
  83.                 {
  84.                     bEqEnergyMax[i]=bEqEnergyMax[i]-2;    //reduce 1  
  85.                 } 
  86.             }         
  87.         }
  88.     }
  89.     
  90.     if (bEqMaxKeepTm)
  91.         bEqMaxKeepTm--;
  92.     else
  93.         bEqMaxKeepTm=1;
  94.     //plot the background block
  95.     if (p_scan==0) {
  96.         pTopLine = (UINT16 *) (get_osdbuf_region_ptr(r,0)+iWidth*120/2);
  97.         pBtmLine = (UINT16 *) (get_osdbuf_region_ptr(r,1)+iWidth*120/2);
  98.     } else {
  99.         pTopLine = (UINT16 *) (get_osdbuf_region_ptr(r,0)+iWidth*120);
  100.         pBtmLine = (UINT16 *) (get_osdbuf_region_ptr(r,0)+iWidth*120);
  101.     }
  102.     
  103.     //Totally has 72 block for each freq (0 ~ 71 )
  104.     //pTopLine=pTopLine+iWidth;
  105.     if(p_scan==0)  step=1;
  106.     else step=1;
  107.     
  108.     
  109.     for (j=barlen;j>0;j--)
  110.     {      
  111.         for(k=0;k<step;k++)
  112.         {
  113.             //pTopLine[0]=TRANS_COLOR;
  114.             
  115.             for (i=1,iBlock=0;iBlock<13;i=i+4,iBlock++)
  116.             {    
  117.                 //make sure color
  118.                 if (j==bEqEnergyMax[iBlock])
  119.                     unColor=BLUECOL;
  120.                 else {
  121.                     if (j<bChannelVal[iBlock])
  122.                         unColor=GREENCOL;
  123.                     else
  124.                         unColor=BLACKCOL;   
  125.                 }            
  126.                                   
  127.                 pTopLine[i]   =  unColor;
  128.                 pTopLine[i+1] =  unColor;
  129.                 pTopLine[i+2] =  unColor;
  130.                 if (p_scan==0)
  131.                 {
  132.                     pBtmLine[i]   =  unColor;
  133.                     pBtmLine[i+1] =  unColor;
  134.                     pBtmLine[i+2] =  unColor;
  135.                 }
  136.             }
  137.             pTopLine+=iWidth;    
  138.             if (p_scan==0) pBtmLine+=iWidth;
  139.         }
  140.         
  141.         //step 2 line
  142.         pTopLine+=(iWidth*step);    
  143.         if (p_scan==0) pBtmLine+=(iWidth*step);
  144.        
  145.     } 
  146. }
  147. //draw the lines related with the 7 spectrum values
  148. void DisplaycdEq(void)
  149. {
  150.     BYTE    i,j;
  151. BYTE bEqValue[7];
  152. BYTE  *p;
  153.     
  154.         if (bEqDisplay>=4) 
  155.         {
  156.             p = (BYTE *)(SDRAM_BASE_CACHED+MEM_PCMYA*1024);
  157.                        
  158.             for (i=0, j=0;i<7 ;i++) 
  159.             {
  160.                 UINT32  eqSrc;
  161.                 UINT32  eqTemp;
  162.                 
  163.                 eqSrc = (((*p)<<8) | *(p+1));                
  164.                 p+=3;
  165.                 if (eqSrc > unEqMaxRef)
  166. unEqMaxRef = eqSrc;
  167.                 //normalize value to 0 ~ 25
  168.                 if (unEqMaxRef==0) 
  169.                     eqTemp = 0;
  170.                 else
  171.                 {
  172.                  if(p_scan==0)
  173.                  eqTemp = eqSrc*80/unEqMaxRef;
  174.                  else
  175.                  eqTemp = eqSrc*160/unEqMaxRef;
  176.                 }
  177.                 bEqValue[i] = eqTemp;
  178.             if (bEqValue[i]<4) 
  179.             {
  180.                     j++;
  181.                 }
  182.             }
  183.             //adjust max refrence 
  184.             if ( (j>=6) && (unEqMaxRef>400) )
  185.                 unEqMaxRef=unEqMaxRef-(unEqMaxRef/8);
  186.             osd_print_cdeq(AUDBAND_R, bEqValue);
  187.             bEqDisplay=1;
  188.         } else {
  189.             bEqDisplay++;
  190.         } 
  191.     } 
  192. #endif