comparison mxfenc.c @ 4376:2b46680bf82f libavformat

always write mxf time base in descriptors
author bcoudurier
date Wed, 04 Feb 2009 09:35:59 +0000
parents 1664a812629f
children 490fde1dcbe5
comparison
equal deleted inserted replaced
4375:ecc817a37849 4376:2b46680bf82f
571 put_be32(pb, st->index); 571 put_be32(pb, st->index);
572 } 572 }
573 573
574 static void mxf_write_multi_descriptor(AVFormatContext *s) 574 static void mxf_write_multi_descriptor(AVFormatContext *s)
575 { 575 {
576 MXFContext *mxf = s->priv_data;
576 ByteIOContext *pb = s->pb; 577 ByteIOContext *pb = s->pb;
577 int i; 578 int i;
578 579
579 mxf_write_metadata_key(pb, 0x014400); 580 mxf_write_metadata_key(pb, 0x014400);
580 PRINT_KEY(s, "multiple descriptor key", pb->buf_ptr - 16); 581 PRINT_KEY(s, "multiple descriptor key", pb->buf_ptr - 16);
584 mxf_write_uuid(pb, MultipleDescriptor, 0); 585 mxf_write_uuid(pb, MultipleDescriptor, 0);
585 PRINT_KEY(s, "multi_desc uid", pb->buf_ptr - 16); 586 PRINT_KEY(s, "multi_desc uid", pb->buf_ptr - 16);
586 587
587 // write sample rate 588 // write sample rate
588 mxf_write_local_tag(pb, 8, 0x3001); 589 mxf_write_local_tag(pb, 8, 0x3001);
589 put_be32(pb, s->streams[0]->time_base.den); 590 put_be32(pb, mxf->time_base.den);
590 put_be32(pb, s->streams[0]->time_base.num); 591 put_be32(pb, mxf->time_base.num);
591 592
592 // write essence container ul 593 // write essence container ul
593 mxf_write_local_tag(pb, 16, 0x3004); 594 mxf_write_local_tag(pb, 16, 0x3004);
594 put_buffer(pb, multiple_desc_ul, 16); 595 put_buffer(pb, multiple_desc_ul, 16);
595 596
598 mxf_write_refs_count(pb, s->nb_streams); 599 mxf_write_refs_count(pb, s->nb_streams);
599 for (i = 0; i < s->nb_streams; i++) 600 for (i = 0; i < s->nb_streams; i++)
600 mxf_write_uuid(pb, SubDescriptor, i); 601 mxf_write_uuid(pb, SubDescriptor, i);
601 } 602 }
602 603
603 static void mxf_write_generic_desc(ByteIOContext *pb, AVStream *st, const UID key, unsigned size) 604 static void mxf_write_generic_desc(AVFormatContext *s, AVStream *st, const UID key, unsigned size)
604 { 605 {
606 MXFContext *mxf = s->priv_data;
605 MXFStreamContext *sc = st->priv_data; 607 MXFStreamContext *sc = st->priv_data;
608 ByteIOContext *pb = s->pb;
606 609
607 put_buffer(pb, key, 16); 610 put_buffer(pb, key, 16);
608 klv_encode_ber_length(pb, size); 611 klv_encode_ber_length(pb, size);
609 612
610 mxf_write_local_tag(pb, 16, 0x3C0A); 613 mxf_write_local_tag(pb, 16, 0x3C0A);
612 615
613 mxf_write_local_tag(pb, 4, 0x3006); 616 mxf_write_local_tag(pb, 4, 0x3006);
614 put_be32(pb, st->index); 617 put_be32(pb, st->index);
615 618
616 mxf_write_local_tag(pb, 8, 0x3001); 619 mxf_write_local_tag(pb, 8, 0x3001);
617 put_be32(pb, st->time_base.den); 620 put_be32(pb, mxf->time_base.den);
618 put_be32(pb, st->time_base.num); 621 put_be32(pb, mxf->time_base.num);
619 622
620 mxf_write_local_tag(pb, 16, 0x3004); 623 mxf_write_local_tag(pb, 16, 0x3004);
621 put_buffer(pb, mxf_essence_container_uls[sc->index].container_ul, 16); 624 put_buffer(pb, mxf_essence_container_uls[sc->index].container_ul, 16);
622 } 625 }
623 626
631 ByteIOContext *pb = s->pb; 634 ByteIOContext *pb = s->pb;
632 int stored_height = (st->codec->height+15)/16*16; 635 int stored_height = (st->codec->height+15)/16*16;
633 AVRational dar; 636 AVRational dar;
634 int f1, f2; 637 int f1, f2;
635 638
636 mxf_write_generic_desc(pb, st, mxf_mpegvideo_descriptor_key, 153+sc->interlaced*4); 639 mxf_write_generic_desc(s, st, mxf_mpegvideo_descriptor_key, 153+sc->interlaced*4);
637 640
638 mxf_write_local_tag(pb, 4, 0x3203); 641 mxf_write_local_tag(pb, 4, 0x3203);
639 put_be32(pb, st->codec->width); 642 put_be32(pb, st->codec->width);
640 643
641 mxf_write_local_tag(pb, 4, 0x3202); 644 mxf_write_local_tag(pb, 4, 0x3202);
693 696
694 static void mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st, const UID key, unsigned size) 697 static void mxf_write_generic_sound_desc(AVFormatContext *s, AVStream *st, const UID key, unsigned size)
695 { 698 {
696 ByteIOContext *pb = s->pb; 699 ByteIOContext *pb = s->pb;
697 700
698 mxf_write_generic_desc(pb, st, key, size); 701 mxf_write_generic_desc(s, st, key, size);
699 702
700 // audio locked 703 // audio locked
701 mxf_write_local_tag(pb, 1, 0x3D02); 704 mxf_write_local_tag(pb, 1, 0x3D02);
702 put_byte(pb, 1); 705 put_byte(pb, 1);
703 706