[FFmpeg-devel] [PATCH/RFC] honor DAR aspect ratio in nuv files.
Michael Niedermayer
michaelni
Sun Jun 8 21:44:34 CEST 2008
On Sun, Jun 08, 2008 at 08:50:05PM +0200, elupus wrote:
>
> >> Anyway, here is a updated patch that behavies just like official myth
> >> player (and actually works). It considers a value of 1.0, which the old
> >> muxers wrote, a DAR of 4:3.
> > [...]
> >> + av_reduce(&vst->codec->sample_aspect_ratio.num,
> >> + &vst->codec->sample_aspect_ratio.den,
> >> + height * aspect,
> >> + width, 255);
> >
> > this is wrong
> > converting height * aspect to an integer is nonsense
> >
> > [...]
>
> Right, missed that. This should be better, but i'm not sure what I should
> set the max num/den in av_reduce/av_d2q.
>
> Joakim
Content-Description: Attached file: 0001-The-aspect-stored-in-nuv-files-is-not-PAR-it-s-DAR.patch
> From eeccd8442fb4fc93bed7a43986ce1e5d0b8b8d53 Mon Sep 17 00:00:00 2001
> From: elupus <elupus at ecce.se>
> Date: Sun, 8 Jun 2008 20:29:34 +0200
> Subject: [PATCH] The aspect stored in nuv files is not PAR, it's DAR. Old muxers encode a hardcoded value of 1.0, which we interpret as a DAR of 4:3.
>
> ---
> libavformat/nuv.c | 10 +++++++++-
> 1 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/libavformat/nuv.c b/libavformat/nuv.c
> index 74393af..6cce6bd 100644
> --- a/libavformat/nuv.c
> +++ b/libavformat/nuv.c
> @@ -123,6 +123,7 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
> ByteIOContext *pb = s->pb;
> char id_string[12], version_string[5];
> double aspect, fps;
> + AVRational dar;
> int is_mythtv, width, height, v_packs, a_packs;
> int stream_nr = 0;
> AVStream *vst = NULL, *ast = NULL;
> @@ -137,6 +138,10 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
> get_byte(pb); // 'P' == progressive, 'I' == interlaced
> url_fskip(pb, 3); // padding
> aspect = av_int2dbl(get_le64(pb));
> + if(aspect > 0.9999 && aspect < 1.0001)
> + dar = (AVRational){4, 3};
> + else
> + dar = av_d2q(aspect, 10000);
> fps = av_int2dbl(get_le64(pb));
>
> // number of packets per stream type, -1 means unknown, e.g. streaming
> @@ -156,7 +161,10 @@ static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) {
> vst->codec->width = width;
> vst->codec->height = height;
> vst->codec->bits_per_sample = 10;
> - vst->codec->sample_aspect_ratio = av_d2q(aspect, 10000);
> + av_reduce(&vst->codec->sample_aspect_ratio.num,
> + &vst->codec->sample_aspect_ratio.den,
> + height * dar.num,
> + width * dar.den, 255);
if(aspect > 0.9999 && aspect < 1.0001)
aspect= 4.0/3.0;
vst->codec->sample_aspect_ratio = av_d2q(aspect*width/height);
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
There will always be a question for which you do not know the correct awnser.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080608/fd3cd77e/attachment.pgp>
More information about the ffmpeg-devel
mailing list