9是什么生肖| 家宴是什么意思| 梦龙什么口味好吃| 老是瞌睡是什么原因| 梦见面包是什么意思| 臻字五行属什么的| 3月20是什么星座| 属狗的守护神是什么菩萨| 女人为什么会宫外怀孕| 除湿气喝什么茶| 保持器是什么| ppd试验是什么意思| 黑乌龙茶属于什么茶| 开斋节是什么意思| 总是掉头发是什么原因| p2是什么意思| 杀鸡吓什么| 月经提前来是什么原因| 上海为什么叫申城| 左腿疼是什么原因| 黄面是什么面| 无语什么意思| p53野生型是什么意思| 儿童看牙齿挂什么科| 咖色是什么颜色| 省委组织部长是什么级别| 靶向药是什么药| 邮箱地址填什么| 居住证是什么| 女生被插是什么感觉| 60岁男人喜欢什么样的女人| 屁股长痘是什么原因| 茯苓是什么东西| 小孩黑眼圈很重是什么原因| 眼镜轴位是什么意思| 折耳猫为什么不能养| 嗓子发苦是什么原因| 陈皮泡水喝有什么功效和作用| 葡萄上的白霜是什么| 含蓄是什么意思| 吃什么有助于排便| 不可亵玩焉的亵是什么意思| 蓝风铃香水什么味道| 什么军什么马| 护理是干什么的| 男生被口是什么感觉| 一路卷风迎大年是什么生肖| 生理性囊肿是什么意思| 很黄很暴力是什么意思| 2月15日是什么星座| 为什么会突然长痣| 一鸣惊人指什么动物| 肛门周围痒是什么病| 三个代表代表了什么| 人山人海是什么生肖| 卿本佳人什么意思| 晚上睡觉手发麻是什么原因| 美莎片是什么药| 胃酸是什么症状| 西湖龙井属于什么茶| 做血常规检查挂什么科| 看见蜈蚣有什么预兆| 5.19是什么星座| 手上三条线分别代表什么| 性生活是什么| 为什么女的会流水怎么回事| 为什么容易被蚊子咬| 项韧带钙化是什么意思| 哪吒妈妈叫什么名字| 一什么秧苗| 发痧是什么原因造成的| 为什么一直流鼻血| 草字头加青读什么| 左舌根疼痛是什么情况| 被蚊子咬了涂什么| 饸烙面是什么面| 马天宇是什么民族| 孕激素是什么| 血糖高什么水果不能吃| 婴儿为什么喜欢趴着睡| 转隶是什么意思| 牛奶能做什么美食| 皮蛋是什么蛋| rag什么意思| 猴子怕什么| 尚书相当于现在的什么官| 2014年五行属什么| 女人梦见掉头发是什么征兆| 养殖什么| 生物钟什么意思| 黄牛用的什么抢票软件| 梅花鹿吃什么| 明朝什么时候灭亡| 澳大利亚有什么特产| 雌二醇高说明什么| 皮肤湿疹用什么药膏| 空白是什么意思| 梦见蛇被别人打死是什么兆头| 子宫发炎是什么原因引起的| 精华液是什么| 己未日五行属什么| 大麦茶是什么做的| 恶心想吐吃什么药| 什么是阴虚火旺| 苏打水喝了有什么好处| 2003年属羊的是什么命| 喉结下面是什么部位| 怀孕初期要注意什么| 罗贯中和施耐庵是什么关系| 腰不好挂什么科| 7.1是什么星座| 愤是什么生肖| 四联用药是些什么药| 女人胃寒吃什么好得快| 什么叫活佛| 胎位loa是什么意思| 大便干结是什么原因| 初潮是什么| 健康管理师是干什么的| 灯火通明是什么生肖| 桑葚不能和什么一起吃| 桀是什么意思| 绿痰吃什么药| 头痒用什么东西洗头最好| 轶是什么意思| 一冷就咳嗽是什么原因| 是什么符号| 抗坏血酸钠是什么| 牙周炎用什么药最见效| 盆腔炎吃什么药好| 舌面有裂纹是什么原因| 倒牙是什么意思| 胆汁反流是什么症状| 什么是大健康产业| 夫妻肺片有什么材料| 纽带是什么意思| 姑姐是什么意思| 减脂期吃什么| 鼻子干燥是什么原因| 真菌是什么原因引起的| cosplay是什么意思| 世界大同是什么意思| 什么伤口需要打破伤风| 什么空调好| 小孩黄疸高有什么危害| 白凉粉是什么| 2023年属兔的是什么命| 回门是什么意思| 牛鞭是什么东西| 出车前检查的目的是什么| 手抽筋吃什么药| 动土破土是什么意思| 动脉硬化有什么危害| 西京医院什么科室最强| 7月去青海带什么衣服| 垚字是什么意思| 醋泡黑豆有什么功效| 兑卦五行属什么| 乘胜追击什么意思| 乌鸡放什么炖补气补血| 眼睛看什么科| 抗心磷脂抗体是什么意思| 什么叫八字| 断裂是什么意思| 涤塔夫是什么面料| 什么的睡觉| 什么属于发物| 大腿肌肉跳动是什么原因| 处女座是什么星座| 头晕恶心想吐吃什么药| 爱出者爱返福往者福来是什么意思| 碗摔碎了预示着什么| 墨菲定律是什么意思| 梦见自己吐了是什么意思| 年年有今日岁岁有今朝什么意思| 1975属什么生肖| 麒麟到了北极会变成什么| 狗为什么会咬人| 为什么不能送手表| 一味是什么意思| 尿酸吃什么药| 玄学是什么| 什么叫丹毒| 阳起石是什么东西| 人工念什么字| 88年属龙的是什么命| 曾舜晞是什么星座| 口腔溃疡是什么原因| 抑菌液有什么作用| 盗墓笔记的结局是什么| rip是什么意思| 西瓜和什么榨汁好喝| 玉露茶属于什么茶| darling是什么意思| 每天一杯蜂蜜水有什么好处| 谢邀什么意思| 胎盘有什么用| 山人是什么意思| 细菌性阴道病用什么药| 经常吃红枣有什么好处和坏处| 开方是什么意思| 腰疼肚子疼是什么原因引起的| 手指腱鞘炎是什么原因造成的| 二月什么星座| 手术室为什么那么冷| 大蒜泡酒有什么功效| 阴茎硬度不够吃什么好| 脾大是什么意思| paba是什么药| 女s是什么| 什么叫留守儿童| 吃什么去肝火最快| 孕妇梦到蛇是什么意思| 吃什么可以补充雌激素| 双手麻木是什么原因| 局长是什么级别干部| 什么人不适合去高原| 敛是什么意思| 常喝普洱茶有什么好处| 右肺中叶索条什么意思| 吃什么健脾胃除湿气| 酸菜鱼用什么鱼| ccu病房什么意思| 敲定是什么意思| 李子什么人不能吃| 前列腺增生吃什么药| 什么中药化结石最厉害| 白天不咳嗽晚上咳嗽吃什么药| 霉菌性阴道炎用什么药好得快| 山东特产是什么生肖| 戒腊什么意思| 芒硝是什么东西| 肠梗阻什么症状| 夹层是什么意思| 日新月异是什么意思| 扫兴是什么意思| 佛跳墙是什么意思| 36是什么码| 姑息是什么意思| 易是什么意思| 头油是什么原因引起的| 老是放屁是什么原因| 升血小板吃什么药| 缓解是什么意思| 吹毛求疵什么意思| 6月5号是什么星座| 大虾炒什么菜好吃| 华盖什么意思| 儿加一笔是什么字| 猫来家门口有什么预兆| 什么叫感性的女人| 伏天是什么意思| 五月是什么季节| 东风是什么意思| 口腔经常溃疡是什么原因| 生殖感染用什么消炎药效果好| 肺气肿有什么症状| 棱是什么| 什么人不怕冷| johnny什么意思| 尿道结石有什么症状| 雨露均沾什么意思| 晨尿很黄是什么原因| 什么是体外射精| 百度

哪台车型最优秀 全球汽车媒体人给出了标准答案


Directory: ../../../ffmpeg/
File: src/libavfilter/af_apad.c
Date: 2025-08-04 00:43:16
Exec Total Coverage
Lines: 62 72 86.1%
Functions: 5 5 100.0%
Branches: 29 50 58.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2012 Michael Niedermayer
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 pad filter.
24 *
25 * Based on af_aresample.c
26 */
27
28 #include "libavutil/avstring.h"
29 #include "libavutil/channel_layout.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/samplefmt.h"
32 #include "libavutil/avassert.h"
33 #include "avfilter.h"
34 #include "audio.h"
35 #include "filters.h"
36
37 typedef struct APadContext {
38 const AVClass *class;
39 int64_t next_pts;
40
41 int eof;
42 int packet_size;
43 int64_t pad_len, pad_len_left;
44 int64_t whole_len, whole_len_left;
45 int64_t pad_dur;
46 int64_t whole_dur;
47 } APadContext;
48
49 #define OFFSET(x) offsetof(APadContext, x)
50 #define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
51
52 static const AVOption apad_options[] = {
53 { "packet_size", "set silence packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, { .i64 = 4096 }, 0, INT_MAX, A },
54 { "pad_len", "set number of samples of silence to add", OFFSET(pad_len), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, A },
55 { "whole_len", "set minimum target number of samples in the audio stream", OFFSET(whole_len), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, A },
56 { "pad_dur", "set duration of silence to add", OFFSET(pad_dur), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, A },
57 { "whole_dur", "set minimum target duration in the audio stream", OFFSET(whole_dur), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT64_MAX, A },
58 { NULL }
59 };
60
61 AVFILTER_DEFINE_CLASS(apad);
62
63 2 static av_cold int init(AVFilterContext *ctx)
64 {
65 2 APadContext *s = ctx->priv;
66
67 2 s->next_pts = AV_NOPTS_VALUE;
68
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if (s->whole_len >= 0 && s->pad_len >= 0) {
69 av_log(ctx, AV_LOG_ERROR, "Both whole and pad length are set, this is not possible\n");
70 return AVERROR(EINVAL);
71 }
72
73 2 return 0;
74 }
75
76 65 static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
77 {
78 65 AVFilterContext *ctx = inlink->dst;
79 65 APadContext *s = ctx->priv;
80
81
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 if (s->whole_len >= 0) {
82 s->whole_len_left = FFMAX(s->whole_len_left - frame->nb_samples, 0);
83 av_log(ctx, AV_LOG_DEBUG,
84 "n_out:%d whole_len_left:%"PRId64"\n", frame->nb_samples, s->whole_len_left);
85 }
86
87 65 s->next_pts = frame->pts + av_rescale_q(frame->nb_samples, (AVRational){1, inlink->sample_rate}, inlink->time_base);
88 65 return ff_filter_frame(ctx->outputs[0], frame);
89 }
90
91 2 static int push_frame(AVFilterLink *outlink)
92 {
93 2 AVFilterContext *ctx = outlink->src;
94 2 APadContext *s = ctx->priv;
95 AVFrame *outsamplesref;
96 int n_out;
97
98
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (ctx->is_disabled)
99 return 0;
100 2 n_out = s->packet_size;
101
102
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if (s->whole_len >= 0 && s->pad_len < 0) {
103 s->pad_len = s->pad_len_left = s->whole_len_left;
104 }
105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if (s->pad_len >=0 || s->whole_len >= 0) {
106 2 n_out = FFMIN(n_out, s->pad_len_left);
107 2 s->pad_len_left -= n_out;
108 2 av_log(ctx, AV_LOG_DEBUG,
109 "padding n_out:%d pad_len_left:%"PRId64"\n", n_out, s->pad_len_left);
110 }
111
112
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (!n_out)
113 1 return AVERROR_EOF;
114
115 1 outsamplesref = ff_get_audio_buffer(outlink, n_out);
116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (!outsamplesref)
117 return AVERROR(ENOMEM);
118
119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 av_assert0(outsamplesref->sample_rate == outlink->sample_rate);
120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 av_assert0(outsamplesref->nb_samples == n_out);
121
122 1 av_samples_set_silence(outsamplesref->extended_data, 0,
123 n_out,
124 outsamplesref->ch_layout.nb_channels,
125 1 outsamplesref->format);
126
127 1 outsamplesref->pts = s->next_pts;
128
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (s->next_pts != AV_NOPTS_VALUE)
129 1 s->next_pts += av_rescale_q(n_out, (AVRational){1, outlink->sample_rate}, outlink->time_base);
130
131 1 return ff_filter_frame(outlink, outsamplesref);
132 }
133
134 132 static int activate(AVFilterContext *ctx)
135 {
136 132 AVFilterLink *inlink = ctx->inputs[0];
137 132 AVFilterLink *outlink = ctx->outputs[0];
138 132 APadContext *s = ctx->priv;
139 int64_t pts;
140 int status;
141
142
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
132 FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
143
144
4/4
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 65 times.
✓ Branch 4 taken 66 times.
132 if (!s->eof && ff_inlink_queued_frames(inlink)) {
145 65 AVFrame *frame = NULL;
146 int ret;
147
148 65 ret = ff_inlink_consume_frame(inlink, &frame);
149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 if (ret < 0)
150 65 return ret;
151
1/2
✓ Branch 0 taken 65 times.
✗ Branch 1 not taken.
65 if (ret > 0)
152 65 return filter_frame(inlink, frame);
153 }
154
155
4/4
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 1 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 65 times.
67 if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts))
156 1 s->eof = status == AVERROR_EOF;
157
158
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 65 times.
67 if (s->eof) {
159 2 int ret = push_frame(outlink);
160
161
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 if (ret == AVERROR_EOF) {
162 1 ff_outlink_set_status(outlink, AVERROR_EOF, s->next_pts);
163 1 return 0;
164 }
165 1 return ret;
166 }
167
168
1/2
✓ Branch 1 taken 65 times.
✗ Branch 2 not taken.
65 FF_FILTER_FORWARD_WANTED(outlink, inlink);
169
170 return FFERROR_NOT_READY;
171 }
172
173 1 static int config_output(AVFilterLink *outlink)
174 {
175 1 AVFilterContext *ctx = outlink->src;
176 1 APadContext *s = ctx->priv;
177
178
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (s->pad_dur >= 0)
179 s->pad_len = av_rescale(s->pad_dur, outlink->sample_rate, AV_TIME_BASE);
180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (s->whole_dur >= 0)
181 s->whole_len = av_rescale(s->whole_dur, outlink->sample_rate, AV_TIME_BASE);
182
183 1 s->pad_len_left = s->pad_len;
184 1 s->whole_len_left = s->whole_len;
185
186 1 return 0;
187 }
188
189 static const AVFilterPad apad_outputs[] = {
190 {
191 .name = "default",
192 .type = AVMEDIA_TYPE_AUDIO,
193 .config_props = config_output,
194 },
195 };
196
197 const FFFilter ff_af_apad = {
198 .p.name = "apad",
199 .p.description = NULL_IF_CONFIG_SMALL("Pad audio with silence."),
200 .p.priv_class = &apad_class,
201 .p.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL,
202 .init = init,
203 .activate = activate,
204 .priv_size = sizeof(APadContext),
205 FILTER_INPUTS(ff_audio_default_filterpad),
206 FILTER_OUTPUTS(apad_outputs),
207 };
208

隐翅虫吃什么 情形是什么意思 长脸适合什么发型女 腱鞘炎用什么药能治好 制冰机不制冰是什么原因
长情是什么意思 ais什么意思 韩束适合什么年龄段的人用 猪肉什么馅的饺子好吃 熵是什么
肺活量5000什么水平 活菩萨是什么意思 满族不吃什么肉 小动脉瘤是什么意思 蜂王浆是什么味道
尿白细胞高是什么原因 莲字五行属什么 邮电局是干什么的 甲状腺结节3类什么意思 带鱼为什么是扁的
食管反流吃什么药hcv8jop3ns2r.cn 痹病是什么意思hcv9jop2ns4r.cn 射精是什么感觉hcv8jop0ns4r.cn 的确良是什么面料jiuxinfghf.com 盛情款待是什么意思hcv8jop4ns8r.cn
聚字五行属什么hcv9jop3ns0r.cn 耳朵里面疼用什么药hcv8jop1ns0r.cn 背后长疙瘩是什么原因hcv9jop7ns9r.cn 烫伤涂什么药膏hcv8jop9ns5r.cn 西瓜霜是什么hcv7jop4ns7r.cn
小鸟进屋有什么预兆吗hcv8jop3ns8r.cn 氪金是什么意思hcv9jop6ns3r.cn 前列腺增大钙化是什么意思wzqsfys.com 世界上最难的数学题是什么hcv8jop6ns5r.cn 两眼中间的位置叫什么hcv8jop8ns5r.cn
今年阴历是什么年hcv8jop7ns6r.cn 无花果什么时候种植cl108k.com 煲仔饭用什么米最好hebeidezhi.com cbd是什么意思啊hcv7jop9ns8r.cn 蛋白粉什么时间喝最好weuuu.com
百度