Skip to content

Commit 5c02dae

Browse files
authored
Increment of current_partial_gop done outside TLV (#487)
On the signing side, the current_partial_gop was updated when encoding the TLVs. The TLV encoding process should not take any actions. It should solely write the current state into the SEI. The update is now done outside encoding. Further, the counter is initialized to -1 instead of 0. This makes it more clear on the validation side when the first SEI is to be used. Co-authored-by: bjornvolcker <bjornvolcker@users.noreply.github.com>
1 parent e787a1c commit 5c02dae

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/src/sv_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ gop_info_create(void)
253253
gop_info_t *gop_info = (gop_info_t *)calloc(1, sizeof(gop_info_t));
254254
if (!gop_info) return NULL;
255255

256-
gop_info->current_partial_gop = 0;
256+
gop_info->current_partial_gop = -1;
257257
// Initialize |verified_signature_hash| as 'error', since we lack data.
258258
gop_info->verified_signature_hash = -1;
259259

@@ -279,7 +279,7 @@ gop_info_reset(gop_info_t *gop_info)
279279
// If a reset is forced, the stored hashes in |hash_list| have no meaning anymore.
280280
gop_info->list_idx = 0;
281281
gop_info->num_partial_gop_wraparounds = 0;
282-
gop_info->current_partial_gop = 0;
282+
gop_info->current_partial_gop = -1;
283283
gop_info->next_partial_gop = 0;
284284
memset(gop_info->linked_hashes, 0, MAX_HASH_SIZE * 2);
285285
}

lib/src/sv_sign.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,11 @@ signed_video_add_nalu_part_for_signing_with_timestamp(signed_video_t *self,
671671
self->num_gops_until_signing = self->signing_frequency;
672672
}
673673
}
674+
// Increment GOP counter since a new (partial) GOP is detected.
675+
if (gop_info->current_partial_gop < 0) {
676+
gop_info->current_partial_gop = 0;
677+
}
678+
gop_info->current_partial_gop++;
674679
if (new_gop) {
675680
self->num_gops_until_signing--;
676681
}

lib/src/sv_tlv.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ encode_general(signed_video_t *self, uint8_t *data)
218218
{
219219
gop_info_t *gop_info = self->gop_info;
220220
size_t data_size = 0;
221-
uint32_t gop_counter = (uint32_t)(gop_info->current_partial_gop + 1);
221+
uint32_t gop_counter = (uint32_t)(gop_info->current_partial_gop & 0xffffffff);
222222
uint16_t num_in_partial_gop = gop_info->num_in_partial_gop;
223223
const uint8_t version = 4;
224224
int64_t start_ts = gop_info->start_timestamp;
@@ -307,8 +307,6 @@ encode_general(signed_video_t *self, uint8_t *data)
307307
sv_write_byte(last_two_bytes, &data_ptr, gop_info->computed_gop_hash[i], epb);
308308
}
309309

310-
gop_info->current_partial_gop = gop_counter;
311-
312310
return (data_ptr - data);
313311
}
314312

0 commit comments

Comments
 (0)