[vlc-devel] Questions about VLC's avcodec video decoder

Laurent Aimar fenrir at via.ecp.fr
Sat Apr 18 17:59:14 CEST 2009


Hi,

On Sat, Apr 18, 2009, Etienne Membrives wrote:
> Thus, we have a few questions about video decoding, and more
> specifically about the management of references frames in
> modules/codec/avcodec/video.c :
> - How VLC knows about which frames are referenced, and which aren't ?
> We've seen that decodec_(un)LinkPicture seems to manages that, but how
> and when these functions are called ?
 VLC does not know, ffmpeg does it for us.

 ffmpeg will call AVCodecContext::get_buffer() when it need a new frame
and will call AVCodecContext::release_buffer() when it does not need it
anymore .
 This 2 functions will then call decodec_(un)LinkPicture to tell VLC core
of the decoder needs if we are using direct rendering.

> - What corresponds to the "direct rendering" mode ? It should be a mode
> where libavcodec passes directly to video output the picture data,
 It is a mode where we give to ffmpeg the buffer in which we want it to
write.
 That means that ffmpeg does not use its own buffer but the buffer comming
from VLC.
 If you look at ffmpeg_GetFrameBuf/ffmpeg_ReleaseFrameBuf you will see that
 - if "direct rendering" is true, then we fill AVFrame with VLC picture_t
 fields.
 - if not, then we simply call the default ffmpeg allocator 
(avcodec_default_get_buffer).

 When using direct rendering, after avcodec_decode_video, we simply retreive
a vlc picture (AVFrame::opaque) and give it back to VLC.
 When not, we have to copy the ffmpeg picture into a vlc one (ffmpeg_CopyPicture).

> which functions of modules/codec/avcodec/video.c are called in this mode
> and which aren't ? And when "direct rendering" is deactivated ?
 The same function are called except that b_direct_rendering is checked at a
few places .

> Then a more general question :
> - When we are filling-in decoded data into a picture_t structure, why
> there is different strides for source and destination in a vast majority
> of codecs ?
 A decoder and a video output may not have the same requirement on the stride
value (multiple of 16 or 32 or ...).

If it could help you, I have made a quick and ugly patch to support VAAPI through
ffmpeg that I can send to you

Regards,

-- 
fenrir




More information about the vlc-devel mailing list