2009-01-05 12:41:40 +00:00
|
|
|
/*
|
|
|
|
* The sample format system used lin libaf is based on bitmasks.
|
|
|
|
* The format definition only refers to the storage format,
|
|
|
|
* not the resolution.
|
|
|
|
*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2008-02-22 09:09:46 +00:00
|
|
|
|
|
|
|
#ifndef MPLAYER_AF_FORMAT_H
|
|
|
|
#define MPLAYER_AF_FORMAT_H
|
2002-11-12 12:33:56 +00:00
|
|
|
|
2012-07-31 21:37:56 +00:00
|
|
|
#include <sys/types.h>
|
2008-02-24 23:44:35 +00:00
|
|
|
#include "config.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "core/bstr.h"
|
2005-01-12 22:00:02 +00:00
|
|
|
|
2007-09-25 16:34:23 +00:00
|
|
|
// Endianness
|
2002-11-12 12:33:56 +00:00
|
|
|
#define AF_FORMAT_BE (0<<0) // Big Endian
|
|
|
|
#define AF_FORMAT_LE (1<<0) // Little Endian
|
|
|
|
#define AF_FORMAT_END_MASK (1<<0)
|
|
|
|
|
Remove compile time/runtime CPU detection, and drop some platforms
mplayer had three ways of enabling CPU specific assembler routines:
a) Enable them at compile time; crash if the CPU can't handle it.
b) Enable them at compile time, but let the configure script detect
your CPU. Your binary will only crash if you try to run it on a
different system that has less features than yours.
This was the default, I think.
c) Runtime detection.
The implementation of b) and c) suck. a) is not really feasible (it
sucks for users). Remove all code related to this, and use libav's CPU
detection instead. Now the configure script will always enable CPU
specific features, and disable them at runtime if libav reports them
not as available.
One implication is that now the compiler is always expected to handle
SSE (etc.) inline assembly at runtime, unless it's explicitly disabled.
Only checks for x86 CPU specific features are kept, the rest is either
unused or barely used.
Get rid of all the dump -mpcu, -march etc. flags. Trust the compiler
to select decent settings.
Get rid of support for the following operating systems:
- BSD/OS (some ancient BSD fork)
- QNX (don't care)
- BeOS (dead, Haiku support is still welcome)
- AIX (don't care)
- HP-UX (don't care)
- OS/2 (dead, actual support has been removed a while ago)
Remove the configure code for detecting the endianness. Instead, use
the standard header <endian.h>, which can be used if _GNU_SOURCE or
_BSD_SOURCE is defined. (Maybe these changes should have been in a
separate commit.)
Since this is a quite violent code removal orgy, and I'm testing only
on x86 32 bit Linux, expect regressions.
2012-07-29 15:20:57 +00:00
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
2002-11-12 12:33:56 +00:00
|
|
|
#define AF_FORMAT_NE AF_FORMAT_BE
|
|
|
|
#else
|
|
|
|
#define AF_FORMAT_NE AF_FORMAT_LE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Signed/unsigned
|
2004-12-27 17:30:15 +00:00
|
|
|
#define AF_FORMAT_SI (0<<1) // Signed
|
|
|
|
#define AF_FORMAT_US (1<<1) // Unsigned
|
2002-11-12 12:33:56 +00:00
|
|
|
#define AF_FORMAT_SIGN_MASK (1<<1)
|
|
|
|
|
2004-10-04 19:11:05 +00:00
|
|
|
// Fixed or floating point
|
2002-11-12 12:33:56 +00:00
|
|
|
#define AF_FORMAT_I (0<<2) // Int
|
|
|
|
#define AF_FORMAT_F (1<<2) // Foating point
|
|
|
|
#define AF_FORMAT_POINT_MASK (1<<2)
|
|
|
|
|
2004-12-27 17:30:15 +00:00
|
|
|
// Bits used
|
|
|
|
#define AF_FORMAT_8BIT (0<<3)
|
|
|
|
#define AF_FORMAT_16BIT (1<<3)
|
|
|
|
#define AF_FORMAT_24BIT (2<<3)
|
|
|
|
#define AF_FORMAT_32BIT (3<<3)
|
2013-05-10 13:04:21 +00:00
|
|
|
#define AF_FORMAT_64BIT (4<<3)
|
2004-12-27 17:30:15 +00:00
|
|
|
#define AF_FORMAT_BITS_MASK (7<<3)
|
|
|
|
|
2012-12-10 16:06:21 +00:00
|
|
|
// Special flags refering to non pcm data (note: 1<<6, 2<<6, 5<<6 unused)
|
2004-12-27 17:30:15 +00:00
|
|
|
#define AF_FORMAT_MPEG2 (3<<6) // MPEG(2) audio
|
2010-01-11 19:08:15 +00:00
|
|
|
#define AF_FORMAT_AC3 (4<<6) // Dolby Digital AC3
|
2011-10-12 17:23:08 +00:00
|
|
|
#define AF_FORMAT_IEC61937 (6<<6)
|
2004-12-27 17:30:15 +00:00
|
|
|
#define AF_FORMAT_SPECIAL_MASK (7<<6)
|
|
|
|
|
2012-09-02 18:13:12 +00:00
|
|
|
#define AF_FORMAT_MASK ((1<<9)-1)
|
|
|
|
|
2004-12-27 17:30:15 +00:00
|
|
|
// PREDEFINED formats
|
|
|
|
|
|
|
|
#define AF_FORMAT_U8 (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_8BIT|AF_FORMAT_NE)
|
|
|
|
#define AF_FORMAT_S8 (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_8BIT|AF_FORMAT_NE)
|
|
|
|
#define AF_FORMAT_U16_LE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_16BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_U16_BE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_16BIT|AF_FORMAT_BE)
|
|
|
|
#define AF_FORMAT_S16_LE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_16BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_S16_BE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_16BIT|AF_FORMAT_BE)
|
|
|
|
#define AF_FORMAT_U24_LE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_24BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_U24_BE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_24BIT|AF_FORMAT_BE)
|
|
|
|
#define AF_FORMAT_S24_LE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_24BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_S24_BE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_24BIT|AF_FORMAT_BE)
|
|
|
|
#define AF_FORMAT_U32_LE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_32BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_U32_BE (AF_FORMAT_I|AF_FORMAT_US|AF_FORMAT_32BIT|AF_FORMAT_BE)
|
|
|
|
#define AF_FORMAT_S32_LE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_32BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_S32_BE (AF_FORMAT_I|AF_FORMAT_SI|AF_FORMAT_32BIT|AF_FORMAT_BE)
|
|
|
|
|
|
|
|
#define AF_FORMAT_FLOAT_LE (AF_FORMAT_F|AF_FORMAT_32BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_FLOAT_BE (AF_FORMAT_F|AF_FORMAT_32BIT|AF_FORMAT_BE)
|
|
|
|
|
2013-05-10 13:04:21 +00:00
|
|
|
#define AF_FORMAT_DOUBLE_LE (AF_FORMAT_F|AF_FORMAT_64BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_DOUBLE_BE (AF_FORMAT_F|AF_FORMAT_64BIT|AF_FORMAT_BE)
|
|
|
|
|
2010-01-11 20:27:52 +00:00
|
|
|
#define AF_FORMAT_AC3_LE (AF_FORMAT_AC3|AF_FORMAT_16BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_AC3_BE (AF_FORMAT_AC3|AF_FORMAT_16BIT|AF_FORMAT_BE)
|
|
|
|
|
2011-10-12 17:23:08 +00:00
|
|
|
#define AF_FORMAT_IEC61937_LE (AF_FORMAT_IEC61937|AF_FORMAT_16BIT|AF_FORMAT_LE)
|
|
|
|
#define AF_FORMAT_IEC61937_BE (AF_FORMAT_IEC61937|AF_FORMAT_16BIT|AF_FORMAT_BE)
|
|
|
|
|
Remove compile time/runtime CPU detection, and drop some platforms
mplayer had three ways of enabling CPU specific assembler routines:
a) Enable them at compile time; crash if the CPU can't handle it.
b) Enable them at compile time, but let the configure script detect
your CPU. Your binary will only crash if you try to run it on a
different system that has less features than yours.
This was the default, I think.
c) Runtime detection.
The implementation of b) and c) suck. a) is not really feasible (it
sucks for users). Remove all code related to this, and use libav's CPU
detection instead. Now the configure script will always enable CPU
specific features, and disable them at runtime if libav reports them
not as available.
One implication is that now the compiler is always expected to handle
SSE (etc.) inline assembly at runtime, unless it's explicitly disabled.
Only checks for x86 CPU specific features are kept, the rest is either
unused or barely used.
Get rid of all the dump -mpcu, -march etc. flags. Trust the compiler
to select decent settings.
Get rid of support for the following operating systems:
- BSD/OS (some ancient BSD fork)
- QNX (don't care)
- BeOS (dead, Haiku support is still welcome)
- AIX (don't care)
- HP-UX (don't care)
- OS/2 (dead, actual support has been removed a while ago)
Remove the configure code for detecting the endianness. Instead, use
the standard header <endian.h>, which can be used if _GNU_SOURCE or
_BSD_SOURCE is defined. (Maybe these changes should have been in a
separate commit.)
Since this is a quite violent code removal orgy, and I'm testing only
on x86 32 bit Linux, expect regressions.
2012-07-29 15:20:57 +00:00
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
2004-12-27 17:30:15 +00:00
|
|
|
#define AF_FORMAT_U16_NE AF_FORMAT_U16_BE
|
|
|
|
#define AF_FORMAT_S16_NE AF_FORMAT_S16_BE
|
|
|
|
#define AF_FORMAT_U24_NE AF_FORMAT_U24_BE
|
|
|
|
#define AF_FORMAT_S24_NE AF_FORMAT_S24_BE
|
|
|
|
#define AF_FORMAT_U32_NE AF_FORMAT_U32_BE
|
|
|
|
#define AF_FORMAT_S32_NE AF_FORMAT_S32_BE
|
|
|
|
#define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_BE
|
2013-05-10 13:04:21 +00:00
|
|
|
#define AF_FORMAT_DOUBLE_NE AF_FORMAT_DOUBLE_BE
|
2010-01-11 20:27:52 +00:00
|
|
|
#define AF_FORMAT_AC3_NE AF_FORMAT_AC3_BE
|
2011-10-12 17:23:08 +00:00
|
|
|
#define AF_FORMAT_IEC61937_NE AF_FORMAT_IEC61937_BE
|
2004-12-27 17:30:15 +00:00
|
|
|
#else
|
|
|
|
#define AF_FORMAT_U16_NE AF_FORMAT_U16_LE
|
|
|
|
#define AF_FORMAT_S16_NE AF_FORMAT_S16_LE
|
|
|
|
#define AF_FORMAT_U24_NE AF_FORMAT_U24_LE
|
|
|
|
#define AF_FORMAT_S24_NE AF_FORMAT_S24_LE
|
|
|
|
#define AF_FORMAT_U32_NE AF_FORMAT_U32_LE
|
|
|
|
#define AF_FORMAT_S32_NE AF_FORMAT_S32_LE
|
|
|
|
#define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_LE
|
2013-05-10 13:04:21 +00:00
|
|
|
#define AF_FORMAT_DOUBLE_NE AF_FORMAT_DOUBLE_LE
|
2010-01-11 20:27:52 +00:00
|
|
|
#define AF_FORMAT_AC3_NE AF_FORMAT_AC3_LE
|
2011-10-12 17:23:08 +00:00
|
|
|
#define AF_FORMAT_IEC61937_NE AF_FORMAT_IEC61937_LE
|
2004-12-27 17:30:15 +00:00
|
|
|
#endif
|
2003-01-18 17:31:58 +00:00
|
|
|
|
2006-11-08 18:31:04 +00:00
|
|
|
#define AF_FORMAT_UNKNOWN (-1)
|
|
|
|
|
2010-01-11 19:23:18 +00:00
|
|
|
#define AF_FORMAT_IS_AC3(fmt) (((fmt) & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_AC3)
|
2012-11-29 17:03:04 +00:00
|
|
|
#define AF_FORMAT_IS_IEC61937(fmt) (AF_FORMAT_IS_AC3(fmt) || ((fmt) & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_IEC61937)
|
2010-01-11 19:23:18 +00:00
|
|
|
|
2012-08-28 22:34:21 +00:00
|
|
|
struct af_fmt_entry {
|
|
|
|
const char *name;
|
|
|
|
int format;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct af_fmt_entry af_fmtstr_table[];
|
|
|
|
|
|
|
|
int af_str2fmt_short(bstr str);
|
2008-12-03 23:01:03 +00:00
|
|
|
int af_fmt2bits(int format);
|
2013-06-15 06:58:12 +00:00
|
|
|
|
|
|
|
// Amount of bytes that contain audio of the given duration, aligned to frames.
|
2013-06-16 17:25:10 +00:00
|
|
|
int af_fmt_seconds_to_bytes(int format, float seconds, int channels, int samplerate);
|
2013-06-15 06:58:12 +00:00
|
|
|
|
|
|
|
char* af_fmt2str(int format, char* str, int size);
|
2008-12-03 23:01:03 +00:00
|
|
|
const char* af_fmt2str_short(int format);
|
2003-01-18 17:31:58 +00:00
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_AF_FORMAT_H */
|