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