[FFmpeg-devel] [PATCH] libavcodec/pngdec: support 'previous' dispose operation for APNG.

Michael Niedermayer michaelni at gmx.at
Mon Dec 1 23:34:44 CET 2014


On Mon, Dec 01, 2014 at 11:41:41AM +0100, Benoit Fouet wrote:
> ---
> Tested against all the materials I have at hand.
> There is an artifact showing for https://raw.githubusercontent.com/maxcom/lorsource/master/src/test/resources/images/i_want_to_be_a_hero__apng_animated__by_tamalesyatole-d5ht8eu.png
> which I don't really understand, as it seems the individual frames are correct
> for our decoder, but the disposal that's done for other decoders (tested
> firefox and chrome) is not the same for the end of the cape.
> ---
>  libavcodec/pngdec.c | 93 ++++++++++++++++++++++++++++++++++++++++-------------
>  1 file changed, 71 insertions(+), 22 deletions(-)
> 
> diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> index 9e52d0b..2ca3dee 100644
> --- a/libavcodec/pngdec.c
> +++ b/libavcodec/pngdec.c
> @@ -23,6 +23,7 @@
>  
>  #include "libavutil/bprint.h"
>  #include "libavutil/imgutils.h"
> +#include "libavutil/thread.h"
>  #include "avcodec.h"
>  #include "bytestream.h"
>  #include "internal.h"
> @@ -38,9 +39,16 @@ typedef struct PNGDecContext {
>      AVCodecContext *avctx;
>  
>      GetByteContext gb;
> +    ThreadFrame previous_picture;
>      ThreadFrame last_picture;
>      ThreadFrame picture;
>  
> +#if CONFIG_APNG_DECODER
> +    AVMutex mutex;
> +    int frame_id;
> +    int *pframe_id;
> +#endif

why do you need a mutex ?


[...]
> @@ -1193,13 +1218,26 @@ static int update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
>  {
>      PNGDecContext *psrc = src->priv_data;
>      PNGDecContext *pdst = dst->priv_data;
> +    int ret;
>  
>      if (dst == src)
>          return 0;
>  
> +#if CONFIG_APNG_DECODER
> +    pdst->pframe_id = psrc->pframe_id;
> +    ff_mutex_destroy(&pdst->mutex);
> +    pdst->mutex = psrc->mutex;
> +#endif

this would destroy mutexes more often than init them i think


[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20141201/c757f605/attachment.asc>


More information about the ffmpeg-devel mailing list