aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorPascal Massimino <pascal.massimino@gmail.com>2010-07-20 21:54:46 +0000
committerPascal Massimino <pascal.massimino@gmail.com>2010-07-20 21:54:46 +0000
commitfd7242ddbdd3bb3bedc3b520d8c80f4512742074 (patch)
tree5d185871c378777a383a6700762df1c7546749c7 /libavcodec
parent91c4d85f7b0f06f83f55496e8f15d9a3545801b7 (diff)
downloadffmpeg-fd7242ddbdd3bb3bedc3b520d8c80f4512742074.tar.gz
remove an unneeded av_realloc()
Originally committed as revision 24375 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/libvorbis.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c
index d0463adeef..4b875338a4 100644
--- a/libavcodec/libvorbis.c
+++ b/libavcodec/libvorbis.c
@@ -85,11 +85,14 @@ static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avcco
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(AVCodecContext *avccontext) {
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(AVCodecContext *avccontext) {
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);