FFmpeg
Loading...
Searching...
No Matches
avdct.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 Michael Niedermayer <michaelni@gmx.at>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
22#include "libavutil/mem.h"
23#include "avcodec.h"
24#include "idctdsp.h"
25#include "fdctdsp.h"
26#include "pixblockdsp.h"
27#include "avdct.h"
28
29#define OFFSET(x) offsetof(AVDCT,x)
30#define DEFAULT 0 //should be NAN but it does not work as it is not a constant in glibc as required by ANSI/ISO C
31//these names are too long to be readable
32#define V AV_OPT_FLAG_VIDEO_PARAM
33#define A AV_OPT_FLAG_AUDIO_PARAM
34#define E AV_OPT_FLAG_ENCODING_PARAM
35#define D AV_OPT_FLAG_DECODING_PARAM
36
37static const AVOption avdct_options[] = {
38{"dct", "DCT algorithm", OFFSET(dct_algo), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|E, .unit = "dct"},
39{"auto", "autoselect a good one", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_AUTO }, INT_MIN, INT_MAX, V|E, .unit = "dct"},
40{"fastint", "fast integer (experimental / for debugging)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_FASTINT }, INT_MIN, INT_MAX, V|E, .unit = "dct"},
41{"int", "accurate integer", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_INT }, INT_MIN, INT_MAX, V|E, .unit = "dct"},
42{"mmx", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_MMX }, INT_MIN, INT_MAX, V|E, .unit = "dct"},
43{"altivec", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_ALTIVEC }, INT_MIN, INT_MAX, V|E, .unit = "dct"},
44{"faan", "floating point AAN DCT (experimental / for debugging)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_DCT_FAAN }, INT_MIN, INT_MAX, V|E, .unit = "dct"},
45
46{"idct", "select IDCT implementation", OFFSET(idct_algo), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, V|E|D, .unit = "idct"},
47{"auto", "autoselect a good one", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_AUTO }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
48{"int", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_INT }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
49{"simple", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLE }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
50{"simplemmx", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEMMX }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
51{"arm", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_ARM }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
52{"altivec", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_ALTIVEC }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
53{"simplearm", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEARM }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
54{"simplearmv5te", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEARMV5TE }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
55{"simplearmv6", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEARMV6 }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
56{"simpleneon", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLENEON }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
57{"xvid", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_XVID }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
58{"xvidmmx", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_XVID }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
59{"faani", "floating point AAN IDCT (experimental / for debugging)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_FAAN }, INT_MIN, INT_MAX, V|D|E, .unit = "idct"},
60{"simpleauto", "experimental / for debugging", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEAUTO }, INT_MIN, INT_MAX, V|E|D, .unit = "idct"},
61
62{"bits_per_sample", "", OFFSET(bits_per_sample), AV_OPT_TYPE_INT, {.i64 = 8 }, 0, 14, 0,},
63{NULL},
64};
65
66static const AVClass avdct_class = {
67 .class_name = "AVDCT",
68 .option = avdct_options,
69 .version = LIBAVUTIL_VERSION_INT,
70};
71
73{
74 return &avdct_class;
75}
76
78{
79 AVDCT *dsp = av_mallocz(sizeof(AVDCT));
80
81 if (!dsp)
82 return NULL;
83
84 dsp->av_class = &avdct_class;
86
87 return dsp;
88}
89
91{
93
94 if (!avctx)
95 return AVERROR(ENOMEM);
96
97 avctx->idct_algo = dsp->idct_algo;
98 avctx->dct_algo = dsp->dct_algo;
100
101#define COPY(src, name) memcpy(&dsp->name, &src.name, sizeof(dsp->name))
102
103#if CONFIG_IDCTDSP
104 {
105 IDCTDSPContext idsp = {0};
106 ff_idctdsp_init(&idsp, avctx);
107 COPY(idsp, idct);
108 COPY(idsp, idct_permutation);
109 }
110#endif
111
112#if CONFIG_FDCTDSP
113 {
114 FDCTDSPContext fdsp;
115 ff_fdctdsp_init(&fdsp, avctx);
116 COPY(fdsp, fdct);
117 }
118#endif
119
120#if CONFIG_PIXBLOCKDSP
121 {
124 COPY(pdsp, get_pixels);
125 COPY(pdsp, get_pixels_unaligned);
126 }
127#endif
128
129 avcodec_free_context(&avctx);
130
131 return 0;
132}
Libavcodec external API header.
#define FF_DCT_FASTINT
Definition avcodec.h:1532
#define FF_DCT_INT
Definition avcodec.h:1533
#define FF_IDCT_SIMPLEMMX
Definition avcodec.h:1548
#define FF_IDCT_SIMPLEARM
Definition avcodec.h:1551
#define FF_IDCT_ALTIVEC
Definition avcodec.h:1550
#define FF_IDCT_FAAN
Definition avcodec.h:1555
#define FF_IDCT_ARM
Definition avcodec.h:1549
#define FF_IDCT_AUTO
Definition avcodec.h:1545
#define FF_DCT_FAAN
Definition avcodec.h:1536
#define FF_IDCT_SIMPLEARMV6
Definition avcodec.h:1554
#define FF_IDCT_XVID
Definition avcodec.h:1552
#define FF_IDCT_SIMPLE
Definition avcodec.h:1547
#define FF_DCT_ALTIVEC
Definition avcodec.h:1535
#define FF_DCT_MMX
Definition avcodec.h:1534
#define FF_IDCT_INT
Definition avcodec.h:1546
#define FF_DCT_AUTO
Definition avcodec.h:1531
#define FF_IDCT_SIMPLEARMV5TE
Definition avcodec.h:1553
#define FF_IDCT_SIMPLEAUTO
Definition avcodec.h:1557
#define FF_IDCT_SIMPLENEON
Definition avcodec.h:1556
#define E
Definition avdct.c:34
static const AVOption avdct_options[]
Definition avdct.c:37
av_cold AVDCT * avcodec_dct_alloc(void)
Allocates a AVDCT context.
Definition avdct.c:77
#define DEFAULT
Definition avdct.c:30
#define COPY(src, name)
av_cold const AVClass * avcodec_dct_get_class(void)
Definition avdct.c:72
av_cold int avcodec_dct_init(AVDCT *dsp)
Definition avdct.c:90
#define OFFSET(x)
Definition avdct.c:29
static const AVClass avdct_class
Definition avdct.c:66
#define D
Definition avdct.c:35
#define V
Definition avdct.c:32
#define NULL
Definition coverity.c:32
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Definition options.c:149
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Definition options.c:164
#define AVERROR(e)
Definition error.h:45
#define LIBAVUTIL_VERSION_INT
Definition version.h:85
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition opt.c:1754
static void idct(int16_t block[64])
Definition 4xm.c:167
av_cold void ff_fdctdsp_init(FDCTDSPContext *c, AVCodecContext *avctx)
Definition fdctdsp.c:25
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
Definition idctdsp.c:228
av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, int bits_per_raw_sample)
Definition pixblockdsp.c:87
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
Memory handling functions.
Describe the class of an AVClass context structure.
Definition log.h:76
main external API structure.
Definition avcodec.h:443
int dct_algo
DCT algorithm, see FF_DCT_* below.
Definition avcodec.h:1530
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
Definition avcodec.h:1571
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
Definition avcodec.h:1544
AVDCT context.
Definition avdct.h:32
const AVClass * av_class
Definition avdct.h:33
int bits_per_sample
Definition avdct.h:72
int idct_algo
IDCT algorithm.
Definition avdct.h:66
int dct_algo
DCT algorithm.
Definition avdct.h:60
AVOption.
Definition opt.h:428
#define av_mallocz(s)