Commit 511b83cc authored by Stefan Westerfeld's avatar Stefan Westerfeld

avfilter/asubprocess: keep track of sp_can_read (performance)

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent a57b69b2
......@@ -42,6 +42,7 @@ typedef struct SP
SPB *unused_buffers;
int pid;
size_t input_count;
size_t can_read;
bool done;
} SP;
......@@ -209,17 +210,15 @@ sp_new(AVFilterContext *ctx)
static size_t
sp_can_read(SP *sp)
{
int can_read = 0;
for (SPB *spb = sp->out_buffers; spb; spb = spb->next)
can_read += spb->count - spb->offset;
return can_read;
return sp->can_read;
}
static void
sp_read(SP *sp, char *buffer, int count)
sp_read(SP *sp, char *buffer, size_t count)
{
SPB *spb = sp->out_buffers;
av_assert0(count <= sp->can_read); // caller should check this before calling sp_read
sp->can_read -= count;
while (spb) {
int n = FFMIN(spb->count - spb->offset, count);
......@@ -389,6 +388,7 @@ sp_write(AVFilterContext *ctx, char *buffer, int count)
if (rc > 0) {
last->count += rc;
sp->input_count += rc;
sp->can_read += rc;
ret = update_state(ctx);
if (ret != 0)
return ret;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment