Ticket #1625: transcode-filters.diff

File transcode-filters.diff, 7.6 KB (added by bmayland@…, 18 years ago)

diff svn head r9579

  • libs/libmythtv/recordingprofile.h

     
    3838class ImageSize;
    3939class TranscodeResize;
    4040class TranscodeLossless;
     41class TranscodeFilters;
    4142
    4243class RecordingProfile: public ConfigurationWizard
    4344{
     
    102103  private slots:
    103104    void ResizeTranscode(bool resize);
    104105    void SetLosslessTranscode(bool lossless);
     106    void FiltersChanged(const QString &val);
    105107
    106108  private:
    107109    ID                       *id;
     
    109111    ImageSize                *imageSize;
    110112    TranscodeResize          *tr_resize;
    111113    TranscodeLossless        *tr_lossless;
     114    TranscodeFilters         *tr_filters;
    112115    VideoCompressionSettings *videoSettings;
    113116    AudioCompressionSettings *audioSettings;
    114117    QString                   profileName;
  • libs/libmythtv/recordingprofile.cpp

     
    676676    };
    677677};
    678678
     679class TranscodeFilters: public CodecParam, public LineEditSetting {
     680public:
     681    TranscodeFilters(const RecordingProfile& parent):
     682        CodecParam(parent, "transcodefilters"),
     683        LineEditSetting() {
     684        setLabel(QObject::tr("Custom Filters"));
     685        setHelpText(QObject::tr("Filters used when transcoding using "
     686                                "this profile. Format:\n"
     687                                "[[<filter>=<options>,]...]"
     688                                ));
     689    };
     690};
     691
    679692class ImageSize: public VerticalConfigurationGroup {
    680693public:
    681694    class Width: public SpinBoxSetting, public CodecParam {
     
    755768    : id(new ID()),        name(new Name(*this)),
    756769      imageSize(NULL),     videoSettings(NULL),
    757770      audioSettings(NULL), profileName(profName),
    758       isEncoder(true)
     771      isEncoder(true)     
    759772{
    760773    // This must be first because it is needed to load/save the other settings
    761774    addChild(id);
     
    769782    profile->setLabel(labelName);
    770783    profile->addChild(name);
    771784
     785    tr_filters = NULL;
    772786    tr_lossless = NULL;
    773787    tr_resize = NULL;
    774788
     
    776790    {
    777791        if (profName.left(11) == "Transcoders")
    778792        {
     793            tr_filters = new TranscodeFilters(*this);
    779794            tr_lossless = new TranscodeLossless(*this);
    780795            tr_resize = new TranscodeResize(*this);
     796            profile->addChild(tr_filters);
    781797            profile->addChild(tr_lossless);
    782798            profile->addChild(tr_resize);
    783799        }
     
    786802    }
    787803    else
    788804    {
     805        tr_filters = new TranscodeFilters(*this);
    789806        tr_lossless = new TranscodeLossless(*this);
    790807        tr_resize = new TranscodeResize(*this);
     808        profile->addChild(tr_filters);
    791809        profile->addChild(tr_lossless);
    792810        profile->addChild(tr_resize);
    793811        profile->addChild(new AutoTranscode(*this));
     
    799817void RecordingProfile::ResizeTranscode(bool resize)
    800818{
    801819    MythWizard *wizard = (MythWizard *)dialog;
     820    if (!wizard)
     821        return;
    802822    //page '1' is the Image Size page
    803823    QWidget *size_page = wizard->page(1);
    804824    wizard->setAppropriate(size_page, resize);
     
    807827void RecordingProfile::SetLosslessTranscode(bool lossless)
    808828{
    809829    MythWizard *wizard = (MythWizard *)dialog;
     830    if (!wizard)
     831        return;
    810832
    811833    bool show_size = (lossless) ? false : tr_resize->boolValue();
    812834    wizard->setAppropriate(wizard->page(1), show_size);
     
    816838    wizard->setNextEnabled(wizard->page(0), ! lossless);
    817839    wizard->setFinishEnabled(wizard->page(0), lossless);
    818840   
     841    if (tr_filters)
     842        tr_filters->setEnabled(!lossless);
    819843}
    820844
    821845void RecordingProfile::loadByID(int profileId)
     
    846870
    847871        audioSettings = new AudioCompressionSettings(*this, profileName);
    848872        addChild(audioSettings);
    849 
     873       
    850874        if (profileName && profileName.left(11) == "Transcoders")
    851875        {
    852876            connect(tr_resize, SIGNAL(valueChanged   (bool)),
    853877                    this,      SLOT(  ResizeTranscode(bool)));
    854878            connect(tr_lossless, SIGNAL(valueChanged        (bool)),
    855                     this,        SLOT(  SetLosslessTranscode(bool)));
     879                    this,      SLOT(  SetLosslessTranscode(bool)));
     880            connect(tr_filters, SIGNAL(valueChanged(const QString &)),
     881                    this,      SLOT(FiltersChanged(const QString &)));
    856882        }
    857883    }
    858884
     
    860886    load();
    861887}
    862888
     889void RecordingProfile::FiltersChanged(const QString &val)
     890{
     891    if (!tr_filters || !tr_lossless)
     892      return;
     893   
     894    // If there are filters, we can not do lossless transcoding
     895    if (val.stripWhiteSpace().length() > 0) {
     896       tr_lossless->setValue(false);
     897       tr_lossless->setEnabled(false);
     898    } else {
     899       tr_lossless->setEnabled(true);
     900    }
     901}
     902
    863903bool RecordingProfile::loadByType(QString name, QString cardtype)
    864904{
    865905    QString hostname = gContext->GetHostName();
     
    937977int RecordingProfile::exec()
    938978{
    939979    MythDialog* dialog = dialogWidget(gContext->GetMainWindow());
     980
    940981    dialog->Show();
    941982    if (tr_lossless)
    942983        SetLosslessTranscode(tr_lossless->boolValue());
    943 
     984    if (tr_resize)
     985        ResizeTranscode(tr_resize->boolValue());
     986    // Filters should be set last because it might disable lossless
     987    if (tr_filters)
     988        FiltersChanged(tr_filters->getValue());
     989   
    944990    int ret = dialog->exec();
    945991
    946992    delete dialog;
  • libs/libmyth/settings.h

     
    214214
    215215class ConfigurationDialog: virtual public Configurable {
    216216public:
     217    ConfigurationDialog() :
     218        Configurable(), dialog(NULL) {};
     219
    217220    // Make a modal dialog containing configWidget
    218221    virtual MythDialog* dialogWidget(MythMainWindow *parent,
    219222                                     const char* widgetName = 0);
  • programs/mythtranscode/transcode.cpp

     
    378378    QString encodingType = nvp->GetEncodingType();
    379379    bool copyvideo = false, copyaudio = false;
    380380
    381     QString vidsetting = NULL, audsetting = NULL;
     381    QString vidsetting = NULL, audsetting = NULL, vidfilters = NULL;
    382382
    383383    int video_width = nvp->GetVideoWidth();
    384384    int video_height = nvp->GetVideoHeight();
     
    397397        }
    398398        vidsetting = profile.byName("videocodec")->getValue();
    399399        audsetting = profile.byName("audiocodec")->getValue();
     400        vidfilters = profile.byName("transcodefilters")->getValue();
    400401
    401402        if (encodingType == "MPEG-2" &&
    402403            profile.byName("transcodelossless")->getValue().toInt())
     
    413414        }
    414415        else if (profile.byName("transcoderesize")->getValue().toInt())
    415416        {
     417            nvp->SetVideoFilters(vidfilters);
    416418            newWidth = profile.byName("width")->getValue().toInt();
    417419            newHeight = profile.byName("height")->getValue().toInt();
    418420
     
    443445                    .arg(video_width).arg(video_height)
    444446                    .arg(newWidth).arg(newHeight));
    445447        }
     448        else  // lossy and no resize
     449            nvp->SetVideoFilters(vidfilters);
    446450
    447451        // this is ripped from tv_rec SetupRecording. It'd be nice to merge
    448452        nvr->SetOption("inpixfmt", FMT_YV12);