Skip to content

Commit be23815

Browse files
committed
Call avfilter_graph_request_oldest after sending a frame to a filter
1 parent b00402d commit be23815

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/cyanrip_encode.c

+10
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ int cyanrip_create_dec_ctx(cyanrip_ctx *ctx, cyanrip_dec_ctx **s,
422422
if ((ctx->settings.decode_hdcd) ||
423423
(ctx->settings.deemphasis && t->preemphasis) ||
424424
(ctx->settings.force_deemphasis)) {
425+
425426
ret = init_filtering(ctx, &dec_ctx->filt,
426427
ctx->settings.decode_hdcd,
427428
(ctx->settings.deemphasis && t->preemphasis) || ctx->settings.force_deemphasis,
@@ -491,6 +492,7 @@ static int filter_frame(cyanrip_ctx *ctx, cyanrip_enc_ctx **enc_ctx,
491492
if (!dec_ctx->filt.buffersrc_ctx)
492493
return push_frame_to_encs(ctx, enc_ctx, num_enc, frame);
493494

495+
494496
ret = av_buffersrc_add_frame_flags(dec_ctx->filt.buffersrc_ctx, frame,
495497
AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT |
496498
AV_BUFFERSRC_FLAG_KEEP_REF);
@@ -499,6 +501,14 @@ static int filter_frame(cyanrip_ctx *ctx, cyanrip_enc_ctx **enc_ctx,
499501
goto fail;
500502
}
501503

504+
ret = avfilter_graph_request_oldest(dec_ctx->filt.graph);
505+
if (ret == AVERROR_EOF) {
506+
return push_frame_to_encs(ctx, enc_ctx, num_enc, NULL);
507+
} else if (ret < 0) {
508+
cyanrip_log(ctx, 0, "Error filtering frame: %s!\n", av_err2str(ret));
509+
goto fail;
510+
}
511+
502512
while (1) {
503513
dec_frame = av_frame_alloc();
504514
if (!dec_frame) {

0 commit comments

Comments
 (0)