@@ -117,7 +117,9 @@ typedef enum
117
117
TYPE_RDD36_422_ITU2020 = 58 ,
118
118
TYPE_MPEG2LG_MP_ML_576I = 59 ,
119
119
TYPE_MPEG2LG_MP_ML_576I_4_3 = 60 ,
120
- TYPE_END = 61 ,
120
+ TYPE_KLV_ANC_DATA_VAR_SIZE = 61 ,
121
+ TYPE_KLV_VBI_DATA_VAR_SIZE = 62 ,
122
+ TYPE_END = 63 ,
121
123
} EssenceType;
122
124
123
125
typedef struct
@@ -902,30 +904,96 @@ static void write_avid_alpha(FILE *file, int type, unsigned int duration)
902
904
write_data (file, duration * frame_size);
903
905
}
904
906
905
- static void write_anc_data (FILE *file, unsigned int duration)
907
+ static void write_anc_data (FILE *file, unsigned int duration, bool klv_var_size )
906
908
{
907
- static const unsigned char anc_frame [24 ] =
909
+ static const unsigned char core_anc_frame [24 ] =
908
910
{0x00 , 0x01 , // single line / packet
909
911
0x00 , 0x09 , 0x01 , 0x04 , 0x00 , 0x07 , // line 9, VANCFrame, ANC_8_BIT_COMP_LUMA, 7 samples
910
912
0x00 , 0x00 , 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x01 , // payload array header: 8 x 1 bytes
911
913
0x45 , 0x04 , 0x04 , 0x21 , 0x22 , 0x23 , 0x24 , 0x00 }; // payload array: DID (1), SDID (1), DC (1), UDW (4), padding (1)
914
+ // Any key will do as it is discarded when parsing the data
915
+ static const unsigned char klv_key[16 ] = {0x41 , 0x4e , 0x43 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
916
+
917
+ // Odd and even frame data and sizes
918
+ unsigned char *anc_data[2 ];
919
+ size_t anc_data_size[2 ];
920
+
921
+ if (klv_var_size) {
922
+ anc_data_size[0 ] = 16 + 1 + sizeof (core_anc_frame);
923
+ anc_data[0 ] = new unsigned char [anc_data_size[0 ]];
924
+ memcpy (anc_data[0 ], klv_key, 16 );
925
+ anc_data[0 ][16 ] = anc_data_size[0 ] - 17 ;
926
+ memcpy (&anc_data[0 ][17 ], core_anc_frame, sizeof (core_anc_frame));
927
+
928
+ // Add an extra padding byte to the odd frame
929
+ anc_data_size[1 ] = 16 + 1 + sizeof (core_anc_frame) + 1 ;
930
+ anc_data[1 ] = new unsigned char [anc_data_size[1 ]];
931
+ memcpy (anc_data[1 ], klv_key, 16 );
932
+ anc_data[1 ][16 ] = anc_data_size[1 ] - 17 ;
933
+ memcpy (&anc_data[1 ][17 ], core_anc_frame, sizeof (core_anc_frame));
934
+ anc_data[1 ][16 + 1 + 11 ] = 0x09 ;
935
+ anc_data[1 ][anc_data_size[1 ] - 1 ] = 0x00 ;
936
+ } else {
937
+ anc_data[0 ] = const_cast <unsigned char *>(core_anc_frame);
938
+ anc_data[1 ] = const_cast <unsigned char *>(core_anc_frame);
939
+ anc_data_size[0 ] = sizeof (core_anc_frame);
940
+ anc_data_size[1 ] = sizeof (core_anc_frame);
941
+ }
912
942
913
943
unsigned int i;
914
944
for (i = 0 ; i < duration; i++)
915
- write_buffer (file, anc_frame, sizeof (anc_frame));
945
+ write_buffer (file, anc_data[i % 2 ], anc_data_size[i % 2 ]);
946
+
947
+ if (klv_var_size) {
948
+ delete [] anc_data[0 ];
949
+ delete [] anc_data[1 ];
950
+ }
916
951
}
917
952
918
- static void write_vbi_data (FILE *file, unsigned int duration)
953
+ static void write_vbi_data (FILE *file, unsigned int duration, bool klv_var_size )
919
954
{
920
- static const unsigned char vbi_frame [24 ] =
955
+ static const unsigned char core_vbi_frame [24 ] =
921
956
{0x00 , 0x01 , // single line
922
957
0x00 , 0x15 , 0x01 , 0x04 , 0x00 , 0x08 , // line 21, VBIFrame, VBI_8_BIT_COMP_LUMA, 8 samples
923
958
0x00 , 0x00 , 0x00 , 0x08 , 0x00 , 0x00 , 0x00 , 0x01 , // payload array header: 8 x 1 bytes
924
959
0x40 , 0x41 , 0x42 , 0x43 , 0x44 , 0x45 , 0x46 , 0x47 }; // payload array
960
+ // Any key will do as it is discarded when parsing the data
961
+ static const unsigned char klv_key[16 ] = {0x56 , 0x42 , 0x49 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 };
962
+
963
+ // Odd and even frame data and sizes
964
+ unsigned char *vbi_data[2 ];
965
+ size_t vbi_data_size[2 ];
966
+
967
+ if (klv_var_size) {
968
+ vbi_data_size[0 ] = 16 + 1 + sizeof (core_vbi_frame);
969
+ vbi_data[0 ] = new unsigned char [vbi_data_size[0 ]];
970
+ memcpy (vbi_data[0 ], klv_key, 16 );
971
+ vbi_data[0 ][16 ] = vbi_data_size[0 ] - 17 ;
972
+ memcpy (&vbi_data[0 ][17 ], core_vbi_frame, sizeof (core_vbi_frame));
973
+
974
+ // Add an extra padding byte to the odd frame
975
+ vbi_data_size[1 ] = 16 + 1 + sizeof (core_vbi_frame) + 1 ;
976
+ vbi_data[1 ] = new unsigned char [vbi_data_size[1 ]];
977
+ memcpy (vbi_data[1 ], klv_key, 16 );
978
+ vbi_data[1 ][16 ] = vbi_data_size[1 ] - 17 ;
979
+ memcpy (&vbi_data[1 ][17 ], core_vbi_frame, sizeof (core_vbi_frame));
980
+ vbi_data[1 ][16 + 1 + 11 ] = 0x09 ;
981
+ vbi_data[1 ][vbi_data_size[1 ] - 1 ] = 0x00 ;
982
+ } else {
983
+ vbi_data[0 ] = const_cast <unsigned char *>(core_vbi_frame);
984
+ vbi_data[1 ] = const_cast <unsigned char *>(core_vbi_frame);
985
+ vbi_data_size[0 ] = sizeof (core_vbi_frame);
986
+ vbi_data_size[1 ] = sizeof (core_vbi_frame);
987
+ }
925
988
926
989
unsigned int i;
927
990
for (i = 0 ; i < duration; i++)
928
- write_buffer (file, vbi_frame, sizeof (vbi_frame));
991
+ write_buffer (file, vbi_data[i % 2 ], vbi_data_size[i % 2 ]);
992
+
993
+ if (klv_var_size) {
994
+ delete [] vbi_data[0 ];
995
+ delete [] vbi_data[1 ];
996
+ }
929
997
}
930
998
931
999
@@ -990,6 +1058,11 @@ static void print_usage(const char *cmd)
990
1058
fprintf (stderr, " 55: RDD-36 422 Profile\n " );
991
1059
fprintf (stderr, " 56: RDD-36 4444 Profile\n " );
992
1060
fprintf (stderr, " 57: 16-bit PCM with duration in samples\n " );
1061
+ fprintf (stderr, " 58: RDD-36 422 ITU 2020\n " );
1062
+ fprintf (stderr, " 59: MPEG-2 Long GOP MP@ML 576i\n " );
1063
+ fprintf (stderr, " 60: MPEG-2 Long GOP MP@ML 576i 4:3\n " );
1064
+ fprintf (stderr, " 61: variable size ANC data in KLV\n " );
1065
+ fprintf (stderr, " 62: variable size VBI data in KLV\n " );
993
1066
}
994
1067
995
1068
int main (int argc, const char **argv)
@@ -1190,10 +1263,16 @@ int main(int argc, const char **argv)
1190
1263
write_pcm (file, 3 , duration);
1191
1264
break ;
1192
1265
case TYPE_ANC_DATA:
1193
- write_anc_data (file, duration);
1266
+ write_anc_data (file, duration, false );
1267
+ break ;
1268
+ case TYPE_KLV_ANC_DATA_VAR_SIZE:
1269
+ write_anc_data (file, duration, true );
1194
1270
break ;
1195
1271
case TYPE_VBI_DATA:
1196
- write_vbi_data (file, duration);
1272
+ write_vbi_data (file, duration, false );
1273
+ break ;
1274
+ case TYPE_KLV_VBI_DATA_VAR_SIZE:
1275
+ write_vbi_data (file, duration, true );
1197
1276
break ;
1198
1277
case TYPE_16BIT_PCM_SAMPLES:
1199
1278
write_pcm_samples (file, 2 , duration);
0 commit comments