File: dsp.c

package info (click to toggle)
gavl 1.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 14,912 kB
  • sloc: ansic: 437,319; sh: 10,487; makefile: 238
file content (84 lines) | stat: -rw-r--r-- 2,410 bytes parent folder | download | duplicates (3)
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
/*****************************************************************
 * gavl - a general purpose audio/video processing library
 *
 * Copyright (c) 2001 - 2011 Members of the Gmerlin project
 * gmerlin-general@lists.sourceforge.net
 * http://gmerlin.sourceforge.net
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * *****************************************************************/
#include <stdlib.h>
#include <string.h>

#include <config.h>
#include <gavl/gavl.h>
#include <gavl/gavldsp.h>
#include <dsp.h>
#include <accel.h>

static void init_table(gavl_dsp_context_t* ctx)
  {
  memset(&ctx->funcs, 0, sizeof(ctx->funcs));
  if(ctx->quality || (ctx->accel_flags & GAVL_ACCEL_C))
    gavl_dsp_init_c(&ctx->funcs, ctx->quality);
#ifdef HAVE_MMX
  if(ctx->accel_flags & GAVL_ACCEL_MMX)
    gavl_dsp_init_mmx(&ctx->funcs, ctx->quality);
  if(ctx->accel_flags & GAVL_ACCEL_MMXEXT)
    gavl_dsp_init_mmxext(&ctx->funcs, ctx->quality);
#endif       

#ifdef HAVE_SSE
  if(ctx->accel_flags & GAVL_ACCEL_SSE)
    gavl_dsp_init_sse(&ctx->funcs, ctx->quality);
#endif       

  }

gavl_dsp_context_t * gavl_dsp_context_create()
  {
  gavl_dsp_context_t * ret;
  ret = calloc(1, sizeof(*ret));
  ret->accel_flags = gavl_accel_supported();
  ret->quality = GAVL_QUALITY_DEFAULT;
  init_table(ret);
  return ret;
  }

void gavl_dsp_context_set_quality(gavl_dsp_context_t * ctx,
                                  int q)
  {
  ctx->quality = q;
  init_table(ctx);
  }

void gavl_dsp_context_set_accel_flags(gavl_dsp_context_t * ctx,
                                      int flags)
  {
  ctx->accel_flags = flags;
  init_table(ctx);
  }


gavl_dsp_funcs_t * 
gavl_dsp_context_get_funcs(gavl_dsp_context_t * ctx)
  {
  return &ctx->funcs;
  }

void gavl_dsp_context_destroy(gavl_dsp_context_t * ctx)
  {
  free(ctx);
  }