@@ -1179,6 +1179,7 @@ maybe_validate_gop(signed_video_t *self, bu_info_t *bu)
11791179 int max_loop = 10 ;
11801180 bool update_validation_status = false;
11811181 bool public_key_has_changed = false;
1182+ bool start_sei_in_sync = validation_flags -> sei_in_sync ;
11821183 char sei_validation_status = 'U' ;
11831184 // Keep validating as long as there are pending GOPs.
11841185 bool stop_validating = false;
@@ -1249,6 +1250,36 @@ maybe_validate_gop(signed_video_t *self, bu_info_t *bu)
12491250 DEBUG_LOG ("Validation aborted after reaching max number of loops" );
12501251 }
12511252
1253+ if (start_sei_in_sync != validation_flags -> sei_in_sync ) {
1254+ // Some partial GOPs may have been discarded due to being out of sync at that time
1255+ // because they were in fact correctly invalid. Get stats another time and update
1256+ // |latest->authenticity|.
1257+ SignedVideoAuthenticityResult valid = SV_AUTH_RESULT_NOT_OK ;
1258+ int num_invalid ;
1259+ int num_missed ;
1260+ bu_list_get_stats (self -> bu_list , NULL , & num_invalid , & num_missed );
1261+ DEBUG_LOG ("Number of invalid Bitstream Units = %d." , num_invalid );
1262+ DEBUG_LOG ("Number of missed Bitstream Units = %d." , num_missed );
1263+
1264+ valid = (num_invalid > 0 ) ? SV_AUTH_RESULT_NOT_OK : SV_AUTH_RESULT_OK ;
1265+
1266+ // Determine if this GOP is valid, but has missing information. This happens if we have
1267+ // detected missed BUs or if the GOP is incomplete.
1268+ if (valid == SV_AUTH_RESULT_OK && (num_missed > 0 )) {
1269+ valid = SV_AUTH_RESULT_OK_WITH_MISSING_INFO ;
1270+ }
1271+ // Update |latest_validation| with the validation result.
1272+ if (latest -> authenticity <= SV_AUTH_RESULT_SIGNATURE_PRESENT ) {
1273+ // Still either pending validation or video has no signature. Update with the current
1274+ // result.
1275+ latest -> authenticity = valid ;
1276+ } else if (valid < latest -> authenticity ) {
1277+ // Current GOP validated a worse authenticity compared to what has been validated so
1278+ // far. Update with this worse result, since that is what should rule the total
1279+ // validation.
1280+ latest -> authenticity = valid ;
1281+ }
1282+ }
12521283 SV_THROW (bu_list_update_status (bu_list , update_validation_status ));
12531284 if (validation_flags -> is_first_validation ) {
12541285 update_sei_in_validation (self , false, NULL , & sei_validation_status );
0 commit comments