View Full Version : For cqp streams, will bigger GOP size lead to bigger PSNR?
lance0010
5th June 2013, 09:02
Hi
Suppose one is encoded as CQP I10P, the other is CQP I30P, both have qp=26.
In most cases, will I30P have a better PSNR than I10P?
(no transmission error involved)
:thanks:
akupenguin
5th June 2013, 10:52
If the I-frames have the same QP as the P-frames (i.e. --ipratio 1), then yes a longer GOP will have better PSNR. Because QP places an upper bound on the distortion, but there's no lower bound, and well predicted blocks can have distortion significantly lower than that upper bound, and inter is better prediction than intra. For the same reason, within a single GOP the P-frames will have better PSNR than the I-frames.
Otoh, x264 default is that --qp only specifies the QP of P-frames, and I-frames have lower QP than that. And they're lower by enough to more than compensate for the above effect.
lance0010
6th June 2013, 07:00
Thanks for your reply.
Does it mean if cqp(both I/P, no B frame involved) and qp is the same, generally P frame will have better PSNR than I frame?(inter will have smaller SAD(SATD probably too?) than intra)?
I noticed that in x264 there is a --scenecut parameter, which will be able to encode scene change frames as I frames.
In such case, if cqp and qp is the same, the PSNR probably will not be better than IPPP..PPP, is that so?
So if I want to get the benefits of --scenecut, what metric should I use? PSNR seems not be a good choice for this, set the same qp and compare the encoded stream size?
Thanks
akupenguin
6th June 2013, 14:41
So if I want to get the benefits of --scenecut, what metric should I use? PSNR seems not be a good choice for this, set the same qp and compare the encoded stream size?
I don't know of any good automated metric to measure scenecut accuracy, but size at CQP definitely isn't it. SSIM at a fixed filesize in 2-pass mode might work, but no promises.
My previous statement about P-frames being better quality than I-frames applies to I-frames forced in the middle of a scene, not to correctly detected scenecuts. Because a scenecut encoded as a P-frame wouldn't in fact be inter-predicted, it'd just be a P-frame full of I-blocks, approximately equivalent to an I-frame.
lance0010
7th June 2013, 02:44
I think I didn't express myself clearly.
Here is what I'm trying to do.
Now I use scenecut to encode a stream, for my clips, all the scene change frames are encoded as I frames, others are P frames. Then I tried to compare the PSNR of "scenecut encoded streams" with I10P/I30P/Ionly encoded stream. If CQP is the same, and all cp is set the same, then I found that Ionly mode has the best PSNR,(At first I thought P frames shall have better PSNR than I frame, but seems not so for some clips), I10P is bette than I30P. So to me it seems that PSNR is better if there are more I frames encoded.
So my question is:
1. Even I encoded all the scene change frames as I frames and intuitively it should be better, but I don't find any good metric to prove that it's better than I10P or I30P.
2. Still a little confused about the PSNR of I/P frames. Per my understanding, all the loss comes from quantization, so the same frame encoded as P should have smaller residual than I frame, but after DCT, smaller residual may not lead to smaller loss during quantization, it's not directly related, is this right?
Thanks
akupenguin
7th June 2013, 14:02
Per my understanding, all the loss comes from quantization, so the same frame encoded as P should have smaller residual than I frame, but after DCT, smaller residual may not lead to smaller loss during quantization, it's not directly related, is this right?
In any DCT coefficient that quantizes to a value >=1, reducing the residual by an amount that leaves it >=1 (while holding QP constant) saves bits but doesn't change distortion on average. Otoh, if the coefficient already quantized to 0, then reducing that residual does reduce the distortion. Lots of coefficients do quantize to 0, so reducing residual does usually reduce distortion. The amount of such reduction depends on what the residual was to begin with.
At first I thought P frames shall have better PSNR than I frame, but seems not so for some clips
I confirm that there are some clips where this is not so. I don't know what distinguishes them from the clips where my reasoning does apply.
But it's irrelevant, because this isn't what you should have measured anyway. (My first two comments were answering your literal question, not addressing your reason for asking it.) Compression efficiency is quality-per-bit, not quality-ignoring-bits. And P-frames are definitely better than I-frames in quality-per-bit. Measuring only PSNR at CQP is measuring quality-ignoring-bits, and is therefore irrelevant to the question of which encoding options are more efficient. Even measuring both PSNR and bitrate at CQP is still wrong, because real encodes aren't CQP (and yes that affects compression ratio, because it eliminates the effect of any optimizations that modulate QP).
Even I encoded all the scene change frames as I frames and intuitively it should be better, but I don't find any good metric to prove that it's better than I10P or I30P.
Scenecut detection has the following purposes:
* Improve compression efficiency. Given that you need a moderate frequency of I-frames so that you can seek, it's more efficient for those I-frames to be at scenecuts rather than in the middle of scenes. The scenecuts are going to be intra-predicted either way, and incur the full bitcost of that. Inserting I-frames in the middle of scenes costs extra bits. Marking the scenecuts as I-frames means you don't have to do that.
* Improve perceptual quality. Intra-coded blocks are less similar to the previous frame than inter-coded blocks are, even holding PSNR and/or SSIM constant. If a frame should have been similar to the previous frame (because it's in the same scene), and isn't because you forced it to be intra, then that change is visible and bad.
* Improve seeking. While merely having a certain frequency of I-frames is necessary and sufficient for seeking to be possible at all, seeking is more convenient if the I-frames are at the places you'd want to seek to, i.e. scenecuts. Some players can only seek to I-frames, and even the ones that don't have that constraint take extra CPU-time to seek anywhere else.
The first of these properties can be measured by SSIM at a given filesize in 2pass mode. The other two can't be measured by any existing automated metrics I know of.
lance0010
8th June 2013, 09:46
Thanks very much, I'm now clear about this.
For the reasons I measured both PSNR and bitrate at CQP because I don't want to involve ratectrl algorithm.
Since different bitrate control algorithm may lead to different results, just want to make it simple first.
benwaggoner
11th June 2013, 23:55
Here is what I'm trying to do.
Now I use scenecut to encode a stream, for my clips, all the scene change frames are encoded as I frames, others are P frames. Then I tried to compare the PSNR of "scenecut encoded streams" with I10P/I30P/Ionly encoded stream. If CQP is the same, and all cp is set the same, then I found that Ionly mode has the best PSNR,(At first I thought P frames shall have better PSNR than I frame, but seems not so for some clips), I10P is bette than I30P. So to me it seems that PSNR is better if there are more I frames encoded.
Those are the steps you are trying to take, but I still have no idea what goal you are trying to go for :). Some sort of test bitstreams or something?
lance0010
17th June 2013, 09:51
Those are the steps you are trying to take, but I still have no idea what goal you are trying to go for :). Some sort of test bitstreams or something?
Just want to find a way to prove that adaptive GOP(--scenecut) is better than fixed GOP, and also want to find a metric to measure it:thanks:
benwaggoner
17th June 2013, 17:03
Just want to find a way to prove that adaptive GOP(--scenecut) is better than fixed GOP, and also want to find a metric to measure it:thanks:
Double-blind subjective ratings :)?
The tricky thing is that one of the biggest advantages of Adaptive GOP is reduced keyframe strobing, which doesn't get captured by spatial only analysis. You'd need some kind of temporal comparison metric.
The MSU analysis tool has Spatio-Temporal SSIM, which sounds like it might be useful there. I've not tried it myself, though.
http://www.compression.ru/video/quality_measure/info_en.html#stssim
lance0010
18th June 2013, 07:23
Double-blind subjective ratings :)?
The tricky thing is that one of the biggest advantages of Adaptive GOP is reduced keyframe strobing, which doesn't get captured by spatial only analysis. You'd need some kind of temporal comparison metric.
The MSU analysis tool has Spatio-Temporal SSIM, which sounds like it might be useful there. I've not tried it myself, though.
http://www.compression.ru/video/quality_measure/info_en.html#stssim
I'll have a try on that.
:thanks:
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.