View Single Post
Old 1st October 2013, 21:52   #5  |  Link
akupenguin
x264 developer
 
akupenguin's Avatar
 
Join Date: Sep 2004
Posts: 2,392
There's two ways that lots of threads can lose quality:
  • When using VBV, we have to plan the size of one frame using only predictions of, not exact knowledge of, the size of previous frames that are still in progress. Threads do tell each other their exact size-so-far at the end of each row of macroblocks, not just when finishing a whole frame; but that can still be a significant amount of stuff in progress, adding up to a significant amount of uncertainty. This is bad because if we overcommitted bits to the beginning of a frame and then have to revise quality downwards for the bottom of the frame, (or conversely if we undercommitted for the top and only later learned that we have more bits available for the bottom), the result looks worse than if we had encoded the whole frame at an intermediate quality that gives the same total size. If you're not using VBV, this doesn't happen; none of the other ratecontrol modes care about such small deviations from the predicted size.
  • Limits to the vertical component of motion vectors, since a block can only be predicted from some part of a previous frame that has already been encoded. Which is bad if the actual motion is faster than that. However, x264 imposes a lower bound on this (default 24 pixels, can be overridden by --mvrange-thread). 24 implies that the spacing between one thread and the next that are working on mutually dependent frames, is 40 pixels (the other 16 is from the height of a macroblock). Which means that a 1080p video won't use more than 27 threads for a sequence of P-frames, though it can use more threads if there are B-frames involved, because those don't add to the dependency chain. And a 304p video won't use more than 8 threads for a sequence of P-frames. (Though perhaps the default mvrange-thread should depend on resolution, since typical speed of motion as measured in pixels depends on resolution.)
akupenguin is offline   Reply With Quote