[FFmpeg-devel] [PATCH] Per-frame metadata
Michael Niedermayer
michaelni at gmx.at
Sat Apr 23 11:43:45 CEST 2011
On Mon, Apr 11, 2011 at 04:59:36PM +0200, Nicolas George wrote:
> Hi.
>
> The attached series of patches introduce per-frame metadata, and in
> particular PNG zTXt and tEXt chunks decoding.
>
> I did not try to make it work for CC subtitles, as I do not know what
> exactly would be required, but I believe this is a first step in that
> direction too.
>
> Regards,
>
> --
> Nicolas George
> mem.c | 15 +++++++++++++++
> mem.h | 25 +++++++++++++++++++++++++
> 2 files changed, 40 insertions(+)
> 26e27b9331a3a098f132399fbe129cc44e561219 0001-Introduce-av_size_mult-and-av_realloc_f.patch
> From c0557275f39dc7bc8049fa04cb0347e065147152 Mon Sep 17 00:00:00 2001
> From: Nicolas George <nicolas.george at normalesup.org>
> Date: Sun, 20 Mar 2011 19:39:20 +0100
> Subject: [PATCH 1/5] Introduce av_size_mult and av_realloc_f.
>
> av_size_mult helps checking for overflow when computing the size of a memory
> area.
>
> av_realloc_f helps avoiding memory-leaks in typical uses of realloc.
>
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavutil/mem.c | 15 +++++++++++++++
> libavutil/mem.h | 25 +++++++++++++++++++++++++
> 2 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/libavutil/mem.c b/libavutil/mem.c
> index 7ffd6cb..26fb8c6 100644
> --- a/libavutil/mem.c
> +++ b/libavutil/mem.c
> @@ -136,6 +136,21 @@ void *av_realloc(void *ptr, FF_INTERNAL_MEM_TYPE size)
> #endif
> }
>
> +void *av_realloc_f(void *ptr, size_t nelem, size_t elsize)
what does the _f stand for?
[...]
> @@ -131,4 +141,19 @@ char *av_strdup(const char *s) av_malloc_attrib;
> */
> void av_freep(void *ptr);
>
> +/**
> + * Multiplies two size_t values checking for overflow.
> + * @return 0 if success, -1 if overflow.
> + */
> +static inline int av_size_mult(size_t a, size_t b, size_t *r)
> +{
> + size_t t = a * b;
> + /* Hack inspired from glibc: only try the division if nelem and elsize
> + * are both greater than sqrt(SIZE_MAX). */
> + if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b)
> + return -1;
> + *r = t;
> + return 0;
> +}
> +
> #endif /* AVUTIL_MEM_H */
LGTM
[...]
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 3fa012d..65b7d7f 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -390,6 +390,7 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){
> // pic->base[i]=NULL;
> }
> //printf("R%X\n", pic->opaque);
> + av_metadata_free(&pic->metadata);
>
> if(s->debug&FF_DEBUG_BUFFERS)
> av_log(s, AV_LOG_DEBUG, "default_release_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count);
That looks like it will cause a leak in applications using their own
release_buffer()
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110423/d2ad3a45/attachment.asc>
More information about the ffmpeg-devel
mailing list