Opened 18 months ago
Closed 8 months ago
#11551 closed defect (fixed)
[HEVC] Incorrect PCM coding block length derivation for YUV400
| Reported by: | ksthey | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avcodec |
| Version: | git-master | Keywords: | hevc |
| Cc: | ksthey, MasterQuestionable | Blocked By: | |
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | yes |
Description
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);
=============================================================================
Change History (4)
comment:1 by , 18 months ago
| Analyzed by developer: | set |
|---|---|
| Cc: | added |
| Component: | ffmpeg → avcodec |
| Keywords: | hevc added; Hevc removed |
| Summary: | [HEVC] Incorrect PCM Coding Block Length Derivation For YUV400 → [HEVC] Incorrect PCM coding block length derivation for YUV400 |
comment:3 by , 17 months ago
͏ Unfamiliar with the committing procedure.
͏ [ As mentioned: https://trac.ffmpeg.org/ticket/11190#comment:6 ]
͏ Please eligible reviewers review and submit?
comment:4 by , 8 months ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |



͏ In "libavcodec/hevc/hevcdec.c", function "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.
͏ https://github.com/FFmpeg/FFmpeg/blob/0ce8868878c90153e45648b180cef59a9bcb0109/libavcodec/hevc/hevcdec.c#L1668-L1671
͏ Modify the code as below does solve the problem:
[[
libavcodec/hevc/hevcdec.c
]]