dpx: sanitize aspect ratio.
authorNicolas George <nicolas.george@normalesup.org>
Mon, 18 Jun 2012 09:39:26 +0000 (11:39 +0200)
committerNicolas George <nicolas.george@normalesup.org>
Wed, 4 Jul 2012 16:59:39 +0000 (18:59 +0200)
Fixes some samples where the ratio is declared as -1/-1.

libavcodec/dpx.c

index dee5921..76a12aa 100644 (file)
@@ -109,6 +109,12 @@ static int decode_frame(AVCodecContext *avctx,
     buf += 825;
     avctx->sample_aspect_ratio.num = read32(&buf, endian);
     avctx->sample_aspect_ratio.den = read32(&buf, endian);
+    if (avctx->sample_aspect_ratio.num > 0 && avctx->sample_aspect_ratio.den > 0)
+        av_reduce(&avctx->sample_aspect_ratio.num, &avctx->sample_aspect_ratio.den,
+                   avctx->sample_aspect_ratio.num,  avctx->sample_aspect_ratio.den,
+                  0x10000);
+    else
+        avctx->sample_aspect_ratio = (AVRational){ 0, 0 };
 
     switch (descriptor) {
         case 51: // RGBA