Chapter 5. The video output layer

简介: Table of Contents Data structures and main loop Methods used by video decoders How to write a video output plug-in How to write a YUV p...

Table of Contents

Data structures and main loop

Methods used by video decoders

How to write a video output plug-in

How to write a YUV plug-in

Data structures and main loop

Important data structures are defined in include/video.h and include/video_output.h. The main data structure is picture_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 planarwps_clip_image1 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 renderedwps_clip_image2 much faster. So a part of the "real" SPU decoder lies in src/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]

1. Find the next picture to display in the heap.

2. Find the current subpicture to display.

3. Render the picture (if the video output plug-in doesn't support YUV overlay). Rendering will call an optimized wps_clip_image3YUV plug-in, which will also do the scalingwps_clip_image4, add subtitles and an optional picture information field.

4. Sleep until the specified date.

5. Display the picture (plug-in function). For outputs which display RGB data, it is often accomplishedwps_clip_image5 with a buffer switchingwps_clip_image6. 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.

6. Manage events.

Methods used by video decoders

The video output exports a bunchwps_clip_image7 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 and vout_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 accidentlywps_clip_image8 freed while the decoder still needs it. For instance, an I or P picture can still be needed after displaying to decode interleavedwps_clip_image9 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 previouslywps_clip_image10 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 preciselywps_clip_image11 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 renderedwps_clip_image12. It can be called before or after vout_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 is DVD_SUBPICTURE or TEXT_SUBPICTURE, i_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 wps_clip_image13the previous subpicture.

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

How to write a video output plug-in

A video output takes care of the system calls to display the pictures and manage the output window. Have a look at plugins/x11/vout_x11.c. You must write the following functions :

1. int vout_Probe ( probedata_t *p_data ) : Returns a score between 0 and 999 to indicate whether it can run on the architecture. 999 is the best. p_data is currently unused.

2. int vout_Create ( vout_thread_t *p_vout ) : Basically, initializes and opens a new window. Returns TRUE if it failed.

3. int vout_Init ( vout_thread_t *p_vout ) : Creates optional picture buffers (for instance ximages or xvimages). Returns TRUE if it failed.

4. vout_End ( vout_thread_t *p_vout ) : Frees optional picture buffers.

5. int vout_Manage ( vout_thread_t *p_vout ) : Manages events (including for instance resize events).

6. vout_Display ( vout_thread_t *p_vout ) : Displays a previously rendered buffer.

7. vout_SetPalette ( vout_thread_t *p_vout, u16 *red, u16 *green, u16 *blue, u16 *transp ) : Sets the 8 bpp palette. red, green and blue are arrays of 256 unsigned shorts.

How to write a YUV plug-in

Look at the C source plugins/yuv/transforms_yuv.c. You need to redefine just the same transformations. Basically, it is a matrix wps_clip_image14multiplywps_clip_image15 operation. Good luck.

相关文章
|
3月前
|
存储 Android开发 数据安全/隐私保护
安卓手机和苹果手机如何快速完成文件互传?安卓手机文件传到苹果手机方法分享
在日常工作中,跨设备文件传输需求频繁,尤其是Android与iOS之间。本文推荐一款名为LocalSend的工具,支持Android、iOS、Windows、Mac平台,通过局域网实现快速、安全的文件互传,无需互联网连接。操作简便,界面直观,适合多设备用户使用。
906 1
|
2月前
|
人工智能 监控 BI
抖音电商 API 接口:开启抖音小店直播带货数据新洞察
在数字化电商浪潮中,抖音小店凭借直播带货迅速崛起。本文详解抖音电商 API 接口如何实现直播数据实时监控与深度分析,助力商家优化策略、提升转化,迈向数据驱动运营新时代。
304 29
|
6月前
|
存储 关系型数据库 分布式数据库
登顶TPC-C|云原生数据库PolarDB技术揭秘:成本优化-软硬协同篇
阿里云PolarDB云原生数据库在TPC-C基准测试中以超越原记录2.5倍的性能登顶排行榜,实现每分钟20.55亿笔交易,单位成本仅0.8元人民币,刷新性能与性价比双纪录。此外,还介绍了国产轻量版PolarDB MySQL的推出,满足市场对高性价比的需求。
|
7月前
|
机器学习/深度学习 人工智能 算法
NeurIPS 2024:拆解高复杂运筹问题的砖石,打破数据稀缺的瓶颈,中科大提出高质量运筹数据生成方法
中国科学技术大学团队在NeurIPS 2024提出MILP-StuDio方法,通过拆解与重构MILP实例的块结构生成高质量数据,解决MILP领域数据稀缺问题。该方法保持实例可行性和计算难度,实验表明可将求解时间减少超10%。尽管存在块结构识别依赖和问题类型覆盖局限,但仍为提升MILP求解器性能提供新思路。
144 8
|
7月前
|
人工智能 安全 物联网
《鸿蒙系统中人工智能驱动的智能助手:应用模式与未来航向》
在数字化时代,人工智能与操作系统的融合成为科技变革的核心力量。鸿蒙系统作为华为自主研发的分布式操作系统,为智能助手提供了广阔舞台。通过语音交互、多模态融合、场景感知与跨设备协同,智能助手实现了便捷操控、深度交互和主动服务。未来,借助大模型赋能、物联网深度融合及强化隐私保护,智能助手将推动全场景服务创新,助力开发者生态繁荣,开启万物互联的智能交互新时代。
427 12
|
8月前
|
数据采集 自然语言处理 监控
《一文破解!自然语言处理论文实验复现秘籍》
在自然语言处理(NLP)领域,复现学术论文实验是将理论转化为实践的关键。前期需深入研读论文、收集数据与代码资源;搭建环境时要配置开发工具和预处理数据;模型训练中注重架构实现、优化器选择及训练监控;最后通过评估指标、结果对比与可视化分析确保复现成功。这一过程不仅验证研究成果,还提升技术能力,推动NLP领域的发展。
224 16
|
9月前
|
供应链 数据可视化 搜索推荐
商业模式画布BMC入门指南:模块、实操与工具
2分钟了解什么是商业模式画布BMC,哪些工具可以绘制。
824 11
商业模式画布BMC入门指南:模块、实操与工具
|
10月前
|
人工智能 供应链 数据可视化
新一代信息技术助力企业数字化转型
本文深入探讨了企业数字化转型的内涵、重要性及其实现路径,强调了数字化转型不仅是技术革新,更是企业全方位的升级。文章分析了转型过程中面临的挑战与机遇,并介绍了板栗看板如何作为高效的项目管理工具,助力企业优化流程、提升效率,推动数字化转型的成功实施。
396 11
|
12月前
|
存储 前端开发 安全
如何选择适合自己搭建网站的CMS?
互联网时代,官网是企业、政务和学校展示自己单位文化的窗口,而内容管理系统(CMS)则是打开这扇窗户的媒介,能帮助高效地创建和分发大规模的网站内容。 CMS网站管理系统、主要包含了前端页面和后端管理平台。用户可以通过这个后台去管理前端页面的内容。对于一些没有建站基础的用户来说,如何选择CMS系统来搭建网站?有什么类型的CMS适合初次接触建站的用户使用?
111 0
|
存储 运维 分布式计算
HDFS 如何实现容错
【8月更文挑战第12天】
477 4