Mercurial > libavformat.hg
comparison mxfenc.c @ 4505:da04428a94db libavformat
fetch display aspect ratio from mpeg-2 essence
author | bcoudurier |
---|---|
date | Mon, 16 Feb 2009 12:48:45 +0000 |
parents | c0803ee07a93 |
children | 3aa54e7973d7 |
comparison
equal
deleted
inserted
replaced
4504:c0803ee07a93 | 4505:da04428a94db |
---|---|
66 int index; ///< index in mxf_essence_container_uls table | 66 int index; ///< index in mxf_essence_container_uls table |
67 const UID *codec_ul; | 67 const UID *codec_ul; |
68 int order; ///< interleaving order if dts are equal | 68 int order; ///< interleaving order if dts are equal |
69 int interlaced; ///< wether picture is interlaced | 69 int interlaced; ///< wether picture is interlaced |
70 int temporal_reordering; | 70 int temporal_reordering; |
71 AVRational aspect_ratio; ///< display aspect ratio | |
71 } MXFStreamContext; | 72 } MXFStreamContext; |
72 | 73 |
73 typedef struct { | 74 typedef struct { |
74 UID container_ul; | 75 UID container_ul; |
75 UID element_ul; | 76 UID element_ul; |
776 { | 777 { |
777 MXFStreamContext *sc = st->priv_data; | 778 MXFStreamContext *sc = st->priv_data; |
778 ByteIOContext *pb = s->pb; | 779 ByteIOContext *pb = s->pb; |
779 int stored_height = (st->codec->height+15)/16*16; | 780 int stored_height = (st->codec->height+15)/16*16; |
780 int display_height; | 781 int display_height; |
781 AVRational dar; | |
782 int f1, f2; | 782 int f1, f2; |
783 | 783 |
784 mxf_write_generic_desc(s, st, key, size); | 784 mxf_write_generic_desc(s, st, key, size); |
785 | 785 |
786 mxf_write_local_tag(pb, 4, 0x3203); | 786 mxf_write_local_tag(pb, 4, 0x3203); |
835 put_be32(pb, 4); | 835 put_be32(pb, 4); |
836 put_be32(pb, f1); | 836 put_be32(pb, f1); |
837 if (sc->interlaced) | 837 if (sc->interlaced) |
838 put_be32(pb, f2); | 838 put_be32(pb, f2); |
839 | 839 |
840 av_reduce(&dar.num, &dar.den, | |
841 st->codec->width*st->codec->sample_aspect_ratio.num, | |
842 st->codec->height*st->codec->sample_aspect_ratio.den, | |
843 1024*1024); | |
844 | |
845 mxf_write_local_tag(pb, 8, 0x320E); | 840 mxf_write_local_tag(pb, 8, 0x320E); |
846 put_be32(pb, dar.num); | 841 put_be32(pb, sc->aspect_ratio.num); |
847 put_be32(pb, dar.den); | 842 put_be32(pb, sc->aspect_ratio.den); |
848 | 843 |
849 mxf_write_local_tag(pb, 16, 0x3201); | 844 mxf_write_local_tag(pb, 16, 0x3201); |
850 put_buffer(pb, *sc->codec_ul, 16); | 845 put_buffer(pb, *sc->codec_ul, 16); |
851 } | 846 } |
852 | 847 |
1347 hours, minutes, seconds, mxf->timecode_drop_frame ? ';':':', frames); | 1342 hours, minutes, seconds, mxf->timecode_drop_frame ? ';':':', frames); |
1348 } | 1343 } |
1349 } | 1344 } |
1350 } else if (c == 0x1b3) { // seq | 1345 } else if (c == 0x1b3) { // seq |
1351 *flags |= 0x40; | 1346 *flags |= 0x40; |
1347 if (i + 4 < pkt->size) { | |
1348 switch ((pkt->data[i+4]>>4) & 0xf) { | |
1349 case 2: sc->aspect_ratio = (AVRational){ 4, 3}; break; | |
1350 case 3: sc->aspect_ratio = (AVRational){ 16, 9}; break; | |
1351 case 4: sc->aspect_ratio = (AVRational){221,100}; break; | |
1352 default: | |
1353 av_reduce(&sc->aspect_ratio.num, &sc->aspect_ratio.den, | |
1354 st->codec->width, st->codec->height, 1024*1024); | |
1355 } | |
1356 } | |
1352 } else if (c == 0x100) { // pic | 1357 } else if (c == 0x100) { // pic |
1353 int pict_type = (pkt->data[i+2]>>3) & 0x07; | 1358 int pict_type = (pkt->data[i+2]>>3) & 0x07; |
1354 if (pict_type == 2) { // P frame | 1359 if (pict_type == 2) { // P frame |
1355 *flags |= 0x22; | 1360 *flags |= 0x22; |
1356 st->codec->gop_size = 1; | 1361 st->codec->gop_size = 1; |