Skip to content

Commit 391f05b

Browse files
authored
Test dummy data now supports FH + TG for AV1 (#504)
A test stream can now be created with FH and following TG. The TG is represented by 't'. That is, a GOP with frame header is written as "ItPtPtPt". Co-authored-by: bjornvolcker <[email protected]>
1 parent cce6f7a commit 391f05b

File tree

7 files changed

+71
-51
lines changed

7 files changed

+71
-51
lines changed

lib/src/sv_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ typedef enum {
8989
BU_TYPE_PS = 4, // Parameter Set: PPS/SPS/VPS and similar for AV1
9090
BU_TYPE_AUD = 5,
9191
BU_TYPE_OTHER = 6,
92+
BU_TYPE_TG = 7,
9293
} SignedVideoFrameType;
9394

9495
typedef enum {

tests/check/check_signed_video_auth.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ START_TEST(invalid_api_inputs)
249249

250250
signed_video_t *sv = signed_video_create(codec);
251251
ck_assert(sv);
252-
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 0, codec);
253-
test_stream_item_t *invalid = test_stream_item_create_from_type('X', 0, codec);
252+
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 0, codec, false);
253+
test_stream_item_t *invalid = test_stream_item_create_from_type('X', 0, codec, false);
254254

255255
// signed_video_add_nalu_and_authenticate()
256256
// NULL pointers are invalid, as well as zero sized BUs.
@@ -1001,7 +1001,7 @@ START_TEST(add_one_sei_after_signing)
10011001
test_stream_check_types(list, "IPPISPPPISPPISP");
10021002

10031003
const uint8_t id = 0;
1004-
test_stream_item_t *sei = test_stream_item_create_from_type('Z', id, codec);
1004+
test_stream_item_t *sei = test_stream_item_create_from_type('Z', id, codec, false);
10051005

10061006
// Append the middle 'P' in second GOP: IPPISP P(Z) PISPPISP
10071007
const int append_item_number = 7;
@@ -1463,7 +1463,7 @@ END_TEST
14631463
*/
14641464
START_TEST(onvif_seis)
14651465
{
1466-
test_stream_t *list = test_stream_create("IPIOPIOP", settings[_i].codec);
1466+
test_stream_t *list = test_stream_create("IPIOPIOP", settings[_i].codec, false);
14671467
if (settings[_i].codec == SV_CODEC_AV1) {
14681468
// ONVIF Media Signing is not supported for AV1.
14691469
test_stream_check_types(list, "IPIPIP");
@@ -1499,7 +1499,7 @@ END_TEST
14991499
*/
15001500
START_TEST(no_signature)
15011501
{
1502-
test_stream_t *list = test_stream_create("IPPIPPIPPIPPI", settings[_i].codec);
1502+
test_stream_t *list = test_stream_create("IPPIPPIPPIPPI", settings[_i].codec, false);
15031503
test_stream_check_types(list, "IPPIPPIPPIPPI");
15041504

15051505
// Video is not signed, hence all Bitstream Units are pending.
@@ -1519,7 +1519,7 @@ START_TEST(multislice_no_signature)
15191519
{
15201520
// For AV1, multi-slices are covered in one single OBU (OBU Frame).
15211521
if (settings[_i].codec == SV_CODEC_AV1) return;
1522-
test_stream_t *list = test_stream_create("IiPpPpIiPpPpIiPpPpIiPpPpIi", settings[_i].codec);
1522+
test_stream_t *list = test_stream_create("IiPpPpIiPpPpIiPpPpIiPpPpIi", settings[_i].codec, false);
15231523
test_stream_check_types(list, "IiPpPpIiPpPpIiPpPpIiPpPpIi");
15241524

15251525
// Video is not signed, hence all Bitstream Units are pending.
@@ -1576,9 +1576,9 @@ START_TEST(vendor_axis_communications_operation)
15761576
SignedVideoReturnCode sv_rc;
15771577
struct sv_setting setting = settings[_i];
15781578
SignedVideoCodec codec = settings[_i].codec;
1579-
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec);
1580-
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 1, codec);
1581-
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 2, codec);
1579+
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec, false);
1580+
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 1, codec, false);
1581+
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 2, codec, false);
15821582
test_stream_item_t *sei_item = NULL;
15831583
uint8_t *sei = NULL;
15841584
size_t sei_size = 0;
@@ -1691,9 +1691,9 @@ START_TEST(factory_provisioned_key)
16911691
#ifndef NO_ONVIF_MEDIA_SIGNING
16921692
if (codec != SV_CODEC_AV1) return;
16931693
#endif
1694-
test_stream_item_t *i_item = test_stream_item_create_from_type('I', 0, codec);
1695-
test_stream_item_t *p_item = test_stream_item_create_from_type('P', 1, codec);
1696-
test_stream_item_t *i_item_2 = test_stream_item_create_from_type('I', 2, codec);
1694+
test_stream_item_t *i_item = test_stream_item_create_from_type('I', 0, codec, false);
1695+
test_stream_item_t *p_item = test_stream_item_create_from_type('P', 1, codec, false);
1696+
test_stream_item_t *i_item_2 = test_stream_item_create_from_type('I', 2, codec, false);
16971697
test_stream_item_t *sei_item = NULL;
16981698
uint8_t *sei = NULL;
16991699
size_t sei_size = 0;
@@ -1844,8 +1844,8 @@ generate_and_set_private_key_on_camera_side(struct sv_setting setting,
18441844
SignedVideoReturnCode sv_rc;
18451845
char *private_key = NULL;
18461846
size_t private_key_size = 0;
1847-
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, setting.codec);
1848-
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, setting.codec);
1847+
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, setting.codec, false);
1848+
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, setting.codec, false);
18491849
signed_video_t *sv = signed_video_create(setting.codec);
18501850
ck_assert(sv);
18511851
// Read and set content of private_key.
@@ -1894,7 +1894,7 @@ validate_public_key_scenario(signed_video_t *sv,
18941894
signed_video_authenticity_t *auth_report = NULL;
18951895
signed_video_latest_validation_t *latest = NULL;
18961896

1897-
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec);
1897+
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec, false);
18981898
sv_rc =
18991899
signed_video_add_nalu_and_authenticate(sv, i_frame->data, i_frame->data_size, &auth_report);
19001900
ck_assert(!auth_report);
@@ -2028,8 +2028,8 @@ START_TEST(no_public_key_in_sei_and_bad_public_key_on_validation_side)
20282028
{
20292029
SignedVideoReturnCode sv_rc;
20302030
SignedVideoCodec codec = settings[_i].codec;
2031-
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec);
2032-
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, codec);
2031+
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec, false);
2032+
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, codec, false);
20332033
test_stream_item_t *sei = NULL;
20342034
signed_video_t *sv_camera = NULL;
20352035
char *tmp_private_key = NULL;
@@ -2098,8 +2098,8 @@ START_TEST(no_emulation_prevention_bytes)
20982098
SignedVideoReturnCode sv_rc;
20992099

21002100
// Create a video with a single I-frame, and a SEI (to be created later).
2101-
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec);
2102-
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, codec);
2101+
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec, false);
2102+
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, codec, false);
21032103

21042104
test_stream_item_t *sei_item = NULL;
21052105
uint8_t *sei = NULL;
@@ -2561,7 +2561,7 @@ START_TEST(add_one_p_frame_partial_gops)
25612561
test_stream_check_types(list, "IPPPPSPISPPISPPPPSPISP");
25622562

25632563
// Add a middle 'P' in third GOP: IPPPPSPISPPISP P PPPSPISP
2564-
test_stream_item_t *p = test_stream_item_create_from_type('P', 100, settings[_i].codec);
2564+
test_stream_item_t *p = test_stream_item_create_from_type('P', 100, settings[_i].codec, false);
25652565
const int append_item_number = 14;
25662566
test_stream_append_item(list, p, append_item_number);
25672567
test_stream_check_types(list, "IPPPPSPISPPISPPPPPSPISP");
@@ -3018,7 +3018,7 @@ START_TEST(add_one_p_frame_multiple_gops)
30183018
test_stream_check_types(list, "IPPIsPPIsPPISPPIsPPIsPPISP");
30193019

30203020
// Add a middle 'P' in second GOP: IPPIsP P PIsPPISPPIsPPIsPPISP
3021-
test_stream_item_t *p = test_stream_item_create_from_type('P', 100, settings[_i].codec);
3021+
test_stream_item_t *p = test_stream_item_create_from_type('P', 100, settings[_i].codec, false);
30223022
const int append_nalu_number = 6;
30233023
test_stream_append_item(list, p, append_nalu_number);
30243024
test_stream_check_types(list, "IPPIsPPPIsPPISPPIsPPIsPPISP");

tests/check/check_signed_video_sign.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ START_TEST(api_inputs)
176176
{
177177
SignedVideoReturnCode sv_rc;
178178
SignedVideoCodec codec = settings[_i].codec;
179-
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 0, codec);
180-
test_stream_item_t *invalid = test_stream_item_create_from_type('X', 0, codec);
179+
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 0, codec, false);
180+
test_stream_item_t *invalid = test_stream_item_create_from_type('X', 0, codec, false);
181181
char *private_key = NULL;
182182
size_t private_key_size = 0;
183183
uint8_t *sei = NULL;
@@ -357,8 +357,8 @@ START_TEST(incorrect_operation)
357357
ck_assert(sv);
358358
char *private_key = NULL;
359359
size_t private_key_size = 0;
360-
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 0, codec);
361-
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec);
360+
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 0, codec, false);
361+
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec, false);
362362
// The path to openssl keys has to be set before start of signing.
363363
SignedVideoReturnCode sv_rc =
364364
signed_video_add_nalu_for_signing_with_timestamp(sv, i_frame->data, i_frame->data_size, NULL);
@@ -685,11 +685,11 @@ START_TEST(two_completed_seis_pending)
685685
signed_video_t *sv = get_initialized_signed_video(settings[_i], false);
686686
ck_assert(sv);
687687

688-
test_stream_item_t *i_frame_1 = test_stream_item_create_from_type('I', 0, codec);
689-
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, codec);
690-
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 2, codec);
691-
test_stream_item_t *i_frame_3 = test_stream_item_create_from_type('I', 3, codec);
692-
test_stream_item_t *i_frame_4 = test_stream_item_create_from_type('i', 4, codec);
688+
test_stream_item_t *i_frame_1 = test_stream_item_create_from_type('I', 0, codec, false);
689+
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, codec, false);
690+
test_stream_item_t *p_frame = test_stream_item_create_from_type('P', 2, codec, false);
691+
test_stream_item_t *i_frame_3 = test_stream_item_create_from_type('I', 3, codec, false);
692+
test_stream_item_t *i_frame_4 = test_stream_item_create_from_type('i', 4, codec, false);
693693

694694
sv_rc = signed_video_add_nalu_for_signing_with_timestamp(
695695
sv, i_frame_1->data, i_frame_1->data_size, NULL);
@@ -808,8 +808,8 @@ START_TEST(w_wo_emulation_prevention_bytes)
808808
uint8_t *seis[NUM_EPB_CASES] = {NULL, NULL};
809809
size_t sei_sizes[NUM_EPB_CASES] = {0, 0};
810810
bool with_emulation_prevention[NUM_EPB_CASES] = {true, false};
811-
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec);
812-
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, codec);
811+
test_stream_item_t *i_frame = test_stream_item_create_from_type('I', 0, codec, false);
812+
test_stream_item_t *i_frame_2 = test_stream_item_create_from_type('I', 1, codec, false);
813813

814814
size_t sei_size = 0;
815815
unsigned num_pending_seis = 0;

tests/check/legacy_test_data.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ get_legacy_stream(int idx, SignedVideoCodec codec)
13011301
// Check if this test case is valid.
13021302
if (!legacy_data[idx][0].data || (legacy_data[idx][0].data_size == 0)) return NULL;
13031303

1304-
test_stream_t *list = test_stream_create("", codec);
1304+
test_stream_t *list = test_stream_create("", codec, false);
13051305
for (int ii = 0; ii < LEGACY_STREAM_LENGTH; ii++) {
13061306
uint8_t *data = malloc(legacy_data[idx][ii].data_size);
13071307
memcpy(data, legacy_data[idx][ii].data, legacy_data[idx][ii].data_size);

tests/check/test_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ create_signed_stream_with_sv(signed_video_t *sv, const char *str, bool split_bu,
369369
const bool apply_ep = false; // Apply emulation prevention on generated SEI afterwards.
370370
const bool get_seis_at_end = false; // Fetch all SEIs at once at the end of the stream.
371371
// Create a test stream given the input string.
372-
test_stream_t *list = test_stream_create(str, sv->codec);
372+
test_stream_t *list = test_stream_create(str, sv->codec, false);
373373
test_stream_item_t *item = list->first_item;
374374
int64_t timestamp = g_testTimestamp;
375375
num_gops_until_signing = sv->signing_frequency - 1;

tests/check/test_stream.c

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ const uint8_t sh_av1[DUMMY_NALU_SIZE] = {0x0a, 0x03, 0x00, 0x00, 0x80};
9999
const uint8_t sei_av1[DUMMY_NALU_SIZE] = {0x2a, 0x03, 0x18, 0x00, 0x80};
100100
const uint8_t invalid_av1[DUMMY_NALU_SIZE] = {0x02, 0x03, 0xff, 0x00, 0xff};
101101

102+
const uint8_t I_fh_av1[DUMMY_NALU_SIZE] = {0x1a, 0x03, 0x10, 0x00, 0x80};
103+
const uint8_t P_fh_av1[DUMMY_NALU_SIZE] = {0x1a, 0x03, 0x30, 0x00, 0x80};
104+
const uint8_t tg_av1[DUMMY_NALU_SIZE] = {0x22, 0x03, 0x00, 0x00, 0x80};
105+
// TODO: Maybe add OBU_TILE_LIST later
106+
// const uint8_t P_tl_av1[DUMMY_NALU_SIZE] = {0x42, 0x03, 0x02, 0x00, 0x80};
107+
102108
/* Helper that parses information from the Bitstream Unit |data| and returns a character
103109
* representing the Bitstream Unit type. */
104110
static char
@@ -133,6 +139,9 @@ get_type_char(const uint8_t *data, size_t data_size, SignedVideoCodec codec)
133139
type = 's';
134140
break;
135141
}
142+
case BU_TYPE_TG:
143+
type = 't';
144+
break;
136145
default:
137146
type = '\0';
138147
break;
@@ -174,7 +183,7 @@ generate_nalu(bool valid_start_code,
174183

175184
/* Creates a test_stream_item_t from |type| for |codec|, then sets the |id|. */
176185
test_stream_item_t *
177-
test_stream_item_create_from_type(char type, uint8_t id, SignedVideoCodec codec)
186+
test_stream_item_create_from_type(char type, uint8_t id, SignedVideoCodec codec, bool with_fh)
178187
{
179188
uint8_t *bu = NULL; // Final Bitstream Unit with id and with/without start code.
180189
const uint8_t *bu_data = NULL;
@@ -184,22 +193,26 @@ test_stream_item_create_from_type(char type, uint8_t id, SignedVideoCodec codec)
184193
// Find out which type of Bitstream Unit the character is and point |bu_data| to it.
185194
switch (type) {
186195
case 'I':
187-
bu_data =
188-
codec == SV_CODEC_H264 ? I_nalu_h264 : (codec == SV_CODEC_H265 ? I_nalu_h265 : I_av1);
196+
bu_data = codec == SV_CODEC_H264
197+
? I_nalu_h264
198+
: (codec == SV_CODEC_H265 ? I_nalu_h265 : (with_fh ? I_fh_av1 : I_av1));
189199
break;
190200
case 'i':
191201
// Not yet valid for AV1.
192-
bu_data = codec == SV_CODEC_H264 ? i_nalu_h264
193-
: (codec == SV_CODEC_H265 ? i_nalu_h265 : invalid_av1);
202+
bu_data = codec == SV_CODEC_H264
203+
? i_nalu_h264
204+
: (codec == SV_CODEC_H265 ? i_nalu_h265 : invalid_av1);
194205
break;
195206
case 'P':
196-
bu_data =
197-
codec == SV_CODEC_H264 ? P_nalu_h264 : (codec == SV_CODEC_H265 ? P_nalu_h265 : P_av1);
207+
bu_data = codec == SV_CODEC_H264
208+
? P_nalu_h264
209+
: (codec == SV_CODEC_H265 ? P_nalu_h265 : (with_fh ? P_fh_av1 : P_av1));
198210
break;
199211
case 'p':
200212
// Not yet valid for AV1.
201-
bu_data = codec == SV_CODEC_H264 ? p_nalu_h264
202-
: (codec == SV_CODEC_H265 ? p_nalu_h265 : invalid_av1);
213+
bu_data = codec == SV_CODEC_H264
214+
? p_nalu_h264
215+
: (codec == SV_CODEC_H265 ? p_nalu_h265 : invalid_av1);
203216
break;
204217
case 'O':
205218
bu_data = codec == SV_CODEC_H264 ? oms_sei_nalu_h264
@@ -215,6 +228,9 @@ test_stream_item_create_from_type(char type, uint8_t id, SignedVideoCodec codec)
215228
bu_data = codec == SV_CODEC_H264 ? pps_nalu_h264
216229
: (codec == SV_CODEC_H265 ? pps_nalu_h265 : sh_av1);
217230
break;
231+
case 't':
232+
bu_data = (codec == SV_CODEC_AV1 && with_fh) ? tg_av1 : invalid_av1;
233+
break;
218234
case 'X':
219235
default:
220236
bu_data = (codec != SV_CODEC_AV1) ? invalid_nalu : invalid_av1;
@@ -398,15 +414,15 @@ test_stream_item_print(test_stream_item_t *item)
398414
/* Creates a test stream with items based on the input string for a given |codec|. The
399415
* string is converted to test stream items. */
400416
test_stream_t *
401-
test_stream_create(const char *str, SignedVideoCodec codec)
417+
test_stream_create(const char *str, SignedVideoCodec codec, bool with_fh)
402418
{
403419
test_stream_t *list = (test_stream_t *)calloc(1, sizeof(test_stream_t));
404420
ck_assert(list);
405421
list->codec = codec;
406422
uint8_t i = 0;
407423

408424
while (str[i]) {
409-
test_stream_item_t *new_item = test_stream_item_create_from_type(str[i], i, codec);
425+
test_stream_item_t *new_item = test_stream_item_create_from_type(str[i], i, codec, with_fh);
410426
if (!new_item) {
411427
// No character could be identified. Continue without adding.
412428
i++;
@@ -470,7 +486,7 @@ test_stream_pop(test_stream_t *list, int number_of_items)
470486
if (!list || number_of_items > list->num_items) return NULL;
471487

472488
// Create an empty list.
473-
test_stream_t *new_list = test_stream_create("", list->codec);
489+
test_stream_t *new_list = test_stream_create("", list->codec, false);
474490
ck_assert(new_list);
475491
// Pop items from list and append to the new_list.
476492
while (number_of_items--) {
@@ -503,7 +519,7 @@ test_stream_pop_gops(test_stream_t *list, int number_of_gops)
503519
}
504520

505521
// Create an empty list.
506-
test_stream_t *new_list = test_stream_create("", list->codec);
522+
test_stream_t *new_list = test_stream_create("", list->codec, false);
507523
ck_assert(new_list);
508524
// Pop items from list and append to the new_list.
509525
while (number_of_gops) {

tests/check/test_stream.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ typedef struct _test_stream_st {
5757
**/
5858

5959
/* Creates a test stream with test stream items based on the input string. The string is
60-
* converted to test stream items. */
60+
* converted to test stream items. For AV1, one can select representing frames with
61+
* OBU_FRAME or OBU_FRAME_HEADER + OBU_TILE_GROUP, the latter if |with_fh| is 'true'. */
6162
test_stream_t *
62-
test_stream_create(const char *str, SignedVideoCodec codec);
63+
test_stream_create(const char *str, SignedVideoCodec codec, bool with_fh);
6364

6465
/* Frees all the items in the list and the list itself. */
6566
void
@@ -112,9 +113,11 @@ test_stream_print(test_stream_t *list);
112113
* test_stream_item_t functions
113114
**/
114115

115-
/* Creates a test_stream_item_t from a |type| and |codec|. Then sets the |id|. */
116+
/* Creates a test_stream_item_t from a |type| and |codec|. Then sets the |id|. For AV1,
117+
* one can select representing frames with OBU_FRAME or OBU_FRAME_HEADER + OBU_TILE_GROUP,
118+
* the latter if |with_fh| is 'true'.*/
116119
test_stream_item_t *
117-
test_stream_item_create_from_type(char type, uint8_t id, SignedVideoCodec codec);
120+
test_stream_item_create_from_type(char type, uint8_t id, SignedVideoCodec codec, bool with_fh);
118121

119122
/* Creates a new test stream item. Takes pointers to the Bitstream Unit data, the bu data
120123
* size. Memory ownership is transferred. */

0 commit comments

Comments
 (0)