mirror of
https://github.com/mpv-player/mpv
synced 2025-02-02 05:01:56 +00:00
added af_format_encode() to convert sample format from libaf to mplayer (OSS)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8994 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
97688e3505
commit
8fd2c262e4
@ -41,3 +41,40 @@ int af_format_decode(int ifmt)
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -22,5 +22,6 @@
|
||||
|
||||
/* Decodes the format from mplayer format to libaf format */
|
||||
extern int af_format_decode(int format);
|
||||
extern int af_format_encode(void* fmt);
|
||||
|
||||
#endif /* __af_mp_h__ */
|
||||
|
Loading…
Reference in New Issue
Block a user