64
64
#include < bmx/essence_parser/RawEssenceReader.h>
65
65
#include < bmx/essence_parser/FileEssenceSource.h>
66
66
#include < bmx/essence_parser/KLVEssenceSource.h>
67
+ #include < bmx/essence_parser/KLVEssenceReader.h>
67
68
#include < bmx/essence_parser/FilePatternEssenceSource.h>
68
69
#include < bmx/essence_parser/D10RawEssenceReader.h>
69
70
#include < bmx/essence_parser/MPEG2AspectRatioFilter.h>
@@ -153,6 +154,7 @@ struct RawInput
153
154
154
155
RawEssenceReader *raw_reader;
155
156
WaveReader *wave_reader;
157
+ KLVEssenceReader *klv_reader;
156
158
uint32_t channel_count;
157
159
TimedTextManifestParser *timed_text_manifest;
158
160
@@ -256,14 +258,20 @@ static uint32_t read_samples(RawInput *input, uint32_t max_samples_per_read)
256
258
uint32_t num_frame_samples = input->sample_sequence [input->sample_sequence_offset ];
257
259
input->sample_sequence_offset = (input->sample_sequence_offset + 1 ) % input->sample_sequence_size ;
258
260
259
- if (input->raw_reader )
261
+ if (input->raw_reader ) {
260
262
return (input->raw_reader ->ReadSamples (num_frame_samples) == num_frame_samples ? 1 : 0 );
261
- else
263
+ } else if (input->klv_reader ) {
264
+ BMX_ASSERT (num_frame_samples == 1 );
265
+ return (input->klv_reader ->ReadValue () ? 1 : 0 );
266
+ } else {
262
267
return (input->wave_reader ->Read (num_frame_samples) == num_frame_samples ? 1 : 0 );
268
+ }
263
269
} else {
264
270
BMX_ASSERT (input->sample_sequence_size == 1 && input->sample_sequence [0 ] == 1 );
265
271
if (input->raw_reader )
266
272
return input->raw_reader ->ReadSamples (max_samples_per_read);
273
+ else if (input->klv_reader )
274
+ return (input->klv_reader ->ReadValue () ? 1 : 0 );
267
275
else
268
276
return input->wave_reader ->Read (max_samples_per_read);
269
277
}
@@ -327,6 +335,12 @@ static bool open_raw_reader(RawInput *input)
327
335
{
328
336
input->raw_reader = new D10RawEssenceReader (essence_source);
329
337
}
338
+ else if (input->parse_klv &&
339
+ (input->essence_type == ANC_DATA ||
340
+ input->essence_type == VBI_DATA))
341
+ {
342
+ input->klv_reader = new KLVEssenceReader (dynamic_cast <KLVEssenceSource*>(essence_source));
343
+ }
330
344
else
331
345
{
332
346
input->raw_reader = new RawEssenceReader (essence_source);
@@ -392,6 +406,7 @@ static void clear_input(RawInput *input)
392
406
{
393
407
delete input->raw_reader ;
394
408
delete input->wave_reader ;
409
+ delete input->klv_reader ;
395
410
delete input->filter ;
396
411
delete input->timed_text_manifest ;
397
412
delete input->wave_chunk_refs ;
@@ -834,8 +849,8 @@ static void usage(const char *cmd)
834
849
printf (" --vc3_1080i_1260 <name> Raw VC3/DNxHD 1920x1080i 85 Mbps input file\n " );
835
850
printf (" --pcm <name> Raw PCM audio input file\n " );
836
851
printf (" --wave <name> Wave PCM audio input file\n " );
837
- printf (" --anc <name> Raw ST 436 Ancillary data. Currently requires the --anc-const option\n " );
838
- printf (" --vbi <name> Raw ST 436 Vertical Blanking Interval data. Currently requires the --vbi-const option\n " );
852
+ printf (" --anc <name> Raw ST 436 Ancillary data. Requires the --anc-const option or frame wrapped in KLV and the --klv option\n " );
853
+ printf (" --vbi <name> Raw ST 436 Vertical Blanking Interval data. Requires the --vbi-const option or frame wrapped in KLV and the --klv option\n " );
839
854
printf (" --tt <manifest> Manifest file containing Timed Text metadata\n " );
840
855
printf (" \n\n " );
841
856
printf (" Notes:\n " );
@@ -4045,10 +4060,10 @@ int main(int argc, const char** argv)
4045
4060
fprintf (stderr, " Multiple '%s' inputs are not permitted\n " , argv[cmdln_index]);
4046
4061
return 1 ;
4047
4062
}
4048
- if (input.anc_const_size == 0 )
4063
+ if (input.anc_const_size == 0 && !input. parse_klv )
4049
4064
{
4050
4065
usage_ref (argv[0 ]);
4051
- fprintf (stderr, " Missing or zero '--anc-const' option for input '%s'\n " , argv[cmdln_index]);
4066
+ fprintf (stderr, " Missing or zero '--anc-const' or '--klv' options for input '%s'\n " , argv[cmdln_index]);
4052
4067
return 1 ;
4053
4068
}
4054
4069
input.essence_type = ANC_DATA;
@@ -4071,7 +4086,7 @@ int main(int argc, const char** argv)
4071
4086
fprintf (stderr, " Multiple '%s' inputs are not permitted\n " , argv[cmdln_index]);
4072
4087
return 1 ;
4073
4088
}
4074
- if (input.vbi_const_size == 0 )
4089
+ if (input.vbi_const_size == 0 && !input. parse_klv )
4075
4090
{
4076
4091
usage_ref (argv[0 ]);
4077
4092
fprintf (stderr, " Missing or zero '--vbi-const' option for input '%s'\n " , argv[cmdln_index]);
@@ -5593,10 +5608,12 @@ int main(int argc, const char** argv)
5593
5608
clip_track->SetChannelAssignment (audio_layout_mode_label);
5594
5609
break ;
5595
5610
case ANC_DATA:
5596
- clip_track->SetConstantDataSize (input->anc_const_size );
5611
+ if (input->anc_const_size )
5612
+ clip_track->SetConstantDataSize (input->anc_const_size );
5597
5613
break ;
5598
5614
case VBI_DATA:
5599
- clip_track->SetConstantDataSize (input->vbi_const_size );
5615
+ if (input->vbi_const_size )
5616
+ clip_track->SetConstantDataSize (input->vbi_const_size );
5600
5617
break ;
5601
5618
case TIMED_TEXT:
5602
5619
clip_track->SetTimedTextSource (input->timed_text_manifest );
@@ -5863,12 +5880,14 @@ int main(int argc, const char** argv)
5863
5880
case ANC_DATA:
5864
5881
input->sample_sequence [0 ] = 1 ;
5865
5882
input->sample_sequence_size = 1 ;
5866
- input->raw_reader ->SetFixedSampleSize (input->anc_const_size );
5883
+ if (input->raw_reader && input->anc_const_size )
5884
+ input->raw_reader ->SetFixedSampleSize (input->anc_const_size );
5867
5885
break ;
5868
5886
case VBI_DATA:
5869
5887
input->sample_sequence [0 ] = 1 ;
5870
5888
input->sample_sequence_size = 1 ;
5871
- input->raw_reader ->SetFixedSampleSize (input->vbi_const_size );
5889
+ if (input->raw_reader && input->vbi_const_size )
5890
+ input->raw_reader ->SetFixedSampleSize (input->vbi_const_size );
5872
5891
break ;
5873
5892
case TIMED_TEXT:
5874
5893
break ;
@@ -6206,6 +6225,16 @@ int main(int argc, const char** argv)
6206
6225
input->raw_reader ->GetSampleData (), input->raw_reader ->GetSampleDataSize (),
6207
6226
num_samples);
6208
6227
}
6228
+ } else if (input->klv_reader ) {
6229
+ num_samples = input->klv_reader ->GetValueSize () ? 1 : 0 ;
6230
+ if (num_samples) {
6231
+ output_track->WriteSamples (
6232
+ output_channel_index,
6233
+ input->klv_reader ->GetValue (),
6234
+ input->klv_reader ->GetValueSize (),
6235
+ num_samples
6236
+ );
6237
+ }
6209
6238
} else {
6210
6239
Frame *frame = input->wave_reader ->GetTrack (input_channel_index)->GetFrameBuffer ()->GetLastFrame (false );
6211
6240
BMX_ASSERT (frame);
0 commit comments