[FFmpeg-cvslog] r24375 - trunk/libavcodec/libvorbis.c
skal
subversion
Tue Jul 20 23:54:46 CEST 2010
Author: skal
Date: Tue Jul 20 23:54:46 2010
New Revision: 24375
Log:
remove an unneeded av_realloc()
Modified:
trunk/libavcodec/libvorbis.c
Modified: trunk/libavcodec/libvorbis.c
==============================================================================
--- trunk/libavcodec/libvorbis.c Tue Jul 20 22:47:47 2010 (r24374)
+++ trunk/libavcodec/libvorbis.c Tue Jul 20 23:54:46 2010 (r24375)
@@ -85,11 +85,14 @@ static av_cold int oggvorbis_init_encode
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) {
@@ -105,9 +108,11 @@ static av_cold int oggvorbis_encode_init
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 + FF_INPUT_BUFFER_PADDING_SIZE);
p[0] = 2;
offset = 1;
offset += av_xiphlacing(&p[offset], header.bytes);
@@ -118,8 +123,7 @@ static av_cold int oggvorbis_encode_init
offset += header_comm.bytes;
memcpy(&p[offset], header_code.packet, header_code.bytes);
offset += header_code.bytes;
- avccontext->extradata_size = offset;
- avccontext->extradata= av_realloc(avccontext->extradata, avccontext->extradata_size);
+ assert(offset == avccontext->extradata_size);
/* vorbis_block_clear(&context->vb);
vorbis_dsp_clear(&context->vd);
More information about the ffmpeg-cvslog
mailing list