diff mbox series

[FFmpeg-devel] avcodec/hevc: compatible with mixed use of annexb and hvcc on bitstream like h264dec

Message ID CACGufqTitfAsF7Kat-geC-x5R-_gXXVoCc0iQtGy=kqHd-aogg@mail.gmail.com
State New
Headers show
Series [FFmpeg-devel] avcodec/hevc: compatible with mixed use of annexb and hvcc on bitstream like h264dec | expand

Checks

Context Check Description
andriy/configure_x86 warning Failed to apply patch

Commit Message

Li Kai July 12, 2024, 2:49 a.m. UTC
Hi:

    I found it's different actions with h264 and hevc when decoded. I try
to make it same as blow.

But I have no idea about the code:


*libavcode/h264dec.c:609 *

*AV_RB32(buf+5) > (unsigned)buf_size*

I tried to find the answer in specs, but I failed. So I am not sure that it
is valid in hevc.


From: Li Kai <wolfleekay@gmail.com>
Date: Fri, 12 Jul 2024 10:21:17 +0800
Subject: [PATCH] avcodec/hevc: compatible with mixed use of annexb and hvcc
on
 bitstream like h264dec

Signed-off-by: Li Kai <wolfleekay@gmail.com>
---
 libavcodec/hevc/hevcdec.c | 7 +++++++
 1 file changed, 7 insertions(+)

     /* split the input packet into NAL units, so we know the upper bound
on the
      * number of slices in the frame */
     ret = ff_h2645_packet_split(&s->pkt, buf, length, s->avctx,
s->is_nalff,
diff mbox series

Patch

diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index fd143cddab..59e99493d5 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -3290,6 +3290,13 @@  static int decode_nal_units(HEVCContext *s, const
uint8_t *buf, int length)
     s->eos = 0;
     s->slice_initialized = 0;

+    if (s->nal_length_size == 4) {
+        if (length > 8 && AV_RB32(buf) == 1 && AV_RB32(buf+5) >
(unsigned)length) {
+            s->is_nalff = 0;
+        } else if (length > 3 && AV_RB32(buf) > 1 && AV_RB32(buf) <=
(unsigned)length)
+            s->is_nalff = 1;
+    }
+