dsputil_init_arm.c 5.29 KB
Newer Older
Fabrice Bellard's avatar
Fabrice Bellard committed
1
/*
2
 * ARM optimized DSP utils
3
 * Copyright (c) 2001 Lionel Ulmer
Fabrice Bellard's avatar
Fabrice Bellard committed
4
 *
5 6 7
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
8 9
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
Fabrice Bellard's avatar
Fabrice Bellard committed
11
 *
12
 * FFmpeg is distributed in the hope that it will be useful,
Fabrice Bellard's avatar
Fabrice Bellard committed
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
Fabrice Bellard's avatar
Fabrice Bellard committed
16
 *
17
 * You should have received a copy of the GNU Lesser General Public
18
 * License along with FFmpeg; if not, write to the Free Software
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Fabrice Bellard's avatar
Fabrice Bellard committed
20 21
 */

22
#include "libavcodec/dsputil.h"
23
#include "dsputil_arm.h"
Fabrice Bellard's avatar
Fabrice Bellard committed
24

25 26
void ff_j_rev_dct_arm(DCTELEM *data);
void ff_simple_idct_arm(DCTELEM *data);
Fabrice Bellard's avatar
Fabrice Bellard committed
27

28 29 30 31
/* XXX: local hack */
static void (*ff_put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);
static void (*ff_add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size);

32 33 34 35
void ff_put_pixels8_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
void ff_put_pixels8_x2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
void ff_put_pixels8_y2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
void ff_put_pixels8_xy2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
36

37 38 39
void ff_put_no_rnd_pixels8_x2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
void ff_put_no_rnd_pixels8_y2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
void ff_put_no_rnd_pixels8_xy2_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
40

41
void ff_put_pixels16_arm(uint8_t *block, const uint8_t *pixels, int line_size, int h);
42

43 44 45 46 47 48
CALL_2X_PIXELS(ff_put_pixels16_x2_arm,         ff_put_pixels8_x2_arm,        8)
CALL_2X_PIXELS(ff_put_pixels16_y2_arm,         ff_put_pixels8_y2_arm,        8)
CALL_2X_PIXELS(ff_put_pixels16_xy2_arm,        ff_put_pixels8_xy2_arm,       8)
CALL_2X_PIXELS(ff_put_no_rnd_pixels16_x2_arm,  ff_put_no_rnd_pixels8_x2_arm, 8)
CALL_2X_PIXELS(ff_put_no_rnd_pixels16_y2_arm,  ff_put_no_rnd_pixels8_y2_arm, 8)
CALL_2X_PIXELS(ff_put_no_rnd_pixels16_xy2_arm, ff_put_no_rnd_pixels8_xy2_arm,8)
49

50
void ff_add_pixels_clamped_arm(const DCTELEM *block, uint8_t *dest,
51
                               int line_size);
52

53 54
/* XXX: those functions should be suppressed ASAP when all IDCTs are
   converted */
55
static void j_rev_dct_arm_put(uint8_t *dest, int line_size, DCTELEM *block)
56
{
57
    ff_j_rev_dct_arm (block);
58 59
    ff_put_pixels_clamped(block, dest, line_size);
}
60
static void j_rev_dct_arm_add(uint8_t *dest, int line_size, DCTELEM *block)
61
{
62
    ff_j_rev_dct_arm (block);
63 64
    ff_add_pixels_clamped(block, dest, line_size);
}
65
static void simple_idct_arm_put(uint8_t *dest, int line_size, DCTELEM *block)
66
{
67
    ff_simple_idct_arm (block);
68 69
    ff_put_pixels_clamped(block, dest, line_size);
}
70
static void simple_idct_arm_add(uint8_t *dest, int line_size, DCTELEM *block)
71
{
72
    ff_simple_idct_arm (block);
73 74
    ff_add_pixels_clamped(block, dest, line_size);
}
75

76 77
int mm_support(void)
{
78
    return HAVE_IWMMXT * AV_CPU_FLAG_IWMMXT;
79 80
}

81
void dsputil_init_arm(DSPContext* c, AVCodecContext *avctx)
Fabrice Bellard's avatar
Fabrice Bellard committed
82
{
83 84 85
    ff_put_pixels_clamped = c->put_pixels_clamped;
    ff_add_pixels_clamped = c->add_pixels_clamped;

Måns Rullgård's avatar
Måns Rullgård committed
86
    if (!avctx->lowres) {
87 88
        if(avctx->idct_algo == FF_IDCT_AUTO ||
           avctx->idct_algo == FF_IDCT_ARM){
89 90 91
            c->idct_put              = j_rev_dct_arm_put;
            c->idct_add              = j_rev_dct_arm_add;
            c->idct                  = ff_j_rev_dct_arm;
Måns Rullgård's avatar
Måns Rullgård committed
92 93
            c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
        } else if (avctx->idct_algo == FF_IDCT_SIMPLEARM){
94 95 96
            c->idct_put              = simple_idct_arm_put;
            c->idct_add              = simple_idct_arm_add;
            c->idct                  = ff_simple_idct_arm;
Måns Rullgård's avatar
Måns Rullgård committed
97
            c->idct_permutation_type = FF_NO_IDCT_PERM;
98
        }
99
    }
100

101
    c->add_pixels_clamped = ff_add_pixels_clamped_arm;
102

103 104 105 106 107 108 109 110
    c->put_pixels_tab[0][0] = ff_put_pixels16_arm;
    c->put_pixels_tab[0][1] = ff_put_pixels16_x2_arm;
    c->put_pixels_tab[0][2] = ff_put_pixels16_y2_arm;
    c->put_pixels_tab[0][3] = ff_put_pixels16_xy2_arm;
    c->put_pixels_tab[1][0] = ff_put_pixels8_arm;
    c->put_pixels_tab[1][1] = ff_put_pixels8_x2_arm;
    c->put_pixels_tab[1][2] = ff_put_pixels8_y2_arm;
    c->put_pixels_tab[1][3] = ff_put_pixels8_xy2_arm;
Måns Rullgård's avatar
Måns Rullgård committed
111

112 113 114 115 116 117 118 119
    c->put_no_rnd_pixels_tab[0][0] = ff_put_pixels16_arm;
    c->put_no_rnd_pixels_tab[0][1] = ff_put_no_rnd_pixels16_x2_arm;
    c->put_no_rnd_pixels_tab[0][2] = ff_put_no_rnd_pixels16_y2_arm;
    c->put_no_rnd_pixels_tab[0][3] = ff_put_no_rnd_pixels16_xy2_arm;
    c->put_no_rnd_pixels_tab[1][0] = ff_put_pixels8_arm;
    c->put_no_rnd_pixels_tab[1][1] = ff_put_no_rnd_pixels8_x2_arm;
    c->put_no_rnd_pixels_tab[1][2] = ff_put_no_rnd_pixels8_y2_arm;
    c->put_no_rnd_pixels_tab[1][3] = ff_put_no_rnd_pixels8_xy2_arm;
120

121 122
    if (HAVE_ARMV5TE) ff_dsputil_init_armv5te(c, avctx);
    if (HAVE_ARMV6)   ff_dsputil_init_armv6(c, avctx);
123
    if (HAVE_IWMMXT)  ff_dsputil_init_iwmmxt(c, avctx);
124 125
    if (HAVE_ARMVFP)  ff_dsputil_init_vfp(c, avctx);
    if (HAVE_NEON)    ff_dsputil_init_neon(c, avctx);
Fabrice Bellard's avatar
Fabrice Bellard committed
126
}