diff mbox series

[FFmpeg-devel,5/6] lavc/videotoolboxdec: insert emu-prevention bytes for HEVC as well

Message ID 36ea2d6faa1b57b888bf39fc8138130e8e40ef3b.1652120184.git.ffmpegagent@gmail.com
State Accepted
Commit 792a9f2406a52a26ddfd3045e97fda791db323d2
Headers show
Series lavc/videotoolboxdec: improve HEVC stream compatibility | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Aman Karmani May 9, 2022, 6:16 p.m. UTC
From: rcombs <rcombs@rcombs.me>

Fixes decoding of files with sync-fooling sequences in their PSs.

Signed-off-by: rcombs <rcombs@rcombs.me>
---
 libavcodec/videotoolbox.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 921fed9619..ce83c2594a 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -246,7 +246,7 @@  CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
     for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \
         if (h->ps.t##ps_list[i]) { \
             const HEVC##T##PS *lps = (const HEVC##T##PS *)h->ps.t##ps_list[i]->data; \
-            vt_extradata_size += 2 + lps->data_size; \
+            vt_extradata_size += 2 + escape_ps(NULL, lps->data, lps->data_size); \
             num_##t##ps++; \
         } \
     }
@@ -369,11 +369,11 @@  CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
     for (i = 0; i < HEVC_MAX_##T##PS_COUNT; i++) { \
         if (h->ps.t##ps_list[i]) { \
             const HEVC##T##PS *lps = (const HEVC##T##PS *)h->ps.t##ps_list[i]->data; \
+            int size = escape_ps(p + 2, lps->data, lps->data_size); \
             /* unsigned int(16) nalUnitLength; */ \
-            AV_WB16(p, lps->data_size); \
+            AV_WB16(p, size); \
             /* bit(8*nalUnitLength) nalUnit; */ \
-            memcpy(p + 2, lps->data, lps->data_size); \
-            p += 2 + lps->data_size; \
+            p += 2 + size; \
         } \
     }