diff options
author | Torsten Jager <t.jager@gmx.de> | 2013-11-23 14:49:40 +0100 |
---|---|---|
committer | Torsten Jager <t.jager@gmx.de> | 2013-11-23 14:49:40 +0100 |
commit | 15a46e3e35906f9281aaff96c5bc303757603f19 (patch) | |
tree | 0ea94a11dc30476955bab7d5caa8edb4e8559982 | |
parent | 1dd0d4d58e52849b6ad6db307a51b5897b4d3e58 (diff) | |
download | xine-lib-15a46e3e35906f9281aaff96c5bc303757603f19.tar.gz xine-lib-15a46e3e35906f9281aaff96c5bc303757603f19.tar.bz2 |
ff_video_decoder: fix palette side data freeing.
-rw-r--r-- | src/combined/ffmpeg/ff_video_decoder.c | 17 | ||||
-rw-r--r-- | src/combined/ffmpeg/ffmpeg_compat.h | 7 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/combined/ffmpeg/ff_video_decoder.c b/src/combined/ffmpeg/ff_video_decoder.c index 2de40409b..182d547c7 100644 --- a/src/combined/ffmpeg/ff_video_decoder.c +++ b/src/combined/ffmpeg/ff_video_decoder.c @@ -139,7 +139,7 @@ struct ff_video_decoder_s { #if AVPALETTE == 1 AVPaletteControl palette_control; -#elif AVPALETTE == 2 +#elif AVPALETTE == 2 || AVPALETTE == 3 uint32_t palette[256]; int palette_changed; #endif @@ -1315,7 +1315,7 @@ static void ff_handle_special_buffer (ff_video_decoder_t *this, buf_element_t *b decoder_palette->palette_changed = 1; this->context->palctrl = decoder_palette; -#elif AVPALETTE == 2 +#elif AVPALETTE == 2 || AVPALETTE == 3 lprintf ("BUF_SPECIAL_PALETTE\n"); for (i = 0; i < buf->decoder_info[2]; i++) { this->palette[i] = @@ -1678,7 +1678,7 @@ static void ff_handle_buffer (ff_video_decoder_t *this, buf_element_t *buf) { avpkt.data = (uint8_t *)&chunk_buf[offset]; avpkt.size = this->size; avpkt.flags = AV_PKT_FLAG_KEY; -# if AVPALETTE == 2 +# if AVPALETTE == 2 || AVPALETTE == 3 if (this->palette_changed) { uint8_t *sd = av_packet_new_side_data (&avpkt, AV_PKT_DATA_PALETTE, 256 * 4); if (sd) @@ -1695,15 +1695,20 @@ static void ff_handle_buffer (ff_video_decoder_t *this, buf_element_t *buf) { len = avcodec_decode_video2 (this->context, this->av_frame, &got_picture, &avpkt); } -# if AVPALETTE == 2 +# if AVPALETTE == 2 || AVPALETTE == 3 if (this->palette_changed) { + /* Prevent freeing our data buffer */ + avpkt.data = NULL; + avpkt.size = 0; +# if AVPALETTE == 2 /* TJ. Oh dear and sigh. AVPacket side data handling is broken even in ffmpeg 1.1.1 - see avcodec/avpacket.c The suggested av_free_packet () would leave a memory leak here, and ff_packet_free_side_data () is private. */ - avpkt.data = NULL; - avpkt.size = 0; av_destruct_packet (&avpkt); +# else /* AVPALETTE == 3 */ + av_free_packet (&avpkt); +# endif this->palette_changed = 0; } # endif diff --git a/src/combined/ffmpeg/ffmpeg_compat.h b/src/combined/ffmpeg/ffmpeg_compat.h index f1927edc8..7433f7646 100644 --- a/src/combined/ffmpeg/ffmpeg_compat.h +++ b/src/combined/ffmpeg/ffmpeg_compat.h @@ -116,9 +116,12 @@ /* release 0.7.x (libavcodec 52) has deprecated AVCodecContext.palctrl but for backwards compatibility no working alternative. */ # define AVPALETTE 1 -#else -/* pass palette as AVPacket side data */ +#elif LIBAVCODEC_VERSION_INT < ((54<<16)|(92<<8)|100) +/* pass palette as AVPacket side data, free with av_destruct_packet () after NULLing main data pointer */ # define AVPALETTE 2 +#else +/* dito, free with av_free_packet () after NULLing main data pointer */ +# define AVPALETTE 3 #endif #if defined LIBAVUTIL_VERSION_MAJOR && LIBAVUTIL_VERSION_MAJOR >= 52 |