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

Function av_write_frame

libavformat/mux.c:1176–1221  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1174}
1175
1176int av_write_frame(AVFormatContext *s, AVPacket *in)
1177{
1178 FFFormatContext *const si = ffformatcontext(s);
1179 AVPacket *pkt = si->parse_pkt;
1180 int ret;
1181
1182 if (!in) {
1183 if (ffofmt(s->oformat)->flags_internal & FF_OFMT_FLAG_ALLOW_FLUSH) {
1184 ret = ffofmt(s->oformat)->write_packet(s, NULL);
1185 flush_if_needed(s);
1186 if (ret >= 0 && s->pb && s->pb->error < 0)
1187 ret = s->pb->error;
1188 return ret;
1189 }
1190 return 1;
1191 }
1192
1193 if (in->flags & AV_PKT_FLAG_UNCODED_FRAME) {
1194 pkt = in;
1195 } else {
1196 /* We don't own in, so we have to make sure not to modify it.
1197 * (ff_write_chained() relies on this fact.)
1198 * The following avoids copying in's data unnecessarily.
1199 * Copying side data is unavoidable as a bitstream filter
1200 * may change it, e.g. free it on errors. */
1201 pkt->data = in->data;
1202 pkt->size = in->size;
1203 ret = av_packet_copy_props(pkt, in);
1204 if (ret < 0)
1205 return ret;
1206 if (in->buf) {
1207 pkt->buf = av_buffer_ref(in->buf);
1208 if (!pkt->buf) {
1209 ret = AVERROR(ENOMEM);
1210 goto fail;
1211 }
1212 }
1213 }
1214
1215 ret = write_packets_common(s, pkt, 0/*non-interleaved*/);
1216
1217fail:
1218 // Uncoded frames using the noninterleaved codepath are also freed here
1219 av_packet_unref(pkt);
1220 return ret;
1221}
1222
1223int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
1224{

Callers 15

flush_dynbufFunction · 0.85
hls_write_packetFunction · 0.85
hls_write_trailerFunction · 0.85
chunk_endFunction · 0.85
webm_chunk_write_packetFunction · 0.85
segment_endFunction · 0.85
seg_write_headerFunction · 0.85
ff_write_chainedFunction · 0.85
fifo_thread_flush_outputFunction · 0.85
fifo_thread_write_packetFunction · 0.85

Calls 6

ffofmtFunction · 0.85
flush_if_neededFunction · 0.85
av_packet_copy_propsFunction · 0.85
av_buffer_refFunction · 0.85
write_packets_commonFunction · 0.85
av_packet_unrefFunction · 0.85

Tested by 6

fifo_basic_testFunction · 0.68
fifo_overflow_drop_testFunction · 0.68
mux_framesFunction · 0.68
mux_id3Function · 0.68
signal_init_tsFunction · 0.68
mainFunction · 0.68