In my opinion, config.h inclusions should be kept to a minimum. MPlayer
code really liked including config.h everywhere, though, even in often
used header files. Try to reduce this.
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);
}
}
}
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.
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.
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.
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.
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
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.)
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.