]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugins-ugly0-10.git/blob - gst-libs/gst/idct/idct.c
remove copyright field from plugins
[glsdk/gst-plugins-ugly0-10.git] / gst-libs / gst / idct / idct.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
24 #include <gst/gst.h>
25 #include <gst/idct/idct.h>
26 #include "dct.h"
28 static void gst_idct_int_sparse_idct(short *data);
30 GstIDCT *gst_idct_new(GstIDCTMethod method) 
31 {
32   GstIDCT *new = g_malloc(sizeof(GstIDCT));
34   new->need_transpose = FALSE;
36   if (method == GST_IDCT_DEFAULT) {
37 #ifdef HAVE_LIBMMX
38     if (gst_cpu_get_flags() & GST_CPU_FLAG_MMX) {
39       method = GST_IDCT_MMX;
40     }
41     /* disabled for now 
42     if (gst_cpu_get_flags() & GST_CPU_FLAG_SSE) {
43       method = GST_IDCT_SSE;
44     }
45     */
46     else
47 #endif /* HAVE_LIBMMX */
48     {
49       method = GST_IDCT_FAST_INT;
50     }
51   }
53   new->convert_sparse = gst_idct_int_sparse_idct;
55   switch (method) {
56          case GST_IDCT_FAST_INT:
57                 GST_INFO ( "using fast_int_idct");
58            gst_idct_init_fast_int_idct();
59                 new->convert = gst_idct_fast_int_idct;
60                 break;
61          case GST_IDCT_INT:
62                 GST_INFO ( "using int_idct");
63                 new->convert = gst_idct_int_idct;
64                 break;
65          case GST_IDCT_FLOAT:
66                 GST_INFO ( "using float_idct");
67                 gst_idct_init_float_idct();
68                 new->convert = gst_idct_float_idct;
69                 break;
70 #ifdef HAVE_LIBMMX
71          case GST_IDCT_MMX:
72                 GST_INFO ( "using MMX_idct");
73                 new->convert = gst_idct_mmx_idct;
74                 new->need_transpose = TRUE;
75                 break;
76          case GST_IDCT_MMX32:
77                 GST_INFO ( "using MMX32_idct");
78                 new->convert = gst_idct_mmx32_idct;
79                 new->need_transpose = TRUE;
80                 break;
81          case GST_IDCT_SSE:
82                 GST_INFO ( "using SSE_idct");
83                 new->convert = gst_idct_sse_idct;
84                 new->need_transpose = TRUE;
85                 break;
86 #endif /* HAVE_LIBMMX */
87          default:
88                 GST_INFO ( "method not supported");
89                 g_free(new);
90                 return NULL;
91   }
92   return new;
93 }
95 static void gst_idct_int_sparse_idct(short *data) 
96 {
97   short val;
98   gint32 v, *dp = (guint32 *)data;
100   v = *data;
102   if (v < 0) {
103     val = -v;
104     val += (8 >> 1);
105     val /= 8;
106     val = -val;
107   }
108   else {
109     val = (v + (8 >> 1)) / 8;
110   }
111   v = (( val & 0xffff) | (val << 16));
113   dp[0] = v;  dp[1] = v;  dp[2] = v;  dp[3] = v;
114   dp[4] = v;  dp[5] = v;  dp[6] = v;  dp[7] = v;
115   dp[8] = v;  dp[9] = v;  dp[10] = v; dp[11] = v;
116   dp[12] = v; dp[13] = v; dp[14] = v; dp[15] = v;
117   dp[16] = v; dp[17] = v; dp[18] = v; dp[19] = v;
118   dp[20] = v; dp[21] = v; dp[22] = v; dp[23] = v;
119   dp[24] = v; dp[25] = v; dp[26] = v; dp[27] = v;
120   dp[28] = v; dp[29] = v; dp[30] = v; dp[31] = v;
123 void gst_idct_destroy(GstIDCT *idct) 
125   g_return_if_fail(idct != NULL);
127   g_free(idct);
130 static gboolean
131 plugin_init (GstPlugin *plugin)
133   return TRUE;
136 GST_PLUGIN_DEFINE (
137   GST_VERSION_MAJOR,
138   GST_VERSION_MINOR,
139   "gstidct",
140   "Accelerated IDCT routines",
141   plugin_init,
142   VERSION,
143   GST_LICENSE,
144   GST_PACKAGE,
145   GST_ORIGIN