/*
* Copyright (C) 2011 Michael Niedermayer (michaelni@gmx.at)
* Copyright (c) 2012 Justin Ruggles <justin.ruggles@gmail.com>
*
* This file is part of Libav.
*
* Libav 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.
*
* Libav 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include "libavutil/common.h"
#include "libavutil/libm.h"
#include "libavutil/samplefmt.h"
#include "avresample.h"
#include "internal.h"
#include "audio_data.h"
#include "audio_mix.h"
/* channel positions */
#define FRONT_LEFT 0
#define FRONT_RIGHT 1
#define FRONT_CENTER 2
#define LOW_FREQUENCY 3
#define BACK_LEFT 4
#define BACK_RIGHT 5
#define FRONT_LEFT_OF_CENTER 6
#define FRONT_RIGHT_OF_CENTER 7
#define BACK_CENTER 8
#define SIDE_LEFT 9
#define SIDE_RIGHT 10
#define TOP_CENTER 11
#define TOP_FRONT_LEFT 12
#define TOP_FRONT_CENTER 13
#define TOP_FRONT_RIGHT 14
#define TOP_BACK_LEFT 15
#define TOP_BACK_CENTER 16
#define TOP_BACK_RIGHT 17
#define STEREO_LEFT 29
#define STEREO_RIGHT 30
#define WIDE_LEFT 31
#define WIDE_RIGHT 32
#define SURROUND_DIRECT_LEFT 33
#define SURROUND_DIRECT_RIGHT 34
#define LOW_FREQUENCY_2 35
#define SQRT3_2 1.22474487139158904909 /* sqrt(3/2) */
static av_always_inline int even(uint64_t layout)
{
return (!layout || (layout & (layout - 1)));
}
static int sane_layout(uint64_t layout)
{
/* check that there is at least 1 front speaker */
if (!(layout & AV_CH_LAYOUT_SURROUND))
return 0;
/* check for left/right symmetry */
if (!even(layout & (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT)) ||
!even(layout & (AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)) ||
!even(layout & (AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT)) ||
!even(layout & (AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)) ||
!even(layout & (AV_CH_TOP_FRONT_LEFT | AV_CH_TOP_FRONT_RIGHT)) ||
!even(layout & (AV_CH_TOP_BACK_LEFT | AV_CH_TOP_BACK_RIGHT)) ||
!even(layout & (AV_CH_STEREO_LEFT | AV_CH_STEREO_RIGHT)) ||
!even(layout & (AV_CH_WIDE_LEFT | AV_CH_WIDE_RIGHT)) ||
!even(layout & (AV_CH_SURROUND_DIRECT_LEFT | AV_CH_SURROUND_DIRECT_RIGHT)))
return 0;
return 1;
}
int avresample_build_matrix(uint64_t in_layout, uint64_t out_layout,
double center_mix_level, double surround_mix_level,
double lfe_mix_level, int normalize,
double *matrix_out, int stride,
enum AVMatrixEncoding matrix_encoding)
{
int i, j, out_i, out_j;
double matrix[64][64] = {{0}};
int64_t unaccounted;
double maxcoef = 0;
int in_channels, out_channels;
if ((out_layout & AV_CH_LAYOUT_STEREO_DOWNMIX) == AV_CH_LAYOUT_STEREO_DOWNMIX) {
out_layout = AV_CH_LAYOUT_STEREO;
}
unaccounted = in_layout & ~out_layout;
in_channels = av_get_channel_layout_nb_channels( in_layout);
out_channels = av_get_channel_layout_nb_channels(out_layout);
memset(matrix_out, 0, out_channels * stride * sizeof(*matrix_out));
/* check if layouts are supported */
if (!in_layout || in_channels > AVRESAMPLE_MAX_CHANNELS)
return AVERROR(EINVAL);
if (!out_layout || out_channels > AVRESAMPLE_MAX_CHANNELS)
return AVERROR(EINVAL);
/* check if layouts are unbalanced or abnormal */
if (!sane_layout(in_layout) || !sane_layout(out_layout))
return AVERROR_PATCHWELCOME;
/* route matching input/output channels */
for (i = 0; i < 64; i++) {
if (in_layout & out_layout & (1ULL << i))
matrix[i][i] = 1.0;
}
/* mix front center to front left/right */
if (unaccounted & AV_CH_FRONT_CENTER) {
if ((out_layout & AV_CH_LAYOUT_STEREO) == AV_CH_LAYOUT_STEREO) {
matrix[FRONT_LEFT ][FRONT_CENTER] += M_SQRT1_2;
matrix[FRONT_RIGHT][FRONT_CENTER] += M_SQRT1_2;
} else
return AVERROR_PATCHWELCOME;
}
/* mix front left/right to center */
if (unaccounted & AV_CH_LAYOUT_STEREO) {
if (out_layout & AV_CH_FRONT_CENTER) {
matrix[FRONT_CENTER][FRONT_LEFT ] += M_SQRT1_2;
matrix[FRONT_CENTER][FRONT_RIGHT] += M_SQRT1_2;
/* mix left/right/center to center */
if (in_layout & AV_CH_FRONT_CENTER)
matrix[FRONT_CENTER][FRONT_CENTER] = center_mix_level * M_SQRT2;
} else
return AVERROR_PATCHWELCOME;
}
/* mix back center to back, side, or front */
if (unaccounted & AV_CH_BACK_CENTER) {
if (out_layout & AV_CH_BACK_LEFT) {
matrix[BACK_LEFT ][BACK_CENTER] += M_SQRT1_2;
matrix[BACK_RIGHT][BACK_CENTER] += M_SQRT1_2;
} else if (out_layout & AV_CH_SIDE_LEFT) {
matrix[SIDE_LEFT ][BACK_CENTER] += M_SQRT1_2;
matrix[SIDE_RIGHT][BACK_CENTER] += M_SQRT1_2;
} else if (out_layout & AV_CH_FRONT_LEFT) {
if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY ||
matrix_encoding == AV_MATRIX_ENCODING_DPLII) {
if (unaccounted & (AV_CH_BACK_LEFT | AV_CH_SIDE_LEFT)) {
matrix[FRONT_LEFT ][BACK_CENTER] -= surround_mix_level * M_SQRT1_2;
matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
} else {
matrix[FRONT_LEFT ][BACK_CENTER] -= surround_mix_level;
matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level;
}
} else {
matrix[FRONT_LEFT ][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
matrix[FRONT_RIGHT][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
}
} else if (out_layout & AV_CH_FRONT_CENTER) {
matrix[FRONT_CENTER][BACK_CENTER] += surround_mix_level * M_SQRT1_2;
} else
return AVERROR_PATCHWELCOME;
}
/* mix back left/right to back center, side, or front */
if (unaccounted & AV_CH_BACK_LEFT) {
if (out_layout & AV_CH_BACK_CENTER) {
matrix[BACK_CENTER][BACK_LEFT ] += M_SQRT1_2;
matrix[BACK_CENTER][BACK_RIGHT] += M_SQRT1_2;
} else if (out_layout & AV_CH_SIDE_LEFT) {
/* if side channels do not exist in the input, just copy back
channels to side channels, otherwise mix back into side */
if (in_layout & AV_CH_SIDE_LEFT) {
matrix[SIDE_LEFT ][BACK_LEFT ] += M_SQRT1_2;
matrix[SIDE_RIGHT][BACK_RIGHT] += M_SQRT1_2;
} else {
matrix[SIDE_LEFT ][BACK_LEFT ] += 1.0;
matrix[SIDE_RIGHT][BACK_RIGHT] += 1.0;
}
} else if (out_layout & AV_CH_FRONT_LEFT) {
if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY) {
matrix[FRONT_LEFT ][BACK_LEFT ] -= surround_mix_level * M_SQRT1_2;
matrix[FRONT_LEFT ][BACK_RIGHT] -= surround_mix_level * M_SQRT1_2;
matrix[FRONT_RIGHT][BACK_LEFT ] += surround_mix_level * M_SQRT1_2;
没有合适的资源?快使用搜索试试~ 我知道了~
RTSP视频播放器客户端
共1217个文件
h:612个
hh:332个
tlog:61个
5星 · 超过95%的资源 需积分: 32 66 下载量 82 浏览量
2017-07-05
16:18:20
上传
评论 5
收藏 43.97MB RAR 举报
温馨提示
RTSP视频播放器客户端
资源推荐
资源详情
资源评论
收起资源包目录
RTSP视频播放器客户端 (1217个子文件)
libavcodec.dll.a 184KB
libavcodec.dll.a 184KB
libavutil.dll.a 166KB
libavutil.dll.a 166KB
libavfilter.dll.a 117KB
libavfilter.dll.a 117KB
libavformat.dll.a 88KB
libavformat.dll.a 88KB
libswresample.dll.a 69KB
libswresample.dll.a 69KB
libswscale.dll.a 23KB
libswscale.dll.a 23KB
libpostproc.dll.a 6KB
libpostproc.dll.a 6KB
libavdevice.dll.a 3KB
libavdevice.dll.a 3KB
SmartPlayer.aps 286KB
audio_convert.asm 43KB
audio_convert.asm 43KB
audio_mix.asm 14KB
audio_mix.asm 14KB
util.asm 1KB
util.asm 1KB
playwndbackground.bmp 158KB
audio_mix_matrix.c 17KB
audio_mix_matrix.c 17KB
utils.c 16KB
utils.c 16KB
audio_convert.c 16KB
audio_convert.c 16KB
audio_convert_init.c 15KB
audio_convert_init.c 15KB
audio_mix.c 15KB
audio_mix.c 15KB
resample.c 15KB
resample.c 15KB
audio_mix_init.c 13KB
audio_mix_init.c 13KB
avresample-test.c 12KB
avresample-test.c 12KB
audio_data.c 10KB
audio_data.c 10KB
options.c 7KB
options.c 7KB
resample_template.c 3KB
resample_template.c 3KB
strtod.c 3KB
strtod.c 3KB
getopt.c 2KB
getopt.c 2KB
snprintf.c 2KB
snprintf.c 2KB
audio_convert_init.c 2KB
audio_convert_init.c 2KB
RtspPlayer.cpp 28KB
SmartPlayerDlg.cpp 9KB
InputURLDlg.cpp 4KB
SmartPlayer.cpp 4KB
ourRTSPClient.cpp 3KB
stdafx.cpp 215B
stdafx.cpp 144B
avcodec-54.dll 14.35MB
avcodec-54.dll 14.35MB
avformat-54.dll 2.77MB
avformat-54.dll 2.77MB
avfilter-3.dll 1.66MB
avfilter-3.dll 1.66MB
mediasipdll.dll 1.25MB
mediasipdll.dll 1.25MB
avdevice-54.dll 382KB
avdevice-54.dll 382KB
swscale-2.dll 326KB
swscale-2.dll 326KB
SDL.dll 297KB
SDL.dll 297KB
avutil-51.dll 230KB
avutil-51.dll 230KB
postproc-52.dll 174KB
postproc-52.dll 174KB
libexpat.dll 140KB
libexpat.dll 140KB
swresample-0.dll 107KB
swresample-0.dll 107KB
SmartPlayer.vcxproj.filters 2KB
RtspPlayer.vcxproj.filters 2KB
SDL_opengl.h 329KB
SDL_opengl.h 329KB
avcodec.h 162KB
avcodec.h 162KB
iedef.h 112KB
iedef.h 112KB
oci.h 108KB
oci.h 108KB
avcodec.h 97KB
avcodec.h 97KB
avformat.h 75KB
avformat.h 75KB
miointerface.h 62KB
miointerface.h 62KB
avformat.h 41KB
共 1217 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
DaveBobo
- 粉丝: 742
- 资源: 52
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页