Image processing method, device, equipment, medium and program product
By setting image rendering properties and generating shader programs, multiple editing steps are integrated into one rendering process, which solves the problem of high real-time rendering complexity in image editing tools and improves rendering efficiency and device-side creation experience.
Patent Information
- Application Number
- CN202410988369.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-07-23
AI Technical Summary
Existing image editing tools require a large amount of real-time rendering and synthesis work during the image or video editing process, resulting in high system resource consumption and increased device power consumption. How to reduce the complexity of real-time rendering has become an important issue in improving the device-side image or video creation experience.
By setting the rendering attributes of the image, parsing and processing to generate shader specification description information, building and running the shader program, and integrating multiple editing steps into one rendering process, it reduces the complexity of real-time rendering and improves rendering efficiency.
It realizes the integration of multiple editing steps in one rendering process, reduces the consumption of device resources by real-time rendering, and improves rendering efficiency and image or video creation experience.
Smart Images

Figure CN118521695B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, in particular to the field of audio and video, and specifically to an image processing method, device, equipment, medium and program product. Background Art
[0002] With the rapid development of Internet technology, more and more users consume images or videos (such as short videos), and the generation of images or videos is also growing rapidly. At the same time, various image editing tools have emerged to help users produce images or videos; among them, the production process of images or videos requires real-time rendering. For example, the production process contains a large number of "edit → preview → re-edit → re-preview" loop operations to help users preview the rendering effects corresponding to the editing steps in real time during the editing process.
[0003] Currently, image editing tools provide a step-by-step rendering method (or step-by-step drawing method), that is, multiple editing steps are performed in sequence as needed, and each editing step performs real-time rendering of a rendering effect. Each editing step uses the output of the previous editing step as input to perform image rendering. This step-by-step drawing method needs to ensure the sequential rendering of the rendering effects corresponding to each editing step, and requires that the intermediate results be rendered off-screen when rendering the effects in each editing step; this results in a large amount of real-time rendering and synthesis work during the editing process, which greatly consumes system resources and increases device power consumption.
[0004] Therefore, how to reduce the complexity of real-time rendering during image or video editing becomes an important issue in improving the image or video creation experience on the device side. Summary of the invention
[0005] The embodiments of the present application provide an image processing method, apparatus, device, medium and program product, which can integrate multiple editing steps into a rendering process, thereby improving rendering efficiency and reducing the complexity of real-time rendering.
[0006] On the one hand, an embodiment of the present application provides an image processing method, the method comprising:
[0007] In response to the attribute setting operation for the image, the rendering attribute of the image is set; the image includes N image characteristics, and the rendering attribute includes attributes under each image characteristic; N is a positive integer;
[0008] Analyze the rendering attributes of the image to generate shader specification description information; the shader specification description information is used to describe the specification information of the shader program used in the rendering process of the image;
[0009] Constructing a shader program according to the specification information described by the shader specification description information;
[0010] Run the shader program to render the image.
[0011] On the other hand, an embodiment of the present application provides an image processing device, the device comprising:
[0012] A setting unit, configured to set a rendering attribute of the image in response to an attribute setting operation for the image; the image includes N image characteristics, and the rendering attribute includes an attribute under each image characteristic; N is a positive integer;
[0013] The processing unit is used to parse and process the rendering attributes of the image and generate shader specification description information; the shader specification description information is used to describe the specification information of the shader program used in the rendering process of the image;
[0014] The processing unit is further used to construct a shader program according to the specification information described by the shader specification description information;
[0015] The processing unit is also used to run shader programs to render images.
[0016] In one implementation, the N image characteristics include: a color adjustment characteristic, a filter type characteristic, and a blending mode characteristic;
[0017] Among them, one image characteristic corresponds to one image rendering effect; each image characteristic includes at least one rendering attribute related to the corresponding image rendering effect, and the at least one rendering attribute is used to render the image to obtain the corresponding image rendering effect.
[0018] In one implementation, the processing unit is used to parse the rendering attributes of the image and generate the shader specification description information, specifically to:
[0019] Performing attribute parsing processing on the rendering attributes under each image characteristic to obtain the attribute parsing result corresponding to each image characteristic; any attribute parsing result is used to indicate the image rendering effect requirement under the corresponding image characteristic;
[0020] Based on the characteristic analysis results corresponding to each image characteristic, shader specification description information is generated. The specification information described by the shader specification description information is used to indicate the image rendering effect requirements under each image characteristic.
[0021] In one implementation, the image characteristic is a color adjustment characteristic, and the color adjustment characteristic includes M1 rendering attributes; the processing unit is used to perform attribute parsing processing on the rendering attributes under each image characteristic, and when obtaining the attribute parsing result corresponding to each image characteristic, it is specifically used to:
[0022] Check whether any of the M1 rendering attributes has a value other than the default value.
[0023] If the attribute value of at least one rendering attribute among the M1 rendering attributes is not the attribute default value, then the characteristic parsing result of the color adjustment characteristic is set to the first color characteristic result;
[0024] If the attribute value of each rendering attribute in the M1 rendering attributes is the attribute default value, then the characteristic parsing result of the color adjustment characteristic is set to be the second color characteristic result.
[0025] In one implementation, the image characteristic is a filter type characteristic, and the filter type characteristic includes a filter identification attribute and a filter strength attribute; the processing unit is used to perform attribute parsing processing on the rendering attribute under each image characteristic, and when obtaining the attribute parsing result corresponding to each image characteristic, it is specifically used to:
[0026] Check whether the attribute value of the filter identification attribute is empty and whether the attribute value of the filter strength attribute is zero;
[0027] If the attribute value of the filter identification attribute is not empty, and the attribute value of the filter strength attribute is not zero, then the characteristic parsing result of the filter type characteristic is set to the first filter characteristic result;
[0028] If the attribute value of the filter identification attribute is empty, or the attribute value of the filter strength attribute is zero, the characteristic parsing result of the filter type characteristic is set to the second filter characteristic result.
[0029] In one implementation, the image characteristic is a mixed mode characteristic, and the processing unit is used to perform attribute parsing processing on the rendering attribute under each image characteristic, and when obtaining the attribute parsing result corresponding to each image characteristic, specifically to:
[0030] The attribute value of the rendering attribute included in the blending mode attribute is taken as the attribute resolution result of the blending mode attribute.
[0031] In one implementation, an image corresponds to a scene tree, the scene tree is a tree structure composed of elements in the image, one element in the image corresponds to a rendering node in the scene tree; one rendering node corresponds to at least one image feature; and a processing unit is used to generate shader specification description information based on a feature parsing result corresponding to each image feature, specifically for:
[0032] According to the node type of the rendering node corresponding to N kinds of image characteristics in the scene tree, a target code template identifier is selected for the N kinds of image characteristics from the code template library; the target code template identifier is used to identify a target shader code template, and the target shader code template is a code framework that can achieve image rendering effects corresponding to the N kinds of image characteristics; the code module library includes one or more code template identifiers pre-configured from the node type dimension, and a shader code template identified by each code module identifier;
[0033] The target code template identifier and the feature parsing results for each image feature are added to the shader specification description information.
[0034] In one implementation, the shader specification description information includes a target code template identifier; and the processing unit is used to construct a shader program according to the specification information described in the shader specification description information, specifically to:
[0035] Get the target shader code template identified by the target code template identifier;
[0036] Based on the feature analysis results of each image feature, obtain the feature code corresponding to each feature analysis result;
[0037] Build a shader program based on the target shader code template and the feature code corresponding to each feature parsing result.
[0038] In one implementation, the processing unit is used to construct a shader program according to the target shader code template and the feature code corresponding to each feature parsing result, specifically to:
[0039] Assemble the target shader code template and the feature code corresponding to each feature parsing result to obtain the shader code;
[0040] Optimize the shader code to obtain optimized reference shader code;
[0041] Compile the reference shader code to obtain a shader program.
[0042] In one implementation, the target shader code template includes a target vertex shader code template and a target fragment shader code template; the shader code includes a vertex shader code and a fragment shader code; the processing unit is used to assemble the target shader code template and the feature code corresponding to each feature parsing result to obtain the shader code, specifically for:
[0043] From the target shader code template, read the target vertex shader code template and the target fragment shader code template respectively; and,
[0044] Obtain candidate vertex shader code templates and candidate fragment shader code templates corresponding to the feature parsing results for each image feature;
[0045] Merging the target vertex shader code template and the N candidate vertex shader code templates to generate vertex shader code; and,
[0046] The target fragment shader code template and the N candidate fragment shader code templates are merged to generate a fragment shader code.
[0047] On the other hand, an embodiment of the present application provides a computer device, the computer device comprising:
[0048] A processor for loading and executing computer programs;
[0049] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image processing method is implemented.
[0050] On the other hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program is suitable for being loaded by a processor and executing the above-mentioned image processing method.
[0051] On the other hand, an embodiment of the present application provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the above-mentioned image processing method is implemented.
[0052] In an embodiment of the present application, in response to a user's attribute setting operation on an image, the rendering attributes of the image are set, and the rendering attributes include attributes under each image characteristic, and the image includes N kinds of image characteristics; one image characteristic corresponds to one image rendering effect, such as color rendering, filter rendering, or mode rendering, etc. In other words, the rendering attributes under different image characteristics can be set in batches according to multiple editing operations of the user on the image (such as one editing operation is used to set the rendering attributes under one image characteristic of the image). In this way, the rendering attributes of the image are parsed and processed in batches to generate a shader specification description; the shader specification description information is used to describe the specification information of the shader program used in the rendering process of the image, and the shader specification description information integrates the specification information of the shader program that can achieve N kinds of image rendering effects corresponding to N kinds of image characteristics. Thereby, it is ensured that the shader program constructed based on the specification information described in the shader specification description information is an overall program that integrates N combinations of image rendering effects; not only is it possible to dynamically generate a shader program based on multiple editing operations of the user, but the shader program also integrates multiple image characteristics, so that when rendering an image based on the shader program, the editing steps corresponding to multiple image characteristics can be merged into one image rendering process, that is, image rendering effects corresponding to multiple image characteristics are added in one image rendering process. Compared with the step-by-step rendering of N image characteristics, the consumption of device resources / system resources for real-time image rendering is greatly reduced, the complexity of real-time image rendering is reduced, and the rendering efficiency is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0054] Figure 1a is a schematic diagram of the architecture of an image processing system provided by an exemplary embodiment of the present application;
[0055] Figure 1b is a schematic diagram of the architecture of another image processing system provided by an exemplary embodiment of the present application;
[0056] Figure 2a It is a flowchart of an existing image rendering solution;
[0057] Figure 2b is a schematic diagram of dynamic generation of a shader program provided by an exemplary embodiment of the present application;
[0058] Figure 3 is a flowchart of an image processing method provided by an exemplary embodiment of the present application;
[0059] Figure 4 It is a schematic diagram of a user performing rendering attribute setting provided by an exemplary embodiment of the present application;
[0060] Figure 5 It is a schematic diagram of a process for generating shader specification description information provided by an exemplary embodiment of the present application;
[0061] Figure 6 is a flowchart of constructing a shader program provided by an exemplary embodiment of the present application;
[0062] Figure 7 is a flowchart of another image processing method provided by an exemplary embodiment of the present application;
[0063] Figure 8 It is a schematic diagram of a flow chart of generating shader code based on shader specification description provided by an exemplary embodiment of the present application;
[0064] Fig. 9 is a structural schematic diagram of an image processing device provided by an exemplary embodiment of the present application;
[0065] Fig.10 It is a structural diagram of a computer device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0066] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0067] The embodiments of the present application relate to computer graphics (CG). Computer graphics is a science that uses mathematical algorithms to convert two-dimensional or three-dimensional images into a grid form on a computer display; specifically, it studies how to represent images in a computer, and the relevant principles and algorithms for using computers to calculate, process and display images. An important tool involved in computer graphics is rendering technology; rendering refers to the process of converting an abstract model in a computer into an intuitively visible image; rendering, as the last tool in computer graphics, can convert the model into an image and finally present it on a computer screen. Among them, the above-mentioned model may refer to a three-dimensional object or virtual scene that is strictly defined by language or data structure, and may include but is not limited to: geometry (such as object shape, etc.), viewpoint (i.e., the optical center of the camera in the image), texture (such as uneven grooves or patterns on the physical surface, etc.) and lighting (such as achieving shadow effects in the image through light, etc.) and other information.
[0068] With the continuous in-depth development of computer graphics, the application of rendering technology is becoming more and more extensive. For example, when running an image editing tool in a mobile device, the user performs editing steps or editing operations on the image or video through the image editing tool running in the mobile device, and the image effect brought about by the editing steps of the image or video needs to be rendered in real time on the display screen of the mobile device, so that the user can perform subsequent editing based on the rendered image. The embodiment of the present application does not limit the content edited by the user in the image editing tool to images or videos; for example, the image can be a frame of video in a video, and the user makes a video by performing image processing on each frame of video in the video; for another example, the image may not belong to the video, but is a separate image. For the sake of ease of explanation, the embodiment of the present application takes the content edited by the image editing tool as an example to introduce, and the image processing process performed on each frame of video in the video is the same as the image processing process for the image.
[0069] Furthermore, image editing tools mainly rely on rendering engines to achieve real-time rendering during image editing. Among them, the rendering engine is a software component responsible for converting 3D (three-dimensional) scenes, models, textures and other data into 2D (two-dimensional) images; it is a very important part in applications such as game engines, virtual reality systems, and graphics editing software, and can be responsible for executing a series of complex graphics algorithms, such as lighting calculations, texture mapping, shadow rendering, etc., to produce high-quality image visual effects. The rendering engine involved in the embodiments of the present application can be a self-developed audio and video rendering processing engine, which can realize image or video rendering processing in special effects video shooting, editing, graphic content creation and other businesses.
[0070] Furthermore, the rendering engine usually relies on the graphics interface (Application Programming Interface, API) to realize its image rendering function; the image interface may include but is not limited to: a cross-platform graphics programming interface (Open Graphics Library, OpenGL), a cross-platform open computing language (Open Computing Language, OpenCL) and a drawing protocol (Web Graphics Library, WebGL), etc. The embodiment of the present application takes the rendering engine using the graphics interface OpenGL for image rendering as an example. The OpenGL is a cross-platform, cross-language graphics programming interface for rendering 2D and 3D vector graphics; it provides a series of functions, data types and protocols, allowing developers to directly control graphics hardware (such as graphics processors (Graphics Processing Unit, GPU)) to perform graphics rendering tasks. The rendering engine uses the functions and data types provided by OpenGL to create and manage graphics resources (such as textures, vertex buffers, etc.), and performs graphics rendering operations through the rendering pipeline of OpenGL. In this way, OpenGL provides a unified, cross-platform graphics programming interface for the rendering engine, so that the rendering engine can run on different operating systems and hardware platforms, realizing the cross-platform operation of the rendering engine.
[0071] In practical applications, image editing tools rely on rendering engines, OpenGL, the hardware central processing unit (CPU) and GPU deployed in mobile devices to render and display images (or pages, pictures (such as game pictures, video frames, etc.). In detail, the rendering engine performs image rendering by calling the interface function of OpenGL. OpenGL converts the data and instructions of the rendering engine into hardware instructions that the GPU can understand, and sends the hardware instructions to the GPU. At the same time, the CPU is responsible for processing the logic and computing tasks related to graphics rendering during the image rendering process, and passes the data to be rendered to the GPU. In this way, the GPU uses its powerful graphics processing capabilities to process the graphics data and instructions from the CPU and OpenGL, and renders the final image. It can be seen that the interaction between the rendering engine, OpenGL, CPU and GPU ensures the smooth progress of the graphics rendering process and can achieve high-quality image rendering effects.
[0072] It is worth noting that the concept of Draw Call (called draw call or rendering command) is involved in the process of interactive graphics rendering between the rendering engine, OpenGL, CPU and GPU. Draw Call refers to a command issued by the CPU to the GPU during the graphics processing process (or image rendering process); specifically, the CPU can call a graphics programming interface (such as OpenGL) to issue a command to the GPU, so that the GPU responds to the command to draw / render a set of primitives (the primitive is the smallest drawing unit in the image, such as a line, polygon, etc.). In short, Draw Call is a command from the CPU to the GPU during the image rendering process, which points to a list of primitives that need to be rendered; when the CPU needs to render some primitives, it adds a Draw Call command to the command buffer, and after completing the last rendering task, the GPU takes out the Draw Call command from the command buffer and executes primitive drawing / rendering.
[0073] In practical applications, the rendering engine is responsible for the generation of the screen during video or image editing / shooting. All elements in the screen (such as the original video frame, text, stickers and special effects superimposed on the video frame) will correspond to a rendering node (that is, one element in the image corresponds to a rendering node), and all rendering nodes form a scene tree, that is, the scene tree is a tree structure composed of all elements in the image. The scene tree can also be understood as a hierarchical structure tree used to represent each layer and element in the video frame or image rendering. In other words, the image or video frame corresponds to a scene tree. When the image or video frame needs to be generated, the corresponding scene tree will be traversed to perform specific drawing operations on each visible rendering node in the scene tree; the drawing operation here is implemented through the aforementioned Draw Call in OpenGL. When a Draw Call occurs, its behavior is determined by the parameters of the Draw Call and the state of the OpenGL context (that is, the OpenGL state and the collection of all the resources it needs) at that time; an important part of the OpenGL context state is the shader program (ShaderProgram) used. A shader is a small program used to perform customized rendering operations in graphics processing (i.e., image rendering processing), which can include a vertex shader and a fragment shader. The vertex shader is mainly responsible for processing shader programs for vertex-level operations such as vertex coordinates and lighting in the image. The fragment shader is mainly responsible for processing shader programs for pixel-level operations such as the color and texture of the primitive pixels in the image. At present, vertex shaders and fragment shaders are pre-written programs, and when the GPU needs to render primitives, it can use the corresponding shader program to process the primitives; that is, vertex shaders and fragment shaders are the basic processing units in the image rendering process, and are fixed as the shaders used for each Draw Call in the image rendering process.
[0074] For example, in an image editing tool, multiple editing operations (i.e., editing steps) may often be performed on a video frame or image. Multiple editing steps will be executed according to the user's execution requirements and execution order, and each editing step uses a vertex shader and / or a fragment shader to render an image rendering effect. Among them, the editing steps may include but are not limited to: color space conversion (the process of converting the color representation of an image or video frame from one color space to another color space), color adjustment, look-up table (LUT) filter overlay (or filter type characteristics), dark corner addition, application of drawing masks, and specific blending mode characteristics, etc.; an editing step may correspond to one or more actions performed by the user (such as color adjustment may correspond to brightness adjustment actions and transparency adjustment actions performed by the user). Considering that each editing step represents a feature of the image (such as color space features, filter features, etc.), in the embodiment of the present application, an editing step corresponds to an image feature; a rendering node in the aforementioned scene tree corresponds to at least one image feature, that is, a rendering node supports or can implement at least one image feature. An image feature may include at least one rendering attribute to achieve the image rendering effect after rendering the corresponding image feature through the at least one rendering attribute.
[0075] It has been found in practice that too many Draw Calls during the image rendering process will seriously consume the CPU's computing resources and increase the power consumption of mobile devices. For example, when making videos in image editing tools, users have high demands for real-time rendering (i.e., rendering video frames or images instantly according to the user's editing steps or editing operations, so as to instantly preview the effects applied to the image or video frames during the image or video production process) (e.g., the user continues to edit the image based on the image rendering effect after the last edit); this causes the image rendering process to include a large number of "edit → preview → edit again → preview again → ..." loop operations, and each editing step will trigger the CPU to respond to the edit and send a DrawCall to the GPU to render the primitive list for this editing step. However, before issuing a Draw Call command each time, the CPU needs to send a series of contents to the GPU memory and check the rendering status. Therefore, issuing Draw Calls multiple times will cause the CPU to spend a lot of time preparing the Draw Call command, which may cause it to be overloaded. In addition, after the GPU responds to the Draw Call command each time, it needs to render the intermediate results obtained by performing rendering for the user's editing steps off-screen to the OpenGLTexture (a structure used to store and process image data in OpenGL) to use the intermediate results as the rendering input for the next editing step. The off-screen rendering process requires the creation of a new buffer and the context switching of rendering, which makes the off-screen rendering very performance-consuming. Based on this, when the CPU issues a Draw Call to the GPU, the energy consumption is large. Since the image rendering process includes a large number of editing steps that require real-time rendering, this further increases the consumption of system resources and power consumption of the mobile device. Therefore, it is particularly important to reduce the number of Draw Calls during the image rendering process to save system resources and power consumption.
[0076] In order to reduce the number of Draw Calls issued by the CPU during image rendering, save the resource system and power consumption of mobile devices, and improve rendering efficiency. The embodiment of the present application supports an image processing solution from the dimension of shader programs, which proposes a set of shader program generation logic, aiming to dynamically generate a shader program corresponding to a combination of effects of multiple image rendering effects according to the user-defined editing logic (specifically, the parameters or rendering properties edited by the editing logic), so that the GPU can execute the shader program in one Draw Call to achieve the function of superimposed rendering of multiple image rendering effects.
[0077] The general content of the image processing scheme may include: when the user customizes the editing logic for the image, that is, the user performs the image attribute setting operation on the image by himself, the computer device can set the rendering attributes of the image in response to the user's attribute setting operation on the image; assuming that the image includes N kinds of image characteristics (that is, the rendering node that needs to be drawn in this Draw Call can support N kinds of image characteristics), then the set rendering attributes include the attributes under each image characteristic. Then, when the image is rendered, the shader specification description information of the shader program to be generated is determined according to the attribute value of the rendering attribute set for the rendering node corresponding to the element in the image; specifically, the attribute value of the rendering attribute of the set image is parsed to generate the shader specification description information, and the shader specification description information is used to describe the specification information of the shader program used in the rendering process of the image. In this way, the shader program can be constructed according to the specification information described by the shader specification description information; when the GPU runs the shader program, the overlay rendering processing of N kinds of image rendering effects corresponding to N kinds of image characteristics is realized.
[0078] It can be seen that, on the one hand, the embodiment of the present application can dynamically generate a shader program according to the user's attribute setting operation, which improves the flexibility of generating the shader program compared to the traditional fixed shader program and meets the needs of user-defined image editing. On the other hand, the shader program corresponds to the rendering logic of multiple image rendering effects, that is, the image rendering results that originally require multiple steps of rendering are compressed into one Draw Call, so that the shader program is used in one Draw Call to achieve combined rendering of batch effects, which not only improves the image rendering efficiency, but also reduces the hardware load by reducing the number of Draw Calls, reduces the utilization rate and power consumption of system resources, and also reduces the real-time rendering complexity in the image rendering process.
[0079] The image processing solution provided by the embodiment of the present application can be applied to any application scenario that requires image rendering. For example, in a real-time image editing scenario (or video editing scenario), when a user edits an image or video frame, he often has the need to perform real-time editing and real-time preview for a variety of image characteristics; at this time, the image processing solution provided by the embodiment of the present application is applied, and the user's rendering process for a variety of image characteristics can be compressed into one rendering (i.e., one Draw Call), which can reduce the computational complexity of real-time rendering and improve the efficiency of real-time rendering. For another example, in a game screen rendering scenario, the game application needs to render the next frame of the game screen triggered by the game operation according to the user's game operation; at this time, the image processing solution provided by the embodiment of the present application is applied, which can reduce the computational complexity of real-time rendering and improve the smoothness of game screen switching to a certain extent.
[0080] The image processing scheme provided in the embodiment of the present application is integrated in the image rendering tool, specifically in the rendering engine of the image rendering tool to realize the image rendering function; according to different application scenarios, the rendering engine can realize the rendering processing of images or videos in different application scenarios. According to the different integration positions of the rendering engine, the computer devices that execute the image processing scheme provided in the embodiment of the present application are different; for example, the rendering engine is integrated in the mobile device, and the computer device that executes the image processing scheme is the mobile device at this time, and the image rendering can be directly realized on the mobile device side. For another example, the rendering engine is integrated on the server side, and the server is a back-end device corresponding to the mobile device, providing technical support services for the mobile device. At this time, the computer device that executes the image processing scheme is the server, and the server calls the rendering engine to realize image rendering, and then sends the rendered image to the mobile device for display. Among them, the mobile device may include but is not limited to: smart phones (such as Android phones, iOS phones, etc.), tablet computers, personal computers, portable personal computers, mobile Internet devices (Mobile Internet Devices, MID), smart TVs, vehicle-mounted devices, tablet computers and head-mounted devices and other portable electronic devices. The image editing tool running in the mobile device may be a tool with audio and video editing capabilities, which may include but is not limited to: a client that needs to be installed in the mobile device to run; a small program that does not require installation, which can be run in the client and can be used without downloading and installing; the World Wide Web (web) opened by the browser in the mobile device; and a plug-in with audio and video editing capabilities in the client; etc. The embodiments of the present application do not limit the type of mobile device, and the type and operation mode of the image editing tool running in the mobile device.
[0081] The following is an exemplary introduction to the image processing system when the rendering engine is integrated into a mobile device or a server in conjunction with the accompanying drawings, wherein:
[0082] 1) The rendering engine is integrated into the mobile device. In this implementation, after the mobile device receives the user's customized attribute setting operation for the image, it can directly call the rendering engine to implement image rendering processing and display the rendered image. Figure 1aAs shown, the image processing system includes a mobile device 101 held by a user, and the user can open and use the image editing tool in the mobile device 101 to perform custom editing of the image (or video frame), such as setting the brightness attribute and the filter attribute, etc.; the rendering engine in the mobile device 101 responds to the user's attribute setting operation on the image, and sets the rendering attribute of the image, such as setting the attribute value of the brightness attribute to the brightness value set by the user, and setting the attribute value of the filter attribute to the filter identification attribute value and the filter strength attribute value. Then, the rendering engine in the mobile device 101 also parses and contacts the set rendering attributes, generates shader specification description information, and generates a shader program corresponding to a combination of multiple effects (such as a shader program corresponding to a combination of brightness effect and filter effect) according to the shader specification description information. In this way, when the CPU sends a Draw Call to the GPU, the GPU can perform a combination rendering of multiple image rendering effects based on the shader program, thereby realizing the compression of multiple attribute setting actions performed by the user into one Draw Call, and achieving the function of adding multiple effects in one rendering.
[0083] 2) The rendering engine is integrated into the server. In this implementation, image rendering is achieved through cloud computing. Cloud computing is a computing model that distributes computing tasks across a resource pool consisting of a large number of computers, allowing various application systems to obtain computing power, storage space, and information services as needed; the network that provides resources is called a "cloud", and the resources in the "cloud" are infinitely expandable from the user's perspective, and can be obtained at any time, used on demand, expanded at any time, and paid for by use. For example, a system architecture diagram of a rendering engine integrated into a server can be seen in Figure 1b ;like Figure 1b As shown, the image processing system includes a mobile device 101 held by a user and a server 102, wherein the server 102 is a backend server corresponding to the mobile device 101 and interacting with the mobile device 101 to provide computing and application service support for the image editing tool running in the mobile device 101. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0084] Specifically, after the user opens the image in the mobile device 101 and uses the image editing tool to perform attribute setting operations on the image, the mobile device 101 can send various rendering attributes generated by the attribute setting operation to the server 102. After the server 102 receives the rendering attributes sent by the mobile device 101, it uses the image processing solution provided in the embodiment of the present application to generate a shader program corresponding to a combination of multiple effects, and after running the shader program to render the image, the server 102 sends the image to the mobile device 101. The mobile device 101 can directly display the image received from the server 102 on the display screen. For the server 102, it can save the computing overhead in image rendering and improve the efficiency of image rendering.
[0085] It should be noted that ① the various devices included in the image processing system can be directly or indirectly connected in a wired or wireless manner, and the embodiments of the present application do not limit the communication method between devices; for example, the communication method between devices may include but is not limited to: using HyperText Transfer Protocol (HTTP) requests, remote procedure calls (Remote Procedure Call), sockets, and shared content. In addition, the above-mentioned embodiments of the present application Figure 1a and Figure 1b The system shown is intended to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided in the embodiment of the present application. It is known to those skilled in the art that with the evolution of the system architecture and the emergence of new business scenarios, the technical solution provided in the embodiment of the present application is also applicable to similar technical problems. ② The collection and processing of relevant data in the embodiment of the present application should be strictly in accordance with the requirements of relevant laws and regulations. The acquisition of personal information requires the knowledge or consent of the individual subject (or the legal basis for the acquisition of information), and the subsequent use and processing of data shall be carried out within the scope of authorization of laws and regulations and the subject of personal information. For example, when the embodiment of the present application is applied to a specific product or technology, such as obtaining the user's attribute setting operation, the user's permission or consent needs to be obtained, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant region.
[0086] The image processing solution provided by the embodiment of the present application has obvious advantages when performing image rendering. The advantages of the embodiment of the present application are described below by comparing the solution of the present application with the existing mainstream image rendering solution, where:
[0087] The general process of existing mainstream image rendering solutions can be found in Figure 2aDuring the image rendering process, multiple editing operations are often performed on the image, such as color space conversion, color adjustment, LUT filter overlay, dark corner addition, application of drawing mask, and specific blending mode according to the user's editing needs. Since the GPU needs to run a certain compiled shader program each time it draws (i.e. responds to a Draw Call command), a step-by-step drawing method is used to draw images corresponding to multiple editing operations. Figure 2a As shown, when the original video frame is drawn for the first time, a shader program is executed to render the corresponding effect of color adjustment, and the intermediate result of the rendering is rendered off-screen to the OpenGLTexture map; when the second drawing is performed, a shader program is executed to render the corresponding effect of adding the LUT filter to the intermediate result, until the effects corresponding to multiple editing steps are rendered. This step-by-step drawing method will cause a large number of Draw Calls, thereby consuming a large amount of system resources and power consumption, and also increasing the complexity of real-time rendering. The reason why the existing mainstream image rendering scheme needs to use step-by-step drawing for image rendering is that the GPU only runs a certain compiled shader program for each drawing. Then, considering that a series of effects can be added to a single image, and whether these effects are enabled and the specific execution logic when enabled are dynamically determined by the user during the image editing process, it is difficult to pre-set the shader program corresponding to each effect combination. In addition, the effect combinations applied to multiple video frames in the video are also different, and the space for effect combinations is very large. It is impossible to pre-write corresponding shader programs for various effect combinations. Therefore, it is difficult to compress multiple rendering steps into one rendering step using the existing mainstream step-by-step drawing method.
[0088] However, the image processing solution provided in the embodiment of the present application adopts a method of dynamically generating a shader program; the principle of dynamically generating a shader program can be found in Figure 2b, supports generating a shader program corresponding to the effect combination of multiple rendering steps based on the user's editing needs, so as to facilitate the rendering of multiple effect combinations in one drawing (i.e., one Draw Call). On the one hand, it can generate and dynamically generate a shader program matching the editing after the user's real-time editing based on the user's customized editing logic, and dynamically generate a shader program matching the next editing when the user edits the next time, without relying on the pre-set shader program, so as to achieve the matching relationship between the shader program and the user's customized editing logic. On the other hand, it can compress the rendering effects corresponding to multiple editing steps executed continuously by the user into one image rendering, specifically, it can generate a shader program capable of rendering the rendering effect combination corresponding to the multiple editing steps based on multiple editing steps. It enables the image rendering effects corresponding to multiple editing steps to be rendered in one Draw Call, greatly reduces system resources and power consumption by reducing the number of DrawCalls, saves the computational complexity of real-time rendering, and improves rendering efficiency. In particular, in the rendering process of video frames, it can effectively improve the maximum frame rate during rendering, and effectively improve the smoothness of video preview for situations where there are many overlapping rendering effects of video frames or low-end devices.
[0089] Based on the image processing scheme described above, the embodiment of the present application proposes a more detailed image processing method. The image processing method proposed in the embodiment of the present application will be described in detail below in conjunction with the accompanying drawings. Figure 3 A flowchart of an image processing method provided by an exemplary embodiment of the present application is shown; the image processing method may be executed by the aforementioned computer device, such as a mobile device; the image processing method may include but is not limited to steps S301-S304:
[0090] S301: In response to a property setting operation for an image, setting rendering properties of the image.
[0091] In a specific implementation, a user opens an image through a mobile device and uses an image editing tool (such as a client or a plug-in in the client) to edit the image; the image editing performed by the user on the image is mainly achieved by performing an attribute setting operation on the image. Among them, the attribute setting operation refers to the action of the user editing / setting the rendering attributes of the image, specifically, the action of setting the rendering attributes of all or part of the elements in the image; the rendering attributes of the image are some parameters that determine the rendering effect of the image.
[0092] As described above, the rendering engine generates an image by traversing each visible rendering node in the scene tree and executing specific drawing logic to achieve image rendering; the scene tree is a tree structure composed of rendering nodes corresponding to elements in the image, and a rendering node in the scene tree corresponds to an element in the picture. Then, by traversing the rendering nodes in the scene tree and executing the drawing logic, the rendering processing of the elements corresponding to the rendering node can be achieved to achieve the purpose of rendering the entire picture. Based on this, when the user sets the rendering properties of all or part of the elements in the image, the essence is to set the rendering properties of the rendering nodes corresponding to the elements in the image. For example, when the user performs a brightness enhancement operation on three elements in the image on a mobile device, the essence is to set the attribute value of the brightness attribute of the rendering nodes corresponding to the three elements, so that the brightness indicated by the attribute value of the brightness attribute after the setting is higher. From the user's visual effect, the brightness of the three elements is higher.
[0093] Among them, a rendering node in the scene tree corresponds to at least one image characteristic, that is, a rendering node supports or can realize at least one image characteristic, and one image characteristic corresponds to an image rendering effect; specifically, after the image characteristic is executed, the image can display the image rendering effect corresponding to the image characteristic. Common image characteristics can refer to the above-mentioned related descriptions, which will not be repeated here. Each image characteristic includes at least one rendering attribute related to the corresponding image rendering effect, so as to realize the image rendering effect corresponding to the corresponding image characteristic through the at least one rendering attribute; that is, at least one rendering attribute can be used to render the image to obtain the image rendering effect corresponding to the corresponding image characteristic.
[0094] Rendering attributes are parameters that control the behavior of rendering nodes, such as the rendering attributes in the color adjustment characteristics used to control the color rendering behavior performed by the rendering node for the color adjustment characteristics. The following is an exemplary introduction to the types of rendering attributes included in several image characteristics, where: the image characteristic is a color adjustment characteristic, and the rendering attributes included in the color adjustment characteristic may include: brightness attribute, contrast attribute, exposure attribute, hue attribute, saturation attribute, color temperature attribute, tint attribute, and vividness attribute; the rendering attributes included in these color adjustment characteristics are used to render the image to obtain the corresponding color rendering effect. The image characteristic is a filter type characteristic, and the rendering attributes included in the filter type characteristic may include: filter identification attribute and filter strength attribute; the rendering attributes included in these filter type characteristics are used to render the image to obtain the corresponding filter rendering effect. The image characteristic is a mixed mode characteristic, and the mixed mode characteristic includes mode attributes, etc.; the mode attributes included in the mixed mode characteristic are used to render the image to obtain the corresponding layer mixed rendering effect.
[0095] The following is combined with Figure 4 The process of the rendering engine setting the rendering attributes of an image when a user performs an attribute setting operation is described in an exemplary manner. Figure 4 As shown, the user opens an image editing interface 401 in an image editing tool, and the image editing interface 401 displays an image to be produced, which includes a bouquet composed of graphic elements. If the user wants to set the brightness of the flowers 402 in the bouquet and add filters to the entire image, the user can set the setting options corresponding to different rendering attributes in the image editing interface 401 to implement attribute setting operations for brightness and filters. For example, when setting the brightness of the flowers 402, the brightness joystick 403 can be operated to slide to set the brightness value; when setting the filter for the entire image, the target filter can be selected from the candidate filters in the image editing interface 401.
[0096] Accordingly, the rendering engine sets the rendering properties of the image in response to the property setting operation performed by the user in the image editing interface 401. Specifically, the set brightness value is used as the attribute value of the brightness attribute of the rendering node (one or more in number) corresponding to the element group (such as including at least one element or primitive) constituting the flower 402 under the color adjustment characteristic; and the filter type identifier of the selected target filter is used as the attribute value of the filter identifier attribute of all rendering nodes corresponding to all elements in the entire image under the filter type characteristic, and the filter strength of the target filter is used as the attribute value of the filter strength attribute of all rendering nodes corresponding to all elements in the entire image under the filter type characteristic. It can be seen that the property setting operation performed by the user this time is to set the rendering properties under the color adjustment characteristic and the filter type characteristic.
[0097] based on Figure 4 As can be seen from the example shown, each time the user performs a property setting operation, the rendering properties set may include properties under each of N image properties, where N is a positive integer; that is, each time the user performs a property setting operation, the rendering properties under different image properties may be set. For example, when the property setting operation was performed last time, the rendering properties under the color adjustment property and the filter type property were set, while when the property setting operation is performed this time, the rendering properties under the color adjustment property, the filter type property, and the blending mode property are set. For ease of explanation, the embodiment of the present application is introduced by taking the number of image properties targeted by a property setting operation as N, and the N image properties include: color adjustment property, filter type property, and blending mode property as an example.
[0098] For example, in the rendering engine, the rendering of the preview video frame is handled by multiple rendering nodes, which can be called SuperVideoSprite (SuperVideoSprite is a general term for text-type rendering nodes in the scene tree); various processing (such as the various image characteristics mentioned above) performed by SuperVideoSprite on the video frame is performed by setting the rendering properties of the rendering node. Exemplarily, the property setting code for rendering properties under the color adjustment characteristics, filter type characteristics, and blending mode characteristics on any SuperVideoSprite rendering node can be as follows:
[0099] / / Color adjustment features
[0100] void SetBrightnessBias(float brightnessBias); / / Set the brightness property
[0101] void SetContrastBias(float contrastBias); / / Set the [contrast] property
[0102] void SetSaturationBias(float saturationBias); / / Set [exposure] properties
[0103] void SetTintBias(float tintBias); / / Set the [hue] property
[0104] void SetHueBias(float hueBias); / / Set the [saturation] property
[0105] void SetTemperatureBias(float temperatureBias); / / Set the [color temperature] property
[0106] void SetExposureBias(float exposureBias); / / Set [hue] property
[0107] void SetVibranceBias(float vibranceBias); / / Set the [Vibrance] property
[0108] / / LUT filter type characteristics
[0109] void SetFilterID(const std::string&filterID); / / Set the [filter ID] property
[0110] void SetFilterIntensity(float filterIntensity); / / Set the [filter intensity] property
[0111] / / Other property setting interfaces...
[0112] / / Mixed mode features
[0113] void SetFinalBlendingMode(ERFBlendingMode finalBlendingMode); / / Set [blending mode] properties
[0114] As can be seen from the code, the SuperVideoSprite rendering node supports several sets of attribute settings, such as the attribute value settings of multiple rendering attributes under the color adjustment feature, the attribute value settings of multiple rendering attributes under the filter type feature, and the attribute value settings of multiple rendering attributes under the blending mode feature. The attribute values of rendering attributes are often controlled by the user's custom editing logic (i.e., executing attribute setting operations); when the attribute values of rendering attributes under any image feature change, it may be necessary to automatically regenerate the corresponding shader program so that the rendering engine can execute the corresponding shader program to achieve different rendering behaviors and achieve different image rendering effects.
[0115] S302: Analyze and process the rendering attributes of the image to generate shader specification description information.
[0116] Among them, the shader specification description information is mainly used to describe the specification information of the shader program used in the image rendering process. The specification information mainly includes some information necessary for generating the shader program, that is, the specification information is used to indicate the user's image rendering effect requirements under each of the N image characteristics. For example, the specification information may include the value of each of the N image characteristics, which indicates the user's image rendering requirements for the corresponding image characteristics; and also includes a template identifier of a code template required to generate a shader program, which indicates the code framework used to implement the N image rendering effects corresponding to the N image characteristics.
[0117] Specifically, the rendering engine parses the rendering attributes of the image to determine the shader specification description information of the shader program to be generated according to the attribute values of the rendering attributes of the rendering node. The exemplary process of the rendering engine parsing the rendering attributes of the image to generate the shader specification description information can be found in Figure 5 , comprising steps s11-s12: wherein:
[0118] s11: Perform attribute parsing processing on the rendering attributes under each of the N image characteristics to obtain the attribute parsing result corresponding to each image characteristic. Performing attribute parsing processing on the rendering attributes under any image characteristic is intended to analyze the image rendering effect that the user wants to edit by parsing the attribute value of the rendering attribute. In this way, any attribute parsing result obtained by the attribute parsing processing is used to indicate the image rendering effect requirement of the user for the image (specifically, the rendering node) under the corresponding image characteristic.
[0119] The following takes N kinds of image characteristics, namely color adjustment characteristics, filter type characteristics and blending mode characteristics, as an example to give the process of parsing and processing the rendering attributes of the image:
[0120] (1) The image characteristic is a color adjustment characteristic.
[0121] The color adjustment characteristic is a characteristic related to the color of the image, and the corresponding image rendering effect is a rendering effect related to the color. The image rendering effect corresponding to the color adjustment characteristic is determined by the values of the M1 rendering attributes included in the color adjustment characteristic; the types of the M1 rendering attributes can refer to the above-mentioned related description, and M1 is a positive integer, such as brightness attribute, transparency attribute, hue attribute, etc.
[0122] Specifically, in the case that there is a color adjustment feature among the N image features, the process of performing attribute parsing processing on the M1 rendering attributes under the color adjustment feature to obtain the feature parsing result corresponding to the color adjustment feature may include: detecting whether there is any rendering attribute whose attribute value is not the attribute default value among the M1 rendering attributes in the color adjustment feature; the attribute default value of any rendering attribute may be the original attribute value of the any rendering attribute on the rendering node in the image, that is, the attribute value of the any rendering attribute on the rendering node in the original image. If there is at least one rendering attribute whose attribute value is not the attribute default value among the M1 rendering attributes, indicating that the user has performed an attribute setting operation on the at least one rendering attribute on the rendering node in the image, then the feature parsing result of the color adjustment feature is set to a first color feature result, and the first color feature result indicates that the shader program uses a first color feature adjustment method to render / adjust the color adjustment feature. On the contrary, if the attribute value of each of the M1 rendering attributes is the attribute default value, indicating that the user has not set or adjusted the M1 rendering attributes on the rendering node in the image, then the characteristic parsing result of setting the color adjustment characteristic is set to the second color characteristic result, and the second color characteristic result instructs the shader program to render / adjust the color adjustment characteristic using the second color characteristic adjustment method.
[0123] It is worth noting that, no matter the characteristic analysis result of the color adjustment characteristic is the first color characteristic result or the second color characteristic result, the role of the characteristic analysis result of the color adjustment characteristic in the shader specification description information is to describe the user's requirements for the color adjustment characteristic.
[0124] (2) Image characteristics are filter type characteristics.
[0125] The filter type characteristic is a characteristic related to image filters. Image filters are tools that can add a specific artistic atmosphere or effect to an image, such as changing the artistic style of an image to a retro style, an artistic style, or a rock style. For example, a LUT filter is a filter technology that uses a lookup table to perform color correction or apply a specific effect. The filter can be provided by an image editing tool. The rendering properties included in the filter type characteristic may include: a filter identification property and a filter strength property. Among them, the attribute value of the filter identification property is the identifier of the filter, which is used to uniquely identify a filter (such as a retro filter, an artistic filter, or a rock filter). The attribute value of the filter strength property indicates the filter strength when the corresponding filter is added to the image. The stronger the filter strength, the more obvious the filter effect added to the image.
[0126] In a specific implementation, when there is a filter type characteristic among the N types of image characteristics, attribute parsing is performed on the filter identification attribute and the filter strength attribute under the filter type characteristic, and the process of obtaining the characteristic parsing result corresponding to the filter type characteristic may include: detecting whether the attribute value of the filter identification attribute is empty, if the attribute value of the filter identification attribute is empty, it indicates that a filter is added to the image, if the attribute value of the filter identification attribute is not empty, it indicates that a filter is added to the image; and, detecting whether the attribute value of the filter strength attribute is zero, if the attribute value of the filter strength attribute is zero, even if the attribute value of the filter identification attribute is not empty, it indicates that no filter is added to the image, if the attribute value of the filter strength attribute is not zero, and the attribute value of the filter identification attribute is not empty, it indicates that a filter at the filter strength indicated by the attribute value of the filter strength attribute is added to the image, and the filter is the filter indicated by the attribute value of the filter identification attribute. Based on this, if it is detected that the attribute value of the filter identification attribute is not empty, and the attribute value of the filter strength attribute is not zero, then the characteristic parsing result of the filter type characteristic is set to the first filter characteristic result, and the first filter characteristic result instructs the shader program to use the filter for the first filter characteristic mode to render / adjust the filter type characteristic. Conversely, if it is detected that the attribute value of the filter identification attribute is empty, or the attribute value of the filter strength attribute is zero, then the characteristic parsing result of the filter type characteristic is set to the second filter characteristic result, and the second filter characteristic result instructs the shader program to use the filter for the second filter characteristic mode to render / adjust the filter type characteristic.
[0127] It is worth noting that, regardless of whether the characteristic parsing result of the filter type characteristic is the first filter characteristic result or the second filter characteristic result, the role of the characteristic parsing result of the filter type characteristic in the shader specification description information is to describe the user's requirements for the filter characteristics.
[0128] (3) The image characteristics are mixed mode characteristics.
[0129] The blending mode feature is the way the colors and transparency of different layers are mixed during the image synthesis process; specifically, it is a feature that allows the color values of two layers to be combined / or mixed in different ways to create special transition effects between layers, simulate lighting effects, adjust image colors and contrast, or create special patterns and textures. The rendering properties included in the blending mode feature may have multiple values, and one value corresponds to a calculation method for a blending mode, which is specifically a rule for combining / mixing two layers; for example, when the second layer is superimposed on the first layer during the image synthesis process, the calculation method of the blending mode refers to the method / rule for layer blending between the second layer and the first layer. Among them, the blending mode may include but is not limited to: Normal mode (Normal), dark mode (Darken), multiply mode (Multiply) and color burn mode (ColorBurn), etc. The normal mode refers to a mode in which there is no blending between the pixels in the first layer and the pixels in the second image, that is, the blending effect corresponding to the normal mode is that the second layer has no effect on the display effect of the first layer. Darkening mode refers to comparing the color brightness values in the RGB (i.e., red (Red, R), green (Green, G), blue (Blue, B)) channels of the corresponding areas in the first layer and the second layer, retaining the pixels in the first layer whose color brightness values are darker than those in the second layer, and replacing the pixels in the first image whose color brightness values are brighter than those in the second layer with the corresponding pixels in the second layer whose color brightness values are brighter; that is, the mixing effect corresponding to the darkening mode is manifested as a decrease in the color grayscale, resulting in a darkening effect. Multiply mode refers to multiplying the grayscale of the pixel colors of the first layer and the second layer, and using the calculated color with a lower grayscale as the color after the layer is mixed, that is, the mixing effect corresponding to the Multiply mode is manifested as low-grayscale pixels appearing while high-grayscale pixels not appearing. Color darkening mode refers to retaining the white area in the first layer and mixing the dark areas in the first layer and the second layer, that is, the mixing effect corresponding to the color darkening mode is manifested as the dark part of the layer becoming darker and the bright part remaining almost unchanged. It can be seen that different blending modes can produce different visual effects; then, when there is a blending mode characteristic among N types of image characteristics, it is supported to use the attribute value of the rendering attribute included in the blending mode characteristic as the characteristic parsing result of the blending mode characteristic.
[0130] It should be noted that the image characteristics indicated by the rendering node are not limited to the three types given above. For example, image characteristics may also include applying drawing masks and adding vignetting characteristics, etc. The embodiment of the present application takes the above three image characteristics as an example to introduce the analysis and processing process for image characteristics, and does not limit the embodiment of the present application.
[0131] s12: Generate shader specification description information based on the feature analysis results corresponding to each image feature.
[0132] After calculating the characteristic analysis results corresponding to each of the N image characteristics based on the aforementioned step s11, the characteristic requirements under the corresponding image characteristics can be known based on the characteristic analysis results; therefore, the characteristic analysis results corresponding to each of the N image characteristics are directly added to the shader specification description information.
[0133] In addition, as the aforementioned image corresponds to a scene tree, the types and quantities of image features supported by different rendering nodes in the scene tree are different, and the user may perform attribute setting operations on different rendering nodes each time the user customizes the editing. Therefore, the embodiment of the present application also supports pre-configured shader code templates (or shader templates), which are the basic structure and framework of the shader code and are used to dynamically generate specific shader codes; it can be understood as a code framework that supports or includes the rendering capabilities of multiple image features.
[0134] Based on this, when generating shader specification description information, the embodiment of the present application also supports selecting target code template identifiers for N image characteristics from the code template library according to the node types of the rendering nodes corresponding to the N image characteristics in the scene tree corresponding to the image. In other words, the target code template identifier corresponding to the node type of the rendering node supporting the N image characteristics is selected from the code template library, and the target code template identifier is added to the shader specification description information; in this way, the shader specification description information includes the target code template identifier indicating the code framework and the characteristic parsing result of each image characteristic.
[0135] Among them, the target code template identifier is used to identify the target shader code template, and the target shader code template is a code framework that can realize the image rendering effects corresponding to N kinds of image characteristics. Among them, the code module library includes one or more code template identifiers pre-configured from the node type dimension, and the shader code template identified by each code module identifier. Exemplarily, according to the rendering node being the picture type dimension or the text type dimension, the shader code template corresponding to the picture type dimension and the shader code template corresponding to the text type dimension are preset. For example, when rendering is implemented for the rendering node of the picture type dimension, the SuperVideoSprite node will be used to implement the rendering, and the SuperVideoSprite node is a type of rendering node. Assuming that the rendering node of the SuperVideoSprite type may support 12 kinds of image rendering effects corresponding to 12 kinds of image characteristics, and the target shader code template identified by the target code template is used to support these 12 kinds of image rendering effects, then when the SuperVideoSprite node is rendered, the target shader code template indicated by the target code template identifier is used.
[0136] From the shader specification description information shown in steps s11-s12, it can be seen that the embodiment of the present application can parse and process each of the multiple image characteristics corresponding to the multiple setting steps in the user's attribute setting operation, and merge the parsing results into the shader specification description information, so as to store the user's characteristic requirements corresponding to each image characteristic in the shader specification description information, avoid the omission of the user's characteristic requirements for image characteristics, and thus ensure the accuracy of the final image rendering. In addition, the implementation of the present application also introduces the concept of code templates, so as to build a general framework for realizing multiple image characteristics for different node types through code templates, and provide a basic code framework for the generation of shader programs that can integrate multiple image characteristics.
[0137] S303: Construct a shader program according to the specification information described in the shader specification description information.
[0138] Based on the above description, it can be known that the shader specification description information includes a target code template identifier indicating a code framework of the shader program and N feature parsing results indicating feature requirements of N types of image features. In this way, the rendering engine will construct the shader code corresponding to the shader program (which can be understood as the initial code version of the shader program) according to the shader specification description information.
[0139] That is to say, after obtaining the shader specification description information, the rendering engine can obtain the target shader code template identified by the target code template identifier based on the target code template identifier in the shader specification description information. And, based on the feature parsing result of each image feature in the shader specification description information, obtain the feature code corresponding to each feature parsing result (i.e., the feature shader code mentioned above). In this way, the shader code can be constructed according to the target shader code template and the feature code corresponding to each feature parsing result, so as to realize the construction of the shader program based on the shader code.
[0140] The rendering engine constructs the shader program according to the target shader code template and the feature code corresponding to each feature parsing result. Figure 6 , including but not limited to steps s21-s23, wherein:
[0141] s21: The rendering engine assembles the target shader code template and the feature code corresponding to the feature parsing result of each of the N image features to obtain the shader code.
[0142] The so-called code assembly refers to the process of assembling the target shader code template indicated by the target code template identifier in the shader specification description information, and the characteristic shader code determined by the values of the characteristic requirements of each part in the shader specification description information to obtain a complete shader code. Among them, each part in the shader specification description information refers to the value of each image characteristic corresponding to N kinds of image characteristics (i.e., the characteristic analysis result).
[0143] As described above, shaders can include vertex shaders and fragment shaders according to their functions; vertex shaders and fragment shaders are the basic units for drawing images; vertex shaders are small programs responsible for processing vertex-level operations such as vertex coordinates and lighting, and fragment shaders are small programs responsible for processing pixel-level operations such as color and texture of primitive pixels. Accordingly, the preset shader code template in the embodiment of the present application is a code framework built based on vertex shaders and fragment shaders, such as the target shader code template indicated by the target code template identifier, including a target vertex shader code template (or simply referred to as a target vertex shader) and a target fragment shader code template (or simply referred to as a target fragment shader). The detailed assembly process of code assembly mentioned in the embodiment of the present application is to assemble the candidate vertex shader code templates corresponding to N feature parsing results and the target vertex shader code template in the target shader code template, and to assemble the candidate fragment shader code templates corresponding to N feature parsing results and the target fragment shader code template in the target shader code template.
[0144] In a specific implementation, after the rendering engine obtains the target shader code template indicated by the target code template identifier based on the target code template identifier, it reads the target vertex shader code template and the target fragment shader code template from the target shader code template respectively. Also, the candidate vertex shader code template and the candidate fragment shader code template corresponding to the feature parsing result for each image feature are obtained. For example, N kinds of image features include color adjustment features, filter type features, and blending mode features, then the candidate vertex shader code template and the candidate fragment shader code template corresponding to the feature parsing result of the color adjustment feature are read; and, the candidate vertex shader code template and the candidate fragment shader code template corresponding to the feature parsing result of the filter type feature are read; and, the candidate vertex shader code template and the candidate fragment shader code template for the blending mode feature are read. Then, the target vertex shader code template and N candidate vertex shader code templates are merged to generate a vertex shader code; and the target fragment shader code template and N candidate fragment shader code templates are merged to generate a fragment shader code to obtain a final shader code, which includes a vertex shader code and a fragment shader code.
[0145] s22: Optimize the shader code to obtain the optimized reference shader code.
[0146] It should be understood that, considering that the shader code is assembled according to the code template and multiple parts (i.e., the characteristic code corresponding to the characteristic analysis result of the image characteristic), there may be some areas in the shader code itself that need to be optimized, such as code redundancy or variable redundancy. To this end, the embodiment of the present application supports code optimization of the shader code, aiming to perform an equivalent (meaning that the running result of the program is not changed) transformation of the shader code, so that the running result of the transformed reference shader code is the same as the running result of the shader code before the transformation, but the reference shader code is shorter, the running time is shorter, and the space occupied is smaller, so as to achieve time and space efficiency.
[0147] The embodiments of the present application do not limit the specific optimization implementation methods of code optimization; code optimization may include but is not limited to: eliminating redundant code, optimizing the number of variables in the code, etc. In this way, a more efficient data structure is used to improve the code running efficiency, and the amount of code is reduced to reduce memory usage, etc.
[0148] The embodiment of the present application can input the shader code into the shader code optimizer (ShaderOptimizer) for coding to obtain an optimized reference shader code; the reference shader code includes an optimized vertex shader code and an optimized fragment shader code. Among them, the shader code optimizer is a module that optimizes the dynamically generated shader code, and aims to optimize it by deeply understanding the execution process of the shader code and identifying the code fragments that may reduce performance. This use of a special shader code optimizer to optimize the shader code can rely on the powerful code optimization capabilities of the shader code optimizer to fully optimize the shader code, and to a certain extent, can improve the quality and efficiency of code optimization.
[0149] It should be noted that the embodiments of the present application do not limit the device or module that performs code optimization; for example, in addition to using a shader code optimizer to optimize the merged shader code, the shader code can also be optimized by relying on the compilation optimization of the shader compiler itself.
[0150] s23: compile the reference shader code to obtain a shader program.
[0151] Code compilation, also known as code translation or code conversion, refers to the process of converting reference shader code written in a high-level language source into machine language code that can be executed by a computer device. This code compilation process is completed by a compiler, which is a tool that can compile and link the reference shader code into a shader program that can be executed by a computer device.
[0152] In summary, through the above steps s21-s23, it is possible to generate a shader program based on the shader specification description information; the shader program is a program with the rendering capability of N kinds of image rendering effects corresponding to N kinds of image characteristics.
[0153] S304: Run the shader program to render the image.
[0154] In a specific implementation, the rendering engine compresses a shader program based on the user's attribute setting operations for N kinds of image characteristics; when the CPU in the computer device sends a Draw Call command to the GPU, the shader program can be executed to achieve the rendering of multiple image rendering effects corresponding to the N kinds of image characteristics, so as to realize the rendering processing of the image.
[0155] In summary, the embodiment of the present application provides a new shader program generation scheme. On the one hand, the scheme can dynamically generate a shader program with multiple image rendering effects corresponding to multiple editing operations according to the user's multiple editing operations on the image; compared with the fixed shader program, the generation flexibility of the shader program is improved. On the other hand, the constructed shader program is an overall program that integrates shader subroutines of N image rendering effect combinations; not only does it realize the dynamic generation of shader programs based on multiple editing operations of the user, but the shader program also integrates multiple image characteristics, so that when the image is rendered based on the shader program, the editing steps corresponding to multiple image characteristics can be merged into one image rendering process, that is, the image rendering effects corresponding to multiple image characteristics are added in one image rendering process, compared with the step-by-step rendering of N image characteristics, the consumption of device resources or system resources by real-time image rendering is greatly reduced, the complexity of real-time image rendering is reduced and the rendering efficiency is improved.
[0156] The foregoing Figure 3 The illustrated embodiment provides a detailed introduction to the specific implementation process of the image processing method provided by the embodiment of the present application. To implement the image processing method provided by the embodiment of the present application, the embodiment of the present application provides multiple modules to execute the image processing method, and these modules may include but are not limited to: a feature parser, a code builder, a code optimizer, and a code compiler. Among them:
[0157] ① The feature parser includes a feature parser corresponding to each image feature, and one feature parser is used to parse the corresponding image feature, specifically to parse the attribute value of the rendering attribute included in the corresponding image feature to obtain the feature parsing result of the image feature. For example, the color adjustment feature parser corresponding to the color adjustment feature is a logic module responsible for generating the feature requirements (the requirement is indicated by the feature parsing result) of the color adjustment feature in the shader specification description information based on the attribute value of the rendering attribute included in the color adjustment feature. The filter type name feature parser corresponding to the filter type feature is a logic module responsible for generating the feature requirements of the filter type feature in the shader specification description based on the attribute value of the rendering attribute included in the filter type feature. The mixed mode feature parser corresponding to the mixed mode feature is a logic module responsible for generating the feature requirements of the mixed mode feature in the shader specification description information based on the attribute value of the rendering attribute included in the mixed mode feature.
[0158] ② The code builder or shader factory is a module that generates specific shader code based on the shader specification description information. In other words, the code builder has the ability to assemble the target shader code template indicated by the target code template identifier in the shader specification description information and the feature code of N parts.
[0159] ③The code optimizer is the shader code optimizer mentioned above, which is mainly responsible for optimizing the shader code dynamically generated according to the template.
[0160] ④ The code compiler is the compiler mentioned above, which is mainly responsible for compiling and linking the optimized reference shader code into a shader program that can be executed by the computer device.
[0161] For ease of understanding, the following Figure 7 Taking N kinds of image characteristics as color adjustment characteristics, filter type characteristics and blending mode characteristics as examples, an exemplary process of the image processing method is given. Figure 7 As shown:
[0162] (1) The rendering engine responds to the attribute setting operation performed by the user on the element in the image by setting the rendering attributes on the rendering node corresponding to the element in the scene tree corresponding to the image.
[0163] (2) When it is necessary to generate an image based on the attribute setting operation (such as in the real-time image editing scene, when it is necessary to preview the image based on the user's attribute setting operation), the feature parser will determine the shader specification description information of the shader program to be generated based on the attribute value of the rendering node. Among them, the generated shader specification description information is composed of multiple parts, and the specific parts and the relationship between these parts are specified in the shader code template. In detail, the shader specification description information includes: the template name of the target shader code template, that is, the target code template identifier mentioned above; and the implementation method of each part in the shader program. One part corresponds to an image feature, and the value of the image feature (that is, the feature parsing result) determines which implementation method the part is.
[0164] The generation process of the shader specification description information may include:
[0165] On the one hand, assuming that the node type of the rendering node belongs to the screen type dimension, and the rendering node supports image rendering effects corresponding to color adjustment characteristics, filter type characteristics, and blending mode characteristics, respectively, then select the template name of the shader code template that can support the image rendering effects corresponding to color adjustment characteristics, filter type characteristics, and blending mode characteristics, respectively, from the code module library (such as the target code template identifier mentioned above); add the template name to the shader specification description information.
[0166] On the other hand, assuming that the image characteristics corresponding to the N types of image rendering effects supported by the rendering node are: color adjustment characteristics, filter type characteristics and blending mode characteristics, then each image characteristic is parsed and processed, and the characteristic parsing result of each image characteristic is added to the shader specification description information. Among them, the color adjustment characteristic parser corresponding to the color adjustment characteristic, the filter type name characteristic parser corresponding to the filter type characteristic and the blending mode characteristic parser corresponding to the blending mode characteristic are used to perform the parsing process, respectively including:
[0167] 1) The color adjustment feature parser will determine the feature requirements of the color adjustment feature in the shader specification description information based on the attribute values of the rendering attributes included in the color adjustment feature. The feature requirements are the feature parsing results of the color adjustment feature. The feature parsing results of the color adjustment feature may have two value results, namely:
[0168] ① If at least one of the M1 rendering attributes included in the color adjustment characteristic has an attribute value that is not the default attribute value, the characteristic analysis result of the color adjustment characteristic is set to the first color characteristic result. Specifically, it is assumed that the M1 rendering attributes are: brightness attribute, contrast attribute, exposure attribute, hue attribute, saturation attribute, color temperature attribute, color cast attribute, and vividness adjustment attribute; as long as there is a rendering attribute whose attribute value is not the default attribute value among the brightness attribute, contrast attribute, exposure attribute, hue attribute, saturation attribute, color temperature attribute, color cast attribute, and vividness adjustment attribute, it is considered that the user has performed an attribute setting operation on the rendering attribute in the color adjustment characteristic on the rendering node, and the characteristic analysis result "first color characteristic result" of the color adjustment characteristic is determined to be Normal, indicating that the characteristic requirement for the color adjustment characteristic is to re-adjust the color of the rendering node based on the rendering attribute whose attribute value has changed. Color adjustment is an operation that can adjust the color attributes of an image or video frame, such as brightness, contrast, and saturation.
[0169] ② If the M1 rendering attributes included in the color adjustment characteristic do not exist and the attribute value of the rendering attribute is not the attribute default value, then the characteristic analysis result of the color adjustment characteristic is set to the second color characteristic result. Specifically, it is assumed that the M1 rendering attributes are: brightness attribute, contrast attribute, exposure attribute, hue attribute, saturation attribute, color temperature attribute, color cast attribute and vividness adjustment attribute; only when the attribute values of the brightness attribute, contrast attribute, exposure attribute, hue attribute, saturation attribute, color temperature attribute, color cast attribute and vividness adjustment attribute are all the attribute default values, the characteristic analysis result "second color characteristic result" of the color adjustment characteristic is determined to be None (empty), indicating that the characteristic requirement for the color adjustment characteristic is that the rendering node does not need to be re-adjusted in color.
[0170] 2) The filter type name feature parser will determine the feature requirements of the filter type feature in the shader specification description information based on the attribute values of the rendering attributes included in the filter type feature. The feature requirements are the feature parsing results of the filter type feature. The feature parsing results of the filter type feature may have two value results, namely:
[0171] ① If the attribute value of the filter identification attribute in the filter type attribute is not empty, and the filter strength attribute is not zero, then the attribute parsing result "first filter characteristic result" of the filter type attribute is determined to be Default; indicating that the characteristic requirement of the filter type attribute is that the filter needs to be re-added to the rendering node based on the attribute value of the filter identification attribute and the attribute value of the filter strength attribute.
[0172] ② If the attribute value of the filter identification attribute in the filter type characteristic is empty, or the filter strength attribute is zero, then the characteristic analysis result "second filter characteristic result" of the filter type characteristic is determined to be None, indicating that the characteristic requirement of the filter type characteristic is that there is no need to re-add the filter to the rendering node.
[0173] 3) The blending mode feature parser will determine the feature requirements for the blending mode feature in the shader specification description information based on the setting value of the blending mode feature in the rendering node. This feature requirement is the feature parsing result of the blending mode feature. For example, the rendering attributes included in the blending mode feature in the rendering node have 27 values, that is, the attribute values may be Normal (corresponding to normal mode), Darken (corresponding to darkening mode), Multiply (corresponding to multiply mode), ColorBurn (corresponding to color burning mode), etc. Correspondingly, the feature requirements of the blending mode are recorded in the shader specification description information, and this feature requirement is one of the 27 values.
[0174] (3) Use the code builder (i.e., shader factory) to construct shader code based on the shader specification description information. The specific construction method is to assemble the code based on the code in the target shader code template in the shader specification description information and the feature code determined by the feature requirements in each part of the shader specification description information to obtain a complete shader code. The shader code here includes both vertex shader code and fragment shader code.
[0175] like Figure 8As shown, assuming that the characteristic parsing result of the color adjustment characteristic is Normal, the characteristic parsing result of the filter type characteristic is Default, and the characteristic parsing result of the blending mode characteristic is ColorBurn. Then, the code of the target vertex shader code template (Vertex Shader) in the target shader code template identified by the target code template identifier is read, and the code of the target vertex shader code template is recorded as vs1; similarly, the code of the target fragment shader code template (Fragment Shader) in the target shader code template identified by the target code template identifier is read, and the code of the target fragment shader code template is recorded as fs1.
[0176] Also, read the code of the candidate vertex shader code template (Vertex Shader) of the color adjustment feature under the Normal mode of the feature analysis result, and record the candidate vertex shader code template of the color adjustment feature as vs2; and read the code of the candidate fragment shader code template (Fragment Shader) of the color adjustment feature under the Normal mode of the feature analysis result, and record the code of the candidate fragment shader code template of the color adjustment feature as fs2.
[0177] Also, read the code of the candidate vertex shader code template (Vertex Shader) of the filter type feature under the Default mode of the feature parsing result, and record the code of the candidate fragment shader code template of the filter type feature as vs3; and read the code of the candidate fragment shader code template (Fragment Shader) of the filter type feature under the Default mode of the feature parsing result, and record the code of the candidate fragment shader code template of the filter type feature as fs3.
[0178] Also, read the code of the candidate vertex shader code template (Vertex Shader) of the mixed mode feature in the ColorBurn mode for the feature parsing result, and record the code of the candidate fragment shader code template of the mixed mode feature as vs4; and read the code of the candidate fragment shader code template (Fragment Shader) of the mixed mode feature in the ColorBurn mode for the feature parsing result, and record the code of the candidate fragment shader code template of the mixed mode feature as fs4.
[0179] Then, merge the vertex shader code in the shader code generated by vs1, vs2, vs3 and vs4, and record the vertex shader code as vs, vs=vs1+vs2+vs3+vs4; and merge the fragment shader code in the shader code generated by fs1, fs2, fs3 and fs4, and record the fragment shader code as fs, fs=fs1+fs2+fs3+fs4. In this way, the shader code is obtained, which includes vs and fs.
[0180] (4) Use a code optimizer to optimize the shader code to obtain an optimized reference shader code. It should be understood that the shader code includes vs and fs, so the optimized reference shader code includes an optimized vs and an optimized fs. The specific implementation method of using a code optimizer for code optimization can be found in the above-mentioned related description, which will not be repeated here.
[0181] (5) Use the code compiler to compile the optimized reference shader code to obtain a shader program. Specifically, the reference shader code can be input into the code compiler (ShaderCompiler), which processes it according to the code compilation and linking process of OpenGL Shader to obtain a shader program (ShaderProgram).
[0182] (6) After obtaining the shader program, the shader program can be executed in the Drwa Call of the corresponding rendering node, so as to compress the rendering effects obtained by multiple editing steps into one rendering process.
[0183] It can be seen that the embodiment of the present application integrates multiple rendering steps in one Draw Call, which saves the computational complexity during rendering, reduces the hardware load of the computer device, and reduces the device power consumption during program operation. In the editing scene of multiple video frames included in the video, the maximum frame rate during rendering can be effectively improved. For situations where there are many superimposed video frame rendering effects or the device is low-end, the smoothness of the video preview can be effectively improved.
[0184] The above detailed description of the method of the embodiment of the present application, in order to facilitate the above-mentioned scheme of the embodiment of the present application, the device of the embodiment of the present application is provided below accordingly. In the embodiment of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that contains the function of the module or unit.
[0185] Fig. 9 A schematic diagram of the structure of an image processing device provided by an exemplary embodiment of the present application is shown; the image processing device can be used to perform Figure 3 Some or all of the steps in the method embodiment shown. Fig. 9 , the device comprises the following units:
[0186] The setting unit 901 is used to set the rendering attributes of the image in response to the attribute setting operation for the image; the image includes N kinds of image characteristics, and the rendering attributes include attributes under each image characteristic; N is a positive integer;
[0187] The processing unit 902 is used to parse and process the rendering attributes of the image to generate shader specification description information; the shader specification description information is used to describe the specification information of the shader program used in the rendering process of the image;
[0188] The processing unit 902 is further configured to construct a shader program according to the specification information described by the shader specification description information;
[0189] The processing unit 902 is also used to run the shader program to render the image.
[0190] In one implementation, the N image characteristics include: a color adjustment characteristic, a filter type characteristic, and a blending mode characteristic;
[0191] Among them, one image characteristic corresponds to one image rendering effect; each image characteristic includes at least one rendering attribute related to the corresponding image rendering effect, and the at least one rendering attribute is used to render the image to obtain the corresponding image rendering effect.
[0192] In one implementation, the processing unit 902 is used to parse the rendering attributes of the image and generate the shader specification description information, specifically to:
[0193] Performing attribute parsing processing on the rendering attributes under each image characteristic to obtain the attribute parsing result corresponding to each image characteristic; any attribute parsing result is used to indicate the image rendering effect requirement under the corresponding image characteristic;
[0194] Based on the characteristic analysis results corresponding to each image characteristic, shader specification description information is generated. The specification information described by the shader specification description information is used to indicate the image rendering effect requirements under each image characteristic.
[0195] In one implementation, the image characteristic is a color adjustment characteristic, and the color adjustment characteristic includes M1 rendering attributes; the processing unit 902 is used to perform attribute parsing processing on the rendering attributes under each image characteristic, and when obtaining the attribute parsing result corresponding to each image characteristic, it is specifically used to:
[0196] Check whether any of the M1 rendering attributes has a value other than the default value.
[0197] If the attribute value of at least one rendering attribute among the M1 rendering attributes is not the attribute default value, then the characteristic parsing result of the color adjustment characteristic is set to the first color characteristic result;
[0198] If the attribute value of each rendering attribute in the M1 rendering attributes is the attribute default value, then the characteristic parsing result of the color adjustment characteristic is set to be the second color characteristic result.
[0199] In one implementation, the image characteristic is a filter type characteristic, and the filter type characteristic includes a filter identification attribute and a filter strength attribute; the processing unit 902 is used to perform attribute parsing processing on the rendering attribute under each image characteristic, and when obtaining the attribute parsing result corresponding to each image characteristic, it is specifically used to:
[0200] Check whether the attribute value of the filter identification attribute is empty and whether the attribute value of the filter strength attribute is zero;
[0201] If the attribute value of the filter identification attribute is not empty, and the attribute value of the filter strength attribute is not zero, then the characteristic parsing result of the filter type characteristic is set to the first filter characteristic result;
[0202] If the attribute value of the filter identification attribute is empty, or the attribute value of the filter strength attribute is zero, the characteristic parsing result of the filter type characteristic is set to the second filter characteristic result.
[0203] In one implementation, the image characteristic is a mixed mode characteristic, and the processing unit 902 is used to perform attribute parsing processing on the rendering attribute under each image characteristic, and when obtaining the attribute parsing result corresponding to each image characteristic, specifically to:
[0204] The attribute value of the rendering attribute included in the blending mode attribute is taken as the attribute resolution result of the blending mode attribute.
[0205] In one implementation, an image corresponds to a scene tree, the scene tree is a tree structure composed of elements in the image, one element in the image corresponds to a rendering node in the scene tree; one rendering node corresponds to at least one image characteristic; the processing unit 902 is used to generate shader specification description information based on the characteristic analysis result corresponding to each image characteristic, specifically for:
[0206] According to the node type of the rendering node corresponding to N kinds of image characteristics in the scene tree, a target code template identifier is selected for the N kinds of image characteristics from the code template library; the target code template identifier is used to identify a target shader code template, and the target shader code template is a code framework that can achieve image rendering effects corresponding to the N kinds of image characteristics; the code module library includes one or more code template identifiers pre-configured from the node type dimension, and a shader code template identified by each code module identifier;
[0207] The target code template identifier and the feature parsing results for each image feature are added to the shader specification description information.
[0208] In one implementation, the shader specification description information includes a target code template identifier; the processing unit 902 is used to construct a shader program according to the specification information described in the shader specification description information, specifically to:
[0209] Get the target shader code template identified by the target code template identifier;
[0210] Based on the feature analysis results of each image feature, obtain the feature code corresponding to each feature analysis result;
[0211] Build a shader program based on the target shader code template and the feature code corresponding to each feature parsing result.
[0212] In one implementation, the processing unit 902 is used to construct a shader program according to the target shader code template and the feature code corresponding to each feature parsing result, specifically to:
[0213] Assemble the target shader code template and the feature code corresponding to each feature parsing result to obtain the shader code;
[0214] Optimize the shader code to obtain optimized reference shader code;
[0215] Compile the reference shader code to obtain a shader program.
[0216] In one implementation, the target shader code template includes a target vertex shader code template and a target fragment shader code template; the shader code includes a vertex shader code and a fragment shader code; the processing unit 902 is used to assemble the target shader code template and the feature code corresponding to each feature parsing result to obtain the shader code, specifically for:
[0217] From the target shader code template, read the target vertex shader code template and the target fragment shader code template respectively; and,
[0218] Obtain candidate vertex shader code templates and candidate fragment shader code templates corresponding to the feature parsing results for each image feature;
[0219] Merging the target vertex shader code template and the N candidate vertex shader code templates to generate vertex shader code; and,
[0220] The target fragment shader code template and the N candidate fragment shader code templates are merged to generate a fragment shader code.
[0221] According to one embodiment of the present application, Fig. 9 The various units in the image processing device shown can be individually or completely combined into one or several other units to form, or one (some) of the units can be further divided into multiple functionally smaller units to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the video processing device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units and can be implemented by the collaboration of multiple units. According to another embodiment of the present application, it can be executed by running on a general computing device such as a computer including processing elements and storage elements such as a central processing unit (CPU), a random access memory (RAM), and a read-only memory (ROM). Figure 3 A computer program (including program code) for each step involved in the corresponding method shown in FIG. Fig. 9 The image processing apparatus shown in the figure can be used to implement the image processing method of the embodiment of the present application. The computer program can be recorded on a computer-readable recording medium, for example, and loaded into the above-mentioned computing device through the computer-readable recording medium and run therein.
[0222] In an embodiment of the present application, in response to a user's attribute setting operation on an image, the rendering attributes of the image are set, and the rendering attributes include attributes under each image characteristic, and the image includes N kinds of image characteristics; one image characteristic corresponds to an image rendering effect, such as color rendering, filter rendering, or mode rendering. In other words, the rendering attributes under different image characteristics can be set in batches according to multiple editing operations of the user on the image (such as one editing operation is used to set the rendering attributes under one image characteristic of the image). In this way, the rendering attributes of the image are parsed and processed in batches to generate a shader specification description; the shader specification description information is used to describe the specification information of the shader program used in the rendering process of the image, and the shader specification description information can integrate the specification information of the shader program that implements the image rendering effect corresponding to each image characteristic in the N kinds of image characteristics. Thereby, it is ensured that the shader program constructed based on the specification information described by the shader specification description information is an overall program of shader subroutines that integrate N combinations of image rendering effects; not only is the shader program dynamically generated based on multiple editing operations of the user, but the shader program also integrates multiple image characteristics, so that when the image is rendered based on the shader program, the editing steps corresponding to multiple image characteristics can be merged into one image rendering process, that is, image rendering effects corresponding to multiple image characteristics are added in one image rendering process. Compared with the step-by-step rendering of N image characteristics, the consumption of device resources / system resources for real-time image rendering is greatly reduced, the complexity of real-time image rendering is reduced and the rendering efficiency is improved.
[0223] Fig.10 FIG. 1 shows a schematic diagram of a computer device provided by an exemplary embodiment of the present application. Fig.10 , the computer device includes a processor 1001, a communication interface 1002 and a computer-readable storage medium 1003. The processor 1001, the communication interface 1002 and the computer-readable storage medium 1003 can be connected via a bus or other means. The communication interface 1002 is used to receive and send data. The computer-readable storage medium 1003 can be stored in the memory of the computer device. The computer-readable storage medium 1003 is used to store a computer program. The computer program includes program instructions. The processor 1001 is used to execute the program instructions stored in the computer-readable storage medium 1003. The processor 1001 (or CPU) is the computing core and control core of the computer device, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function.
[0224] The embodiment of the present application also provides a computer-readable storage medium (Memory), which is a memory device in a computer device for storing programs and data. It is understandable that the computer-readable storage medium here can include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer-readable storage medium provides a storage space that stores the processing system of the electronic device. In addition, one or more instructions suitable for being loaded and executed by the processor 1001 are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer-readable storage medium here can be a high-speed RAM memory, or a non-volatile memory, such as at least one disk storage; optionally, it can also be at least one computer-readable storage medium located away from the aforementioned processor.
[0225] In one embodiment, the computer-readable storage medium stores one or more instructions; the processor 1001 loads and executes the one or more instructions stored in the computer-readable storage medium to implement the corresponding steps in the above-mentioned image processing method embodiment; in a specific implementation, the one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and the following steps are executed:
[0226] In response to the attribute setting operation for the image, the rendering attribute of the image is set; the image includes N image characteristics, and the rendering attribute includes attributes under each image characteristic; N is a positive integer;
[0227] Analyze the rendering attributes of the image to generate shader specification description information; the shader specification description information is used to describe the specification information of the shader program used in the rendering process of the image;
[0228] Constructing a shader program according to the specification information described by the shader specification description information;
[0229] Run the shader program to render the image.
[0230] In one implementation, the N image characteristics include: a color adjustment characteristic, a filter type characteristic, and a blending mode characteristic;
[0231] Among them, one image characteristic corresponds to one image rendering effect; each image characteristic includes at least one rendering attribute related to the corresponding image rendering effect, and the at least one rendering attribute is used to render the image to obtain the corresponding image rendering effect.
[0232] In one implementation, one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and when parsing the rendering attributes of the image and generating the shader specification description information, the following steps are specifically performed:
[0233] Performing attribute parsing processing on the rendering attributes under each image characteristic to obtain the attribute parsing result corresponding to each image characteristic; any attribute parsing result is used to indicate the image rendering effect requirement under the corresponding image characteristic;
[0234] Based on the characteristic analysis results corresponding to each image characteristic, shader specification description information is generated. The specification information described by the shader specification description information is used to indicate the image rendering effect requirements under each image characteristic.
[0235] In one implementation, the image characteristic is a color adjustment characteristic, and the color adjustment characteristic includes M1 rendering attributes; one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and when performing attribute parsing processing on the rendering attributes under each image characteristic and obtaining a characteristic parsing result corresponding to each image characteristic, the following steps are specifically performed:
[0236] Check whether any of the M1 rendering attributes has a value other than the default value.
[0237] If the attribute value of at least one rendering attribute among the M1 rendering attributes is not the attribute default value, then the characteristic parsing result of the color adjustment characteristic is set to the first color characteristic result;
[0238] If the attribute value of each rendering attribute in the M1 rendering attributes is the attribute default value, then the characteristic parsing result of the color adjustment characteristic is set to be the second color characteristic result.
[0239] In one implementation, the image characteristic is a filter type characteristic, and the filter type characteristic includes a filter identification attribute and a filter strength attribute; one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and when performing attribute parsing processing on the rendering attributes under each image characteristic, and obtaining a characteristic parsing result corresponding to each image characteristic, the following steps are specifically performed:
[0240] Check whether the attribute value of the filter identification attribute is empty and whether the attribute value of the filter strength attribute is zero;
[0241] If the attribute value of the filter identification attribute is not empty, and the attribute value of the filter strength attribute is not zero, then the characteristic parsing result of the filter type characteristic is set to the first filter characteristic result;
[0242] If the attribute value of the filter identification attribute is empty, or the attribute value of the filter strength attribute is zero, the characteristic parsing result of the filter type characteristic is set to the second filter characteristic result.
[0243] In one implementation, the image characteristic is a mixed mode characteristic, and one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and are executed to perform attribute parsing processing on the rendering attributes under each image characteristic, and when obtaining the characteristic parsing result corresponding to each image characteristic, the following steps are specifically performed:
[0244] The attribute value of the rendering attribute included in the blending mode attribute is taken as the attribute resolution result of the blending mode attribute.
[0245] In one implementation, an image corresponds to a scene tree, the scene tree is a tree structure composed of elements in the image, one element in the image corresponds to a rendering node in the scene tree; one rendering node corresponds to at least one image feature; one or more instructions in a computer-readable storage medium are loaded by the processor 1001 and when executing the feature parsing result corresponding to each image feature to generate shader specification description information, the following steps are specifically performed:
[0246] According to the node type of the rendering node corresponding to N kinds of image characteristics in the scene tree, a target code template identifier is selected for the N kinds of image characteristics from the code template library; the target code template identifier is used to identify a target shader code template, and the target shader code template is a code framework that can achieve image rendering effects corresponding to the N kinds of image characteristics; the code module library includes one or more code template identifiers pre-configured from the node type dimension, and a shader code template identified by each code module identifier;
[0247] The target code template identifier and the feature parsing results for each image feature are added to the shader specification description information.
[0248] In one implementation, the shader specification description information includes a target code template identifier; one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and executed according to the specification information described in the shader specification description information to construct a shader program, specifically performing the following steps:
[0249] Get the target shader code template identified by the target code template identifier;
[0250] Based on the feature analysis results of each image feature, obtain the feature code corresponding to each feature analysis result;
[0251] Build a shader program based on the target shader code template and the feature code corresponding to each feature parsing result.
[0252] In one implementation, one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and when executing the characteristic code corresponding to the target shader code template and each characteristic parsing result to construct a shader program, the following steps are specifically performed:
[0253] Assemble the target shader code template and the feature code corresponding to each feature parsing result to obtain the shader code;
[0254] Optimize the shader code to obtain optimized reference shader code;
[0255] Compile the reference shader code to obtain a shader program.
[0256] In one implementation, the target shader code template includes a target vertex shader code template and a target fragment shader code template; the shader code includes a vertex shader code and a fragment shader code; one or more instructions in the computer-readable storage medium are loaded by the processor 1001 and when executing, the target shader code template and the feature code corresponding to each feature parsing result are assembled into code to obtain the shader code, and the following steps are specifically performed:
[0257] From the target shader code template, read the target vertex shader code template and the target fragment shader code template respectively; and,
[0258] Obtain candidate vertex shader code templates and candidate fragment shader code templates corresponding to the feature parsing results for each image feature;
[0259] Merging the target vertex shader code template and the N candidate vertex shader code templates to generate vertex shader code; and,
[0260] The target fragment shader code template and the N candidate fragment shader code templates are merged to generate a fragment shader code.
[0261] Based on the same inventive concept, the principles and beneficial effects of solving the problems provided by the computer device in the embodiment of the present application are similar to the principles and beneficial effects of solving the problems provided by the image processing method in the method embodiment of the present application. Please refer to the principles and beneficial effects of the implementation of the method. For the sake of concise description, they will not be repeated here.
[0262] The embodiment of the present application also provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device performs the above-mentioned image processing method.
[0263] A person skilled in the art can appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0264] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from a website site, a computer, a server or a data center to another website site, a computer, a server or a data center by wired (for example, coaxial cable, optical fiber, digital line (Digital Subscriber Line, DSL)) or wireless (for example, infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data processing device such as a server, a data center, etc. that includes one or more available media integrated. The available media may be magnetic media (eg, floppy disks, hard disks, magnetic tapes), optical media (eg, digital video disks (DVDs)), or semiconductor media (eg, solid state disks (SSDs)).
[0265] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technical object familiar with the technical field can be easily changed or replaced within the technical scope disclosed by the present invention, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An image processing method, characterized in that: include: In response to a user's attribute setting operation on an image, a rendering attribute of the image is set; the image includes N kinds of image characteristics, the N kinds of image characteristics include a color adjustment characteristic, a filter type characteristic, and a blending mode characteristic, and one of the image characteristics corresponds to one image rendering effect; the rendering attribute includes attributes under each of the image characteristics; N is a positive integer; Parsing the rendering attributes of the image to generate shader specification description information; The shader specification description information is used to describe the specification information of the shader program used in the rendering process of the image; the shader specification description information includes a target code template identifier and a characteristic analysis result of each of the N image characteristics; The target code template identifier is used to identify a target shader code template, and the target shader code template is a code framework capable of realizing N types of image rendering effects corresponding to the image characteristics; The characteristic analysis result of the image characteristic is used to indicate the image rendering effect requirement of the user for the image under the corresponding image characteristic; Constructing the shader program according to the specification information described in the shader specification description information; The shader program is an overall program that combines N types of image rendering effects corresponding to N types of image characteristics; The shader program is run to render the image.
2. The method according to claim 1, characterized in that in, Each of the image characteristics includes at least one rendering attribute related to the corresponding image rendering effect, and the at least one rendering attribute is used to render the image to obtain the corresponding image rendering effect.
3. The method according to claim 1 or 2, characterized in that The parsing and processing of the rendering attributes of the image to generate shader specification description information includes: Performing attribute analysis processing on the rendering attributes under each of the image characteristics to obtain attribute analysis results corresponding to each of the image characteristics; Based on the characteristic analysis results corresponding to each of the image characteristics, shader specification description information is generated, and the specification information described in the shader specification description information is used to indicate the image rendering effect requirements under each of the image characteristics.
4. The method according to claim 3, characterized in that The image characteristic is a color adjustment characteristic, and the color adjustment characteristic includes M1 rendering attributes; the rendering attributes under each of the image characteristics are subjected to attribute analysis processing to obtain a characteristic analysis result corresponding to each of the image characteristics, including: Detecting whether there is any one of the rendering attributes whose attribute value is not the attribute default value among the M1 rendering attributes; If at least one of the M1 rendering attributes has an attribute value that is not an attribute default value, setting the characteristic parsing result of the color adjustment characteristic to a first color characteristic result; If the attribute value of each of the M1 rendering attributes is the attribute default value, then the characteristic parsing result of the color adjustment characteristic is set to the second color characteristic result.
5. The method according to claim 3, characterized in that The image characteristic is a filter type characteristic, and the filter type characteristic includes a filter identification attribute and a filter strength attribute; the rendering attribute under each of the image characteristics is subjected to attribute parsing processing to obtain a characteristic parsing result corresponding to each of the image characteristics, including: Detecting whether the attribute value of the filter identification attribute is empty, and whether the attribute value of the filter strength attribute is zero; If the attribute value of the filter identification attribute is not empty, and the attribute value of the filter strength attribute is not zero, setting the characteristic parsing result of the filter type characteristic to the first filter characteristic result; If the attribute value of the filter identification attribute is empty, or the attribute value of the filter strength attribute is zero, the characteristic parsing result of the filter type characteristic is set to the second filter characteristic result.
6. The method according to claim 3, characterized in that The image characteristic is a mixed mode characteristic, and the rendering attribute under each of the image characteristics is subjected to attribute parsing processing to obtain a characteristic parsing result corresponding to each of the image characteristics, including: The attribute value of the rendering attribute included in the mixed mode characteristic is used as the characteristic parsing result of the mixed mode characteristic.
7. The method according to claim 3, characterized in that The image corresponds to a scene tree, the scene tree is a tree structure composed of elements in the image, and one element in the image corresponds to a rendering node in the scene tree; One of the rendering nodes corresponds to at least one image characteristic; The generating of shader specification description information based on the characteristic analysis result corresponding to each of the image characteristics includes: According to the node types of the rendering nodes corresponding to the N types of the image characteristics in the scene tree, select target code template identifiers for the N types of the image characteristics from a code template library; the code template library includes one or more code template identifiers pre-configured from a node type dimension, and a shader code template identified by each of the code template identifiers; The target code template identifier and the characteristic parsing result of each of the image characteristics are added to the shader specification description information.
8. The method according to claim 1, characterized in that The shader specification description information includes a target code template identifier; and constructing the shader program according to the specification information described in the shader specification description information includes: Obtaining the target shader code template identified by the target code template identifier; Based on the characteristic analysis results of each of the image characteristics, obtaining a characteristic code corresponding to each of the characteristic analysis results; The shader program is constructed according to the target shader code template and the feature code corresponding to each feature parsing result.
9. The method according to claim 8, characterized in that The step of constructing the shader program according to the target shader code template and the characteristic code corresponding to each characteristic parsing result includes: Assemble the target shader code template and the characteristic code corresponding to each characteristic analysis result to obtain a shader code; Optimizing the shader code to obtain an optimized reference shader code; Compiling the reference shader code to obtain the shader program.
10. The method according to claim 9, characterized in that The target shader code template includes a target vertex shader code template and a target fragment shader code template; the shader code includes a vertex shader code and a fragment shader code; The step of assembling the target shader code template and the characteristic code corresponding to each characteristic parsing result to obtain the shader code comprises: Reading the target vertex shader code template and the target fragment shader code template from the target shader code template respectively; and, Obtaining candidate vertex shader code templates and candidate fragment shader code templates corresponding to the characteristic analysis results of each of the image characteristics; Merging the target vertex shader code template and the N candidate vertex shader code templates to generate the vertex shader code; and, The target fragment shader code template and the N candidate fragment shader code templates are merged to generate the fragment shader code.
11. An image processing device, characterized in that: include: A setting unit, configured to set rendering properties of the image in response to a user's property setting operation on the image; the image includes N kinds of image characteristics, the N kinds of image characteristics include color adjustment characteristics, filter type characteristics and blending mode characteristics, and one of the image characteristics corresponds to one image rendering effect; the rendering properties include properties under each of the image characteristics; N is a positive integer; A processing unit, configured to parse the rendering attributes of the image and generate shader specification description information; The shader specification description information is used to describe the specification information of the shader program used in the rendering process of the image; the shader specification description information includes a target code template identifier and a characteristic analysis result of each of the N image characteristics; The target code template identifier is used to identify a target shader code template, and the target shader code template is a code framework capable of realizing N types of image rendering effects corresponding to the image characteristics; The characteristic analysis result of the image characteristic is used to indicate the image rendering effect requirement of the user for the image under the corresponding image characteristic; The processing unit is further used to construct the shader program according to the specification information described in the shader specification description information; the shader program is an overall program that integrates the N image rendering effect combinations corresponding to the N image characteristics; The processing unit is further used to run the shader program to render the image.
12. A computer device, characterized in that: include: a processor adapted to execute a computer program; A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by the processor, the image processing method according to any one of claims 1 to 10 is implemented.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the image processing method according to any one of claims 1 to 10.
14. A computer program product, characterized in that The computer program product comprises computer instructions, and when the computer instructions are executed by a processor, the image processing method according to any one of claims 1 to 10 is implemented.
Citation Information
Patent Citations
Image rendering method, image rendering device and electronic device
CN106997610A
Method for realizing multi-projector projection gradient fusion based on shader
CN114071104A
Image rendering method and device, electronic equipment and readable storage medium
CN118172229A
Rendering method and device, electronic equipment and storage medium
CN118334229A
Apparatus for providing and transforming shader of 3D graphic system
US20100141653A1
