[FFmpeg-cvslog] avformat/matroskadec: don't infer display dimensions when DisplayUnit is not pixels

James Almer git at videolan.org
Mon Jul 8 19:31:03 EEST 2024


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Sun Jul  7 16:51:02 2024 -0300| [dc763efe70a3a8999bea81f788a2629ca95de9c9] | committer: James Almer

avformat/matroskadec: don't infer display dimensions when DisplayUnit is not pixels

The spec doesn't define a default value for other values of DisplayUnit.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc763efe70a3a8999bea81f788a2629ca95de9c9
---

 libavformat/matroskadec.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index d1a135ed63..33de5bc4e9 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2965,7 +2965,8 @@ static int mkv_parse_video(MatroskaTrack *track, AVStream *st,
                                     &display_width_mul, &display_height_mul);
 
     if (track->video.display_unit < MATROSKA_VIDEO_DISPLAYUNIT_UNKNOWN) {
-        if (track->video.display_width && track->video.display_height &&
+        if (track->video.display_width       && track->video.display_height &&
+            track->video.display_width != -1 && track->video.display_height != -1 &&
             par->height  < INT64_MAX / track->video.display_width  / display_width_mul &&
             par->width   < INT64_MAX / track->video.display_height / display_height_mul)
             av_reduce(&st->sample_aspect_ratio.num,
@@ -3139,10 +3140,12 @@ static int matroska_parse_tracks(AVFormatContext *s)
                     track->default_duration = default_duration;
                 }
             }
-            if (track->video.display_width == -1)
-                track->video.display_width = track->video.pixel_width;
-            if (track->video.display_height == -1)
-                track->video.display_height = track->video.pixel_height;
+            if (track->video.display_unit == MATROSKA_VIDEO_DISPLAYUNIT_PIXELS) {
+                if (track->video.display_width == -1)
+                    track->video.display_width = track->video.pixel_width;
+                if (track->video.display_height == -1)
+                    track->video.display_height = track->video.pixel_height;
+            }
         } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
             if (!track->audio.out_samplerate)
                 track->audio.out_samplerate = track->audio.samplerate;



More information about the ffmpeg-cvslog mailing list