1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

remove an unneeded av_realloc()

Originally committed as revision 24375 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Pascal Massimino 2010-07-20 21:54:46 +00:00
parent 91c4d85f7b
commit fd7242ddbd

View File

@ -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);