PDA

View Full Version : Do motion estimation in frame level or merged into macroblock encode?


johnslion
23rd May 2005, 04:20
Hi, all:
I am reading H.264 source codes, I found that the motion estimation part in both x264 and JM project are working in marcoblock level, detecting a marcoblock's motion vector and type just before encoding the marcoblock and then do next macroblock"s ME..., not like some mpeg4 projects, such as xvid, working in frame level, doing whole frame MB motion estimation and store the MVs and macroblocks' type, then do marcoblock encoding one by one with these data.
In my opinion, do frame level motion estimation procedure will decrease the cache read miss, because the reference frames will be always in cache lines, but if the motion estimation procedure in marcroblock level, the reference frame data will be kicked out the cache because there are lot of memory access in marcoblock encode process.Less cache read miss will benefit performance.
And I also think about multi-frames reference, if the marcoblocks can seldom found their reference in nearest reference frame, then the frame level me and MB level ME might got same cache miss.But this happens little.
So, what do you think about motion estimation whole frame or motion estimation MB -> MB encode -> ME MB -> MB encode .....?

Manao
23rd May 2005, 06:34
The encoding process need exactly the same data as the motion estimation, so it's better to do it at the macroblock's level, just after the motion estimation, because at that moment, all the data needed to do the motion compensation is in the cache.

johnslion
23rd May 2005, 08:14
I just think about it, here is my opinion.
In frame level ME process, when a marcoblock do searching in range, a lot of pixels around it will be loaded into cache, and most these pixels can also be reused by next marcoblock ME process, while doing MB encoding, only 1 or 2 macroblock cache miss will be meet while doing motion compensation.
In MB level ME process, motion compensation process will not got any cache miss, but when next MB entering motion estimation procedure, all the pixels around current MB has already been kicked out of cache, so they needed to be loaded into cache again and will meet a lot cache miss.

johnslion
23rd May 2005, 08:27
And in discrete marcoblock motion estimation most of the quant tables, transform tables, VLC tables which been used in current marcoblock encoding will be kicked out of cache when the next macroblock in motion estimation process if the marcroblock can not get quick match.So they need to be loaded again and again when doing next marcoblock encoding.
In continous marcoblock (frame level) motion estimation, most of the tables can stay in cache.