]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb'
authorMark Thompson <sw@jkqxz.net>
Wed, 21 Feb 2018 22:32:42 +0000 (22:32 +0000)
committerMark Thompson <sw@jkqxz.net>
Wed, 21 Feb 2018 22:37:07 +0000 (22:37 +0000)
* commit '69062d0f9b6aef5d9d9b8c9c9b5cfb23037caddb':
  h264_metadata: Use common SEI addition function

Minor changes because the following patch is already present.

Merged-by: Mark Thompson <sw@jkqxz.net>
1  2 
libavcodec/h264_metadata_bsf.c

index 62a5547fe0a17558baa3e1a189de683b1bc2bda5,356daef3ec6a2a4c7ecc4605469cc8582f94441c..20ac299bda7f5c0f693e091049538665d9e49026
@@@ -289,48 -287,14 +288,17 @@@ static int h264_metadata_filter(AVBSFCo
          }
      }
  
 -    // Only insert the SEI in access units containing SPSs.
 -    if (has_sps && ctx->sei_user_data) {
 +    // 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->sei_first_au)) {
-         H264RawSEI *sei;
-         H264RawSEIPayload *payload;
-         H264RawSEIUserDataUnregistered *udu;
-         int sei_pos, sei_new;
+         H264RawSEIPayload payload = {
+             .payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED,
+         };
+         H264RawSEIUserDataUnregistered *udu =
+             &payload.payload.user_data_unregistered;
  
-         for (i = 0; i < au->nb_units; i++) {
-             if (au->units[i].type == H264_NAL_SEI ||
-                 au->units[i].type == H264_NAL_SLICE ||
-                 au->units[i].type == H264_NAL_IDR_SLICE)
-                 break;
-         }
-         sei_pos = i;
-         if (sei_pos < au->nb_units &&
-             au->units[sei_pos].type == H264_NAL_SEI) {
-             sei_new = 0;
-             sei = au->units[sei_pos].content;
-         } else {
-             sei_new = 1;
-             sei = &ctx->sei_nal;
-             memset(sei, 0, sizeof(*sei));
-             sei->nal_unit_header.nal_unit_type = H264_NAL_SEI;
-             err = ff_cbs_insert_unit_content(ctx->cbc, au, sei_pos,
-                                              H264_NAL_SEI, sei, NULL);
-             if (err < 0) {
-                 av_log(bsf, AV_LOG_ERROR, "Failed to insert SEI.\n");
-                 goto fail;
-             }
-         }
-         payload = &sei->payload[sei->payload_count];
-         payload->payload_type = H264_SEI_TYPE_USER_DATA_UNREGISTERED;
-         udu = &payload->payload.user_data_unregistered;
 +        ctx->sei_first_au = 1;
 +
          for (i = j = 0; j < 32 && ctx->sei_user_data[i]; i++) {
              int c, v;
              c = ctx->sei_user_data[i];