Log in

View Full Version : Lossless with "-QP 0"?


asarian
28th August 2014, 09:54
Speaking of lossless, how lossless is encoding with "-QP 0" (x264) really?

I have a project that requires several passes, with lossless intermediate steps. Will "-QP 0" do it?

Thanks.

nevcairiel
28th August 2014, 09:57
--qp 0 is entirely lossless, if you also ensure it uses the same pixel format (ie. chroma is not being resampled, or anything like that)

asarian
28th August 2014, 09:58
--qp 0 is entirely lossless, if you also ensure it uses the same pixel format (ie. chroma is not being resampled, or anything like that)

Thanks. :) Question answered.

F J Walter
5th September 2014, 02:43
Does setting --qp 0 also set other options to sensible values for lossless coding?

For example, does it disable AQ and psy options?

Or should I be doing that myself?

LoRd_MuldeR
5th September 2014, 02:58
Does setting --qp 0 also set other options to sensible values for lossless coding?

Yes, it does.

For example, does it disable AQ and psy options?

Those don't apply to lossless encoding, for obvious reasons.

F J Walter
10th September 2014, 02:44
Those don't apply to lossless encoding, for obvious reasons.

A quick test shows this is correct: --psy-rd and --aq-mode have no effect on the output in lossless.

The same goes for --trellis, and --deadzone-intra - I guess lossless uses a different quantization algorithm to both trellis and deadzone (either that or it locks off these parameters).

Options like --subme and --me do change the output size though, so these are not locked off in lossless. And --subme 7 results in a lower file size than --subme 5 implying that normal non-psy RDO is still active in lossless.

In lossless there is not very much different in output size as long as you don't go below --preset fast (eg, medium, slow, slower don't offer much benefit). And lossless is significantly slower than non-lossless even with all else equal, eg lossless with --preset fast is much slower than --preset fast is normally.

I could have done this testing myself instead of asking you, sorry!

foxyshadis
10th September 2014, 04:28
Any options that trade-off different artifacts (like AQ & psy prefer more noise instead of more blur, trellis and deadzone also affect the blur vs noise) don't matter when there's no blur or noise. I'm pretty sure they're ignored in lossless, but the result would be the same if they weren't.

fionag
10th September 2014, 15:17
From encoder.c:

if( b_open && (h->param.rc.i_rc_method == X264_RC_CQP || h->param.rc.i_rc_method == X264_RC_CRF)
&& h->param.rc.i_qp_constant == 0 )
{
h->mb.b_lossless = 1;
h->param.i_cqm_preset = X264_CQM_FLAT;
h->param.psz_cqm_file = NULL;
h->param.rc.i_rc_method = X264_RC_CQP;
h->param.rc.f_ip_factor = 1;
h->param.rc.f_pb_factor = 1;
h->param.analyse.b_psnr = 0;
h->param.analyse.b_ssim = 0;
h->param.analyse.i_chroma_qp_offset = 0;
h->param.analyse.i_trellis = 0;
h->param.analyse.b_fast_pskip = 0;
h->param.analyse.i_noise_reduction = 0;
h->param.analyse.b_psy = 0;
h->param.i_bframe = 0;
/* 8x8dct is not useful without RD in CAVLC lossless */
if( !h->param.b_cabac && h->param.analyse.i_subpel_refine < 6 )
h->param.analyse.b_transform_8x8 = 0;
h->param.analyse.inter &= ~X264_ANALYSE_I8x8;
h->param.analyse.intra &= ~X264_ANALYSE_I8x8;
}