1 /*****************************************************************************
2 * va.c: hardware acceleration plugins for avcodec
3 *****************************************************************************
4 * Copyright (C) 2009 Laurent Aimar
5 * Copyright (C) 2012-2013 RĂ©mi Denis-Courmont
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation; either version 2.1 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
20 *****************************************************************************/
26 #include <vlc_common.h>
27 #include <vlc_modules.h>
28 #include <libavcodec/avcodec.h>
31 static int vlc_va_Start(void *func, va_list ap)
33 vlc_va_t *va = va_arg(ap, vlc_va_t *);
34 int codec = va_arg(ap, int);
35 const es_format_t *fmt = va_arg(ap, const es_format_t *);
36 int (*open)(vlc_va_t *, int, const es_format_t *) = func;
38 return open(va, codec, fmt);
41 static void vlc_va_Stop(void *func, va_list ap)
43 vlc_va_t *va = va_arg(ap, vlc_va_t *);
44 void (*close)(vlc_va_t *) = func;
49 vlc_va_t *vlc_va_New(vlc_object_t *obj, int codec_id, const es_format_t *fmt)
51 vlc_va_t *va = vlc_object_create(obj, sizeof (*va));
52 if (unlikely(va == NULL))
55 va->module = vlc_module_load(va, "hw decoder", "$avcodec-hw", true,
56 vlc_va_Start, va, codec_id, fmt);
57 if (va->module == NULL)
59 vlc_object_release(va);
65 void vlc_va_Delete(vlc_va_t *va)
67 vlc_module_unload(va->module, vlc_va_Stop, va);
68 vlc_object_release(va);