1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * Format Conversion Utils 3cabdff1aSopenharmony_ci * Copyright (c) 2000, 2001 Fabrice Bellard 4cabdff1aSopenharmony_ci * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> 5cabdff1aSopenharmony_ci * 6cabdff1aSopenharmony_ci * This file is part of FFmpeg. 7cabdff1aSopenharmony_ci * 8cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 9cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 10cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 11cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 12cabdff1aSopenharmony_ci * 13cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 14cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 15cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16cabdff1aSopenharmony_ci * Lesser General Public License for more details. 17cabdff1aSopenharmony_ci * 18cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 19cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 20cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21cabdff1aSopenharmony_ci */ 22cabdff1aSopenharmony_ci 23cabdff1aSopenharmony_ci#include "config.h" 24cabdff1aSopenharmony_ci#include "libavutil/attributes.h" 25cabdff1aSopenharmony_ci#include "avcodec.h" 26cabdff1aSopenharmony_ci#include "fmtconvert.h" 27cabdff1aSopenharmony_ci 28cabdff1aSopenharmony_cistatic void int32_to_float_fmul_scalar_c(float *dst, const int32_t *src, 29cabdff1aSopenharmony_ci float mul, int len) 30cabdff1aSopenharmony_ci{ 31cabdff1aSopenharmony_ci int i; 32cabdff1aSopenharmony_ci for(i=0; i<len; i++) 33cabdff1aSopenharmony_ci dst[i] = src[i] * mul; 34cabdff1aSopenharmony_ci} 35cabdff1aSopenharmony_ci 36cabdff1aSopenharmony_cistatic void int32_to_float_c(float *dst, const int32_t *src, intptr_t len) 37cabdff1aSopenharmony_ci{ 38cabdff1aSopenharmony_ci int i; 39cabdff1aSopenharmony_ci 40cabdff1aSopenharmony_ci for (i = 0; i < len; i++) 41cabdff1aSopenharmony_ci dst[i] = (float)src[i]; 42cabdff1aSopenharmony_ci} 43cabdff1aSopenharmony_ci 44cabdff1aSopenharmony_cistatic void int32_to_float_fmul_array8_c(FmtConvertContext *c, float *dst, 45cabdff1aSopenharmony_ci const int32_t *src, const float *mul, 46cabdff1aSopenharmony_ci int len) 47cabdff1aSopenharmony_ci{ 48cabdff1aSopenharmony_ci int i; 49cabdff1aSopenharmony_ci for (i = 0; i < len; i += 8) 50cabdff1aSopenharmony_ci c->int32_to_float_fmul_scalar(&dst[i], &src[i], *mul++, 8); 51cabdff1aSopenharmony_ci} 52cabdff1aSopenharmony_ci 53cabdff1aSopenharmony_ciav_cold void ff_fmt_convert_init(FmtConvertContext *c, AVCodecContext *avctx) 54cabdff1aSopenharmony_ci{ 55cabdff1aSopenharmony_ci c->int32_to_float = int32_to_float_c; 56cabdff1aSopenharmony_ci c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c; 57cabdff1aSopenharmony_ci c->int32_to_float_fmul_array8 = int32_to_float_fmul_array8_c; 58cabdff1aSopenharmony_ci 59cabdff1aSopenharmony_ci#if ARCH_AARCH64 60cabdff1aSopenharmony_ci ff_fmt_convert_init_aarch64(c, avctx); 61cabdff1aSopenharmony_ci#elif ARCH_ARM 62cabdff1aSopenharmony_ci ff_fmt_convert_init_arm(c, avctx); 63cabdff1aSopenharmony_ci#elif ARCH_PPC 64cabdff1aSopenharmony_ci ff_fmt_convert_init_ppc(c, avctx); 65cabdff1aSopenharmony_ci#elif ARCH_X86 66cabdff1aSopenharmony_ci ff_fmt_convert_init_x86(c, avctx); 67cabdff1aSopenharmony_ci#endif 68cabdff1aSopenharmony_ci#if HAVE_MIPSFPU 69cabdff1aSopenharmony_ci ff_fmt_convert_init_mips(c); 70cabdff1aSopenharmony_ci#endif 71cabdff1aSopenharmony_ci} 72