MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / write_stream_codec_info

Function write_stream_codec_info

libavformat/wtvenc.c:260–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260static int write_stream_codec_info(AVFormatContext *s, AVStream *st)
261{
262 const ff_asf_guid *g, *media_type, *format_type;
263 const AVCodecTag *tags;
264 AVIOContext *pb = s->pb;
265 int64_t hdr_pos_start;
266 int hdr_size = 0;
267
268 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
269 g = ff_get_codec_guid(st->codecpar->codec_id, ff_video_guids);
270 media_type = &ff_mediatype_video;
271 format_type = st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO ? &ff_format_mpeg2_video : &ff_format_videoinfo2;
272 tags = ff_codec_bmp_tags;
273 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
274 g = ff_get_codec_guid(st->codecpar->codec_id, ff_codec_wav_guids);
275 media_type = &ff_mediatype_audio;
276 format_type = &ff_format_waveformatex;
277 tags = ff_codec_wav_tags;
278 } else {
279 av_log(s, AV_LOG_ERROR, "unknown codec_type (0x%x)\n", st->codecpar->codec_type);
280 return -1;
281 }
282
283 ff_put_guid(pb, media_type); // mediatype
284 ff_put_guid(pb, &ff_mediasubtype_cpfilters_processed); // subtype
285 write_pad(pb, 12);
286 ff_put_guid(pb,&ff_format_cpfilters_processed); // format type
287 avio_wl32(pb, 0); // size
288
289 hdr_pos_start = avio_tell(pb);
290 if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
291 put_videoinfoheader2(pb, st);
292 } else {
293 if (ff_put_wav_header(s, pb, st->codecpar, 0) < 0)
294 format_type = &ff_format_none;
295 }
296 hdr_size = avio_tell(pb) - hdr_pos_start;
297
298 // seek back write hdr_size
299 avio_seek(pb, -(hdr_size + 4), SEEK_CUR);
300 avio_wl32(pb, hdr_size + 32);
301 avio_seek(pb, hdr_size, SEEK_CUR);
302 if (g) {
303 ff_put_guid(pb, g); // actual_subtype
304 } else {
305 int tag = ff_codec_get_tag(tags, st->codecpar->codec_id);
306 if (!tag) {
307 av_log(s, AV_LOG_ERROR, "unsupported codec_id (0x%x)\n", st->codecpar->codec_id);
308 return -1;
309 }
310 avio_wl32(pb, tag);
311 avio_write(pb, (const uint8_t[]){FF_MEDIASUBTYPE_BASE_GUID}, 12);
312 }
313 ff_put_guid(pb, format_type); // actual_formattype
314
315 return 0;
316}
317

Callers 2

write_stream_codecFunction · 0.85
write_stream_dataFunction · 0.85

Calls 10

ff_get_codec_guidFunction · 0.85
av_logFunction · 0.85
ff_put_guidFunction · 0.85
avio_wl32Function · 0.85
avio_tellFunction · 0.85
put_videoinfoheader2Function · 0.85
ff_put_wav_headerFunction · 0.85
avio_seekFunction · 0.85
ff_codec_get_tagFunction · 0.85
avio_writeFunction · 0.85

Tested by

no test coverage detected