Ticket #4712: tools_gui_lame_fix.patch

File tools_gui_lame_fix.patch, 11.5 KB (added by criezy, 13 years ago)

Updated and cleaned patch

  • scummvm/tools/trunk/compress.h

     
    8989        // Settings
    9090        // These functions are used by the GUI Tools and by CLI argument parsing functions
    9191        // mp3 settings
     92        void setMp3LamePath(const std::string&);
    9293        void setMp3CompressionType(const std::string&);
    9394        void setMp3MpegQuality(const std::string&);
    9495        void setMp3ABRBitrate(const std::string&);
  • scummvm/tools/trunk/gui/pages.cpp

     
    833833
    834834wxWindow *ChooseAudioOptionsMp3Page::CreatePanel(wxWindow *parent) {
    835835        wxWindow *panel = WizardPage::CreatePanel(parent);
     836       
     837        wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
     838       
     839        // Add a ScrolledWindow in that panel as there is a lot of options
     840        // and there might not be enough place to display them all.
     841        wxScrolledWindow *scroll = new wxScrolledWindow(panel);
     842        scroll->SetScrollbars(10, 10, 60, 40);
     843       
     844        sizer->Add(scroll, 1, wxEXPAND | wxALL);
    836845
    837 
    838846        /*
    839847        "\nMP3 mode params:\n"
     848        " -lame-path <path> Path to the lame excutable to use (default: lame)\n"
    840849        " -b <rate>    <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:" minBitrDef_str "%d)\n"
    841850        " -B <rate>    <rate> is the maximum VBR/ABR bitrate (default:%" maxBitrDef_str ")\n"
    842851        " --vbr        LAME uses the VBR mode (default)\n"
     
    846855        " --silent     the output of LAME is hidden (default:disabled)\n"
    847856        */
    848857
    849         wxFlexGridSizer *sizer = new wxFlexGridSizer(6, 2, 10, 25);
    850         sizer->AddGrowableCol(1);
     858        // Grid
     859        wxFlexGridSizer *gridSizer = new wxFlexGridSizer(7, 2, 10, 25);
     860        gridSizer->AddGrowableCol(1);
    851861
     862        // Create output selection
     863        gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Lame executable:")));
    852864
     865        wxFilePickerCtrl *lamePicker = new wxFilePickerCtrl(
     866                        scroll, wxID_ANY, _configuration.outputPath, wxT("Select lame executable"),
     867                        wxT("lame"),
     868                        wxDefaultPosition, wxSize(250, -1),
     869                        wxFLP_USE_TEXTCTRL | wxFLP_FILE_MUST_EXIST | wxFLP_OPEN, wxDefaultValidator,
     870                        wxT("LamePath")
     871                );
     872               
     873        gridSizer->Add(lamePicker, wxSizerFlags().Expand());
     874
    853875        // Type of compression
    854         sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Compression Type:")));
     876        gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Compression Type:")));
    855877
    856         wxRadioButton *abrButton = new wxRadioButton(panel, wxID_ANY, wxT("ABR"),
     878        wxRadioButton *abrButton = new wxRadioButton(scroll, wxID_ANY, wxT("ABR"),
    857879                wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("ABR"));
    858880
    859881        wxSizer *radioSizer = new wxBoxSizer(wxHORIZONTAL);
    860882        radioSizer->Add(abrButton);
    861883
    862         wxRadioButton *vbrButton = new wxRadioButton(panel, wxID_ANY, wxT("VBR"),
     884        wxRadioButton *vbrButton = new wxRadioButton(scroll, wxID_ANY, wxT("VBR"),
    863885                wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("VBR"));
    864886        radioSizer->Add(vbrButton);
    865887
    866         sizer->Add(radioSizer, wxSizerFlags().Expand());
     888        gridSizer->Add(radioSizer, wxSizerFlags().Expand());
    867889
    868890        // Bitrates
    869891        const int possibleBitrateCount = 160 / 8;
     
    872894                possibleBitrates[i] << (i+1)*8;
    873895        }
    874896
    875         sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Minimum Bitrate:")));
     897        gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Minimum Bitrate:")));
    876898
    877899        wxChoice *vbrMinBitrate = new wxChoice(
    878                 panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
     900                scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
    879901                possibleBitrateCount, possibleBitrates, 0, wxDefaultValidator, wxT("MinimumBitrate"));
    880         sizer->Add(vbrMinBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
     902        gridSizer->Add(vbrMinBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
    881903
    882904
    883         sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Maximum Bitrate:")));
     905        gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Maximum Bitrate:")));
    884906
    885907        wxChoice *vbrMaxBitrate = new wxChoice(
    886                 panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
     908                scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
    887909                possibleBitrateCount, possibleBitrates, 0, wxDefaultValidator, wxT("MaximumBitrate"));
    888         sizer->Add(vbrMaxBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
     910        gridSizer->Add(vbrMaxBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
    889911
    890912
    891         sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("Average Bitrate:")));
     913        gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("Average Bitrate:")));
    892914
    893915        wxChoice *abrAvgBitrate = new wxChoice(
    894                 panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
     916                scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
    895917                possibleBitrateCount, possibleBitrates, 0, wxDefaultValidator, wxT("AverageBitrate"));
    896         sizer->Add(abrAvgBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
     918        gridSizer->Add(abrAvgBitrate, wxSizerFlags().Expand().Border(wxRIGHT, 100));
    897919
    898920        abrButton->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(ChooseAudioOptionsMp3Page::onChangeCompressionType), NULL, this);
    899921        vbrButton->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler(ChooseAudioOptionsMp3Page::onChangeCompressionType), NULL, this);
     
    905927                possibleQualities[i] << i;
    906928        }
    907929
    908         sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("VBR Quality:")));
     930        gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("VBR Quality:")));
    909931
    910932        wxChoice *vbrQuality = new wxChoice(
    911                 panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
     933                scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
    912934                possibleQualityCount, possibleQualities, 0, wxDefaultValidator, wxT("VBRQuality"));
    913         sizer->Add(vbrQuality, wxSizerFlags().Expand().Border(wxRIGHT, 100));
     935        gridSizer->Add(vbrQuality, wxSizerFlags().Expand().Border(wxRIGHT, 100));
    914936
    915937
    916         sizer->Add(new wxStaticText(panel, wxID_ANY, wxT("MPEG Quality:")));
     938        gridSizer->Add(new wxStaticText(scroll, wxID_ANY, wxT("MPEG Quality:")));
    917939
    918940        wxChoice *mpegQuality = new wxChoice(
    919                 panel, wxID_ANY, wxDefaultPosition, wxDefaultSize,
     941                scroll, wxID_ANY, wxDefaultPosition, wxDefaultSize,
    920942                possibleQualityCount, possibleQualities, 0, wxDefaultValidator, wxT("MpegQuality"));
    921         sizer->Add(mpegQuality, wxSizerFlags().Expand().Border(wxRIGHT, 100));
     943        gridSizer->Add(mpegQuality, wxSizerFlags().Expand().Border(wxRIGHT, 100));
    922944
    923945        // Finish the window
     946        scroll->SetSizer(gridSizer);
    924947        SetAlignedSizer(panel, sizer);
    925948
    926949
    927950        // Load settings
     951        lamePicker->SetPath(_configuration.mp3LamePath);
    928952        if (_configuration.mp3CompressionType == wxT("ABR"))
    929953                abrButton->SetValue(true);
    930954        else
     
    941965}
    942966
    943967void ChooseAudioOptionsMp3Page::save(wxWindow *panel) {
     968        wxFilePickerCtrl *lamePath = static_cast<wxFilePickerCtrl *>(panel->FindWindowByName(wxT("LamePath")));
     969       
    944970        wxRadioButton *abr = static_cast<wxRadioButton *>(panel->FindWindowByName(wxT("ABR")));
    945971//      wxRadioButton *vbr = static_cast<wxRadioButton *>(panel->FindWindowByName(wxT("VBR")));
    946972
     
    950976        wxChoice *vbrQuality = static_cast<wxChoice *>(panel->FindWindowByName(wxT("VBRQuality")));
    951977        wxChoice *mpegQuality = static_cast<wxChoice *>(panel->FindWindowByName(wxT("MpegQuality")));
    952978
     979        _configuration.mp3LamePath      = lamePath->GetPath();
    953980        _configuration.mp3VBRMinBitrate = vbrMinBitrate->GetStringSelection();
    954981        _configuration.mp3VBRMaxBitrate = vbrMaxBitrate->GetStringSelection();
    955982        _configuration.mp3ABRBitrate    = abrAvgBitrate->GetStringSelection();
  • scummvm/tools/trunk/gui/gui_tools.cpp

     
    146146                compression->_format               = conf.selectedAudioFormat;
    147147
    148148                // mp3
     149                compression->setMp3LamePath       ( (const char *)conf.mp3LamePath.mb_str()        );
    149150                compression->setMp3CompressionType( (const char *)conf.mp3CompressionType.mb_str() );
    150151                compression->setMp3MpegQuality    ( (const char *)conf.mp3MpegQuality.mb_str()     );
    151152                compression->setMp3ABRBitrate     ( (const char *)conf.mp3ABRBitrate.mb_str()      );
  • scummvm/tools/trunk/gui/configuration.cpp

     
    3737        advancedAudioSettings = false;
    3838
    3939        // mp3 params
     40        mp3LamePath = wxT("lame");
    4041        mp3CompressionType = wxT("VBR");
    4142        mp3MpegQuality = wxT("2");
    4243
     
    6768        filecnf->Read(wxT("outputpath"), &outputPath);
    6869
    6970        // mp3 params
     71        filecnf->Read(wxT("mp3LamePath"), &mp3LamePath, mp3LamePath);
    7072        filecnf->Read(wxT("mp3CompressionType"), &mp3CompressionType, mp3CompressionType);
    7173        filecnf->Read(wxT("mp3MpegQuality"), &mp3MpegQuality, mp3MpegQuality);
    7274        filecnf->Read(wxT("mp3ABRBitrate"), &mp3ABRBitrate, mp3ABRBitrate);
     
    9294
    9395        wxFileName op(outputPath);
    9496        filecnf->Write(wxT("outputpath"), op.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR));
     97        filecnf->Write(wxT("mp3LamePath"), mp3LamePath);
    9598
    9699        if (all) {
    97100                // mp3 params
  • scummvm/tools/trunk/gui/configuration.h

     
    8484        bool advancedAudioSettings;
    8585
    8686        // mp3 settings
     87        wxString mp3LamePath;
    8788        wxString mp3CompressionType;
    8889        wxString mp3MpegQuality;
    8990        wxString mp3ABRBitrate;
  • scummvm/tools/trunk/compress.cpp

     
    4949        uint32 algqual;
    5050        uint32 vbrqual;
    5151        bool silent;
     52        std::string lamePath;
    5253};
    5354
    5455struct oggencparams {
     
    7172        uint8 bitsPerSample;
    7273};
    7374
    74 lameparams encparms = { minBitrDef, maxBitrDef, false, algqualDef, vbrqualDef, 0 };
     75lameparams encparms = { minBitrDef, maxBitrDef, false, algqualDef, vbrqualDef, 0, "lame" };
    7576oggencparams oggparms = { -1, -1, -1, (float)oggqualDef, 0 };
    7677flaccparams flacparms = { flacCompressDef, flacBlocksizeDef, false, false };
    7778rawtype rawAudioType = { false, false, 8 };
     
    124125        char *tmp = fbuf;
    125126
    126127        if (compmode == AUDIO_MP3) {
    127                 tmp += sprintf(tmp, "lame -t ");
     128                tmp += sprintf(tmp, "%s -t ", encparms.lamePath.c_str());
    128129                if (rawInput) {
    129130                        tmp += sprintf(tmp, "-r ");
    130131                        tmp += sprintf(tmp, "--bitwidth %d ", rawAudioType.bitsPerSample);
     
    774775}
    775776
    776777// mp3 settings
     778void CompressionTool::setMp3LamePath(const std::string& arg) {
     779        encparms.lamePath = arg;
     780}
     781
    777782void CompressionTool::setMp3CompressionType(const std::string& arg) {
    778783        encparms.abr = (arg == "ABR");
    779784}
     
    899904                        encparms.abr = 0;
    900905                } else if (arg == "--abr") {
    901906                        encparms.abr = 1;
     907                } else if (arg == "-lame-path") {
     908                        if (_arguments.empty())
     909                                throw ToolException("Could not parse command line options, expected value after -lame-path");
     910                        setMp3LamePath(_arguments.front());
     911                        _arguments.pop_front();
    902912
    903913                } else if (arg == "-b") {
    904914                        if (_arguments.empty())
     
    11031113
    11041114        if (_supportedFormats & AUDIO_MP3) {
    11051115                os << "\nMP3 mode params:\n";
     1116                os << " -lame-path <path> Path to the lame excutable to use (default: lame)\n";
    11061117                os << " -b <rate>    <rate> is the target bitrate(ABR)/minimal bitrate(VBR) (default:" << minBitrDef << "%d)\n";
    11071118                os << " -B <rate>    <rate> is the maximum VBR/ABR bitrate (default:%" << maxBitrDef << ")\n";
    11081119                os << " --vbr        LAME uses the VBR mode (default)\n";