Dev/ONScripter/onscripter_android/jni/sdl/src/audio/SDL_audiocvt.c
/*
 * Find a converter between two data types. We try to select a hand-tuned
 *  asm/vectorized/optimized function first, and then fallback to an
 *  autogenerated function that is customized to convert between two
 *  specific data types.
 */
Find a converter between two data types. We try to select a hand-tuned
asm/vectorized/optimized function first, and then fallback to an
autogenerated function that is customized to convert between two
specific data types.
Find a converter between two data types . We try to select a hand - tuned asm / vectorized / optimized function first and then fallback to an autogenerated function that is customized to convert between two specific data types .
static int
SDL_BuildAudioTypeCVT(SDL_AudioCVT * cvt,
                      SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
{
    if (src_fmt != dst_fmt) {
        const Uint16 src_bitsize = SDL_AUDIO_BITSIZE(src_fmt);
        const Uint16 dst_bitsize = SDL_AUDIO_BITSIZE(dst_fmt);
        SDL_AudioFilter filter = SDL_HandTunedTypeCVT(src_fmt, dst_fmt);
        if (filter == NULL) {
            int i;
            for (i = 0; sdl_audio_type_filters[i].filter != NULL; i++) {
                const SDL_AudioTypeFilters *filt = &sdl_audio_type_filters[i];
                if ((filt->src_fmt == src_fmt) && (filt->dst_fmt == dst_fmt)) {
                    filter = filt->filter;
                    break;
                }
            }
            if (filter == NULL) {
                SDL_SetError("No conversion available for these formats");
                return -1;
            }
        }
        cvt->filters[cvt->filter_index++] = filter;
        if (src_bitsize < dst_bitsize) {
            const int mult = (dst_bitsize / src_bitsize);
            cvt->len_mult *= mult;
            cvt->len_ratio *= mult;
        } else if (src_bitsize > dst_bitsize) {
            cvt->len_ratio /= (src_bitsize / dst_bitsize);
        }
        return 1;               
    }
    return 0;                   
}
static int SDL_BuildAudioTypeCVT ( SDL_AudioCVT * cvt , SDL_AudioFormat src_fmt , SDL_AudioFormat dst_fmt ) { if ( src_fmt != dst_fmt ) { const Uint16 src_bitsize = SDL_AUDIO_BITSIZE ( src_fmt ) ; const Uint16 dst_bitsize = SDL_AUDIO_BITSIZE ( dst_fmt ) ; SDL_AudioFilter filter = SDL_HandTunedTypeCVT ( src_fmt , dst_fmt ) ; if ( filter == NULL ) { int i ; for ( i = 0 ; sdl_audio_type_filters [ i ] . filter != NULL ; i ++ ) { const SDL_AudioTypeFilters * filt = & sdl_audio_type_filters [ i ] ; if ( ( filt -> src_fmt == src_fmt ) && ( filt -> dst_fmt == dst_fmt ) ) { filter = filt -> filter ; break ; } } if ( filter == NULL ) { SDL_SetError ( " " ) ; return -1 ; } } cvt -> filters [ cvt -> filter_index ++ ] = filter ; if ( src_bitsize < dst_bitsize ) { const int mult = ( dst_bitsize / src_bitsize ) ; cvt -> len_mult *= mult ; cvt -> len_ratio *= mult ; } else if ( src_bitsize > dst_bitsize ) { cvt -> len_ratio /= ( src_bitsize / dst_bitsize ) ; } return 1 ; } return 0 ; }
Find a converter between two data types.
Find a converter between two data types .
/* No hand-tuned converter? Try the autogenerated ones. */ /* Update (cvt) with filter details... */ /* added a converter. */ /* no conversion necessary. */