X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fapngenc.c;h=c97c475274e9aee0e615fcd99fc4ab628017d224;hb=bc70684e74a185d7b80c8b80bdedda659cb581b8;hp=77c1c916c2e8dbb679f5631db313dce0ccd12b74;hpb=de33b3e457a656230fc6d544a1889218d77a5b3c;p=ffmpeg diff --git a/libavformat/apngenc.c b/libavformat/apngenc.c index 77c1c916c2e..c97c475274e 100644 --- a/libavformat/apngenc.c +++ b/libavformat/apngenc.c @@ -119,7 +119,7 @@ static int flush_packet(AVFormatContext *format_context, AVPacket *packet) AVIOContext *io_context = format_context->pb; AVStream *codec_stream = format_context->streams[0]; uint8_t *side_data = NULL; - int side_data_size = 0; + size_t side_data_size; av_assert0(apng->prev_packet); @@ -251,7 +251,6 @@ static int apng_write_trailer(AVFormatContext *format_context) if (apng->prev_packet) { ret = flush_packet(format_context, NULL); - av_freep(&apng->prev_packet); if (ret < 0) return ret; } @@ -266,12 +265,18 @@ static int apng_write_trailer(AVFormatContext *format_context) apng_write_chunk(io_context, MKBETAG('a', 'c', 'T', 'L'), buf, 8); } - av_freep(&apng->extra_data); - apng->extra_data = 0; - return 0; } +static void apng_deinit(AVFormatContext *s) +{ + APNGMuxContext *apng = s->priv_data; + + av_packet_free(&apng->prev_packet); + av_freep(&apng->extra_data); + apng->extra_data_size = 0; +} + #define OFFSET(x) offsetof(APNGMuxContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { @@ -289,7 +294,7 @@ static const AVClass apng_muxer_class = { .option = options, }; -AVOutputFormat ff_apng_muxer = { +const AVOutputFormat ff_apng_muxer = { .name = "apng", .long_name = NULL_IF_CONFIG_SMALL("Animated Portable Network Graphics"), .mime_type = "image/png", @@ -300,6 +305,7 @@ AVOutputFormat ff_apng_muxer = { .write_header = apng_write_header, .write_packet = apng_write_packet, .write_trailer = apng_write_trailer, + .deinit = apng_deinit, .priv_class = &apng_muxer_class, .flags = AVFMT_VARIABLE_FPS, };