CN117372238A - Registration function method, video frame processing method, device, equipment and storage medium - Google Patents
Registration function method, video frame processing method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN117372238A CN117372238A CN202311228920.4A CN202311228920A CN117372238A CN 117372238 A CN117372238 A CN 117372238A CN 202311228920 A CN202311228920 A CN 202311228920A CN 117372238 A CN117372238 A CN 117372238A
- Authority
- CN
- China
- Prior art keywords
- video
- layer
- shader
- registration
- function
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Landscapes
- Image Processing (AREA)
Abstract
本申请实施例公开了一种注册函数方法、视频帧处理方法、注册函数装置、视频帧处理装置、计算机设备和计算机可读存储介质。其中,本申请能够在图层合成器中注册用户提供的注册函数。注册好的注册函数将会以视频处理函数的形式向外暴露接口,以便于随时调用。使得在图像处理过程中,可以直接调用图象合成器内的视频处理函数,利用显存资源进行视频处理,视频数据无需在内存和显存之间多次转换。相比现有技术,本申请可以在同样的硬件配置下支持更高的帧率输出,并保证更佳的视频输出效果,提高性能和用户体验。
The embodiments of the present application disclose a registration function method, a video frame processing method, a registration function device, a video frame processing device, computer equipment and a computer-readable storage medium. Among them, this application can register the registration function provided by the user in the layer compositor. The registered function will expose the interface in the form of a video processing function so that it can be called at any time. During the image processing process, the video processing function in the image synthesizer can be directly called, and the video memory resources are used for video processing. The video data does not need to be converted multiple times between the memory and the video memory. Compared with the existing technology, this application can support higher frame rate output under the same hardware configuration, ensure better video output effects, and improve performance and user experience.
Description
技术领域Technical field
本申请属于计算机视频处理技术领域,特别是涉及一种注册函数方法、视频帧处理方法、注册函数装置、视频帧处理装置、计算机设备和计算机可读存储介质。The present application belongs to the technical field of computer video processing, and in particular relates to a registration function method, a video frame processing method, a registration function device, a video frame processing device, computer equipment and a computer-readable storage medium.
背景技术Background technique
随着5G的快速发展和普及,移动终端上运行的APP越来越多的加入了对显示的画面进行优化的功能。现有方法处理视频帧的时候需要经历如下的繁琐流程:步骤一:App控制打开相机;步骤二:获取相机采集视频帧;步骤三:从相机上的Surface中读取出视频帧到内存并转换成预设格式的视频帧;步骤四:把内存上的预设格式视频帧写入到自己申请的Surface上,然后使用着色器的相关原理处理视频帧,即视频编辑(比如:人脸识别、美颜、大眼瘦脸、滤镜等);步骤五:把处理完的Surface和桌面画面融合;步骤六:把融合后的Surface交给Surfaceflinger;步骤七:把Surfaceflinger中的画面投递给opengl或者屏幕硬件进行显示。以上步骤,每帧都需要走一遍,如果APP要求30fps,则如上流程每秒需要走30遍。以上步骤十分繁琐,视频帧在内存和显存之间转换多次,特别浪费性能,导致当前的主流直播平台在直播时,帧率都不高,且经常卡顿,同时对手机硬件的CPU和内存占用较大,导致手机发热严重,功耗增加。因此如何提高视频帧的处理效率,是本领域技术人员亟待解决的技术问题。With the rapid development and popularization of 5G, more and more apps running on mobile terminals have the function of optimizing the displayed images. Existing methods need to go through the following cumbersome process when processing video frames: Step 1: App controls to open the camera; Step 2: Gets the camera to collect video frames; Step 3: Reads the video frames from the Surface on the camera to the memory and converts them into pre-formatted video frames; Step 4: Write the pre-formatted video frames in the memory to the Surface you applied for, and then use the relevant principles of shaders to process the video frames, that is, video editing (such as: face recognition, Beauty, big eyes and face slimming, filters, etc.); Step 5: Fuse the processed Surface with the desktop screen; Step 6: Give the fused Surface to Surfaceflinger; Step 7: Deliver the screen in Surfaceflinger to opengl or screen hardware for display. The above steps need to be carried out every frame. If the APP requires 30fps, the above process needs to be carried out 30 times per second. The above steps are very cumbersome. The video frames are converted multiple times between memory and video memory, which is particularly wasteful of performance. As a result, the frame rate of the current mainstream live broadcast platforms is not high during live broadcast, and often freezes. At the same time, it also affects the CPU and memory of the mobile phone hardware. It occupies a large area, causing serious heating of the phone and increasing power consumption. Therefore, how to improve the processing efficiency of video frames is an urgent technical problem that needs to be solved by those skilled in the art.
前面的叙述在于提供一般的背景信息,并不一定构成现有技术。The preceding description is intended to provide general background information and does not necessarily constitute prior art.
发明内容Contents of the invention
基于此,有必要针对上述问题,提出了一种注册函数方法、视频帧处理方法、注册函数装置、视频帧处理装置、计算机设备和计算机可读存储介质,能够更高效地处理视频帧。Based on this, it is necessary to address the above problems and propose a registration function method, video frame processing method, registration function device, video frame processing device, computer equipment and computer-readable storage medium, which can process video frames more efficiently.
本申请解决其技术问题是采用以下的技术方案来实现的:This application solves its technical problems by adopting the following technical solutions:
本申请提供了一种注册函数方法,应用于视频设备,包括如下步骤:执行初始化操作,初始化操作的对象包括开放图形库、显存和纹理句柄中的至少一项;获取用户提供的注册函数,解析注册函数以得到第一着色器;对第一着色器执行注册操作,注册操作包括编译着色器代码并绑定在图层合成器中;将完成注册操作的第一着色器封装为视频处理函数,并向外暴露接口,以使视频应用通过接口直接调用视频处理函数。This application provides a registration function method, which is applied to video equipment and includes the following steps: perform an initialization operation, and the objects of the initialization operation include at least one of an open graphics library, a video memory, and a texture handle; obtain the registration function provided by the user, and parse Register the function to obtain the first shader; perform a registration operation on the first shader, the registration operation includes compiling the shader code and binding it in the layer compositor; encapsulate the first shader that completes the registration operation as a video processing function, And expose the interface to the outside, so that the video application can directly call the video processing function through the interface.
在本申请一可选实施例中,执行初始化操作之后,方法还包括:获取第二着色器,第二着色器为图层合成器自身所有的;对第二着色器执行注册操作,以在图层合成器内注册第二着色器;将完成注册操作的第一着色器封装为视频处理函数,并向外暴露接口,包括:将完成注册操作的第一着色器和第二着色器封装为视频处理函数,并向外暴露接口。In an optional embodiment of the present application, after performing the initialization operation, the method further includes: obtaining a second shader, which is owned by the layer compositor itself; and performing a registration operation on the second shader so as to create the second shader in the image. Register the second shader in the layer synthesizer; encapsulate the first shader that has completed the registration operation as a video processing function, and expose the interface to the outside, including: encapsulate the first shader and the second shader that have completed the registration operation as video Process functions and expose interfaces to the outside world.
在本申请一可选实施例中,将完成注册操作的第一着色器封装为视频处理函数,包括:将完成注册操作的第一着色器串行成开放图形库的处理管线;获取完成注册操作的第一着色器提供的对外的纹理句柄;将纹理句柄和处理管线封装为视频处理函数。In an optional embodiment of the present application, encapsulating the first shader that has completed the registration operation into a video processing function includes: serializing the first shader that has completed the registration operation into the processing pipeline of the open graphics library; obtaining the completed registration operation The external texture handle provided by the first shader; encapsulate the texture handle and processing pipeline into video processing functions.
本申请还提供了一种视频帧处理方法,应用于视频应用,包括如下步骤:从第一图层处获取第一视频数据,第一图层为相机模块的图层;将第一视频数据发送至图层合成器,图层合成器经过前文所描述的方法完成了注册;调用图层合成器中的视频处理函数,以控制图层合成器根据视频处理函数处理第一视频数据,视频处理函数为前文所描述的视频处理函数;读取并输出经过视频处理函数处理后的视频帧。This application also provides a video frame processing method, which is applied to video applications and includes the following steps: obtaining the first video data from the first layer, which is the layer of the camera module; sending the first video data To the layer compositor, the layer compositor completes the registration through the method described above; the video processing function in the layer compositor is called to control the layer compositor to process the first video data according to the video processing function. The video processing function is the video processing function described above; reads and outputs the video frames processed by the video processing function.
在本申请一可选实施例中,从第一图层处获取第一视频数据之后,方法还包括:从第二图层处获取第二视频数据,第二图层为应用模块的图层;将第一视频数据和第二视频数据进行画面融合处理以得到第三视频数据;将第三视频数据发送至图层合成器,调用视频处理函数,以控制图层合成器根据视频处理函数处理第三视频数据;读取并输出经过视频处理函数处理后的视频帧。In an optional embodiment of the present application, after obtaining the first video data from the first layer, the method further includes: obtaining the second video data from the second layer, and the second layer is the layer of the application module; Perform screen fusion processing on the first video data and the second video data to obtain the third video data; send the third video data to the layer synthesizer, and call the video processing function to control the layer synthesizer to process the third video data according to the video processing function. Three video data; read and output the video frames processed by the video processing function.
在本申请一可选实施例中,读取并输出经过视频处理函数处理后的视频帧,包括:判断是否有推流需求;若没有推流需求,则将视频帧投递至开放图形库或屏幕硬件进行显示;若有推流需求,则将视频帧投递至开放图形库或屏幕硬件进行显示,同时读取视频帧并传输至关联的流媒体服务器中,以使流媒体服务器进行视频推流。In an optional embodiment of the present application, reading and outputting the video frames processed by the video processing function includes: determining whether there is a demand for streaming; if there is no demand for streaming, delivering the video frames to an open graphics library or screen The hardware displays; if there is a demand for streaming, the video frames are delivered to the open graphics library or screen hardware for display. At the same time, the video frames are read and transmitted to the associated streaming media server, so that the streaming media server can push the video.
本申请还提供了一种注册函数装置,包括:初始化模块,用于执行初始化操作,初始化操作的对象包括开放图形库、显存和纹理句柄中的至少一项;注册模块,用于获取用户提供的注册函数,解析注册函数以得到第一着色器;对第一着色器执行注册操作,注册操作包括编译着色器代码并绑定在图层合成器中;封装模块,用于将完成注册操作的第一着色器封装为视频处理函数,并向外暴露接口,以使视频应用通过接口直接调用视频处理函数。This application also provides a registration function device, including: an initialization module, used to perform an initialization operation, the object of the initialization operation includes at least one of an open graphics library, a video memory, and a texture handle; a registration module, used to obtain the user-provided The registration function parses the registration function to obtain the first shader; performs a registration operation on the first shader. The registration operation includes compiling the shader code and binding it in the layer compositor; the encapsulation module is used to complete the registration operation of the third shader. A shader is encapsulated as a video processing function and exposes an interface to the outside, so that the video application can directly call the video processing function through the interface.
本申请还提供了一种视频帧处理装置,包括:获取模块,用于从第一图层处获取第一视频数据,第一图层为相机模块的图层;发送模块,用于将第一视频数据发送至图层合成器,图层合成器经过前文所描述的方法完成了注册;处理模块,用于调用图层合成器中的视频处理函数,利用显存资源处理第一视频数据;视频处理函数为前文所描述的视频处理函数;输出模块,用于读取并输出经过视频处理函数处理后的视频帧。This application also provides a video frame processing device, including: an acquisition module, used to acquire the first video data from the first layer, where the first layer is the layer of the camera module; and a sending module, used to send the first video data to the camera module. The video data is sent to the layer synthesizer, and the layer synthesizer completes the registration through the method described above; the processing module is used to call the video processing function in the layer synthesizer, and uses the video memory resources to process the first video data; video processing The function is the video processing function described above; the output module is used to read and output the video frames processed by the video processing function.
本申请还提供了一种计算机设备,包括处理器和存储器:处理器用于执行存储器中存储的计算机程序以实现如前述的方法。This application also provides a computer device, including a processor and a memory: the processor is used to execute the computer program stored in the memory to implement the aforementioned method.
本申请还提供了一种计算机可读存储介质,存储有计算机程序,当计算机程序被处理器执行时实现如前述的方法。This application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the aforementioned method is implemented.
采用本申请实施例,具有如下有益效果:Adopting the embodiments of this application has the following beneficial effects:
本申请能够在图层合成器中注册用户提供的注册函数。注册好的注册函数将会以视频处理函数的形式向外暴露接口,以便于随时调用。使得在图像处理过程中,可以直接调用图象合成器内的视频处理函数,利用显存资源进行视频处理,视频数据无需在内存和显存之间多次转换。相比现有技术,本申请可以在同样的硬件配置下支持更高的帧率输出,并保证更佳的视频输出效果,提高性能和用户体验。This application has the ability to register user-provided registration functions in the layer compositor. The registered function will expose the interface in the form of a video processing function so that it can be called at any time. During the image processing process, the video processing function in the image synthesizer can be directly called, and the video memory resources are used for video processing. The video data does not need to be converted multiple times between the memory and the video memory. Compared with the existing technology, this application can support higher frame rate output under the same hardware configuration, ensure better video output effects, and improve performance and user experience.
上述说明仅是本申请技术方案的概述,为了能够更清楚了解本申请的技术手段,而可依照说明书的内容予以实施,并且为了让本申请的上述和其他目的、特征和优点能够更明显易懂,以下特举较佳实施例,并配合附图,详细说明。应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。The above description is only an overview of the technical solutions of the present application. In order to have a clearer understanding of the technical means of the present application, they can be implemented in accordance with the contents of the description, and in order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand. , the following is a detailed description of the preferred embodiments, together with the accompanying drawings. It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and do not limit the present application.
附图说明Description of the drawings
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to explain the embodiments of the present application or the technical solutions in the prior art more clearly, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings in the following description are only These are some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without exerting creative efforts.
其中:in:
图1为一实施例提供的一种注册函数方法的流程示意图;Figure 1 is a schematic flowchart of a registration function method provided by an embodiment;
图2为一实施例提供的一种视频帧处理方法的流程示意图;Figure 2 is a schematic flowchart of a video frame processing method provided by an embodiment;
图3为一实施例提供的一种注册函数装置的内部功能模块连接关系示意图;Figure 3 is a schematic diagram of the internal functional module connection relationship of a registration function device provided by an embodiment;
图4为一实施例提供的一种视频帧处理装置的内部功能模块连接关系示意图;Figure 4 is a schematic diagram of the connection relationship between internal functional modules of a video frame processing device according to an embodiment;
图5为一实施例提供的一种计算机设备的结构示意框图。FIG. 5 is a schematic structural block diagram of a computer device according to an embodiment.
具体实施方式Detailed ways
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this application.
现有技术中,设备的相机模块采集视频数据后将放置于内存当中,而设备也仅能就内存内的视频数据进行帧处理,而无法处理整个画面。且处理过程中,数据往往在内存和显存之间多次转换,耗时耗力,导致很多不必要的资源消耗。为此,本申请提出了一种注册函数方法和一种视频帧处理方法,使得在设备的图层合成器中注册用户提供的视频处理函数,并暴露出接口以供随时调用。因而视频应用可以直接调用此接口,设置自己的画面优化相关方案,以在设备画面渲染时,调用注册的画面优化代码,实现对画面的优化,避免画面在各个模块间或者内存显存间传递和转化,大大降低耗时和耗能。为了清楚描述本实施例提供的一种注册函数方法和一种视频帧处理方法,请参考图1~图2,视频帧处理方法则由步骤S210~S240实现。In the existing technology, the camera module of the device collects the video data and places it in the memory. The device can only process frames of the video data in the memory, but cannot process the entire picture. And during the processing, data is often converted multiple times between memory and video memory, which is time-consuming and labor-intensive, resulting in a lot of unnecessary resource consumption. To this end, this application proposes a registration function method and a video frame processing method, so that the video processing function provided by the user is registered in the layer compositor of the device, and the interface is exposed for calling at any time. Therefore, the video application can directly call this interface and set up its own picture optimization related scheme to call the registered picture optimization code when rendering the device picture to optimize the picture and avoid the picture being transferred and converted between various modules or between memory and memory. , greatly reducing time and energy consumption. In order to clearly describe a registration function method and a video frame processing method provided by this embodiment, please refer to Figures 1 to 2. The video frame processing method is implemented by steps S210 to S240.
具体地,本申请所提供的方法中,可以应用于视频设备,在较佳的实施方式中视频设备可以为移动终端。对于移动终端具体形式例如可以但不限于手机、平板电脑、个人数码助理(英文:personal digital assistant,缩写:PDA)、移动互联网设备(英文:mobileInternet device,缩写:MID)和可穿戴设备(例如智能手表)等。移动终端上可以通过的应用程序(例如APP)来对相应的信息进处理和展示,以及执行相应的操作,从而提升使用效率。Specifically, the method provided in this application can be applied to a video device, and in a preferred embodiment, the video device can be a mobile terminal. Specific forms of mobile terminals include, but are not limited to, mobile phones, tablet computers, personal digital assistants (English: personal digital assistant, abbreviation: PDA), mobile Internet devices (English: mobile Internet device, abbreviation: MID) and wearable devices (such as smart phones). watches) etc. Applications (such as APP) can be used on mobile terminals to process and display corresponding information and perform corresponding operations, thereby improving usage efficiency.
其中,本申请提供的方法可以在图层合成器(Surfaceflinger)中开发可插入组件,使得相应视频处理函数在视频应用启动时运行一次即可,无需每帧调用,也不存在帧在显存和内存之间的转换,提高视频处理效率。为此需要在图层合成器中注册函数,实现该组件的插入,提出了注册函数方法,应用于视频设备,实现在硬件系统层面的设置,使得视频设备内的视频应用都可以调用注册好的函数,具体的,注册函数方法包括有步骤S110~S130。Among them, the method provided by this application can develop pluggable components in the layer compositor (Surfaceflinger), so that the corresponding video processing function can be run once when the video application is started. There is no need to call it every frame, and there is no need for frames to be stored in the video memory and memory. Conversion between to improve video processing efficiency. To this end, it is necessary to register a function in the layer compositor to realize the insertion of the component. A registration function method is proposed, which is applied to the video device to realize the settings at the hardware system level, so that all video applications in the video device can call the registered Function, specifically, the registration function method includes steps S110 to S130.
步骤S110:执行初始化操作,初始化操作的对象包括开放图形库、显存和纹理句柄中的至少一项。Step S110: Perform an initialization operation. The objects of the initialization operation include at least one of an open graphics library, a video memory, and a texture handle.
在一实施方式中,在注册函数之前,初始化操作也即是视频设备回到初始化状态,具体执行对象包括开放图形库(OpenGL)、显存和纹理句柄中的至少一项。具体还可以例如为该函数注册分配显存大小,以准备好用于存储顶点数据、纹理数据等。加载纹理图像并创建纹理句柄:可以使用第三方库(例如STB Image、FreeImage)加载纹理图像,并使用glTexImage2D()函数创建一个纹理对象。然后,可以使用glGenTextures()函数创建一个纹理句柄,并使用glBindTexture()函数将其绑定到开放图形库上下文中,以完成初始化操作。并且值得注意的是,对于初始化操作的具体步骤和实现方式可能因环境和需求的不同而略有不同。例如在实际应用中,还可以进行错误处理、资源清理等操作,以确保程序的正确性和稳定性,实际操作按照视频设备的应用环境具体设置,对此本申请便不再展开。In one embodiment, before registering the function, the initialization operation is to return the video device to the initialization state, and the specific execution object includes at least one of an open graphics library (OpenGL), a video memory, and a texture handle. Specifically, you can also register and allocate a video memory size for this function, so that it is ready for storing vertex data, texture data, etc. Load a texture image and create a texture handle: You can use a third-party library (such as STB Image, FreeImage) to load a texture image, and use the glTexImage2D() function to create a texture object. You can then create a texture handle using the glGenTextures() function and bind it to the open graphics library context using the glBindTexture() function to complete the initialization operation. And it is worth noting that the specific steps and implementation methods of the initialization operation may vary slightly depending on the environment and requirements. For example, in actual applications, operations such as error handling and resource cleaning can also be performed to ensure the correctness and stability of the program. The actual operation is set according to the specific application environment of the video device, and this application will not elaborate further.
步骤S120:获取用户提供的注册函数,解析注册函数以得到第一着色器;对第一着色器执行注册操作,注册操作包括编译着色器代码并绑定在图层合成器中。Step S120: Obtain the registration function provided by the user, parse the registration function to obtain the first shader, and perform a registration operation on the first shader. The registration operation includes compiling the shader code and binding it in the layer compositor.
步骤S130:将完成注册操作的第一着色器封装为视频处理函数,并向外暴露接口,以使视频应用通过接口直接调用视频处理函数。Step S130: Encapsulate the first shader that has completed the registration operation as a video processing function, and expose the interface to the outside, so that the video application can directly call the video processing function through the interface.
在一实施方式中,执行初始化操作之后,方法还包括:获取第二着色器,第二着色器为图层合成器自身所有的;对第二着色器执行注册操作,以在图层合成器内注册第二着色器;将完成注册操作的第一着色器封装为视频处理函数,并向外暴露接口,包括:将完成注册操作的第一着色器和第二着色器封装为视频处理函数,并向外暴露接口。In one embodiment, after performing the initialization operation, the method further includes: obtaining a second shader, which is owned by the layer compositor itself; and performing a registration operation on the second shader to register it within the layer compositor. Register the second shader; encapsulate the first shader that has completed the registration operation as a video processing function, and expose the interface to the outside, including: encapsulate the first shader and the second shader that have completed the registration operation as video processing functions, and Expose the interface to the outside world.
在一实施方式中,在图层合成器中注册用户提供的注册函数,必然需要将相应着色器(Shader)进行变异绑定。因此当用户编写了着色器相关代码,并以注册函数的形式提供给视频设备时。视频设备可解析注册函数以得到第一着色器,第一着色器也即是注册函数中着色器,是用户设定的视频处理方案,例如美颜方案、滤镜方案。并控制图层合成器对第一着色器相关代码进行编译和绑定实现函数的注册。In one embodiment, registering a user-provided registration function in the layer compositor necessarily requires mutation binding of the corresponding shader. So when the user writes shader-related code and provides it to the video device in the form of a registered function. The video device can parse the registration function to obtain the first shader. The first shader is the shader in the registration function and is a video processing solution set by the user, such as a beauty solution and a filter solution. And control the layer compositor to compile the first shader related code and register the binding implementation function.
进一步地,图层合成器不仅仅只处理用户指定的内容,还需要处理其他画面。因此在编译和绑定第一着色器的同时,还需要控制图层合成器获取自身所有的第二着色器同样执行注册操作,也即进行相关代码的编译和绑定。图层合成器完成第一着色器和第二着色器的注册操作之后,用户所提供的注册函数即以内嵌入图层合成器中,图层合成器也就能够按照用户注册函数设定的,对输入的视频数据进行处理。Furthermore, the layer compositor not only processes the content specified by the user, but also needs to process other images. Therefore, while compiling and binding the first shader, you also need to control the layer compositor to obtain all of its own second shaders and also perform registration operations, that is, compile and bind the relevant code. After the layer compositor completes the registration operation of the first shader and the second shader, the registration function provided by the user is embedded in the layer compositor, and the layer compositor can also set according to the user registration function. The input video data is processed.
在一实施方式中,将完成注册操作的第一着色器封装为视频处理函数,包括:将完成注册操作的第一着色器串行成开放图形库的处理管线;获取完成注册操作的第一着色器提供的对外的纹理句柄;将纹理句柄和处理管线封装为视频处理函数。In one embodiment, encapsulating the first shader that has completed the registration operation into a video processing function includes: serializing the first shader that has completed the registration operation into a processing pipeline of the open graphics library; and obtaining the first shader that has completed the registration operation. The external texture handle provided by the processor; the texture handle and processing pipeline are encapsulated into video processing functions.
在一实施方式中,完成注册操作的图层合成器还需要将函数进行封装,并将接口暴露,以使后续视频应用能够直接通过该接口调用控制图层合成器以处理视频数据。具体的,封装过程可以为将完成注册操作的第一着色器串行成开放图形库的处理管线。同样的处理管线中不仅包括有第一着色器,还可以包括有第二着色器,使得图层合成器的处理管线更加完整。之后提取出第一着色器和第二着色器提供的对外的纹理句柄,并连同和处理管线封装为视频处理函数。通过如上步骤还需要把显存句柄暴露出来,方便用户注册或者读取视频帧,并注册自己的美颜方案作为回调,如此设置,使得当图层合成器渲染时,会回调客户提供的视频处理算法实现对当前帧的视频处理操作。In one implementation, the layer compositor that completes the registration operation also needs to encapsulate the function and expose the interface, so that subsequent video applications can directly call the control layer compositor through the interface to process video data. Specifically, the encapsulation process may be to serialize the first shader that has completed the registration operation into a processing pipeline of the open graphics library. The same processing pipeline includes not only the first shader, but also the second shader, making the processing pipeline of the layer compositor more complete. Afterwards, the external texture handle provided by the first shader and the second shader is extracted and packaged into a video processing function together with the processing pipeline. Through the above steps, it is also necessary to expose the video memory handle, so that users can register or read video frames, and register their own beauty scheme as a callback. This setting makes the video processing algorithm provided by the customer callback when the layer compositor renders. Implement video processing operations on the current frame.
因此,视频装置在启动视频应用时可以按照如上步骤执行一遍从而实现注册函数方法。通过一次运行,使得之后视频处理过程中无需每帧调用,也不存在帧在显存和内存之间的转换,提高视频处理的效率和效果。Therefore, when starting the video application, the video device can execute the above steps once to implement the registration function method. By running it once, there is no need to call each frame during subsequent video processing, and there is no frame conversion between video memory and memory, which improves the efficiency and effect of video processing.
进一步地,执行完前文所述的方法,则需要执行本申请提供的应用于视频应用的视频帧处理,来合理使用该图层合成器,实现高效的视频处理。Furthermore, after executing the method described above, it is necessary to execute the video frame processing provided by this application and applied to video applications, so as to reasonably use the layer synthesizer and achieve efficient video processing.
步骤S210:从第一图层处获取第一视频数据,第一图层为相机模块的图层。Step S210: Obtain the first video data from the first layer, which is the layer of the camera module.
步骤S220:将第一视频数据发送至图层合成器,图层合成器经过前文所描述的方法完成了注册。Step S220: Send the first video data to the layer compositor, and the layer compositor completes the registration through the method described above.
在一实施方式中,从第一图层处获取第一视频数据之后,方法还包括:从第二图层处获取第二视频数据,第二图层为应用模块的图层;将第一视频数据和第二视频数据进行画面融合处理以得到第三视频数据;将第三视频数据发送至图层合成器,调用视频处理函数,以控制图层合成器根据视频处理函数处理第三视频数据;读取并输出经过视频处理函数处理后的视频帧。In one embodiment, after obtaining the first video data from the first layer, the method further includes: obtaining the second video data from the second layer, where the second layer is a layer of the application module; converting the first video perform picture fusion processing on the data and the second video data to obtain the third video data; send the third video data to the layer synthesizer, and call the video processing function to control the layer synthesizer to process the third video data according to the video processing function; Read and output the video frames processed by the video processing function.
在一实施方式中,视频应用也即是视频设备中相关处理视频数据的应用,尤其是需要实时处理的,具体包括但不限于有相机软件、录像软件、美颜软件、直播软件等。视频应用不再需要像现有技术一样从内存中调用视频数据,而是控制相机模块中的第一图层(Surface)所采集的第一视频数据,直接发送至图层合成器中进行处理,由图层合成器直接利用显存资源进行处理,而不需要再仅有内存互相转化处理。In one embodiment, video applications are applications related to processing video data in video devices, especially those that require real-time processing, including but not limited to camera software, video recording software, beauty software, live broadcast software, etc. The video application no longer needs to call the video data from the memory like the existing technology, but controls the first video data collected by the first layer (Surface) in the camera module and sends it directly to the layer synthesizer for processing. The layer compositor directly utilizes video memory resources for processing, eliminating the need for memory conversion processing.
此外,如前文所述,图层合成器不仅需要处理相机模块采集的视频数据,还需要处理渲染其他数据,例如桌面画面等。而桌面画面等视频数据也即是第二图层中的第二视频数据,第二图层为应用模块的图层。将第一视频数据和第二视频数据进行画面融合处理以得到第三视频数据。In addition, as mentioned earlier, the layer compositor not only needs to process the video data collected by the camera module, but also needs to process and render other data, such as desktop images. The video data such as the desktop screen is also the second video data in the second layer, and the second layer is the layer of the application module. The first video data and the second video data are subjected to screen fusion processing to obtain third video data.
步骤S230:调用图层合成器中的视频处理函数,以控制图层合成器根据视频处理函数处理第一视频数据,视频处理函数为前文所描述的视频处理函数。Step S230: Call the video processing function in the layer compositor to control the layer compositor to process the first video data according to the video processing function. The video processing function is the video processing function described above.
步骤S240:读取并输出经过视频处理函数处理后的视频帧。Step S240: Read and output the video frames processed by the video processing function.
在一实施方式中,读取并输出经过视频处理函数处理后的视频帧,包括:判断是否有推流需求;若没有推流需求,则将视频帧投递至开放图形库或屏幕硬件进行显示;若有推流需求,则将视频帧投递至开放图形库或屏幕硬件进行显示,同时读取视频帧并传输至关联的流媒体服务器中,以使流媒体服务器进行视频推流。In one implementation, reading and outputting the video frames processed by the video processing function includes: determining whether there is a demand for streaming; if there is no demand for streaming, delivering the video frames to an open graphics library or screen hardware for display; If there is a demand for streaming, the video frames are delivered to the open graphics library or screen hardware for display. At the same time, the video frames are read and transmitted to the associated streaming media server, so that the streaming media server can push the video.
在一实施方式中,图层合成器获取到的第三视频数据,将会直接利用显存资源进行处理。由于图层合成器已经完成了前文注册函数方法步骤,因此图像合成器中即包含有被封装的视频处理函数。视频应用处理视频数据本就需要调用图层合成器进行处理,在此情况下即可以调用图层合成器中的视频处理函数。使得图层合成器实际处理视频数据的过程中可以根据视频处理函数的要求进行处理,从而实现用户所设定的视频效果,包括但不限于美颜、滤镜、降噪等效果。处理好的视频数据将会以视频帧的方式进行输出。In one implementation, the third video data obtained by the layer compositor will be directly processed using video memory resources. Since the layer compositor has completed the previous registration function method steps, the image compositor already contains the encapsulated video processing function. When a video application processes video data, it needs to call the layer compositor for processing. In this case, the video processing function in the layer compositor can be called. This allows the layer compositor to actually process video data according to the requirements of the video processing function, thereby achieving the video effects set by the user, including but not limited to beautification, filters, noise reduction and other effects. The processed video data will be output in the form of video frames.
对于输出过程,可以是图层合成器将处理完成的视频帧投递给开放图形库或屏幕硬件进行显示。输出过程中,还可以确定视频应用是否收到有推流需求。如果有推流需求,则在将视频帧投递给开放图形库或屏幕硬件进行显示的同时,还控制将视频帧发送给关联的流媒体服务器实现推流。如果没有,则仅将视频帧投递至开放图形库或屏幕硬件进行显示。通过输出,用户即可以在视频设备上,实时看到经过处理后的视频帧,例如经过美颜或蒙上滤镜的视频。经过对于图层合成器的函数注册,以及利用注册了函数的图层合成器处理视频数据,使得视频帧在内存和显存之间转换多次,可以在同样的硬件配置下支持更高的帧率,提高性能和用户体验。For the output process, the layer compositor can deliver the processed video frames to the open graphics library or screen hardware for display. During the output process, you can also determine whether the video application receives a push request. If there is a demand for streaming, while delivering the video frames to the open graphics library or screen hardware for display, it also controls sending the video frames to the associated streaming media server for streaming. If not, the video frames are simply delivered to the Open Graphics Library or screen hardware for display. Through output, users can see the processed video frames in real time on the video device, such as videos that have been beautified or filtered. After registering the function of the layer compositor, and using the layer compositor with the registered function to process the video data, the video frame can be converted between memory and video memory multiple times, and a higher frame rate can be supported under the same hardware configuration. , improve performance and user experience.
因此,本申请能够在图层合成器中注册用户提供的注册函数。注册好的注册函数将会以视频处理函数的形式向外暴露接口,以便于随时调用。使得在图像处理过程中,可以直接调用图象合成器内的视频处理函数,利用显存资源进行视频处理,视频数据无需在内存和显存之间多次转换。相比现有技术,本申请可以在同样的硬件配置下支持更高的帧率输出,并保证更佳的视频输出效果,提高性能和用户体验。Therefore, this application is able to register user-provided registration functions in the layer compositor. The registered function will expose the interface in the form of a video processing function so that it can be called at any time. During the image processing process, the video processing function in the image synthesizer can be directly called, and the video memory resources are used for video processing. The video data does not need to be converted multiple times between the memory and the video memory. Compared with the existing technology, this application can support higher frame rate output under the same hardware configuration, ensure better video output effects, and improve performance and user experience.
图3示出了一个实施例提供的一种注册函数装置的内部功能模块连接关系示意图。注册函数装置30,包括有:初始化模块31、注册模块32和封装模块33。初始化模块31,用于执行初始化操作,初始化操作的对象包括开放图形库、显存和纹理句柄中的至少一项。注册模块32,用于获取用户提供的注册函数,解析注册函数以得到第一着色器;对第一着色器执行注册操作,注册操作包括编译着色器代码并绑定在图层合成器中。封装模块33,用于将完成注册操作的第一着色器封装为视频处理函数,并向外暴露接口,以使视频应用通过接口直接调用视频处理函数。Figure 3 shows a schematic diagram of the internal functional module connection relationship of a registration function device provided by an embodiment. The registration function device 30 includes: an initialization module 31 , a registration module 32 and an encapsulation module 33 . The initialization module 31 is configured to perform an initialization operation. The objects of the initialization operation include at least one of an open graphics library, a video memory, and a texture handle. The registration module 32 is used to obtain the registration function provided by the user, parse the registration function to obtain the first shader, and perform a registration operation on the first shader. The registration operation includes compiling the shader code and binding it in the layer compositor. The encapsulation module 33 is used to encapsulate the first shader that has completed the registration operation into a video processing function, and expose the interface to the outside, so that the video application can directly call the video processing function through the interface.
图4示出了一个实施例提供的一种视频帧处理装置的内部功能模块连接关系示意图。视频帧处理装置40,包括有:获取模块41、发送模块42、处理模块43和输出模块44。获取模块41,用于从第一图层处获取第一视频数据,第一图层为相机模块的图层。发送模块42,用于将第一视频数据发送至图层合成器,图层合成器经过前文所描述的方法完成了注册。处理模块43,用于调用图层合成器中的视频处理函数,利用显存资源处理第一视频数据;视频处理函数为前文所描述的视频处理函数。输出模块44,用于读取并输出经过视频处理函数处理后的视频帧。Figure 4 shows a schematic diagram of the connection relationship between internal functional modules of a video frame processing device provided by an embodiment. The video frame processing device 40 includes: an acquisition module 41, a sending module 42, a processing module 43 and an output module 44. The acquisition module 41 is used to acquire the first video data from the first layer, where the first layer is the layer of the camera module. The sending module 42 is used to send the first video data to the layer synthesizer, and the layer synthesizer completes the registration through the method described above. The processing module 43 is used to call the video processing function in the layer synthesizer and use the video memory resources to process the first video data; the video processing function is the video processing function described above. The output module 44 is used to read and output video frames processed by the video processing function.
图5示出了一个实施例中计算机设备的内部结构图。该计算机设备具体可以是终端,也可以是服务器。如图5所示,该计算机设备包括通过系统总线连接的处理器、存储器和网络接口。其中,存储器包括非易失性存储介质和内存储器。该计算机设备的非易失性存储介质存储有操作系统,还可存储有计算机程序,该计算机程序被处理器执行时,可使得处理器实现前文所描述的方法。该内存储器中也可储存有计算机程序,该计算机程序被处理器执行时,可使得处理器执行前文所描述的方法。本领域技术人员可以理解,图5中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Figure 5 shows an internal structure diagram of a computer device in one embodiment. Specifically, the computer device may be a terminal or a server. As shown in Figure 5, the computer device includes a processor, a memory and a network interface connected through a system bus. Among them, memory includes non-volatile storage media and internal memory. The non-volatile storage medium of the computer device stores an operating system and may also store a computer program. When the computer program is executed by the processor, it can cause the processor to implement the method described above. A computer program may also be stored in the internal memory. When the computer program is executed by the processor, it may cause the processor to perform the method described above. Those skilled in the art can understand that the structure shown in Figure 5 is only a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer equipment to which the solution of the present application is applied. The specific computer equipment can May include more or fewer parts than shown, or combine certain parts, or have a different arrangement of parts.
在一个实施例中,本申请还提出了一种计算机可读存储介质,存储有计算机程序,计算机程序被处理器执行时,使得处理器执行如前述方法的步骤,In one embodiment, this application also proposes a computer-readable storage medium that stores a computer program. When the computer program is executed by a processor, it causes the processor to perform the steps of the aforementioned method,
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一非易失性计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented by instructing relevant hardware through computer programs. The programs can be stored in a non-volatile computer-readable storage medium. , when the program is executed, it may include the processes of the above-mentioned method embodiments. Any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Synchlink DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined in any way. To simplify the description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, all possible combinations should be used. It is considered to be within the scope of this manual.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对本申请专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-described embodiments only express several implementation modes of the present application, and their descriptions are relatively specific and detailed, but should not be construed as limiting the patent scope of the present application. It should be noted that, for those of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all fall within the protection scope of the present application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311228920.4A CN117372238A (en) | 2023-09-21 | 2023-09-21 | Registration function method, video frame processing method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311228920.4A CN117372238A (en) | 2023-09-21 | 2023-09-21 | Registration function method, video frame processing method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117372238A true CN117372238A (en) | 2024-01-09 |
Family
ID=89399271
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311228920.4A Pending CN117372238A (en) | 2023-09-21 | 2023-09-21 | Registration function method, video frame processing method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117372238A (en) |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030179220A1 (en) * | 2002-03-20 | 2003-09-25 | Nvidia Corporation | System, method and computer program product for generating a shader program |
CN101223518A (en) * | 2005-07-12 | 2008-07-16 | 微软公司 | Magnification engine and interface for computers |
US8490034B1 (en) * | 2010-07-08 | 2013-07-16 | Gauda, Inc. | Techniques of optical proximity correction using GPU |
CN108765534A (en) * | 2018-05-24 | 2018-11-06 | 武汉斗鱼网络科技有限公司 | A kind of image rendering method, device, equipment and storage medium |
CN110290425A (en) * | 2019-07-29 | 2019-09-27 | 腾讯科技(深圳)有限公司 | A kind of method for processing video frequency, device and storage medium |
WO2021253141A1 (en) * | 2020-06-15 | 2021-12-23 | 华为技术有限公司 | Image data processing apparatus and method |
CN115878209A (en) * | 2021-09-29 | 2023-03-31 | 华为技术有限公司 | Method and device for loading shader |
-
2023
- 2023-09-21 CN CN202311228920.4A patent/CN117372238A/en active Pending
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030179220A1 (en) * | 2002-03-20 | 2003-09-25 | Nvidia Corporation | System, method and computer program product for generating a shader program |
CN101223518A (en) * | 2005-07-12 | 2008-07-16 | 微软公司 | Magnification engine and interface for computers |
US8490034B1 (en) * | 2010-07-08 | 2013-07-16 | Gauda, Inc. | Techniques of optical proximity correction using GPU |
CN108765534A (en) * | 2018-05-24 | 2018-11-06 | 武汉斗鱼网络科技有限公司 | A kind of image rendering method, device, equipment and storage medium |
CN110290425A (en) * | 2019-07-29 | 2019-09-27 | 腾讯科技(深圳)有限公司 | A kind of method for processing video frequency, device and storage medium |
WO2021253141A1 (en) * | 2020-06-15 | 2021-12-23 | 华为技术有限公司 | Image data processing apparatus and method |
CN115878209A (en) * | 2021-09-29 | 2023-03-31 | 华为技术有限公司 | Method and device for loading shader |
Non-Patent Citations (1)
Title |
---|
陈月华等: "实时渲染应用程序中着色器的管理和控制", 哈尔滨工业大学学报, no. 03, 15 March 2009 (2009-03-15) * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2021218327A1 (en) | Page processing method and related device | |
CN109194960B (en) | Image frame rendering method and device and electronic equipment | |
CN111163345A (en) | Image rendering method and device | |
CN110750664A (en) | Picture display method and device | |
CN114390307A (en) | Image quality enhancement method, device, terminal and readable storage medium | |
CN114998087A (en) | Rendering method and device | |
CN108921784B (en) | Picture compression method and system based on mobile terminal | |
CN118096492A (en) | Image processing method, device, electronic equipment and computer readable storage medium | |
CN112214250A (en) | Application program assembly loading method and device | |
CN117372238A (en) | Registration function method, video frame processing method, device, equipment and storage medium | |
US11706463B2 (en) | Video synthesis method, apparatus, computer device and readable storage medium | |
CN110515834B (en) | Interface testing method, device, mobile terminal and storage medium | |
CN112541391A (en) | Violation behavior identification method and system based on examination video analysis | |
CN111199569A (en) | Data processing method and device, electronic equipment and computer readable medium | |
CN114647411B (en) | Programming interface loading method, device, electronic device and storage medium | |
CN116962813A (en) | A YUV data rendering system and method, electronic device and storage medium | |
CN113900825A (en) | App time-consuming task optimization method and device based on artificial intelligence and related equipment | |
CN115908097A (en) | Image rendering method and device, electronic equipment and storage medium | |
CN114328422A (en) | Canvas-based image compression method, device and computer equipment | |
CN114217758A (en) | Image display method, image display device, electronic equipment and computer readable storage medium | |
CN113220249B (en) | Image display method, device and storage medium | |
CN119255047B (en) | Video stream data processing method, device, computer equipment, storage medium and program product | |
CN112631782A (en) | Method for rapidly loading remote sensing image on Android system | |
CN114003308A (en) | Project text resource loading method and device, electronic equipment and storage medium | |
CN110221873B (en) | Method for improving full-screen animation loading performance based on programming language and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |