On 6/7/2018 8:43 PM, Mark Thompson wrote: > +static int cbs_jpeg_write_unit(CodedBitstreamContext *ctx, > + CodedBitstreamUnit *unit) > +{ > + CodedBitstreamJPEGContext *priv = ctx->priv_data; > + PutBitContext pbc; > + int err; > + > + if (!priv->write_buffer) { > + // Initial write buffer size is 1MB. > + priv->write_buffer_size = 1024 * 1024; > + > + reallocate_and_try_again: > + err = av_reallocp(&priv->write_buffer, priv->write_buffer_size);
You could use av_fast_malloc() instead, since you don't care about the previous contents of the buffer. But it will make no real difference admittedly since at most it will be reallocated twice or thrice for really big files and that's it. I sent a patch implementing this change for the other modules some weeks, which i guess you didn't see and i forgot about :p > + if (err < 0) { > + av_log(ctx->log_ctx, AV_LOG_ERROR, "Unable to allocate a " > + "sufficiently large write buffer (last attempt " > + "%"SIZE_SPECIFIER" bytes).\n", priv->write_buffer_size); > + return err; > + } > + } _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel