[MEncoder-users] on psy_rd

Matyas mplayer.list at sustik.com
Thu Sep 17 15:43:08 CEST 2009


Grozdan wrote:
> 2009/9/17 Matyas <mplayer.list at sustik.com>:
>> Hi,
>>
>> Could someone in the know compare and comment on the two runs bellow.  It
>> would hopefully help me understand the usage/benefit of various psy_rd values.
> 
> psy-rd lowers PSNR and SSIM while subjectively increases quality so
> you shouldn't trust these metrics too much while using psychovisual
> options like adaptive quantization and psy-rd. I don't really know
> what you want us to comment about. I always use psy-rd of 0.8:0.2 and
> all looks good to me. Also you should use b-adapt=2 and lower bframes
> to something like 4 or 5

Thank you for the recommendation about b_adapt and bframes, I will play with
them.

I was not looking at the global PSNR/SSIM numbers with that much interest,
but rather the bitrate.  I just recently switched all my encodes to use crf
from two-pass and so this is the first time I saw how psy_rd affects bitrate
with crf.

(Really just in parenthesis why I switched: I run several samples - from
movies and OTA HD recordings - with various crf values - in the range of
20-24 - and then reencoded the same with two-pass using the bitrates these
encodings produced.  I used log=3 and turned off psy_rd (as recommended here)
and plotted the resulting SSIM values.  I found that crf produced almost the
same results in almost half the time.  In fact, surprisingly the deviation
for per frame SSIM was slightly lower for crf more often.)

So once I settled on crf encodings I started to run some experiments to see
what crf values make sense (look good) for my various types of sources.

I accidentally noticed that psy_rd has a substantial effect on bitrate (with
same crf).

I did one subsequent run which uses crf=21.65 psy_rd=0.0:0.0.  This produced
a 461kb/s video file.  I compared the per frame SSIM values to the run from
crf=22 psy_rd=0.0:0.2.  (Recall that was 466kb/s.)  My reasoning is that with
(almost) the same bitrate, the difference is in where bits are allocated.  I
looked at the frames where the two encodings had the largest difference
(either way) in SSIM and looked at those frames.  Considering that psy_rd
aims to improve perceptual quality and not SSIM I also compared the frames
themselves (so my intention was to use the SSIM values only to find the
outliers.)  The frames looked the same (also compared to the source).  Maybe
with lower crf settings I could see difference.  The crf=21.65 run had the
max SSIM advantage at the first frame after a cut.

Here is the log info around frames 17712 and 24701, the outliers:

crf=22:psy_rd=0.0:0.2 run:
x264 [debug]: frame=17710 QP=25.47 NAL=2 Slice:P Poc:52  I:59   P:909  SKIP:0
 size=20619 bytes PSNR Y:39.91 U:38.82 V:40.24 SSIM Y:0.98659
x264 [debug]: frame=17711 QP=28.22 NAL=0 Slice:B Poc:50  I:18   P:800  SKIP:2
 size=16542 bytes PSNR Y:37.62 U:36.31 V:37.56 SSIM Y:0.97775
x264 [debug]: frame=17712 QP=25.33 NAL=2 Slice:P Poc:56  I:60   P:908  SKIP:0
   size=23261 bytes PSNR Y:39.44 U:38.70 V:40.07 SSIM Y:0.98483
x264 [debug]: frame=17713 QP=27.51 NAL=0 Slice:B Poc:54  I:9    P:727  SKIP:3
   size=17356 bytes PSNR Y:38.09 U:36.77 V:38.09 SSIM Y:0.97984
x264 [debug]: frame=17714 QP=25.13 NAL=2 Slice:P Poc:60  I:58   P:909  SKIP:1
   size=21740 bytes PSNR Y:39.29 U:38.73 V:40.26 SSIM Y:0.98454
[...]
x264 [debug]: frame=24699 QP=24.12 NAL=0 Slice:B Poc:260 I:3    P:230  SKIP:732
 size=676 bytes PSNR Y:40.95 U:41.43 V:44.73 SSIM Y:0.98223
x264 [debug]: frame=24700 QP=20.72 NAL=3 Slice:I Poc:0   I:968  P:0    SKIP:0
 size=19495 bytes PSNR Y:43.65 U:42.65 V:45.25 SSIM Y:0.96706
x264 [debug]: frame=24701 QP=22.41 NAL=2 Slice:P Poc:2   I:352  P:507
SKIP:109  size=3759 bytes PSNR Y:45.82 U:42.83 V:46.19 SSIM Y:0.98341
x264 [debug]: frame=24702 QP=21.81 NAL=2 Slice:P Poc:6   I:163  P:741
SKIP:64   size=3641 bytes PSNR Y:46.15 U:43.00 V:46.27 SSIM Y:0.98495
x264 [debug]: frame=24703 QP=24.50 NAL=0 Slice:B Poc:4   I:0    P:221
SKIP:746  size=523 bytes PSNR Y:45.37 U:41.95 V:45.89 SSIM Y:0.98469

crf=21.65:psy_rd=0.0:0.0 run:
x264 [debug]: frame=17710 QP=25.13 NAL=2 Slice:P Poc:52  I:68   P:899  SKIP:1
 size=20396 bytes PSNR Y:40.06 U:38.35 V:39.83 SSIM Y:0.98686
x264 [debug]: frame=17711 QP=27.21 NAL=0 Slice:B Poc:50  I:15   P:776  SKIP:0
 size=17869 bytes PSNR Y:38.29 U:36.34 V:37.50 SSIM Y:0.98043
x264 [debug]: frame=17712 QP=24.94 NAL=2 Slice:P Poc:56  I:70   P:897  SKIP:1
   size=23219 bytes PSNR Y:39.74 U:38.39 V:39.70 SSIM Y:0.98558
x264 [debug]: frame=17713 QP=27.26 NAL=0 Slice:B Poc:54  I:11   P:726  SKIP:3
   size=16564 bytes PSNR Y:38.23 U:36.14 V:37.46 SSIM Y:0.98041
x264 [debug]: frame=17714 QP=24.84 NAL=2 Slice:P Poc:60  I:52   P:916  SKIP:0
   size=21051 bytes PSNR Y:39.44 U:38.22 V:39.75 SSIM Y:0.98487
[...]
x264 [debug]: frame=24699 QP=23.83 NAL=0 Slice:B Poc:260 I:2    P:232  SKIP:732
 size=688 bytes PSNR Y:41.04 U:41.22 V:44.48 SSIM Y:0.98252
x264 [debug]: frame=24700 QP=20.52 NAL=3 Slice:I Poc:0   I:968  P:0    SKIP:0
 size=15785 bytes PSNR Y:43.34 U:42.13 V:44.98 SSIM Y:0.96354
x264 [debug]: frame=24701 QP=22.00 NAL=2 Slice:P Poc:2   I:302  P:539
SKIP:127  size=3279 bytes PSNR Y:46.02 U:42.54 V:45.96 SSIM Y:0.98393
x264 [debug]: frame=24702 QP=21.53 NAL=2 Slice:P Poc:6   I:143  P:742
SKIP:83   size=3374 bytes PSNR Y:46.33 U:42.76 V:46.10 SSIM Y:0.98538
x264 [debug]: frame=24703 QP=23.74 NAL=0 Slice:B Poc:4   I:1    P:209
SKIP:754  size=521 bytes PSNR Y:45.65 U:41.88 V:45.75 SSIM Y:0.98532

Note, this is not a question about psy_rd really improving quality, it is
about the effect on bitrate.   I expected that when using a crf setting I
would see smaller bitrate but the same quality as I use higher settings for
options affecting quality.  Maybe this is where I am wrong.  I certainly saw
that with subq though.  The same crf value encode produced lower bitrates
with higher subq values.  (I did not yet get to compare the per frame SSIM
for that.)

Thanks to all for their attention.
Matyas
-
Every hardware eventually breaks.  Every software eventually works.


More information about the MEncoder-users mailing list