H.265 decode error

I have trouble executing HEVC hardware decoding while H264 hardware decoding is working fine following the instructions found here:
https://docs.khadas.com/vim3/HowToUseHardwareDecodingLibrary.html

To be honest the provided example did not report any case with HEVC decoding, just only H.264 and MPEG4.
Following the example found on the master branch it has been easy to support even the HEVC decoding:

vpcodec->has_video = 1;
if (_codec == “h264”) {
spdlog::get(_name)->info(“Video codec H.264”);
vpcodec->video_type = VFORMAT_H264;
vpcodec->am_sysinfo.format = VIDEO_DEC_FORMAT_H264;
vpcodec->am_sysinfo.param = (void *)(EXTERNAL_PTS | SYNC_OUTSIDE);
} else if (_codec == “h265”) {
spdlog::get(_name)->info(“Video codec H.265”);
vpcodec->video_type = VFORMAT_HEVC;
vpcodec->am_sysinfo.format = VIDEO_DEC_FORMAT_HEVC;
vpcodec->am_sysinfo.param = (void *) (EXTERNAL_PTS | SYNC_OUTSIDE);
} else {
spdlog::get(_name)->critical(“Codec not available: {}”, _codec);
return;
}
vpcodec->stream_type = STREAM_TYPE_ES_VIDEO;
vpcodec->am_sysinfo.rate = 96000 / _fps;
vpcodec->am_sysinfo.height = _h;
vpcodec->am_sysinfo.width = _w;
vpcodec->has_audio = 0;
vpcodec->noblock = 0;

I noticed that sometimes the HEVC decoding attempt blocks the whole cpu, while sometimes returns just vertical lines.
I’ve set the output format to V4L2_PIX_FMT_BGR24, and the stream resolution is 1080p.

So I doubt HEVC is currenlty completely supported by the library.
Is it true?

1 Like

Still having issues about h.265 decoding on a recently update system:
Linux Khadas 4.9.241 #3 SMP PREEMPT Fri Apr 30 09:07:25 CST 2021 aarch64 aarch64 aarch64 GNU/Linux

Attached a decoded frame that shows just vertical lines:

dmesg log reports errors (set error_mark):

[  134.748510] vfm_map_store:rm default
[  134.748584] vfm_map_store:add default decoder ionvideo
[  134.764452] ionvid: dbg: ionvideo open
[  134.764470] ionvid: dbg: ionvideo: set freerun mode
[  135.784369] the demux           clock on, ref cnt: 1
[  135.784377] the parser_top      clock on, ref cnt: 1
[  135.784382] the vdec            clock on, ref cnt: 1
[  135.784403] the clk_hevc_mux    clock on, ref cnt: 1
[  135.784409] the clk_hevcb_mux   clock on, ref cnt: 1
[  135.784494] hevc mux clock is 499999992 Hz
[  135.784528] hevc back mux clock is 499999992 Hz
[  135.784590] vdec_create instance ffffff8012c00000, total 1
[  135.784992] no drmmode
[  135.785044] The fw has been loaded.
[  135.790263] HEVC stbuf alloced at 00000000593c0000, secure = 0, size = 10485760
[  135.790288] vdec_init, dev_name:amvdec_h265, vdec_type=VDEC_TYPE_SINGLE
[  135.790292] vdec_init set vfm decoder ffffff8012c00000
[  135.792611] decoder_bmmu_box_alloc_box, tvp_flags = 0
[  135.801995] [0]h265:pts_unstable=0
[  135.802002] [0]h265: ver (201602101,0) decinfo: 1920x1080 rate=3840
[  135.802726] [LOCAL], the fw (hevc_mmu) will be loaded.
[  135.803039] reg:ionvideo
[  135.804859] hevc mux clock is 799999987 Hz
[  135.804880] hevc back mux clock is 799999987 Hz
[  135.804883] hevc video changed to 3840 x 2160 60 fps clk->800MHZ
[  135.804904] vdec_init, vf_provider_name = 
[  135.805102] video first pts = 0
[  135.805105] vdec_request_irq ffffff80027a3f98, parser
[  135.850643] [0]set pic_list_init_flag 1
[  135.852607] [0]init_decode_head_hw: (1920, 1080) body_size 0x31ce00 header_size 0x1fe0
[  135.852614] [0]init_buf_spec2 1920 1080
[  135.852618] [0]set pic_list_init_flag to 2
[  135.852675] [0]set pic_list_init_flag to 3
[  135.873096] [0]VH265: output first frame
[  136.894987] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  136.933885] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  136.933932] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  136.933975] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  136.934018] [0]cur lcu idx = 2039, (total 2040), set error_mark
...
[  140.205862] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  140.205904] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  140.205945] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  140.205987] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  140.206028] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  140.206069] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  140.206110] [0]cur lcu idx = 2039, (total 2040), set error_mark
[  143.020051] unreg:ionvideo
[  143.020603] [0]uninit list
[  143.032214] hevc mux clock is 799999987 Hz
[  143.032225] hevc back mux clock is 799999987 Hz
[  143.032228] hevc video changed to 0 x 0 0 fps clk->800MHZ
[  143.032278] vdec_release instance ffffff8012c00000, total 1
[  143.032352] the clk_hevc_mux    clock off, ref cnt: 0
[  143.032354] the clk_hevcb_mux   clock off, ref cnt: 0
[  143.032368] the clk_vdec_mux    clock off, ref cnt: -1
[  143.032373] the vdec            clock off, ref cnt: 0
[  143.032376] the parser_top      clock off, ref cnt: 0
[  143.032379] the demux           clock off, ref cnt: 0
[  143.044090] ionvid: dbg: vidioc_close!!!!
[  143.044099] ionvid: dbg: vidioc_close

I really don’t know the reason of the switch from:

h265: ver (201602101,0) decinfo: 1920x1080 rate=3840

to:

hevc video changed to 3840 x 2160 60 fps clk->800MHZ

Yes, it is a known issue for H265 format, we will check this issue.

1 Like

Ok, I wasn’t aware of that.
Thank you

Hello @fguerzoni

Please check the latest code, it works on my side for H265.

2 Likes

Yes, I confirm it works fine.
Thank you for the support.
Regards

1 Like

Can the hardware playback be compiled into 5.10 - 5.12 etc kernels?

I have almost no video the cpu cannot playback, but i have some 4k that would benefit.

Thanks for the pioneering numbqq. You are a hero.