2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 * Library <2002> Ronald Bultje <rbultje@ronald.bitfreak.net>
4 * Copyright (C) 2007 David A. Schleef <ds@schleef.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
30 #include "gstvideometa.h"
34 * @short_description: Support library for video operations
38 * This library contains some helper functions and includes the
39 * videosink and videofilter base classes.
45 * gst_video_calculate_display_ratio:
46 * @dar_n: Numerator of the calculated display_ratio
47 * @dar_d: Denominator of the calculated display_ratio
48 * @video_width: Width of the video frame in pixels
49 * @video_height: Height of the video frame in pixels
50 * @video_par_n: Numerator of the pixel aspect ratio of the input video.
51 * @video_par_d: Denominator of the pixel aspect ratio of the input video.
52 * @display_par_n: Numerator of the pixel aspect ratio of the display device
53 * @display_par_d: Denominator of the pixel aspect ratio of the display device
55 * Given the Pixel Aspect Ratio and size of an input video frame, and the
56 * pixel aspect ratio of the intended display device, calculates the actual
57 * display ratio the video will be rendered with.
59 * Returns: A boolean indicating success and a calculated Display Ratio in the
60 * dar_n and dar_d parameters.
61 * The return value is FALSE in the case of integer overflow or other error.
64 gst_video_calculate_display_ratio (guint * dar_n, guint * dar_d,
65 guint video_width, guint video_height,
66 guint video_par_n, guint video_par_d,
67 guint display_par_n, guint display_par_d)
72 g_return_val_if_fail (dar_n != NULL, FALSE);
73 g_return_val_if_fail (dar_d != NULL, FALSE);
75 /* Calculate (video_width * video_par_n * display_par_d) /
76 * (video_height * video_par_d * display_par_n) */
77 if (!gst_util_fraction_multiply (video_width, video_height, video_par_n,
78 video_par_d, &tmp_n, &tmp_d))
81 if (!gst_util_fraction_multiply (tmp_n, tmp_d, display_par_d, display_par_n,
85 g_return_val_if_fail (num > 0, FALSE);
86 g_return_val_if_fail (den > 0, FALSE);
96 GST_WARNING ("overflow in multiply");
102 * gst_video_alignment_reset:
103 * @align: a #GstVideoAlignment
105 * Set @align to its default values with no padding and no alignment.
108 gst_video_alignment_reset (GstVideoAlignment * align)
112 g_return_if_fail (align != NULL);
114 align->padding_top = 0;
115 align->padding_bottom = 0;
116 align->padding_left = 0;
117 align->padding_right = 0;
118 for (i = 0; i < GST_VIDEO_MAX_PLANES; i++)
119 align->stride_align[i] = 0;