2002-03-20 21:45:03 +00:00
|
|
|
/* GStreamer
|
2001-12-23 19:40:53 +00:00
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-10-31 20:03:29 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2001-12-23 19:40:53 +00:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2001-12-23 20:14:18 +00:00
|
|
|
#include <gst/idct/idct.h>
|
2001-12-23 19:40:53 +00:00
|
|
|
#include "dct.h"
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void gst_idct_int_sparse_idct (short *data);
|
2001-12-23 19:40:53 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GstIDCT *
|
|
|
|
gst_idct_new (GstIDCTMethod method)
|
2001-12-23 19:40:53 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
GstIDCT *new = g_malloc (sizeof (GstIDCT));
|
2001-12-23 19:40:53 +00:00
|
|
|
|
|
|
|
new->need_transpose = FALSE;
|
|
|
|
|
|
|
|
if (method == GST_IDCT_DEFAULT) {
|
2004-08-09 21:21:25 +00:00
|
|
|
method = GST_IDCT_FAST_INT;
|
2001-12-23 19:40:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
new->convert_sparse = gst_idct_int_sparse_idct;
|
|
|
|
|
|
|
|
switch (method) {
|
2004-03-14 22:34:34 +00:00
|
|
|
case GST_IDCT_FAST_INT:
|
|
|
|
GST_INFO ("using fast_int_idct");
|
|
|
|
gst_idct_init_fast_int_idct ();
|
|
|
|
new->convert = gst_idct_fast_int_idct;
|
|
|
|
break;
|
|
|
|
case GST_IDCT_INT:
|
|
|
|
GST_INFO ("using int_idct");
|
|
|
|
new->convert = gst_idct_int_idct;
|
|
|
|
break;
|
|
|
|
case GST_IDCT_FLOAT:
|
|
|
|
GST_INFO ("using float_idct");
|
|
|
|
gst_idct_init_float_idct ();
|
|
|
|
new->convert = gst_idct_float_idct;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
GST_INFO ("method not supported");
|
|
|
|
g_free (new);
|
|
|
|
return NULL;
|
2001-12-23 19:40:53 +00:00
|
|
|
}
|
|
|
|
return new;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
static void
|
|
|
|
gst_idct_int_sparse_idct (short *data)
|
2001-12-23 19:40:53 +00:00
|
|
|
{
|
|
|
|
short val;
|
2004-03-14 22:34:34 +00:00
|
|
|
gint32 v, *dp = (guint32 *) data;
|
2001-12-23 19:40:53 +00:00
|
|
|
|
|
|
|
v = *data;
|
|
|
|
|
|
|
|
if (v < 0) {
|
|
|
|
val = -v;
|
|
|
|
val += (8 >> 1);
|
|
|
|
val /= 8;
|
|
|
|
val = -val;
|
2004-03-14 22:34:34 +00:00
|
|
|
} else {
|
2001-12-23 19:40:53 +00:00
|
|
|
val = (v + (8 >> 1)) / 8;
|
|
|
|
}
|
2004-03-14 22:34:34 +00:00
|
|
|
v = ((val & 0xffff) | (val << 16));
|
|
|
|
|
|
|
|
dp[0] = v;
|
|
|
|
dp[1] = v;
|
|
|
|
dp[2] = v;
|
|
|
|
dp[3] = v;
|
|
|
|
dp[4] = v;
|
|
|
|
dp[5] = v;
|
|
|
|
dp[6] = v;
|
|
|
|
dp[7] = v;
|
|
|
|
dp[8] = v;
|
|
|
|
dp[9] = v;
|
|
|
|
dp[10] = v;
|
|
|
|
dp[11] = v;
|
|
|
|
dp[12] = v;
|
|
|
|
dp[13] = v;
|
|
|
|
dp[14] = v;
|
|
|
|
dp[15] = v;
|
|
|
|
dp[16] = v;
|
|
|
|
dp[17] = v;
|
|
|
|
dp[18] = v;
|
|
|
|
dp[19] = v;
|
|
|
|
dp[20] = v;
|
|
|
|
dp[21] = v;
|
|
|
|
dp[22] = v;
|
|
|
|
dp[23] = v;
|
|
|
|
dp[24] = v;
|
|
|
|
dp[25] = v;
|
|
|
|
dp[26] = v;
|
|
|
|
dp[27] = v;
|
|
|
|
dp[28] = v;
|
|
|
|
dp[29] = v;
|
|
|
|
dp[30] = v;
|
|
|
|
dp[31] = v;
|
2001-12-23 19:40:53 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
void
|
|
|
|
gst_idct_destroy (GstIDCT * idct)
|
2001-12-23 19:40:53 +00:00
|
|
|
{
|
2004-03-14 22:34:34 +00:00
|
|
|
g_return_if_fail (idct != NULL);
|
2001-12-23 19:40:53 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
g_free (idct);
|
2001-12-23 19:40:53 +00:00
|
|
|
}
|
|
|
|
|
2002-03-24 20:55:44 +00:00
|
|
|
static gboolean
|
2004-03-14 22:34:34 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2002-03-24 20:55:44 +00:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"gstidct",
|
|
|
|
"Accelerated IDCT routines",
|
|
|
|
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN)
|