[FFmpeg-devel] [PATCH] avoid mb_xy recalculation in h264

Alexander Strange astrange
Wed May 7 09:05:47 CEST 2008


This line appears in a lot of h264.c functions:
const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;

It only changes once per MB, so we can add it to the context and only  
recalculate it in decode_slice().
I put it at the end of H264Context, but it could be moved up earlier  
if someone likes it there. The position doesn't seem to affect  
performance much; it can't be moved next to mb_x/mb_y since that would  
put it in MpegEncContext, and none of the other codecs use it.

Patches:
1- does that, updating it for MBAFF when needed
2- removes some newly unused variables
3- does the same thing to svq3.c

Before: avg 8.799s max 8.8s min 8.794s
After: avg 8.645s max 8.651s min 8.641s

Tested on progressive, PAFF, MBAFF, and svq3. I couldn't find a  
labeled MBAFF file in samples, so I'll put one in incoming.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1-h264-nombxy.diff
Type: text/x-diff
Size: 8330 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080507/c4dd66c7/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2-h264-warnings.diff
Type: text/x-diff
Size: 1009 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080507/c4dd66c7/attachment-0001.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 3-svq3.diff
Type: text/x-diff
Size: 1120 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080507/c4dd66c7/attachment-0002.diff>



More information about the ffmpeg-devel mailing list