[FFmpeg-trac] #11551(ffmpeg:new): [HEVC] Incorrect PCM Coding Block Length Derivation For YUV400
FFmpeg
trac at avcodec.org
Tue Apr 22 06:17:36 EEST 2025
#11551: [HEVC] Incorrect PCM Coding Block Length Derivation For YUV400
--------------------------------+--------------------------------------
Reporter: ksthey | Type: defect
Status: new | Priority: normal
Component: ffmpeg | Version: git-master
Keywords: Hevc | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
--------------------------------+--------------------------------------
In hevcdec.c, hls_pcm_sample(), the derivation of length below doesn't
consider the case of YUV400 (chroma_format_idc == 0), which results in
incorrect byte skipped and parsing errors for later blocks, when YUV400
PCM blocks appear.
=============================================================================
int length = cb_size * cb_size * sps->pcm.bit_depth +
(((cb_size >> sps->hshift[1]) * (cb_size >>
sps->vshift[1])) +
((cb_size >> sps->hshift[2]) * (cb_size >>
sps->vshift[2]))) *
sps->pcm.bit_depth_chroma;
=============================================================================
Modify the code as below does solve the problem:
=============================================================================
int length = cb_size * cb_size * sps->pcm.bit_depth +
((sps->chroma_format_idc != 0) ?
((((cb_size >> sps->hshift[1]) * (cb_size >>
sps->vshift[1])) +
((cb_size >> sps->hshift[2]) * (cb_size >>
sps->vshift[2]))) *
sps->pcm.bit_depth_chroma) : 0);
=============================================================================
--
Ticket URL: <https://trac.ffmpeg.org/ticket/11551>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list