310
mxf_metadata_wave_audio_essence_descriptor_write_tags (MXFMetadataBase * m,
311
MXFPrimerPack * primer)
313
MXFMetadataWaveAudioEssenceDescriptor *self =
314
MXF_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR (m);
316
MXF_METADATA_BASE_CLASS
317
(mxf_metadata_wave_audio_essence_descriptor_parent_class)->write_tags (m,
320
static const guint8 block_align_ul[] = {
321
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
322
0x04, 0x02, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00
324
static const guint8 sequence_offset_ul[] = {
325
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
326
0x04, 0x02, 0x03, 0x02, 0x02, 0x00, 0x00, 0x00
328
static const guint8 avg_bps_ul[] = {
329
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
330
0x04, 0x02, 0x03, 0x03, 0x05, 0x00, 0x00, 0x00
332
static const guint8 channel_assignment_ul[] = {
333
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x07,
334
0x04, 0x02, 0x01, 0x01, 0x05, 0x00, 0x00, 0x00
336
static const guint8 peak_envelope_version_ul[] = {
337
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x08,
338
0x04, 0x02, 0x03, 0x01, 0x06, 0x00, 0x00, 0x00
340
static const guint8 peak_envelope_format_ul[] = {
341
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x08,
342
0x04, 0x02, 0x03, 0x01, 0x07, 0x00, 0x00, 0x00
344
static const guint8 points_per_peak_value_ul[] = {
345
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x08,
346
0x04, 0x02, 0x03, 0x01, 0x08, 0x00, 0x00, 0x00
348
static const guint8 peak_envelope_block_size_ul[] = {
349
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x08,
350
0x04, 0x02, 0x03, 0x01, 0x09, 0x00, 0x00, 0x00
352
static const guint8 peak_channels_ul[] = {
353
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x08,
354
0x04, 0x02, 0x03, 0x01, 0x0A, 0x00, 0x00, 0x00
356
static const guint8 peak_frames_ul[] = {
357
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x08,
358
0x04, 0x02, 0x03, 0x01, 0x0B, 0x00, 0x00, 0x00
360
static const guint8 peak_of_peaks_position_ul[] = {
361
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x08,
362
0x04, 0x02, 0x03, 0x01, 0x0C, 0x00, 0x00, 0x00
364
static const guint8 peak_envelope_timestamp_ul[] = {
365
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x08,
366
0x04, 0x02, 0x03, 0x01, 0x0D, 0x00, 0x00, 0x00
368
static const guint8 peak_envelope_data_ul[] = {
369
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x08,
370
0x04, 0x02, 0x03, 0x01, 0x0E, 0x00, 0x00, 0x00
373
t = g_slice_new0 (MXFLocalTag);
374
memcpy (&t->ul, &block_align_ul, 16);
376
t->data = g_slice_alloc (t->size);
378
GST_WRITE_UINT16_BE (t->data, self->block_align);
379
mxf_primer_pack_add_mapping (primer, 0x3d0a, &t->ul);
380
ret = g_list_prepend (ret, t);
382
if (self->sequence_offset) {
383
t = g_slice_new0 (MXFLocalTag);
384
memcpy (&t->ul, &sequence_offset_ul, 16);
386
t->data = g_slice_alloc (t->size);
388
GST_WRITE_UINT8 (t->data, self->sequence_offset);
389
mxf_primer_pack_add_mapping (primer, 0x3d0b, &t->ul);
390
ret = g_list_prepend (ret, t);
393
t = g_slice_new0 (MXFLocalTag);
394
memcpy (&t->ul, &avg_bps_ul, 16);
396
t->data = g_slice_alloc (t->size);
398
GST_WRITE_UINT32_BE (t->data, self->avg_bps);
399
mxf_primer_pack_add_mapping (primer, 0x3d09, &t->ul);
400
ret = g_list_prepend (ret, t);
402
if (!mxf_ul_is_zero (&self->channel_assignment)) {
403
t = g_slice_new0 (MXFLocalTag);
404
memcpy (&t->ul, &channel_assignment_ul, 16);
406
t->data = g_slice_alloc (t->size);
408
memcpy (t->data, &self->channel_assignment, 16);
409
mxf_primer_pack_add_mapping (primer, 0x3d32, &t->ul);
410
ret = g_list_prepend (ret, t);
413
if (self->peak_envelope_version) {
414
t = g_slice_new0 (MXFLocalTag);
415
memcpy (&t->ul, &peak_envelope_version_ul, 16);
417
t->data = g_slice_alloc (t->size);
419
GST_WRITE_UINT32_BE (t->data, self->peak_envelope_version);
420
mxf_primer_pack_add_mapping (primer, 0x3d29, &t->ul);
421
ret = g_list_prepend (ret, t);
424
if (self->peak_envelope_format) {
425
t = g_slice_new0 (MXFLocalTag);
426
memcpy (&t->ul, &peak_envelope_format_ul, 16);
428
t->data = g_slice_alloc (t->size);
430
GST_WRITE_UINT32_BE (t->data, self->peak_envelope_format);
431
mxf_primer_pack_add_mapping (primer, 0x3d2a, &t->ul);
432
ret = g_list_prepend (ret, t);
435
if (self->points_per_peak_value) {
436
t = g_slice_new0 (MXFLocalTag);
437
memcpy (&t->ul, &points_per_peak_value_ul, 16);
439
t->data = g_slice_alloc (t->size);
441
GST_WRITE_UINT32_BE (t->data, self->points_per_peak_value);
442
mxf_primer_pack_add_mapping (primer, 0x3d2b, &t->ul);
443
ret = g_list_prepend (ret, t);
446
if (self->peak_envelope_block_size) {
447
t = g_slice_new0 (MXFLocalTag);
448
memcpy (&t->ul, &peak_envelope_block_size_ul, 16);
450
t->data = g_slice_alloc (t->size);
452
GST_WRITE_UINT32_BE (t->data, self->peak_envelope_block_size);
453
mxf_primer_pack_add_mapping (primer, 0x3d2c, &t->ul);
454
ret = g_list_prepend (ret, t);
457
if (self->peak_channels) {
458
t = g_slice_new0 (MXFLocalTag);
459
memcpy (&t->ul, &peak_channels_ul, 16);
461
t->data = g_slice_alloc (t->size);
463
GST_WRITE_UINT32_BE (t->data, self->peak_channels);
464
mxf_primer_pack_add_mapping (primer, 0x3d2d, &t->ul);
465
ret = g_list_prepend (ret, t);
468
if (self->peak_frames) {
469
t = g_slice_new0 (MXFLocalTag);
470
memcpy (&t->ul, &peak_frames_ul, 16);
472
t->data = g_slice_alloc (t->size);
474
GST_WRITE_UINT32_BE (t->data, self->peak_frames);
475
mxf_primer_pack_add_mapping (primer, 0x3d2e, &t->ul);
476
ret = g_list_prepend (ret, t);
479
if (self->peak_of_peaks_position) {
480
t = g_slice_new0 (MXFLocalTag);
481
memcpy (&t->ul, &peak_of_peaks_position_ul, 16);
483
t->data = g_slice_alloc (t->size);
485
GST_WRITE_UINT64_BE (t->data, self->peak_of_peaks_position);
486
mxf_primer_pack_add_mapping (primer, 0x3d2f, &t->ul);
487
ret = g_list_prepend (ret, t);
490
if (!mxf_timestamp_is_unknown (&self->peak_envelope_timestamp)) {
491
t = g_slice_new0 (MXFLocalTag);
492
memcpy (&t->ul, &peak_envelope_timestamp_ul, 16);
494
t->data = g_slice_alloc (t->size);
496
mxf_timestamp_write (&self->peak_envelope_timestamp, t->data);
497
mxf_primer_pack_add_mapping (primer, 0x3d30, &t->ul);
498
ret = g_list_prepend (ret, t);
501
if (self->peak_envelope_data) {
502
t = g_slice_new0 (MXFLocalTag);
503
memcpy (&t->ul, &peak_envelope_data_ul, 16);
504
t->size = self->peak_envelope_data_length;
505
t->data = g_memdup (self->peak_envelope_data, t->size);
506
mxf_primer_pack_add_mapping (primer, 0x3d31, &t->ul);
507
ret = g_list_prepend (ret, t);
309
514
mxf_metadata_wave_audio_essence_descriptor_init
310
515
(MXFMetadataWaveAudioEssenceDescriptor * self)
916
mxf_metadata_aes3_audio_essence_descriptor_write_tags (MXFMetadataBase * m,
917
MXFPrimerPack * primer)
919
MXFMetadataAES3AudioEssenceDescriptor *self =
920
MXF_METADATA_AES3_AUDIO_ESSENCE_DESCRIPTOR (m);
922
MXF_METADATA_BASE_CLASS
923
(mxf_metadata_aes3_audio_essence_descriptor_parent_class)->write_tags (m,
926
static const guint8 emphasis_ul[] = {
927
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
928
0x04, 0x02, 0x05, 0x01, 0x06, 0x00, 0x00, 0x00
930
static const guint8 block_start_offset_ul[] = {
931
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
932
0x04, 0x02, 0x03, 0x02, 0x03, 0x00, 0x00, 0x00
934
static const guint8 auxiliary_bits_mode_ul[] = {
935
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
936
0x04, 0x02, 0x05, 0x01, 0x01, 0x00, 0x00, 0x00
938
static const guint8 channel_status_mode_ul[] = {
939
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
940
0x04, 0x02, 0x05, 0x01, 0x02, 0x00, 0x00, 0x00
942
static const guint8 fixed_channel_status_data_ul[] = {
943
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
944
0x04, 0x02, 0x05, 0x01, 0x03, 0x00, 0x00, 0x00
946
static const guint8 user_data_mode_ul[] = {
947
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
948
0x04, 0x02, 0x05, 0x01, 0x04, 0x00, 0x00, 0x00
950
static const guint8 fixed_user_data_ul[] = {
951
0x06, 0x0E, 0x2B, 0x34, 0x01, 0x01, 0x01, 0x05,
952
0x04, 0x02, 0x05, 0x01, 0x05, 0x00, 0x00, 0x00
955
if (self->emphasis) {
956
t = g_slice_new0 (MXFLocalTag);
957
memcpy (&t->ul, &emphasis_ul, 16);
959
t->data = g_slice_alloc (t->size);
961
GST_WRITE_UINT8 (t->data, self->emphasis);
962
mxf_primer_pack_add_mapping (primer, 0x3d0d, &t->ul);
963
ret = g_list_prepend (ret, t);
966
if (self->block_start_offset) {
967
t = g_slice_new0 (MXFLocalTag);
968
memcpy (&t->ul, &block_start_offset_ul, 16);
970
t->data = g_slice_alloc (t->size);
972
GST_WRITE_UINT16_BE (t->data, self->block_start_offset);
973
mxf_primer_pack_add_mapping (primer, 0x3d0f, &t->ul);
974
ret = g_list_prepend (ret, t);
977
if (self->auxiliary_bits_mode) {
978
t = g_slice_new0 (MXFLocalTag);
979
memcpy (&t->ul, &auxiliary_bits_mode_ul, 16);
981
t->data = g_slice_alloc (t->size);
983
GST_WRITE_UINT8 (t->data, self->auxiliary_bits_mode);
984
mxf_primer_pack_add_mapping (primer, 0x3d08, &t->ul);
985
ret = g_list_prepend (ret, t);
988
if (self->channel_status_mode) {
989
t = g_slice_new0 (MXFLocalTag);
990
memcpy (&t->ul, &channel_status_mode_ul, 16);
991
t->size = 8 + self->n_channel_status_mode;
992
t->data = g_slice_alloc (t->size);
994
GST_WRITE_UINT32_BE (t->data, self->n_channel_status_mode);
995
GST_WRITE_UINT32_BE (t->data + 4, 1);
996
memcpy (t->data + 8, self->channel_status_mode, t->size);
997
mxf_primer_pack_add_mapping (primer, 0x3d10, &t->ul);
998
ret = g_list_prepend (ret, t);
1001
if (self->fixed_channel_status_data) {
1004
t = g_slice_new0 (MXFLocalTag);
1005
memcpy (&t->ul, &fixed_channel_status_data_ul, 16);
1006
t->size = 8 + 24 * self->n_fixed_channel_status_data;
1007
t->data = g_slice_alloc (t->size);
1009
GST_WRITE_UINT32_BE (t->data, self->n_fixed_channel_status_data);
1010
GST_WRITE_UINT32_BE (t->data + 4, 24);
1011
for (i = 0; i < self->n_fixed_channel_status_data; i++)
1012
memcpy (t->data + 8 + 24 * i, self->fixed_channel_status_data[i], 24);
1013
mxf_primer_pack_add_mapping (primer, 0x3d11, &t->ul);
1014
ret = g_list_prepend (ret, t);
1017
if (self->user_data_mode) {
1018
t = g_slice_new0 (MXFLocalTag);
1019
memcpy (&t->ul, &user_data_mode_ul, 16);
1020
t->size = 8 + self->n_user_data_mode;
1021
t->data = g_slice_alloc (t->size);
1023
GST_WRITE_UINT32_BE (t->data, self->n_user_data_mode);
1024
GST_WRITE_UINT32_BE (t->data + 4, 1);
1025
memcpy (t->data + 8, self->user_data_mode, t->size);
1026
mxf_primer_pack_add_mapping (primer, 0x3d12, &t->ul);
1027
ret = g_list_prepend (ret, t);
1030
if (self->fixed_user_data) {
1033
t = g_slice_new0 (MXFLocalTag);
1034
memcpy (&t->ul, &fixed_user_data_ul, 16);
1035
t->size = 8 + 24 * self->n_fixed_user_data;
1036
t->data = g_slice_alloc (t->size);
1038
GST_WRITE_UINT32_BE (t->data, self->n_fixed_user_data);
1039
GST_WRITE_UINT32_BE (t->data + 4, 24);
1040
for (i = 0; i < self->n_fixed_user_data; i++)
1041
memcpy (t->data + 8 + 24 * i, self->fixed_user_data[i], 24);
1042
mxf_primer_pack_add_mapping (primer, 0x3d11, &t->ul);
1043
ret = g_list_prepend (ret, t);
710
1050
mxf_metadata_aes3_audio_essence_descriptor_init
1051
1393
mxf_aes_bwf_create_caps
1399
gint width, rate, channels;
1400
MXFFraction edit_rate;
1403
static GstFlowReturn
1404
mxf_bwf_write_func (GstBuffer * buffer, GstCaps * caps, gpointer mapping_data,
1405
GstAdapter * adapter, GstBuffer ** outbuf, gboolean flush)
1407
BWFMappingData *md = mapping_data;
1410
gst_util_uint64_scale (md->rate, md->edit_rate.d, md->edit_rate.n);
1412
md->error += (md->edit_rate.d * md->rate) % (md->edit_rate.n);
1413
if (md->error >= md->edit_rate.n) {
1418
bytes = (speu * md->channels * md->width) / 8;
1421
gst_adapter_push (adapter, buffer);
1423
if (gst_adapter_available (adapter) == 0)
1427
bytes = MIN (gst_adapter_available (adapter), bytes);
1429
if (gst_adapter_available (adapter) >= bytes) {
1430
*outbuf = gst_adapter_take_buffer (adapter, bytes);
1433
if (gst_adapter_available (adapter) >= bytes)
1434
return GST_FLOW_CUSTOM_SUCCESS;
1439
static const guint8 bwf_essence_container_ul[] = {
1440
0x06, 0x0e, 0x2b, 0x34, 0x04, 0x01, 0x01, 0x01,
1441
0x0d, 0x01, 0x03, 0x01, 0x02, 0x06, 0x01, 0x00
1444
static MXFMetadataFileDescriptor *
1445
mxf_bwf_get_descriptor (GstPadTemplate * tmpl, GstCaps * caps,
1446
MXFEssenceElementWriteFunc * handler, gpointer * mapping_data)
1448
MXFMetadataWaveAudioEssenceDescriptor *ret;
1451
gint width, rate, channels, endianness;
1453
s = gst_caps_get_structure (caps, 0);
1454
if (strcmp (gst_structure_get_name (s), "audio/x-raw-int") != 0 ||
1455
!gst_structure_get_int (s, "width", &width) ||
1456
!gst_structure_get_int (s, "rate", &rate) ||
1457
!gst_structure_get_int (s, "channels", &channels) ||
1458
!gst_structure_get_int (s, "endianness", &endianness)) {
1459
GST_ERROR ("Invalid caps %" GST_PTR_FORMAT, caps);
1463
ret = (MXFMetadataWaveAudioEssenceDescriptor *)
1464
gst_mini_object_new (MXF_TYPE_METADATA_WAVE_AUDIO_ESSENCE_DESCRIPTOR);
1466
memcpy (&ret->parent.parent.essence_container, &bwf_essence_container_ul, 16);
1467
if (endianness == G_LITTLE_ENDIAN)
1468
memcpy (&ret->parent.sound_essence_compression,
1469
&mxf_sound_essence_compression_uncompressed, 16);
1471
memcpy (&ret->parent.sound_essence_compression,
1472
&mxf_sound_essence_compression_aiff, 16);
1474
ret->block_align = (width / 8) * channels;
1475
ret->parent.quantization_bits = width;
1476
ret->avg_bps = ret->block_align * rate;
1478
if (!mxf_metadata_generic_sound_essence_descriptor_from_caps (&ret->parent,
1480
gst_mini_object_unref (GST_MINI_OBJECT_CAST (ret));
1484
*handler = mxf_bwf_write_func;
1486
md = g_new0 (BWFMappingData, 1);
1489
md->channels = channels;
1492
return (MXFMetadataFileDescriptor *) ret;
1496
mxf_bwf_update_descriptor (MXFMetadataFileDescriptor * d, GstCaps * caps,
1497
gpointer mapping_data, GstBuffer * buf)
1503
mxf_bwf_get_edit_rate (MXFMetadataFileDescriptor * a, GstCaps * caps,
1504
gpointer mapping_data, GstBuffer * buf, MXFMetadataSourcePackage * package,
1505
MXFMetadataTimelineTrack * track, MXFFraction * edit_rate)
1508
gdouble min = G_MAXDOUBLE;
1509
BWFMappingData *md = mapping_data;
1511
for (i = 0; i < package->parent.n_tracks; i++) {
1512
MXFMetadataTimelineTrack *tmp;
1514
if (!MXF_IS_METADATA_TIMELINE_TRACK (package->parent.tracks[i]) ||
1515
package->parent.tracks[i] == (MXFMetadataTrack *) track)
1518
tmp = MXF_METADATA_TIMELINE_TRACK (package->parent.tracks[i]);
1519
if (((gdouble) tmp->edit_rate.n) / ((gdouble) tmp->edit_rate.d) < min) {
1520
min = ((gdouble) tmp->edit_rate.n) / ((gdouble) tmp->edit_rate.d);
1521
memcpy (edit_rate, &tmp->edit_rate, sizeof (MXFFraction));
1525
if (min == G_MAXDOUBLE) {
1526
/* 100ms edit units */
1531
memcpy (&md->edit_rate, edit_rate, sizeof (MXFFraction));
1535
mxf_bwf_get_track_number_template (MXFMetadataFileDescriptor * a,
1536
GstCaps * caps, gpointer mapping_data)
1538
return (0x16 << 24) | (0x01 << 8);
1541
static MXFEssenceElementWriter mxf_bwf_essence_element_writer = {
1542
mxf_bwf_get_descriptor,
1543
mxf_bwf_update_descriptor,
1544
mxf_bwf_get_edit_rate,
1545
mxf_bwf_get_track_number_template,
1551
"audio/x-raw-int, " \
1552
"rate = (int) [ 1, MAX ], " \
1553
"channels = (int) [ 1, MAX ], " \
1554
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
1555
"width = (int) 32, " \
1556
"depth = (int) 32, " \
1557
"signed = (boolean) TRUE; " \
1558
"audio/x-raw-int, " \
1559
"rate = (int) [ 1, MAX ], " \
1560
"channels = (int) [ 1, MAX ], " \
1561
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
1562
"width = (int) 24, " \
1563
"depth = (int) 24, " \
1564
"signed = (boolean) TRUE; " \
1565
"audio/x-raw-int, " \
1566
"rate = (int) [ 1, MAX ], " \
1567
"channels = (int) [ 1, MAX ], " \
1568
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
1569
"width = (int) 16, " \
1570
"depth = (int) 16, " \
1571
"signed = (boolean) TRUE; " \
1572
"audio/x-raw-int, " \
1573
"rate = (int) [ 1, MAX ], " \
1574
"channels = (int) [ 1, MAX ], " \
1575
"endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \
1576
"width = (int) 8, " \
1577
"depth = (int) 8, " \
1578
"signed = (boolean) FALSE"
1055
1581
mxf_aes_bwf_init (void)