2013-04-05 13:25:09 +00:00
|
|
|
/*
|
|
|
|
* This file is part of mpv.
|
|
|
|
*
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2013-04-05 13:25:09 +00:00
|
|
|
*
|
|
|
|
* mpv 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
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-04-05 13:25:09 +00:00
|
|
|
*
|
Relicense some non-MPlayer source files to LGPL 2.1 or later
This covers source files which were added in mplayer2 and mpv times
only, and where all code is covered by LGPL relicensing agreements.
There are probably more files to which this applies, but I'm being
conservative here.
A file named ao_sdl.c exists in MPlayer too, but the mpv one is a
complete rewrite, and was added some time after the original ao_sdl.c
was removed. The same applies to vo_sdl.c, for which the SDL2 API is
radically different in addition (MPlayer supports SDL 1.2 only).
common.c contains only code written by me. But common.h is a strange
case: although it originally was named mp_common.h and exists in MPlayer
too, by now it contains only definitions written by uau and me. The
exceptions are the CONTROL_ defines - thus not changing the license of
common.h yet.
codec_tags.c contained once large tables generated from MPlayer's
codecs.conf, but all of these tables were removed.
From demux_playlist.c I'm removing a code fragment from someone who was
not asked; this probably could be done later (see commit 15dccc37).
misc.c is a bit complicated to reason about (it was split off mplayer.c
and thus contains random functions out of this file), but actually all
functions have been added post-MPlayer. Except get_relative_time(),
which was written by uau, but looks similar to 3 different versions of
something similar in each of the Unix/win32/OSX timer source files. I'm
not sure what that means in regards to copyright, so I've just moved it
into another still-GPL source file for now.
screenshot.c once had some minor parts of MPlayer's vf_screenshot.c, but
they're all gone.
2016-01-19 17:36:06 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2013-04-05 13:25:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MP_CHMAP_H
|
|
|
|
#define MP_CHMAP_H
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdbool.h>
|
2014-08-29 10:09:04 +00:00
|
|
|
#include "misc/bstr.h"
|
2013-04-05 13:25:09 +00:00
|
|
|
|
2015-10-26 14:54:19 +00:00
|
|
|
#define MP_NUM_CHANNELS 16
|
2013-04-05 13:25:09 +00:00
|
|
|
|
|
|
|
// Speaker a channel can be assigned to.
|
|
|
|
// This corresponds to WAVEFORMATEXTENSIBLE channel mask bit indexes.
|
|
|
|
// E.g. channel_mask = (1 << MP_SPEAKER_ID_FL) | ...
|
2014-02-28 14:02:53 +00:00
|
|
|
enum mp_speaker_id {
|
2013-04-05 13:25:09 +00:00
|
|
|
// Official WAVEFORMATEXTENSIBLE (shortened names)
|
|
|
|
MP_SPEAKER_ID_FL = 0, // FRONT_LEFT
|
|
|
|
MP_SPEAKER_ID_FR, // FRONT_RIGHT
|
|
|
|
MP_SPEAKER_ID_FC, // FRONT_CENTER
|
|
|
|
MP_SPEAKER_ID_LFE, // LOW_FREQUENCY
|
|
|
|
MP_SPEAKER_ID_BL, // BACK_LEFT
|
|
|
|
MP_SPEAKER_ID_BR, // BACK_RIGHT
|
|
|
|
MP_SPEAKER_ID_FLC, // FRONT_LEFT_OF_CENTER
|
|
|
|
MP_SPEAKER_ID_FRC, // FRONT_RIGHT_OF_CENTER
|
|
|
|
MP_SPEAKER_ID_BC, // BACK_CENTER
|
|
|
|
MP_SPEAKER_ID_SL, // SIDE_LEFT
|
|
|
|
MP_SPEAKER_ID_SR, // SIDE_RIGHT
|
|
|
|
MP_SPEAKER_ID_TC, // TOP_CENTER
|
|
|
|
MP_SPEAKER_ID_TFL, // TOP_FRONT_LEFT
|
|
|
|
MP_SPEAKER_ID_TFC, // TOP_FRONT_CENTER
|
|
|
|
MP_SPEAKER_ID_TFR, // TOP_FRONT_RIGHT
|
|
|
|
MP_SPEAKER_ID_TBL, // TOP_BACK_LEFT
|
|
|
|
MP_SPEAKER_ID_TBC, // TOP_BACK_CENTER
|
|
|
|
MP_SPEAKER_ID_TBR, // TOP_BACK_RIGHT
|
2015-06-17 20:23:08 +00:00
|
|
|
// Unofficial/libav* extensions
|
2013-04-05 13:25:09 +00:00
|
|
|
MP_SPEAKER_ID_DL = 29, // STEREO_LEFT (stereo downmix special speakers)
|
|
|
|
MP_SPEAKER_ID_DR, // STEREO_RIGHT
|
|
|
|
MP_SPEAKER_ID_WL, // WIDE_LEFT
|
|
|
|
MP_SPEAKER_ID_WR, // WIDE_RIGHT
|
|
|
|
MP_SPEAKER_ID_SDL, // SURROUND_DIRECT_LEFT
|
|
|
|
MP_SPEAKER_ID_SDR, // SURROUND_DIRECT_RIGHT
|
|
|
|
MP_SPEAKER_ID_LFE2, // LOW_FREQUENCY_2
|
|
|
|
|
2015-05-07 21:15:52 +00:00
|
|
|
// Speaker IDs >= 64 are not representable in WAVEFORMATEXTENSIBLE or libav*.
|
2013-04-05 13:25:09 +00:00
|
|
|
|
2015-05-04 21:59:20 +00:00
|
|
|
// "Silent" channels. These are sometimes used to insert padding for
|
2015-05-07 21:07:14 +00:00
|
|
|
// unused channels. Unlike other speaker types, multiple of these can
|
|
|
|
// occur in a single mp_chmap.
|
2015-05-07 21:15:52 +00:00
|
|
|
MP_SPEAKER_ID_NA = 64,
|
2015-05-04 21:59:20 +00:00
|
|
|
|
2014-11-24 18:40:24 +00:00
|
|
|
// Including the unassigned IDs in between. This is not a valid ID anymore,
|
|
|
|
// but is still within uint8_t.
|
2013-04-05 13:25:09 +00:00
|
|
|
MP_SPEAKER_ID_COUNT,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mp_chmap {
|
|
|
|
uint8_t num; // number of channels
|
|
|
|
// Given a channel n, speaker[n] is the speaker ID driven by that channel.
|
|
|
|
// Entries after speaker[num - 1] are undefined.
|
|
|
|
uint8_t speaker[MP_NUM_CHANNELS];
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MP_SP(speaker) MP_SPEAKER_ID_ ## speaker
|
|
|
|
|
|
|
|
#define MP_CHMAP2(a, b) \
|
|
|
|
{2, {MP_SP(a), MP_SP(b)}}
|
|
|
|
#define MP_CHMAP3(a, b, c) \
|
|
|
|
{3, {MP_SP(a), MP_SP(b), MP_SP(c)}}
|
|
|
|
#define MP_CHMAP4(a, b, c, d) \
|
|
|
|
{4, {MP_SP(a), MP_SP(b), MP_SP(c), MP_SP(d)}}
|
|
|
|
#define MP_CHMAP5(a, b, c, d, e) \
|
|
|
|
{5, {MP_SP(a), MP_SP(b), MP_SP(c), MP_SP(d), MP_SP(e)}}
|
|
|
|
#define MP_CHMAP6(a, b, c, d, e, f) \
|
|
|
|
{6, {MP_SP(a), MP_SP(b), MP_SP(c), MP_SP(d), MP_SP(e), MP_SP(f)}}
|
|
|
|
#define MP_CHMAP7(a, b, c, d, e, f, g) \
|
|
|
|
{7, {MP_SP(a), MP_SP(b), MP_SP(c), MP_SP(d), MP_SP(e), MP_SP(f), MP_SP(g)}}
|
|
|
|
#define MP_CHMAP8(a, b, c, d, e, f, g, h) \
|
|
|
|
{8, {MP_SP(a), MP_SP(b), MP_SP(c), MP_SP(d), MP_SP(e), MP_SP(f), MP_SP(g), MP_SP(h)}}
|
|
|
|
|
|
|
|
#define MP_CHMAP_INIT_MONO {1, {MP_SPEAKER_ID_FC}}
|
|
|
|
#define MP_CHMAP_INIT_STEREO MP_CHMAP2(FL, FR)
|
|
|
|
|
|
|
|
bool mp_chmap_is_valid(const struct mp_chmap *src);
|
|
|
|
bool mp_chmap_is_empty(const struct mp_chmap *src);
|
|
|
|
bool mp_chmap_is_unknown(const struct mp_chmap *src);
|
|
|
|
bool mp_chmap_equals(const struct mp_chmap *a, const struct mp_chmap *b);
|
|
|
|
bool mp_chmap_equals_reordered(const struct mp_chmap *a, const struct mp_chmap *b);
|
|
|
|
bool mp_chmap_is_stereo(const struct mp_chmap *src);
|
|
|
|
|
|
|
|
void mp_chmap_reorder_norm(struct mp_chmap *map);
|
2015-05-04 21:59:20 +00:00
|
|
|
void mp_chmap_remove_na(struct mp_chmap *map);
|
|
|
|
void mp_chmap_fill_na(struct mp_chmap *map, int num);
|
2013-04-05 13:25:09 +00:00
|
|
|
|
|
|
|
void mp_chmap_from_channels(struct mp_chmap *dst, int num_channels);
|
|
|
|
void mp_chmap_set_unknown(struct mp_chmap *dst, int num_channels);
|
|
|
|
|
|
|
|
uint64_t mp_chmap_to_lavc(const struct mp_chmap *src);
|
|
|
|
uint64_t mp_chmap_to_lavc_unchecked(const struct mp_chmap *src);
|
|
|
|
void mp_chmap_from_lavc(struct mp_chmap *dst, uint64_t src);
|
|
|
|
|
|
|
|
bool mp_chmap_is_lavc(const struct mp_chmap *src);
|
|
|
|
void mp_chmap_reorder_to_lavc(struct mp_chmap *map);
|
|
|
|
|
2015-05-04 21:59:20 +00:00
|
|
|
void mp_chmap_get_reorder(int src[MP_NUM_CHANNELS], const struct mp_chmap *from,
|
2013-04-05 13:25:09 +00:00
|
|
|
const struct mp_chmap *to);
|
|
|
|
|
2015-05-08 17:31:54 +00:00
|
|
|
int mp_chmap_diffn(const struct mp_chmap *a, const struct mp_chmap *b);
|
2014-12-28 08:38:22 +00:00
|
|
|
|
2014-11-24 18:56:01 +00:00
|
|
|
char *mp_chmap_to_str_buf(char *buf, size_t buf_size, const struct mp_chmap *src);
|
|
|
|
#define mp_chmap_to_str(m) mp_chmap_to_str_buf((char[64]){0}, 64, (m))
|
|
|
|
|
2015-06-25 17:10:24 +00:00
|
|
|
char *mp_chmap_to_str_hr_buf(char *buf, size_t buf_size, const struct mp_chmap *src);
|
|
|
|
#define mp_chmap_to_str_hr(m) mp_chmap_to_str_hr_buf((char[128]){0}, 128, (m))
|
|
|
|
|
2013-04-05 13:25:09 +00:00
|
|
|
bool mp_chmap_from_str(struct mp_chmap *dst, bstr src);
|
2013-12-21 18:45:42 +00:00
|
|
|
|
|
|
|
struct mp_log;
|
|
|
|
void mp_chmap_print_help(struct mp_log *log);
|
2013-04-05 13:25:09 +00:00
|
|
|
|
|
|
|
// Use these to avoid chaos in case lavc's definition should diverge from MS.
|
|
|
|
#define mp_chmap_to_waveext mp_chmap_to_lavc
|
|
|
|
#define mp_chmap_from_waveext mp_chmap_from_lavc
|
|
|
|
#define mp_chmap_is_waveext mp_chmap_is_lavc
|
|
|
|
#define mp_chmap_reorder_to_waveext mp_chmap_reorder_to_lavc
|
|
|
|
|
|
|
|
#endif
|