vlc学习计划(6)--从接收到数据流到播放视频的过程分析

本文来自internet,转载这里供流媒体爱好者学习和研究使用,请尊重作者的劳动成果。未经授权而在商业上使用原作者的文章属侵权行为,后果由使用者自负,本人不承担任何法律责任。

 

 

从接收到数据流到播放视频的过程分析:从网络接收到流 -对数据流进行视频和音频分离-对视频用解码器解码-显示解码后的视频流 视频显示部分走势线:分离 - 解码 - 新的 VOUT 缓冲区 -VOUT 线程

从接收到数据流到播放视频的过程分析

从网络接收到流->对数据流进行视频和音频分离->对视频用解码器解码->显示解码后的视频流

视频显示部分走势线:分离->解码->新的VOUT缓冲区->VOUT线程

Demux(modules/demux/mpeg/ps.c)->DemuxPs(modules/demux/mpeg/system.c)-> ParsePS->input_SelectES(src/input/input_programs.c)->input_RunDecoder(src/input/input_dec.c)->CreateDecoder->

vout_new_buffer->vout_Request(src/video_output/video_output.c)->vout_Create->RunThread->vout_RenderPicture(src/video_output/vout_pictures.c)->pf_display

注意:p_dec->pf_vout_buffer_new = vout_new_buffer的pf_vout_buffer_new在ffmpeg_NewPictBuf(modules/codec/ffmpeg/video.c)函数中激活

解码部分走势线:

Demux(modules/demux/mpeg/ps.c)->DemuxPs(modules/demux/mpeg/system.c)-> ParsePS->input_SelectES(src/input/input_programs.c)->input_RunDecoder(src/input/input_dec.c)->CreateDecoder->DecoderThread

注意:在解码线程中对数据流(AUDIO 或者VIDEO)进行解码

详细资料 http://developers.videolan.org/vlc/    VLC API documentation  或者VLC developer documentation

Chapter 5.  The video output layer

Data structures and main loop

Important data structures are defined in include/video.h and include/video_output.h. The main data structure ispicture_t, which describes everything a video decoder thread needs. Please refer to this file for more information. Typically, p_data will be a pointer to YUV planar picture.

Note also the subpicture_t structure. In fact the VLC SPU decoder only parses the SPU header, and converts the SPU graphical data to an internal format which can be rendered much faster. So a part of the "real" SPU decoder lies insrc/video_output/video_spu.c.

The vout_thread_t structure is much more complex, but you needn't understand everything. Basically the video output thread manages a heap of pictures and subpictures (5 by default). Every picture has a status (displayed, destroyed, empty...) and eventually a presentation time. The main job of the video output is an infinite loop 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 YUV overlay). Rendering will call an optimized YUV plug-in, which will also do the scaling, add subtitles and an optional picture information field.

    • Sleep until the specified date.

    • Display the picture (plug-in function). For outputs which display RGB data, it is often accomplished with a buffer switching. p_vout->p_buffer is an array of two buffers where the YUV transform takes place, and p_vout->i_buffer_index indicates the currently displayed buffer.

    • Manage events.

Methods used by video decoders

The video output exports a bunch of functions so that decoders can send their decoded data. The most important function is vout_CreatePicture which allocates the picture buffer to the size indicated by the video decoder. It then just needs to feed (void *) p_picture->p_data with the decoded data, and call vout_DisplayPicture andvout_DatePicture upon necessary.

    • picture_t * vout_CreatePicture ( vout_thread_t *p_vout, int i_type, int i_width, int i_height ) : Returns an allocated picture buffer. i_type will be for instance YUV_420_PICTURE, and i_width and i_height are in pixels.

      Warning

      If no picture is available in the heap, vout_CreatePicture will return NULL.

    • vout_LinkPicture ( vout_thread_t *p_vout, picture_t *p_pic ) : Increases the refcount of the picture, so that it doesn't get accidently freed while the decoder still needs it. For instance, an I or P picture can still be needed after displaying to decode interleaved B pictures.

    • vout_UnlinkPicture ( vout_thread_t *p_vout, picture_t *p_pic ) : Decreases the refcount of the picture. An unlink must be done for every link previously made.

    • vout_DatePicture ( vout_thread_t *p_vout, picture_t *p_pic ) : Gives the picture a presentation date. You can start working on a picture before knowing precisely at what time it will be displayed. For instance to date an I or P picture, you must wait until you have decoded 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 the video output that a picture has been completely decoded and is ready to be rendered. It can be called before or aftervout_DatePicture.

    • vout_DestroyPicture ( vout_thread_t *p_vout, picture_t *p_pic ) : Marks the picture 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 an allocated subpicture buffer. i_channel is the ID of the subpicture channel, i_type isDVD_SUBPICTURE or TEXT_SUBPICTUREi_size is the length in bytes of the packet.

    • vout_DisplaySubPicture ( vout_thread_t *p_vout, subpicture_t *p_subpic ) : Tells the video output that a subpicture has been completely decoded. It obsoletes the previous subpicture.

    • vout_DestroySubPicture ( vout_thread_t *p_vout, subpicture_t *p_subpic ) : Marks the subpicture as empty.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值