filter: Remove allocation of filter buffers.
authorAndre Noll <maan@systemlinux.org>
Tue, 12 Jan 2010 07:12:44 +0000 (08:12 +0100)
committerAndre Noll <maan@systemlinux.org>
Tue, 12 Jan 2010 07:12:44 +0000 (08:12 +0100)
fn->buf is not used any more.

aacdec_filter.c
amp_filter.c
compress_filter.c
fecdec_filter.c
ggo/mp3dec_filter.m4
mp3dec_filter.c
oggdec_filter.c
prebuffer_filter.c
wav_filter.c
wmadec_filter.c

index 5166555272c672ecda4bd4109d2e29b06b90aa4d..9809552ccf1694f4a2f97d2fd955b08bd22b9e07 100644 (file)
 #include "string.h"
 #include "aac.h"
 
 #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
 
 /**
 #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;
        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();
 }
        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);
        struct private_aacdec_data *padd = fn->private_data;
 
        NeAACDecClose(padd->handle);
-       free(fn->buf);
-       fn->buf = NULL;
        free(padd);
        fn->private_data = NULL;
 }
        free(padd);
        fn->private_data = NULL;
 }
index 5e58212dacee5daacad0209805ef2591684f9855..2c833d656c859ff2b36a9c67295681ff9a92c429 100644 (file)
@@ -19,9 +19,6 @@
 #include "string.h"
 #include "error.h"
 
 #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. */
 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);
 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)
 }
 
 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;
                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);
 }
        PARA_NOTICE_LOG("amplification: %u (scaling factor: %1.2f)\n",
                pad->amp, pad->amp / 64.0 + 1.0);
 }
index 8e6b1c45eca5c65ae712875ab46250fa7a7dca7c..09a4c74d17dd7642dccbe990f4cb309418e58b71 100644 (file)
@@ -23,9 +23,6 @@
 #include "string.h"
 #include "error.h"
 
 #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. */
 /** Data specific to the compress filter. */
 struct private_compress_data {
        /** The current multiplier. */
@@ -40,10 +37,9 @@ struct private_compress_data {
        int peak;
 };
 
        int peak;
 };
 
-static void close_compress(struct filter_node *fn)
+static void compress_close(struct filter_node *fn)
 {
        free(fn->private_data);
 {
        free(fn->private_data);
-       free(fn->buf);
 }
 
 static void compress_post_select(__a_unused struct sched *s, struct task *t)
 }
 
 static void compress_post_select(__a_unused struct sched *s, struct task *t)
@@ -134,15 +130,13 @@ err:
        return  ret;
 }
 
        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 */
 {
        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);
 }
        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);
        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;
        f->pre_select = generic_filter_pre_select;
        f->post_select = compress_post_select;
        f->parse_config = compress_parse_config;
index fd35d5f5d6a278a615c34e02c9c096d775330c0a..8ccc2ee2b344371e369e0c2df5c792616f5d2374 100644 (file)
  */
 #define NUM_FEC_GROUPS 3
 
  */
 #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. */
 /** 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;
                                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;
                        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;
                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;
                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);
 
        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;
        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)
 }
 
 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;
 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;
        pfd = para_calloc(sizeof(*pfd));
        fn->private_data = pfd;
-       fn->loaded = 0;
        fn->min_iqs = FEC_HEADER_SIZE;
 }
 
        fn->min_iqs = FEC_HEADER_SIZE;
 }
 
index 0a31d7e8787c8a8418fe4d767f42532903761a51..b6e596c9f591e75d6244444c07c388b79cbfc30b 100644 (file)
@@ -2,18 +2,6 @@ include(header.m4)
 include(buffer_tree.m4)
 
 <qu>
 include(buffer_tree.m4)
 
 <qu>
-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."
 option "ignore-crc" i
 #~~~~~~~~~~~~~~~~~~~~
 "ignore CRC information in the audio stream."
index b13c602bbf6a4ef03b20093254bcf80d87013399..bff42090158d4929cab5e7cbdfdcf20aff864bdf 100644 (file)
@@ -114,8 +114,6 @@ static void mp3dec_close(struct filter_node *fn)
        mad_frame_finish(&pmd->frame);
        mad_stream_finish(&pmd->stream);
 
        mad_frame_finish(&pmd->frame);
        mad_stream_finish(&pmd->stream);
 
-       free(fn->buf);
-       fn->buf = NULL;
        free(pmd);
        fn->private_data = 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);
        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);
 }
        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 = -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:
        *config = mp3_conf;
        return 1;
 err:
index 7a52508ec8a7bdc0a2ad0d423f65c44d68b905c0..bac28cfdee77d5a9d48d343fc7f208111f437991 100644 (file)
@@ -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 private_oggdec_data *pod = para_calloc(
                sizeof(struct private_oggdec_data));
-       struct oggdec_filter_args_info *conf = fn->conf;
 
        fn->private_data = pod;
 
        fn->private_data = pod;
-       fn->bufsize = conf->bufsize_arg * 1024;
-       fn->buf = para_malloc(fn->bufsize);
        fn->min_iqs = 8000;
 }
 
        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");
                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;
 }
        free(fn->private_data);
        fn->private_data = NULL;
 }
index 7fea2dfccd978c001148e2721273114f7349d4c9..ac66b203c5526d75b52178a47383151d47a8f12d 100644 (file)
@@ -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);
 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)
 }
 
 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;
 
        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)
 }
 
 static void prebuffer_free_config(void *conf)
index 4f12a34c03fe5a74d58e772ba76df23f40fa5735..5b879f2d6270344b96ad95c9d061a484b5c76222 100644 (file)
 #include "string.h"
 #include "portable_io.h"
 
 #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
 #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,
 #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)
 {
 
 static void wav_close(struct filter_node *fn)
 {
-       free(fn->buf);
-       fn->buf = NULL;
        free(fn->private_data);
        fn->private_data = NULL;
 }
        free(fn->private_data);
        fn->private_data = NULL;
 }
@@ -63,14 +59,9 @@ static void wav_open(struct filter_node *fn)
 {
        int *bof;
 
 {
        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->private_data = para_malloc(sizeof(int));
        bof = fn->private_data;
-       fn->loaded = 0;
        *bof = 1;
        *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)
 }
 
 static void wav_pre_select(struct sched *s, struct task *t)
index 0ec5878c3a836d389ebac7a7188bcdb809ddcc25..1233996284f231d9855e7c14954fb77d317816f9 100644 (file)
@@ -1199,8 +1199,6 @@ static void wmadec_close(struct filter_node *fn)
        if (!pwd)
                return;
        wmadec_cleanup(pwd);
        if (!pwd)
                return;
        wmadec_cleanup(pwd);
-       free(fn->buf);
-       fn->buf = NULL;
        free(fn->private_data);
        fn->private_data = NULL;
 }
        free(fn->private_data);
        fn->private_data = NULL;
 }
@@ -1289,10 +1287,7 @@ err:
 
 static void wmadec_open(struct filter_node *fn)
 {
 
 static void wmadec_open(struct filter_node *fn)
 {
-       fn->bufsize = 1024 * 1024;
-       fn->buf = para_malloc(fn->bufsize);
        fn->private_data = NULL;
        fn->private_data = NULL;
-       fn->loaded = 0;
        fn->min_iqs = 4096;
 }
 
        fn->min_iqs = 4096;
 }