Mercurial > mplayer.hg
changeset 8993:a6615e7bc710
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
author | arpi |
---|---|
date | Sat, 18 Jan 2003 17:31:22 +0000 |
parents | a2111e523d50 |
children | 06d7ef3c7b01 |
files | libaf/af_mp.c libaf/af_mp.h |
diffstat | 2 files changed, 38 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libaf/af_mp.c Sat Jan 18 16:49:43 2003 +0000 +++ b/libaf/af_mp.c Sat Jan 18 17:31:22 2003 +0000 @@ -41,3 +41,40 @@ } return ofmt; } + +/* Encodes the format from libaf format to mplayer (OSS) format */ +int af_format_encode(void* fmtp) +{ + af_data_t* fmt=(af_data_t*) fmtp; + switch(fmt->format&AF_FORMAT_SPECIAL_MASK){ + case 0: // PCM: + if((fmt->format&AF_FORMAT_POINT_MASK)==AF_FORMAT_I){ + if((fmt->format&AF_FORMAT_SIGN_MASK)==AF_FORMAT_SI){ + // signed int PCM: + switch(fmt->bps){ + case 1: return AFMT_S8; + case 2: return (fmt->format&AF_FORMAT_LE) ? AFMT_S16_LE : AFMT_S16_BE; + case 4: return (fmt->format&AF_FORMAT_LE) ? AFMT_S32_LE : AFMT_S32_BE; + } + } else { + // unsigned int PCM: + switch(fmt->bps){ + case 1: return AFMT_U8; + case 2: return (fmt->format&AF_FORMAT_LE) ? AFMT_U16_LE : AFMT_U16_BE; +// case 4: return (fmt->format&AF_FORMAT_LE) ? AFMT_U32_LE : AFMT_U32_BE; + } + } + } else { + // float PCM: + return AFMT_FLOAT; // FIXME? + } + break; + case AF_FORMAT_MU_LAW: return AFMT_MU_LAW; + case AF_FORMAT_A_LAW: return AFMT_A_LAW; + case AF_FORMAT_MPEG2: return AFMT_MPEG; + case AF_FORMAT_AC3: return AFMT_AC3; + case AF_FORMAT_IMA_ADPCM: return AFMT_IMA_ADPCM; + } + return AFMT_S16_LE; // shouldn't happen +} +