Opened 10 years ago

Closed 10 years ago

#3567 closed defect (fixed)

Infinite PSNR Values with X265

Reported by: Oche Ejembi Owned by:
Priority: minor Component: avcodec
Version: git-master Keywords: libx265
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
When I encode a YUV file with libx265 with the -psnr flag turned on, the given values are infinite/do not make sense.

How to reproduce:

% ffmpeg -i bunny1_test_small_QCIF.y4m -report -ssim 1 -psnr -v 9 -loglevel 99 -y bunny1_QCIF_small.hevc
ffmpeg version 2.2.git Copyright (c) 2000-2014 the FFmpeg developers
  built on Mar 12 2014 00:14:34 with gcc 4.8 (Ubuntu/Linaro 4.8.1-10ubuntu9)
  configuration: --prefix=/home/system/ffmpeg_build --extra-cflags=-I/home/system/ffmpeg_build/include --extra-ldflags=-L/home/system/ffmpeg_build/lib --bindir=/home/system/bin --extra-libs=-ldl --enable-gpl --enable-libass --enable-libfdk-aac --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-nonfree --enable-x11grab --enable-libx265
  libavutil      52. 66.101 / 52. 66.101
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 34.100 / 55. 34.100
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  5.101 /  2.  5.101
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-i' ... matched as input file with argument 'bunny1_test_small_QCIF.y4m'.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Reading option '-ssim' ... matched as AVOption 'ssim' with argument '1'.
Reading option '-psnr' ... matched as option 'psnr' (calculate PSNR of compressed frames) with argument '1'.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option 'bunny1_QCIF_small.hevc' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option report (generate a report) with argument 1.
Applying option psnr (calculate PSNR of compressed frames) with argument 1.
Applying option v (set logging level) with argument 9.
Applying option loglevel (set logging level) with argument 99.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file bunny1_test_small_QCIF.y4m.
Successfully parsed a group of options.
Opening an input file: bunny1_test_small_QCIF.y4m.
[yuv4mpegpipe @ 0x2a66a80] Format yuv4mpegpipe probed with size=2048 and score=100
[yuv4mpegpipe @ 0x2a66a80] Before avformat_find_stream_info() pos: 60 bytes read:32768 seeks:0
[yuv4mpegpipe @ 0x2a66a80] max_analyze_duration 5000000 reached at 5000000 microseconds
[yuv4mpegpipe @ 0x2a66a80] After avformat_find_stream_info() pos: 4600722 bytes read:4622982 seeks:0 frames:120
Input #0, yuv4mpegpipe, from 'bunny1_test_small_QCIF.y4m':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 120, 1/24: Video: rawvideo (I420 / 0x30323449), yuv420p, 176x144, 1/24, SAR 16:11 DAR 16:9, 24 fps, 24 tbr, 24 tbn, 24 tbc
Successfully opened the file.
Parsing a group of options: output file bunny1_QCIF_small.hevc.
Successfully parsed a group of options.
Opening an output file: bunny1_QCIF_small.hevc.
Codec AVOption ssim (Calculate and print SSIM stats.) specified for output file #0 (bunny1_QCIF_small.hevc) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0x2a6a4c0] Setting 'video_size' to value '176x144'
[graph 0 input from stream 0:0 @ 0x2a6a4c0] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 0x2a6a4c0] Setting 'time_base' to value '1/24'
[graph 0 input from stream 0:0 @ 0x2a6a4c0] Setting 'pixel_aspect' to value '16/11'
[graph 0 input from stream 0:0 @ 0x2a6a4c0] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x2a6a4c0] Setting 'frame_rate' to value '24/1'
[graph 0 input from stream 0:0 @ 0x2a6a4c0] w:176 h:144 pixfmt:yuv420p tb:1/24 fr:24/1 sar:16/11 sws_param:flags=2
[format @ 0x2a6aba0] compat: called with args=[yuv420p|yuv444p]
[format @ 0x2a6aba0] Setting 'pix_fmts' to value 'yuv420p|yuv444p'
[AVFilterGraph @ 0x2a68080] query_formats: 4 queried, 3 merged, 0 already done, 0 delayed
Output #0, hevc, to 'bunny1_QCIF_small.hevc':
  Metadata:
    encoder         : Lavf55.34.100
    Stream #0:0, 0, 1/90000: Video: hevc (libx265), yuv420p, 176x144 [SAR 16:11 DAR 16:9], 1/24, q=2-31, 200 kb/s, 90k tbn, 24 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> libx265)
Press [q] to stop, [?] for help
[output stream 0:0 @ 0x2a6a820] EOF on sink link output stream 0:0:default.=00:00:10.00 bitrate= 257.1kbits/s    
No more output streams to write to, finishing.
frame=  269 fps= 28 q=0.0 **LPSNR=Y:inf U:inf V:inf *:inf *** size=     338kB time=00:00:11.12 bitrate= 248.6kbits/s    
video:338kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead 0.000000%
269 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x2a68320] Statistics: 0 seeks, 269 writeouts
[AVIOContext @ 0x2a6f200] Statistics: 10240000 bytes read, 0 seeks

This is interesting because using x265 by itself prints out a valid-looking value for global PSNR.

%system@ubuntu:~$ x265 bunny1_test_small_QCIF.y4m --psnr --log-level debug -o bunny1_QCIF_small.hevc
y4m  [info]: 176x144 fps 24/1 i420 sar 16:11 frames 0 - 268 of 269
x265 [info]: HEVC encoder version 0.9+48-9f0f011294bd
x265 [info]: build info [Linux][GCC 4.8.2][64 bit] 8bpp
x265 [warning]: Assembly not supported in this binary
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
x265 [info]: WPP streams / pool / frames         : 3 / 4 / 2
x265 [info]: Main profile, Level-2 (Main tier)
x265 [info]: CU size                             : 64
x265 [info]: Max RQT depth inter / intra         : 1 / 1
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 2
x265 [info]: Keyframe min / max / scenecut       : 24 / 250 / 40
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb / refs: 1 / 1 / 0 / 3
x265 [info]: Rate Control / AQ-Strength / CUTree : CRF-28.0 / 1.0 / 1
x265 [info]: tools: rect amp rd=3 lft sao-lcu sign-hide 
x265 [debug]: POC:0 I QP 30.67(33)        280 bits [Y: 69.71 U: 66.70 V: 66.70]
x265 [debug]: POC:4 P QP 30.78(33)        200 bits [Y: 58.42 U: 66.70 V: 65.54] [L0 0 ]
x265 [debug]: POC:2 B QP 30.67(33)        144 bits [Y: 69.71 U: 66.70 V: 66.70] [L0 0 ] [L1 4 ]
x265 [debug]: POC:1 b QP 30.67(33)        144 bits [Y: 69.71 U: 66.70 V: 66.70] [L0 0 ] [L1 2 4 ]
x265 [debug]: POC:3 b QP 30.67(33)        160 bits [Y: 68.48 U: 66.70 V: 66.70] [L0 2 0 ] [L1 4 ]
x265 [debug]: POC:7 P QP 31.33(33)        304 bits [Y: 52.89 U: 59.31 V: 55.42] [L0 4 2 0 ]
x265 [debug]: POC:6 B QP 31.33(33)        176 bits [Y: 53.39 U: 61.85 V: 55.81] [L0 4 2 0 ] [L1 7 ]
x265 [debug]: POC:5 b QP 30.89(33)        176 bits [Y: 59.29 U: 65.15 V: 60.82] [L0 4 2 ] [L1 6 7 ]
x265 [debug]: POC:8 P QP 30.78(33)        296 bits [Y: 55.98 U: 57.62 V: 54.57] [L0 7 6 4 ]
x265 [debug]: POC:10 P QP 31.00(33)        240 bits [Y: 53.07 U: 54.54 V: 51.37] [L0 8 7 6 ]
x265 [debug]: POC:9 b QP 31.00(33)        232 bits [Y: 53.57 U: 55.79 V: 52.41] [L0 8 7 6 ] [L1 10 ]
x265 [debug]: POC:12 P QP 31.00(33)        384 bits [Y: 52.31 U: 52.89 V: 54.57] [L0 10 8 7 ]
x265 [debug]: POC:11 b QP 31.22(33)        248 bits [Y: 51.76 U: 53.51 V: 54.20] [L0 10 8 6 ] [L1 12 ]
x265 [debug]: POC:13 P QP 31.22(33)        344 bits [Y: 50.97 U: 51.64 V: 54.06] [L0 12 10 8 ]
x265 [debug]: POC:14 P QP 31.22(33)        296 bits [Y: 50.82 U: 50.32 V: 51.66] [L0 13 
<---Output truncated>
x265 [debug]: POC:265 b QP 37.89(33)        152 bits [Y: 36.51 U: 38.22 V: 40.60] [L0 264 262 ] [L1 266 268 ]
x265 [debug]: POC:267 b QP 38.00(33)        160 bits [Y: 35.85 U: 37.93 V: 40.48] [L0 266 264 262 ] [L1 268 ]
x265 [info]: frame I: 2      Avg QP:29.28  kb/s: 520.80    PSNR Mean: Y:54.948 U:53.609 V:54.084
x265 [info]: frame P: 76     Avg QP:31.38  kb/s: 40.48     PSNR Mean: Y:39.390 U:42.399 V:41.899
x265 [info]: frame B: 191    Avg QP:35.64  kb/s: 4.74      PSNR Mean: Y:38.310 U:41.205 V:40.852
x265 [info]: global : 269    Avg QP:34.39  kb/s: 18.67     PSNR Mean: Y:38.739 U:41.634 V:41.246
x265 [info]: Weighted P-Frames: Y:36.8% UV:22.4%
x265 [info]: consecutive B-frames: 17.9% 5.1% 9.0% 50.0% 17.9% 

encoded 269 frames in 6.47s (41.60 fps), 18.67 kb/s, Global PSNR: 39.414

Attachments (1)

bunny1_test_small_QCIF.y4m (2.3 MB ) - added by Oche Ejembi 10 years ago.
This is a small YUV sample in QCIF resolution that can be used to reproduce the problem. My experiments and output where with a larger file.

Change History (3)

by Oche Ejembi, 10 years ago

Attachment: bunny1_test_small_QCIF.y4m added

This is a small YUV sample in QCIF resolution that can be used to reproduce the problem. My experiments and output where with a larger file.

comment:1 by Carl Eugen Hoyos, 10 years ago

Component: undeterminedavcodec
Keywords: libx265 added; x265 PSNR HEVC H265 removed
Priority: normalminor

comment:2 by Michael Niedermayer, 10 years ago

Reproduced by developer: set
Resolution: fixed
Status: newclosed

Fixed in 3956b12fdec5ec1b1358788a6000b78a724f76aa, similar to the x264 case

Note: See TracTickets for help on using tickets.