Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x265] Lossless option #515

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion avidemux_core/ADM_coreUtils/src/ADM_paramList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ static bool compressReadFromString(COMPRES_PARAMS *params,const char *str)
if(!strcasecmp(tmp,"2PASS")) {params->mode=COMPRESS_2PASS;params->finalsize=val;return true;}
if(!strcasecmp(tmp,"2PASSBITRATE")) {params->mode=COMPRESS_2PASS_BITRATE;params->avg_bitrate=val;return true;}
if(!strcasecmp(tmp,"AQ")) {params->mode=COMPRESS_AQ;params->qz=val;return true;}
if(!strcasecmp(tmp,"LOSSLESS")) {params->mode=COMPRESS_LOSSLESS;return true;}
ADM_error("Unknown mode :%s\n",tmp);
return false;

Expand All @@ -197,8 +198,9 @@ bool ADM_compressWriteToString(COMPRES_PARAMS *params, char **str)
case COMPRESS_SAME: sprintf(tmp,"SAME");break;
case COMPRESS_2PASS_BITRATE: sprintf(tmp,"2PASSBITRATE=%" PRIu32,params->avg_bitrate);break;
case COMPRESS_AQ: sprintf(tmp,"AQ=%" PRIu32,params->qz);break;
case COMPRESS_LOSSLESS: sprintf(tmp,"LOSSLESS=1");break;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, it feels somewhat awkward to write "general.params=LOSSLESS=1" when "general.params=LOSSLESS=0" means exactly the same. Could you please explain the rationale?

With "general.params=LOSSLESS" we can exit compressReadFromString() early like in case of "general.params=SAME" (just not really used anywhere) and it is free from ambiguity, IMHO.

default:
ADM_error("Unknown compressin mode \n");
ADM_error("Unknown compression mode \n");
return false;
}
*str=ADM_strdup(tmp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ typedef enum
COMPRESS_SAME,
COMPRESS_2PASS_BITRATE,
COMPRESS_AQ,
COMPRESS_LOSSLESS,
COMPRESS_MAX
} COMPRESSION_MODE;

Expand Down
4 changes: 4 additions & 0 deletions avidemux_plugins/ADM_videoEncoder/x265/ADM_x265Setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ bool x265Encoder::setup(void)
MKPARAM(transferCharacteristics,transfer_characteristics)
}

param.bLossless = 0;
// -------------- rate control------------
switch(x265Settings.general.params.mode)
{
Expand Down Expand Up @@ -243,6 +244,9 @@ bool x265Encoder::setup(void)
param.rc.qp = 0;
param.rc.rfConstant = 0;
break;
case COMPRESS_LOSSLESS:
param.bLossless = 1;
break;
default:
GUI_Error_HIG(QT_TRANSLATE_NOOP("x265","Not coded"),QT_TRANSLATE_NOOP("x265","this mode has not been implemented\n"));
return false;
Expand Down
15 changes: 11 additions & 4 deletions avidemux_plugins/ADM_videoEncoder/x265/qt4/Q_x265.cpp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my Q&D version to try out the lossless mode, I ended up with the same changes here, but, for a proper implementation, I'd love to see all options overridden by lossless mode systematically disabled. Maybe not trying to rush it in 2.8.2 but doing it thoroughly right thereafter?

Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ bool x265Dialog::upload(void)
//encodingModeComboBox_currentIndexChanged(1);
ui.quantiserSpinBox->setValue(ENCODING(qz));
break;
case COMPRESS_LOSSLESS:
ui.encodingModeComboBox->setCurrentIndex(5);
break;

default: ADM_assert(0);break;
}
Expand Down Expand Up @@ -679,6 +682,7 @@ bool x265Dialog::download(void)
case 2: ENCODING(mode)=COMPRESS_AQ;ENCODING(qz)=ui.quantiserSpinBox->value();break;
case 3: ENCODING(mode)=COMPRESS_2PASS;ENCODING(finalsize)=ui.targetRateControlSpinBox->value();;break;
case 4: ENCODING(mode)=COMPRESS_2PASS_BITRATE;ENCODING(avg_bitrate)=ui.targetRateControlSpinBox->value();;break;
case 5: ENCODING(mode)=COMPRESS_LOSSLESS;break;
}

#if X265_BUILD < 47
Expand Down Expand Up @@ -710,7 +714,7 @@ bool x265Dialog::download(void)
// General tab
void x265Dialog::encodingModeComboBox_currentIndexChanged(int index)
{
bool enableQp = false, enableMaxCrf = false, enableStrictCbr = false;
bool enableQp = false, enableMaxCrf = false, enableStrictCbr = false, lossless = false;

switch (index)
{
Expand Down Expand Up @@ -739,6 +743,9 @@ void x265Dialog::encodingModeComboBox_currentIndexChanged(int index)
ui.targetRateControlLabel2->setText(QString::fromUtf8(QT_TRANSLATE_NOOP("x265","kbit/s")));
ui.targetRateControlSpinBox->setValue(lastBitrate);
break;
case 5: // Lossless
lossless = true;
break;
}

ui.quantiserLabel1->setEnabled(enableQp);
Expand All @@ -747,9 +754,9 @@ void x265Dialog::encodingModeComboBox_currentIndexChanged(int index)
ui.quantiserSlider->setEnabled(enableQp);
ui.quantiserSpinBox->setEnabled(enableQp);

ui.targetRateControlLabel1->setEnabled(!enableQp);
ui.targetRateControlLabel2->setEnabled(!enableQp);
ui.targetRateControlSpinBox->setEnabled(!enableQp);
ui.targetRateControlLabel1->setEnabled(!enableQp && !lossless);
ui.targetRateControlLabel2->setEnabled(!enableQp && !lossless);
ui.targetRateControlSpinBox->setEnabled(!enableQp && !lossless);

#if X265_BUILD >= 41
ui.strictCbrCheckBox->setEnabled(enableStrictCbr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@
<string>Average Bitrate (Two Pass)</string>
</property>
</item>
<item>
<property name="text">
<string>Lossless (Single Pass)</string>
</property>
</item>
</widget>
</item>
<item>
Expand Down