[transcode] Don't push NULL frames to filtergraph when flushing, can lead to segfault

This commit is contained in:
ejurgensen 2015-10-25 19:59:06 +01:00
parent ac3d47430c
commit 7894a4d85f

View File

@ -373,12 +373,15 @@ filter_encode_write_frame(struct encode_ctx *ctx, AVFrame *frame, unsigned int s
int ret; int ret;
// Push the decoded frame into the filtergraph // Push the decoded frame into the filtergraph
if (frame)
{
ret = av_buffersrc_add_frame_flags(ctx->filter_ctx[stream_index].buffersrc_ctx, frame, 0); ret = av_buffersrc_add_frame_flags(ctx->filter_ctx[stream_index].buffersrc_ctx, frame, 0);
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_XCODE, "Error while feeding the filtergraph\n"); DPRINTF(E_LOG, L_XCODE, "Error while feeding the filtergraph\n");
return -1; return -1;
} }
}
// Pull filtered frames from the filtergraph // Pull filtered frames from the filtergraph
while (1) while (1)
@ -424,12 +427,15 @@ filter_encode_write_frame(struct encode_ctx *ctx, AVFrame *frame, unsigned int s
enc_ctx = ctx->ofmt_ctx->streams[stream_index]->codec; enc_ctx = ctx->ofmt_ctx->streams[stream_index]->codec;
// Push the decoded frame into the filtergraph // Push the decoded frame into the filtergraph
if (frame)
{
ret = av_buffersrc_write_frame(ctx->filter_ctx[stream_index].buffersrc_ctx, frame); ret = av_buffersrc_write_frame(ctx->filter_ctx[stream_index].buffersrc_ctx, frame);
if (ret < 0) if (ret < 0)
{ {
DPRINTF(E_LOG, L_XCODE, "Error while feeding the filtergraph\n"); DPRINTF(E_LOG, L_XCODE, "Error while feeding the filtergraph\n");
return -1; return -1;
} }
}
// Pull filtered frames from the filtergraph // Pull filtered frames from the filtergraph
while (1) while (1)