FFmpeg
idctdsp.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg 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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVCODEC_IDCTDSP_H
20 #define AVCODEC_IDCTDSP_H
21 
22 #include <stdint.h>
23 
24 #include "config.h"
25 
26 #include "avcodec.h"
27 
35 };
36 
37 void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64],
38  const uint8_t permutation[64]);
39 void ff_init_scantable_permutation(uint8_t *idct_permutation,
40  enum idct_permutation_type perm_type);
41 int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
42  enum idct_permutation_type perm_type);
43 
44 typedef struct IDCTDSPContext {
45  /* pixel ops : interface with DCT */
46  void (*put_pixels_clamped)(const int16_t *block /* align 16 */,
47  uint8_t *av_restrict pixels /* align 8 */,
48  ptrdiff_t line_size);
49  void (*put_signed_pixels_clamped)(const int16_t *block /* align 16 */,
50  uint8_t *av_restrict pixels /* align 8 */,
51  ptrdiff_t line_size);
52  void (*add_pixels_clamped)(const int16_t *block /* align 16 */,
53  uint8_t *av_restrict pixels /* align 8 */,
54  ptrdiff_t line_size);
55 
56  void (*idct)(int16_t *block /* align 16 */);
57 
58  /**
59  * block -> idct -> clip to unsigned 8 bit -> dest.
60  * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
61  * @param line_size size in bytes of a horizontal line of dest
62  */
63  void (*idct_put)(uint8_t *dest /* align 8 */,
64  ptrdiff_t line_size, int16_t *block /* align 16 */);
65 
66  /**
67  * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
68  * @param line_size size in bytes of a horizontal line of dest
69  */
70  void (*idct_add)(uint8_t *dest /* align 8 */,
71  ptrdiff_t line_size, int16_t *block /* align 16 */);
72 
73  /**
74  * IDCT input permutation.
75  * Several optimized IDCTs need a permutated input (relative to the
76  * normal order of the reference IDCT).
77  * This permutation must be performed before the idct_put/add.
78  * Note, normally this can be merged with the zigzag/alternate scan<br>
79  * An example to avoid confusion:
80  * - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...)
81  * - (x -> reference DCT -> reference IDCT -> x)
82  * - (x -> reference DCT -> simple_mmx_perm = idct_permutation
83  * -> simple_idct_mmx -> x)
84  * - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant
85  * -> simple_idct_mmx -> ...)
86  */
87  uint8_t idct_permutation[64];
89 
92 
93 void ff_put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
94  ptrdiff_t line_size);
95 void ff_add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels,
96  ptrdiff_t line_size);
97 
99 
101  unsigned high_bit_depth);
103  unsigned high_bit_depth);
105  unsigned high_bit_depth);
107  unsigned high_bit_depth);
109  unsigned high_bit_depth);
111  unsigned high_bit_depth);
113  unsigned high_bit_depth);
115  unsigned high_bit_depth);
116 
117 #endif /* AVCODEC_IDCTDSP_H */
ff_init_scantable_permutation_x86
int ff_init_scantable_permutation_x86(uint8_t *idct_permutation, enum idct_permutation_type perm_type)
Definition: idctdsp_init.c:42
ff_add_pixels_clamped_c
void ff_add_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
Definition: idctdsp.c:147
IDCTDSPContext::put_signed_pixels_clamped
void(* put_signed_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
Definition: idctdsp.h:49
ff_idctdsp_init_x86
void ff_idctdsp_init_x86(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth)
Definition: idctdsp_init.c:61
IDCTDSPContext::mpeg4_studio_profile
int mpeg4_studio_profile
Definition: idctdsp.h:90
ff_idctdsp_init_arm
void ff_idctdsp_init_arm(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth)
Definition: idctdsp_init_arm.c:66
IDCTDSPContext::idct_add
void(* idct_add)(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
Definition: idctdsp.h:70
IDCTDSPContext::idct
void(* idct)(int16_t *block)
Definition: idctdsp.h:56
IDCTDSPContext::idct_put
void(* idct_put)(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
Definition: idctdsp.h:63
ff_permute_scantable
void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64], const uint8_t permutation[64])
Definition: idctdsp.c:30
ff_init_scantable_permutation
void ff_init_scantable_permutation(uint8_t *idct_permutation, enum idct_permutation_type perm_type)
Definition: idctdsp.c:39
ff_idctdsp_init_mips
void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth)
Definition: idctdsp_init_mips.c:27
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
FF_IDCT_PERM_NONE
@ FF_IDCT_PERM_NONE
Definition: idctdsp.h:29
ff_idctdsp_init_aarch64
void ff_idctdsp_init_aarch64(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth)
Definition: idctdsp_init_aarch64.c:34
ff_idctdsp_init_riscv
void ff_idctdsp_init_riscv(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth)
Definition: idctdsp_init.c:36
ff_idctdsp_init_ppc
void ff_idctdsp_init_ppc(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth)
Definition: idctdsp.c:255
ff_idctdsp_init_loongarch
void ff_idctdsp_init_loongarch(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth)
Definition: idctdsp_init_loongarch.c:26
avcodec.h
FF_IDCT_PERM_TRANSPOSE
@ FF_IDCT_PERM_TRANSPOSE
Definition: idctdsp.h:32
ff_idctdsp_init_alpha
void ff_idctdsp_init_alpha(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth)
Definition: idctdsp_alpha.c:108
IDCTDSPContext
Definition: idctdsp.h:44
IDCTDSPContext::put_pixels_clamped
void(* put_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
Definition: idctdsp.h:46
FF_IDCT_PERM_SSE2
@ FF_IDCT_PERM_SSE2
Definition: idctdsp.h:34
AVCodecContext
main external API structure.
Definition: avcodec.h:426
FF_IDCT_PERM_PARTTRANS
@ FF_IDCT_PERM_PARTTRANS
Definition: idctdsp.h:33
idct_permutation_type
idct_permutation_type
Definition: idctdsp.h:28
IDCTDSPContext::perm_type
enum idct_permutation_type perm_type
Definition: idctdsp.h:88
IDCTDSPContext::idct_permutation
uint8_t idct_permutation[64]
IDCT input permutation.
Definition: idctdsp.h:87
IDCTDSPContext::add_pixels_clamped
void(* add_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
Definition: idctdsp.h:52
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
block
The exact code depends on how similar the blocks are and how related they are to the block
Definition: filter_design.txt:207
FF_IDCT_PERM_SIMPLE
@ FF_IDCT_PERM_SIMPLE
Definition: idctdsp.h:31
ff_idctdsp_init
void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
Definition: idctdsp.c:228
ff_put_pixels_clamped_c
void ff_put_pixels_clamped_c(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
Definition: idctdsp.c:73
FF_IDCT_PERM_LIBMPEG2
@ FF_IDCT_PERM_LIBMPEG2
Definition: idctdsp.h:30