低血糖吃什么好的最快| 头经常晕是什么原因| 黄色有什么黄| 蓝色属于什么五行属性| 致五行属什么| 红加绿是什么颜色| 田童念什么| 死库水是什么| 胃寒吃什么好| 什么运动降血糖最快| 荻是什么意思| 甲状腺结节是什么病| 血晕症是什么病| 呼吸道感染用什么药| 丰富是什么意思| 原生家庭是什么意思| 胆黄素高是怎么回事有什么危害| 男人不尊重你说明什么| 高密度脂蛋白胆固醇偏高是什么意思| 塔罗牌正位和逆位是什么意思| 霸王别姬是什么生肖| 九二年属什么生肖| 老是肚子疼是什么原因| 黑蝴蝶代表什么| 男性硬不起来什么原因| 眩晕症什么症状| mrr是什么意思| 书香是什么意思| 一个日一个安念什么字| 慢性病都包括什么病| 慕名而来是什么意思| 吃什么让月经量增多| 6月30日是什么节日| 脸上长水泡似的痘痘是什么原因| 5s是什么意思| 吸氧机什么牌子好| 宝宝拉肚子能吃什么| 人参果总皂苷是什么| 同型半胱氨酸高有什么症状| 印度是什么制度的国家| 净空是什么意思| 内向的人适合什么工作| 就义是什么意思| 兰蔻适合什么年龄的人用| 特警力量第二部叫什么| 洋字五行属什么| 13层楼房有什么说法吗| 自言自语什么意思| 6月20日是什么星座| 什么药可以流产| 我行我素的人什么性格| 头不自觉的晃动是什么原因| 腹部彩超可以检查什么| 感觉是什么意思| 夏天吹什么风| 没有什么了不起| 手掌发热是什么原因| 肌肉疼是什么原因| 什么叫钙化了| 阴虚吃什么调理| 小便出血是什么原因| 疾苦的疾是什么意思| beyond是什么意思| 紫菜和海苔有什么区别| 私处痒用什么药| 铁树开花是什么生肖| 锦纶是什么材料| 宫腔灌注是治疗什么的| 抄经书有什么好处| 膝盖疼挂什么科室| 孕妇喝什么牛奶| 女人舌苔厚白吃什么药| 打嗝是什么毛病| 心阴虚吃什么中成药| 左手小手指麻木是什么原因引起的| 黄茶是什么茶| 大智若愚什么意思| 奔走相告是什么意思| 心烦焦虑吃什么药| 查血糖是什么检查项目| 荡气回肠什么意思| 乳腺无回声结节是什么意思| 维生素d滴剂什么时候吃最好| 皮肤是什么组织| 医院三甲是什么意思| 虾不能跟什么一起吃| 华妃娘娘是什么电视剧| 小孩子长白头发是什么原因| 药引子是什么意思| 女性脉弦是什么意思| 什么样的升旗仪式| 五位一体是什么| 肾精亏虚吃什么药最好| 男人耳朵大代表什么| 嗜酸性肉芽肿是什么病| 诸葛亮属相是什么生肖| 人爱出汗是什么原因| 饭前吃药和饭后吃药有什么区别| 粘膜充血水肿什么意思| 办结婚证需要什么| 藜麦是什么| 过敏性鼻炎吃什么水果好| 4月27号是什么星座| 什么是门户网站| 2.6号是什么星座| 存是什么生肖| 卵巢钙化灶是什么意思| 欲盖弥彰什么意思| 寒咳嗽吃什么药止咳效果好| 林可霉素主治什么病| 婴儿为什么喜欢趴着睡| 出水痘吃什么药| pppd是什么意思| 黄体破裂有什么症状| 耳朵不舒服是什么原因| 望尘莫及什么意思| 两面派是什么意思| 钢铁侠是什么意思| 什么原因导致脑出血| 什么是孤独| 乌合之众什么意思| 围绝经期吃什么药调理| 正事是什么意思| 癌胚抗原是什么| 什么的水井| 下午四五点是什么时辰| 6月16什么星座| 84年属什么生肖| 黄山四绝指的是什么| 三联律是什么意思| 灌肠什么感觉| 无产阶级是什么意思| 尿频尿急尿不尽吃什么药效果最好| 枪是什么生肖| 促甲状腺激素低是什么原因| 胃口不好吃什么| 幽门螺杆菌是什么意思| 长庚是什么意思| 双肾钙化灶是什么意思| 什么药治便秘| 前列腺增生有什么症状表现| 机警是什么意思| cor是什么意思| o型血与a型血生的孩子是什么血型| 什么是阳光抑郁症| 大条是什么意思| 青椒炒什么好吃又简单| 月柱桃花是什么意思| 类风湿关节炎吃什么药| 阴沟肠杆菌是什么病| 什么是菩提心| a2是什么材质| 龙虎山是什么地貌| 梦见战争是什么兆头| 哀大莫过于心死是什么意思| 乱点鸳鸯谱什么意思| 什么中生什么| 金牛男最烦什么女孩| 手牵手我们一起走是什么歌| 什么是随机血糖| 复方乙酰水杨酸片是什么药| 白色糠疹是什么原因引起的| 细胞骨架是由什么构成| 喝中药可以吃什么水果| 萎缩性鼻炎用什么药| 企鹅是什么意思| 博物馆里面有什么| 为什么会得肠梗阻| 什么盐好| 什么是速率| pola是什么牌子| 为什么蚊子喜欢咬我| 赢弱什么意思| 抑郁症吃的药叫什么| 秋葵有什么功效| 滴滴是什么意思| 玉米须能治什么病| 肝主疏泄是什么意思| 趴在桌子上睡觉有什么坏处| 羊水破了什么感觉| 人放屁多是什么原因| 红霉素软膏和眼膏有什么区别| 花可以组什么词| 卤素灯是什么灯| zoe什么意思| 别出心裁是什么生肖| 两只小船儿孤孤零零是什么歌| 梦见小黑蛇是什么预兆| 迪桑特属于什么档次| 什么是遗精| 红斑是什么皮肤病| 不自主的摇头是什么病| 猪肚搭配什么煲汤最好| 黄痰是什么原因| 奖励是什么意思| 月经不调吃什么药效果好| 鸡枞是什么| 绿色食品是什么| 太阳出来我爬山坡是什么歌| 胎盘可以治什么病| tr什么意思| 什么姿势容易怀孕| 扶她是什么意思| 穿刺活检是什么意思| 以身相许是什么意思| 肝部出现腹水是什么原因| 蒸鱼豉油什么时候放| 什么食物是养肝的| 赤藓糖醇是什么| 来减一笔是什么字| 微尘是什么意思| 手掌麻是什么原因引起的| 四不放过是指什么| 夏至吃什么食物| 通讯地址填什么| 做胃镜前喝的那个液体是什么| 青蛙像什么| 静息心率是什么意思| 迪奥是什么品牌| 腔隙性脑梗吃什么药| 什么是痔疮早期图片| 吃什么补钾食物有哪些| 玻尿酸有什么作用| 土地兼并是什么意思| 六月十号是什么星座| 高血糖挂什么科室的号| 乳腺钼靶是什么意思| 福星贵人是什么意思| 卵巢早衰是什么原因引起的| 黄瓜生吃有什么好处| 1994年什么命| 检查眼睛挂什么科| 支原体培养及药敏是检查什么| 抗药性是什么意思| 什么水果糖分最高| 欢五行属什么| 1940年属什么生肖| 倒模是什么意思| 静脉曲张是什么引起的| 商鞅姓什么| 嗜睡是什么症状| 人次什么意思| 白色糠疹是什么原因引起的| ra是什么病的缩写| 执迷不悟是什么生肖| 化学阉割什么意思| 男人吃四环素治什么病| 肿瘤最怕什么| 新生儿黄疸是什么原因引起的| 血糖高的人吃什么水果| 小葱拌豆腐的下一句是什么| 朋友圈发女朋友照片配什么文字| 血糖仪什么牌子的好用又准确| 承你吉言是什么意思| 布洛芬起什么作用| 新生儿吐奶什么原因| 热毒是什么| 心脏跳的快是什么原因| 天克地冲是什么意思| 毅五行属什么| 武则天代表什么生肖| 小孩下半夜咳嗽是什么原因| 串串房是什么意思| 11月9日是什么星座| 百度

麻辣天后利菁久未露面现身广州 罗志祥和欧弟同


Directory: ../../../ffmpeg/
File: src/libavfilter/af_channelmap.c
Date: 2025-08-04 00:43:16
Exec Total Coverage
Lines: 152 237 64.1%
Functions: 9 9 100.0%
Branches: 77 143 53.8%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2012 Google, Inc.
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * audio channel mapping filter
24 */
25
26 #include <ctype.h>
27
28 #include "libavutil/avstring.h"
29 #include "libavutil/channel_layout.h"
30 #include "libavutil/common.h"
31 #include "libavutil/mathematics.h"
32 #include "libavutil/mem.h"
33 #include "libavutil/opt.h"
34 #include "libavutil/samplefmt.h"
35
36 #include "audio.h"
37 #include "avfilter.h"
38 #include "filters.h"
39 #include "formats.h"
40
41 struct ChannelMap {
42 int in_channel;
43 int out_channel;
44 int in_channel_idx;
45 int out_channel_idx;
46 };
47
48 enum MappingMode {
49 MAP_NONE,
50 MAP_ONE_INT,
51 MAP_ONE_STR,
52 MAP_PAIR_INT_INT,
53 MAP_PAIR_INT_STR,
54 MAP_PAIR_STR_INT,
55 MAP_PAIR_STR_STR
56 };
57
58 typedef struct ChannelMapContext {
59 const AVClass *class;
60 char *mapping_str;
61 AVChannelLayout output_layout;
62 struct ChannelMap *map;
63 int nch;
64 enum MappingMode mode;
65
66 uint8_t **source_planes;
67 } ChannelMapContext;
68
69 #define OFFSET(x) offsetof(ChannelMapContext, x)
70 #define A AV_OPT_FLAG_AUDIO_PARAM
71 #define F AV_OPT_FLAG_FILTERING_PARAM
72 static const AVOption channelmap_options[] = {
73 { "map", "A comma-separated list of input channel numbers in output order.",
74 OFFSET(mapping_str), AV_OPT_TYPE_STRING, .flags = A|F },
75 { "channel_layout", "Output channel layout.",
76 OFFSET(output_layout), AV_OPT_TYPE_CHLAYOUT, .flags = A|F },
77 { NULL }
78 };
79
80 AVFILTER_DEFINE_CLASS(channelmap);
81
82 114 static void channelmap_uninit(AVFilterContext *ctx)
83 {
84 114 ChannelMapContext *s = ctx->priv;
85 114 av_freep(&s->map);
86 114 av_freep(&s->source_planes);
87 114 }
88
89 460 static char* split(char *message, char delim) {
90 460 char *next = strchr(message, delim);
91
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 110 times.
460 if (next)
92 350 *next++ = '\0';
93 460 return next;
94 }
95
96 192 static int get_channel_idx(char **map, int *ch, char delim)
97 {
98 char *next;
99 int len;
100 192 int n = 0;
101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if (!*map)
102 return AVERROR(EINVAL);
103 192 next = split(*map, delim);
104
3/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 106 times.
192 if (!next && delim == '-')
105 return AVERROR(EINVAL);
106 192 len = strlen(*map);
107 192 sscanf(*map, "%d%n", ch, &n);
108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if (n != len)
109 return AVERROR(EINVAL);
110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if (*ch < 0)
111 return AVERROR(EINVAL);
112 192 *map = next;
113 192 return 0;
114 }
115
116 268 static int get_channel(char **map, int *ch, char delim)
117 {
118 268 char *next = split(*map, delim);
119
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 264 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
268 if (!next && delim == '-')
120 return AVERROR(EINVAL);
121 268 *ch = av_channel_from_string(*map);
122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
268 if (*ch < 0)
123 return AVERROR(EINVAL);
124 268 *map = next;
125 268 return 0;
126 }
127
128 516 static int check_idx_and_id(AVFilterContext *ctx, int channel_idx, int channel, AVChannelLayout *ch_layout, const char *io)
129 {
130 char channel_name[64];
131 char layout_name[256];
132 516 int nb_channels = ch_layout->nb_channels;
133
134
2/4
✓ Branch 0 taken 516 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 516 times.
516 if (channel_idx < 0 || channel_idx >= nb_channels) {
135 av_channel_layout_describe(ch_layout, layout_name, sizeof(layout_name));
136 if (channel >= 0) {
137 av_channel_name(channel_name, sizeof(channel_name), channel);
138 av_log(ctx, AV_LOG_ERROR,
139 "%sput channel '%s' not available from %sput layout '%s'\n",
140 io, channel_name, io, layout_name);
141 } else {
142 av_log(ctx, AV_LOG_ERROR,
143 "%sput channel #%d not available from %sput layout '%s'\n",
144 io, channel_idx, io, layout_name);
145 }
146 return AVERROR(EINVAL);
147 }
148
149 516 return 0;
150 }
151
152 114 static av_cold int channelmap_init(AVFilterContext *ctx)
153 {
154 114 ChannelMapContext *s = ctx->priv;
155 114 char *mapping, separator = '|';
156 114 int map_entries = 0;
157 enum MappingMode mode;
158 114 int64_t out_ch_mask = 0;
159 114 uint8_t *presence_map = NULL;
160 114 int ret = 0;
161 int i;
162
163 114 mapping = s->mapping_str;
164
165
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if (!mapping) {
166 4 mode = MAP_NONE;
167 } else {
168 110 char *dash = strchr(mapping, '-');
169
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 2 times.
110 if (!dash) { // short mapping
170
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 2 times.
108 if (av_isdigit(*mapping))
171 106 mode = MAP_ONE_INT;
172 else
173 2 mode = MAP_ONE_STR;
174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 } else if (av_isdigit(*mapping)) {
175 if (av_isdigit(*(dash+1)))
176 mode = MAP_PAIR_INT_INT;
177 else
178 mode = MAP_PAIR_INT_STR;
179 } else {
180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (av_isdigit(*(dash+1)))
181 mode = MAP_PAIR_STR_INT;
182 else
183 2 mode = MAP_PAIR_STR_STR;
184 }
185 }
186
187
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 4 times.
114 if (mode != MAP_NONE) {
188 110 char *sep = mapping;
189 110 map_entries = 1;
190
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 110 times.
328 while ((sep = strchr(sep, separator))) {
191
1/2
✓ Branch 0 taken 218 times.
✗ Branch 1 not taken.
218 if (*++sep) // Allow trailing comma
192 218 map_entries++;
193 }
194
195 110 s->map = av_malloc_array(map_entries, sizeof(*s->map));
196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if (!s->map)
197 return AVERROR(ENOMEM);
198 }
199
200
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 114 times.
442 for (i = 0; i < map_entries; i++) {
201 328 int in_ch_idx = -1, out_ch_idx = -1;
202 328 int in_ch = -1, out_ch = -1;
203 static const char err[] = "Failed to parse channel map\n";
204
205 328 s->map[i].in_channel_idx = -1;
206 328 s->map[i].out_channel_idx = -1;
207 328 s->map[i].in_channel = -1;
208 328 s->map[i].out_channel = -1;
209
210
3/7
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
✗ Branch 6 not taken.
328 switch (mode) {
211 192 case MAP_ONE_INT:
212
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 192 times.
192 if (get_channel_idx(&mapping, &in_ch_idx, separator) < 0) {
213 av_log(ctx, AV_LOG_ERROR, err);
214 return AVERROR(EINVAL);
215 }
216 192 s->map[i].in_channel_idx = in_ch_idx;
217 192 s->map[i].out_channel_idx = i;
218 192 break;
219 4 case MAP_ONE_STR:
220
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 if (get_channel(&mapping, &in_ch, separator) < 0) {
221 av_log(ctx, AV_LOG_ERROR, err);
222 return AVERROR(EINVAL);
223 }
224 4 s->map[i].in_channel = in_ch;
225 4 s->map[i].out_channel_idx = i;
226 4 break;
227 case MAP_PAIR_INT_INT:
228 if (get_channel_idx(&mapping, &in_ch_idx, '-') < 0 ||
229 get_channel_idx(&mapping, &out_ch_idx, separator) < 0) {
230 av_log(ctx, AV_LOG_ERROR, err);
231 return AVERROR(EINVAL);
232 }
233 s->map[i].in_channel_idx = in_ch_idx;
234 s->map[i].out_channel_idx = out_ch_idx;
235 break;
236 case MAP_PAIR_INT_STR:
237 if (get_channel_idx(&mapping, &in_ch_idx, '-') < 0 ||
238 get_channel(&mapping, &out_ch, separator) < 0) {
239 av_log(ctx, AV_LOG_ERROR, err);
240 return AVERROR(EINVAL);
241 }
242 s->map[i].in_channel_idx = in_ch_idx;
243 s->map[i].out_channel = out_ch;
244 if (out_ch < 63)
245 out_ch_mask |= 1ULL << out_ch;
246 else
247 out_ch_mask = -1;
248 break;
249 case MAP_PAIR_STR_INT:
250 if (get_channel(&mapping, &in_ch, '-') < 0 ||
251 get_channel_idx(&mapping, &out_ch_idx, separator) < 0) {
252 av_log(ctx, AV_LOG_ERROR, err);
253 return AVERROR(EINVAL);
254 }
255 s->map[i].in_channel = in_ch;
256 s->map[i].out_channel_idx = out_ch_idx;
257 break;
258 132 case MAP_PAIR_STR_STR:
259
2/4
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 132 times.
264 if (get_channel(&mapping, &in_ch, '-') < 0 ||
260 132 get_channel(&mapping, &out_ch, separator) < 0) {
261 av_log(ctx, AV_LOG_ERROR, err);
262 return AVERROR(EINVAL);
263 }
264 132 s->map[i].in_channel = in_ch;
265 132 s->map[i].out_channel = out_ch;
266
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 128 times.
132 if (out_ch < 63)
267 4 out_ch_mask |= 1ULL << out_ch;
268 else
269 128 out_ch_mask = -1;
270 132 break;
271 }
272 }
273 114 s->mode = mode;
274 114 s->nch = map_entries;
275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (s->output_layout.nb_channels == 0) {
276 if (out_ch_mask > 0)
277 av_channel_layout_from_mask(&s->output_layout, out_ch_mask);
278 else if (map_entries)
279 av_channel_layout_default(&s->output_layout, map_entries);
280 }
281
282
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 110 times.
114 if (mode == MAP_NONE) {
283 int i;
284 4 s->nch = s->output_layout.nb_channels;
285
286 4 s->map = av_malloc_array(s->nch, sizeof(*s->map));
287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!s->map)
288 return AVERROR(ENOMEM);
289
290
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for (i = 0; i < s->nch; i++) {
291 16 s->map[i].in_channel_idx = i;
292 16 s->map[i].out_channel_idx = i;
293 16 s->map[i].out_channel = av_channel_layout_channel_from_index(&s->output_layout, i);
294 }
295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 } else if (s->nch != s->output_layout.nb_channels) {
296 char buf[256];
297 av_channel_layout_describe(&s->output_layout, buf, sizeof(buf));
298 av_log(ctx, AV_LOG_ERROR,
299 "Output channel layout %s does not match the number of channels mapped %d.\n",
300 buf, s->nch);
301 return AVERROR(EINVAL);
302 }
303
304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (!s->output_layout.nb_channels) {
305 av_log(ctx, AV_LOG_ERROR, "Output channel layout is not set and "
306 "cannot be guessed from the maps.\n");
307 return AVERROR(EINVAL);
308 }
309
310
3/4
✓ Branch 0 taken 114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 112 times.
114 if (mode == MAP_PAIR_INT_STR || mode == MAP_PAIR_STR_STR) {
311
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 2 times.
134 for (i = 0; i < s->nch; i++) {
312 132 s->map[i].out_channel_idx = av_channel_layout_index_from_channel(
313 132 &s->output_layout, s->map[i].out_channel);
314 }
315 }
316
317 114 presence_map = av_calloc(s->nch, sizeof(*presence_map));
318
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 114 times.
458 for (i = 0; i < s->nch; i++) {
319 344 const int out_idx = s->map[i].out_channel_idx;
320 344 ret = check_idx_and_id(ctx, out_idx, s->map[i].out_channel, &s->output_layout, "out");
321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 if (ret < 0)
322 break;
323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344 times.
344 if (presence_map[out_idx]) {
324 char layout_name[256];
325 av_channel_layout_describe(&s->output_layout, layout_name, sizeof(layout_name));
326 av_log(ctx, AV_LOG_ERROR, "Mapping %d assigns channel #%d twice in output layout '%s'.\n",
327 i + 1, s->map[i].out_channel_idx, layout_name);
328 ret = AVERROR(EINVAL);
329 break;
330 }
331 344 presence_map[out_idx] = 1;
332 }
333 114 av_freep(&presence_map);
334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (ret < 0)
335 return ret;
336
337 114 return 0;
338 }
339
340 57 static int channelmap_query_formats(const AVFilterContext *ctx,
341 AVFilterFormatsConfig **cfg_in,
342 AVFilterFormatsConfig **cfg_out)
343 {
344 57 const ChannelMapContext *s = ctx->priv;
345 57 AVFilterChannelLayouts *channel_layouts = NULL;
346
347 int ret;
348
349 57 ret = ff_set_common_formats2(ctx, cfg_in, cfg_out, ff_planar_sample_fmts());
350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (ret < 0)
351 return ret;
352
353 57 ret = ff_add_channel_layout(&channel_layouts, &s->output_layout);
354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (ret < 0)
355 return ret;
356
357 57 ret = ff_channel_layouts_ref(channel_layouts, &cfg_out[0]->channel_layouts);
358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (ret < 0)
359 return ret;
360
361 57 return 0;
362 }
363
364 826 static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf)
365 {
366 826 AVFilterContext *ctx = inlink->dst;
367 826 AVFilterLink *outlink = ctx->outputs[0];
368 826 const ChannelMapContext *s = ctx->priv;
369 826 const int nch_in = inlink->ch_layout.nb_channels;
370 826 const int nch_out = s->nch;
371 int ch, ret;
372
373 826 memcpy(s->source_planes, buf->extended_data,
374 nch_in * sizeof(s->source_planes[0]));
375
376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
826 if (nch_out > nch_in) {
377 if (nch_out > FF_ARRAY_ELEMS(buf->data)) {
378 uint8_t **new_extended_data =
379 av_calloc(nch_out, sizeof(*buf->extended_data));
380 if (!new_extended_data) {
381 av_frame_free(&buf);
382 return AVERROR(ENOMEM);
383 }
384 if (buf->extended_data == buf->data) {
385 buf->extended_data = new_extended_data;
386 } else {
387 av_free(buf->extended_data);
388 buf->extended_data = new_extended_data;
389 }
390 } else if (buf->extended_data != buf->data) {
391 av_free(buf->extended_data);
392 buf->extended_data = buf->data;
393 }
394 }
395
396
2/2
✓ Branch 0 taken 2174 times.
✓ Branch 1 taken 826 times.
3000 for (ch = 0; ch < nch_out; ch++) {
397 2174 buf->extended_data[s->map[ch].out_channel_idx] =
398 2174 s->source_planes[s->map[ch].in_channel_idx];
399 }
400
401
2/2
✓ Branch 0 taken 517 times.
✓ Branch 1 taken 309 times.
826 if (buf->data != buf->extended_data)
402 517 memcpy(buf->data, buf->extended_data,
403
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 1 times.
517 FFMIN(FF_ARRAY_ELEMS(buf->data), nch_out) * sizeof(buf->data[0]));
404
405
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 826 times.
826 if ((ret = av_channel_layout_copy(&buf->ch_layout, &outlink->ch_layout)) < 0)
406 return ret;
407
408 826 return ff_filter_frame(outlink, buf);
409 }
410
411 57 static int channelmap_config_input(AVFilterLink *inlink)
412 {
413 57 AVFilterContext *ctx = inlink->dst;
414 57 ChannelMapContext *s = ctx->priv;
415 57 int i, err = 0;
416
417
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 57 times.
229 for (i = 0; i < s->nch; i++) {
418 172 struct ChannelMap *m = &s->map[i];
419
420
5/6
✓ Branch 0 taken 172 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 104 times.
172 if (s->mode == MAP_PAIR_STR_INT || s->mode == MAP_PAIR_STR_STR || s->mode == MAP_ONE_STR) {
421 68 m->in_channel_idx = av_channel_layout_index_from_channel(
422 68 &inlink->ch_layout, m->in_channel);
423 }
424
425
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 172 times.
172 if (check_idx_and_id(ctx, m->in_channel_idx, m->in_channel, &inlink->ch_layout, "in") < 0)
426 err = AVERROR(EINVAL);
427 }
428
429 57 av_freep(&s->source_planes);
430 57 s->source_planes = av_calloc(inlink->ch_layout.nb_channels,
431 sizeof(*s->source_planes));
432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if (!s->source_planes)
433 return AVERROR(ENOMEM);
434
435 57 return err;
436 }
437
438 static const AVFilterPad avfilter_af_channelmap_inputs[] = {
439 {
440 .name = "default",
441 .type = AVMEDIA_TYPE_AUDIO,
442 .flags = AVFILTERPAD_FLAG_NEEDS_WRITABLE,
443 .filter_frame = channelmap_filter_frame,
444 .config_props = channelmap_config_input,
445 },
446 };
447
448 const FFFilter ff_af_channelmap = {
449 .p.name = "channelmap",
450 .p.description = NULL_IF_CONFIG_SMALL("Remap audio channels."),
451 .p.priv_class = &channelmap_class,
452 .init = channelmap_init,
453 .uninit = channelmap_uninit,
454 .priv_size = sizeof(ChannelMapContext),
455 FILTER_INPUTS(avfilter_af_channelmap_inputs),
456 FILTER_OUTPUTS(ff_audio_default_filterpad),
457 FILTER_QUERY_FUNC2(channelmap_query_formats),
458 };
459

什么血型最多 12月22号是什么星座 七月份适合种什么蔬菜 yrc是什么牌子的鞋 热射病是什么
口臭看什么科室 老人手抖是什么病的预兆 高血压不能吃什么水果 蟑螂对人体有什么危害 打醮是什么意思
手脚发麻什么原因 肝郁化火是什么意思 故人什么意思 抽烟有什么危害 白带发黄粘稠是什么原因
什么是三界五行 荷花象征着什么 月经不调吃什么调理 厅堂是什么意思 60岁生日送什么礼物
怀孕有什么特征和反应hcv8jop9ns2r.cn 专项变应原筛查是什么hcv9jop5ns7r.cn 尿检ph值偏高说明什么hcv9jop2ns7r.cn 牙齿吃甜的就会疼什么原因hcv9jop0ns3r.cn 口腔溃疡看什么科室hcv8jop9ns5r.cn
脚上有青筋是什么原因hcv9jop4ns2r.cn c4是什么hcv7jop5ns2r.cn 痔疮有什么特征hcv7jop9ns8r.cn 为什么会胃痛hcv8jop3ns2r.cn 有痔疮不能吃什么食物hcv7jop4ns6r.cn
扁桃体发炎不能吃什么hcv9jop6ns1r.cn 离是什么生肖hcv7jop9ns9r.cn 2岁什么都听懂但不说话hcv8jop3ns6r.cn 甘耳朵旁什么字wmyky.com 肩周炎是什么原因造成的hcv9jop0ns9r.cn
宫颈口大是什么原因hcv8jop1ns4r.cn 肛裂是什么原因引起的hcv7jop6ns4r.cn 益气养阴是什么意思hcv8jop3ns5r.cn 蚯蚓吃什么hcv9jop7ns1r.cn wbc是什么意思医学hcv8jop7ns4r.cn
百度