[x264-devel] Custom slice support

Loren Merritt lorenm at u.washington.edu
Tue Nov 13 12:35:06 CET 2007


On Tue, 13 Nov 2007, Etienne Bömcke wrote:

> I'm a PhD student at the university of Louvain-la-Neuve, Belgium,
> currently working in the field of video-transmission to mobile
> devices. I'm looking for a h.264 encoder which would allow me to
> define custom slice patterns, such as a vertical subdivision of each
> frame in two rectangular slices. I wanted to know if this was possible
> using the current version of x264, or if I would have to do some
> programming.
> If new code is needed, could anyone point me to the file where the
> frames should be split into slices? I tried to look at the whole code
> but I'm afraid it'll take me days to figure this out.

Current x264 doesn't support slices at all. It will support horizontal 
slices when I get around to merging that patch. But shapes other than 
"rectangles filling the width of the frame" are nontrivial to implement. 
You'd have to modify just about every piece of code that looks at 
neighboring macroblocks, since the normal assumptions of which neighbors 
are valid and which aren't would no longer hold. Also, x264 doesn't divide 
the frame into slices, instead it codes macroblocks in raster scan order 
and writes a new slice header when it reaches a slice border. You can't 
change the raster order without breaking threading, so you'd have keep 
multiple bitstream contexts and switch between them depending on which 
slice the current macroblock is in. And that's just if you're using slices 
for error resilience; if you also want to change any parameters between 
slices things get even more complicated.

--Loren Merritt


More information about the x264-devel mailing list