Skip to content

Commit

Permalink
Call avfilter_graph_request_oldest after sending a frame to a filter
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanreg committed Apr 7, 2024
1 parent b00402d commit be23815
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cyanrip_encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ int cyanrip_create_dec_ctx(cyanrip_ctx *ctx, cyanrip_dec_ctx **s,
if ((ctx->settings.decode_hdcd) ||
(ctx->settings.deemphasis && t->preemphasis) ||
(ctx->settings.force_deemphasis)) {

ret = init_filtering(ctx, &dec_ctx->filt,
ctx->settings.decode_hdcd,
(ctx->settings.deemphasis && t->preemphasis) || ctx->settings.force_deemphasis,
Expand Down Expand Up @@ -491,6 +492,7 @@ static int filter_frame(cyanrip_ctx *ctx, cyanrip_enc_ctx **enc_ctx,
if (!dec_ctx->filt.buffersrc_ctx)
return push_frame_to_encs(ctx, enc_ctx, num_enc, frame);


ret = av_buffersrc_add_frame_flags(dec_ctx->filt.buffersrc_ctx, frame,
AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT |
AV_BUFFERSRC_FLAG_KEEP_REF);
Expand All @@ -499,6 +501,14 @@ static int filter_frame(cyanrip_ctx *ctx, cyanrip_enc_ctx **enc_ctx,
goto fail;
}

ret = avfilter_graph_request_oldest(dec_ctx->filt.graph);
if (ret == AVERROR_EOF) {
return push_frame_to_encs(ctx, enc_ctx, num_enc, NULL);
} else if (ret < 0) {
cyanrip_log(ctx, 0, "Error filtering frame: %s!\n", av_err2str(ret));
goto fail;
}

while (1) {
dec_frame = av_frame_alloc();
if (!dec_frame) {
Expand Down

0 comments on commit be23815

Please sign in to comment.