2007-12-10 16:53:30 +00:00
|
|
|
/*
|
|
|
|
* common functions for reordering audio channels
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Ulion <ulion A gmail P com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2008-05-14 17:24:10 +00:00
|
|
|
* 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.
|
2007-12-10 16:53:30 +00:00
|
|
|
*/
|
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#ifndef MPLAYER_REORDER_CH_H
|
|
|
|
#define MPLAYER_REORDER_CH_H
|
2007-12-10 16:53:30 +00:00
|
|
|
|
2012-12-21 17:13:16 +00:00
|
|
|
#include <inttypes.h>
|
|
|
|
|
2007-12-10 16:53:30 +00:00
|
|
|
// L - Left
|
|
|
|
// R - Right
|
|
|
|
// C - Center
|
|
|
|
// Ls - Left Surround
|
|
|
|
// Rs - Right Surround
|
|
|
|
// Cs - Center Surround
|
|
|
|
// Rls - Rear Left Surround
|
|
|
|
// Rrs - Rear Right Surround
|
|
|
|
|
|
|
|
#define AF_LFE (1<<7)
|
|
|
|
|
|
|
|
#define AF_CHANNEL_LAYOUT_MONO ((100<<8)|1)
|
|
|
|
#define AF_CHANNEL_LAYOUT_STEREO ((101<<8)|2)
|
|
|
|
#define AF_CHANNEL_LAYOUT_1_0 AF_CHANNEL_LAYOUT_MONO // C
|
|
|
|
#define AF_CHANNEL_LAYOUT_2_0 AF_CHANNEL_LAYOUT_STEREO // L R
|
|
|
|
#define AF_CHANNEL_LAYOUT_2_1 ((102<<8)|3) // L R LFE
|
|
|
|
#define AF_CHANNEL_LAYOUT_3_0_A ((103<<8)|3) // L R C
|
|
|
|
#define AF_CHANNEL_LAYOUT_3_0_B ((104<<8)|3) // C L R
|
|
|
|
#define AF_CHANNEL_LAYOUT_4_0_A ((105<<8)|4) // L R C Cs
|
|
|
|
#define AF_CHANNEL_LAYOUT_4_0_B ((106<<8)|4) // C L R Cs
|
|
|
|
#define AF_CHANNEL_LAYOUT_4_0_C ((107<<8)|4) // L R Ls Rs
|
|
|
|
#define AF_CHANNEL_LAYOUT_5_0_A ((108<<8)|5) // L R C Ls Rs
|
|
|
|
#define AF_CHANNEL_LAYOUT_5_0_B ((109<<8)|5) // L R Ls Rs C
|
|
|
|
#define AF_CHANNEL_LAYOUT_5_0_C ((110<<8)|5) // L C R Ls Rs
|
|
|
|
#define AF_CHANNEL_LAYOUT_5_0_D ((111<<8)|5) // C L R Ls Rs
|
|
|
|
#define AF_CHANNEL_LAYOUT_5_1_A ((112<<8)|6|AF_LFE) // L R C LFE Ls Rs
|
|
|
|
#define AF_CHANNEL_LAYOUT_5_1_B ((113<<8)|6|AF_LFE) // L R Ls Rs C LFE
|
|
|
|
#define AF_CHANNEL_LAYOUT_5_1_C ((114<<8)|6|AF_LFE) // L C R Ls Rs LFE
|
|
|
|
#define AF_CHANNEL_LAYOUT_5_1_D ((115<<8)|6|AF_LFE) // C L R Ls Rs LFE
|
|
|
|
#define AF_CHANNEL_LAYOUT_5_1_E ((116<<8)|6|AF_LFE) // LFE L C R Ls Rs
|
2009-08-18 22:24:36 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_5_1_F ((117<<8)|6|AF_LFE) // C L R LFE Ls Rs
|
|
|
|
#define AF_CHANNEL_LAYOUT_6_1_A ((118<<8)|7|AF_LFE) // L R C LFE Ls Rs Cs
|
|
|
|
#define AF_CHANNEL_LAYOUT_7_1_A ((119<<8)|8|AF_LFE) // L R C LFE Ls Rs Rls Rrs
|
2009-11-10 00:45:19 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_7_1_B ((120<<8)|8|AF_LFE) // L R Ls Rs C LFE Rls Rrs
|
|
|
|
#define AF_CHANNEL_LAYOUT_7_1_C ((121<<8)|8|AF_LFE) // L C R Ls Rs LFE Rls Rrs
|
|
|
|
#define AF_CHANNEL_LAYOUT_7_1_D ((122<<8)|8|AF_LFE) // C L R Ls Rs Rls Rrs LFE
|
|
|
|
#define AF_CHANNEL_LAYOUT_7_1_F ((123<<8)|8|AF_LFE) // C L R LFE Ls Rs Rls Rrs
|
2007-12-10 16:53:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_B
|
|
|
|
#define AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_B
|
2009-11-10 00:45:19 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_ALSA_8CH_DEFAULT AF_CHANNEL_LAYOUT_7_1_B
|
2007-12-10 16:53:30 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_MPLAYER_5CH_DEFAULT AF_CHANNEL_LAYOUT_ALSA_5CH_DEFAULT
|
|
|
|
#define AF_CHANNEL_LAYOUT_MPLAYER_6CH_DEFAULT AF_CHANNEL_LAYOUT_ALSA_6CH_DEFAULT
|
2009-11-10 00:45:19 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_MPLAYER_8CH_DEFAULT AF_CHANNEL_LAYOUT_ALSA_8CH_DEFAULT
|
2007-12-10 16:53:30 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_AAC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_D
|
|
|
|
#define AF_CHANNEL_LAYOUT_AAC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_D
|
2009-11-10 00:45:19 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_AAC_8CH_DEFAULT AF_CHANNEL_LAYOUT_7_1_D
|
2007-12-10 16:53:30 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_WAVEEX_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A
|
|
|
|
#define AF_CHANNEL_LAYOUT_WAVEEX_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A
|
2009-11-10 00:45:19 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_WAVEEX_8CH_DEFAULT AF_CHANNEL_LAYOUT_7_1_A
|
2009-08-18 22:24:36 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_LAVC_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_A
|
|
|
|
#define AF_CHANNEL_LAYOUT_LAVC_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_A
|
2009-11-10 00:45:19 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_LAVC_8CH_DEFAULT AF_CHANNEL_LAYOUT_7_1_A
|
2008-06-07 12:57:36 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_VORBIS_5CH_DEFAULT AF_CHANNEL_LAYOUT_5_0_C
|
|
|
|
#define AF_CHANNEL_LAYOUT_VORBIS_6CH_DEFAULT AF_CHANNEL_LAYOUT_5_1_C
|
2009-11-10 00:45:19 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_VORBIS_8CH_DEFAULT AF_CHANNEL_LAYOUT_7_1_C
|
2007-12-10 16:53:30 +00:00
|
|
|
|
|
|
|
#define AF_CHANNEL_MASK 0xFF
|
|
|
|
#define AF_GET_CH_NUM(A) ((A)&0x7F)
|
|
|
|
#define AF_GET_CH_NUM_WITH_LFE(A) ((A)&0xFF)
|
|
|
|
#define AF_IS_SAME_CH_NUM(A,B) (((A)&0xFF)==((B)&0xFF))
|
|
|
|
#define AF_IS_LAYOUT_SPECIFIED(A) ((A)&0xFFFFF800)
|
|
|
|
#define AF_IS_LAYOUT_UNSPECIFIED(A) (!AF_IS_LAYOUT_SPECIFIED(A))
|
|
|
|
|
|
|
|
/// Optimized channel reorder between channel layouts with same channel number.
|
|
|
|
void reorder_channel_copy(void *src,
|
|
|
|
int src_layout,
|
|
|
|
void *dest,
|
|
|
|
int dest_layout,
|
|
|
|
int samples,
|
|
|
|
int samplesize);
|
|
|
|
|
|
|
|
/// Same with reorder_channel_copy, but works on single buffer.
|
|
|
|
void reorder_channel(void *buf,
|
|
|
|
int src_layout,
|
|
|
|
int dest_layout,
|
|
|
|
int samples,
|
|
|
|
int samplesize);
|
|
|
|
|
|
|
|
// Channel layout definitions for different audio sources or targets
|
|
|
|
// When specified channel number, they will be map to the specific layouts.
|
2009-08-18 22:25:58 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_ALSA_DEFAULT 0
|
|
|
|
#define AF_CHANNEL_LAYOUT_AAC_DEFAULT 1
|
|
|
|
#define AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT 2
|
2009-08-18 22:24:36 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_LAVC_DEFAULT 3
|
|
|
|
#define AF_CHANNEL_LAYOUT_VORBIS_DEFAULT 4
|
2009-11-04 00:58:11 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_SOURCE_NUM 5
|
2007-12-10 16:53:30 +00:00
|
|
|
#define AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT AF_CHANNEL_LAYOUT_ALSA_DEFAULT
|
|
|
|
|
|
|
|
/// Optimized channel reorder between different audio sources and targets.
|
|
|
|
void reorder_channel_copy_nch(void *src,
|
|
|
|
int src_layout,
|
|
|
|
void *dest,
|
|
|
|
int dest_layout,
|
|
|
|
int chnum,
|
|
|
|
int samples,
|
|
|
|
int samplesize);
|
|
|
|
|
|
|
|
/// Same with reorder_channel_copy_nch, but works on single buffer.
|
|
|
|
void reorder_channel_nch(void *buf,
|
|
|
|
int src_layout,
|
|
|
|
int dest_layout,
|
|
|
|
int chnum,
|
|
|
|
int samples,
|
|
|
|
int samplesize);
|
|
|
|
|
2012-12-03 19:16:17 +00:00
|
|
|
/// Utility function for planar audio conversions
|
|
|
|
void reorder_to_planar(void *restrict out, const void *restrict in,
|
2012-12-21 17:13:16 +00:00
|
|
|
size_t size, size_t nchan, size_t nmemb);
|
|
|
|
void reorder_to_packed(uint8_t *out, uint8_t **in,
|
|
|
|
size_t size, size_t nchan, size_t nmemb);
|
2012-12-03 19:16:17 +00:00
|
|
|
|
2008-02-22 09:09:46 +00:00
|
|
|
#endif /* MPLAYER_REORDER_CH_H */
|