yading@11
|
1 /*
|
yading@11
|
2 * Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
|
yading@11
|
3 *
|
yading@11
|
4 * This file is part of FFmpeg.
|
yading@11
|
5 *
|
yading@11
|
6 * FFmpeg is free software; you can redistribute it and/or
|
yading@11
|
7 * modify it under the terms of the GNU Lesser General Public
|
yading@11
|
8 * License as published by the Free Software Foundation; either
|
yading@11
|
9 * version 2.1 of the License, or (at your option) any later version.
|
yading@11
|
10 *
|
yading@11
|
11 * FFmpeg is distributed in the hope that it will be useful,
|
yading@11
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@11
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@11
|
14 * Lesser General Public License for more details.
|
yading@11
|
15 *
|
yading@11
|
16 * You should have received a copy of the GNU Lesser General Public
|
yading@11
|
17 * License along with FFmpeg; if not, write to the Free Software
|
yading@11
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@11
|
19 */
|
yading@11
|
20
|
yading@11
|
21 #include "config.h"
|
yading@11
|
22 #include "libavutil/cpu.h"
|
yading@11
|
23 #include "libavutil/x86/cpu.h"
|
yading@11
|
24 #include "libavresample/dither.h"
|
yading@11
|
25
|
yading@11
|
26 void ff_quantize_sse2(int16_t *dst, const float *src, float *dither, int len);
|
yading@11
|
27
|
yading@11
|
28 void ff_dither_int_to_float_rectangular_sse2(float *dst, int *src, int len);
|
yading@11
|
29 void ff_dither_int_to_float_rectangular_avx(float *dst, int *src, int len);
|
yading@11
|
30
|
yading@11
|
31 void ff_dither_int_to_float_triangular_sse2(float *dst, int *src0, int len);
|
yading@11
|
32 void ff_dither_int_to_float_triangular_avx(float *dst, int *src0, int len);
|
yading@11
|
33
|
yading@11
|
34 av_cold void ff_dither_init_x86(DitherDSPContext *ddsp,
|
yading@11
|
35 enum AVResampleDitherMethod method)
|
yading@11
|
36 {
|
yading@11
|
37 int mm_flags = av_get_cpu_flags();
|
yading@11
|
38
|
yading@11
|
39 if (EXTERNAL_SSE2(mm_flags)) {
|
yading@11
|
40 ddsp->quantize = ff_quantize_sse2;
|
yading@11
|
41 ddsp->ptr_align = 16;
|
yading@11
|
42 ddsp->samples_align = 8;
|
yading@11
|
43 }
|
yading@11
|
44
|
yading@11
|
45 if (method == AV_RESAMPLE_DITHER_RECTANGULAR) {
|
yading@11
|
46 if (EXTERNAL_SSE2(mm_flags)) {
|
yading@11
|
47 ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_sse2;
|
yading@11
|
48 }
|
yading@11
|
49 if (EXTERNAL_AVX(mm_flags)) {
|
yading@11
|
50 ddsp->dither_int_to_float = ff_dither_int_to_float_rectangular_avx;
|
yading@11
|
51 }
|
yading@11
|
52 } else {
|
yading@11
|
53 if (EXTERNAL_SSE2(mm_flags)) {
|
yading@11
|
54 ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_sse2;
|
yading@11
|
55 }
|
yading@11
|
56 if (EXTERNAL_AVX(mm_flags)) {
|
yading@11
|
57 ddsp->dither_int_to_float = ff_dither_int_to_float_triangular_avx;
|
yading@11
|
58 }
|
yading@11
|
59 }
|
yading@11
|
60 }
|