[Bf-blender-cvs] [cc12fc1] master: Fix T47806: Blender animation player stop working correctly with XVID codec

Sergey Sharybin noreply at git.blender.org
Fri Mar 18 07:51:35 CET 2016


Commit: cc12fc1f118c0921cd399a25456ea44a9f330bc2
Author: Sergey Sharybin
Date:   Fri Mar 18 11:50:06 2016 +0500
Branches: master
https://developer.blender.org/rBcc12fc1f118c0921cd399a25456ea44a9f330bc2

Fix T47806: Blender animation player stop working correctly with XVID codec

Something weird, seems some buffers _might_ be shared between codec context
and frame, which is quite weird. Could be a bug in FFmpeg or could be wrong
API usage somewhere else..

===================================================================

M	source/blender/imbuf/intern/anim_movie.c

===================================================================

diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c
index 763ec12..d378ca9 100644
--- a/source/blender/imbuf/intern/anim_movie.c
+++ b/source/blender/imbuf/intern/anim_movie.c
@@ -1168,6 +1168,15 @@ static void free_anim_ffmpeg(struct anim *anim)
 	if (anim->pCodecCtx) {
 		avcodec_close(anim->pCodecCtx);
 		avformat_close_input(&anim->pFormatCtx);
+
+		/* Special case here: pFrame could share pointers with codec,
+		 * so in order to avoid double-free we don't use av_frame_free()
+		 * to free the frame.
+		 *
+		 * Could it be a bug in FFmpeg?
+		 */
+		av_free(anim->pFrame);
+
 		if (!need_aligned_ffmpeg_buffer(anim)) {
 			/* If there's no need for own aligned buffer it means that FFmpeg's
 			 * frame shares the same buffer as temporary ImBuf. In this case we
@@ -1179,8 +1188,8 @@ static void free_anim_ffmpeg(struct anim *anim)
 			               anim->x, anim->y);
 		}
 		av_frame_free(&anim->pFrameRGB);
-		av_frame_free(&anim->pFrame);
 		av_frame_free(&anim->pFrameDeinterlaced);
+
 		sws_freeContext(anim->img_convert_ctx);
 		IMB_freeImBuf(anim->last_frame);
 		if (anim->next_packet.stream_index != -1) {




More information about the Bf-blender-cvs mailing list