Opened 14 months ago

Closed 6 months ago

#11612 closed defect (fixed)

Vulkan HEVC decode 1st frame broken

Reported by: Andrew-R Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: vulkan, hevc
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description

Summary of the bug:
How to reproduce:

Download https://drive.google.com/file/d/1Ic9DZXMSo07EJMqCFaQRKSSrSw6y1mYv/view

Run ffmpeg like this:
RADV_PERFTEST=video_decode ~/bin/ffmpeg8-vk -hwaccel vulkan -i ~/K38_sdcard1/Documents/iPhone11_4K-recorder_59.940HDR10.mov -vframes 1 frame-vulkan.png
ffmpeg version N-118546-g903b085f91 Copyright (c) 2000-2025 the FFmpeg developers
  built with gcc 11.2.0 (GCC)
  configuration: --enable-opencl --disable-debug --enable-libx265 --enable-libx264 --enable-gpl --enable-libplacebo --enable-vulkan --enable-libshaderc --enable-libzimg --enable-libaom --enable-libdav1d --enable-libsoxr --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-libass --enable-libbluray --enable-libcdio --enable-frei0r --enable-libgsm --enable-openal --enable-libopus --enable-librtmp --enable-libsnappy --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp
  libavutil      60.  3.100 / 60.  3.100
  libavcodec     62.  3.101 / 62.  3.101
  libavformat    62.  0.102 / 62.  0.102
  libavdevice    62.  0.100 / 62.  0.100
  libavfilter    11.  0.100 / 11.  0.100
  libswscale      9.  0.100 /  9.  0.100
  libswresample   6.  0.100 /  6.  0.100
[aist#0:1/pcm_s16le @ 0xba830c0] Guessed Channel Layout: stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/guest/K38_sdcard1/Documents/iPhone11_4K-recorder_59.940HDR10.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    creation_time   : 2020-12-18T22:20:29.000000Z
    com.apple.quicktime.creationdate: 2020-12-18T17:20:29-0500
    com.apple.quicktime.location.ISO6709: +33.4233-084.5802/
  Duration: 00:00:19.16, start: 0.000000, bitrate: 69140 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(pc, bt2020nc/bt2020/smpte2084), 3840x2160, 64166 kb/s, 59.92 fps, 59.94 tbr, 600 tbn (default)
    Metadata:
      creation_time   : 2020-12-18T22:20:29.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
      encoder         : HEVC
  Stream #0:1[0x2](und): Audio: pcm_s16le (lpcm / 0x6D63706C), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2020-12-18T22:20:29.000000Z
      handler_name    : Core Media Audio
      vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (hevc (native) -> png (native))
Press [q] to stop, [?] for help
Output #0, image2, to 'frame-vulkan.png':
  Metadata:
    major_brand     : qt
    minor_version   : 0
    compatible_brands: qt
    com.apple.quicktime.location.ISO6709: +33.4233-084.5802/
    com.apple.quicktime.creationdate: 2020-12-18T17:20:29-0500
    encoder         : Lavf62.0.102
  Stream #0:0(und): Video: png, rgb48be(pc, gbr/bt2020/smpte2084, progressive), 3840x2160, q=2-31, 200 kb/s, 59.94 fps, 59.94 tbn (default)
    Metadata:
      encoder         : Lavc62.3.101 png
      creation_time   : 2020-12-18T22:20:29.000000Z
      handler_name    : Core Media Video
      vendor_id       : [0][0][0][0]
[image2 @ 0xba825c0] The specified filename 'frame-vulkan.png' does not contain an image sequence pattern or a pattern is invalid.
[image2 @ 0xba825c0] Use a pattern such as %03d for an image sequence or use the -update option (with -frames:v 1 if needed) to write a single image.
[out#0/image2 @ 0xba672c0] video:14788KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown
frame=    1 fps=0.2 q=-0.0 Lsize=N/A time=00:00:00.01 bitrate=N/A speed=0.00299x elapsed=0:00:05.57

Observe that frame-vulkan.png broken relative to software decoding.

Problem also exist in ffmpeg 7.1.1

Attachments (1)

vulkaninfo.log (136.8 KB ) - added by Andrew-R 14 months ago.
vulkaninfo

Download all attachments as: .zip

Change History (10)

comment:1 by Lynne, 14 months ago

Analyzed by developer: set

Works fine across all systems I have access to (7900, 6900, Alder Lake, 6000 Ada).
Recheck, with updated Mesa and firmware?
Also, what are you seeing?

in reply to:  1 comment:2 by Andrew-R, 14 months ago

Replying to Lynne:

Works fine across all systems I have access to (7900, 6900, Alder Lake, 6000 Ada).
Recheck, with updated Mesa and firmware?
Also, what are you seeing?

Some grey squares .. (even after pngquant image still bigger than 2.5 mb limit)

Hw RX550
will attach vulkaninfo

by Andrew-R, 14 months ago

Attachment: vulkaninfo.log added

vulkaninfo

comment:3 by Lynne, 14 months ago

Resolution: invalid
Status: newclosed

Likely a Mesa issue, in that case. You should report it to Mesa.

comment:4 by Andrew-R, 14 months ago

https://paste.pics/8b3abd754f5457755fb34305a7e4e6e1

If it mesa issue why I can't see it with ffmpeg 7.0 as used by cingg ?

comment:5 by Andrew-R, 14 months ago

It works with unmodified ffmpeg 7.0

comment:6 by Andrew-R, 14 months ago

git bisect result in:

631a7256705eb5ca424133b612cea9e4c0154ab8 is the first bad commit
commit 631a7256705eb5ca424133b612cea9e4c0154ab8 (HEAD)
Author: Anton Khirnov <anton@khirnov.net>
Date:   Thu Jun 13 14:03:16 2024 +0200

    lavc/hevcdec: call ff_thread_finish_setup() even if hwaccel is in use

    Serializing frame threading for non-threadsafe hwaccels is handled at the
    generic level, the decoder does not need to care about it.

 libavcodec/hevc/hevcdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
bash-5.1$ git bisect log
git bisect start
# status: waiting for both good and bad commits
# good: [6b213175c90534e0ad1924bfeba2cf7e20db5bf2] Bump after 7.0 branch point
git bisect good 6b213175c90534e0ad1924bfeba2cf7e20db5bf2
# status: waiting for bad commit, 1 good commit known
# bad: [38e224c2ba0958d84453f81548d9b245eecd82a1] */version.h: bump after release/7.1 branch
git bisect bad 38e224c2ba0958d84453f81548d9b245eecd82a1
# skip: [d72a5fe719c01da07af30e4402a7c3cd994b4cfc] lavc/vvc: Prevent overflow in chroma QP derivation
git bisect skip d72a5fe719c01da07af30e4402a7c3cd994b4cfc
# bad: [d5188adba82eaf979acf98fe2642de5c84a91fcb] lavc/hevcdec: move HEVCContext.tab_slice_address to HEVCLayerContext
git bisect bad d5188adba82eaf979acf98fe2642de5c84a91fcb
# good: [6ddba110eb1dcb7c05368f85759a70a5645ca4ca] lavc/hevc/parser: stop using HEVCParamSets.[psv]ps
git bisect good 6ddba110eb1dcb7c05368f85759a70a5645ca4ca
# good: [25f9211bdd61641cb8739efcb45bf31b46557178] avdevice/dshow: Cleanup also on av_log case
git bisect good 25f9211bdd61641cb8739efcb45bf31b46557178
# good: [9229587c2df92b24b3ed1f4f5dd9830e8d1d6992] avfilter/vf_unsharp_opencl: Use AV_VIDEO_MAX_PLANES
git bisect good 9229587c2df92b24b3ed1f4f5dd9830e8d1d6992
# bad: [d8fb44c0aa2f7bc566f937330067be6f2ab83c67] lavc/mpegvideoencdsp: R-V V add_8x8basis
git bisect bad d8fb44c0aa2f7bc566f937330067be6f2ab83c67
# good: [426e33c75853c395b39e216e7ecde0103ff48086] lavfi: set AVFilterLink.graph on link creation
git bisect good 426e33c75853c395b39e216e7ecde0103ff48086
# good: [1917270d32e386e8a1623a760baf1bc436aef2a3] avcodec/dovi_rpuenc: add ff_dovi_configure_ext()
git bisect good 1917270d32e386e8a1623a760baf1bc436aef2a3
# good: [8744764a4cab5153e14512af702f217a827344ac] swscale/x86/yuv2rgb: add ssse3 yuv42{0,2}p -> gbrp unscaled colorspace converters
git bisect good 8744764a4cab5153e14512af702f217a827344ac
# good: [2fdecbb239714b6203e37067fda2521f80e19d47] lavc/hevcdec: switch to receive_frame()
git bisect good 2fdecbb239714b6203e37067fda2521f80e19d47
# good: [4b9adb35b609b7acb591be0459cde07550fd4ebe] lavc/hevcdec: simplify output logic
git bisect good 4b9adb35b609b7acb591be0459cde07550fd4ebe
# bad: [0fd37c00d728becba6c49aff9efaf7cae17d46d7] lavc/mpegvideoencdsp: R-V V pix_norm1
git bisect bad 0fd37c00d728becba6c49aff9efaf7cae17d46d7
# bad: [631a7256705eb5ca424133b612cea9e4c0154ab8] lavc/hevcdec: call ff_thread_finish_setup() even if hwaccel is in use
git bisect bad 631a7256705eb5ca424133b612cea9e4c0154ab8
# first bad commit: [631a7256705eb5ca424133b612cea9e4c0154ab8] lavc/hevcdec: call ff_thread_finish_setup() even if hwaccel is in use

comment:7 by Andrew-R, 14 months ago

Resolution: invalid
Status: closedreopened

comment:8 by Andrew-R, 8 months ago

I think this one is fixed in ffmpeg 8.0 (just retested). But may be mesa/radv version also played a role (using mesa git snapshot from 8 aug 2025).

comment:9 by Balling, 6 months ago

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.