|
|
|
@ -53,38 +53,38 @@ typedef struct FifoContext { |
|
|
|
|
|
|
|
|
|
static av_cold int init(AVFilterContext *ctx) |
|
|
|
|
{ |
|
|
|
|
FifoContext *fifo = ctx->priv; |
|
|
|
|
fifo->last = &fifo->root; |
|
|
|
|
FifoContext *s = ctx->priv; |
|
|
|
|
s->last = &s->root; |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static av_cold void uninit(AVFilterContext *ctx) |
|
|
|
|
{ |
|
|
|
|
FifoContext *fifo = ctx->priv; |
|
|
|
|
FifoContext *s = ctx->priv; |
|
|
|
|
Buf *buf, *tmp; |
|
|
|
|
|
|
|
|
|
for (buf = fifo->root.next; buf; buf = tmp) { |
|
|
|
|
for (buf = s->root.next; buf; buf = tmp) { |
|
|
|
|
tmp = buf->next; |
|
|
|
|
av_frame_free(&buf->frame); |
|
|
|
|
av_free(buf); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
av_frame_free(&fifo->out); |
|
|
|
|
av_frame_free(&s->out); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int add_to_queue(AVFilterLink *inlink, AVFrame *frame) |
|
|
|
|
{ |
|
|
|
|
FifoContext *fifo = inlink->dst->priv; |
|
|
|
|
FifoContext *s = inlink->dst->priv; |
|
|
|
|
|
|
|
|
|
fifo->last->next = av_mallocz(sizeof(Buf)); |
|
|
|
|
if (!fifo->last->next) { |
|
|
|
|
s->last->next = av_mallocz(sizeof(Buf)); |
|
|
|
|
if (!s->last->next) { |
|
|
|
|
av_frame_free(&frame); |
|
|
|
|
return AVERROR(ENOMEM); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fifo->last = fifo->last->next; |
|
|
|
|
fifo->last->frame = frame; |
|
|
|
|
s->last = s->last->next; |
|
|
|
|
s->last->frame = frame; |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
@ -229,24 +229,24 @@ static int return_audio_frame(AVFilterContext *ctx) |
|
|
|
|
|
|
|
|
|
static int request_frame(AVFilterLink *outlink) |
|
|
|
|
{ |
|
|
|
|
FifoContext *fifo = outlink->src->priv; |
|
|
|
|
FifoContext *s = outlink->src->priv; |
|
|
|
|
int ret = 0; |
|
|
|
|
|
|
|
|
|
if (!fifo->root.next) { |
|
|
|
|
if (!s->root.next) { |
|
|
|
|
if ((ret = ff_request_frame(outlink->src->inputs[0])) < 0) { |
|
|
|
|
if (ret == AVERROR_EOF && outlink->request_samples) |
|
|
|
|
return return_audio_frame(outlink->src); |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
if (!fifo->root.next) |
|
|
|
|
if (!s->root.next) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (outlink->request_samples) { |
|
|
|
|
return return_audio_frame(outlink->src); |
|
|
|
|
} else { |
|
|
|
|
ret = ff_filter_frame(outlink, fifo->root.next->frame); |
|
|
|
|
queue_pop(fifo); |
|
|
|
|
ret = ff_filter_frame(outlink, s->root.next->frame); |
|
|
|
|
queue_pop(s); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ret; |
|
|
|
|