详细资料http://developers.videolan.org/vlc/ VLC API documentation 或者VLC
developerdocumentationChapter 5. The video
outputlayer Data structures and main loopImportant data structures are defined ininclude/video.handinclude/video_output.h.The
main data structure is picture_t, which describes everything avideo decoder thread needs. Please refer to this file for moreinformation. Typically,p_datawillbe
a pointer to YUV planar picture.Note also the subpicture_t structure. In fact the VLC SPU decoderonly parses the SPU header, and converts the SPU graphical data toan internal format which can be rendered much faster. So a part ofthe "real" SPU decoder
lies insrc/video_output/video_spu.c.The vout_thread_t structure is much more complex, but you needn'tunderstand everything. Basically the video output thread manages aheap of pictures and subpictures (5 by default). Every picture hasa status (displayed,
destroyed, empty...) and eventually apresentation time. The main job of the video output is an infiniteloop to : [this is subject to change in the near future]
Find the next picture to display in the heap.
Find the current subpicture to display.
Render the picture (if the video output plug-in doesn't support YUVoverlay). Rendering will call an optimized YUV plug-in, which willalso do the scaling, add subtitles and an optional
pictureinformation field.
Sleep until the specified date.
Display the picture (plug-in function). For outputs which displayRGB data, it is often accomplished with a bufferswitching.p_vout->p_bufferisan
array of two buffers where the YUV transform takes place, andp_vout->i_buffer_index indicates the currentlydisplayed buffer.
Manage events.
Methods used by video
decodersThe video output exports a bunch of functions so that decoders cansend their decoded data. The most important functionisvout_CreatePicture whichallocates
the picture buffer to the size indicated by the videodecoder. It then just needs to feed (void*) p_picture->p_datawiththe decoded data, and callvout_DisplayPictureandvout_DatePictureuponnecessary.
picture_t *vout_CreatePicture(vout_thread_t *p_vout, int i_type, int i_width,
int i_height): Returns anallocated picture buffer.i_typewillbe for instanceYUV_420_PICTURE,and
i_width and i_height are in pixels.WarningIf no picture is available in the heap,vout_CreatePicturewillreturn NULL.
vout_LinkPicture(vout_thread_t *p_vout, picture_t *p_pic ):
Increasesthe refcount of the picture, so that it doesn't get accidentlyfreed while the decoder still needs it. For instance, an I or Ppicture can still be needed after displaying to decode interleavedB pictures.
vout_UnlinkPicture(vout_thread_t *p_vout, picture_t *p_pic ):
Decreasesthe refcount of the picture. An unlink must be done for every linkpreviously made.
vout_DatePicture(vout_thread_t *p_vout, picture_t *p_pic ):
Gives thepicture a presentation date. You can start working on a picturebefore knowing precisely at what time it will be displayed. Forinstance to date an I or P picture, you must wait until you havedecoded all previous B pictures (which are indeed placed
after -decoding order != presentation order).
vout_DisplayPicture(vout_thread_t *p_vout, picture_t *p_pic ):
Tells thevideo output that a picture has been completely decoded and isready to be rendered. It can be called before oraftervout_DatePicture.
vout_DestroyPicture(vout_thread_t *p_vout, picture_t *p_pic ):
Marks thepicture as empty (useful in case of a stream parsing error).
subpicture_t *vout_CreateSubPicture(vout_thread_t *p_vout, int i_channel,
int i_type ): Returns anallocated subpicture buffer.i_channelisthe ID of the subpicture channel,i_typeisDVD_SUBPICTUREorTEXT_SUBPICTURE,i_sizeisthe
length in bytes of the packet.
vout_DisplaySubPicture(vout_thread_t *p_vout, subpicture_t *p_subpic ):
Tells thevideo output that a subpicture has been completely decoded. Itobsoletes the previous subpicture.
vout_DestroySubPicture(vout_thread_t *p_vout, subpicture_t *p_subpic ):
Marks thesubpicture as empty.