LCOV - code coverage report
Current view: top level - src/libswresample/x86 - audio_convert_init.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 48 109 44.0 %
Date: 2017-08-17 10:06:07 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (C) 2012 Michael Niedermayer (michaelni@gmx.at)
       3             :  *
       4             :  * This file is part of libswresample
       5             :  *
       6             :  * libswresample is free software; you can redistribute it and/or
       7             :  * modify it under the terms of the GNU Lesser General Public
       8             :  * License as published by the Free Software Foundation; either
       9             :  * version 2.1 of the License, or (at your option) any later version.
      10             :  *
      11             :  * libswresample is distributed in the hope that it will be useful,
      12             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14             :  * Lesser General Public License for more details.
      15             :  *
      16             :  * You should have received a copy of the GNU Lesser General Public
      17             :  * License along with libswresample; if not, write to the Free Software
      18             :  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
      19             :  */
      20             : 
      21             : #include "libavutil/x86/cpu.h"
      22             : #include "libswresample/swresample_internal.h"
      23             : #include "libswresample/audioconvert.h"
      24             : 
      25             : #define PROTO(pre, in, out, cap) void ff ## pre ## in## _to_ ##out## _a_ ##cap(uint8_t **dst, const uint8_t **src, int len);
      26             : #define PROTO2(pre, out, cap) PROTO(pre, int16, out, cap) PROTO(pre, int32, out, cap) PROTO(pre, float, out, cap)
      27             : #define PROTO3(pre, cap) PROTO2(pre, int16, cap) PROTO2(pre, int32, cap) PROTO2(pre, float, cap)
      28             : #define PROTO4(pre) PROTO3(pre, mmx) PROTO3(pre, sse) PROTO3(pre, sse2) PROTO3(pre, ssse3) PROTO3(pre, sse4) PROTO3(pre, avx) PROTO3(pre, avx2)
      29             : PROTO4(_)
      30             : PROTO4(_pack_2ch_)
      31             : PROTO4(_pack_6ch_)
      32             : PROTO4(_pack_8ch_)
      33             : PROTO4(_unpack_2ch_)
      34             : PROTO4(_unpack_6ch_)
      35             : 
      36        1864 : av_cold void swri_audio_convert_init_x86(struct AudioConvert *ac,
      37             :                                  enum AVSampleFormat out_fmt,
      38             :                                  enum AVSampleFormat in_fmt,
      39             :                                  int channels){
      40        1864 :     int mm_flags = av_get_cpu_flags();
      41             : 
      42        1864 :     ac->simd_f= NULL;
      43             : 
      44             : //FIXME add memcpy case
      45             : 
      46             : #define MULTI_CAPS_FUNC(flag, cap) \
      47             :     if (EXTERNAL_##flag(mm_flags)) {\
      48             :         if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S16P)\
      49             :             ac->simd_f =  ff_int16_to_int32_a_ ## cap;\
      50             :         if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_S32P)\
      51             :             ac->simd_f =  ff_int32_to_int16_a_ ## cap;\
      52             :     }
      53             : 
      54        1864 : MULTI_CAPS_FUNC(MMX, mmx)
      55        1864 : MULTI_CAPS_FUNC(SSE2, sse2)
      56             : 
      57        1864 :     if(EXTERNAL_MMX(mm_flags)) {
      58          12 :         if(channels == 6) {
      59           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
      60           0 :                 ac->simd_f =  ff_pack_6ch_float_to_float_a_mmx;
      61             :         }
      62             :     }
      63        1864 :     if(EXTERNAL_SSE(mm_flags)) {
      64          12 :         if(channels == 6) {
      65           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
      66           0 :                 ac->simd_f =  ff_pack_6ch_float_to_float_a_sse;
      67             : 
      68           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
      69           0 :                 ac->simd_f =  ff_unpack_6ch_float_to_float_a_sse;
      70             :         }
      71             :     }
      72        1864 :     if(EXTERNAL_SSE2(mm_flags)) {
      73          12 :         if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
      74           0 :             ac->simd_f =  ff_int32_to_float_a_sse2;
      75          12 :         if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S16 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S16P)
      76           2 :             ac->simd_f =  ff_int16_to_float_a_sse2;
      77          12 :         if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
      78           0 :             ac->simd_f =  ff_float_to_int32_a_sse2;
      79          12 :         if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S16P && in_fmt == AV_SAMPLE_FMT_FLTP)
      80           0 :             ac->simd_f =  ff_float_to_int16_a_sse2;
      81             : 
      82          12 :         if(channels == 2) {
      83           3 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
      84           1 :                 ac->simd_f =  ff_pack_2ch_int32_to_int32_a_sse2;
      85           3 :             if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_S16P)
      86           0 :                 ac->simd_f =  ff_pack_2ch_int16_to_int16_a_sse2;
      87           3 :             if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_S16P)
      88           0 :                 ac->simd_f =  ff_pack_2ch_int16_to_int32_a_sse2;
      89           3 :             if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_S32P)
      90           0 :                 ac->simd_f =  ff_pack_2ch_int32_to_int16_a_sse2;
      91             : 
      92           3 :             if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
      93           0 :                 ac->simd_f =  ff_unpack_2ch_int32_to_int32_a_sse2;
      94           3 :             if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_S16)
      95           0 :                 ac->simd_f =  ff_unpack_2ch_int16_to_int16_a_sse2;
      96           3 :             if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_S16)
      97           0 :                 ac->simd_f =  ff_unpack_2ch_int16_to_int32_a_sse2;
      98           3 :             if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_S32)
      99           0 :                 ac->simd_f =  ff_unpack_2ch_int32_to_int16_a_sse2;
     100             : 
     101           3 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
     102           0 :                 ac->simd_f =  ff_pack_2ch_int32_to_float_a_sse2;
     103           3 :             if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
     104           0 :                 ac->simd_f =  ff_pack_2ch_float_to_int32_a_sse2;
     105           3 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S16P)
     106           0 :                 ac->simd_f =  ff_pack_2ch_int16_to_float_a_sse2;
     107           3 :             if(   out_fmt == AV_SAMPLE_FMT_S16  && in_fmt == AV_SAMPLE_FMT_FLTP)
     108           0 :                 ac->simd_f =  ff_pack_2ch_float_to_int16_a_sse2;
     109           3 :             if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S32)
     110           0 :                 ac->simd_f =  ff_unpack_2ch_int32_to_float_a_sse2;
     111           3 :             if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_FLT)
     112           0 :                 ac->simd_f =  ff_unpack_2ch_float_to_int32_a_sse2;
     113           3 :             if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S16)
     114           0 :                 ac->simd_f =  ff_unpack_2ch_int16_to_float_a_sse2;
     115           3 :             if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_FLT)
     116           0 :                 ac->simd_f =  ff_unpack_2ch_float_to_int16_a_sse2;
     117             :         }
     118          12 :         if(channels == 6) {
     119           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
     120           0 :                 ac->simd_f =  ff_pack_6ch_int32_to_float_a_sse2;
     121           0 :             if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
     122           0 :                 ac->simd_f =  ff_pack_6ch_float_to_int32_a_sse2;
     123             : 
     124           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S32)
     125           0 :                 ac->simd_f =  ff_unpack_6ch_int32_to_float_a_sse2;
     126           0 :             if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_FLT)
     127           0 :                 ac->simd_f =  ff_unpack_6ch_float_to_int32_a_sse2;
     128             :         }
     129          12 :         if(channels == 8) {
     130           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
     131           0 :                 ac->simd_f =  ff_pack_8ch_float_to_float_a_sse2;
     132           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
     133           0 :                 ac->simd_f =  ff_pack_8ch_int32_to_float_a_sse2;
     134           0 :             if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
     135           0 :                 ac->simd_f =  ff_pack_8ch_float_to_int32_a_sse2;
     136             :         }
     137             :     }
     138        1864 :     if(EXTERNAL_SSSE3(mm_flags)) {
     139          12 :         if(channels == 2) {
     140           3 :             if(   out_fmt == AV_SAMPLE_FMT_S16P  && in_fmt == AV_SAMPLE_FMT_S16)
     141           0 :                 ac->simd_f =  ff_unpack_2ch_int16_to_int16_a_ssse3;
     142           3 :             if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_S16)
     143           0 :                 ac->simd_f =  ff_unpack_2ch_int16_to_int32_a_ssse3;
     144           3 :             if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S16)
     145           0 :                 ac->simd_f =  ff_unpack_2ch_int16_to_float_a_ssse3;
     146             :         }
     147             :     }
     148        1864 :     if(EXTERNAL_AVX_FAST(mm_flags)) {
     149          12 :         if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32 || out_fmt == AV_SAMPLE_FMT_FLTP && in_fmt == AV_SAMPLE_FMT_S32P)
     150           0 :             ac->simd_f =  ff_int32_to_float_a_avx;
     151             :     }
     152        1864 :     if(EXTERNAL_AVX(mm_flags)) {
     153          12 :         if(channels == 6) {
     154           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
     155           0 :                 ac->simd_f =  ff_pack_6ch_float_to_float_a_avx;
     156           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
     157           0 :                 ac->simd_f =  ff_pack_6ch_int32_to_float_a_avx;
     158           0 :             if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
     159           0 :                 ac->simd_f =  ff_pack_6ch_float_to_int32_a_avx;
     160             : 
     161           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_S32)
     162           0 :                 ac->simd_f =  ff_unpack_6ch_float_to_float_a_avx;
     163           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLTP  && in_fmt == AV_SAMPLE_FMT_S32)
     164           0 :                 ac->simd_f =  ff_unpack_6ch_int32_to_float_a_avx;
     165           0 :             if(   out_fmt == AV_SAMPLE_FMT_S32P  && in_fmt == AV_SAMPLE_FMT_FLT)
     166           0 :                 ac->simd_f =  ff_unpack_6ch_float_to_int32_a_avx;
     167             :         }
     168          12 :         if(channels == 8) {
     169           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_FLTP || out_fmt == AV_SAMPLE_FMT_S32 && in_fmt == AV_SAMPLE_FMT_S32P)
     170           0 :                 ac->simd_f =  ff_pack_8ch_float_to_float_a_avx;
     171           0 :             if(   out_fmt == AV_SAMPLE_FMT_FLT  && in_fmt == AV_SAMPLE_FMT_S32P)
     172           0 :                 ac->simd_f =  ff_pack_8ch_int32_to_float_a_avx;
     173           0 :             if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLTP)
     174           0 :                 ac->simd_f =  ff_pack_8ch_float_to_int32_a_avx;
     175             :         }
     176             :     }
     177        1864 :     if(EXTERNAL_AVX2_FAST(mm_flags)) {
     178          12 :         if(   out_fmt == AV_SAMPLE_FMT_S32  && in_fmt == AV_SAMPLE_FMT_FLT || out_fmt == AV_SAMPLE_FMT_S32P && in_fmt == AV_SAMPLE_FMT_FLTP)
     179           0 :             ac->simd_f =  ff_float_to_int32_a_avx2;
     180             :     }
     181        1864 : }

Generated by: LCOV version 1.13