diff mbox series

[FFmpeg-devel,v7,6/8] avcodec/h264_metadata_bsf: Fix user data failed to insert in case no SPSs NAL for global headers

Message ID 20200107050355.17503-6-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,v7,1/8] avutil: add AV_FRAME_DATA_USER_DATA_UNREGISTERED side data type | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Lance Wang Jan. 7, 2020, 5:03 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/h264_metadata_bsf.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c
index d96a50dbf7..a320589530 100644
--- a/libavcodec/h264_metadata_bsf.c
+++ b/libavcodec/h264_metadata_bsf.c
@@ -279,7 +279,7 @@  static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
 {
     H264MetadataContext *ctx = bsf->priv_data;
     CodedBitstreamFragment *au = &ctx->access_unit;
-    int err, i, j, has_sps;
+    int err, i, j, has_sps, has_keyframe = 0;
     H264RawAUD aud;
 
     err = ff_bsf_get_packet_ref(bsf, pkt);
@@ -359,11 +359,13 @@  static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
                 goto fail;
             has_sps = 1;
         }
+        if (au->units[i].type == H264_NAL_IDR_SLICE)
+            has_keyframe = 1;
     }
 
     // Only insert the SEI in access units containing SPSs, and also
     // unconditionally in the first access unit we ever see.
-    if (ctx->sei_user_data && (has_sps || !ctx->done_first_au)) {
+    if (ctx->sei_user_data && (has_sps || !ctx->done_first_au || has_keyframe)) {
         H264RawSEIPayload payload = {
             .payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED,
         };