Just have a look at the speex_bits_write_whole_bytes (or something like
that). That allows you to flush the "complete" bytes and continue
writing to the bits structure. As you guessed, just encoding without
flushing anything isn't a good idea.
Jean-Marc
On ven, 2004-07-30 at 14:20 -0600, David Barrett wrote:> When encoding many frames, I get a write access exception. It appears
> the "bits" structure has a fixed-size buffer (allocated in
> speex_bits_init()), and speex-encode() pukes when it overruns it.
>
> I understand I could just initialize bits with a bigger buffer, or watch
> the buffer and stop encoding when it gets full.
>
> But I don't want to care about compressed frame sizes, nor *can* I know
> when VBR is enabled.
>
> Is there any way to make speex_encode() automatically reallocate the
> "bits" buffer if its too small? Then it'd "just
work" without me caring
> about the size of the internal bits buffer.
>
> Alternatively, am I'm not supposed to encode many (>100) frames into
a
> single bits buffer? The docs say to call speex_encode() multiple times,
> and it doesn't specify a limit. It works great for up to 53 frames,
and
> I see no reason why more shouldn't work fine.
>
> So, am I doing something wrong, or is this a bug, or should the library
> be enhanced to auto-resize the internal bits buffer (or at least return
> a pretty error code) rather than blindly overwriting it?
>
> Thanks! Speex rox!
>
> -david
> _______________________________________________
> Speex-dev mailing list
> Speex-dev@xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev
>
--
Jean-Marc Valin <Jean-Marc.Valin@USherbrooke.ca>
Universit? de Sherbrooke