"Fossies" - the Fresh Open Source Software Archive

Member "faac-1_30/plugins/cooledit/Faad.cpp" (16 Oct 2019, 5837 Bytes) of package /linux/misc/faac-1_30.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Faad.cpp" see the Fossies "Dox" file reference documentation.

    1 /*
    2 FAAC - codec plugin for Cooledit
    3 Copyright (C) 2002-2004 Antonio Foranna
    4 
    5 This program is free software; you can redistribute it and/or modify
    6 it under the terms of the GNU General Public License as published by
    7 the Free Software Foundation.
    8     
    9 This program is distributed in the hope that it will be useful,
   10 but WITHOUT ANY WARRANTY; without even the implied warranty of
   11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12 GNU General Public License for more details.
   13         
   14 You should have received a copy of the GNU General Public License
   15 along with this program; if not, write to the Free Software
   16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   17             
   18 The author can be contacted at:
   19 ntnfrn_email-temp@yahoo.it
   20 */
   21 
   22 #include <windows.h>
   23 //#include "resource.h"
   24 #include "filters.h"    // CoolEdit
   25 #include "DecDialog.h"
   26 #include "Cfaad.h"
   27 
   28 // *********************************************************************************************
   29 
   30 BOOL FAR PASCAL FilterUnderstandsFormat(LPSTR filename)
   31 {
   32 WORD len;
   33 
   34     if((len=lstrlen(filename))>4 && 
   35         (!strcmpi(filename+len-4,".aac") ||
   36         !strcmpi(filename+len-4,".mp4") ||
   37         !strcmpi(filename+len-4,".m4a")))
   38         return TRUE;
   39     return FALSE;
   40 }
   41 // *********************************************************************************************
   42 
   43 long FAR PASCAL FilterGetFileSize(HANDLE hInput)
   44 {
   45     if(!hInput)
   46         return 0;
   47 
   48 DWORD   dst_size;
   49 MYINPUT *mi;
   50 
   51     GLOBALLOCK(mi,hInput,MYINPUT,return 0);
   52     dst_size=mi->dst_size;
   53     
   54     GlobalUnlock(hInput);
   55 
   56     return dst_size;
   57 }
   58 // *********************************************************************************************
   59 
   60 DWORD FAR PASCAL FilterOptionsString(HANDLE hInput, LPSTR szString)
   61 {
   62     if(!hInput)
   63     {
   64         lstrcpy(szString,"");
   65         return 0;
   66     }
   67 
   68 MYINPUT *mi;
   69 
   70     GLOBALLOCK(mi,hInput,MYINPUT,return 0);
   71 
   72     sprintf(szString,"MPEG%d - %lu bps\n", mi->file_info.version ? 4 : 2, mi->file_info.bitrate);
   73     
   74     if(mi->IsMP4)  // MP4 file --------------------------------------------------------------------
   75         lstrcat(szString,mpeg4AudioNames[mi->type]);
   76     else  // AAC file -----------------------------------------------------------------------------
   77     {
   78         switch(mi->file_info.headertype)
   79         {
   80         case RAW:
   81             sprintf(szString,"MPEG%d\nRaw\n", mi->file_info.version ? 4 : 2);
   82             lstrcat(szString,mpeg4AudioNames[mi->file_info.object_type]);
   83             GlobalUnlock(hInput);
   84             return 1;//0; // call FilterGetOptions()
   85         case ADIF:
   86             lstrcat(szString,"ADIF\n");
   87             break;
   88         case ADTS:
   89             lstrcat(szString,"ADTS\n");
   90             break;
   91         }
   92         
   93         lstrcat(szString,mpeg4AudioNames[mi->file_info.object_type]);
   94 /*      switch(mi->file_info.object_type)
   95         {
   96         case MAIN:
   97             lstrcat(szString,"Main");
   98             break;
   99         case LC:
  100             lstrcat(szString,"LC (Low Complexity)");
  101             break;
  102         case SSR:
  103             lstrcat(szString,"SSR (unsupported)");
  104             break;
  105         case LTP:
  106             lstrcat(szString,"LTP (Long Term Prediction)");
  107             break;
  108         case HE_AAC:
  109             lstrcat(szString,"HE (High Efficiency)");
  110             break;
  111         }*/
  112     }
  113     
  114     GlobalUnlock(hInput);
  115     return 1; // don't call FilterGetOptions()
  116 }
  117 // *********************************************************************************************
  118 /*
  119 DWORD FAR PASCAL FilterOptions(HANDLE hInput)
  120 {
  121 //  FilterGetOptions() is called if this function and FilterSetOptions() are exported and FilterOptionsString() returns 0
  122 //  FilterSetOptions() is called only if this function is exported and and it returns 0
  123 
  124     return 1;
  125 }
  126 // ---------------------------------------------------------------------------------------------
  127 
  128 DWORD FAR PASCAL FilterSetOptions(HANDLE hInput, DWORD dwOptions, LONG lSamprate, WORD wChannels, WORD wBPS)
  129 {
  130     return dwOptions;
  131 }*/
  132 // *********************************************************************************************
  133 
  134 void FAR PASCAL CloseFilterInput(HANDLE hInput)
  135 {
  136     if(!hInput)
  137         return;
  138 
  139 /*  if(mi->file_info.headertype==RAW)
  140     {
  141     CRegistry   reg;
  142 
  143         if(reg.openCreateReg(HKEY_CURRENT_USER,REGISTRY_PROGRAM_NAME  "\\FAAD"))
  144             reg.setRegBool("OpenDialog",FALSE);
  145         else
  146             MessageBox(0,"Can't open registry!",0,MB_OK|MB_ICONSTOP);
  147     }*/
  148 
  149 Cfaad tmp(hInput);
  150 }
  151 // *********************************************************************************************
  152 
  153 #define ERROR_OFI(msg) \
  154 { \
  155     if(msg) \
  156         MessageBox(0, msg, APP_NAME " plugin", MB_OK|MB_ICONSTOP); \
  157     if(hInput) \
  158     { \
  159         GlobalUnlock(hInput); \
  160         CloseFilterInput(hInput); \
  161     } \
  162     return 0; \
  163 }
  164 // -----------------------------------------------------------------------------------------------
  165 
  166 // return handle that will be passed in to close, and write routines
  167 HANDLE FAR PASCAL OpenFilterInput(LPSTR lpstrFilename, long far *lSamprate, WORD far *wBitsPerSample, WORD far *wChannels, HWND hWnd, long far *lChunkSize)
  168 {
  169 HANDLE  hInput=NULL;
  170 Cfaad   tmp;
  171 CMyDecCfg cfg(false);
  172 
  173     if(!*lSamprate && !tmp.IsMP4(lpstrFilename))
  174     {
  175 /*  aac_buffer  b;
  176     float       fLength;
  177     int         bitrate;
  178     DWORD       headertype;
  179         tmp.GetAACInfos(lpstrFilename,&b,&headertype,&fLength,&bitrate);
  180         if(headertype==RAW)
  181             tmp.ShowDlg4RawAAC=ShowDlg4RawAAC;*/
  182     DWORD           *seek_table;
  183     int             seek_table_length;
  184     faadAACInfo     file_info;
  185         if(!get_AAC_format(lpstrFilename, &file_info, &seek_table, &seek_table_length, 0))
  186             if(file_info.headertype==RAW)
  187                 tmp.ShowDlg4RawAAC=ShowDlg4RawAAC;
  188     }
  189 
  190     if(hInput=tmp.getInfos(lpstrFilename))
  191     {
  192     MYINPUT *mi;
  193         GLOBALLOCK(mi,hInput,MYINPUT,return NULL);
  194     
  195         *wChannels=(WORD)mi->Channels;
  196         *lSamprate=mi->Samprate;
  197         *wBitsPerSample=mi->BitsPerSample;
  198         *lChunkSize=(*wBitsPerSample/8)*1024**wChannels*2;
  199 
  200         GlobalUnlock(hInput);
  201         tmp.hInput=NULL;
  202     }
  203 
  204     return hInput;
  205 }
  206 // *********************************************************************************************
  207 
  208 DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *bufout, long lBytes)
  209 {
  210     if(!hInput)
  211         return 0;
  212 
  213 Cfaad tmp;
  214 
  215     return tmp.processData(hInput,bufout,lBytes);
  216 }