[FFmpeg-devel] [PATCH] h264: allocate PPS and SPS dynamically
Guillaume Poirier
gpoirier
Mon May 28 15:03:10 CEST 2007
Andreas ?man wrote:
> Hi
>
> The following patch reduces sizeof(H264Context) from ~240kB to ~140kB.
> If only a few SPS and PPS are used (which i believe is most common)
> thus, it should save some memory footprint.
>
> +static void *
> +alloc_parameter_set(H264Context *h, void **vec, const int id, const int max, const size_t size, const char *name)
> +{
> + void *x;
> +
> + if(id>=max){
> + av_log(h->s.avctx, AV_LOG_ERROR, "%s_id (%d) out of range\n", name, id);
> + return NULL;
> + }
> +
> + x = vec[id];
> + if(x == NULL) {
> + x = av_mallocz(size);
> + if(x == NULL) {
> + av_log(h->s.avctx, AV_LOG_ERROR, "cannot allocate memory for %s\n", name);
> + return NULL;
> + }
> + vec[id] = x;
> + }
> + return x;
> +}
Don't hesitate to add a doxy comment before this new function ^|^
Guillaume
More information about the ffmpeg-devel
mailing list