吃什么水果对胃好| 杨家将是什么生肖| 塞保妇康为什么会出血| 泡泡棉是什么面料| 新疆为什么天黑的晚| 胃烧心吃什么食物好| 腺肌症不治疗会导致什么结果| 肝囊肿有什么危害| 什么心所什么| 牙齿黑是什么原因| 麦露迪女鞋什么档次| 云母是什么东西| 芝麻开花节节高是什么意思| 走路快的人是什么性格| 生理期肚子疼吃什么药| 蓝色预警是什么级别| 去心火喝什么茶好| 孕前检查挂什么科室| 濡养是什么意思| 呼吸困难是什么原因| 微信什么时候有的| 输卵管为什么会堵塞原因是什么| 酉时是什么时候| 黄色是什么颜色组成的| 水是由什么组成的| 稽留流产是什么意思| 好朋友是什么意思| ac是什么意思| 手足口是什么引起的| 筋是什么组织| 白发缺少什么维生素| 迟脉是什么意思| 三年级用什么笔| saa是什么意思| 风流人物指什么生肖| 木槿花的花语是什么| 刷单是什么意思| 手指麻木是什么原因引起的| 文号是什么| 痛风吃什么药效果好| 鸡奸是什么意思| 细菌性毛囊炎用什么药| 坐疮是什么样的图片| 势利眼的人有什么特征| 什么什么满门| 唠嗑是什么意思| 减肥喝什么饮料| 镭是什么| 哺乳期什么东西不能吃| 拖鞋什么材质的好| 喝苦荞茶有什么好处| 男人胡子长得快是什么原因| 抑郁症什么症状表现| 眼白发黄是什么原因| 为什么趴着睡觉会胀气然后打嗝| 1.7号是什么星座| 八面玲珑是什么数字| 身体起水泡是什么病症| 5月3日什么星座| 十月七号什么星座| 验孕棒一深一浅代表什么| 11.11什么星座| 情何以堪是什么意思| 蓝光有什么作用| loves是什么意思| 欲什么意思| 什么是管制| ckd是什么意思| 5月31号是什么星座| 白喉采取什么隔离| 身上老是痒是什么原因| 孕前检查挂什么科| 鸭蛋炒什么好吃| 献血前要注意什么| 女右眉毛跳是什么预兆| 定量是什么意思| 谝是什么意思| dine是什么意思| 红绿色盲是什么遗传病| 黄精有什么作用和功效| 药流后吃什么消炎药| 舌苔黄腻吃什么中成药| 屁股长痣代表什么| 年轮稀疏的一面是什么方向| 95511是什么电话| 学子是什么意思| 喉软骨发育不良有什么症状| 妄想症是什么意思| 狮子座与什么星座最配| 三和大神是什么意思| 沙发是什么头发| 女人梦见狼是什么预兆| 枫叶什么颜色| b是什么单位| 看见蛇有什么预兆| 什么时候怀孕几率高| 多出汗有什么好处| 阿弥陀佛是什么意思| 梦见相亲是什么意思| 什么鱼吃鱼粪便| 什么时候量血压最准| 手麻脚麻是什么原因引起的| outlets是什么意思| 窦性心律室性早搏是什么意思| 飘了是什么意思| 有什么汤菜谱大全| 脂肪瘤是什么原因引起的| 梦见和尚是什么预兆| 什么血型招蚊子咬| 突然戒烟对身体有什么影响| 时辰宜忌是什么意思| 痔疮长什么样| 表现是什么意思| 吃什么会瘦| 43属什么| 什么3121919Z空间| 慕字五行属什么| 嘛是什么意思| 将军代表什么生肖| 什么是外心| suv是什么意思| 安宫丸什么时候吃效果是最佳的| sahara是什么牌子| 黑豚肉是什么肉| 小便有点黄是什么原因| 复刻版是什么意思| 肺部结节是什么原因引起的| 爱拍马屁的动物是什么生肖| 右手麻是什么原因| 生理期吃什么好| 黄帝姓什么| 养寇自重什么意思| 精子是什么颜色的| 头发痒是什么原因| 跳舞有什么好处| 经典是什么意思| 排卵期身体有什么症状表现吗| 脊椎炎有什么症状| 为什么会长肥胖纹| 偷什么不犯法| 介入手术是什么意思| 什么是佛跳墙| 没有鱼鳞的鱼是什么鱼| 荔枝不能与什么一起吃| 输卵管不通有什么症状| 韭菜炒什么好吃| 什么的大自然| 梦见下大雪是什么意思| 葡萄球菌感染是什么原因引起的| 牛奶什么时候喝好| 泉水什么| 塑料袋是什么材质| 感冒发烧吃什么饭菜好| 派石项链有什么功效| 老司机是什么意思| 肥肠烧什么配菜好吃| 脸麻是什么原因| 书卷气是什么意思| 孩子总爱哭是什么原因| 发什么什么大| 尿检阴性是什么意思| 乙肝有抗体是显示什么结果| 格列卫是什么药| 疯狂动物城树懒叫什么| 哺乳期不能吃什么| 人少了一魄什么反应| 绝育手术对女性有什么危害| 一个王一个月念什么| 丝瓜络是什么东西| 令坦是对方什么人的尊称| 喝茶叶茶有什么好处和坏处| 世界上最小的国家是什么| 腰麻是什么麻醉| 什么时间种白菜| 阴阳两虚吃什么中成药| 七月二十五是什么星座| 中暑了吃什么| 导弹是什么意思| 阑尾炎吃什么药最有效| 腰椎间盘突出挂什么科室| 居士什么意思| 风疹吃什么药好得快| 农历7月28日是什么星座| 久而久之下一句是什么| 编外人员是什么意思| 喜神是什么意思| 什么时候血压最高| 卡裆是什么意思啊| 白鸡蛋是什么鸡下的蛋| 火药是什么时候发明的| 1.29是什么星座| 裙带菜是什么菜| 发烧喝什么药| 长期耳鸣是什么原因| 4月6日是什么星座| 什么目寸光成语| 胸闷吃什么药| 烟雾病是什么原因引起的| 矢什么意思| 零八年属什么生肖| 做月子可以吃什么| 男人吃什么补肾壮阳效果最好| 胃窦在胃的什么位置| 势利是什么意思| 海鸥手表是什么档次| 胃不好吃什么| 扁桃体发炎是什么原因引起的| 新生儿前面头发稀少是什么原因| 黄芪不适合什么人吃| 办护照需要什么条件| 对什么都不感兴趣| 做手术后吃什么对伤口恢复快| 兔跟什么生肖配对最好| 口干舌燥口苦吃什么药| 米索前列醇片是什么药| 开普拉多的都是什么人| 三有动物是什么意思| 孕妇可以喝什么茶| 女生什么时候最容易怀孕| 苹果煮水喝有什么好处和坏处| 鼻头长痘痘什么原因| 中国国粹是什么| 丝瓜不能和什么一起吃| 7月6日是什么日子| 梦到明星是什么意思| 24k镀金是什么意思| 7月8号是什么星座的| it是什么行业| 心脏不舒服吃什么药最好| 下火喝什么茶| 得理不饶人什么意思| 什么样的笑脸| 新鲜的乌梅长什么样| poss是什么意思| 控制欲强的人最怕什么| 嗓子哑是什么原因引起的| 肮脏是什么意思| 什么是冤亲债主| 鬼压床是什么原因造成的| 甲亢病是什么原因引起的| 胃胀吃什么药效果最好| 津液不足吃什么中成药| 福州立冬吃什么| 输尿管不扩张什么意思| 早晨起来口苦什么原因| hpa是什么单位| 请丧假需要什么证明| 哼唧是什么意思| 有何指教是什么意思| 上皮细胞一个加号什么意思| 胆囊结石不能吃什么| 反乌托邦是什么意思| 才高八斗代表什么生肖| 圣诞节送孩子什么礼物好| 什么身是胆| 伤官是什么| 吃什么奶水多| 小拇指和无名指发麻是什么原因| 人得猫癣用什么药| 耳朵前面有痣代表什么| 宽粉是什么做的| 什么的石头| 怀孕周期是从什么时候开始算的| 木变石是什么| 百度

摇滚男神热力开嗓 郑钧“私奔”演唱会今日开票


Directory: ../../../ffmpeg/
File: src/libavformat/flacenc.c
Date: 2025-08-04 11:35:17
Exec Total Coverage
Lines: 163 211 77.3%
Functions: 11 11 100.0%
Branches: 76 130 58.5%

Line Branch Exec Source
1 /*
2 * raw FLAC muxer
3 * Copyright (c) 2006-2009 Justin Ruggles
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include "libavutil/avstring.h"
23 #include "libavutil/channel_layout.h"
24 #include "libavutil/opt.h"
25 #include "libavutil/pixdesc.h"
26 #include "libavcodec/flac.h"
27 #include "libavcodec/packet_internal.h"
28 #include "avformat.h"
29 #include "avio_internal.h"
30 #include "flacenc.h"
31 #include "id3v2.h"
32 #include "internal.h"
33 #include "mux.h"
34 #include "version.h"
35 #include "vorbiscomment.h"
36
37
38 typedef struct FlacMuxerContext {
39 const AVClass *class;
40 int write_header;
41
42 int audio_stream_idx;
43 int waiting_pics;
44 /* audio packets are queued here until we get all the attached pictures */
45 PacketList queue;
46
47 /* updated streaminfo sent by the encoder at the end */
48 uint8_t streaminfo[FLAC_STREAMINFO_SIZE];
49 int updated_streaminfo;
50
51 unsigned attached_types;
52 } FlacMuxerContext;
53
54 13 static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_bytes,
55 int last_block)
56 {
57
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 avio_w8(pb, last_block ? 0x81 : 0x01);
58 13 avio_wb24(pb, n_padding_bytes);
59 13 ffio_fill(pb, 0, n_padding_bytes);
60 13 return 0;
61 }
62
63 13 static int flac_write_block_comment(AVIOContext *pb, AVDictionary **m,
64 int last_block, int bitexact)
65 {
66
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 10 times.
13 const char *vendor = bitexact ? "ffmpeg" : LIBAVFORMAT_IDENT;
67 int64_t len;
68
69 13 ff_metadata_conv(m, ff_vorbiscomment_metadata_conv, NULL);
70
71 13 len = ff_vorbiscomment_length(*m, vendor, NULL, 0);
72
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (len >= ((1<<24) - 4))
73 return AVERROR(EINVAL);
74
75
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 avio_w8(pb, last_block ? 0x84 : 0x04);
76 13 avio_wb24(pb, len);
77 13 ff_vorbiscomment_write(pb, *m, vendor, NULL, 0);
78
79 13 return 0;
80 }
81
82 5 static int flac_write_picture(struct AVFormatContext *s, AVPacket *pkt)
83 {
84 5 FlacMuxerContext *c = s->priv_data;
85 5 AVIOContext *pb = s->pb;
86 const AVPixFmtDescriptor *pixdesc;
87 5 const CodecMime *mime = ff_id3v2_mime_tags;
88 AVDictionaryEntry *e;
89 5 const char *mimetype = NULL, *desc = "";
90 5 const AVStream *st = s->streams[pkt->stream_index];
91 5 int i, mimelen, desclen, type = 0, blocklen;
92
93
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!pkt->data)
94 return 0;
95
96
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 while (mime->id != AV_CODEC_ID_NONE) {
97
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 13 times.
18 if (mime->id == st->codecpar->codec_id) {
98 5 mimetype = mime->str;
99 5 break;
100 }
101 13 mime++;
102 }
103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!mimetype) {
104 av_log(s, AV_LOG_ERROR, "No mimetype is known for stream %d, cannot "
105 "write an attached picture.\n", st->index);
106 return AVERROR(EINVAL);
107 }
108 5 mimelen = strlen(mimetype);
109
110 /* get the picture type */
111 5 e = av_dict_get(st->metadata, "comment", NULL, 0);
112
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
75 for (i = 0; e && i < FF_ARRAY_ELEMS(ff_id3v2_picture_types); i++) {
113
2/2
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 70 times.
75 if (!av_strcasecmp(e->value, ff_id3v2_picture_types[i])) {
114 5 type = i;
115 5 break;
116 }
117 }
118
119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if ((c->attached_types & (1 << type)) & 0x6) {
120 av_log(s, AV_LOG_ERROR, "Duplicate attachment for type '%s'\n", ff_id3v2_picture_types[type]);
121 return AVERROR(EINVAL);
122 }
123
124
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (type == 1 && (st->codecpar->codec_id != AV_CODEC_ID_PNG ||
125 st->codecpar->width != 32 ||
126 st->codecpar->height != 32)) {
127 av_log(s, AV_LOG_ERROR, "File icon attachment must be a 32x32 PNG");
128 return AVERROR(EINVAL);
129 }
130
131 5 c->attached_types |= (1 << type);
132
133 /* get the description */
134
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 if ((e = av_dict_get(st->metadata, "title", NULL, 0)))
135 5 desc = e->value;
136 5 desclen = strlen(desc);
137
138 5 blocklen = 4 + 4 + mimelen + 4 + desclen + 4 + 4 + 4 + 4 + 4 + pkt->size;
139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (blocklen >= 1<<24) {
140 av_log(s, AV_LOG_ERROR, "Picture block too big %d >= %d\n", blocklen, 1<<24);
141 return AVERROR(EINVAL);
142 }
143
144 5 avio_w8(pb, 0x06);
145 5 avio_wb24(pb, blocklen);
146
147 5 avio_wb32(pb, type);
148
149 5 avio_wb32(pb, mimelen);
150 5 avio_write(pb, mimetype, mimelen);
151
152 5 avio_wb32(pb, desclen);
153 5 avio_write(pb, desc, desclen);
154
155 5 avio_wb32(pb, st->codecpar->width);
156 5 avio_wb32(pb, st->codecpar->height);
157
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 if ((pixdesc = av_pix_fmt_desc_get(st->codecpar->format)))
158 5 avio_wb32(pb, av_get_bits_per_pixel(pixdesc));
159 else
160 avio_wb32(pb, 0);
161 5 avio_wb32(pb, 0);
162
163 5 avio_wb32(pb, pkt->size);
164 5 avio_write(pb, pkt->data, pkt->size);
165 5 return 0;
166 }
167
168 13 static int flac_finish_header(struct AVFormatContext *s)
169 {
170 13 int i, ret, padding = s->metadata_header_padding;
171
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (padding < 0)
172 13 padding = 8192;
173 /* The FLAC specification states that 24 bits are used to represent the
174 * size of a metadata block so we must clip this value to 2^24-1. */
175 13 padding = av_clip_uintp2(padding, 24);
176
177
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 13 times.
31 for (i = 0; i < s->nb_streams; i++) {
178 18 AVStream *st = s->streams[i];
179 18 AVPacket *pkt = st->priv_data;
180
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5 times.
18 if (!pkt)
181 13 continue;
182 5 ret = flac_write_picture(s, pkt);
183 5 av_packet_unref(pkt);
184
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if (ret < 0 && (s->error_recognition & AV_EF_EXPLODE))
185 return ret;
186 }
187
188 13 ret = flac_write_block_comment(s->pb, &s->metadata, !padding,
189 13 s->flags & AVFMT_FLAG_BITEXACT);
190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (ret)
191 return ret;
192
193 /* The command line flac encoder defaults to placing a seekpoint
194 * every 10s. So one might add padding to allow that later
195 * but there seems to be no simple way to get the duration here.
196 * So just add the amount requested by the user. */
197
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (padding)
198 13 flac_write_block_padding(s->pb, padding, 1);
199
200 13 return 0;
201 }
202
203 13 static int flac_init(struct AVFormatContext *s)
204 {
205 AVCodecParameters *par;
206 13 FlacMuxerContext *c = s->priv_data;
207 int i;
208
209 13 c->audio_stream_idx = -1;
210
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 13 times.
31 for (i = 0; i < s->nb_streams; i++) {
211 18 AVStream *st = s->streams[i];
212
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 5 times.
18 if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
213
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (c->audio_stream_idx >= 0 || st->codecpar->codec_id != AV_CODEC_ID_FLAC) {
214 av_log(s, AV_LOG_ERROR, "Invalid audio stream. Exactly one FLAC "
215 "audio stream is required.\n");
216 return AVERROR(EINVAL);
217 }
218 13 par = s->streams[i]->codecpar;
219 13 c->audio_stream_idx = i;
220
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC)) {
222 av_log(s, AV_LOG_WARNING, "Video stream #%d is not an attached picture. Ignoring\n", i);
223 continue;
224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 } else if (st->codecpar->codec_id == AV_CODEC_ID_GIF) {
225 av_log(s, AV_LOG_ERROR, "GIF image support is not implemented.\n");
226 return AVERROR_PATCHWELCOME;
227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 } else if (!c->write_header) {
228 av_log(s, AV_LOG_ERROR, "Can't write attached pictures without a header.\n");
229 return AVERROR(EINVAL);
230 }
231 5 c->waiting_pics++;
232 } else {
233 av_log(s, AV_LOG_ERROR, "Only audio streams and pictures are allowed in FLAC.\n");
234 return AVERROR(EINVAL);
235 }
236 }
237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (c->audio_stream_idx < 0) {
238 av_log(s, AV_LOG_ERROR, "No audio stream present.\n");
239 return AVERROR(EINVAL);
240 }
241
242 /* add the channel layout tag */
243
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE &&
244
3/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12 times.
26 !(par->ch_layout.u.mask & ~0x3ffffULL) &&
245 13 !ff_flac_is_native_layout(par->ch_layout.u.mask)) {
246 1 AVDictionaryEntry *chmask = av_dict_get(s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK",
247 NULL, 0);
248
249
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (chmask) {
250 av_log(s, AV_LOG_WARNING, "A WAVEFORMATEXTENSIBLE_CHANNEL_MASK is "
251 "already present, this muxer will not overwrite it.\n");
252 } else {
253 uint8_t buf[32];
254 1 snprintf(buf, sizeof(buf), "0x%"PRIx64, par->ch_layout.u.mask);
255 1 av_dict_set(&s->metadata, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
256 }
257 }
258
259 13 return 0;
260 }
261
262 13 static int flac_write_header(struct AVFormatContext *s)
263 {
264 13 FlacMuxerContext *c = s->priv_data;
265 13 AVCodecParameters *par = s->streams[c->audio_stream_idx]->codecpar;
266 int ret;
267
268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (!c->write_header)
269 return 0;
270
271 13 ret = ff_flac_write_header(s->pb, par->extradata,
272 par->extradata_size, 0);
273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (ret < 0)
274 return ret;
275
276
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 times.
13 if (!c->waiting_pics)
277 12 ret = flac_finish_header(s);
278
279 13 return ret;
280 }
281
282 1263 static int flac_write_audio_packet(struct AVFormatContext *s, AVPacket *pkt)
283 {
284 1263 FlacMuxerContext *c = s->priv_data;
285 uint8_t *streaminfo;
286 size_t streaminfo_size;
287
288 /* check for updated streaminfo */
289 1263 streaminfo = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
290 &streaminfo_size);
291
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1250 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
1263 if (streaminfo && streaminfo_size == FLAC_STREAMINFO_SIZE) {
292 13 memcpy(c->streaminfo, streaminfo, FLAC_STREAMINFO_SIZE);
293 13 c->updated_streaminfo = 1;
294 }
295
296
2/2
✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 13 times.
1263 if (pkt->size)
297 1250 avio_write(s->pb, pkt->data, pkt->size);
298 1263 return 0;
299 }
300
301 1 static int flac_queue_flush(AVFormatContext *s)
302 {
303 1 FlacMuxerContext *c = s->priv_data;
304 1 AVPacket *const pkt = ffformatcontext(s)->pkt;
305 1 int ret, write = 1;
306
307 1 ret = flac_finish_header(s);
308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret < 0)
309 write = 0;
310
311
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 while (c->queue.head) {
312 1 avpriv_packet_list_get(&c->queue, pkt);
313
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
1 if (write && (ret = flac_write_audio_packet(s, pkt)) < 0)
314 write = 0;
315 1 av_packet_unref(pkt);
316 }
317 1 return ret;
318 }
319
320 13 static int flac_write_trailer(struct AVFormatContext *s)
321 {
322 13 AVIOContext *pb = s->pb;
323 int64_t file_size;
324 13 FlacMuxerContext *c = s->priv_data;
325
326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (c->waiting_pics) {
327 av_log(s, AV_LOG_WARNING, "No packets were sent for some of the "
328 "attached pictures.\n");
329 flac_queue_flush(s);
330 }
331
332
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (!c->write_header || !c->updated_streaminfo)
333 return 0;
334
335
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
336 /* rewrite the STREAMINFO header block data */
337 13 file_size = avio_tell(pb);
338 13 avio_seek(pb, 8, SEEK_SET);
339 13 avio_write(pb, c->streaminfo, FLAC_STREAMINFO_SIZE);
340 13 avio_seek(pb, file_size, SEEK_SET);
341 } else {
342 av_log(s, AV_LOG_WARNING, "unable to rewrite FLAC header.\n");
343 }
344
345 13 return 0;
346 }
347
348 13 static void flac_deinit(struct AVFormatContext *s)
349 {
350 13 FlacMuxerContext *c = s->priv_data;
351
352 13 avpriv_packet_list_free(&c->queue);
353
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 13 times.
31 for (unsigned i = 0; i < s->nb_streams; i++)
354 18 av_packet_free((AVPacket **)&s->streams[i]->priv_data);
355 13 }
356
357 1268 static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
358 {
359 1268 FlacMuxerContext *c = s->priv_data;
360 int ret;
361
362
2/2
✓ Branch 0 taken 1263 times.
✓ Branch 1 taken 5 times.
1268 if (pkt->stream_index == c->audio_stream_idx) {
363
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1262 times.
1263 if (c->waiting_pics) {
364 /* buffer audio packets until we get all the pictures */
365 1 ret = avpriv_packet_list_put(&c->queue, pkt, NULL, 0);
366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret < 0) {
367 av_log(s, AV_LOG_ERROR, "Out of memory in packet queue; skipping attached pictures\n");
368 c->waiting_pics = 0;
369 ret = flac_queue_flush(s);
370 if (ret < 0)
371 return ret;
372 return flac_write_audio_packet(s, pkt);
373 }
374 } else
375 1262 return flac_write_audio_packet(s, pkt);
376 } else {
377 5 AVStream *st = s->streams[pkt->stream_index];
378
379
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if (!c->waiting_pics ||
380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 !(st->disposition & AV_DISPOSITION_ATTACHED_PIC))
381 return 0;
382
383 /* warn only once for each stream */
384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (st->nb_frames == 1) {
385 av_log(s, AV_LOG_WARNING, "Got more than one picture in stream %d,"
386 " ignoring.\n", pkt->stream_index);
387 }
388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (st->nb_frames >= 1)
389 return 0;
390
391 5 st->priv_data = av_packet_clone(pkt);
392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (!st->priv_data)
393 av_log(s, AV_LOG_ERROR, "Out of memory queueing an attached picture; skipping\n");
394 5 c->waiting_pics--;
395
396 /* flush the buffered audio packets */
397
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
6 if (!c->waiting_pics &&
398 1 (ret = flac_queue_flush(s)) < 0)
399 return ret;
400 }
401
402 6 return 0;
403 }
404
405 static const AVOption flacenc_options[] = {
406 { "write_header", "Write the file header", offsetof(FlacMuxerContext, write_header), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
407 { NULL },
408 };
409
410 static const AVClass flac_muxer_class = {
411 .class_name = "flac muxer",
412 .item_name = av_default_item_name,
413 .option = flacenc_options,
414 .version = LIBAVUTIL_VERSION_INT,
415 };
416
417 const FFOutputFormat ff_flac_muxer = {
418 .p.name = "flac",
419 .p.long_name = NULL_IF_CONFIG_SMALL("raw FLAC"),
420 .priv_data_size = sizeof(FlacMuxerContext),
421 .p.mime_type = "audio/x-flac",
422 .p.extensions = "flac",
423 .p.audio_codec = AV_CODEC_ID_FLAC,
424 .p.video_codec = AV_CODEC_ID_PNG,
425 .init = flac_init,
426 .write_header = flac_write_header,
427 .write_packet = flac_write_packet,
428 .write_trailer = flac_write_trailer,
429 .deinit = flac_deinit,
430 .p.flags = AVFMT_NOTIMESTAMPS,
431 .p.priv_class = &flac_muxer_class,
432 };
433

上市公司什么意思 囊肿里面是什么东西 什么是可转债 上颚痒是什么原因 吃什么提高免疫力和增强体质
鼻炎是什么引起的 莞字五行属什么 牙齿出血是什么原因 斜视是什么原因导致的 acei是什么意思
面包糠是什么做的 angelababy英文什么意思 憩室是什么意思 省政府秘书长什么级别 什么的贾宝玉
贺涵为什么会爱上罗子君 朱代表什么生肖 私处长痘痘是什么原因 做脑ct挂什么科 王字旁一个玉读什么
水落石出开过什么生肖qingzhougame.com 连铁是什么器官hcv9jop5ns9r.cn 什么的杨桃shenchushe.com 八哥是什么鸟hcv9jop0ns8r.cn 左心室强光点是什么意思hcv8jop3ns9r.cn
薄荷脑是什么东西hebeidezhi.com 重组人干扰素a2b主要是治疗什么病hcv9jop0ns3r.cn 动物的脖子有什么作用hcv7jop7ns4r.cn 胎停会有什么症状inbungee.com 江米是什么米hcv8jop2ns4r.cn
媛交是什么意思gangsutong.com 钙片什么时候吃hcv8jop7ns7r.cn 黄芪的功效与作用是什么hcv9jop1ns1r.cn 上天眷顾是什么意思liaochangning.com 梦里见血代表什么预兆jasonfriends.com
盆腔肿物是什么意思hcv9jop1ns1r.cn 产生幻觉是什么原因hcv8jop6ns0r.cn 1963年发生了什么hcv8jop3ns9r.cn 炼奶是什么hcv8jop1ns1r.cn betty是什么意思hcv9jop1ns3r.cn
百度