[FFmpeg-cvslog] h264: Use mb itself as memcpy anchor and assert the other anchors position

Michael Niedermayer git at videolan.org
Thu Feb 14 00:43:18 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Feb 14 00:33:28 2013 +0100| [701e9b82547c6fa72acfb91c86bf29c40722f154] | committer: Michael Niedermayer

h264: Use mb itself as memcpy anchor and assert the other anchors position

This makes the code more robust against reordering or fields.

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=701e9b82547c6fa72acfb91c86bf29c40722f154
---

 libavcodec/h264.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 26386b9..3471e67 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -1251,9 +1251,10 @@ static int decode_update_thread_context(AVCodecContext *dst,
         for (i = 0; i < MAX_PPS_COUNT; i++)
             av_freep(h->pps_buffers + i);
 
-        // copy all fields after MpegEnc
+        // copy all fields after MpegEnc, except mb
         memcpy(&h->s + 1, &h1->s + 1,
-               offsetof(H264Context, intra_gb) - sizeof(MpegEncContext));
+               offsetof(H264Context, mb) - sizeof(MpegEncContext));
+        av_assert0(&h->cabac == &h->mb_padding + 1);
         memcpy(&h->cabac, &h1->cabac,
                sizeof(H264Context) - offsetof(H264Context, cabac));
         memset(h->sps_buffers, 0, sizeof(h->sps_buffers));



More information about the ffmpeg-cvslog mailing list