From d9d83772fbee853857f1904fa6553f06a026108c Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 12 Jan 2010 08:12:44 +0100 Subject: [PATCH] filter: Remove allocation of filter buffers. fn->buf is not used any more. --- aacdec_filter.c | 9 +-------- amp_filter.c | 6 ------ compress_filter.c | 14 ++++---------- fecdec_filter.c | 23 ++--------------------- ggo/mp3dec_filter.m4 | 12 ------------ mp3dec_filter.c | 10 ---------- oggdec_filter.c | 5 ----- prebuffer_filter.c | 3 --- wav_filter.c | 13 ++----------- wmadec_filter.c | 5 ----- 10 files changed, 9 insertions(+), 91 deletions(-) diff --git a/aacdec_filter.c b/aacdec_filter.c index 51665552..9809552c 100644 --- a/aacdec_filter.c +++ b/aacdec_filter.c @@ -23,10 +23,7 @@ #include "string.h" #include "aac.h" -/** the output buffer size */ -#define AAC_OUTBUF_SIZE (32 * 1024) - -/** give up decoding after that many errors */ +/** Give up decoding after that many errors. */ #define MAX_ERRORS 20 /** @@ -83,8 +80,6 @@ static void aacdec_open(struct filter_node *fn) struct private_aacdec_data *padd = para_calloc(sizeof(*padd)); fn->private_data = padd; - fn->bufsize = AAC_OUTBUF_SIZE; - fn->buf = para_calloc(fn->bufsize); fn->min_iqs = 2048; padd->handle = aac_open(); } @@ -94,8 +89,6 @@ static void aacdec_close(struct filter_node *fn) struct private_aacdec_data *padd = fn->private_data; NeAACDecClose(padd->handle); - free(fn->buf); - fn->buf = NULL; free(padd); fn->private_data = NULL; } diff --git a/amp_filter.c b/amp_filter.c index 5e58212d..2c833d65 100644 --- a/amp_filter.c +++ b/amp_filter.c @@ -19,9 +19,6 @@ #include "string.h" #include "error.h" -/** The size of the output data buffer. */ -#define AMP_CHUNK_SIZE 40960 - extern char *stat_item_values[NUM_STAT_ITEMS]; /** Data specific to the amplify filter. */ @@ -35,7 +32,6 @@ struct private_amp_data { static void amp_close(struct filter_node *fn) { free(fn->private_data); - free(fn->buf); } static int amp_parse_config(int argc, char **argv, void **config) @@ -66,8 +62,6 @@ static void amp_open(struct filter_node *fn) sscanf(stat_item_values[SI_AMPLIFICATION], "%u", &pad->amp); else pad->amp = pad->conf->amp_arg; - fn->bufsize = AMP_CHUNK_SIZE; - fn->buf = para_malloc(fn->bufsize); PARA_NOTICE_LOG("amplification: %u (scaling factor: %1.2f)\n", pad->amp, pad->amp / 64.0 + 1.0); } diff --git a/compress_filter.c b/compress_filter.c index 8e6b1c45..09a4c74d 100644 --- a/compress_filter.c +++ b/compress_filter.c @@ -23,9 +23,6 @@ #include "string.h" #include "error.h" -/** The size of the output data buffer. */ -#define COMPRESS_CHUNK_SIZE 40960 - /** Data specific to the compress filter. */ struct private_compress_data { /** The current multiplier. */ @@ -40,10 +37,9 @@ struct private_compress_data { int peak; }; -static void close_compress(struct filter_node *fn) +static void compress_close(struct filter_node *fn) { free(fn->private_data); - free(fn->buf); } static void compress_post_select(__a_unused struct sched *s, struct task *t) @@ -134,15 +130,13 @@ err: return ret; } -static void open_compress(struct filter_node *fn) +static void compress_open(struct filter_node *fn) { struct private_compress_data *pcd = para_calloc( sizeof(struct private_compress_data)); pcd->conf = fn->conf; fn->private_data = pcd; fn->min_iqs = 2; /* 16 bit audio */ - fn->bufsize = COMPRESS_CHUNK_SIZE; - fn->buf = para_malloc(fn->bufsize); pcd->current_gain = 1 << pcd->conf->inertia_arg; pcd->max_gain = 1 << (pcd->conf->inertia_arg + pcd->conf->aggressiveness_arg); } @@ -162,8 +156,8 @@ void compress_filter_init(struct filter *f) struct compress_filter_args_info dummy; compress_cmdline_parser_init(&dummy); - f->open = open_compress; - f->close = close_compress; + f->open = compress_open; + f->close = compress_close; f->pre_select = generic_filter_pre_select; f->post_select = compress_post_select; f->parse_config = compress_parse_config; diff --git a/fecdec_filter.c b/fecdec_filter.c index fd35d5f5..8ccc2ee2 100644 --- a/fecdec_filter.c +++ b/fecdec_filter.c @@ -31,11 +31,6 @@ */ #define NUM_FEC_GROUPS 3 -/** Default size of the output buffer of the fecdec filter. */ -#define FECDEC_DEFAULT_OUTBUF_SIZE (3 * 1024) -/** Maximal size of the output buffer of the fecdec filter. */ -#define FECDEC_MAX_OUTBUF_SIZE (1024 * 1024) - /** Data read from the header of a slice. */ struct fec_header { /** Total number of slices in this group. */ @@ -326,11 +321,7 @@ static int decode_group(struct fecdec_group *fg, struct filter_node *fn) break; if (sb + written > fg->h.audio_header_size) n = fg->h.audio_header_size - written; - if (fn->btrn) - btr_copy(fg->data[i], n, pfd->btrp, fn->btrn); - else - memcpy(p + written, fg->data[i], n); - fn->loaded += n; + btr_copy(fg->data[i], n, pfd->btrp, fn->btrn); written += n; } p += written; @@ -340,11 +331,7 @@ static int decode_group(struct fecdec_group *fg, struct filter_node *fn) size_t n = sb; if (n + written > fg->h.group_bytes) n = fg->h.group_bytes - written; - if (fn->btrn) - btr_copy(fg->data[i], n, pfd->btrp, fn->btrn); - else - memcpy(p + written, fg->data[i], n); - fn->loaded += n; + btr_copy(fg->data[i], n, pfd->btrp, fn->btrn); written += n; } p += written; @@ -443,12 +430,9 @@ static void fecdec_close(struct filter_node *fn) FOR_EACH_FECDEC_GROUP(fg, pfd) clear_group(fg); - free(fn->buf); - fn->buf = NULL; fec_free(pfd->fec); free(fn->private_data); fn->private_data = NULL; - fn->conf = NULL; } static void fecdec_post_select(__a_unused struct sched *s, struct task *t) @@ -491,11 +475,8 @@ out: static void fecdec_open(struct filter_node *fn) { struct private_fecdec_data *pfd; - fn->bufsize = FECDEC_DEFAULT_OUTBUF_SIZE; - fn->buf = para_malloc(fn->bufsize); pfd = para_calloc(sizeof(*pfd)); fn->private_data = pfd; - fn->loaded = 0; fn->min_iqs = FEC_HEADER_SIZE; } diff --git a/ggo/mp3dec_filter.m4 b/ggo/mp3dec_filter.m4 index 0a31d7e8..b6e596c9 100644 --- a/ggo/mp3dec_filter.m4 +++ b/ggo/mp3dec_filter.m4 @@ -2,18 +2,6 @@ include(header.m4) include(buffer_tree.m4) -option "bufsize" b -#~~~~~~~~~~~~~~~~~ -"size of output buffer" -int typestr="kilobyte" -default="128" -optional -details=" - Increase this if you encounter output buffer overrun - errors. Smaller values make the mp3dec filter use less - memory. The minimal size is 32K. -" - option "ignore-crc" i #~~~~~~~~~~~~~~~~~~~~ "ignore CRC information in the audio stream." diff --git a/mp3dec_filter.c b/mp3dec_filter.c index b13c602b..bff42090 100644 --- a/mp3dec_filter.c +++ b/mp3dec_filter.c @@ -114,8 +114,6 @@ static void mp3dec_close(struct filter_node *fn) mad_frame_finish(&pmd->frame); mad_stream_finish(&pmd->stream); - free(fn->buf); - fn->buf = NULL; free(pmd); fn->private_data = NULL; } @@ -207,9 +205,6 @@ static void mp3dec_open(struct filter_node *fn) mad_stream_init(&pmd->stream); mad_frame_init(&pmd->frame); mad_synth_init(&pmd->synth); - fn->loaded = 0; - fn->bufsize = mp3_conf->bufsize_arg * 1024; - fn->buf = para_calloc(fn->bufsize); if (mp3_conf->ignore_crc_given) mad_stream_options(&pmd->stream, MAD_OPTION_IGNORECRC); } @@ -223,11 +218,6 @@ static int mp3dec_parse_config(int argc, char **argv, void **config) ret = -E_MP3DEC_SYNTAX; if (mp3dec_cmdline_parser(argc, argv, mp3_conf)) goto err; - ret = -ERRNO_TO_PARA_ERROR(EINVAL); - if (mp3_conf->bufsize_arg < 32) - goto err; - if (mp3_conf->bufsize_arg >= INT_MAX / 1024) - goto err; *config = mp3_conf; return 1; err: diff --git a/oggdec_filter.c b/oggdec_filter.c index 7a52508e..bac28cfd 100644 --- a/oggdec_filter.c +++ b/oggdec_filter.c @@ -97,11 +97,8 @@ static void ogg_open(struct filter_node *fn) { struct private_oggdec_data *pod = para_calloc( sizeof(struct private_oggdec_data)); - struct oggdec_filter_args_info *conf = fn->conf; fn->private_data = pod; - fn->bufsize = conf->bufsize_arg * 1024; - fn->buf = para_malloc(fn->bufsize); fn->min_iqs = 8000; } @@ -115,8 +112,6 @@ static void ogg_close(struct filter_node *fn) pod->vf = NULL; } else PARA_DEBUG_LOG("nothing to close\n"); - free(fn->buf); - fn->buf = NULL; free(fn->private_data); fn->private_data = NULL; } diff --git a/prebuffer_filter.c b/prebuffer_filter.c index 7fea2dfc..ac66b203 100644 --- a/prebuffer_filter.c +++ b/prebuffer_filter.c @@ -56,7 +56,6 @@ static void prebuffer_pre_select(struct sched *s, struct task *t) static void prebuffer_close(struct filter_node *fn) { free(fn->private_data); - free(fn->buf); } static void prebuffer_post_select(__a_unused struct sched *s, struct task *t) @@ -107,8 +106,6 @@ static void prebuffer_open(struct filter_node *fn) ppd->conf = fn->conf; fn->private_data = ppd; - fn->bufsize = 8192; /* gets increased on demand */ - fn->buf = para_malloc(fn->bufsize); } static void prebuffer_free_config(void *conf) diff --git a/wav_filter.c b/wav_filter.c index 4f12a34c..5b879f2d 100644 --- a/wav_filter.c +++ b/wav_filter.c @@ -19,11 +19,9 @@ #include "string.h" #include "portable_io.h" -/** size of the output buffer */ -#define WAV_OUTBUF_SIZE 81920 -/** a wav header is always 44 bytes */ +/** A wav header is always 44 bytes. */ #define WAV_HEADER_LEN 44 -/** always write 16 bit header */ +/** Always write 16 bit header. */ #define BITS 16 static void make_wav_header(unsigned int channels, unsigned int samplerate, @@ -53,8 +51,6 @@ static void make_wav_header(unsigned int channels, unsigned int samplerate, static void wav_close(struct filter_node *fn) { - free(fn->buf); - fn->buf = NULL; free(fn->private_data); fn->private_data = NULL; } @@ -63,14 +59,9 @@ static void wav_open(struct filter_node *fn) { int *bof; - fn->bufsize = WAV_OUTBUF_SIZE; - fn->buf = para_malloc(fn->bufsize); fn->private_data = para_malloc(sizeof(int)); bof = fn->private_data; - fn->loaded = 0; *bof = 1; - PARA_INFO_LOG("wav filter node: %p, output buffer: %p, loaded: %zd\n", - fn, fn->buf, fn->loaded); } static void wav_pre_select(struct sched *s, struct task *t) diff --git a/wmadec_filter.c b/wmadec_filter.c index 0ec5878c..12339962 100644 --- a/wmadec_filter.c +++ b/wmadec_filter.c @@ -1199,8 +1199,6 @@ static void wmadec_close(struct filter_node *fn) if (!pwd) return; wmadec_cleanup(pwd); - free(fn->buf); - fn->buf = NULL; free(fn->private_data); fn->private_data = NULL; } @@ -1289,10 +1287,7 @@ err: static void wmadec_open(struct filter_node *fn) { - fn->bufsize = 1024 * 1024; - fn->buf = para_malloc(fn->bufsize); fn->private_data = NULL; - fn->loaded = 0; fn->min_iqs = 4096; } -- 2.39.5