summaryrefslogtreecommitdiff
path: root/sys/vdpau/gstvdputils.c
blob: 21c5cc2a43b80b4b35d62afeb8fecc1428e72bcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* 
 * GStreamer
 * Copyright (C) 2009 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <gst/vdpau/gstvdpvideobuffer.h>

#include "gstvdputils.h"

GstCaps *
gst_vdp_yuv_to_output_caps (GstCaps * caps)
{
  GstCaps *result;
  gint i;

  result = gst_caps_copy (caps);
  for (i = 0; i < gst_caps_get_size (caps); i++) {
    GstStructure *structure, *rgb_structure;

    structure = gst_caps_get_structure (result, i);
    rgb_structure = gst_structure_copy (structure);

    gst_structure_set_name (structure, "video/x-vdpau-output");
    gst_structure_remove_field (structure, "format");

    gst_structure_set_name (rgb_structure, "video/x-raw-rgb");
    gst_structure_remove_field (rgb_structure, "format");
    gst_caps_append_structure (result, rgb_structure);
  }

  return result;
}

GstCaps *
gst_vdp_video_to_output_caps (GstCaps * caps)
{
  GstCaps *result;
  gint i;

  result = gst_caps_copy (caps);
  for (i = 0; i < gst_caps_get_size (caps); i++) {

    GstStructure *structure, *rgb_structure;
    gint par_n, par_d;

    structure = gst_caps_get_structure (result, i);
    rgb_structure = gst_structure_copy (structure);

    gst_structure_set_name (structure, "video/x-vdpau-output");
    gst_structure_remove_field (structure, "chroma-type");

    if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n,
            &par_d)) {
      gint width;

      gst_structure_get_int (structure, "width", &width);
      width = gst_util_uint64_scale_int (width, par_n, par_d);
      gst_structure_set (structure, "width", G_TYPE_INT, width, NULL);

      gst_structure_remove_field (structure, "pixel-aspect-ratio");
    }

    gst_structure_set_name (rgb_structure, "video/x-raw-rgb");
    gst_structure_remove_field (rgb_structure, "chroma-type");
    gst_caps_append_structure (result, rgb_structure);
  }

  return result;
}