dither_init.c 2.2 KB
Newer Older
1 2 3
/*
 * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
 *
4
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7 8 9 10
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
11
 * FFmpeg is distributed in the hope that it will be useful,
12 13 14 15 16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * 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 19 20 21 22 23 24 25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#include "config.h"
#include "libavutil/cpu.h"
#include "libavutil/x86/cpu.h"
#include "libavresample/dither.h"

26
void ff_quantize_sse2(int16_t *dst, const float *src, float *dither, int len);
27

28 29
void ff_dither_int_to_float_rectangular_sse2(float *dst, int *src, int len);
void ff_dither_int_to_float_rectangular_avx(float *dst, int *src, int len);
30

31 32
void ff_dither_int_to_float_triangular_sse2(float *dst, int *src0, int len);
void ff_dither_int_to_float_triangular_avx(float *dst, int *src0, int len);
33

34 35 36
av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,
                                enum AVResampleDitherMethod method)
{
37
    int cpu_flags = av_get_cpu_flags();
38

39
    if (EXTERNAL_SSE2(cpu_flags)) {
40 41 42 43
        ddsp->quantize      = ff_quantize_sse2;
        ddsp->ptr_align     = 16;
        ddsp->samples_align = 8;
    }
44 45

    if (method == AV_RESAMPLE_DITHER_RECTANGULAR) {
46
        if (EXTERNAL_SSE2(cpu_flags)) {
47 48
            ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_sse2;
        }
49
        if (EXTERNAL_AVX(cpu_flags)) {
50 51 52
            ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_avx;
        }
    } else {
53
        if (EXTERNAL_SSE2(cpu_flags)) {
54 55
            ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_sse2;
        }
56
        if (EXTERNAL_AVX(cpu_flags)) {
57 58 59
            ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_avx;
        }
    }
60
}