CN107193551B - Method and device for generating image frame - Google Patents

Method and device for generating image frame Download PDF

Info

Publication number
CN107193551B
CN107193551B CN201710258406.3A CN201710258406A CN107193551B CN 107193551 B CN107193551 B CN 107193551B CN 201710258406 A CN201710258406 A CN 201710258406A CN 107193551 B CN107193551 B CN 107193551B
Authority
CN
China
Prior art keywords
program
thread
operation instruction
processing
image frame
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710258406.3A
Other languages
Chinese (zh)
Other versions
CN107193551A (en
Inventor
张首钊
许伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Yonghang Technology Co Ltd
Original Assignee
Beijing Yonghang Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Yonghang Technology Co Ltd filed Critical Beijing Yonghang Technology Co Ltd
Priority to CN201710258406.3A priority Critical patent/CN107193551B/en
Publication of CN107193551A publication Critical patent/CN107193551A/en
Application granted granted Critical
Publication of CN107193551B publication Critical patent/CN107193551B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a method for generating an image frame, and belongs to the technical field of computers. The method comprises the following steps: receiving an operation instruction input by a user; performing logic processing on the operation instruction through a program auxiliary thread based on a program operation parameter at a preset moment to obtain a processing result; and generating a target image frame according to the processing result through the program main thread, wherein the target image frame is a subsequent image frame of the image frame which is generated when the processing result is obtained. By adopting the invention, the deviation of the image frame generated by the terminal relative to the operation instruction input by the user is smaller.

Description

Method and device for generating image frame
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for generating an image frame.
Background
With the continuous development of computer technology, electronic games are becoming more popular, and many people like to relax mood and relieve fatigue by playing the electronic games in leisure time. Electronic games can be broadly classified into computer games, mainframe games (or called home games, tv games), palm games, arcade games, mobile games (mainly mobile games), and the like according to the terminal in operation.
When a user plays an electronic game (hereinafter referred to as a game), an object in the game can be controlled through an input device of the terminal, when the user operates the input device, an operating system of the terminal can receive a corresponding operating instruction and provide the operating instruction to a program main thread of the game, so that the program main thread can perform logic processing on the operating instruction, and then an image frame to be displayed is generated based on a processing result, so that the image frame is displayed on the terminal. For example, when playing a role playing game on a mobile phone, a user may control the movement of a game role by clicking a screen, so that an operating system of the terminal may receive a click instruction of a certain point on the screen, and then a game program main thread may calculate the position of the game role in a next image frame according to the click instruction, and may further generate a corresponding image frame and display the image frame on the terminal screen.
In the process of implementing the invention, the inventor finds that the prior art has at least the following problems:
and sending the image frame to a screen for display after the program main thread generates one image frame, and then continuously generating the next image frame. When a program main thread receives an operation instruction, the generation processing of a certain image frame is generally carried out, and the currently received operation instruction can be started to be logically processed only after the image frame is completely generated, so that the program main thread can carry out the logical processing on the currently received operation instruction based on the game content at the moment when the image frame is completely generated, and the game content is likely to have been greatly changed relative to the moment when a user operates an input device, and thus, the image frame finally displayed by a terminal is likely to have large deviation.
Disclosure of Invention
To solve the problems of the prior art, embodiments of the present invention provide a method and apparatus for generating an image frame. The technical scheme is as follows:
in a first aspect, a method of generating an image frame is provided, the method comprising:
receiving an operation instruction input by a user;
performing logic processing on the operation instruction through a program auxiliary thread based on a program operation parameter at a preset moment to obtain a processing result;
and generating a target image frame according to the processing result through the program main thread, wherein the target image frame is a subsequent image frame of the image frame which is generated when the processing result is obtained.
Optionally, after receiving the operation instruction input by the user, the method further includes:
judging the operation type corresponding to the operation instruction through a program message distribution thread;
and if the operation type of the operation instruction is a preset operation, sending the operation instruction to a program auxiliary thread through the message distribution thread.
Optionally, the performing, by the program assistant thread, logic processing on the operation instruction based on the program operation parameter at the preset time to obtain a processing result further includes:
storing the processing result to an operation result queue;
the generating, by the program main thread, a target image frame according to the processing result includes:
and reading the processing result stored in the operation result queue through the program main thread, and generating a target image frame according to the processing result.
Optionally, the performing, by the program assistant thread, a logic process on the operation instruction based on a program running parameter at a preset time to obtain a processing result includes:
in a target processing cycle of a program assistant thread, performing logic processing on the operation instruction through the program assistant thread based on a program operation parameter at the starting moment of the target processing cycle to obtain a processing result, wherein the target processing cycle is a cycle next to the current processing cycle of the program assistant thread when the operation instruction is received.
Optionally, the method further includes:
recording the receiving time corresponding to the operation instruction through a program message distribution thread;
the logic processing is performed on the operation instruction through the program assistant thread based on the program operation parameter at the preset moment to obtain a processing result, and the logic processing method comprises the following steps:
and performing logic processing on the operation instruction by the program auxiliary thread based on the program operation parameters at the receiving moment to obtain a processing result.
In a second aspect, there is provided an apparatus for generating an image frame, the apparatus comprising:
the receiving module is used for receiving an operation instruction input by a user;
the processing module is used for carrying out logic processing on the operation instruction based on the program operation parameters at the preset moment through the program assistant thread to obtain a processing result;
and the generating module is used for generating a target image frame according to the processing result through the program main thread, wherein the target image frame is a subsequent image frame of the image frame which is generated when the processing result is obtained.
Optionally, the apparatus further comprises:
the judging module is used for judging the operation type corresponding to the operation instruction through a program message distribution thread after receiving the operation instruction input by a user;
and the sending module is used for sending the operating instruction to a program auxiliary thread through the message distribution thread if the operating type of the operating instruction is a preset operation.
Optionally, the apparatus further comprises:
the storage module is used for carrying out logic processing on the operation instruction based on program operation parameters at a preset moment through a program assistant thread to obtain a processing result, and then storing the processing result into an operation result queue;
the generation module is specifically configured to:
and reading the processing result stored in the operation result queue through the program main thread, and generating a target image frame according to the processing result.
Optionally, the processing module is specifically configured to:
in a target processing cycle of a program assistant thread, performing logic processing on the operation instruction through the program assistant thread based on a program operation parameter at the starting moment of the target processing cycle to obtain a processing result, wherein the target processing cycle is a cycle next to the current processing cycle of the program assistant thread when the operation instruction is received.
Optionally, the apparatus further comprises:
the recording module is used for recording the receiving time corresponding to the operation instruction through a program message distribution thread;
the processing module is specifically configured to:
and performing logic processing on the operation instruction by the program auxiliary thread based on the program operation parameters at the receiving moment to obtain a processing result.
The technical scheme provided by the embodiment of the invention has the following beneficial effects:
in the embodiment of the invention, after the user operates the input device, the program auxiliary thread can quickly carry out logic processing on the operation instruction based on the program content, and the main thread of the program does not need to respond to the operation instruction after the current image frame is generated, so that the deviation of the image frame finally displayed by the terminal is small.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a method for generating an image frame according to an embodiment of the present invention;
FIG. 1a is a comparison of processing times provided by embodiments of the present invention;
FIG. 1b is a schematic diagram of a time instant when an image frame is generated according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for generating an image frame according to an embodiment of the present invention;
fig. 3 is a flowchart of a method for generating an image frame according to an embodiment of the present invention;
FIG. 3a is a schematic diagram of an architecture for generating an image frame according to an embodiment of the present invention;
fig. 4 is a flowchart of a method for generating an image frame according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an apparatus for generating an image frame according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
The embodiment of the invention provides a method for generating image frames, wherein an execution main body of the method is a terminal, the terminal can be any terminal with an application program running, such as a mobile phone, a computer and the like, and the application program can be any program needing to interact with a user and can be a game program. The terminal can be provided with a processor, a memory and a screen, wherein the processor can be used for processing the process of displaying the image, the memory can be used for storing data required in the following process and generated data, and the screen can be used for displaying the content required to be displayed to a user in the following process, such as an image frame. An input unit may also be provided in the terminal, which may be used for a user to input instructions or setting information to the terminal, such as for a game program, which may be a game control device. In this embodiment, the detailed description of the scheme is performed by taking the terminal as a mobile phone and the program as a game program as an example, and other cases are similar to the above, and the description of this embodiment is not repeated.
The process flow shown in fig. 1 will be described in detail below with reference to specific embodiments, and the contents may be as follows:
step 101, receiving an operation instruction input by a user.
In implementation, when the terminal runs the game program, the user can control the character in the game program through the control device so as to realize the operation which the user wants to complete. Here, the control device may be a touch screen, a mouse, an operation handle, etc. depending on the terminal, and the character may be any controllable element in the game program, such as a character in the game, a vehicle, etc., depending on the type of the game program. Thus, when the user operates the control device, the terminal can correspondingly receive the operation instruction input by the user. It should be noted that, here, the specific case may be that the system program of the terminal acquires the operation instruction, and the operation instruction here may be a click instruction of a certain point in the screen, or a press instruction of a certain key on the operation handle, and the like.
And 102, performing logic processing on the operation instruction through the program assistant thread based on the program operation parameters at the preset moment to obtain a processing result.
The program auxiliary thread may be a thread which is independent of the program main thread and is dedicated to logically processing the operation instruction input by the user. For the convenience of understanding, for a game program, a game main thread mentioned later is a program main thread of the game, and a game auxiliary thread is a program auxiliary thread of the game. The preset time may be a time that meets a preset rule, for example, the time when the program assistant thread starts to perform logic processing on the operation instruction after receiving the operation instruction, or the time when the operation instruction is received.
In implementation, when a technician develops a program, the technician may design a program assistant thread, which is independent of the program main thread and is dedicated to processing an operation instruction input by a user, so that when the program main thread performs logic processing of a game main body and rendering of an image frame, the program assistant thread may simultaneously perform logic processing related to the operation instruction of the user, and thus when the program main thread needs to generate the image frame corresponding to the operation instruction, a processing result of the operation instruction by the program assistant thread may be directly called. Therefore, after the user operates the control device, the system program of the terminal can receive the corresponding operation instruction, and then the system program of the terminal can provide the received operation instruction for the program assistant thread. Therefore, after the program assistant thread acquires the operation instruction, the operation instruction may be logically processed based on the program operation parameter at the preset time to obtain a processing result, for example, the operation instruction is a pressing operation of a direction key up key in a gamepad, the program assistant thread may first determine a control object in a game determined by the operation instruction, then determine a specific action corresponding to a key operation of the up key in a game scene at the preset time, such as an upward movement of the corresponding control object, or a jump of the corresponding control object once, and then may determine attribute information of a state, a position, and the like of the control object after the action is completed, so that the information may be converted into binary data to obtain the processing result.
Optionally, the auxiliary thread of the program may be a periodically working high-frequency processing thread, and correspondingly, the processing of step 102 may specifically be: in the target processing period of the program assistant thread, the program assistant thread performs logic processing on the operation instruction based on the program operation parameter at the starting moment of the target processing period to obtain a processing result.
And the target processing cycle is the next cycle of the current processing cycle of the program assistant thread when the operation instruction is received. Here, the duration of the processing cycle of the program assistant thread may not be fixed, but is determined by the number of the operation instructions to be processed, and if the program assistant thread needs to perform logical processing of a plurality of operation instructions in a certain processing cycle, the duration of the processing cycle is long.
In implementation, after the terminal runs the program, the program assistant thread may be continuously in a periodic working state, so that after the terminal receives the operation instruction, when the period processing time point of the program assistant thread is reached for the first time (that is, the starting time of the target processing period is reached), the program assistant thread may perform logic processing on the operation instruction based on the program running parameter at the current time, thereby obtaining a processing result. The auxiliary program thread only needs to perform logic processing on the operation instruction input by the user, does not need to be responsible for other logic processing of the program, and does not need to perform rendering processing on the image frame, so that the auxiliary program thread can run at a frequency higher than that of the main program thread, and response delay to the operation instruction can be greatly reduced. Here, the response delay is a difference between a time at which the operation instruction is logically processed and a time at which the operation instruction is received. As shown in fig. 1a, assuming that the frame rate of the main program thread is stable, at the time t of the N +1 th frame, if an operation instruction is received, according to the prior art scheme, the main program thread needs to perform logical processing on the operation instruction at the time t3 based on the program operation parameter at the time t3, whereas according to the scheme of the present application, the operation instruction can be performed logical processing on the operation instruction at the time t4 based on the program operation parameter at the time t4, so that the response delay can be reduced from "t 3-t" to "t 4-t". If a plurality of operation instructions need to be logically processed in a target processing cycle, the plurality of operation instructions may be logically processed based on the program operating parameter at the start time of the target processing cycle.
And 103, generating a target image frame according to the processing result through the program main thread.
The target image frame is a subsequent image frame of the image frame being generated when the processing result is obtained, and specifically, the target image frame may be a first subsequent image frame.
In implementation, after the program assistant thread performs logic processing on the operation instruction input by the user, the terminal may obtain the processing result through the program main thread, and then generate a subsequent image frame based on the processing result. Specifically, when the program runs, the terminal displays a certain image frame, and the program main thread performs logic processing and rendering processing on the next image frame, and after the rendering is completed, the program main thread can provide the next image frame to the terminal for display. As shown in fig. 1b, when the operation instruction is received at time t, the program assistant thread starts to perform logic processing on the operation instruction at time t4, and obtains a processing result at time t5, and further, the program main thread may generate an N +3 th frame (i.e., a target image frame) based on the processing result of the program assistant thread on the operation instruction after completing the generation processing of the N +2 th frame at time t 3. It should be noted that the logic processing of the image frame may be divided into logic calculation of the program running body and logic calculation of the user operation instruction, so that, in the process of performing the logic processing of the target image frame by the program main thread, when the logic calculation of the user operation instruction is required, the processing result provided by the program auxiliary thread may be directly obtained, and then the logic processing of the target image frame is completed according to the processing result, and the target image frame is generated by rendering.
For ease of understanding, the above-described partial processing is briefly described here by way of the following example: the program main thread needs to render the image frame according to the parameter Z, and without user operation, the parameter Z needs to be obtained by the program main thread through logical processing Z ═ f (X), and the parameter X may be obtained through logical processing X ═ g (t), where t is the program running time length. If the user performs an operation, and the logical processing of the parameter Z becomes Z ═ f (X, Y), in the existing processing, the logical processing of the program main thread may be to determine the parameter X, then determine the parameter Y, and finally determine the parameter Z according to the parameters X and Y. By adopting the scheme, the parameter Y can be determined by the program assistant thread (namely the parameter Y is a processing result), so that when the parameter Z is determined, the program main thread can determine the parameter X firstly and then determine the parameter Z according to the obtained parameter Y.
In the embodiment of the invention, after the user operates the input device, the program auxiliary thread can quickly carry out logic processing on the operation instruction based on the program content, and the main thread of the program does not need to respond to the operation instruction after the current image frame is generated, so that the deviation of the image frame finally displayed by the terminal is small.
An embodiment of the present invention further provides a method for generating an image frame, and the following details will describe the processing flow shown in fig. 2 in conjunction with the specific implementation, and the contents may be as follows:
step 201, obtaining an operation instruction input by a user through a program message distribution thread.
The program message distribution thread may be included in the program, is independent of the main program thread and the auxiliary program thread, and is used for acquiring an operation instruction input by a user and distributing the operation instruction to the main program thread or the auxiliary program thread.
In implementation, when the terminal runs the game program, the user can control the character in the game program through the control device so as to realize the operation which the user wants to complete. When the user operates the control device, the terminal can acquire the operation instruction input by the user through the program message distribution thread.
Step 202, judging an operation type corresponding to the operation instruction through the program message distribution thread, and if the operation type of the operation instruction is a preset operation type, sending the operation instruction to the program auxiliary thread through the message distribution thread.
In implementation, a designer of a program may divide operation types of all user operations supported by the program in advance according to a requirement for response speed, that is, may divide the operation types of all user operations related in the program into an operation type requiring a fast response speed (such as a switching operation of a lens in a first-person shooter game) and an operation type that can tolerate a certain response delay (such as an opening operation of a setting interface of the program), so that the designer may write the division result into an execution code of a program message distribution thread. In this way, when a program runs, after the program message distribution thread acquires an operation instruction input by a user, the operation type corresponding to the operation instruction may be judged first, and then it is determined whether the operation type is a preset operation type, that is, the degree of demand of all operations under the operation type on the response speed is determined. If the operation type of the operation instruction is a preset operation type, that is, the operation corresponding to the operation instruction requires a higher response speed, the terminal may send the operation instruction to the program assistant thread through the message distribution thread. It is understood that if the operation corresponding to the operation instruction does not require a high response speed, the message distribution thread may send the operation instruction directly to the program main thread.
In addition, the message distribution thread can also determine the average time length for generating one image frame by the program main thread according to the interval time length of the image frame generated by the program main thread, and then estimate the generation time of the next image frame after the program main thread generates one image frame, and if an operation instruction is received within a preset time length before the generation time of the next image frame, the operation instruction can be directly sent to the program main thread for processing. The preset time length may be the shortest time length from when the message distribution thread provides the operation instruction to the program auxiliary thread to when the program main thread acquires the processing result. Further, if the program assistant thread is periodically operated, the preset duration may be an average operation period of the program assistant thread.
And 203, performing logic processing on the operation instruction through the program assistant thread based on the program operation parameters at the preset time to obtain a processing result.
The specific processing of this step can refer to step 102.
And step 204, generating a target image frame according to the processing result through the program main thread.
The specific processing of this step can refer to step 103.
In the embodiment of the invention, after the user operates the input device, the type analysis of the user operation can be carried out by the program message distribution thread, if the operation type belongs to the operation type with higher response speed requirement, the program auxiliary thread can carry out logic processing on the operation instruction rapidly based on the program content, the main thread of the program does not need to respond to the operation instruction after the current image frame is generated, and further, the deviation of the image frame finally displayed by the terminal is smaller.
An embodiment of the present invention further provides a method for generating an image frame, and the following details will describe the processing flow shown in fig. 3 in conjunction with the specific implementation, and the contents may be as follows:
step 301, receiving an operation instruction input by a user through a program message distribution thread.
The specific processing of this step can refer to step 201.
Step 302, storing the operation instruction to an operation instruction queue through a program message distribution thread.
In implementation, after receiving an operation instruction input by a user, the program message distribution thread may store the operation instruction in an operation instruction queue. The operation instructions in the operation instruction queue may be arranged according to the sequence input by the user, or the program message distribution thread records the receiving time corresponding to the operation instruction when receiving the operation instruction input by the user, so that the receiving time and the operation instruction may be correspondingly stored in the operation instruction queue.
Step 303, reading the operation instruction stored in the operation instruction queue through the program assistant thread, and performing logic processing on the operation instruction based on the program operation parameter at the preset time to obtain a processing result.
In implementation, the program assistant thread may read the operation instruction stored in the operation instruction queue, and perform logic processing on the operation instruction according to the program operation parameter at the preset time, so as to obtain a corresponding processing result. If a plurality of unprocessed operation instructions are stored in the operation instruction queue, the program assistant thread can sequentially perform logic processing on the plurality of operation instructions according to the sequence. Further, if the receiving time corresponding to the operation instruction is recorded in the operation instruction queue at the same time, the program assistant thread may sequentially perform logic processing on the plurality of operation instructions from early to late according to the receiving time. After the program assistant thread finishes reading the processing result, the corresponding operation instruction in the operation instruction queue can be deleted, and the program assistant thread is prevented from repeatedly reading a certain operation instruction.
And step 304, storing the processing result to an operation result queue through the program assistant thread.
In implementation, the program assistant thread performs logic processing on the operation instruction input by the user, and after a processing result is obtained, the processing result can be stored in the operation result queue. It can be understood that the operation result queue may be dedicated to store the processing results of the program assistant thread for the operation instructions input by the user, where the processing results may be arranged according to the sequence of the operation instructions input by the user, or the program assistant thread may store the receiving time of the operation instructions and the processing results into the operation instruction queue correspondingly.
And 305, reading the processing result stored in the operation result queue through the program main thread, and generating the target image frame according to the processing result.
In implementation, the program main thread may read the processing result stored in the operation result queue and generate a subsequent image frame according to the processing result. If the processing results of the plurality of operation instructions are stored in the operation result queue, the program main thread can read the plurality of processing results according to the sequence and generate a subsequent image frame based on the plurality of processing results. Here, after the program main thread finishes reading the processing result, the corresponding processing result in the operation result queue may be deleted, so as to avoid the program main thread from repeatedly reading a certain processing result.
Fig. 3a shows a possible architecture diagram, which is only used to help understanding the scheme, and is not limiting.
In the embodiment of the invention, after a user operates the input device, the program message distribution thread can store the operation instruction into the operation instruction queue, so that the program assistant thread can read the corresponding operation instruction from the operation instruction queue, then quickly perform logic processing on the operation instruction based on the program content, and store the logic processing result into the operation result queue for the program main thread to read, and the program main thread does not need to respond to the operation instruction after the current image frame is generated, and further, the deviation of the image frame finally displayed by the terminal is small.
An embodiment of the present invention further provides a method for generating an image frame, and the following details will describe the processing flow shown in fig. 4 in conjunction with the specific implementation, where the contents may be as follows:
step 401, obtaining an operation instruction input by a user through a program message distribution thread.
The specific processing of this step can refer to step 201.
Step 402, recording the receiving time corresponding to the operation instruction through a program message distribution thread.
In implementation, after the program message distribution thread acquires an operation instruction input by a user, the receiving time corresponding to the operation instruction may be recorded at the same time. It should be noted that the program message distribution thread is mainly used for distributing the operation instruction, and the operating frequency is high, so that the difference duration between the receiving time and the actual input time of the operation instruction is very small.
And 403, performing logic processing on the operation instruction through the auxiliary thread of the program based on the program operation parameters at the receiving moment to obtain a processing result.
In implementation, the program assistant thread may receive the operation instruction sent by the program message distribution thread, and may obtain a receiving time corresponding to the operation instruction recorded by the program message distribution thread. Then, the program assistant thread may determine the program operation parameter at the receiving time, and then perform logic processing on the operation instruction based on the determined program operation parameter, so that a processing result with extremely small delay may be obtained. It is easy to understand that, because the receiving time is very close to the actual operation time of the user, the difference between the program operation parameter at the receiving time and the program operation parameter during the actual operation of the user is not large, and thus, the obtained processing result can better meet the accurate purpose of the user operation. It should be noted that, if a plurality of operation instructions need to be logically processed in a target processing cycle, each operation instruction may be logically processed based on the program operation parameter at the time of receiving each operation instruction.
And step 404, generating a target image frame according to the processing result through the program main thread.
The specific processing of this step can refer to step 103.
In the embodiment of the invention, after the user operates the input device, the receiving time of the operation instruction can be recorded by the program message distribution thread, then the program auxiliary thread can quickly carry out logic processing on the operation instruction based on the program content corresponding to the receiving time, the main program thread does not need to respond to the operation instruction after the current image frame is generated, and further, the deviation of the image frame finally displayed by the terminal is small.
Based on the same technical concept, an embodiment of the present invention further provides an apparatus for generating an image frame, as shown in fig. 5, the apparatus including:
a receiving module 501, configured to receive an operation instruction input by a user;
the processing module 502 is configured to perform logic processing on the operation instruction based on a program operation parameter at a preset time through a program assistant thread to obtain a processing result;
a generating module 503, configured to generate, by the program main thread, a target image frame according to the processing result, where the target image frame is a subsequent image frame to the image frame being generated when the processing result is obtained.
Optionally, the apparatus further comprises:
the judging module is used for judging the operation type corresponding to the operation instruction through a program message distribution thread after receiving the operation instruction input by a user;
and the sending module is used for sending the operating instruction to a program auxiliary thread through the message distribution thread if the operating type of the operating instruction is a preset operation.
Optionally, the apparatus further comprises:
the storage module is used for carrying out logic processing on the operation instruction based on program operation parameters at a preset moment through a program assistant thread to obtain a processing result, and then storing the processing result into an operation result queue;
the generation module is specifically configured to:
and reading the processing result stored in the operation result queue through the program main thread, and generating a target image frame according to the processing result.
Optionally, the processing module is specifically configured to:
in a target processing cycle of a program assistant thread, performing logic processing on the operation instruction through the program assistant thread based on a program operation parameter at the starting moment of the target processing cycle to obtain a processing result, wherein the target processing cycle is a cycle next to the current processing cycle of the program assistant thread when the operation instruction is received.
Optionally, the apparatus further comprises:
the recording module is used for recording the receiving time corresponding to the operation instruction through a program message distribution thread;
the processing module is specifically configured to:
and performing logic processing on the operation instruction by the program auxiliary thread based on the program operation parameters at the receiving moment to obtain a processing result.
In the embodiment of the invention, after the user operates the input device, the program auxiliary thread can quickly carry out logic processing on the operation instruction based on the program content, and the main thread of the program does not need to respond to the operation instruction after the current image frame is generated, so that the deviation of the image frame finally displayed by the terminal is small.
It should be noted that: the image frame generating device provided in the above embodiment is only illustrated by dividing the above functional modules when generating an image frame, and in practical applications, the above function distribution may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the above described functions. In addition, the apparatus for generating an image frame and the method for generating an image frame provided by the above embodiments belong to the same concept, and specific implementation processes thereof are detailed in the method embodiments and are not described herein again.
Fig. 6 is a schematic diagram illustrating a structure of a terminal according to an exemplary embodiment. The terminal may be used to implement the method of generating image frames provided in the above embodiments.
The terminal 600 may include RF (Radio Frequency) circuitry 610, memory 620 including one or more computer-readable storage media, an input unit 630, a display unit 640, a sensor 650, audio circuitry 660, a WiFi (wireless fidelity) module 670, a processor 680 including one or more processing cores, and a power supply 690. Those skilled in the art will appreciate that the terminal structure shown in fig. 6 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
the RF circuit 610 may be used for receiving and transmitting signals during information transmission and reception or during a call, and in particular, for receiving downlink information from a base station and then processing the received downlink information by the one or more processors 680; in addition, data relating to uplink is transmitted to the base station. In general, RF circuitry 610 includes, but is not limited to, an antenna, at least one Amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (Low Noise Amplifier), a duplexer, and the like. In addition, the RF circuitry 610 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to GSM (Global System for Mobile communications), GPRS (General Packet Radio Service), CDMA (Code Division Multiple Access), WCDMA (Wideband Code Division Multiple Access), LTE (Long Term Evolution), email, SMS (Short Messaging Service), and the like.
The memory 620 may be used to store software programs and modules, and the processor 680 may execute various functional applications and data processing by operating the software programs and modules stored in the memory 620. The memory 620 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the terminal 600, and the like. Further, the memory 620 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 620 may also include a memory controller to provide the processor 680 and the input unit 630 access to the memory 620.
The input unit 630 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. In particular, the input unit 630 may include a touch sensitive surface 631 as well as other input devices 632. The touch sensitive surface 631, also referred to as a touch display screen or a touch pad, may collect touch operations by a user (e.g., operations by a user on the touch sensitive surface 631 or near the touch sensitive surface 631 using any suitable object or attachment such as a finger, a stylus, etc.) on or near the touch sensitive surface 631 and drive the corresponding connection device according to a predetermined program. Alternatively, the touch sensitive surface 631 may comprise two parts, a touch detection means and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 680, and can receive and execute commands sent by the processor 680. In addition, the touch sensitive surface 631 may be implemented using various types of resistive, capacitive, infrared, and surface acoustic waves. The input unit 630 may include other input devices 632 in addition to the touch-sensitive surface 631. In particular, other input devices 632 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 640 may be used to display information input by or provided to a user and various graphical user interfaces of the terminal 600, which may be made up of graphics, text, icons, video, and any combination thereof. The Display unit 640 may include a Display panel 641, and optionally, the Display panel 641 may be configured in the form of an LCD (Liquid Crystal Display), an OLED (Organic Light-Emitting Diode), or the like. Further, the touch-sensitive surface 631 may overlay the display panel 641, and when the touch-sensitive surface 631 detects a touch operation thereon or nearby, the touch operation is transmitted to the processor 680 to determine the type of the touch event, and then the processor 680 provides a corresponding visual output on the display panel 641 according to the type of the touch event. Although in FIG. 6, the touch-sensitive surface 631 and the display panel 641 are implemented as two separate components to implement input and output functions, in some embodiments, the touch-sensitive surface 631 and the display panel 641 may be integrated to implement input and output functions.
The terminal 600 may also include at least one sensor 650, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that may adjust the brightness of the display panel 641 according to the brightness of ambient light, and a proximity sensor that may turn off the display panel 641 and/or the backlight when the terminal 600 is moved to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, and can be used for applications of recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured in the terminal 600, detailed descriptions thereof are omitted.
Audio circuit 660, speaker 661, and microphone 662 can provide an audio interface between a user and terminal 600. The audio circuit 660 may transmit the electrical signal converted from the received audio data to the speaker 661, and convert the electrical signal into an audio signal through the speaker 661 for output; on the other hand, the microphone 662 converts the collected sound signal into an electrical signal, which is received by the audio circuit 660 and converted into audio data, which is then processed by the audio data output processor 680 and then passed through the RF circuit 610 to be transmitted to, for example, another terminal, or output to the memory 620 for further processing. The audio circuit 660 may also include an earbud jack to provide communication of a peripheral headset with the terminal 600.
WiFi belongs to short-distance wireless transmission technology, and the terminal 600 can help the user send and receive e-mails, browse web pages, access streaming media, etc. through the WiFi module 670, and it provides wireless broadband internet access for the user. Although fig. 6 shows the WiFi module 670, it is understood that it does not belong to the essential constitution of the terminal 600, and can be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 680 is a control center of the terminal 600, connects various parts of the entire handset using various interfaces and lines, and performs various functions of the terminal 600 and processes data by operating or executing software programs and/or modules stored in the memory 620 and calling data stored in the memory 620, thereby integrally monitoring the handset. Optionally, processor 680 may include one or more processing cores; preferably, the processor 680 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 680.
The terminal 600 also includes a power supply 690 (e.g., a battery) for powering the various components, which may be logically coupled to the processor 680 via a power management system to manage charging, discharging, and power consumption via the power management system. The power supply 690 may also include any component including one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
Although not shown, the terminal 600 may further include a camera, a bluetooth module, and the like, which will not be described herein. Specifically, in this embodiment, the display unit of the terminal 600 is a touch screen display, the terminal 600 further includes a memory, and one or more programs, where the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for:
receiving an operation instruction input by a user;
performing logic processing on the operation instruction through a program auxiliary thread based on a program operation parameter at a preset moment to obtain a processing result;
and generating a target image frame according to the processing result through the program main thread, wherein the target image frame is a subsequent image frame of the image frame which is generated when the processing result is obtained.
Optionally, after receiving the operation instruction input by the user, the method further includes:
judging the operation type corresponding to the operation instruction through a program message distribution thread;
and if the operation type of the operation instruction is a preset operation, sending the operation instruction to a program auxiliary thread through the message distribution thread.
Optionally, the performing, by the program assistant thread, logic processing on the operation instruction based on the program operation parameter at the preset time to obtain a processing result further includes:
storing the processing result to an operation result queue;
the generating, by the program main thread, a target image frame according to the processing result includes:
and reading the processing result stored in the operation result queue through the program main thread, and generating a target image frame according to the processing result.
Optionally, the performing, by the program assistant thread, a logic process on the operation instruction based on a program running parameter at a preset time to obtain a processing result includes:
in a target processing cycle of a program assistant thread, performing logic processing on the operation instruction through the program assistant thread based on a program operation parameter at the starting moment of the target processing cycle to obtain a processing result, wherein the target processing cycle is a cycle next to the current processing cycle of the program assistant thread when the operation instruction is received.
Optionally, the method further includes:
recording the receiving time corresponding to the operation instruction through a program message distribution thread;
the logic processing is performed on the operation instruction through the program assistant thread based on the program operation parameter at the preset moment to obtain a processing result, and the logic processing method comprises the following steps:
and performing logic processing on the operation instruction by the program auxiliary thread based on the program operation parameters at the receiving moment to obtain a processing result.
In the embodiment of the invention, after the user operates the input device, the program auxiliary thread can quickly carry out logic processing on the operation instruction based on the program content, and the main thread of the program does not need to respond to the operation instruction after the current image frame is generated, so that the deviation of the image frame finally displayed by the terminal is small.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (6)

1. A method of generating an image frame, the method comprising:
receiving an operation instruction input by a user;
through the auxiliary thread of the program, based on the program running parameters at the preset moment, the operation instruction is logically processed to obtain a processing result, which includes: in a target processing cycle of a program assistant thread, performing logic processing on the operation instruction through the program assistant thread based on a program operation parameter at the starting moment of the target processing cycle to obtain a processing result, wherein the target processing cycle is the next cycle of the current processing cycle of the program assistant thread when the operation instruction is received;
generating a target image frame according to the processing result through the program main thread, wherein the target image frame is a subsequent image frame of the image frame which is generated when the processing result is obtained;
after receiving the operation instruction input by the user, the method further comprises the following steps:
judging the operation type corresponding to the operation instruction through a program message distribution thread;
and if the operation type of the operation instruction is preset operation, the operation instruction is sent to a program auxiliary thread through the message distribution thread, and the working frequency of the program message distribution thread and the working frequency of the program auxiliary thread are both higher than the working frequency of the program main thread.
2. The method of claim 1, wherein after performing logic processing on the operation instruction by the auxiliary program thread based on a program operation parameter at a preset time to obtain a processing result, the method further comprises:
storing the processing result to an operation result queue;
the generating, by the program main thread, a target image frame according to the processing result includes:
and reading the processing result stored in the operation result queue through the program main thread, and generating a target image frame according to the processing result.
3. The method according to any one of claims 1-2, further comprising:
recording the receiving time corresponding to the operation instruction through a program message distribution thread;
the logic processing is performed on the operation instruction through the program assistant thread based on the program operation parameter at the preset moment to obtain a processing result, and the logic processing method comprises the following steps:
and performing logic processing on the operation instruction by the program auxiliary thread based on the program operation parameters at the receiving moment to obtain a processing result.
4. An apparatus for generating an image frame, the apparatus comprising:
the receiving module is used for receiving an operation instruction input by a user;
the processing module is used for carrying out logic processing on the operation instruction based on the program operation parameters at the preset moment through the program assistant thread to obtain a processing result;
a generating module, configured to generate, by the program main thread, a target image frame according to the processing result, where the target image frame is a subsequent image frame of an image frame that is being generated when the processing result is obtained;
the device further comprises:
the judging module is used for judging the operation type corresponding to the operation instruction through a program message distribution thread after receiving the operation instruction input by a user;
the sending module is used for sending the operating instruction to a program auxiliary thread through the message distribution thread if the operating type of the operating instruction is a preset operation;
the processing module is specifically configured to:
in a target processing cycle of a program auxiliary thread, performing logic processing on the operation instruction by the program auxiliary thread based on a program operation parameter at the starting moment of the target processing cycle to obtain a processing result, wherein the target processing cycle is the next cycle of the current processing cycle of the program auxiliary thread when the operation instruction is received, and the working frequencies of the program message distribution thread and the program auxiliary thread are both higher than the working frequency of the program main thread.
5. The apparatus of claim 4, further comprising:
the storage module is used for carrying out logic processing on the operation instruction based on program operation parameters at a preset moment through a program assistant thread to obtain a processing result, and then storing the processing result into an operation result queue;
the generation module is specifically configured to:
and reading the processing result stored in the operation result queue through the program main thread, and generating a target image frame according to the processing result.
6. The apparatus of any of claims 4-5, further comprising:
the recording module is used for recording the receiving time corresponding to the operation instruction through a program message distribution thread;
the processing module is specifically configured to:
and performing logic processing on the operation instruction by the program auxiliary thread based on the program operation parameters at the receiving moment to obtain a processing result.
CN201710258406.3A 2017-04-19 2017-04-19 Method and device for generating image frame Active CN107193551B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710258406.3A CN107193551B (en) 2017-04-19 2017-04-19 Method and device for generating image frame

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710258406.3A CN107193551B (en) 2017-04-19 2017-04-19 Method and device for generating image frame

Publications (2)

Publication Number Publication Date
CN107193551A CN107193551A (en) 2017-09-22
CN107193551B true CN107193551B (en) 2021-02-02

Family

ID=59872070

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710258406.3A Active CN107193551B (en) 2017-04-19 2017-04-19 Method and device for generating image frame

Country Status (1)

Country Link
CN (1) CN107193551B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110502294B (en) * 2019-07-20 2021-08-20 华为技术有限公司 Data processing method and device and electronic equipment
CN111104964B (en) * 2019-11-22 2023-10-17 北京永航科技有限公司 Method, equipment and computer storage medium for matching music with action
CN111781884B (en) * 2020-06-23 2021-03-23 中国计量科学研究院 Energy monitoring system

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104869398A (en) * 2015-05-21 2015-08-26 大连理工大学 Parallel method of realizing CABAC in HEVC based on CPU+GPU heterogeneous platform
CN105631921A (en) * 2015-12-18 2016-06-01 网易(杭州)网络有限公司 Method and device for processing image data

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104869398A (en) * 2015-05-21 2015-08-26 大连理工大学 Parallel method of realizing CABAC in HEVC based on CPU+GPU heterogeneous platform
CN105631921A (en) * 2015-12-18 2016-06-01 网易(杭州)网络有限公司 Method and device for processing image data

Also Published As

Publication number Publication date
CN107193551A (en) 2017-09-22

Similar Documents

Publication Publication Date Title
US11237724B2 (en) Mobile terminal and method for split screen control thereof, and computer readable storage medium
CN106686396B (en) Method and system for switching live broadcast room
CN109062467B (en) Split screen application switching method and device, storage medium and electronic equipment
CN106993227B (en) Method and device for information display
CN106254910B (en) Method and device for recording image
CN107066268B (en) Display position switching method and device for widget application
WO2020007114A1 (en) Method and apparatus for switching split-screen application, storage medium, and electronic device
WO2017206918A1 (en) Terminal awakening accelerating method and related product
CN110874128B (en) Visualized data processing method and electronic equipment
CN106791916B (en) Method, device and system for recommending audio data
CN107193551B (en) Method and device for generating image frame
CN111273955B (en) Thermal restoration plug-in optimization method and device, storage medium and electronic equipment
CN110688051B (en) Screen recording operation method and device, computer readable storage medium and terminal
CN112040324A (en) Playing progress adjusting method and device, storage medium and terminal
CN110221765B (en) Video file playing method and device, storage medium and terminal
WO2017206860A1 (en) Processing method of mobile terminal and mobile terminal
CN108564539B (en) Method and device for displaying image
CN113050863A (en) Page switching method and device, storage medium and electronic equipment
CN109660445B (en) Message processing method, device and storage medium
CN110312995B (en) Application program accelerated starting method and device and terminal
CN105159655B (en) Behavior event playing method and device
CN108920086B (en) Split screen quitting method and device, storage medium and electronic equipment
CN105320532B (en) Method, device and terminal for displaying interactive interface
WO2013152656A1 (en) Method and mobile terminal for drawing sliding track
CN108111553B (en) Method and device for providing service

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant