Commit 4f3c079f authored by Stefan Westerfeld's avatar Stefan Westerfeld

avfilter/asubprocess: coding style changes

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 4874e76c
......@@ -108,9 +108,8 @@ 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;
}
......@@ -143,7 +142,7 @@ sp_write (SP *sp, char *buffer, int count)
int offset = 0;
if (count == 0 && sp->input_pipe >= 0) // eof
{
close (sp->input_pipe);
close(sp->input_pipe);
sp->input_pipe = -1;
}
if (count && sp->done)
......@@ -157,7 +156,7 @@ sp_write (SP *sp, char *buffer, int count)
poll (fds, 2, -1);
if (fds[0].revents & (POLLOUT | POLLHUP))
{
int rc = write (sp->input_pipe, &buffer[offset], count);
int rc = write(sp->input_pipe, &buffer[offset], count);
if (rc > 0)
{
offset += rc;
......@@ -167,7 +166,7 @@ sp_write (SP *sp, char *buffer, int count)
if (fds[1].revents & (POLLIN | POLLHUP))
{
SPB *spb = spb_new();
int rc = read (sp->output_pipe, spb->data, sizeof (spb->data));
int rc = read(sp->output_pipe, spb->data, sizeof (spb->data));
if (rc > 0)
{
spb->count = rc;
......@@ -184,8 +183,8 @@ sp_write (SP *sp, char *buffer, int count)
else if (rc == 0)
{
int status;
waitpid (sp->pid, &status, 0);
printf ("wstatus=%d\n", WEXITSTATUS (status));
waitpid(sp->pid, &status, 0);
printf("wstatus=%d\n", WEXITSTATUS (status));
sp->done = true;
if (count)
return AVERROR_EXTERNAL;
......@@ -265,7 +264,7 @@ static av_cold void uninit(AVFilterContext *ctx)
#define NB_BUFFER_SAMPLES 4096
static int write_wav_header (ASubProcessContext *s, int nb_channels, int sample_rate)
static int write_wav_header(ASubProcessContext *s, int nb_channels, int sample_rate)
{
int bit_depth = s->in_bit_depth;
AVIOContext *wav_header = NULL;
......@@ -279,20 +278,20 @@ static int write_wav_header (ASubProcessContext *s, int nb_channels, int sample_
ffio_wfourcc(wav_header, "WAVE");
// subchunk 1
ffio_wfourcc(wav_header, "fmt ");
avio_wl32 (wav_header, 16); // subchunk size
avio_wl16 (wav_header, 1); // uncompressed audio
avio_wl16 (wav_header, nb_channels);
avio_wl32 (wav_header, sample_rate);
avio_wl32 (wav_header, sample_rate * nb_channels * bit_depth / 8); // byte rate
avio_wl16 (wav_header, nb_channels * bit_depth / 8); // block align
avio_wl16 (wav_header, bit_depth); // bits per sample
avio_wl32(wav_header, 16); // subchunk size
avio_wl16(wav_header, 1); // uncompressed audio
avio_wl16(wav_header, nb_channels);
avio_wl32(wav_header, sample_rate);
avio_wl32(wav_header, sample_rate * nb_channels * bit_depth / 8); // byte rate
avio_wl16(wav_header, nb_channels * bit_depth / 8); // block align
avio_wl16(wav_header, bit_depth); // bits per sample
// subchunk 2
ffio_wfourcc (wav_header, "data");
avio_wl32 (wav_header, -1);
size = avio_close_dyn_buf (wav_header, &buffer);
ret = sp_write (s->sp, buffer, size);
av_free (buffer);
ffio_wfourcc(wav_header, "data");
avio_wl32(wav_header, -1);
size = avio_close_dyn_buf(wav_header, &buffer);
ret = sp_write(s->sp, buffer, size);
av_free(buffer);
return ret;
}
......@@ -413,16 +412,16 @@ static int try_read_frame(ASubProcessContext *s, AVFilterLink *outlink)
AVFrame *out;
int ret;
if (s->state == STATE_EXPECT_RIFF && sp_can_read (s->sp) >= 12)
if (s->state == STATE_EXPECT_RIFF && sp_can_read(s->sp) >= 12)
{
char buffer[12];
sp_read (s->sp, buffer, 12);
sp_read(s->sp, buffer, 12);
s->state = STATE_EXPECT_CHUNK;
}
if (s->state == STATE_EXPECT_CHUNK && sp_can_read (s->sp) >= 8)
if (s->state == STATE_EXPECT_CHUNK && sp_can_read(s->sp) >= 8)
{
unsigned char x[8];
sp_read (s->sp, x, 8);
sp_read(s->sp, x, 8);
s->chunk_size = AV_RL32 (x + 4);
if (x[0] == 'd' && x[1] == 'a' && x[2] == 't' && x[3] == 'a')
s->state = STATE_IN_DATA_CHUNK;
......@@ -431,20 +430,20 @@ static int try_read_frame(ASubProcessContext *s, AVFilterLink *outlink)
else
s->state = STATE_SKIP_CHUNK;
}
if (s->state == STATE_IN_FMT_CHUNK && sp_can_read (s->sp) >= 16)
if (s->state == STATE_IN_FMT_CHUNK && sp_can_read(s->sp) >= 16)
{
unsigned char data[16];
sp_read (s->sp, data, 16);
sp_read(s->sp, data, 16);
s->out_bit_depth = AV_RL16 (data + 14);
s->chunk_size -= 16;
s->state = STATE_SKIP_CHUNK;
}
if (s->state == STATE_SKIP_CHUNK && sp_can_read (s->sp) >= s->chunk_size)
if (s->state == STATE_SKIP_CHUNK && sp_can_read(s->sp) >= s->chunk_size)
{
while (s->chunk_size)
{
char buffer[1024];
unsigned int n = FFMIN (sizeof (buffer), s->chunk_size);
unsigned int n = FFMIN(sizeof (buffer), s->chunk_size);
sp_read (s->sp, buffer, n);
s->chunk_size -= n;
}
......@@ -453,7 +452,7 @@ static int try_read_frame(ASubProcessContext *s, AVFilterLink *outlink)
if (s->state == STATE_IN_DATA_CHUNK)
{
int sample_size = s->out_bit_depth / 8;
int avail = sp_can_read (s->sp) / sample_size / outlink->ch_layout.nb_channels;
int avail = sp_can_read(s->sp) / sample_size / outlink->ch_layout.nb_channels;
if (avail > NB_BUFFER_SAMPLES)
avail = NB_BUFFER_SAMPLES;
if (avail == NB_BUFFER_SAMPLES || (s->eof && avail > 0))
......
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