From 98fe404a94063b28e66f32e8047e20136900f25f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 6 Apr 2011 00:14:56 +0200 Subject: [PATCH] Fix REBASE_PICTURE with h.264 Signed-off-by: Michael Niedermayer --- libavcodec/mpegvideo.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 3a47ebe2bc..fee75b248d 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -686,7 +686,10 @@ typedef struct MpegEncContext { void (*denoise_dct)(struct MpegEncContext *s, DCTELEM *block); } MpegEncContext; -#define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? &new_ctx->picture[pic - old_ctx->picture] : NULL) +#define REBASE_PICTURE(pic, new_ctx, old_ctx) (pic ? \ + (pic >= old_ctx->picture && pic < old_ctx->picture+old_ctx->picture_count ?\ + &new_ctx->picture[pic - old_ctx->picture] : pic - (Picture*)old_ctx + (Picture*)new_ctx)\ + : NULL) void MPV_decode_defaults(MpegEncContext *s); int MPV_common_init(MpegEncContext *s);