haasn / libplacebo

Official mirror of libplacebo
http://libplacebo.org/
GNU Lesser General Public License v2.1
560 stars 70 forks source link

HDR Video render problem #160

Closed CharlesMengCA closed 1 year ago

CharlesMengCA commented 1 year ago

Hi Haasn,

Maybe related to the commits today (March 06). Following video is rendered incorrectly in MPV. A build from yesterday is fine.

https://4kmedia.org/sony-whale-in-tonga-hdr-uhd-4k-demo/

Regards,

haasn commented 1 year ago

File has completely broken static mastering metadata. In the last refactor I inadvertently removed some safety clamps that prevented these broken values from being used.

CharlesMengCA commented 1 year ago

When playing above video, at the beginning, it has a yellow screen flashed, and then everything is normal.

Could you take a look?

[cplayer] Command line options: 'd:\Test Videos\Sony-Whale-in-Tonga-HDR-UHD.mp4' '-v'
[cplayer] mpv 0.35.1-315-g855b619c Copyright © 2000-2023 mpv/MPlayer/mplayer2 projects
[cplayer]  built on 2023-03-07 11:23 AM
[cplayer] libplacebo version: v5.261.0
[cplayer] FFmpeg version: git-2023-03-06-e50a02b0f
[cplayer] FFmpeg library versions:
[cplayer]    libavutil       58.3.100
[cplayer]    libavcodec      60.6.100
[cplayer]    libavformat     60.4.100
[cplayer]    libswscale      7.2.100
[cplayer]    libavfilter     9.4.100
[cplayer]    libswresample   4.11.100
[cplayer] 
[cplayer] Configuration: meson build
[cplayer] List of enabled features: av-channel-layout build-date cuda-hwaccel cuda-interop d3d-hwaccel d3d11 d3d9-hwaccel direct3d dos-paths dvdnav ffmpeg ffnvcodec glob glob-win32 gpl iconv jpeg jpegxl lcms2 libarchive libass libavdevice libbluray libm libplacebo libplacebo-next luajit noexecstack shaderc spirv-cross stdatomic threads uchardet vector vk_khr_display vulkan wasapi zimg zlib
[cplayer] Built with NDEBUG.
[cplayer] Reading config file F:/LinuxFolder/Mod/portable_config/mpv.conf
[cplayer] Applying profile 'default'...
[cplayer] Setting option 'loop-playlist' = '' (flags = 4)
[cplayer] Setting option 'vo' = 'gpu-next' (flags = 4)
[cplayer] Setting option 'hwdec' = 'auto' (flags = 4)
[cplayer] Setting option 'gpu-api' = 'vulkan' (flags = 4)
[cplayer] Setting option 'script-opts' = 'ytdl_hook-ytdl_path=D:\Tools\yt-dlp\yt-dlp' (flags = 4)
[cplayer] Setting option 'v' = '' (flags = 8)
[ifo_dvdnav] Opening F:/LinuxFolder/Mod/portable_config/input.conf
[bdmv/bluray] Opening F:/LinuxFolder/Mod/portable_config/input.conf
[file] Opening F:/LinuxFolder/Mod/portable_config/input.conf
[input] Parsing input config file F:/LinuxFolder/Mod/portable_config/input.conf
[input] Input config file F:/LinuxFolder/Mod/portable_config/input.conf parsed: 23 binds
[cplayer] Waiting for scripts...
[osd/libass] libass API version: 0x1701000
[osd/libass] libass source: commit: 0.17.0-40-g218dace
[osd/libass] Shaper: FriBidi 1.0.12 (SIMPLE) HarfBuzz-ng 7.1.0 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider directwrite (with GDI)
[osd/libass] Done.
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Set property: user-data/osc/visibility="auto" -> 1
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Done loading scripts.
[cplayer] Running hook: ytdl_hook/on_load
[ytdl_hook] ytdl:// hook 
[ytdl_hook] not a ytdl:// url 
[cplayer] Set property: shared-script-properties -> 1
[ifo_dvdnav] Opening d:\Test Videos\Sony-Whale-in-Tonga-HDR-UHD.mp4
[bdmv/bluray] Opening d:\Test Videos\Sony-Whale-in-Tonga-HDR-UHD.mp4
[file] Opening d:\Test Videos\Sony-Whale-in-Tonga-HDR-UHD.mp4
[demux] Trying demuxers for level=normal.
[cplayer] Set property: shared-script-properties -> 1
[osd/libass] libass API version: 0x1701000
[osd/libass] libass source: commit: 0.17.0-40-g218dace
[osd/libass] Shaper: FriBidi 1.0.12 (SIMPLE) HarfBuzz-ng 7.1.0 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider directwrite (with GDI)
[osd/libass] Done.
[lavf] Found 'mov,mp4,m4a,3gp,3g2,mj2' at score=100 size=2048.
[demux] Detected file format: mov,mp4,m4a,3gp,3g2,mj2 (libavformat)
[cplayer] Opening done: d:\Test Videos\Sony-Whale-in-Tonga-HDR-UHD.mp4
[find_files] Loading external files in d:\Test Videos\
[cplayer] Running hook: ytdl_hook/on_preloaded
[lavf] select track 0
[lavf] select track 1
[cplayer]  (+) Video --vid=1 (*) (hevc 3840x2160 59.940fps)
[cplayer]  (+) Audio --aid=1 --alang=eng (*) (aac 2ch 48000Hz)
[vo/gpu-next] Probing for best GPU context.
[vo/gpu-next/vulkan] Initializing GPU context 'winvk'
[vo/gpu-next/libplacebo] Initialized libplacebo v5.261.0 (API v261)
[vo/gpu-next/libplacebo] Creating vulkan instance with extensions:
[vo/gpu-next/libplacebo]     VK_KHR_get_physical_device_properties2
[vo/gpu-next/libplacebo]     VK_KHR_surface
[vo/gpu-next/libplacebo]     VK_EXT_swapchain_colorspace
[vo/gpu-next/libplacebo]     VK_KHR_external_memory_capabilities
[vo/gpu-next/libplacebo]     VK_KHR_external_semaphore_capabilities
[vo/gpu-next/libplacebo]     VK_KHR_get_surface_capabilities2
[vo/gpu-next/libplacebo]     VK_KHR_portability_enumeration
[vo/gpu-next/libplacebo]     VK_KHR_surface
[vo/gpu-next/libplacebo]     VK_KHR_win32_surface
[vo/gpu-next/libplacebo] Probing for vulkan devices:
[vo/gpu-next/libplacebo]     GPU 0: NVIDIA GeForce GTX 1650 SUPER (discrete)
[vo/gpu-next/libplacebo]            uuid: 30:86:8B:3D:F5:51:F3:6F:0C:5E:9E:A6:24:47:A7:26
[vo/gpu-next/libplacebo]     GPU 1: Intel(R) UHD Graphics 630 (integrated)
[vo/gpu-next/libplacebo]            uuid: 86:80:C5:9B:05:00:00:00:00:00:00:00:00:00:00:00
[vo/gpu-next/libplacebo] Vulkan device properties:
[vo/gpu-next/libplacebo]     Device Name: NVIDIA GeForce GTX 1650 SUPER
[vo/gpu-next/libplacebo]     Device ID: 10de:2187
[vo/gpu-next/libplacebo]     Device UUID: 30:86:8B:3D:F5:51:F3:6F:0C:5E:9E:A6:24:47:A7:26
[vo/gpu-next/libplacebo]     Driver version: 84c48000
[vo/gpu-next/libplacebo]     API version: 1.3.236
[vo/gpu-next/libplacebo] Using async transfer (queue 1)
[vo/gpu-next/libplacebo] Using async compute (queue 2)
[vo/gpu-next/libplacebo] Creating vulkan device with extensions:
[vo/gpu-next/libplacebo]     VK_KHR_swapchain
[vo/gpu-next/libplacebo]     VK_KHR_swapchain
[vo/gpu-next/libplacebo]     VK_KHR_push_descriptor
[vo/gpu-next/libplacebo]     VK_KHR_external_memory_win32
[vo/gpu-next/libplacebo]     VK_EXT_external_memory_host
[vo/gpu-next/libplacebo]     VK_KHR_external_semaphore_win32
[vo/gpu-next/libplacebo]     VK_EXT_pci_bus_info
[vo/gpu-next/libplacebo]     VK_EXT_hdr_metadata
[vo/gpu-next/libplacebo]     VK_EXT_full_screen_exclusive
[vo/gpu-next/libplacebo] Memory heaps supported by device:
[vo/gpu-next/libplacebo]     0: flags 0x1 size 3943M
[vo/gpu-next/libplacebo]     1: flags 0x0 size 8067M
[vo/gpu-next/libplacebo]     2: flags 0x1 size  214M
[vo/gpu-next/libplacebo] Memory summary:     0 used     0 res     0 alloc, efficiency 100.00%, utilization 100.00%
[vo/gpu-next/libplacebo] shaderc SPIR-V version 1.6 rev 1
[vo/gpu-next/libplacebo] Initialized SPIR-V compiler 'shaderc'
[vo/gpu-next/libplacebo] GPU information:
[vo/gpu-next/libplacebo]     GLSL version: 450 (vulkan)
[vo/gpu-next/libplacebo]       max_shmem_size:            49152
[vo/gpu-next/libplacebo]       max_group_threads:         1024
[vo/gpu-next/libplacebo]       max_group_size[0]:         1024
[vo/gpu-next/libplacebo]       max_group_size[1]:         1024
[vo/gpu-next/libplacebo]       max_group_size[2]:         64
[vo/gpu-next/libplacebo]       subgroup_size:             32
[vo/gpu-next/libplacebo]       min_gather_offset:         -32
[vo/gpu-next/libplacebo]       max_gather_offset:         31
[vo/gpu-next/libplacebo]     Limits:
[vo/gpu-next/libplacebo]       thread_safe:               1
[vo/gpu-next/libplacebo]       callbacks:                 1
[vo/gpu-next/libplacebo]       max_buf_size:              8459100160
[vo/gpu-next/libplacebo]       max_ubo_size:              65536
[vo/gpu-next/libplacebo]       max_ssbo_size:             4294967295
[vo/gpu-next/libplacebo]       max_vbo_size:              4134535168
[vo/gpu-next/libplacebo]       max_mapped_size:           8459100160
[vo/gpu-next/libplacebo]       max_buffer_texels:         134217728
[vo/gpu-next/libplacebo]       align_host_ptr:            4096
[vo/gpu-next/libplacebo]       host_cached:               1
[vo/gpu-next/libplacebo]       max_tex_1d_dim:            32768
[vo/gpu-next/libplacebo]       max_tex_2d_dim:            32768
[vo/gpu-next/libplacebo]       max_tex_3d_dim:            16384
[vo/gpu-next/libplacebo]       blittable_1d_3d:           1
[vo/gpu-next/libplacebo]       buf_transfer:              1
[vo/gpu-next/libplacebo]       align_tex_xfer_pitch:      1
[vo/gpu-next/libplacebo]       align_tex_xfer_offset:     4
[vo/gpu-next/libplacebo]       max_variable_comps:        0
[vo/gpu-next/libplacebo]       max_constants:             18446744073709551615
[vo/gpu-next/libplacebo]       max_pushc_size:            256
[vo/gpu-next/libplacebo]       align_vertex_stride:       1
[vo/gpu-next/libplacebo]       max_dispatch[0]:           2147483647
[vo/gpu-next/libplacebo]       max_dispatch[1]:           65535
[vo/gpu-next/libplacebo]       max_dispatch[2]:           65535
[vo/gpu-next/libplacebo]       fragment_queues:           1
[vo/gpu-next/libplacebo]       compute_queues:            1
[vo/gpu-next/libplacebo]     External API interop:
[vo/gpu-next/libplacebo]       UUID: 30:86:8B:3D:F5:51:F3:6F:0C:5E:9E:A6:24:47:A7:26
[vo/gpu-next/libplacebo]       PCI: 0000:01:00:0
[vo/gpu-next/libplacebo]       buf export caps: 0x16
[vo/gpu-next/libplacebo]       buf import caps: 0x16
[vo/gpu-next/libplacebo]       tex export caps: 0x16
[vo/gpu-next/libplacebo]       tex import caps: 0x16
[vo/gpu-next/libplacebo]       sync export caps: 0x6
[vo/gpu-next/libplacebo]       sync import caps: 0x0
[vo/gpu-next/libplacebo] Available surface configurations:
[vo/gpu-next/libplacebo]     0: VK_FORMAT_B8G8R8A8_UNORM                 VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
[vo/gpu-next/libplacebo]     1: VK_FORMAT_B8G8R8A8_SRGB                  VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
[vo/gpu-next/libplacebo]     2: VK_FORMAT_A2B10G10R10_UNORM_PACK32       VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
[vo/gpu-next/libplacebo] Picked surface configuration 2: VK_FORMAT_A2B10G10R10_UNORM_PACK32 + VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
[vo/gpu-next/win32] DPI detected from the new API: 96
[vo/gpu-next/win32] display-fps: 74.971000
[vo/gpu-next/win32] color-profile: C:\Windows\system32\spool\drivers\color\S2721DS.icm
[vo/gpu-next] Assuming 74.971000 FPS for display sync.
[vd] Container reported FPS: 59.940060
[vd] Codec list:
[vd]     hevc - HEVC (High Efficiency Video Coding)
[vd]     hevc_qsv (hevc) - HEVC video (Intel Quick Sync Video acceleration)
[vd]     hevc_cuvid (hevc) - Nvidia CUVID HEVC decoder
[vd] Opening decoder hevc
[vd] Looking at hwdec hevc-d3d11va...
[vo/gpu-next] Loading hwdec drivers for format: 'd3d11'
[vo/gpu-next] Loading hwdec driver 'd3d11va'
[vo/gpu-next] Loading failed.
[vd] Could not create device.
[vd] Looking at hwdec hevc-dxva2...
[vo/gpu-next] Loading hwdec drivers for format: 'dxva2_vld'
[vo/gpu-next] Loading hwdec driver 'dxva2-dxgi'
[vo/gpu-next] Loading failed.
[vd] Could not create device.
[vd] Looking at hwdec hevc-nvdec...
[vo/gpu-next] Loading hwdec drivers for format: 'cuda'
[vo/gpu-next] Loading hwdec driver 'cuda'
[vd] Trying hardware decoding via hevc-nvdec.
[vd] Selected codec: hevc (HEVC (High Efficiency Video Coding))
[vf] User filter list:
[vf]   (empty)
[ad] Codec list:
[ad]     aac - AAC (Advanced Audio Coding)
[ad]     aac_fixed (aac) - AAC (Advanced Audio Coding)
[ad] Opening decoder aac
[ad] Requesting 1 threads for decoding.
[ad] Selected codec: aac (AAC (Advanced Audio Coding))
[af] User filter list:
[af]   (empty)
[cplayer] Starting playback...
[af] [in] 48000Hz stereo 2ch floatp
[af] [userspeed] 48000Hz stereo 2ch floatp
[af] [userspeed] (disabled)
[af] [convert] 48000Hz stereo 2ch floatp
[vd] Pixel formats supported by decoder: dxva2_vld d3d11va_vld d3d11 cuda yuv420p10le
[vd] Codec profile: Main 10 (0x2)
[vd] Requesting pixfmt 'cuda' from decoder.
[vd] Using hardware decoding (nvdec).
[vd] Decoder format: 3840x2160 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/auto SP=0.002463 CL=uhd
[vd] Invalid HDR peak in stream: 0.002463
[vf] [in] 3840x2160 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=49.261086 CL=uhd
[vf] [userdeint] 3840x2160 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=49.261086 CL=uhd
[vf] [userdeint] (disabled)
[vf] [autorotate] 3840x2160 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=49.261086 CL=uhd
[vf] [autorotate] (disabled)
[vf] [convert] 3840x2160 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=49.261086 CL=uhd
[vf] [convert] (disabled)
[vf] [out] 3840x2160 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=49.261086 CL=uhd
[ao] Trying audio driver 'wasapi'
[ao/wasapi] requested format: 48000 Hz, stereo channels, floatp
[ao/wasapi] No device specified. Selecting default.
[ao/wasapi] Selecting device '{01d1a280-dccc-4391-ba46-6e03eda072d1}' (Speakers (Sony MDR-1ADAC))
[ao/wasapi] Monitoring changes in device {0.0.0.00000000}.{01d1a280-dccc-4391-ba46-6e03eda072d1}
[ao/wasapi] Trying stereo float (32/32 bits) @ 48000hz (shared) -> ok
[ao/wasapi] Accepted as stereo float @ 48000hz -> stereo float (32/32 bits) @ 48000hz (shared)
[ao/wasapi] Device period: 10 ms
[ao/wasapi] Buffer frame count: 2400 (50 ms)
[ao/wasapi] IAudioClock::GetFrequency gave a frequency of 384000.
[ao/wasapi] device buffer: 2400 samples.
[ao/wasapi] using soft-buffer of 9600 samples.
[cplayer] AO: [wasapi] 48000Hz stereo 2ch float
[cplayer] AO: Description: Windows WASAPI audio output (event mode)
[autoconvert] inserting resampler
[swresample] format change, reinitializing resampler
[swresample] 48000Hz stereo floatp -> 48000Hz stereo float
[af] [out] 48000Hz stereo 2ch float
[cplayer] VO: [gpu-next] 3840x2160 cuda[p010]
[cplayer] VO: Description: Video output based on libplacebo
[vo/gpu-next] reconfig to 3840x2160 cuda[p010] bt.2020-ncl/bt.2020/pq/limited/display SP=49.261086 CL=uhd
[vo/gpu-next/win32] reset window bounds: -609:-348:3840:2160
[vo/gpu-next/win32] adjusted window bounds: 70:34:2482:1396
[vo/gpu-next/win32] resize window: 2482:1396
[vo/gpu-next/win32] resize window: 2482:1396
[vo/gpu-next] Window size: 2482x1396 (Borders: l=0 t=0 r=0 b=0)
[vo/gpu-next] Video source: 3840x2160 (1:1)
[vo/gpu-next] Video display: (0, 0) 3840x2160 -> (0, 0) 2481x1396
[vo/gpu-next] Video scale: 0.646094/0.646296
[vo/gpu-next] OSD borders: l=0 t=0 r=1 b=0
[vo/gpu-next] Video borders: l=0 t=0 r=1 b=0
[vo/gpu-next] Window size: 2482x1396 (Borders: l=0 t=0 r=0 b=0)
[vo/gpu-next] Video source: 3840x2160 (1:1)
[vo/gpu-next] Video display: (0, 0) 3840x2160 -> (0, 0) 2481x1396
[vo/gpu-next] Video scale: 0.646094/0.646296
[vo/gpu-next] OSD borders: l=0 t=0 r=1 b=0
[vo/gpu-next] Video borders: l=0 t=0 r=1 b=0
[vo/gpu-next/libplacebo] Spent 78.000 ms translating SPIR-V
[cplayer] first video frame after restart shown
[cplayer] audio ready
[cplayer] delaying audio start 0.000000 vs. 0.000000, diff=0.000000
[cplayer] playback restart complete @ 0.000000, audio=ready, video=playing
[cplayer] starting audio playback
[vo/gpu-next/libplacebo] Detected fps ratio 0.0000 below threshold 0.0100, disabling interpolation
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Set property: shared-script-properties -> 1
[osd/libass] fontselect: (sans-serif, 400, 0) -> ArialMT, 0, ArialMT
[osd/libass] fontselect: (mpv-osd-symbols, 400, 0) -> mpv-osd-symbols-Regular, 0, mpv-osd-symbols-Regular
[vo/gpu-next/libplacebo] Estimated source FPS: 59.940, display FPS: 59.940
[vo/gpu-next/libplacebo] Spent 17.000 ms translating SPIR-V
[vo/gpu-next/libplacebo] Spent 16.000 ms translating SPIR-V
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Set property: shared-script-properties -> 1
[cplayer] EOF code: 5  
[cplayer] finished playback, success (reason 3)
[cplayer] 
[cplayer] Exiting... (Quit)
[cplayer] Set property: shared-script-properties -> 1
[vo/gpu-next/win32] uninit
haasn commented 1 year ago

Should be fixed now