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

Function ff_encode_encode_cb

libavcodec/encode.c:232–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232int ff_encode_encode_cb(AVCodecContext *avctx, AVPacket *avpkt,
233 AVFrame *frame, int *got_packet)
234{
235 const FFCodec *const codec = ffcodec(avctx->codec);
236 int ret;
237
238 ret = codec->cb.encode(avctx, avpkt, frame, got_packet);
239 ff_assert1_fpu();
240 av_assert0(ret <= 0);
241
242 if (!ret && *got_packet) {
243 if (avpkt->data) {
244 ret = encode_make_refcounted(avctx, avpkt);
245 if (ret < 0)
246 goto unref;
247 // Date returned by encoders must always be ref-counted
248 av_assert0(avpkt->buf);
249 }
250
251 // set the timestamps for the simple no-delay case
252 // encoders with delay have to set the timestamps themselves
253 if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) ||
254 (frame && (codec->caps_internal & FF_CODEC_CAP_EOF_FLUSH))) {
255 if (avpkt->pts == AV_NOPTS_VALUE)
256 avpkt->pts = frame->pts;
257
258 if (!avpkt->duration) {
259 if (frame->duration)
260 avpkt->duration = frame->duration;
261 else if (avctx->codec->type == AVMEDIA_TYPE_AUDIO) {
262 avpkt->duration = ff_samples_to_time_base(avctx,
263 frame->nb_samples);
264 }
265 }
266
267 ret = ff_encode_reordered_opaque(avctx, avpkt, frame);
268 if (ret < 0)
269 goto unref;
270 }
271
272 // dts equals pts unless there is reordering
273 // there can be no reordering if there is no encoder delay
274 if (!(avctx->codec_descriptor->props & AV_CODEC_PROP_REORDER) ||
275 !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) ||
276 (codec->caps_internal & FF_CODEC_CAP_EOF_FLUSH))
277 avpkt->dts = avpkt->pts;
278 } else {
279unref:
280 av_packet_unref(avpkt);
281 }
282
283 if (frame)
284 av_frame_unref(frame);
285
286 return ret;
287}
288
289static int encode_simple_internal(AVCodecContext *avctx, AVPacket *avpkt)

Callers 2

encode_simple_internalFunction · 0.85
workerFunction · 0.85

Calls 6

ffcodecFunction · 0.85
encode_make_refcountedFunction · 0.85
ff_samples_to_time_baseFunction · 0.85
av_packet_unrefFunction · 0.85
av_frame_unrefFunction · 0.85

Tested by

no test coverage detected