ref: 68f48bbb6d1448d7f068b4084c10dd4719496612
parent: bd1caf5deb659c62174142fe83036949ccddc3c4
author: ca5e <ca5e>
date: Thu Dec 11 13:24:55 EST 2003
Added average bitrate control and some extra console infos
--- a/plugins/foo_faac/foo_faac.cpp
+++ b/plugins/foo_faac/foo_faac.cpp
@@ -2,6 +2,7 @@
// Copyright (C) 2003 Janne Hyv�rinen
//
// Changes:
+// 0.4 (2003-12-11): Added support for average bitrate controlling
// 0.3.5 (2003-10-17): Changed way gapless encoding is handled (iTunes is buggy...)
// 0.3.4 (2003-10-14): Fixed AAC object type selecting
// 0.3.3 (2003-10-02): Removed gapless support for raw AAC files, it was hacky and recent libfaad changes broke it
@@ -34,7 +35,7 @@
#include <faac.h>
#include <version.h>
-#define FOO_FAAC_VERSION "0.3.5"
+#define FOO_FAAC_VERSION "0.4"
#define FF_AAC 0
#define FF_MP4 1
@@ -43,18 +44,22 @@
#define FF_DEFAULT_OBJECTTYPE LOW
#define FF_DEFAULT_MIDSIDE 1
#define FF_DEFAULT_TNS 0
-#define FF_DEFAULT_BITRATE 0
#define FF_DEFAULT_QUANTQUAL 100
+#define FF_DEFAULT_AVGBRATE 64
#define FF_DEFAULT_CUTOFF -1
#define FF_DEFAULT_MP4CONTAINER FF_MP4
+#define FF_DEFAULT_USE_QQ 1
+#define FF_DEFAULT_USE_AB 0
static cfg_int cfg_objecttype ( "objecttype", FF_DEFAULT_OBJECTTYPE );
static cfg_int cfg_midside ( "midside", FF_DEFAULT_MIDSIDE );
static cfg_int cfg_tns ( "tns", FF_DEFAULT_TNS );
-static cfg_int cfg_bitrate ( "bitrate", FF_DEFAULT_BITRATE );
static cfg_int cfg_quantqual ( "quantqual", FF_DEFAULT_QUANTQUAL );
+static cfg_int cfg_avgbrate ( "avgbrate", FF_DEFAULT_AVGBRATE );
static cfg_int cfg_cutoff ( "cutoff", FF_DEFAULT_CUTOFF );
static cfg_int cfg_mp4container ( "mp4container", FF_DEFAULT_MP4CONTAINER );
+static cfg_int cfg_use_qq ( "use_qq", FF_DEFAULT_USE_QQ );
+static cfg_int cfg_use_ab ( "use_ab", FF_DEFAULT_USE_AB );
DECLARE_COMPONENT_VERSION ( "FAAC encoder", FOO_FAAC_VERSION, "Uses libfaac version " FAAC_VERSION );
@@ -73,6 +78,7 @@
int cutOff;
int bitRate;
unsigned long quantqual;
+ int use_qq, use_ab;
int create_mp4;
@@ -97,8 +103,10 @@
useMidSide = cfg_midside;
useTns = cfg_tns;
cutOff = cfg_cutoff;
- bitRate = cfg_bitrate;
+ bitRate = cfg_avgbrate * 1000;
quantqual = cfg_quantqual;
+ use_qq = cfg_use_qq;
+ use_ab = cfg_use_ab;
hEncoder = 0;
myFormat = 0;
@@ -136,15 +144,23 @@
encode_error = false;
path = filename;
- if ( path.is_empty() ) return 0;
+ if ( src_file ) src_file->handle_query ( &info ); else info.reset();
+ console::info ( "AAC encoding with FAAC version " FAAC_VERSION );
+ console::info ( string_printf ("Source file: %s", (const char *)info.get_file_path()) );
+ console::info ( string_printf ("Destination file: %s", (const char *)path) );
+
+ if ( path.is_empty() ) {
+ console::error ( "No destination name" );
+ return 0;
+ }
+
m_reader = file::g_open ( path, reader::MODE_WRITE_NEW );
if ( !m_reader ) {
- console::error ( string_printf ("Can't write to '%s'", (const char *)path) );
+ console::error ( "Can't write to destination" );
return 0;
}
- if ( src_file ) src_file->handle_query ( &info ); else info.reset();
return 1;
}
@@ -199,9 +215,9 @@
myFormat->useLfe = (nch == 6) ? 1 : 0;
myFormat->useTns = useTns;
myFormat->allowMidside = useMidSide;
- if ( bitRate ) myFormat->bitRate = bitRate;
+ if ( use_ab ) myFormat->bitRate = bitRate;
myFormat->bandWidth = cutOff;
- if ( quantqual > 0 ) myFormat->quantqual = quantqual;
+ if ( use_qq ) myFormat->quantqual = quantqual;
myFormat->outputFormat = create_mp4 ? 0 : 1;
myFormat->inputFormat = FAAC_INPUT_FLOAT;
@@ -235,6 +251,12 @@
quantqual = myFormat->quantqual;
bitRate = myFormat->bitRate;
+ if ( bitRate > 0 ) {
+ console::info ( string_printf ("Using quantizer quality %i and average bitrate of %i kbps per channel", quantqual, bitRate/1000) );
+ } else {
+ console::info ( string_printf ("Using quantizer quality %i and no average bitrate control", quantqual, bitRate) );
+ }
+
encode_error = false;
}
@@ -337,7 +359,10 @@
if ( m_reader ) {
bool success = !encode_error && (m_reader->get_length() > 0);
- if ( success ) write_tag();
+ if ( success ) {
+ write_tag();
+ console::info ( "Encoding finished successfully" );
+ }
if ( create_mp4 ) {
MP4Close ( MP4hFile );
@@ -347,7 +372,10 @@
m_reader->reader_release();
m_reader = 0;
- if ( !success ) file::g_remove ( path );
+ if ( !success ) {
+ console::info ( "Encoding failed" );
+ file::g_remove ( path );
+ }
}
}
@@ -548,6 +576,11 @@
{ 10000, "10000" },
};
+#define QQ_MIN 10
+#define QQ_MAX 500
+#define AB_MIN 8
+#define AB_MAX 384
+
class config_faac : public config {
static void update ( HWND wnd )
{
@@ -585,6 +618,12 @@
uSendDlgItemMessage ( wnd, IDC_QUANTQUAL_SLIDER, TBM_SETPOS, 1, cfg_quantqual );
uSetDlgItemText ( wnd, IDC_QUANTQUAL_EDIT, string_printf ("%i", (int)cfg_quantqual) );
+ uSendDlgItemMessage ( wnd, IDC_AVGBRATE_SLIDER, TBM_SETPOS, 1, cfg_avgbrate );
+ uSetDlgItemText ( wnd, IDC_AVGBRATE_EDIT, string_printf ("%i", (int)cfg_avgbrate) );
+
+ CheckDlgButton ( wnd, IDC_USE_QQ, cfg_use_qq );
+ CheckDlgButton ( wnd, IDC_USE_AB, cfg_use_ab );
+
CheckDlgButton ( wnd, IDC_MIDSIDE, cfg_midside );
CheckDlgButton ( wnd, IDC_TNS, cfg_tns );
}
@@ -612,7 +651,8 @@
uSendMessageText ( wnd_cutoff, CB_ADDSTRING, 0, cutoff_list[i].name );
}
- uSendDlgItemMessage ( wnd, IDC_QUANTQUAL_SLIDER, TBM_SETRANGE, 0, MAKELONG(10, 500) );
+ uSendDlgItemMessage ( wnd, IDC_QUANTQUAL_SLIDER, TBM_SETRANGE, 0, MAKELONG(QQ_MIN, QQ_MAX) );
+ uSendDlgItemMessage ( wnd, IDC_AVGBRATE_SLIDER, TBM_SETRANGE, 0, MAKELONG(AB_MIN, AB_MAX) );
update ( wnd );
}
@@ -637,11 +677,11 @@
case IDC_QUANTQUAL_EDIT | (EN_KILLFOCUS<<16):
{
cfg_quantqual = GetDlgItemInt ( wnd, IDC_QUANTQUAL_EDIT, 0, 0 );
- if ( cfg_quantqual < 10 || cfg_quantqual > 500 ) {
- if ( cfg_quantqual < 10 ) {
- cfg_quantqual = 10;
+ if ( cfg_quantqual < QQ_MIN || cfg_quantqual > QQ_MAX ) {
+ if ( cfg_quantqual < QQ_MIN ) {
+ cfg_quantqual = QQ_MIN;
} else {
- cfg_quantqual = 500;
+ cfg_quantqual = QQ_MAX;
}
uSetDlgItemText ( wnd, IDC_QUANTQUAL_EDIT, string_printf ("%i", (int)cfg_quantqual) );
}
@@ -649,6 +689,21 @@
}
break;
+ case IDC_AVGBRATE_EDIT | (EN_KILLFOCUS<<16):
+ {
+ cfg_avgbrate = GetDlgItemInt ( wnd, IDC_AVGBRATE_EDIT, 0, 0 );
+ if ( cfg_avgbrate < AB_MIN || cfg_quantqual > AB_MAX ) {
+ if ( cfg_avgbrate< AB_MIN ) {
+ cfg_avgbrate = AB_MIN;
+ } else {
+ cfg_avgbrate = AB_MAX;
+ }
+ uSetDlgItemText ( wnd, IDC_AVGBRATE_EDIT, string_printf ("%i", (int)cfg_avgbrate) );
+ }
+ uSendDlgItemMessage ( wnd, IDC_AVGBRATE_SLIDER, TBM_SETPOS, 1, cfg_avgbrate );
+ }
+ break;
+
case IDC_CUTOFF | (CBN_SELCHANGE<<16):
{
int t = (int)uSendMessage ( wnd_cutoff, CB_GETCURSEL, 0, 0 );
@@ -685,14 +740,28 @@
}
break;
+ case IDC_USE_QQ:
+ {
+ cfg_use_qq = !cfg_use_qq;
+ }
+ break;
+
+ case IDC_USE_AB:
+ {
+ cfg_use_ab = !cfg_use_ab;
+ }
+ break;
+
case IDC_DEFAULTS:
{
cfg_objecttype = FF_DEFAULT_OBJECTTYPE;
cfg_midside = FF_DEFAULT_MIDSIDE;
cfg_tns = FF_DEFAULT_TNS;
- cfg_bitrate = FF_DEFAULT_BITRATE;
+ cfg_avgbrate = FF_DEFAULT_AVGBRATE;
cfg_quantqual = FF_DEFAULT_QUANTQUAL;
cfg_cutoff = FF_DEFAULT_CUTOFF;
+ cfg_use_qq = FF_DEFAULT_USE_QQ;
+ cfg_use_ab = FF_DEFAULT_USE_AB;
update ( wnd );
}
break;
@@ -700,9 +769,16 @@
break;
case WM_HSCROLL:
- {
- cfg_quantqual = uSendDlgItemMessage ( wnd, IDC_QUANTQUAL_SLIDER, TBM_GETPOS, 0, 0 );
+ switch ( uGetWindowLong((HWND)lp, GWL_ID) ) {
+ case IDC_QUANTQUAL_SLIDER:
+ cfg_quantqual = uSendMessage ( (HWND)lp, TBM_GETPOS, 0, 0 );
uSetDlgItemText ( wnd, IDC_QUANTQUAL_EDIT, string_printf ("%i", (int)cfg_quantqual) );
+ break;
+
+ case IDC_AVGBRATE_SLIDER:
+ cfg_avgbrate = uSendMessage ( (HWND)lp, TBM_GETPOS, 0, 0 );
+ uSetDlgItemText ( wnd, IDC_AVGBRATE_EDIT, string_printf ("%i", (int)cfg_avgbrate) );
+ break;
}
break;
}
--- a/plugins/foo_faac/foo_faac.dsp
+++ b/plugins/foo_faac/foo_faac.dsp
@@ -38,12 +38,12 @@
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
+# PROP Output_Dir "..\Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "foo_faac_EXPORTS" /YX /FD /c
-# ADD CPP /nologo /G6 /MD /W3 /GX /O1 /I "../../../faac/include" /I "../../../faac/libfaac" /I "..\..\..\faad2\common\mp4v2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD CPP /nologo /G6 /MD /W3 /O1 /I "../../../faac/include" /I "../../../faac/libfaac" /I "..\..\..\faad2\common\mp4v2" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
@@ -54,11 +54,6 @@
LINK32=xilink6.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib /nologo /dll /machine:I386
-# Begin Special Build Tool
-SOURCE="$(InputPath)"
-PostBuild_Desc=UPX
-PostBuild_Cmds=upx --best --crp-ms=999999 Release\foo_faac.dll
-# End Special Build Tool
!ELSEIF "$(CFG)" == "foo_faac - Win32 Debug"
@@ -69,7 +64,7 @@
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
+# PROP Output_Dir "..\Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
--- a/plugins/foo_faac/foo_faac.rc
+++ b/plugins/foo_faac/foo_faac.rc
@@ -78,23 +78,30 @@
LTEXT "Output format:",IDC_STATIC,13,16,54,8
COMBOBOX IDC_FORMAT,68,14,53,50,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
- LTEXT "AAC profile:",IDC_STATIC,21,60,42,8
- COMBOBOX IDC_PROFILE,81,58,60,50,CBS_DROPDOWNLIST | WS_VSCROLL |
+ LTEXT "AAC profile:",IDC_STATIC,21,76,42,8
+ COMBOBOX IDC_PROFILE,81,74,60,64,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
- LTEXT "Quantizer quality:",IDC_STATIC,21,44,60,8
- EDITTEXT IDC_QUANTQUAL_EDIT,220,42,32,12,ES_CENTER |
+ EDITTEXT IDC_QUANTQUAL_EDIT,233,41,32,12,ES_CENTER |
ES_AUTOHSCROLL | ES_NUMBER
- LTEXT "Bandwidth (Hz):",IDC_STATIC,21,76,56,8
+ LTEXT "Bandwidth (Hz):",IDC_STATIC,21,92,56,8
CONTROL "Use mid/side coding",IDC_MIDSIDE,"Button",
- BS_AUTOCHECKBOX | WS_TABSTOP,21,91,79,10
+ BS_AUTOCHECKBOX | WS_TABSTOP,21,107,79,10
CONTROL "Use TNS",IDC_TNS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,
- 21,104,43,10
- COMBOBOX IDC_CUTOFF,81,74,60,50,CBS_DROPDOWN | WS_VSCROLL |
+ 21,120,43,10
+ COMBOBOX IDC_CUTOFF,81,90,60,160,CBS_DROPDOWN | WS_VSCROLL |
WS_TABSTOP
CONTROL "Slider2",IDC_QUANTQUAL_SLIDER,"msctls_trackbar32",
- WS_TABSTOP,84,42,132,11
- GROUPBOX "Encoder settings",IDC_STATIC,14,31,246,90
- PUSHBUTTON "Defaults",IDC_DEFAULTS,213,100,40,14
+ WS_TABSTOP,97,41,132,11
+ GROUPBOX "Encoder settings",IDC_STATIC,14,31,258,107
+ PUSHBUTTON "Defaults",IDC_DEFAULTS,225,116,40,14
+ CONTROL "Quantizer quality:",IDC_USE_QQ,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,21,43,73,10
+ CONTROL "Bitrate/ch (kbps):",IDC_USE_AB,"Button",BS_AUTOCHECKBOX |
+ WS_TABSTOP,21,58,72,10
+ CONTROL "Slider2",IDC_AVGBRATE_SLIDER,"msctls_trackbar32",
+ WS_TABSTOP,97,57,132,11
+ EDITTEXT IDC_AVGBRATE_EDIT,233,57,32,12,ES_CENTER |
+ ES_AUTOHSCROLL | ES_NUMBER
END
#endif // English (U.S.) resources
--- a/plugins/foo_faac/resource.h
+++ b/plugins/foo_faac/resource.h
@@ -3,16 +3,18 @@
// Used by foo_faac.rc
//
#define IDD_CONFIG 116
-#define IDC_COMPRESSION 1000
-#define IDC_FORMAT 1001
-#define IDC_BPS 1002
-#define IDC_PROFILE 1003
-#define IDC_QUANTQUAL_EDIT 1004
-#define IDC_CUTOFF 1005
-#define IDC_MIDSIDE 1006
-#define IDC_TNS 1007
-#define IDC_QUANTQUAL_SLIDER 1008
-#define IDC_DEFAULTS 1009
+#define IDC_FORMAT 1000
+#define IDC_USE_QQ 1001
+#define IDC_USE_AB 1002
+#define IDC_QUANTQUAL_SLIDER 1003
+#define IDC_AVGBRATE_SLIDER 1004
+#define IDC_QUANTQUAL_EDIT 1005
+#define IDC_AVGBRATE_EDIT 1006
+#define IDC_PROFILE 1007
+#define IDC_CUTOFF 1008
+#define IDC_MIDSIDE 1009
+#define IDC_TNS 1010
+#define IDC_DEFAULTS 1011
// Next default values for new objects
//
@@ -20,7 +22,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1016
+#define _APS_NEXT_CONTROL_VALUE 1012
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif