matroskademux: fix pixel-aspect-ratio if header has only one display variable
authorAlexey Fisher <bug-track@fisher-privat.net>
Sat, 16 Jul 2011 17:38:51 +0000 (19:38 +0200)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sat, 16 Jul 2011 23:11:03 +0000 (00:11 +0100)
Current matroska demux calculates the pixel aspect ratio only if both
DisplayHeight and DisplayWidth are set, but it is legal to use only
one variable if the other is equal to PixelWidth or PixelHeight, at
least the mkclean utility is doing that. So this makse mkcleaned
files play correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=654744

gst/matroska/matroska-demux.c

index 9d2bf6e..9481ed9 100644 (file)
@@ -4873,16 +4873,20 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
       /* pixel width and height are the w and h of the video in pixels */
       if (videocontext->pixel_width > 0 && videocontext->pixel_height > 0) {
         gint w = videocontext->pixel_width;
-
         gint h = videocontext->pixel_height;
 
         gst_structure_set (structure,
             "width", G_TYPE_INT, w, "height", G_TYPE_INT, h, NULL);
       }
 
-      if (videocontext->display_width > 0 && videocontext->display_height > 0) {
+      if (videocontext->display_width > 0 || videocontext->display_height > 0) {
         int n, d;
 
+        if (videocontext->display_width <= 0)
+          videocontext->display_width = videocontext->pixel_width;
+        if (videocontext->display_height <= 0)
+          videocontext->display_height = videocontext->pixel_height;
+
         /* calculate the pixel aspect ratio using the display and pixel w/h */
         n = videocontext->display_width * videocontext->pixel_height;
         d = videocontext->display_height * videocontext->pixel_width;