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

Function write_packet

libavformat/wtvenc.c:461–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

459}
460
461static int write_packet(AVFormatContext *s, AVPacket *pkt)
462{
463 AVIOContext *pb = s->pb;
464 WtvContext *wctx = s->priv_data;
465 AVStream *st = s->streams[pkt->stream_index];
466
467 if (st->codecpar->codec_id == AV_CODEC_ID_MJPEG && !wctx->thumbnail.size) {
468 av_packet_ref(&wctx->thumbnail, pkt);
469 return 0;
470 } else if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
471 int ret = ff_check_h264_startcode(s, st, pkt);
472 if (ret < 0)
473 return ret;
474 }
475
476 /* emit sync chunk and 'timeline.table.0.entries.Event' record every 50 frames */
477 if (wctx->serial - (wctx->nb_sp_pairs ? wctx->sp_pairs[wctx->nb_sp_pairs - 1].serial : 0) >= 50)
478 write_sync(s);
479
480 /* emit 'table.0.entries.time' record every 500ms */
481 if (pkt->pts != AV_NOPTS_VALUE && pkt->pts - (wctx->nb_st_pairs ? wctx->st_pairs[wctx->nb_st_pairs - 1].value : 0) >= 5000000)
482 add_serial_pair(&wctx->st_pairs, &wctx->nb_st_pairs, wctx->serial, pkt->pts);
483
484 if (pkt->pts != AV_NOPTS_VALUE && pkt->pts > wctx->last_pts) {
485 wctx->last_pts = pkt->pts;
486 wctx->last_serial = wctx->serial;
487 }
488
489 // write timestamp chunk
490 write_timestamp(s, pkt);
491
492 write_chunk_header(s, &ff_data_guid, pkt->size, INDEX_BASE + pkt->stream_index);
493 avio_write(pb, pkt->data, pkt->size);
494 write_pad(pb, WTV_PAD8(pkt->size) - pkt->size);
495
496 wctx->serial++;
497 return 0;
498}
499
500static int write_table0_header_events(AVIOContext *pb)
501{

Callers

nothing calls this directly

Calls 7

av_packet_refFunction · 0.85
ff_check_h264_startcodeFunction · 0.85
write_syncFunction · 0.85
add_serial_pairFunction · 0.85
write_timestampFunction · 0.85
avio_writeFunction · 0.85
write_chunk_headerFunction · 0.70

Tested by

no test coverage detected