Mercurial > libavformat.hg
changeset 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 | dfb8f047b552 |
files | mxfenc.c |
diffstat | 1 files changed, 13 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mxfenc.c Mon Feb 16 10:44:38 2009 +0000 +++ b/mxfenc.c Mon Feb 16 12:48:45 2009 +0000 @@ -68,6 +68,7 @@ int order; ///< interleaving order if dts are equal int interlaced; ///< wether picture is interlaced int temporal_reordering; + AVRational aspect_ratio; ///< display aspect ratio } MXFStreamContext; typedef struct { @@ -778,7 +779,6 @@ ByteIOContext *pb = s->pb; int stored_height = (st->codec->height+15)/16*16; int display_height; - AVRational dar; int f1, f2; mxf_write_generic_desc(s, st, key, size); @@ -837,14 +837,9 @@ if (sc->interlaced) put_be32(pb, f2); - av_reduce(&dar.num, &dar.den, - st->codec->width*st->codec->sample_aspect_ratio.num, - st->codec->height*st->codec->sample_aspect_ratio.den, - 1024*1024); - mxf_write_local_tag(pb, 8, 0x320E); - put_be32(pb, dar.num); - put_be32(pb, dar.den); + put_be32(pb, sc->aspect_ratio.num); + put_be32(pb, sc->aspect_ratio.den); mxf_write_local_tag(pb, 16, 0x3201); put_buffer(pb, *sc->codec_ul, 16); @@ -1349,6 +1344,16 @@ } } else if (c == 0x1b3) { // seq *flags |= 0x40; + if (i + 4 < pkt->size) { + switch ((pkt->data[i+4]>>4) & 0xf) { + case 2: sc->aspect_ratio = (AVRational){ 4, 3}; break; + case 3: sc->aspect_ratio = (AVRational){ 16, 9}; break; + case 4: sc->aspect_ratio = (AVRational){221,100}; break; + default: + av_reduce(&sc->aspect_ratio.num, &sc->aspect_ratio.den, + st->codec->width, st->codec->height, 1024*1024); + } + } } else if (c == 0x100) { // pic int pict_type = (pkt->data[i+2]>>3) & 0x07; if (pict_type == 2) { // P frame