[FFmpeg-devel] [PATCH] misc libvorbis.c fixes
Aurelien Jacobs
aurel
Sun Jul 11 14:21:15 CEST 2010
On Sun, Jul 11, 2010 at 12:07:53AM -0700, Pascal Massimino wrote:
> David,
>
> On Sat, Jul 3, 2010 at 12:35 AM, David Conrad <lessen42 at gmail.com> wrote:
>
> > Sorry for the delays...
> >
> > On Jun 29, 2010, at 3:44 AM, Pascal Massimino wrote:
> >
> > > Index: libavcodec/libvorbis.c
> > > ===================================================================
> > > --- libavcodec/libvorbis.c (revision 23816)
> > > +++ libavcodec/libvorbis.c (working copy)
> > > @@ -84,11 +84,14 @@
> > > return vorbis_encode_setup_init(vi);
> > > }
> > >
> > > +/* How many bytes are needed for a buffer of length 'l' */
> > > +static int xiph_len(int l) { return (1 + l / 255 + l); }
> > > +
> > > static av_cold int oggvorbis_encode_init(AVCodecContext *avccontext) {
> > > OggVorbisContext *context = avccontext->priv_data ;
> > > ogg_packet header, header_comm, header_code;
> > > uint8_t *p;
> > > - unsigned int offset, len;
> > > + unsigned int offset;
> > >
> > > vorbis_info_init(&context->vi) ;
> > > if(oggvorbis_init_encoder(&context->vi, avccontext) < 0) {
> > > @@ -104,9 +107,10 @@
> > > vorbis_analysis_headerout(&context->vd, &context->vc, &header,
> > > &header_comm, &header_code);
> > >
> > > - len = header.bytes + header_comm.bytes + header_code.bytes;
> > > - avccontext->extradata_size= 64 + len + len/255;
> > > - p = avccontext->extradata= av_mallocz(avccontext->extradata_size);
> > > + avccontext->extradata_size=
> > > + 1 + xiph_len(header.bytes) + xiph_len(header_comm.bytes) +
> > > + header_code.bytes;
> > > + p = avccontext->extradata = av_malloc(avccontext->extradata_size);
> >
> > Might as well add in the missing FF_INPUT_BUFFER_PADDING_SIZE while you're
> > at it
> >
>
> ok, as in the new patch attached?
No...
> Index: libvorbis.c
> ===================================================================
> --- libvorbis.c (revision 24184)
> +++ libvorbis.c (working copy)
> @@ -105,9 +108,10 @@
> vorbis_analysis_headerout(&context->vd, &context->vc, &header,
> &header_comm, &header_code);
>
> - len = header.bytes + header_comm.bytes + header_code.bytes;
> - avccontext->extradata_size= 64 + len + len/255;
> - p = avccontext->extradata= av_mallocz(avccontext->extradata_size);
> + len= 1 + xiph_len(header.bytes) + xiph_len(header_comm.bytes) +
> + header_code.bytes;
> + avccontext->extradata_size= len + FF_INPUT_BUFFER_PADDING_SIZE;
> + p = avccontext->extradata = av_malloc(avccontext->extradata_size);
extradata must be allocated with FF_INPUT_BUFFER_PADDING_SIZE, but
FF_INPUT_BUFFER_PADDING_SIZE must not be added to extradata_size.
Aurel
More information about the ffmpeg-devel
mailing list