Image frame prediction method, electronic device and computer readable storage medium

By determining the difference in motion vectors and color values ​​between video frames and using the image frame prediction method, the problem of inaccurate video frame prediction in the existing technology is solved, and the video fluency and smoothness are improved.

CN116263971BActive Publication Date: 2024-10-18HUAWEI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111561106.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-15
Publication Date
2024-10-18
Estimated Expiration
2041-12-15

AI Technical Summary

Technical Problem

It is difficult for existing technology to accurately predict video frames, resulting in poor video fluency and smoothness, especially when high frame rate requirements are required.

Method used

By determining the difference in motion vectors and color values ​​between drawn frames, the image frame prediction method is used to accurately calculate the difference in motion vectors and depth values ​​for each pixel to generate more accurate predicted frames.

Benefits of technology

Improved video fluency and smoothness, reduced frame rate drops, and enhanced video display effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116263971B_ABST
    Figure CN116263971B_ABST
Patent Text Reader

Abstract

An embodiment of the present application provides a method for predicting an image frame, in which, when drawing a first drawing frame, the electronic device writes the drawing result of the drawing instruction that does not carry a dynamic identifier in the first drawing frame into the first color attachment and the first depth attachment in the first memory space; when drawing a second drawing frame, the electronic device writes the drawing result of the drawing instruction that does not carry a dynamic identifier in the second drawing frame into the second color attachment and the second depth attachment in the second memory space. Then, the electronic device determines the motion vector of the second color attachment based on the first color attachment and the second color attachment; the electronic device determines the color value of the third color attachment based on the second color attachment, the second depth attachment, and the motion vector of the second color attachment. Finally, the electronic device predicts the first predicted frame based on the third color attachment. In this way, the electronic device can predict the image frame more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to an image frame prediction method, electronic equipment and computer-readable storage medium. Background Art

[0002] With the continuous advancement of electronic technology, people's requirements for video fluency are also getting higher and higher. Generally speaking, the fluency of a video is related to the frame rate of the video. The higher the frame rate of the video, the better its fluency and smoothness. Therefore, in order to improve the fluency of the video, the image frame prediction can be performed based on the application's drawing frame to obtain a predicted frame, and the predicted frame can be inserted between the application's drawing frames. Therefore, how to accurately obtain the predicted frame is an urgent problem to be solved. Summary of the invention

[0003] The embodiments of the present application provide an image frame prediction method, an electronic device, and a computer-readable storage medium, which can obtain a predicted frame more accurately.

[0004] In a first aspect, an embodiment of the present application provides a method for predicting an image frame, the method comprising: when drawing a first drawing frame, the electronic device writes a drawing result of a drawing instruction that does not carry a dynamic identifier in the first drawing frame into a first color attachment and a first depth attachment in a first memory space; when drawing a second drawing frame, the electronic device writes a drawing result of a drawing instruction that does not carry a dynamic identifier in the second drawing frame into a second color attachment and a second depth attachment in a second memory space; the electronic device determines a motion vector of the second color attachment based on the first color attachment and the second color attachment; the electronic device determines a color value of a third color attachment based on the second color attachment, the second depth attachment, and the motion vector of the second color attachment, wherein the third color attachment is in a third memory space; the electronic device predicts a first predicted frame based on the third color attachment.

[0005] In implementing the method provided in the first aspect, the electronic device determines the motion vector of the second color attachment by determining the motion vector of each pixel in the second color attachment. In this way, by calculating the motion vector of each pixel in the second color attachment, the problem of inaccurate motion vector can be avoided. Based on each pixel in the second color attachment and the motion vector of each pixel, the electronic device can determine the coordinates of each pixel in the second color attachment in the third color attachment, and then determine the color value in the third color attachment based on the difference in depth values ​​of the pixels corresponding to the same coordinates in the second color attachment and the third color attachment. In this way, when two pixels move to a coordinate in the third color attachment, the problem of incorrect prediction of the color value at the coordinate in the third color attachment can be avoided, and the first predicted frame can be obtained more accurately.

[0006] In combination with the first aspect, in a possible implementation, the second color attachment includes a first pixel and a second pixel, the first pixel is at a first coordinate in the second color attachment, and the second pixel is at a second coordinate in the second color attachment; the electronic device determines the color value of the third color attachment based on the second color attachment, the second depth attachment, and the motion vector of the second color attachment, specifically including: the electronic device determines, based on the motion vector of the second color attachment, that the first pixel moves from the first coordinate to a third coordinate in the third color attachment, and the second pixel moves from the second coordinate to a fourth coordinate in the third color attachment; the electronic device determines the color value of the pixel at the third coordinate in the third color attachment based on the depth value of the first pixel and the depth value of the third pixel at the third coordinate in the second depth attachment; the electronic device determines the color value of the pixel at the fourth coordinate in the third color attachment based on the depth value of the second pixel and the depth value of the fourth pixel at the fourth coordinate in the second depth attachment.

[0007] In combination with the first aspect, in a possible implementation manner, the electronic device determines, based on the depth value of the first pixel and the depth value of the third pixel at the third coordinate in the second depth attachment, a color value of the pixel at the third coordinate in the third color attachment, specifically including:

[0008] At a first moment, the electronic device determines a first difference between a depth value of a first pixel and a depth value of a third pixel, and a second difference between a depth value of a second pixel and a depth value of a fourth pixel; the electronic device determines that the first difference is less than a first threshold value, and the second difference is greater than the first threshold value, and the electronic device sets a color value of a pixel at a third coordinate in a third color attachment as a color value of the first pixel, and a color value at a fourth coordinate in the third color attachment as an initial color value;

[0009] At a second moment, the electronic device determines a first difference between the depth value of the first pixel and the depth value of the third pixel, and a second difference between the depth value of the second pixel and the depth value of the fourth pixel; the second moment is later than the first moment;

[0010] The electronic device determines that the first difference is less than a first threshold and the second difference is greater than the first threshold. The electronic device determines that the color value of the pixel at the third coordinate in the third color attachment is the color value of the first pixel and the color value at the fourth coordinate in the third color attachment is the color value of the second pixel.

[0011] In combination with the first aspect, in a possible implementation manner, the second color attachment further includes a fifth pixel point, and the fifth pixel point is located at a fifth coordinate in the second color attachment; the electronic device determines that the fifth pixel point moves from the fifth coordinate to a second coordinate in the third color attachment;

[0012] After the electronic device sets the color value of the pixel at the third coordinate in the third color attachment as the color value of the first pixel, the electronic device further includes:

[0013] At the second moment, the electronic device determines the third difference between the depth value of the fifth pixel and the depth value of the first pixel; the electronic device determines that the third difference is greater than the first threshold, and the electronic device determines that the color value of the pixel at the third coordinate in the third color attachment is the color value of the fifth pixel.

[0014] In combination with the first aspect, in a possible implementation manner, before the electronic device determines that the color value at the third coordinate in the third color attachment is the color value of the first pixel, the method further includes: the electronic device sets the transparent channel of the pixel in the third color attachment in the third memory space to the first transparent value;

[0015] After the electronic device determines that the color value of the pixel at the third coordinate in the third color attachment is the color value of the first pixel, and the color value at the fourth coordinate in the third color attachment is the color value of the second pixel, the electronic device further includes:

[0016] The electronic device writes the color value of the first pixel at the third coordinate in the third color attachment, writes the color value of the second pixel at the fourth coordinate in the third color attachment, and sets the transparent channels of the pixels at the third coordinate and the fourth coordinate in the third color attachment to a second transparent value, where the first transparent value is different from the second transparent value;

[0017] At a third moment, the electronic device determines that a transparent channel in the third color attachment has one or more pixels with a first transparency value, and the first or more pixels include a sixth pixel;

[0018] The electronic device determines that the color of the sixth pixel is the first color value.

[0019] In combination with the first aspect, in a possible implementation, the sixth pixel is a pixel in the second depth attachment whose depth value is less than the first depth value, the first depth value is used to distinguish between foreground objects and distant objects in the second color attachment, and in the second color attachment, the depth value of the pixel included in the foreground object is less than the first depth value, and the depth value of the pixel included in the distant object is greater than the first depth value.

[0020] In combination with the first aspect, in one possible implementation, the sixth pixel is a pixel in the second depth attachment whose depth value is less than the second depth value, the coordinates of the sixth pixel in the third color attachment are the sixth coordinates, and the second depth value is the average of the depth values ​​within the first range of the sixth coordinate in the second depth attachment.

[0021] In combination with the first aspect, in a possible implementation manner, the electronic device determines a motion vector of the second color attachment based on the first color attachment and the second color attachment, specifically including:

[0022] The electronic device takes out the first pixel in the second color attachment; the electronic device calculates the seventh coordinate of the first pixel in the first color attachment; the electronic device determines the motion vector of the first pixel based on the seventh coordinate and the first coordinate of the first pixel in the second color attachment; the electronic device determines the motion vector of the second color attachment based on the motion vector of the first pixel.

[0023] In combination with the first aspect, in a possible implementation method, the electronic device calculates the seventh coordinate of the first pixel point in the first color attachment, specifically including: the electronic device obtains the first matrix and the second matrix in the drawing parameters of the first drawing frame and the third matrix and the fourth matrix of the drawing instructions in the second drawing frame, the first matrix is ​​used to describe the mapping relationship from the world coordinate system of the drawing object in the first drawing frame to the observation coordinate system, the second matrix is ​​used to describe the mapping relationship from the observation coordinate system of the drawing object in the first drawing frame to the clipping coordinate system, the third matrix is ​​used to describe the mapping relationship from the world coordinate system of the drawing object in the second drawing frame to the observation coordinate system, and the fourth matrix is ​​used to describe the mapping relationship from the observation coordinate system of the drawing object in the second drawing frame to the clipping coordinate system; the electronic device calculates the seventh coordinate of the first pixel point in the first color attachment based on the first matrix, the second matrix, the third matrix and the fourth matrix.

[0024] In combination with the first aspect, in a possible implementation, the method further includes: when drawing the first drawing frame, the electronic device writes the drawing result of the drawing instruction carrying the dynamic identifier in the first drawing frame into the fourth color attachment and the fourth depth attachment in the fourth memory space; when drawing the second drawing frame, the electronic device writes the drawing result of the drawing instruction carrying the dynamic identifier in the second drawing frame into the fifth color attachment and the fifth depth attachment in the fifth memory space; the electronic device determines the motion vector of the fifth color attachment based on the fourth color attachment and the fifth color attachment; the electronic device generates the sixth color attachment of the first predicted frame based on the fifth color attachment and the motion vector of the fifth color attachment; the electronic device predicts the first predicted frame based on the third color attachment, specifically including: the electronic device synthesizes the third color attachment and the sixth color attachment into the first predicted frame.

[0025] In a second aspect, an electronic device is provided, which may include: one or more processors and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute a method as in any possible manner of the first aspect.

[0026] In a third aspect, a chip system is provided. The chip system is applied to an electronic device, and the chip system includes one or more processors, and the processor is used to call computer instructions so that the electronic device executes any possible implementation method as in the first aspect.

[0027] In a fourth aspect, a computer-readable storage medium is provided, comprising instructions, characterized in that when the instructions are executed on an electronic device, the electronic device executes any possible implementation method in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments of the present application will be described below.

[0029] Figure 1 is a schematic diagram of a user interface 100 of a tablet computer 10 provided in an embodiment of the present application;

[0030] Figure 2 is a schematic diagram of a positional relationship provided in an embodiment of the present application;

[0031] Figure 3 It is a logic block diagram of a method for image frame prediction provided by an embodiment of the present application;

[0032] Figure 4A is a schematic diagram of an Nth drawing frame provided in an embodiment of the present application;

[0033] Figure 4B This is a schematic diagram of the N+2th drawing frame provided in an embodiment of the present application;

[0034] Figure 5 is a schematic diagram of calculating a motion vector of a static object provided by an embodiment of the present application;

[0035] Figure 6 is a schematic diagram of predicting distortion of an image frame provided by an embodiment of the present application;

[0036] Figure 7 is another schematic diagram of calculating the motion vector of a static object provided by an embodiment of the present application;

[0037] Figure 8 is a schematic diagram of determining position coordinates in the N+3th frame provided by an embodiment of the present application;

[0038] Fig. 9 is a flow chart of a method for image frame prediction provided by an embodiment of the present application;

[0039] Fig.10is a flow chart of a method for predicting the color value of a static object in the +3rd frame provided by an embodiment of the present application;

[0040] Fig.11 This is a schematic diagram of predicting the color value of a static object in the +3rd frame provided by an embodiment of the present application;

[0041] Fig.12 is a schematic diagram of determining position coordinates in the N+3th frame provided by an embodiment of the present application;

[0042] Fig.13 is a schematic diagram of filling a hole in an image frame provided by an embodiment of the present application;

[0043] Fig.14 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0044] Fig.15 It is a schematic diagram of the system framework of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0045] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear indication to the contrary in the context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items.

[0046] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features, and in the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more.

[0047] To facilitate understanding, the relevant terms and concepts involved in the embodiments of the present application are first introduced below.

[0048] 1. Image frame

[0049] In the embodiment of the present application, each frame of an image displayed on a display screen by an electronic device is referred to as an image frame. In the embodiment of the present application, an image frame may be an image frame of a certain application, may be a result drawn by the electronic device according to a drawing instruction of the application, or may be a predicted result predicted based on an existing drawing result. Figure 1As shown, the electronic device (ie, tablet computer 10) displays a user interface 100. At time T0, the Nth image frame is displayed in the user interface 100. The Nth image frame is a drawing frame. Figure 1 The timing diagram 101 shows the image frames that can be displayed by the electronic device from time T0 to time Tn.

[0050] 2. Draw the frame

[0051] In the embodiment of the present application, when an application is running, an electronic device draws an image frame according to the drawing instructions and drawing parameters of the application, which is called a drawing frame. The drawing instructions and drawing parameters of the application can be automatically generated by the application graphics framework or the application engine, or can be written by the application developer. The drawing parameters corresponding to the drawing frame can contain one or more objects. The electronic device can draw one or more objects into corresponding elements in the drawing frame. For example, Figure 1 The user interface 100 shown may be a drawing frame. The elements 102 and 103 in the user interface 100 are obtained by drawing and rendering the objects in the drawing parameters.

[0052] It is understandable that the drawing parameters of the drawing frame include properties of multiple objects. The properties of the object may include the color value of each pixel in the object (such as RGB value), the depth value of each pixel in the object, one or more of the template buffer (stencil buffer), the projection matrix, the observation matrix, etc. The CPU can send a drawing instruction to the GPU to instruct the GPU to perform drawing according to the drawing parameters. The GPU can draw an object according to a drawing instruction. The object drawn by the GPU according to the drawing instruction carrying a motion identifier can be called a moving object. The object drawn by the GPU according to the drawing instruction without a motion identifier can be called a static object. Among them, the motion identifier can be a transfer matrix or other forms.

[0053] Taking game applications as an example, static objects are stationary in the game scene, but the position of static objects in different image frames will be different due to changes in the camera's shooting angle. The position of elements in the user interface drawn and rendered by static objects can change between two adjacent image frames, and the size of the position change is related to the camera's shooting position and shooting angle. Moving objects will move in the game scene. The position of elements in the user interface drawn and rendered by moving objects changes between two adjacent image frames. Users can see that the position of the element is moving in the user interface.

[0054] In an embodiment of the present application, a frame of an image includes a distant object and a near object. The electronic device can determine whether the object is a distant object or a near object based on the depth value of each pixel in the object. Specifically, in a frame of an image, when the depth values ​​of all pixels contained in an object are greater than a first depth value, the object is called a distant object. When the depth values ​​of all pixels contained in an object are less than the first depth value, the object is called a near object. It can be understood that the smaller the depth value of the pixel, the closer it is to the camera, and the larger the depth value of the pixel, the farther it is from the camera. For example, a distant object can be Figure 1 The static hill 101. The foreground object can be Figure 1 The static small tree 102 in the.

[0055] 3. Prediction frame

[0056] In an embodiment of the present application, an image frame newly generated by an electronic device based on existing drawn image frame data is called a predicted frame. The drawing parameters of the predicted frame are obtained based on the drawing parameters of two drawn image frames. For example, the electronic device can generate a first predicted frame through a first drawn image frame and a second drawn image frame. The first predicted frame is an image frame after the second drawn image frame. That is, after the electronic device displays the second drawn image frame, it displays the first predicted frame. The first drawn image frame is an image frame before the second drawn frame (there may be an image frame between the first drawn image frame and the second drawn image frame). That is, the first drawn image frame is displayed on the display screen of the electronic device before the second drawn image frame. It can be understood that if the Nth image frame is a drawn image frame, then it can be called the Nth drawn frame in the embodiment of the present application. If the Nth image frame is a predicted frame, then it can be called the Nth predicted frame in the embodiment of the present application.

[0057] It can be understood that the objects included in the drawing parameters of the predicted frame are the same as the objects included in the drawing parameters of the drawing frame displayed one frame before the predicted frame. Here, the objects included in the drawing parameters of the image frame can be referred to as the objects included in the image frame. For example, the objects included in the drawing parameters of the predicted frame can be referred to as the objects included in the predicted frame.

[0058] It should be noted that the position of the frame to be predicted can be determined according to the application scenario and user needs, for example Figure 2 As shown in (a), in order to improve the frame rate of the game, the electronic device can generate a subsequent frame image of the previous two frames according to the previous two frames. This method can avoid the game delay being too long. For example, Figure 2 As shown in (b), when processing a video without real-time requirements, the electronic device can generate an intermediate image based on two adjacent video frames. The predicted frame generated by this method is more accurate.

[0059] Here, the specific process of the electronic device generating a prediction frame through two drawing frames can be referred to below and will not be described in detail here.

[0060] 4. Color attachment

[0061] In the embodiment of the present application, a color attachment is a memory space used to store color data of each pixel in a drawing result (eg, RGB value of a pixel) when the electronic device draws according to a drawing instruction.

[0062] 5. Depth attachment

[0063] In an embodiment of the present application, a depth attachment is a memory space used to store the depth data of each pixel in the drawing result when the electronic device draws according to the drawing instruction. It can be understood that the smaller the depth value of the pixel in the depth attachment, the closer it is to the camera. When synthesizing image frames, for two pixels with equal coordinate values ​​in two color attachments, the pixel with a smaller depth value can cover the other pixel with a larger depth value. That is, the color displayed by the pixel on the final display screen is the color of the pixel with a smaller depth value in the two color attachments.

[0064] The following will describe in detail a method for image frame prediction provided by an embodiment of the present application in conjunction with the accompanying drawings. First, Figure 3 The method for predicting an image frame provided by an embodiment of the present application exemplarily shows a process in which an electronic device draws an Nth drawing frame, an N+2th drawing frame, and obtains an N+3th predicted frame.

[0065] Figure 3 Figure (a) shows an exemplary process of the electronic device drawing the Nth drawing frame. Figure 3 As shown in FIG. 1 (a), the electronic device drawing the Nth drawing frame may include the following steps:

[0066] 301. The electronic device obtains a drawing instruction of the Nth drawing frame and determines whether the drawing instruction carries a dynamic flag. If so, execute 302a; if not, execute 302b.

[0067] Specifically, when the target application in the electronic device is drawing, the target application can call the drawing instruction to draw. The CPU of the electronic device can obtain the drawing parameters of the Nth drawing frame of the application through the interface in the three-dimensional image processing library. The drawing parameters of the Nth drawing frame are used to draw and render the Nth drawing frame. The drawing parameters of the Nth drawing frame may include information carried in the drawing instruction (such as a draw call instruction) of the Nth drawing frame, such as the coordinates of each vertex in the drawing content of the draw call instruction, pixel values, depth values, and other information.

[0068] The CPU of the electronic device may send a drawing instruction to the GPU for instructing the GPU to draw the Nth drawing frame according to the drawing parameters of the Nth drawing frame. It is understandable that the drawing parameters of the Nth drawing frame obtained by the CPU may include information of multiple drawing instructions. In this way, the CPU may sequentially send multiple drawing instructions to the GPU for instructing the GPU to draw the Nth drawing frame.

[0069] The GPU of the electronic device can draw an object according to a drawing instruction sent by the CPU. It can be understood that after the GPU of the electronic device draws a drawing instruction, it draws another drawing instruction of the Nth drawing frame until all the drawing instructions of the Nth drawing frame are drawn.

[0070] The drawing instructions of the Nth drawing frame may include drawing instructions carrying dynamic identifiers and drawing instructions without dynamic identifiers. If the drawing instructions carry a motion identifier, the object drawn by the GPU of the electronic device according to the drawing instructions is a moving object. If the drawing instructions do not carry a motion identifier, the object drawn by the GPU of the electronic device according to the drawing instructions is a static object. The motion identifier may be a transfer matrix, etc.

[0071] For example, Figure 4A As shown in (a), Figure 4A (a) shows an Nth drawing frame by way of example, and the Nth drawing frame may include a static hill 101, a static tree 102, and a moving car 103. The drawing instructions of the Nth drawing frame may include a drawing instruction for drawing the static hill 101, a drawing instruction for drawing the static tree 102, and a drawing instruction for drawing the moving car 103. The drawing instruction for drawing the static hill 101 may not carry a dynamic identifier, and the object drawn by the CPU of the electronic device according to the drawing instruction is a static object.

[0072] The GPU of an electronic device can store moving objects and static objects separately. For example, if the drawing content of a drawing instruction is a dynamic object, the GPU of the electronic device draws the drawing content of the drawing instruction in the memory space H1. The memory space H1 can be referred to as D1 FBO (dynamic frame buffer object). If the drawing content of a drawing instruction is a static object, the GPU of the electronic device draws the drawing content of the drawing instruction in the memory space H2. The memory space H2 can be referred to as S1 FBO (static frame buffer object). Here, the frame buffer object FBO is a piece of memory space that can be used to store color data, depth data, etc. of a drawing object.

[0073] Among them, memory space H1 and memory space H2 are created by the GPU of the electronic device according to the instructions of the CPU. When the target application starts to draw, the CPU of the electronic device sends an instruction to the GPU to instruct the GPU to create memory space. The target application is an application with animation effects in the user interface, such as a game application. The embodiments of the present application are explained below using the target application as a game application as an example. When the game application installed in the electronic device is running, the CPU of the electronic device sends an instruction to the GPU to instruct the GPU to create memory space. The GPU responds to the instruction sent by the CPU to instruct the GPU to create memory space, and the GPU can create memory space H1 and a second memory space H2 in the memory.

[0074] In some optional embodiments, the GPU of the electronic device may store the moving objects and the static objects together, that is, the GPU of the electronic device draws the drawing contents of all drawing instructions in the memory space H1. There may be multiple drawing instructions for the drawing contents in the first drawing frame, and the GPU of the electronic device may sequentially write the color values ​​of the drawing contents of the multiple drawing instructions into the color attachment A, and sequentially write the depth values ​​of the drawing contents of the multiple drawing instructions into the depth attachment A. The GPU of the electronic device may add a mark to each pixel in the color attachment A, and the mark may be a numerical value G1 or a numerical value G2. If the mark of the pixel is the numerical value G1, it indicates that the object corresponding to the pixel is a dynamic object. If the mark of the pixel is the numerical value G2, it indicates that the object corresponding to the pixel is a static object. The numerical value G1 and the numerical value G2 are not the same. For example, the numerical value G1 may be 1, and the numerical value G2 may be 0. The embodiment of the present application does not limit the specific values ​​of the numerical values ​​G1 and G2.

[0075] Among them, the tag can be written into the depth attachment, or into the template attachment, or an additional attachment storage can be generated, and this application does not impose any restrictions on this.

[0076] 302a. The electronic device writes the drawing content of the drawing instruction into the color attachment A and the depth attachment A in the memory space H1.

[0077] Specifically, if the drawing content of the drawing instruction of the Nth drawing frame is a dynamic object, the GPU of the electronic device writes the drawing content of the drawing instruction into the color attachment A and the depth attachment A in the memory space H1. There may be multiple drawing instructions in the Nth drawing frame, and the drawing content of the multiple drawing instructions is a dynamic object. The GPU of the electronic device may draw the drawing content of the multiple drawing instructions into the color attachment A and the depth attachment A in sequence.

[0078] For example, Figure 4A As shown in (b), Figure 4A (b) shows the color attachment A and the depth attachment A in the memory space H1. The drawing contents of the drawing instructions of the moving car 103 are written in the color attachment A and the depth attachment A. It can be understood that the color attachment A is actually a memory space in the memory. Figure 4A In (b), the color data in the memory space is shown in the form of image ratio for the sake of visual understanding. Similarly, the depth attachment A is actually a piece of memory space in the memory. Figure 4A In (b), for the sake of visual understanding, the depth data in the memory space is schematically displayed in the form of image ratio.

[0079] 302b. The electronic device writes the drawing content of the drawing instruction into the color attachment B and the depth attachment B in the memory space H2.

[0080] Specifically, if the drawing content of the drawing instruction of the Nth drawing frame is a static object, the GPU of the electronic device writes the drawing content of the drawing instruction into the color attachment B and the depth attachment B in the memory space H2. There may be multiple drawing instructions in the Nth drawing frame, and the drawing content of the multiple drawing instructions is a static object. The GPU of the electronic device may draw the drawing content of the multiple drawing instructions into the color attachment B and the depth attachment B in sequence.

[0081] like Figure 4A As shown in (c), Figure 4A (c) shows the color attachment B and the depth attachment B of the memory space H2 by way of example. The color attachment B and the depth attachment B contain the drawing contents of the drawing instructions of the static hill 101 and the drawing contents of the drawing instructions of the static tree 102. It can be understood that the color attachment B is actually a piece of memory space in the memory. Figure 4A In (c), the color data in the memory space is shown in the form of image ratio for the sake of visual understanding. Similarly, the depth attachment B is actually a memory space in the memory. Figure 4AIn (c), for the sake of visual understanding, the depth data in the memory space is schematically displayed in the form of image ratio.

[0082] It can be understood that color attachment A and depth attachment A can be two separate memory spaces in memory space H1. Optionally, color attachment A and depth attachment A can also be a memory space in memory space H1, that is, color data and depth data can be written into this memory space. Similarly, color attachment B and depth attachment B can be two separate memory spaces in memory space H2. Optionally, color attachment B and depth attachment B can also be a memory space in memory space H2, that is, color data and depth data can be written into this memory space.

[0083] 303. The electronic device combines the color attachment A and the color attachment B according to the depth attachment A and the depth attachment B to form an image frame of the Nth rendering frame.

[0084] Specifically, the GPU of the electronic device may synthesize the color attachment A and the color attachment B into an image frame of the Nth drawing frame in the memory space H7. It is understandable that the color attachment A may include multiple dynamic objects in the Nth drawing frame, and the color attachment B may include multiple static objects in the Nth drawing frame. The memory space H7 is generated by the GPU of the electronic device according to the instruction of the CPU of the electronic device.

[0085] The GPU of the electronic device can obtain the depth information of each dynamic object and each pixel in the color attachment A in the depth attachment A. The GPU of the electronic device can obtain the depth information of each static object and each pixel in the color attachment B in the depth attachment B. The electronic device can synthesize the color attachment A and the color attachment B into an image frame according to the depth information of each pixel in the color attachment A and the depth information of each pixel in the color attachment B.

[0086] 304. The electronic device displays the Nth drawing frame.

[0087] The electronic device may send the image frame of the Nth drawing frame to the display screen for display, and finally, the display screen in the electronic device may display the Nth drawing frame.

[0088] Figure 3 Figure (b) shows an exemplary process of the electronic device drawing the N+2th drawing frame. Figure 3 As shown in FIG. 5( b ), the electronic device drawing the N+2th drawing frame may include the following steps:

[0089] 305. The electronic device obtains the drawing instruction of the N+2th drawing frame and determines whether the drawing instruction carries a dynamic flag. If so, execute 306a; if not, execute 306b.

[0090] Specifically, the CPU of the electronic device can obtain the drawing parameters of the N+2th drawing frame, and the CPU of the electronic device can send a drawing instruction to the GPU to instruct the GPU to draw the N+2th drawing frame according to the drawing parameters of the N+2th drawing frame. It can be understood that the drawing parameters of the N+2th drawing frame obtained by the CPU may include information of multiple drawing instructions. In this way, the CPU can sequentially send multiple drawing instructions to the GPU to instruct the GPU to draw the N+2th drawing frame. Here, please refer to the description in step 301 for details, which will not be repeated here.

[0091] The drawing instructions of the N+2th drawing frame may include drawing instructions carrying dynamic flags and drawing instructions without dynamic flags. If the drawing instructions carry dynamic flags, step 306a is executed; if the drawing instructions do not carry dynamic flags, step 306b is executed.

[0092] like Figure 4B As shown in (a), Figure 4B (a) shows the N+2th drawing frame by way of example, and the N+2th drawing frame may include a static hill 101, a static tree 102, and a moving car 103. The drawing instructions of the N+2th drawing frame may include a drawing instruction for drawing the static hill 101, a drawing instruction for drawing the static tree 102, and a drawing instruction for drawing the moving car 103. The drawing instruction for drawing the static hill 101 may not carry a dynamic identifier, and the object drawn by the CPU of the electronic device according to the drawing instruction is a static object.

[0093] 306a. The electronic device writes the drawing content of the drawing instruction into the color attachment C and the depth attachment C in the memory space H3.

[0094] If the drawing content of the drawing instruction is a dynamic object, the GPU of the electronic device writes the drawing content of the drawing instruction into the color attachment C and the depth attachment C in the memory space H3.

[0095] For example, Figure 4B As shown in (b), Figure 4B (b) shows the color attachment A and the depth attachment A in the memory space H3 by way of example. The drawing contents of the drawing instructions of the moving car 103 are written in the color attachment A and the depth attachment A. It can be understood that the color attachment A is actually a piece of memory space in the memory. Figure 4B In (b), the color data in the memory space is shown in the form of image ratio for the sake of visual understanding. Similarly, the depth attachment A is actually a piece of memory space in the memory. Figure 4B In (b), for the sake of visual understanding, the depth data in the memory space is schematically displayed in the form of image ratio.

[0096] 306b. The electronic device writes the drawing content of the drawing instruction into the color attachment D and the color attachment D in the memory space H4.

[0097] If the drawing content of the drawing instruction of the N+2th drawing frame is a static object, the GPU of the electronic device writes the drawing content of the drawing instruction into the color attachment D and the depth attachment D in the memory space H4.

[0098] like Figure 4B As shown in (c), Figure 4B (c) shows the color attachment B and the depth attachment B of the memory space H4 by way of example. The color attachment B and the depth attachment B contain the drawing contents of the drawing instructions of the static hill 101 and the drawing contents of the drawing instructions of the static tree 102. It can be understood that the color attachment B is actually a piece of memory space in the memory. Figure 4B In (c), the color data in the memory space is shown in the form of image ratio for the sake of visual understanding. Similarly, the depth attachment B is actually a memory space in the memory. Figure 4B In (c), for the sake of visual understanding, the depth data in the memory space is schematically displayed in the form of image ratio.

[0099] 307 . The electronic device combines the color attachment C and the color attachment D according to the depth attachment C and the depth attachment D to form an image frame of the N+2 th rendering frame.

[0100] The GPU of the electronic device can synthesize the color attachment C and the color attachment D into an image frame of the N+2th drawing frame in the memory space H7. It can be understood that the color attachment C can include multiple moving objects in the N+2th drawing frame, and the color attachment D can include multiple static objects in the N+2th drawing frame. The GPU of the electronic device can obtain the depth information of each moving object and each pixel in the color attachment C in the depth attachment C. The GPU of the electronic device can obtain the depth information of each static object and each pixel in the color attachment D in the depth attachment D. The GPU of the electronic device can synthesize the color attachment C and the color attachment D into an image frame according to the depth information of each pixel in the color attachment C and the depth information of each pixel in the color attachment D. The image frame can include moving objects in the color attachment C and static objects in the color attachment D.

[0101] 308. The electronic device displays the N+2th drawing frame.

[0102] The electronic device may send the image frame of the N+2th drawing frame to the display screen for display. Finally, the display screen in the electronic device may display the N+2th drawing frame.

[0103] Figure 3 Figure (c) shows an example of how the electronic device predicts the N+3th prediction frame. Figure 3 As shown in Figure (c) in the figure, the process is as follows:

[0104] 309. The electronic device calculates a motion vector A based on color attachment A and color attachment C.

[0105] Specifically, the CPU of the electronic device may send an instruction to the GPU for instructing the GPU to calculate the motion vector. The instruction is used to instruct the shader in the GPU to calculate the motion vector. For example, the instruction may be a dispatch instruction. The embodiment of the present application does not limit the specific form of the instruction for calculating the motion vector.

[0106] The GPU of the electronic device uses color attachment A to calculate a motion vector A of color attachment C of the N+2th rendering frame.

[0107] like Figure 3 As shown in Figure (c), the electronic device can calculate the motion vector A based on the color attachment A of the Nth frame and the color attachment C of the N+2th frame.

[0108] In a possible implementation, the process of the electronic device calculating the motion vector A includes:

[0109] 1. The GPU of the electronic device divides the color attachment C of the N+2th frame into Q pixel blocks. Each pixel block may contain f*f (e.g., 16*16) pixels.

[0110] 2. The GPU of the electronic device takes the first pixel block in the color attachment C, and searches for a matching pixel block that matches the first pixel block in the color attachment A of the Nth drawing frame.

[0111] Among them, the candidate block with the smallest absolute difference in RGB value with the first pixel block among all the candidate blocks in the Nth frame is called a matching pixel block that matches the first pixel block. The electronic device needs to find a matching pixel block that matches the first pixel block in the Nth drawing frame. Optionally, the electronic device can find a matching pixel block that matches the first pixel block in the Nth drawing frame through a diamond search algorithm. The diamond search algorithm can be specifically described in the prior art and will not be repeated here.

[0112] 3. The GPU of the electronic device calculates a first displacement from the matching pixel block to the first pixel block, and determines a motion vector A1 of the first pixel block according to the first displacement.

[0113] 4. The GPU of the electronic device can calculate the motion vector of each of the Q pixel blocks in the color attachment C according to the above steps 1 to 3, that is, A1, A2, ..., AQ. The motion vector of the color attachment C is A = (A1, A2, ..., AQ).

[0114] 310. The electronic device calculates a motion vector B based on the color attachment B and the color attachment D.

[0115] like Figure 3 As shown in FIG. 1( c ), the GPU of the electronic device can calculate the motion vector B based on the color attachment B of the Nth frame and the color attachment D of the N+2th frame. That is, the electronic device can calculate the motion vector of the static object based on the static object in the Nth frame and the static object in the N+2th frame.

[0116] The specific calculation process of the GPU of the electronic device calculating the motion vector B based on the color attachment B and the color attachment D can be referred to Figure 5 The description in the embodiments will not be repeated here.

[0117] 311. The electronic device obtains color attachment E based on color attachment C and motion vector A.

[0118] The GPU of the electronic device can obtain the color attachment E of the N+3 prediction frame based on the color attachment C of the N+2 rendering frame and the motion vector A. That is, the electronic device can predict the moving object in the N+3 frame based on the moving object of the N+2 rendering frame and the motion vector of the moving object.

[0119] 312. The electronic device obtains color attachment F based on color attachment D and motion vector B.

[0120] Specifically, the GPU of the electronic device can obtain the color attachment F of the N+3th frame based on the color attachment D of the N+2th rendering frame and the motion vector B. In other words, the electronic device can predict the static object in the N+3th frame based on the static object and the motion object of the static object in the N+2th rendering frame.

[0121] 313. The electronic device combines the color attachment E and the color attachment F into an image frame of the N+3th prediction frame in the memory space H7.

[0122] In an embodiment of the present application, the depth information of the pixel at the first coordinate in the color attachment E of the N+3 prediction frame may be the same as the depth information of the pixel at the first coordinate in the color attachment C of the N+2 drawing frame. The depth information of the pixel at the second coordinate in the color attachment F of the N+3 prediction frame may be the same as the depth information of the pixel at the second coordinate in the color attachment D of the N+2 drawing frame. That is to say, the electronic device may use the depth value of each pixel in the depth attachment C as the depth value of each pixel in the color attachment E. The electronic device may use the depth value of each pixel in the depth attachment D as the depth value of each pixel in the color attachment F. The electronic device may synthesize the color attachment E and the color attachment F into the image frame of the N+3 prediction frame according to the depth values ​​of the pixels taken out from the depth attachment C and the depth attachment D.

[0123] 314. The electronic device displays the N+3th predicted frame.

[0124] The electronic device can send the image frame of the N+3th prediction frame to the display screen for display, and finally, the display screen in the electronic device can display the N+3th prediction frame.

[0125] In one possible implementation, Figure 5 The process of how the electronic device calculates the motion vector B is shown as an example. Figure 5 As shown, the process of the electronic device calculating the motion vector B is as follows:

[0126] 3101. The electronic device divides the color attachment D of the N+2th frame into L pixel blocks. Each pixel block may include f*f (for example, 16*16) pixels.

[0127] For example, see Figure 5 In (a), see Figure 5 (a) shows the color attachment D of the N+2 frame by way of example. Figure 5 As shown in (a) of FIG. 1 , the color attachment D includes a static hill 101 and a static tree 102. Figure 5 As shown in (b), the electronic device divides the color attachment D of the N+2th frame into 64 pixel blocks.

[0128] 3102. The electronic device obtains drawing parameters of the Nth frame and the N+2th frame.

[0129] Specifically, when the electronic device draws the Nth frame, it can obtain the observation matrix V1 and the projection matrix P1 of the Nth frame. When the electronic device draws the N+2th frame, it can obtain the observation matrix V2 and the projection matrix P2 of the N+2th frame.

[0130] The observation matrix V1 and the projection matrix P1 can be directly obtained by the GPU through the hook glBufferSubData interface when the electronic device draws the Nth frame. The observation matrix V2 and the projection matrix P2 can be directly obtained by the GPU through the hook glBufferSubData interface when the electronic device draws the N+2th frame.

[0131] In an embodiment of the present application, the observation matrix is ​​a conversion matrix between the world space and the observation space (cameraspace). For example, the coordinates of pixel point 1 in the drawing instruction of the Nth frame can be converted from the coordinates in the world space to the coordinates in the observation space through the observation matrix. The projection matrix is ​​a conversion matrix between the observation space and the clipping space (clipspace). For example, the coordinates of pixel point 1 can be converted from the coordinates in the observation space to the coordinates in the clipping space through the projection matrix. The world space is the corresponding space under the world coordinates. The observation space is the space corresponding to the camera coordinate system (a coordinate system constructed with the camera as the coordinate origin). The positions of objects described in the observation space are all positions under the camera coordinates. The clipping space specifies the coordinate range of objects that can be displayed on the display screen of the electronic device.

[0132] 3103. The electronic device obtains a transformation matrix T between the Nth frame and the N+2th frame based on the observation matrix V1, the projection matrix P1, the observation matrix V2 and the projection matrix P2.

[0133] Among them, the position coordinates of static objects in the world coordinate system are unchanged. For example, in a game application, although static objects in the game screen will move with the movement of the camera's perspective, these static objects will not move with the movement of the camera's perspective in the world coordinate system.

[0134] In the Nth frame, the position coordinates of the first pixel in the world coordinate system are Xw. According to the observation matrix V1 and the projection matrix P1, the coordinates of the first pixel in the observation coordinate system can be obtained as:

[0135] X c1 =P1·V1·X w

[0136] Since the position coordinates of the static object in the world coordinate system are unchanged, the position coordinates of the first pixel in the world coordinate system in the N+2th frame are Xw. According to the observation matrix V2 and the projection matrix P2, the position coordinates of the first pixel in the observation coordinate system in the N+2th frame can be obtained as:

[0137] X c2 =P2·V2·X w

[0138] The pixel point a in the Nth frame and the pixel point in the N+2th frame are the same pixel, and the position coordinates of the pixel point a in the Nth frame and the N+2th frame in the world coordinate system are the same.

[0139] The electronic device can obtain the conversion matrix from the Nth frame to the N+2th frame as:

[0140] T=(P1·V1) -1 ·(P2·V2)

[0141] Among them, (P1V1)-1 is the inverse matrix of (P1V1).

[0142] 3104. The electronic device obtains the first vertex of the second pixel block and the position 2 of the first vertex of the second pixel block in the N+2 frame in the color attachment D of the N+2 frame, and obtains the depth value D2 of the first vertex of the second pixel block in the depth attachment D.

[0143] 3105. The electronic device calculates the position position1 of the first vertex of the second pixel block in the Nth rendering frame using the position position2 of the first vertex of the second pixel block, the depth value D2, and the matrix T. Then the motion vector B1 of the first vertex of the second pixel block = position2-position1.

[0144] The electronic device can calculate the motion vectors B1, B2, ..., B4L of the four vertices of each pixel block in the color attachment D according to the step of calculating the motion vector of the first vertex of the second pixel block, and obtain the motion vector B of the color attachment D = (B1, B2, ..., B4L).

[0145] Next, combine Figure 5 The example introduces a specific process of an electronic device obtaining a color attachment F based on the color attachment D and the motion vector B:

[0146] 3106. The electronic device determines the motion vectors of the pixels in the third pixel block based on the motion vectors of the vertices of the third pixel block.

[0147] Specifically, the electronic device performs linear interpolation on the motion vectors of four vertices included in the third pixel block to obtain the motion vectors of the pixel points in the third pixel block.

[0148] For example, see Figure 5 , Figure 5 The process of predicting the color attachment F based on the color attachment D is shown as an example. In order to better illustrate the situation of predicting the color attachment F, the area 501 in the color attachment D is taken as an example. After the area 501 in the color attachment D is enlarged, it can be seen as follows Figure 5As shown in (c), the dark area is a small tree, and the light area is the background in the distance. Figure 5 As shown in (c), pixel block A includes four vertices: vertex a1, vertex a2, vertex a3, and vertex a4. The electronic device obtains the motion vectors of the four vertices of pixel block A based on the observation matrix and the projection matrix, wherein the motion vector of vertex a1 is Mv'a=(0,0), the motion vector of vertex a2 is Mv'a2=(0,0), the motion vector of vertex a3 is Mv'a3=(-4,0), and the motion vector of vertex a4 is Mv'a4=(-4,0). The electronic device performs linear interpolation on the motion vectors of the four vertices of pixel block A, and obtains that the motion vector of pixel point b1 in pixel block A is (-1,0), and the motion vector of pixel point b2 in pixel block A is (-1,0).

[0149] The electronic device can calculate the motion vector of each pixel point of each pixel block in the color attachment D according to the step of calculating the motion vector of the pixel point b1 and the pixel point b2 in the third pixel block.

[0150] 3107. The electronic device obtains color attachment F based on color attachment D and the motion vector of each pixel in color attachment D.

[0151] Specifically, the electronic device obtains the coordinates of a pixel point in the color attachment F for a pixel point at a coordinate in the color attachment D and a motion vector of the pixel point.

[0152] For example, Figure 5 As shown in (c), the coordinates of pixel b1 in pixel block A in color attachment D are (x1, y1), the motion vector of pixel b1 is (-1, 0), and the coordinates of pixel b2 in color attachment D are (x2, y2). The motion vector of pixel b2 is (-1, 0). Figure 5 As shown in (d), the electronic device can obtain the positions of pixel 1 and pixel 2 in color attachment F as (x1', y1') and (x2', y2').

[0153] The electronic device can calculate the position coordinates of each pixel point of each pixel block in the color attachment D in the color attachment F according to the steps of calculating the position coordinates of the pixel point b1 and the pixel point b2 in the color attachment F to obtain the color attachment F.

[0154] The electronic device first divides the N+2 frame into multiple pixel blocks, and then calculates the motion vectors of the four vertices of each pixel block in the N+2 frame based on the N frame and the N+2 frame. For a pixel block in the N+2 frame, the electronic device determines the coordinates of the four vertices of the pixel block in the N+3 frame based on the motion vectors of the four vertices of the pixel block. Finally, the electronic device determines the coordinates of the pixels of the third pixel block in the N+3 frame based on the coordinates of the four vertices of the pixel block in the N+2 frame and the coordinates in the N+3 frame. However, when the motion vectors of the four vertices of the pixel block are very different, the calculated motion vector will be inaccurate. This will cause distortion in the predicted image frame.

[0155] For example, Figure 5 As shown in (c), vertices a1 and a2 are pixels contained in the static hill 101, that is, vertices a1 and a2 are distant objects, and the motion vectors of distant objects are both (0, 0). Vertex c and vertex d are pixels contained in the static tree 102, that is, vertices c and d are near objects, and the motion vectors of near objects are both (-4, 0). Figure 5 As shown in (c), pixel b2 is a pixel included in the static tree 102, and its motion vector should be (-4, 0). However, the electronic device can obtain the motion vectors of pixel b1 and pixel b2 as (-1, 0) based on the motion vectors based on the four vertices. Therefore, when the electronic device determines the coordinates of pixel b2 in color attachment F according to the motion vector (-1, 0), pixel b2 will deviate from the actual coordinates, resulting in image distortion. Figure 6 As shown in , the electronic device can obtain a color attachment F based on the above method, wherein the edge of the static correspondence 102 in the color attachment F is distorted.

[0156] In order to solve the problem of distortion at the edge of the above-mentioned image, in a possible implementation, the electronic device can calculate a motion vector based on the color attachment D of the N+2th frame and each pixel in it. For example, the Nth frame includes m pixels, and the electronic device calculates the motion vectors of the m pixels, and can obtain the motion vector B of the pixel = (B1, B2...Bm). Based on the motion vector B, the electronic device can obtain the position coordinates of each pixel in the color attachment D of the N+2th frame in the color attachment E of the N+3th frame. Based on the color attachment D and the position coordinates of each pixel in the color attachment D in the color attachment F, the electronic device can obtain the color attachment F.

[0157] The electronic device may obtain the color attachment F based on the color attachment D and the position coordinates of each pixel in the color attachment D in the color attachment F, which may specifically include some or all of the following steps:

[0158] 401. The electronic device obtains drawing parameters of the Nth frame and the N+2th frame.

[0159] Please refer to the relevant operations of the above step 3102 for details, which will not be repeated here.

[0160] 402. The electronic device obtains a transformation matrix T between the Nth frame and the N+2th frame based on the observation matrix V1, the projection matrix P1, the observation matrix V2, and the projection matrix P2.

[0161] For details on the operations of the electronic device to obtain the conversion matrix T, refer to the operations of step 3103 above, which will not be described in detail here.

[0162] In an embodiment of the present application, the first matrix may be referred to as an observation matrix V1, the second matrix may be referred to as a projection matrix P1, the third matrix may be referred to as an observation matrix V2, and the fourth matrix may be referred to as a projection matrix P2.

[0163] 403 . The electronic device obtains a second pixel point in the color attachment D and a position 4 (x4, y4) of the second pixel point in the color attachment D, and obtains a depth value D2 of the second pixel point in the depth attachment D.

[0164] 404. The electronic device calculates the position position3 (x3, y3) of the second pixel block in the color appendix B using the position position4 (x4, y4) of the second pixel point, the depth value D2, and the transformation matrix T. Then the motion vector B1 of the second pixel block = position4-position3.

[0165] The electronic device can calculate the motion vector B1, B2, ..., Bm of each pixel in the color attachment D according to the step of calculating the motion vector of the second pixel. The motion vector B of the color attachment D = (B1, B2, ..., Bm).

[0166] For example, see Figure 7 , Figure 7 The process of calculating the motion vector B of the color attachment D by the electronic device is exemplified. Figure 7 (a) shows the color annex B, as Figure 7 As shown in (a), the color attachment B includes a pixel 1011 in the static hill 101 and a pixel 1021 in the static tree 102. Figure 7 (b) shows a color attachment D, which includes a pixel 1012 in the static hill 101 and a pixel 1022 in the static tree 102. Among them, the pixel 1011 and the pixel 1012 are the same pixel, and the pixel 1021 and the pixel 1022 are the same pixel. Figure 7As shown in (c), the position coordinates of pixel 1011 and pixel 1021 in color appendix B are (x3, y3) and (x4, y4), respectively. Figure 7 As shown in (d), the electronic device can obtain the position coordinates (x4', y4') of the pixel 1011 in the color attachment F and the position coordinates (x3', y3') of the pixel 1021 in the color attachment F based on the transformation matrix T. Therefore, the motion vector of the pixel 1012 can be obtained as Mv=(-1, 0), and the motion vector of the pixel 1022 can be obtained as Mv=(-5, 0).

[0167] The electronic device can obtain the color attachment E of the N+3th frame based on the color attachment D and the motion vector B of each pixel in the color attachment D. In this way, by calculating the motion vector of each pixel, image distortion can be avoided.

[0168] In actual applications, when the camera moves to the left, the object in the camera's field of view is equivalent to moving to the right. According to the camera shooting principle, during the camera movement, the movement of the distant view and the near view in the camera's field of view are inconsistent, that is, the distant view moves more than the near view, that is, in two adjacent frames, the motion vectors of the distant view object and the near view object are different. In this way, when obtaining the color attachment F based on the color attachment D and the motion vector of each pixel in the color attachment D, it will cause two pixels in the color attachment D to correspond to a position coordinate in the color attachment F, which will cause the color value at the position coordinate in the color attachment F to be wrong.

[0169] For example, Figure 8 As shown, for the pixel point 1032 in the static hill 101, the position coordinates in the color attachment D are (x5, y5), and the calculated motion vector is Mv=(-1, 0), and the coordinates of the pixel point 1032 in the color attachment F are (x7, y7); the pixel point 1022 in the static tree 102, the position coordinates in the color attachment D are (x6, y6), and the calculated motion vector is Mv=(-4, 0), and the coordinates of the pixel point 1022 in the color attachment F are (x7, y7). It can be known that, Figure 8 As shown in (b), the pixel 1032 and the pixel 1022 have the same coordinates in the color attachment F. The electronic device writes both the pixel 1032 and the pixel 1022 into the coordinate (x7, y7) in the color attachment F. When the color value written first at the coordinate (x7, y7) in the color attachment F is the color value of the pixel 1022, and the color value written later is the color value of the pixel 1032, the pixel 1032 written later will overwrite the color value of the pixel 1022 written earlier, thus causing a prediction error at the coordinate (x7, y7) in the color attachment F.

[0170] Therefore, an embodiment of the present application provides a frame prediction method, an electronic device, and a computer-readable storage medium, in which: first, when drawing a first drawing frame, the electronic device writes the drawing result of the drawing instruction that does not carry a dynamic identifier in the first drawing frame into the first color attachment and the first depth attachment in the first memory space; when drawing a second drawing frame, the electronic device writes the drawing result of the drawing instruction that does not carry a dynamic identifier in the second drawing frame into the second color attachment and the second depth attachment in the second memory space; then, the electronic device determines a motion vector of the second color attachment based on the first color attachment and the second color attachment; the electronic device determines a color value of a third color attachment based on the second color attachment, the second depth attachment, and the motion vector of the second color attachment, wherein the third color attachment is in the third memory space; finally, the electronic device predicts a first predicted frame based on the third color attachment.

[0171] The electronic device determines the motion vector of the second color attachment by determining the motion vector of each pixel in the second color attachment. In this way, by calculating the motion vector of each pixel in the second color attachment, the problem of inaccurate motion vector can be avoided. Based on each pixel in the second color attachment and the motion vector of each pixel, the electronic device can determine the coordinates of each pixel in the second color attachment in the third color attachment, and then determine the color value in the third color attachment based on the difference in depth values ​​of the pixels corresponding to the same coordinates in the second color attachment and the third color attachment. In this way, when two pixels move to a coordinate in the third color attachment, the problem of incorrect prediction of the color value at the coordinate in the third color attachment can be avoided, and the first predicted frame can be obtained more accurately.

[0172] A method for image frame prediction provided by an embodiment of the present application will be described in detail below with reference to the accompanying drawings. Fig. 9 The process of predicting the first prediction frame by the electronic device is exemplarily shown. Fig. 9 As shown, the electronic device predicting the first prediction frame may include the following steps:

[0173] S501 . When drawing the Nth frame, the electronic device writes the drawing result of the drawing instruction without a dynamic identifier in the Nth frame into the color attachment B and the depth attachment B in the memory space H2 .

[0174] Specifically, when the electronic device draws the Nth frame, the GPU of the electronic device can obtain the drawing instruction of the Nth frame. The GPU of the electronic device can determine whether the drawing instruction of the Nth frame carries a motion flag, and the GPU of the electronic device writes the drawing result of the drawing instruction that does not carry a dynamic flag into the color attachment B and the depth attachment B in the memory space H2. For example, Figure 4AAs shown in (c), the drawing contents of the drawing instructions for the static hill 101 and the drawing contents of the drawing instructions for the static tree 102 are written into the color attachment B and the depth attachment B in the memory space H2.

[0175] S502: When drawing the N+2th frame, the electronic device writes the drawing instructions in the N+2th frame that do not carry a dynamic identifier into the color attachment D and the depth attachment D in the memory space H4.

[0176] Specifically, when the electronic device draws the N+2th frame, the GPU of the electronic device can obtain the drawing instruction of the Nth frame. The GPU of the electronic device can determine whether the drawing instruction of the N+2th frame carries a motion flag, and the GPU of the electronic device writes the drawing result of the drawing instruction that does not carry a dynamic flag into the color attachment D and the depth attachment D in the memory space H4. For example, Figure 4B As shown in (c), the drawing contents of the drawing instructions for the static hill 101 and the drawing contents of the drawing instructions for the static tree 102 are written into the color attachment D and the depth attachment D in the memory space H4.

[0177] S503: The electronic device determines a motion vector of each pixel in color attachment D based on color attachment B and color attachment D.

[0178] Specifically, the GUP of the electronic device can obtain the observation matrix and projection matrix of the Nth frame and the N+2th frame, and can obtain the transformation matrix T from the Nth frame to the N+2th frame based on the observation matrix and the projection matrix. For a pixel point at any position coordinate in the color attachment B, the GUP of the electronic device can obtain the corresponding position coordinate of the pixel point in the color attachment D based on the transformation matrix T. Based on the position coordinates of the pixel point in the color attachment B and the color attachment D, the motion vector of the pixel point can be obtained. Therefore, the electronic device can obtain the motion vector B = (B1, B2...Bm) of each pixel point in the color attachment D.

[0179] The GUP of the electronic device obtains the motion vector B of each pixel in the color attachment D based on the color attachment B and the color attachment D. For details, please refer to the relevant description of the above steps 401 to 404, which will not be repeated here.

[0180] S504: The electronic device predicts the color value of color attachment F in the N+3th frame based on color attachment D, depth attachment D, and the motion vector of each pixel in color attachment D, where color attachment F is in memory space H6.

[0181] Specifically, the GUP of the electronic device can obtain the coordinates of each pixel of the color attachment D in the N+2th frame in the color attachment F of the N+3th frame based on the color attachment D and the motion vector B of the N+2th frame. Among them, one coordinate in the color attachment F in the N+3th frame can correspond to several pixels, that is, several pixels in the color attachment D can move to one coordinate in the color attachment F. The GUP of the electronic device compares the difference in depth values ​​of the pixel points corresponding to the same coordinates in the color attachment B and the color attachment F, and determines the color value of the coordinate of the color attachment F based on the difference. In this way, the electronic device can determine the color value at each coordinate in the color attachment F.

[0182] Here, for a specific description of how the electronic device determines the color value in the color attachment F, please refer to the relevant description in steps 601 to 611, which will not be repeated here.

[0183] S505: The electronic device predicts a first prediction frame based on the color attachment F.

[0184] Specifically, when the electronic device draws the Nth frame, the drawing result of the drawing instruction carrying the dynamic identifier in the Nth frame is written into the color attachment A and the depth attachment A in the memory space H1. That is, the electronic device can write the drawing result of the dynamic object into the color attachment A and the depth attachment A. When the electronic device draws the N+2th frame, the drawing result of the drawing instruction carrying the dynamic identifier in the Nth frame can be written into the color attachment C and the depth attachment C in the memory space H3. Based on the color attachment A and the color attachment C, the electronic device can obtain the color attachment E. For the relevant operation of the electronic device to obtain the color attachment E, please refer to the above Figure 3 The related operations in the embodiment are not described in detail here. The electronic device can synthesize the obtained color attachment E and color attachment F into a first prediction frame. For the related description of the electronic device synthesizing the first prediction frame, please refer to the related description in the above step 313, which is not described in detail here.

[0185] In some optional embodiments, memory space H1 and memory space H2 may be one memory space, and memory space H2 and memory space H3 may be one memory space. When drawing the Nth drawing frame, the electronic device writes the dynamic object and the static object together into the color attachment I. The electronic device adds a mark G1 to the pixel points of the moving object in the color attachment I, and adds a mark G2 to the pixel points of the static object in the color attachment I. When drawing the N+2th drawing frame, the electronic device writes the dynamic object and the static object together into the color attachment J. The electronic device adds a mark G1 to the pixel points of the moving object in the color attachment J, and adds a mark G2 to the pixel points of the static object in the color attachment J. When calculating the motion vector of the static object, the electronic device determines the motion vector of the pixel point carrying the mark G2 in the color attachment J based on the pixel points carrying the mark G2 in the color attachment I and the color attachment J. Then, the electronic device predicts the color value of the pixel carrying the tag G2 in the N+3th frame, that is, the color value of the static object in the N+3th frame, based on the color value of the pixel carrying the tag G2 in the color attachment J, the depth value of the pixel carrying the tag G2 in the color attachment J, and the motion vector of the pixel carrying the tag G2 in the color attachment J. The electronic device can also predict the color value of the pixel carrying the tag G1 in the N+3th frame, that is, the color value of the dynamic object in the N+3th frame, based on the pixel carrying the tag G1 in the color attachment I and the pixel carrying the tag G1 in the color attachment J. Finally, the electronic device synthesizes the first predicted frame based on the pixel carrying the tag G1 in the N+3th frame and the pixel carrying the tag G2 in the N+3th frame.

[0186] In the embodiment of the present application, the first drawing frame can be referred to as the Nth frame, the second drawing frame can be referred to as the N+2th frame, and the first predicted frame can be referred to as the N+3th frame. The first memory space can be referred to as memory space H2, the second memory space can be referred to as memory space H4, the third memory space can be referred to as memory space H6, the fourth memory space can be referred to as memory space H1, and the fifth memory space can be referred to as memory space H3. The first color attachment can be referred to as color attachment B, the first depth attachment can be referred to as depth attachment B, the second color attachment can be referred to as color attachment D, the second depth attachment can be referred to as depth attachment D, the third color attachment can be referred to as color attachment F, the fourth color attachment can be referred to as color attachment A, the fourth depth attachment can be referred to as depth attachment A, the fifth color attachment can be referred to as color attachment C, the fifth depth attachment can be referred to as depth attachment C, and the sixth color attachment can be referred to as color attachment E.

[0187] Next, combine Figure 10-13 The example introduces a process in which an electronic device predicts a color value of color attachment F.

[0188] Fig.10The process of obtaining a color attachment F by an electronic device is exemplarily shown. As shown in the figure, the electronic device obtaining the color attachment F may include all or part of the following steps:

[0189] 601. The electronic device generates a color attachment F in the memory space H6, and sets a transparent channel of each pixel in the color attachment F to a first transparent value.

[0190] Specifically, when the CPU of the electronic device obtains the prediction instruction of the target application, the CPU of the electronic device sends an instruction to the GPU to instruct the GPU to create a memory space. In response to the instruction sent by the CPU to instruct the GPU to create a memory space, the GPU of the electronic device can create a memory space H6 in the memory. The GPU of the electronic device generates a color attachment F in the memory space H6, and sets the transparent channel of each pixel in the color attachment F in the memory space H6 to the first transparent value. Here, the color value in the generated color attachment F is an initial value color value, and the initial color value can be any color value. The color attachment F can be used to store the color value of the drawing content of the drawing instruction that does not carry a dynamic identifier in the first prediction frame. For the convenience of description, the color attachment F that sets the transparent channel of each pixel to the first transparent value is referred to as color attachment F1 in this application.

[0191] For example, see Fig.11 , Fig.11 FIG. 4 exemplarily shows a process in which an electronic device obtains a color attachment F. FIG. Fig.11 (a) shows the color attachment D, Fig.11 (b) shows the depth attachment D, Fig.11 (c) shows the color attachment F1. For the convenience of illustration, the dotted line in the figure indicates that the transparent channel of the pixel point at the position coordinate is the first transparent value, and the solid line indicates that the transparent channel of the pixel point at the position coordinate is the second transparent value. Fig.11 As shown in (c), the pixel point at each position coordinate in the color attachment F1 is represented by a dotted line, that is, the transparent channel of the pixel point at each position coordinate is set to the first transparent value.

[0192] 602. The electronic device determines a motion vector in color attachment D based on color attachment B and color attachment D.

[0193] Specifically, the GPU of the electronic device can determine the motion vector of each pixel in the color attachment D based on the color attachment B and the color attachment D. The electronic device determines the motion vector of each pixel in the color attachment D. Please refer to the relevant description in the above step 104, which will not be repeated here.

[0194] The execution order of step 601 and step 602 may be interchangeable, or the two steps may be executed simultaneously. The embodiment of the present application does not limit the execution order of step 601 and step 602.

[0195] 603. The electronic device determines, based on the motion vector of color attachment D, that a first pixel point at a first coordinate in color attachment D is at a third coordinate in color attachment F, and that a second pixel point at a second coordinate in color attachment D is at a fourth coordinate in color attachment F.

[0196] Specifically, for a first pixel point at a third coordinate in color attachment D, the electronic device adds the first coordinate to the motion vector of the first pixel point to obtain a third coordinate of the first pixel point in color attachment F. For a second pixel point at a second coordinate in color attachment D, the electronic device adds the second coordinate to the motion vector of the second pixel point to obtain a fourth coordinate of the second pixel point in color attachment F.

[0197] For example, see Fig.12 , Fig.12 A schematic diagram of determining pixel coordinates provided in an embodiment of the present application. Fig.12 As shown, Fig.12 (a) is color attachment D, which includes static object 1101 and static object 102. Static object 1101 is the distant background, i.e., the distant view, and static object 102 is a small tree nearby. In order to better illustrate the coordinates of the pixel points in color attachment D in color attachment F, the area around the small tree is taken for illustration. After the trunk edge of the small tree is enlarged, it can be seen as follows Fig.12 As shown in (b), the dark area is the small tree and the light area is the distant background. Fig.12 (b) is the enlarged trunk of the small tree. Fig.12 The width of the trunk of the small tree in (b) is Fig.12 The width of (a) is wider because of the drawing. Fig.12 This is not clearly reflected in the text, so we would like to explain it here.

[0198] like Fig.12 As shown in (d), the coordinates of pixel c3 in color attachment D are (n+3, m+3), and the motion vector of pixel c3 is (-1, 0). The electronic device adds the coordinates of pixel c3 in color attachment D and the motion vector of pixel c3, and obtains the coordinates of pixel c3 in color attachment F as (n+2, m+3). Accordingly, the electronic device can obtain the corresponding coordinates of pixel c3, pixel c8, and pixel c13 in color attachment F as (n+2, m+3), (n+2, m+2), and (n+2, m+1).

[0199] like Fig.12 As shown in (c), the coordinates of pixel c2 in color attachment D are (n+2, m+3), and the motion vector of pixel c2 is (0, 0), that is, the coordinates of pixel c2 in color attachment F are consistent with the coordinates in color attachment F, namely (n+2, m+3). Accordingly, the corresponding coordinates of pixel c2, pixel c7, and pixel c12 in color attachment F are (n+2, m+3), (n+2, m+2), and (n+2, m+1).

[0200] According to the above operation, the electronic device can obtain the position coordinates of each pixel point in the color attachment D in the color attachment F.

[0201] 604. The electronic device obtains a depth value D1 of a first pixel at a first coordinate, a depth value D2 of a second pixel at a second coordinate, a depth value D3 of a third pixel at a third coordinate, and a depth value D4 of the third pixel at a fourth coordinate in the color attachment D.

[0202] Specifically, when drawing the N+2th frame, the electronic device writes the depth value of the first drawing object in the N+2th frame into the depth attachment D in the memory space H4. Therefore, the electronic device can obtain the depth value of the pixel point at each coordinate in the color attachment D from the depth attachment D.

[0203] For example, see Fig.11 (b) Fig.11 (b) shows the depth attachment D. Fig.11 As shown in (b), the depth value of pixel c2 is d2, the depth value of pixel c3 is d3, the depth value of pixel c4 is d4, and so on.

[0204] 605. At the first moment, the electronic device determines a first difference between a depth value D1 of a first pixel at a first coordinate in the color attachment D and a depth value D3 of a third pixel at a third coordinate, and a second difference between a depth value D2 of a second pixel at a second coordinate and a depth value D4 of the third pixel at a fourth coordinate.

[0205] For example, Fig.12 As shown in (c), the first pixel point of the first coordinate can be as follows Fig.12 The motion vector of the pixel c2 in the color attachment D is (0, 0), and the electronic device can obtain the third coordinate (n+2, m+3) of the pixel c2 in the color attachment F according to the motion vector (0, 0). That is, the third coordinate is the same as the first coordinate, so the electronic device can obtain the first difference as 0.

[0206] like Fig.12 As shown in (c), the first pixel point of the first coordinate can be as follows Fig.12 The motion vector of the pixel c4 in the color attachment D is (-1, 0), and the electronic device can obtain the third coordinate (n+3, m+3) of the pixel c4 in the color attachment F according to the motion vector (-1, 0). The electronic device can obtain the depth value d4 of the pixel c4 at the first coordinate (n+4, m+3) in the color attachment D, and the depth value d3 of the pixel c3 at the third coordinate (n+3, m+3) in the color attachment D, and the electronic device calculates the difference between the depth value D1 and the depth value D3 as d3-d4.

[0207] like Fig.12 As shown in (d), the second pixel point of the second coordinate can be as follows Fig.12 The electronic device can obtain the pixel c3 at (n+3, m+3) in the color attachment D. The motion vector of the pixel c3 in the color attachment D is (-1, 0), and the electronic device can obtain the fourth coordinate (n+2, m+3) of the pixel c3 in the color attachment F according to the motion vector (-1, 0). The electronic device can obtain the depth value d3 of the pixel c3 at the second coordinate (n+3, m+3) in the color attachment D, and the depth value d2 of the pixel c2 at the fourth coordinate (n+2, m+3) in the color attachment D. The electronic device calculates that the difference between the depth value D2 and the depth value D3 is d2-d3.

[0208] 606. The electronic device determines that a first difference between the depth value D1 and the depth value D3 is less than a first threshold, and a second difference between the depth value D2 and the depth value D4 is greater than the first threshold, and the electronic device sets the color value of the pixel at the third coordinate in the color attachment F to the color value of the first pixel.

[0209] Specifically, the electronic device determines at the first moment that a first difference between a depth value of the first pixel and a depth value of the third pixel at the third coordinate in the second drawing frame is less than a first threshold value, and the electronic device sets the color value of the pixel at the third coordinate in the color attachment F to the color value of the first pixel, and the color value at the fourth coordinate in the color attachment F to the initial color value, and the electronic device does not perform any processing.

[0210] For example, Fig.12 As shown in (c), based on the motion vector (0, 0), the pixel c2 at the coordinates (n+2, m+3) in the color attachment F can be obtained. It can be seen that the third coordinate is the same as the first coordinate, so the electronic device can obtain the first difference value as 0. The first difference value is less than the first threshold value, and the electronic device determines that the color value of the pixel at the coordinates (n+2, m+3) in the color attachment F is the color value of the pixel c2.

[0211] like Fig.12As shown in (c), the pixel c4 at the coordinates (n+4, m+3) can be obtained at the coordinates (n+3, m+3) in the color attachment F based on the motion vector (-1, 0). The electronic device determines the difference d3-d4 between the depth value d4 of the pixel c4 at the coordinates (n+4, m+3) and the depth value d3 of the pixel c3 at the coordinates (n+3, m+3). Fig.12 As shown in (a), both pixel c3 and pixel c4 are pixels included in the static object 102, and the static object 102 is a small tree nearby, i.e., a foreground object, so the depth value difference between pixel c3 and pixel c4 is less than the first threshold. Thus, the electronic device determines that the color value of the pixel at the coordinate (n+3, m+3) in the color attachment F is the color value of pixel c4.

[0212] like Fig.12 As shown in (d), the pixel c3 at the coordinates (n+3, m+3) can be obtained at the coordinates (n+2, m+3) in the color attachment F based on the motion vector (-1, 0). The electronic device determines the difference d3-d2 between the depth value d3 of the pixel c3 at the coordinates (n+3, m+3) and the depth value d2 of the pixel c2 at the coordinates (n+2, m+3). Fig.12 As can be seen from (a), pixel c3 is a pixel included in static object 102, and pixel c2 is a pixel included in static object 1101. Static object 1101 is a distant object, and static object 102 is a near object. Therefore, the depth value difference between pixel c3 and pixel c2 is greater than the first threshold. The electronic device does not process the color of the pixel (n+2, m+3) in color attachment F.

[0213] 607. The electronic device writes the color value of the first pixel at the third coordinate in the color attachment F, and sets the transparent channel at the third coordinate to the second transparent value.

[0214] For example, Fig.11 As shown in (d), the electronic device writes the color value of pixel c2 at coordinate (n+2, m+3) in color attachment F2, the electronic device writes the color value of pixel c4 at coordinate (n+3, m+3) in color attachment F2, and sets the transparent channels of the pixel at coordinate (n+2, m+3) and the pixel at coordinate (n+3, m+3) in color attachment F2 to the second transparent value.

[0215] At the first moment, the electronic device writes the corresponding color value at each coordinate of the color attachment F1 according to the operations of the above steps 604 to 605, and the following can be obtained: Fig.11 The color shown in (d) is Appendix F2.

[0216] 608. At the second moment, the electronic device determines a first difference between the depth value D1 and the depth value D3, and determines a second difference between the depth value D2 and the depth value D4.

[0217] Specifically, the operations related to the electronic device determining the first difference and the second difference are specifically referred to the operations related to the electronic device determining the first difference and the second difference in the above step 604, which will not be repeated here.

[0218] 609. The electronic device determines that a first difference between the depth value D1 and the depth value D3 is less than a first threshold, and a second difference between the depth value D2 and the depth value D4 is greater than the first threshold. The electronic device determines that, based on the depth value of the second pixel and the depth value of the fourth pixel at the fourth coordinate in the second depth attachment, the color value of the pixel at the third coordinate in the third color attachment is the color value of the first pixel, and the color value at the fourth coordinate in the third color attachment is the color value of the second pixel.

[0219] Specifically, at the second moment, the electronic device determines that the first difference between the depth value D1 and the depth value D3 is less than the first threshold, and the electronic device does not process the color value of the pixel at the third coordinate in the color attachment F, and the pixel value of the pixel at the third coordinate in the color attachment F is still the color value of the first pixel.

[0220] For example, if the coordinates Fig.11 As shown in (d), for the pixel c11 at the coordinates (n+1, m+1), based on the motion vector (0, 0), the coordinates of the pixel c11 in the color attachment F3 can be obtained. That is, the pixel c11 moves from the coordinates (n+1, m+1) of the color attachment F2 to the coordinates (n+1, m+1) of the color attachment F3. It can be known that the difference between the depth value of the pixel c1 at the coordinates (n+1, m+1) of the color attachment F2 and the depth value of the pixel c1 at the coordinates (n+1, m+1) of the color attachment F3 is 0, which is less than the first threshold value. Therefore, at the first moment, the electronic device writes the color value of the pixel c11 at the coordinates (n+1, m+1) of the color attachment F3. Fig.11 As shown in (d), at the second moment, the electronic device does not process the color value at the coordinate (n+1, m+1) of the color attachment F3, and the color value at the coordinate (n+1, m+1) of the color attachment F3 is still the color value of the pixel c11.

[0221] At the second moment, the electronic device determines that the second difference between the depth value D2 and the depth value D4 is greater than the first threshold, and the electronic device determines that the color value at the fourth coordinate in the color attachment F is the color value of the second pixel.

[0222] For example, Fig.12As shown in (d), the pixel c3 at the coordinates (n+3, m+3) can be obtained at the coordinates (n+2, m+3) in the color attachment F based on the motion vector (-1, 0). The electronic device determines the difference d3-d2 between the depth value d3 of the pixel c3 at the coordinates (n+3, m+3) and the depth value d2 of the pixel c2 at the coordinates (n+2, m+3). Fig.12 As can be seen from (a), pixel c3 is a pixel included in static object 102, and pixel c2 is a pixel included in static object 1101. Static object 1101 is a distant object, and static object 102 is a near object. Therefore, the depth value difference between pixel c3 and pixel c2 is greater than the first threshold, so the electronic device determines that the color value of the pixel at the coordinate (n+3, m+3) in the color attachment F is the color value of pixel c3.

[0223] In some embodiments, based on the motion vector of color attachment D, the movement of the first pixel and the fifth pixel in color attachment D to the third coordinate of color attachment F is calculated, wherein a first difference between the depth value of the first pixel and the depth value of the third pixel at the third coordinate in color attachment D is less than a first threshold, and a second difference between the depth value of the fifth pixel and the depth value of the third pixel is greater than the first threshold. At a first moment, the electronic device writes the color value of the first pixel at the third coordinate in the third color attachment, and at a second moment, the electronic device writes the color value of the fifth pixel at the third coordinate in the third color attachment, i.e., the color value of the first pixel is overwritten with the color value of the fifth pixel at the third coordinate in the third color attachment. For example, Fig.11 As shown in (d), at the first moment, the electronic device writes the color value of pixel c7 at the coordinates (n+2, m+2). Fig.11 As shown in (e), at the second moment, the electronic device writes the color value of the pixel c8 at the coordinates (n+2, m+2).

[0224] In some optional embodiments, at the second moment, when the electronic device determines the color value at each coordinate in the color attachment F, the electronic device may compare the pixel points written in the color attachment F based on the first moment. For example, at the first moment, the electronic device sets the color value of the pixel point at the third coordinate in the color attachment F to the color value of the first pixel point. At the second moment, the electronic device determines the third difference between the depth value D1 of the first pixel point at the first coordinate in the color attachment D and the depth value D5 of the fifth pixel point. When the third difference is greater than the first threshold, the electronic device determines that the color value at the third coordinate in the color attachment F is the color value of the fifth pixel point.

[0225] 610. The electronic device writes the color value of the second pixel at the fourth coordinate in the color attachment F, and sets the transparent channel at the fourth coordinate to the second transparent value.

[0226] For example, Fig.11 As shown in (e), the electronic device writes the color value of the pixel c3 at (n+2, m+3) in the color attachment F2, and sets the transparent channel of the pixel at (n+2, m+3) in the color attachment F2 to the second transparent value.

[0227] At the second moment, according to the operations of steps 608 to 609 above, the corresponding color value is written into each coordinate of the color attachment F2, and the following can be obtained: Fig.11 The color shown in (e) is attached to F3.

[0228] 611. At a third moment, the electronic device determines one or more pixel points whose transparent channel in a third color attachment is a first transparent value, wherein the one or more pixel points include a sixth pixel point.

[0229] Specifically, according to the above steps 604 to 609, the electronic device writes the color value of the corresponding pixel at the position coordinate in the color attachment F to obtain the color attachment F3. However, there are still some pixels at some coordinates in the color attachment F3 that have not been written with color values. For example, Fig.11 As shown in (e), the transparent channels of the pixels at the position coordinates (m+3, n+4), (m+2, n+4) and (m+1, n+4) are the first transparent value. In other words, the corresponding color values ​​are not written to the pixels at these position coordinates.

[0230] In some embodiments, the sixth pixel may be any pixel whose depth value is less than the first depth value in the color attachment D. That is, the electronic device randomly selects a pixel whose depth value is less than the first depth value in the color attachment D and writes the color value of the pixel into the sixth coordinate in the color attachment F.

[0231] In some optional embodiments, the electronic device obtains multiple depth values ​​of pixels within the first range at the sixth coordinate in the color attachment D, calculates the average of the multiple depth values, selects the color value of the pixel whose depth value within the first range is less than the average value and writes it at the sixth coordinate. In the embodiment of the present application, the average of the multiple depth values ​​is also referred to as the second depth value.

[0232] For example, see Fig.13 , Fig.13 (a) shows the color attachment F1, Fig.13 (b) shows the depth attachment D. The following is an example of the position coordinates (n+4, m+2). Fig.13As shown in (b), the electronic device obtains the depth values ​​of the pixels in the first area around the coordinates (n+4, m+2), calculates the average value of the depth values ​​of the pixels in the first area, and selects the color values ​​of the pixels in the first area whose depth values ​​are less than the average value and writes them into the coordinates (n+2, m+4) in the color attachment F1. For example, the depth value of the pixel at the coordinates (n+5, m+2) is less than the average value, as shown in FIG. Fig.13 As shown in (c), the color value of the pixel at the coordinate (n+5, m+2) is written into the coordinate (n+2, m+4) in the color attachment F1.

[0233] It should be noted that, for the above method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present invention is not limited to the described order of actions. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the present invention.

[0234] The following first introduces an exemplary electronic device 100 provided in an embodiment of the present application.

[0235] Fig.14 It is a schematic diagram of the structure of the electronic device 100 provided in an embodiment of the present application.

[0236] The embodiment is described in detail below by taking the electronic device 100 as an example. It should be understood that the electronic device 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have different component configurations. The various components shown in the figure may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0237] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194 and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0238] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0239] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0240] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0241] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0242] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0243] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 may be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface, thereby realizing the touch function of the electronic device 100.

[0244] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call through a Bluetooth headset.

[0245] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0246] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In some embodiments, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.

[0247] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to implement the display function of the electronic device 100.

[0248] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0249] The SIM interface can be used to communicate with the SIM card interface 195 to implement the function of transmitting data to the SIM card or reading data in the SIM card.

[0250] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.

[0251] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0252] The charging management module 140 is used to receive charging input from a charger, where the charger can be a wireless charger or a wired charger.

[0253] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160.

[0254] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0255] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0256] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0257] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0258] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0259] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0260] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0261] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

[0262] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0263] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.

[0264] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0265] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0266] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0267] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0268] The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).

[0269] Random access memory may include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM, for example, the fifth generation DDR SDRAM is generally referred to as DDR5 SDRAM), etc.

[0270] Non-volatile memory may include disk storage devices and flash memory.

[0271] Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle; can be divided into single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc. according to the storage unit potential level; can be divided into universal flash storage (UFS), embedded multi media card (eMMC), etc. according to the storage specification.

[0272] The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data.

[0273] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 110 .

[0274] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0275] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0276] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.

[0277] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.

[0278] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.

[0279] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0280] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.

[0281] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

[0282] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.

[0283] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Then, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, the flip cover can be automatically unlocked.

[0284] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.

[0285] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.

[0286] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.

[0287] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.

[0288] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.

[0289] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 performs a boost on the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.

[0290] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0291] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.

[0292] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0293] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.

[0294] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications.

[0295] Fig.15 It is a software structure block diagram of the electronic device 100 according to an embodiment of the present application.

[0296] The system framework 1500 for implementing image frame prediction provided in the embodiment of the present application includes a software architecture and hardware devices. Among them, the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the system library, and the kernel layer.

[0297] The application layer can include a series of application packages.

[0298] like Fig.15 As shown, the application layer can target application 1501. The application layer can also include a camera ( Fig.15 Not shown), Gallery ( Fig.15 Not shown), Calendar ( Fig.15 Not shown), call ( Fig.15 Not shown), map ( Fig.15 Not shown), navigation ( Fig.15Target application 1501 may be a game application.

[0299] The application framework layer provides an application programming interface (API) and a programming framework for the application of the application layer. The application framework layer includes some predefined functions. In an embodiment of the present application, the application framework layer may include an application engine 1510. Among them, the application engine 1510 may include a rendering system (Rendering System) 1511. When the electronic device 100 is running the target application 1501, the rendering system 1511 in the application engine 1510 corresponding to the target application 1501 can obtain the drawing parameters of the target application 1501. The rendering system 1511 can also call the interface in the three-dimensional graphics processing library 1530 according to the drawing parameters to realize the rendering of the image frame of the target application 1501. Among them, the application engine 1510 can be a game engine corresponding to a game application. The three-dimensional graphics processing library 1530 can be Vulkan, OpenGL, OpenGL ES.

[0300] The system library can include multiple functional modules. For example: surface manager (surface manager) ( Fig.15 Not shown), Media Libraries ( Fig.15 ), platform interface 1520, 3D graphics processing library 1530 (eg, OpenGL ES), 2D graphics engine (eg, SGL) ( Fig.15 Not shown in the figure) etc.

[0301] The surface manager is used to manage the display subsystem and provide the fusion of two-dimensional (2D) and three-dimensional (3D) layers for multiple applications.

[0302] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0303] The platform interface 1520 can be used to receive an API for configuring a cache transmitted by the three-dimensional graphics processing library 1530. In response to the API for configuring the cache, the platform interface 1520 can drive the motion random access memory through the driver in the driver layer. Then the platform interface 1520 can configure storage space in the motion random access memory for use by the target application. In an embodiment of the present application, the platform interface 1520 can be EGL. EGL is an interface between a Khronos rendering API (such as OpenGL, OpenGL ES, or OpenVG) and the underlying native platform window system. EGL handles graphics context management, surface / buffer binding, rendering synchronization, and enables "high-performance, accelerated, mixed-mode 2D and 3D rendering using other Khronos APIs". The platform interface 1520 may, for example, include an Allocate Buffer interface 1521 and an eglSwapBuffer interface 1532'.

[0304] The three-dimensional graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing. The three-dimensional graphics processing library 1530 can be OpenGL ES. OpenGL ES is an application programming interface / function library and is a subset of the OpenGL three-dimensional graphics API. OpenGL ES includes a variety of functional functions / application programming interfaces, such as glBindFrameBuffer interface 1533' and glDrawArrays interface (not shown in the figure). The electronic device 100 can call OpenGL ES to implement the drawing of image frames.

[0305] The hook module (HOOK System) 1531 can obtain parameters for calling interfaces such as the glBindFrameBuffer interface 1533' and the glDrawArrays interface in the 3D graphics processing library 1530 by hooking some interfaces in the 3D graphics processing library 1530. For example, the hook module (HOOK System) 1531 can obtain parameters for calling the glBindFrameBuffer interface 1533' in the 3D graphics processing library 1530 by hooking some interfaces in the 3D graphics processing library 1530.

[0306] In the embodiment of the present application, when the target application 1501 is drawing, the rendering system 1511 in the application engine 1510 can call interfaces such as eglSwapBuffers interface 1532 and glBindFrameBuffer interface 1533 in the hook module 1531. Then the hook module (HOOK System) 1531 can obtain parameters of calling interfaces such as glBindFrameBuffer interface 1533' and glDrawArrays interface in the three-dimensional graphics processing library 1530 by hooking some interfaces in the three-dimensional graphics processing library 1530 to insert the predicted frame in the target application 1501, and calculate the motion vector according to the drawing frame of the target application 1501 and obtain the predicted frame.

[0307] A 2D graphics engine is a drawing engine for 2D drawings.

[0308] The kernel layer is a layer between hardware and software. The kernel layer may include a driver 1540. The driver 1540 may include a variety of drivers for implementing drivers for hardware devices. For example, the driver 1540 may include a graphics memory driver 1541, a GPU driver 1542, and the like.

[0309] The hardware device may include: a display device Display 1550, a graphics processor GPU 1551, a cache 1552, and an application processor 1553. The display device 1550 may be Fig.14 The display screen 194 shown in FIG. The graphics processor GPU 1551 and the application processor 1553 may be integrated in Fig.14 1. The cache 1552 may be Fig.14 The internal memory 121 shown in FIG. Here, the display device 1550 can refer to the description of the display screen 194 above. The graphics processor 1551 can refer to the description of the GPU above. The application processor 1553 can refer to the description of the Fig.14 The cache 1552 can refer to the above description of the internal memory 121. It will not be repeated here.

[0310] The following is an illustrative description of the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.

[0311] When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, timestamp of the touch operation, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the input event. For example, if the touch operation is a touch single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer to capture static images or videos through the camera 193.

[0312] Through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0313] Each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units.

[0314] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as flash memory, mobile hard disk, read-only memory, random access memory, disk or optical disk.

[0315] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, 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. A method for predicting an image frame, characterized in that: The method comprises: When drawing the first drawing frame, the electronic device writes the drawing result of the drawing instruction that does not carry the dynamic identifier in the first drawing frame into the first color attachment and the first depth attachment in the first memory space; When drawing the second drawing frame, the electronic device writes, in the second memory space, a drawing result of the drawing instruction that does not carry a dynamic identifier in the second drawing frame into a second color attachment and a second depth attachment, where the second color attachment includes a first pixel point and a second pixel point, where the first pixel point is at a first coordinate in the second color attachment, and the second pixel point is at a second coordinate in the second color attachment; The electronic device determines a motion vector of the second color attachment based on the first color attachment and the second color attachment; The electronic device determines, based on the motion vector of the second color attachment, that the first pixel moves from the first coordinate to a third coordinate in a third color attachment, and that the second pixel moves from the second coordinate to a fourth coordinate in the third color attachment; At a first moment, the electronic device determines a first difference between a depth value of the first pixel and a depth value of a third pixel, and a second difference between a depth value of the second pixel and a depth value of a fourth pixel; The electronic device determines that the first difference is less than a first threshold value, and the second difference is greater than the first threshold value, and the electronic device sets the color value of the pixel at the third coordinate in the third color attachment to the color value of the first pixel point, and the color value at the fourth coordinate in the third color attachment is an initial color value, and the initial color value is the color value at the fourth coordinate in the third color attachment when the electronic device generates the third color attachment; At a second moment, the electronic device determines a first difference between the depth value of the first pixel and the depth value of the third pixel, and a second difference between the depth value of the second pixel and the depth value of the fourth pixel; the second moment is later than the first moment; The electronic device determines that the first difference is less than a first threshold value, and the second difference is greater than the first threshold value, and the electronic device determines that the color value of the pixel at the third coordinate in the third color attachment is the color value of the first pixel point, and the color value at the fourth coordinate in the third color attachment is the color value of the second pixel point; The electronic device predicts a first prediction frame based on the third color attachment.

2. The method according to claim 1, wherein the second color attachment further comprises a fifth pixel point, and the fifth pixel point is located at a fifth coordinate in the second color attachment; The electronic device determines that the fifth pixel moves from the fifth coordinate to the third coordinate in the third color attachment; After the electronic device sets the color value of the pixel at the third coordinate in the third color attachment to the color value of the first pixel, the method further includes: At a second moment, the electronic device determines a third difference between the depth value of the fifth pixel and the depth value of the first pixel; The electronic device determines that the third difference is greater than the first threshold, and determines that the color value of the pixel at the third coordinate in the third color attachment is the color value of the fifth pixel.

3. The method according to claim 1 or 2, characterized in that: Before the electronic device determines that the color value at the third coordinate in the third color attachment is the color value of the first pixel, the method further includes: The electronic device sets the transparent channel of the pixel in the third color attachment in the third memory space to the first transparent value; After the electronic device determines that the color value of the pixel at the third coordinate in the third color attachment is the color value of the first pixel, and the color value at the fourth coordinate in the third color attachment is the color value of the second pixel, the method further includes: The electronic device writes the color value of the first pixel at the third coordinate in the third color attachment, writes the color value of the second pixel at the fourth coordinate in the third color attachment, and sets the transparent channels of the pixels at the third coordinate and the fourth coordinate in the third color attachment to a second transparent value, wherein the first transparent value is different from the second transparent value; At a third moment, the electronic device determines that a transparent channel in the third color attachment has one or more pixels of the first transparency value, wherein the one or more pixels include a sixth pixel; The electronic device determines that the color of the sixth pixel is a first color value, where the first color value is a color value of any pixel in the second color attachment whose depth value is less than the first depth value.

4. The method according to claim 3, characterized in that The sixth pixel is a pixel in the second depth attachment whose depth value is less than the first depth value, the first depth value is used to distinguish between near-view objects and distant-view objects in the second color attachment, and in the second color attachment, the depth value of the pixel included in the near-view object is less than the first depth value, and the depth value of the pixel included in the distant-view object is greater than the first depth value.

5. The method according to claim 3, characterized in that: The sixth pixel is a pixel in the second depth attachment whose depth value is less than the second depth value, the coordinate of the sixth pixel in the third color attachment is the sixth coordinate, and the second depth value is the average value of the depth values ​​within the first range of the sixth coordinate in the second depth attachment.

6. The method according to claim 5, characterized in that The electronic device determines, based on the first color attachment and the second color attachment, a motion vector of the second color attachment, specifically including: The electronic device extracts the first pixel from the second color attachment; The electronic device calculates a seventh coordinate of the first pixel in the first color attachment; The electronic device determines a motion vector of the first pixel based on the seventh coordinate and a first coordinate of the first pixel in the second color attachment; The electronic device determines a motion vector of the second color attachment based on the motion vector of the first pixel.

7. The method according to claim 6, characterized in that The electronic device calculates the seventh coordinate of the first pixel in the first color attachment, specifically including: The electronic device obtains a first matrix and a second matrix in the drawing parameters of the first drawing frame and a third matrix and a fourth matrix in the drawing instructions of the second drawing frame, wherein the first matrix is ​​used to describe a mapping relationship between a drawing object in the first drawing frame from a world coordinate system to an observation coordinate system, the second matrix is ​​used to describe a mapping relationship between a drawing object in the first drawing frame from the observation coordinate system to a clipping coordinate system, the third matrix is ​​used to describe a mapping relationship between a drawing object in the second drawing frame from the world coordinate system to the observation coordinate system, and the fourth matrix is ​​used to describe a mapping relationship between a drawing object in the second drawing frame from the observation coordinate system to the clipping coordinate system; The electronic device calculates a seventh coordinate of the first pixel in the first color attachment based on the first matrix, the second matrix, the third matrix, and the fourth matrix.

8. The method according to any one of claims 4 to 7, characterized in that: The method further comprises: When drawing the first drawing frame, the electronic device writes the drawing result of the drawing instruction carrying the dynamic identifier in the first drawing frame into the fourth color attachment and the fourth depth attachment in the fourth memory space; When drawing the second drawing frame, the electronic device writes the drawing result of the drawing instruction carrying the dynamic identifier in the second drawing frame into the fifth color attachment and the fifth depth attachment in the fifth memory space; The electronic device determines a motion vector of the fifth color attachment based on the fourth color attachment and the fifth color attachment; The electronic device generates a sixth color attachment of the first prediction frame based on the fifth color attachment and a motion vector of the fifth color attachment; The electronic device predicts a first prediction frame based on the third color attachment, specifically including: The electronic device combines the third color attachment and the sixth color attachment into the first predicted frame.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors and a memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method according to any one of claims 1 to 8.

10. A chip system, wherein the chip system is applied to an electronic device, the chip system comprises one or more processors, and the processor is used to call computer instructions so that the electronic device executes the method as described in any one of claims 1-8.

11. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Image frame prediction method and electronic equipment

    CN115398907A