]> git.sesse.net Git - ffmpeg/commitdiff
mov: Prioritize aspect ratio values found in pasp atom
authorVittorio Giovara <vittorio.giovara@gmail.com>
Tue, 6 Apr 2021 16:15:49 +0000 (18:15 +0200)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Thu, 15 Apr 2021 14:21:58 +0000 (16:21 +0200)
From the ISO/IEC specification for MP4:
  The pixel aspect ratio and clean aperture of the video may be specified
  using the ‘pasp’ and ‘clap’ sample entry boxes, respectively. These are
  both optional; if present, they over-ride the declarations (if any) in
  structures specific to the video codec, which structures should be
  examined if these boxes are absent. For maximum compatibility, these
  boxes should follow, not precede, any boxes defined in or required by
  derived specifications.

Fixes trac/#7277.

libavformat/mov.c

index 43c55ef4a481f61278a2c27f280a5230ff8869bf..9ca1ac89a86f767d5448a49def40593bf942075c 100644 (file)
@@ -941,6 +941,7 @@ static int mov_read_wfex(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     return ret;
 }
 
+/* This atom overrides any previously set aspect ratio */
 static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
     const int num = avio_rb32(pb);
@@ -951,13 +952,7 @@ static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         return 0;
     st = c->fc->streams[c->fc->nb_streams-1];
 
-    if ((st->sample_aspect_ratio.den != 1 || st->sample_aspect_ratio.num) && // default
-        (den != st->sample_aspect_ratio.den || num != st->sample_aspect_ratio.num)) {
-        av_log(c->fc, AV_LOG_WARNING,
-               "sample aspect ratio already set to %d:%d, ignoring 'pasp' atom (%d:%d)\n",
-               st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
-               num, den);
-    } else if (den != 0) {
+    if (den != 0) {
         av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den,
                   num, den, 32767);
     }