summaryrefslogtreecommitdiffstats
path: root/audio/format.h
Commit message (Collapse)AuthorAgeFilesLines
* audio/format: add heuristic to estimate loss on format conversionwm42013-11-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The added function af_format_conversion_score() can be used to select the best sample format to convert to in order to reduce loss and extra conversion work. It calculates a "loss" score when going from one format to another, and for each conversion that needs to be done a certain score is subtracted. Thus, if you have to convert from one format to a set of other formats, you can calculate the score for each conversion, and pick the one with the highest score. Conversion between int and float is considered the worst case. One odd consequence is that when converting from s32 to u8 or float, u8 will be picked. Test program used to develop this follows: #define MAX_FMT 200 struct entry { const char *name; int score; }; static int compentry(const void *px1, const void *px2) { const struct entry *x1 = px1; const struct entry *x2 = px2; if (x1->score > x2->score) return 1; if (x1->score < x2->score) return -1; return 0; } int main(int argc, char *argv[]) { for (int n = 0; af_fmtstr_table[n].name; n++) { struct entry entry[MAX_FMT]; int entries = 0; for (int i = 0; af_fmtstr_table[i].name; i++) { assert(i < MAX_FMT); entry[entries].name = af_fmtstr_table[i].name; entry[entries].score = af_format_conversion_score(af_fmtstr_table[i].format, af_fmtstr_table[n].format); entries++; } qsort(&entry[0], entries, sizeof(entry[0]), compentry); for (int i = 0; i < entries; i++) { printf("%s -> %s: %d \n", af_fmtstr_table[n].name, entry[i].name, entry[i].score); } } }
* audio/format: fix doublep sample formatwm42013-11-161-1/+1
| | | | This was accidentally equivalent to floatp.
* audio: drop "_NE"/"ne" suffix from audio formatswm42013-11-151-11/+0
| | | | | | You get the native format by not appending any suffix to the format. This change includes user-facing names, e.g. for the --format option.
* audio/format: add non-interleaved audio formatswm42013-11-121-2/+20
|
* ao: add ao_play_silence, use for ao_alsa and ao_osswm42013-11-101-0/+5
| | | | | Also add a corresponding function to audio/format.c, which fills an audio block with silence.
* audio/format: convert format macros to enum, drop NE suffixwm42013-11-071-62/+74
| | | | | | | | | | Turn the sample format definitions into an enum. (The format bits are still macros.) The native endian versions of the new definitions don't have a NE suffix anymore, although there are still compatibility defines since too much code uses the NE variants. Rename the format bits for special formats to help to distinguish them from the actual definitions, e.g. AF_FORMAT_AC3 to AF_FORMAT_S_AC3.
* audio: replace af_fmt2str_short -> af_fmt_to_strwm42013-11-071-3/+2
| | | | Also, remove all af_fmt2str usages.
* audio/format: reformatwm42013-11-071-38/+38
|
* audio/format: add some helper functionswm42013-10-221-0/+3
|
* audio: make internal audio format 0 an invalid formatwm42013-08-261-7/+7
| | | | | | | | | | | | Having to use -1 for that is generally quite annoying. Audio formats are created from bitmasks, and it can't be excluded that 0 is not a valid format. Fix this by adjusting AF_FORMAT_I so that it is never 0. Along with AF_FORMAT_F and the special formats, all valid formats are covered and guaranteed to be non-0. It's possible that this commit will cause some regressions, as the check for invalid audio formats changes a bit.
* core: move contents to mpvcore (2/2)Stefano Pigozzi2013-08-061-1/+1
| | | | Followup commit. Fixes all the files references.
* audio: fix af_fmt_seconds_to_bytesStefano Pigozzi2013-06-161-1/+1
| | | | Was missing samplerate
* ao_portaudio: use mp_ringStefano Pigozzi2013-06-161-1/+4
|
* core: add a spsc ringbuffer implementationStefano Pigozzi2013-06-161-0/+1
| | | | | | | | | | | | | | | | | Currently every single AO was implementing it's own ringbuffer, many times with slightly different semantics. This is an attempt to fix the problem. I stole some good ideas from ao_portaudio's ringbuffer and went from there. The main difference is this one stores wpos and rpos which are absolute positions in an "infinite" buffer. To find the actual position for writing / reading just apply modulo size. The producer only modifies wpos while the consumer only modifies rpos. This makes it pretty easy to reason about and make the operations thread safe by using barriers (thread safety is guaranteed only in the Single-Producer/Single- Consumer case). Also adapted ao_coreaudio to use this ringbuffer.
* audio: add double sample formatwm42013-05-121-3/+6
| | | | | | To make this easier, get rid of the direct mapping of the AF_FORMAT_BITS_MASK bit field to number of bytes. This way we can throw away the unused AF_FORMAT_48BIT and don't have to add ..._56BIT.
* audio: remove support for native alaw/mulaw/adpcm outputwm42012-12-111-4/+1
| | | | | | This is considered a worthless feature. Note that alaw/mulaw/adpcm input is unaffected: such data is handed to libavcodec and "decoded" to linear PCM.
* audio: make AC3 pass-through with ad_spdif workreimar2012-12-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Do not fall back to 0 for samplerate when parser is not initialized. Might fix some issues with using -ac spdifenc with audio in MKV or MP4. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35517 b3059339-0415-0410-9bf9-f77b7e298cf2 Replace outdated list of unsupported formats by list of supported formats. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35534 b3059339-0415-0410-9bf9-f77b7e298cf2 Do not call af_fmt2str on the same data over and over. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35535 b3059339-0415-0410-9bf9-f77b7e298cf2 ad_spdif: use the more specific AF_FORMAT_AC3_LE when we handle AC3. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35536 b3059339-0415-0410-9bf9-f77b7e298cf2 Make AF_FORMAT_IS_IEC61937 include AF_FORMAT_IS_AC3. Our AC3 "sample format" is also iec61937. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35537 b3059339-0415-0410-9bf9-f77b7e298cf2 af_format: support endianness conversion also for iec61937 formats in general, not just AC3. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35538 b3059339-0415-0410-9bf9-f77b7e298cf2 Conflicts: audio/filter/af_format.c af_format: Fix check_format, non-special formats are of course supported. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@35545 b3059339-0415-0410-9bf9-f77b7e298cf2 Note: see mplayer bug #2110
* Rename directories, move files (step 2 of 2)wm42012-11-121-1/+1
| | | | | | | | | | | | Finish renaming directories and moving files. Adjust all include statements to make the previous commit compile. The two commits are separate, because git is bad at tracking renames and content changes at the same time. Also take this as an opportunity to remove the separation between "common" and "mplayer" sources in the Makefile. ("common" used to be shared between mplayer and mencoder.)
* Rename directories, move files (step 1 of 2) (does not compile)wm42012-11-121-0/+137
Tis drops the silly lib prefixes, and attempts to organize the tree in a more logical way. Make the top-level directory less cluttered as well. Renames the following directories: libaf -> audio/filter libao2 -> audio/out libvo -> video/out libmpdemux -> demux Split libmpcodecs: vf* -> video/filter vd*, dec_video.* -> video/decode mp_image*, img_format*, ... -> video/ ad*, dec_audio.* -> audio/decode libaf/format.* is moved to audio/ - this is similar to how mp_image.* is located in video/. Move most top-level .c/.h files to core. (talloc.c/.h is left on top- level, because it's external.) Park some of the more annoying files in compat/. Some of these are relicts from the time mplayer used ffmpeg internals. sub/ is not split, because it's too much of a mess (subtitle code is mixed with OSD display and rendering). Maybe the organization of core is not ideal: it mixes playback core (like mplayer.c) and utility helpers (like bstr.c/h). Should the need arise, the playback core will be moved somewhere else, while core contains all helper and common code.