[MPlayer-dev-eng] [PATCH] allow builtin codecs table to be const

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Mon Dec 3 08:26:23 CET 2007


Hello,
On Mon, Dec 03, 2007 at 05:17:18AM +0200, Uoti Urpala wrote:
> On Mon, 2007-12-03 at 00:25 +0100, Reimar Döffinger wrote:
[...]
> Less than 200 kB, so not really "several". It would be possible to make
> it significantly smaller. The infmt and inflags fields do not seem to be

hmm...true, about 176kB.

> used for anything. Most codecs do not have many output formats or
> fourccs, so storing a count plus a pointer to an array instead of a
> constant-sized array per codec would use much less memory (though with
> slightly more complicated code). I think that would drop the total size
> to about one fifth.

It's no problem for the parsed codecs.conf, it just seems like it would
be a real mess for the builtin one...

> > Unfortunately there is a bit extra work necessary for that, since
> > currently one flag for each codec is stored in that table.
> > Attached patch makes the changes necessary.
> > What do you think?
> 
> +               selected_video = calloc(4, nr_vcodecs >> 5);
> +               selected_audio = calloc(4, nr_acodecs >> 5);
> 
> Should round up not down. The arguments to calloc are in the opposite
> order compared to the formal meaning.

Yes, I forgot to round up at one other place as well.

[...]
> +int get_codec_ptr_selected(const codecs_t *c) {
> +       int offset;
> +       uint32_t *field = selected_audio;
> +       int index = ptr2idx(c, 1);
> +       if (index < 0) {
> +               field = selected_video;
> +               index = ptr2idx(c, 0);
> +       }
> +       if (index < 0) return -1;
> +       offset = index & 31;
> +       index >>= 5;
> +       return (field[index] >> offset) & 1;
> +}
> 
> When is the return -1 case expected to happen?

When someone messes up and passed an invalid pointer...

Greetings,
Reimar Döffinger



More information about the MPlayer-dev-eng mailing list