WO2022100646A1 - Picture frame rate adjustment method for electronic device, electronic device, and storage medium - Google Patents

Picture frame rate adjustment method for electronic device, electronic device, and storage medium Download PDF

Info

Publication number
WO2022100646A1
WO2022100646A1 PCT/CN2021/129988 CN2021129988W WO2022100646A1 WO 2022100646 A1 WO2022100646 A1 WO 2022100646A1 CN 2021129988 W CN2021129988 W CN 2021129988W WO 2022100646 A1 WO2022100646 A1 WO 2022100646A1
Authority
WO
WIPO (PCT)
Prior art keywords
frame rate
sleep
game
frame
electronic device
Prior art date
Application number
PCT/CN2021/129988
Other languages
French (fr)
Chinese (zh)
Inventor
潘品睿
陈毓书
Original Assignee
深圳市万普拉斯科技有限公司
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 深圳市万普拉斯科技有限公司 filed Critical 深圳市万普拉斯科技有限公司
Publication of WO2022100646A1 publication Critical patent/WO2022100646A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4418Suspend and resume; Hibernate and awake
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/14Digital output to display device ; Cooperation and interconnection of the display device with other functional units
    • G06F3/147Digital output to display device ; Cooperation and interconnection of the display device with other functional units using display panels
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks

Definitions

  • the present application relates to the technical field of image processing, and in particular, to a frame rate adjustment method of an electronic device, an electronic device, and a storage medium.
  • the drawing thread of the game will load the drawn game screen into the buffer, and then the center (SurfaceFlinger) used to manage the screen in the operating system will take out the game screen from the buffer; however, for For electronic devices, the higher and more refined the frame rate of the picture, the more likely the electronic device will get hot.
  • the method of reducing the game frame rate is generally used to reduce the heat generation of electronic devices.
  • the frame rate can only be reduced by controlling the frequency of the display screen.
  • a display screen whose refresh rate can be controlled at will is expensive, and the reduced frame rate is usually fixed, so it does not have flexibility and scalability.
  • the present application provides a frame rate adjustment method for electronic equipment, an electronic device and a storage medium, which solves the problem that a display screen whose screen refresh frequency can be controlled at will cost is relatively high, and the reduced frame rate is not flexible and expandable. The problem.
  • a first aspect of the present application provides a method for adjusting a picture frame rate of an electronic device, including: identifying a drawing thread of the electronic device to obtain a game drawing thread of the electronic device running a game; and judging whether to change according to the whitelist and the current state of the electronic device Game frame rate, the whitelist contains at least the frame rates corresponding to different states of the electronic device; if the game screen needs to reduce the frame rate, before loading the game screen drawn by the drawing thread into the buffer or into any After the buffer, or when the drawing thread calls the drawing function library, the sleep time is calculated and the drawing thread is put to sleep; and after the sleep time is over, the sleep state of the drawing thread is released to slow down the game screen The output time interval will reduce the frame rate of the game screen.
  • the calculation of the sleep time includes: the time difference between obtaining the sleep end time of the previous frame of the game screen and executing the judgment on whether the game screen of the current frame needs to sleep; obtaining the desired frame of the frame rate of the game screen in the buffer or whitelist
  • the sleep time is calculated according to the time difference and the expected frame length; the calculation formula of the sleep time is as follows:
  • SleepDuration represents the sleep time
  • ExpectedPeriod represents the expected frame length
  • TimeDiff represents the time difference
  • the calculating the sleep time further includes: when the game screen of the current frame has at least two and an even number of frames, calculating a sleep correction item; according to the time difference, the expected frame length and the sleep correction item Calculate the sleep time; the calculation formula of the sleep time is as follows:
  • SleepDuration represents the sleep time
  • ExpectedPeriod represents the expected frame length
  • TimeDiff represents the time difference
  • SleepCorrection represents the sleep correction item.
  • the calculating the sleep correction item includes: calculating the average frame length of all frames of the game screen of the current frame; calculating the difference between the expected frame length and the average frame length, and using the difference as the sleep correction term; the formula for calculating the sleep correction term is as follows:
  • SleepCorrection represents the sleep correction item, Represents ExpectedPeriod
  • EFPS is the expected frame rate preset by the game
  • N represents the size of the small window in the game screen of the current frame
  • the size of the small window represents the number of frames included in the calculation at one time.
  • Fi represents the frame length of the ith frame
  • i is the ith frame in the current frame.
  • the calculating the sleep correction item includes: obtaining the size of the small window in the game screen of the current frame; calculating the frame lengths of all frames of the game screen of the current frame; The frame length of all frames of the picture calculates the sleep correction term; the formula for calculating the sleep correction term is as follows:
  • Q represents the sleep correction term
  • EFPS is the expected frame rate preset by the game
  • N represents the size of the small window in the game screen
  • Fi represents the frame length of the i-th frame of the small window of the game screen.
  • the calculation of the sleep time further includes: obtaining the size of the large window and the size of the small window in the game screen of the current frame, where the size of the large window represents the number of frames included in the calculation at one time, wherein the size of the large window is larger than the size of the small window; calculate a long-term correction value; obtain a short-term correction value according to the sleep correction term; use the time difference, the expected frame length, the long-term correction value and the sleep correction term to calculate the described sleep time; the calculation formula of described sleep time is as follows:
  • SleepDuration represents the sleep time
  • ExpectedPeriod represents the expected frame length
  • TimeDiff represents the time difference
  • LTC represents the long-term correction value
  • STC represents the short-term correction value
  • the short-term correction value is consistent with the sleep correction item.
  • the calculating the long-term correction value includes: setting a gear interval, each integer in the gear interval is a gear, and each of the gears represents a time value; dividing the large window screen into are different sub-areas; match the gears for each sub-area according to the time of each sub-area; obtain the gears matched by each of the sub-areas, and use the most matched gear as the long-term Correction value.
  • the calculating the long-term correction value further includes: using machine learning or a neural network to divide each of the sub-regions into different categories; matching different categories with different gears; matching the most The gear is used as the long-term correction value.
  • the calculating the long-term correction value includes: acquiring at least one current feature value of the electronic device that affects the frame rate of the game screen; inputting the current feature value into the reinforcement learning model, and receiving the preliminary correction value output by the reinforcement learning model ; Use the preparatory correction value to replace the long-term correction value to calculate the sleep time; after the sleep time of the drawing thread, calculate the average frame rate of the game screen, and obtain the target under the current feature value frame rate; compare the average frame rate and the target frame rate; if the average frame rate is greater than the target frame rate, input the first negative feedback data to the reinforcement learning model, and make the reinforcement learning model output
  • the preparatory correction value of moves in the direction of increasing until the average frame rate is equal to the target frame rate; if the average frame rate is less than the target frame rate, input a second negative value to the reinforcement learning model Feedback data to make the preliminary correction value output by the reinforcement learning model move in a direction of decreasing until the average frame rate is equal to the target frame rate; if the average frame rate is equal to the target
  • a second aspect of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, when the processor executes the computer program, the above-mentioned any of the methods described in .
  • a third aspect of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements any one of the methods described above.
  • the game drawing thread when the frame rate of the game picture needs to be reduced, the game drawing thread only needs to be put to sleep, and the sleep state of the game drawing thread is released after the sleep is over, so that the game drawing thread is released from the sleep state.
  • the adjustment of the frame rate of the game screen by the thread sleeps for a period of time, thus slowing down the output interval of the game drawing thread from the buffer to the game screen, thereby reducing the frame rate of the game screen, so there is no need to use the screen refresh rate
  • the display can be controlled at will
  • the application of the screen to the electronic device can reduce the frequency of the game screen and reduce the development cost of the electronic device.
  • the sleep time By adjusting the sleep time, the time interval of the game drawing thread from the buffer to the game screen can be adjusted, so as to control the game screen at will. Therefore, manufacturers of electronic equipment can adjust the frame rate according to the performance, power consumption and temperature of the hardware, thus improving the flexibility and scalability of the game frame rate.
  • FIG. 1 is a schematic flowchart of a method for adjusting a picture frame rate of an electronic device according to an embodiment of the present application
  • Fig. 2 is the relation diagram of TimeDiff and sleep time of the picture frame rate adjustment method of the electronic device of the embodiment of the present application;
  • FIG. 3 is a schematic structural block diagram of an electronic device according to an embodiment of the present application.
  • a method for adjusting the frame rate of an electronic device proposed by the application includes: S1, identifying the drawing thread of the electronic device, obtaining the game drawing thread of the game running on the electronic device, and obtaining, for example, the game name, and the whitelist that comes with the game set by the game manufacturer.
  • the whitelist contains at least the frame rates corresponding to different states of the electronic device; S2. Determine whether to change the game frame rate according to the whitelist and the current state of the electronic device; S3. If the game screen If the frame rate needs to be reduced, before or after loading the game screen drawn by the game drawing thread into the buffer, or when the drawing thread calls the drawing function library, calculate the sleep time and put the game drawing thread to sleep ; S4. After the sleep time ends, release the sleep state of the game drawing thread, so as to slow down the output time interval of the game screen and reduce the frame rate of the game screen.
  • the drawing thread responsible for issuing drawing commands will call the drawing function library of the operating system, so the drawing thread can be easily identified, so that when the drawing thread of the game or application calls the drawing function library, according to the process of the thread Identifier (Process Identity, PID) to identify whether the current drawing thread is the target of frame stabilization (that is, whether the game needs to be stabilized). If it belongs to the goal of stable frame, sleep the drawing thread for a period of time at the moment. As long as the sleep time is properly controlled, the game can slow down the time interval of outputting the picture, and the system computing unit will have more time to do calculations, so that It can operate at a lower frequency and ultimately achieve the goal of reducing power consumption.
  • PID Process Identity
  • the frame rate of the game is reduced by means of indirect influence.
  • the indirect influence refers to a module or thread that adopts a certain "synchronization mechanism" with the drawing thread of the game, and the synchronization mechanism makes the drawing thread of the game wait for the module or thread. After the execution is completed, the work of the next frame will continue, so it can indirectly affect the game frame rate.
  • the modules or threads involved in the synchronization mechanism include: Inter-process communication (IPC) calls or core layer Hooks, etc.
  • the calculation of the sleep time includes: the time difference between obtaining the sleep end time of the previous frame of the game screen and executing the judgment on whether the game screen of the current frame needs to sleep; obtaining the expected frame rate of the frame rate of the game screen in the whitelist; using the expected frame rate to calculate The expected frame length is calculated; the sleep time is calculated according to the time difference and the expected frame length; the calculation formula of the sleep time is shown in the following formula 1:
  • SleepDuration represents the sleep time
  • ExpectedPeriod represents the expected frame length
  • TimeDiff represents the time difference
  • the TimeDiff is obtained according to the time from the previous sleep time to the current sleep judgment time. If the TimeDiff is 8ms, the sleep time obtained according to formula 1 is: 12ms, what needs to be understood is that the game drawing thread has been put to sleep since the last time; in order to wait for other threads of the game to complete the operation, the game thread may also go through a period of sleep time. Wake up and get a picture of how it should be drawn. This kind of sleep is controlled by the game itself, and the sleep time TimeDiff is required by this application and is used to calculate SleepDuration.
  • Figure 2 is a schematic diagram of the time difference TimeDiff equal to 8ms and the above-mentioned sleep time SleepDuration equal to 12ms.
  • the top is the drawing thread, or other threads that will indirectly affect the drawing thread
  • the middle part of the thread indicates that the thread is in a sleep state that is not performed by the game itself (the mobile phone is in a state after the sleep time SleepDuration added in this embodiment)
  • the duration is the sleep time.
  • Enqueue in Figure 2 represents changing the game
  • the content in Figure 2 shows that when you want the game to stabilize at 50FPS (frame length is 20ms), the time difference TimeDiff is 8ms, and the sleep time (the area shown by SleepDuration) is 12ms.
  • calculating the sleep time further includes: recording the interval of each frame of the game screen, and calculating the sleep correction item when calculating the sleep time of the current frame; according to the recorded interval of each frame of the game screen
  • the sleep time is calculated by the time difference, the expected frame length and the sleep correction term; the calculation formula of the sleep time is shown in the following formula 2:
  • SleepDuration represents the sleep time
  • ExpectedPeriod represents the expected frame length
  • TimeDiff represents the time difference
  • SleepCorrection represents the sleep correction item.
  • the interval time between each frame of the game screen of multi-threaded games may be different.
  • the long and short frames are the result of one long frame and one short frame in the game.
  • the overall situation may not cause frame drop.
  • the data of the current frame is used to determine the sleep time, it will cause the short frame to sleep for too long, making it unable to complement the long frame. , which will eventually cause the frame rate to drop; in order to make the frame rate jitter more stable, a sleep correction item needs to be added to correct the sleep time.
  • calculating the sleep correction item includes: calculating the average frame length of all frames of the game screen; calculating the difference between the expected frame length and the average frame length, and using the difference as the sleep correction item; the formula for calculating the sleep correction item is as follows:
  • SleepCorrection represents the sleep correction item, Represents ExpectedPeriod, EFPS is the expected frame rate preset by the game, Represents the average frame length, N represents the size of the small window in the game screen of the current frame, and the size of the small window represents the number of frames included in the calculation at one time.
  • F i represents the frame length of the ith frame, and i is the ith frame in the current frame.
  • calculating the sleep correction item includes: acquiring the size of the small window in the game screen; calculating the frame length of the game screen of the current frame; calculating sleep according to the expected frame length, the size of the small window and the frame length of the game screen of the current frame Correction term; the formula for calculating the sleep correction term is as follows:
  • Q represents the sleep correction term
  • EFPS is the expected frame rate preset by the game
  • N represents the size of the small window in the game screen
  • Fi represents the frame length of the i-th frame of the small window of the game screen.
  • the calculation method of the sleep correction term can also be obtained by using a neural network, for example, using an artificial neural network (Artificial Neural Networks, ANN) or a convolutional neural network (Convolution Neural Networks, CNN) or a fully connected neural network ( Fully-Connected Neural Networks, FC).
  • ANN Artificial Neural Networks
  • CNN convolution Neural Networks
  • FC Fully-Connected Neural Networks
  • the above network can be obtained through supervised learning, and its training data can be recorded by recording the frame length of each frame of the game and the above TimeDiff, and through artificial countermeasures. Push to get the time you need to sleep and sleep modifiers.
  • the sleep time calculated by formula 2 takes into account the correction of long frames and short frames, which greatly increases the stability of the frame rate of the game screen.
  • the calculation method centered on formula 2 can only correct the local frame rate (small window screen), and does not take into account the long-term frame rate trend of the system or the game, there is still room for improvement in the stability of the frame rate.
  • a long-term correction value and a short-term correction value are introduced.
  • calculating the sleep time also includes: acquiring the size of the large window and the size of the small window in the game screen, the size of the large window represents the number of frames included in the calculation at one time, wherein the size of the large window is larger than the size of the small window Calculate the long-term correction value; obtain the short-term correction value according to the sleep correction item; use the time difference, expected frame length, long-term correction value and sleep correction item to calculate the sleep time; the calculation formula of the sleep time is as follows:
  • SleepDuration represents the sleep time
  • ExpectedPeriod represents the expected frame length
  • TimeDiff represents the time difference
  • LTC represents the long-term correction value
  • STC represents the short-term correction value
  • the short-term correction value is consistent with the sleep correction item.
  • calculating the long-term correction value includes: setting a gear interval, each integer in the gear interval is a gear, and each gear represents a time value; dividing the large window screen into different sub-areas; Match the gears for each sub-area according to the time of each sub-area; obtain the gears matched by each sub-area, and use the most matched gear as the long-term correction value.
  • the long-term correction value is divided into several gears, for example, from -5 to +5, each integer is a gear, and a long enough time (large window screen) is counted at one end, such as half a Second or one second frame rate, and divide the large window into several sub-regions, each sub-region votes on the gear according to the internal situation, and finally uses the vote-drunk gear as the current long-term correction value, and each sub-region decides
  • the method of voting for a certain gear can be obtained in the following ways: each sub-area can be rounded up with the result of the short-term correction value, and finally the corresponding gear corresponding to the result is matched and voted. For example, the current group area has a short-term correction value. +4.3ms is calculated, and after rounding, the sub-region matches the +4 gear and votes for the +4 gear.
  • each sub-area decides to cast a certain gear can also be obtained by the following methods: use machine learning or a neural network to classify the current sub-area, and each category corresponds to a certain gear.
  • calculating the long-term correction value also includes: using machine learning or neural network to divide each sub-region into different categories; matching different categories with different gears; taking the most matched gear as the long-term correction value.
  • the calculation of the long-term correction value includes: obtaining at least one current feature value of the electronic device that affects the frame rate of the game screen; inputting the current feature value into the reinforcement learning model, and receiving the preliminary correction value output by the reinforcement learning model; using the preliminary correction value instead of The long-term correction value calculates the sleep time; after the sleep time of the game drawing thread, the average frame rate of the game screen is calculated, and the target frame rate under the current feature value is obtained; the average frame rate and the target frame rate are compared; if the average frame rate is greater than the target frame rate frame rate, input the first negative feedback data to the reinforcement learning model, so that the preparatory correction value output by the reinforcement learning model moves in the direction of increasing until the average frame rate is equal to the target frame rate; if the average frame rate is less than the target frame rate, then Input the second negative feedback data to the reinforcement learning model, so that the preparatory correction value output by the reinforcement learning model moves to a smaller direction until the average frame rate is equal to the target frame rate; if the average frame rate is
  • the current feature value may be the frame length (Frame Length), the execution time (Runtime), or TimeDiff, etc. It can be understood that as long as it is a feature value that can affect the frame rate of the game screen, it can be used as the present embodiment.
  • the output of the enhancement model can be the gear corresponding to the long-term correction value, or it can be described as the modified value of the long-term correction value. Increase 2.3ms), -1.5ms (decrease 1.5ms for long-term correction value), etc.
  • the reinforcement learning model can be a Monte Carlo method, a tabular solution method, or an approximate solution method such as an artificial neural network (Artificial Neural Networks).
  • the long-term correction value is zero.
  • the calculation method of the short-term correction value is consistent with the algorithm of the sleep correction term.
  • the short-term correction value can also be obtained by using the reinforcement learning model. out, the reinforcement learning model directly outputs the short-term correction value.
  • the long-term corrections and short-term corrections may be replaced by a neural network-like network; for example, using CNN or FC to acquire local data and simulate the effects of short-term corrections.
  • RNN Recurrent Neural Network
  • LSTM Long-Short-Term-Memory
  • input sequence data that is, the frame length of each frame, but also input features such as Runtime, TimeDiff, etc. that may be used to judge the running smoothness of the game, and represent the data in another dimension.
  • the frame length of several frames is input into the CNN to obtain local data, and then the data is input into the LSTM, and the LSTM outputs the current total correction value.
  • the frame length of several frames is also input into the CNN to obtain local data, and then the data is input into the LSTM.
  • the LSTM will selectively retain the previous memory and will represent The "state" of the memory is sent to the next frame, and the memory retains the long-term trend.
  • the model can not only judge the trend of the sleep correction item under the long-term trend, but also have the function of corresponding short-term changes.
  • the long-term correction value and the short-term correction value can be calculated separately by LSTM.
  • the electronic device includes: a memory 601, a processor 602, and a computer program stored in the memory 601 and running on the processor 602, and the processor 602 executes the computer When the program is executed, the method for adjusting the picture frame rate of the electronic device described above is implemented.
  • the electronic device further includes: at least one input device 603 and at least one output device 604 .
  • the above-mentioned memory 601 , processor 602 , input device 603 and output device 604 are connected through a bus 605 .
  • the input device 603 may specifically be a camera, a touch panel, a physical button, a mouse, or the like.
  • the output device 604 may specifically be a display screen.
  • the memory 601 may be a high-speed random access memory (RAM, Random Access Memory) memory, or may be a non-volatile memory (non-volatile memory), such as a disk memory.
  • RAM Random Access Memory
  • non-volatile memory such as a disk memory.
  • Memory 601 is used to store a set of executable program codes, and processor 602 is coupled to memory 601 .
  • an embodiment of the present application further provides a computer-readable storage medium, which may be provided in the electronic device in each of the foregoing embodiments, and the computer-readable storage medium may be the foregoing memory 601.
  • a computer program is stored on the computer-readable storage medium, and when the program is executed by the processor 602, the method for adjusting the picture frame rate of the electronic device described in the foregoing embodiments is implemented.
  • the computer-storable medium may also be a U disk, a removable hard disk, a read-only memory 601 (ROM, Read-Only Memory), a RAM, a magnetic disk or an optical disk and other mediums that can store program codes.
  • ROM Read-Only Memory
  • RAM Random Access Memory

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Multimedia (AREA)
  • Artificial Intelligence (AREA)
  • Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Medical Informatics (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

Disclosed in the present application is a picture frame rate adjustment method for an electronic device, comprising: identifying a drawing thread of an electronic device to obtain a game name and a game vendor; according to a whitelist set by the game vendor and the current state of the electronic device, determining whether to change a game frame rate; if a game picture needs to reduce the frame rate, loading, before or after a buffer region, the game picture that is drawn by the drawing thread, or when the drawing thread invokes a graphics library, calculating a sleep time, and enabling the drawing thread to sleep; and after a sleep time is ended, releasing the sleep state of the drawing thread to reduce the output time interval of the game picture, and reduce the frame rate of the game picture. Adjusting the sleep time can adjust the time interval of the game picture in the buffer region by the drawing thread of a game, thereby controlling the frame rate of the game picture at will, and thus, the manufacturer of the electronic device can adjust the frame rate according to the performance, power consumption, and temperature of hardware, thereby improving the flexibility and expandability of the game frame rate.

Description

电子设备的画面帧率调整方法、电子装置及存储介质Frame rate adjustment method of electronic equipment, electronic device and storage medium
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请基于申请号为202011283182.X、申请日为2020年11月16日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on the Chinese patent application with the application number of 202011283182.X and the filing date of November 16, 2020, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is incorporated herein by reference.
技术领域technical field
本申请涉及图像处理技术领域,具体涉及一种电子设备的画面帧率调整方法、电子装置及存储介质。The present application relates to the technical field of image processing, and in particular, to a frame rate adjustment method of an electronic device, an electronic device, and a storage medium.
背景技术Background technique
随着科学技术的发展,电子设备的中央处理器(Central Processing Unit,CPU)、图形处理器(Graphics Processing Unit,GPU)等部件的运算力得到了大幅度的强化,因此对于电子设备的游戏类等功耗较大的图像显示应用,画面的帧率及复杂度逐渐提升,以期得到更好的使用者体验。With the development of science and technology, the computing power of components such as the Central Processing Unit (CPU) and Graphics Processing Unit (GPU) of electronic equipment has been greatly strengthened. For image display applications with high power consumption, the frame rate and complexity of the picture are gradually increased, in order to obtain a better user experience.
在电子设备运行游戏时,游戏的绘图线程会将绘制好的游戏画面装入缓冲区中,随后操作系统中的用来管理画面的中枢(SurfaceFlinger)会从缓冲区中取出游戏画面;然而,对于电子设备来说,画面的帧率越高、越精致,就会使得电子设备更容易发烫。When the electronic device runs the game, the drawing thread of the game will load the drawn game screen into the buffer, and then the center (SurfaceFlinger) used to manage the screen in the operating system will take out the game screen from the buffer; however, for For electronic devices, the higher and more refined the frame rate of the picture, the more likely the electronic device will get hot.
为了使得电子设备降低发烫几率,一般都会使用降低游戏帧率的方法来减少电子设备的发热,但是对于电子设备而言,目前只能通过控制显示屏的刷屏频率来降低帧率,但采用刷屏频率可随意控制的显示屏成本较高,且降低的画面帧率通常是固定的,因此不具备弹性与扩充性。In order to reduce the risk of overheating of electronic devices, the method of reducing the game frame rate is generally used to reduce the heat generation of electronic devices. However, for electronic devices, the frame rate can only be reduced by controlling the frequency of the display screen. A display screen whose refresh rate can be controlled at will is expensive, and the reduced frame rate is usually fixed, so it does not have flexibility and scalability.
发明内容SUMMARY OF THE INVENTION
鉴于此,本申请提供一种电子设备的画面帧率调整方法、电子装置及存储介质,解决了刷屏频率可随意控制的显示屏成本较高,且降低的画面帧率不具备弹性与扩充性的问题。In view of this, the present application provides a frame rate adjustment method for electronic equipment, an electronic device and a storage medium, which solves the problem that a display screen whose screen refresh frequency can be controlled at will cost is relatively high, and the reduced frame rate is not flexible and expandable. The problem.
本申请第一方面提供一种电子设备的画面帧率调整方法,包括:对电子设备的绘图线程进行识别,得到电子设备运行游戏的游戏绘图线程;根据白名单及电子设备的当前状态判断是否更改游戏帧率,所述白名单内至少具有电子设备不同状态下对应的帧率;若游戏画面需要降低帧率,则在将所述绘图线程绘制好的游戏画面装入缓冲区前或装入所述缓冲区后,或在所述绘图线程呼叫绘图函式库时,计算睡眠时间,将所述绘图线程睡眠;并在所述睡眠时间结束后,解除绘图线程的睡眠状态,以放慢游戏画面的输出时间间隔,降低游戏画面的帧率。A first aspect of the present application provides a method for adjusting a picture frame rate of an electronic device, including: identifying a drawing thread of the electronic device to obtain a game drawing thread of the electronic device running a game; and judging whether to change according to the whitelist and the current state of the electronic device Game frame rate, the whitelist contains at least the frame rates corresponding to different states of the electronic device; if the game screen needs to reduce the frame rate, before loading the game screen drawn by the drawing thread into the buffer or into any After the buffer, or when the drawing thread calls the drawing function library, the sleep time is calculated and the drawing thread is put to sleep; and after the sleep time is over, the sleep state of the drawing thread is released to slow down the game screen The output time interval will reduce the frame rate of the game screen.
其中,所述计算睡眠时间包括:获取上一帧游戏画面的睡眠结束时间至执行所述判断当前帧的游戏画面是否需要睡眠的时间差;获取缓冲区或白名单内游戏画面的帧率的期望帧长;根据所述时间差及所述期望帧长计算出所述睡眠时间;所述睡眠时间的计算公式如下:The calculation of the sleep time includes: the time difference between obtaining the sleep end time of the previous frame of the game screen and executing the judgment on whether the game screen of the current frame needs to sleep; obtaining the desired frame of the frame rate of the game screen in the buffer or whitelist The sleep time is calculated according to the time difference and the expected frame length; the calculation formula of the sleep time is as follows:
SleepDuration=ExpectedPeriod-TimeDiffSleepDuration=ExpectedPeriod-TimeDiff
其中,SleepDuration代表所述睡眠时间,ExpectedPeriod代表所述期望帧长,TimeDiff代表所述时间差。Wherein, SleepDuration represents the sleep time, ExpectedPeriod represents the expected frame length, and TimeDiff represents the time difference.
其中,所述计算睡眠时间还包括:在当前帧的游戏画面具有至少两个、且具有偶数量的帧时,计算睡眠修正项;根据所述时间差、所述期望帧长及所述睡眠修正项计算出所述睡眠时间;所述睡眠时间的计算公式如下:Wherein, the calculating the sleep time further includes: when the game screen of the current frame has at least two and an even number of frames, calculating a sleep correction item; according to the time difference, the expected frame length and the sleep correction item Calculate the sleep time; the calculation formula of the sleep time is as follows:
SleepDuration=ExpectedPeriod-TimeDiff+SleepCorrectionSleepDuration=ExpectedPeriod-TimeDiff+SleepCorrection
其中,SleepDuration代表所述睡眠时间,ExpectedPeriod代表所述期望帧长,TimeDiff代表所述时间差,SleepCorrection代表所述睡眠修正项。Wherein, SleepDuration represents the sleep time, ExpectedPeriod represents the expected frame length, TimeDiff represents the time difference, and SleepCorrection represents the sleep correction item.
其中,所述计算睡眠修正项包括:计算当前帧的游戏画面的所有帧的 平均帧长;计算所述期望帧长与所述平均帧长的差值,将所述差值作为所述睡眠修正项;所述计算睡眠修正项的公式如下:The calculating the sleep correction item includes: calculating the average frame length of all frames of the game screen of the current frame; calculating the difference between the expected frame length and the average frame length, and using the difference as the sleep correction term; the formula for calculating the sleep correction term is as follows:
Figure PCTCN2021129988-appb-000001
Figure PCTCN2021129988-appb-000001
其中,SleepCorrection代表所述睡眠修正项,
Figure PCTCN2021129988-appb-000002
代表ExpectedPeriod,EFPS为游戏预设的期望帧率,
Figure PCTCN2021129988-appb-000003
代表所述平均帧长,N代表当前帧的游戏画面中小窗口的大小,所述小窗口的大小表示一次纳入计算的帧数。Fi代表第i个帧的帧长,i为当前帧中的第i个帧。
Wherein, SleepCorrection represents the sleep correction item,
Figure PCTCN2021129988-appb-000002
Represents ExpectedPeriod, EFPS is the expected frame rate preset by the game,
Figure PCTCN2021129988-appb-000003
represents the average frame length, N represents the size of the small window in the game screen of the current frame, and the size of the small window represents the number of frames included in the calculation at one time. Fi represents the frame length of the ith frame, and i is the ith frame in the current frame.
其中,所述计算睡眠修正项包括:获取当前帧的游戏画面中小窗口的大小;计算当前帧的游戏画面的所有帧的帧长;根据所述期望帧长、小窗口的大小及当前帧的游戏画面的所有帧的帧长计算睡眠修正项;计算睡眠修正项的公式如下:The calculating the sleep correction item includes: obtaining the size of the small window in the game screen of the current frame; calculating the frame lengths of all frames of the game screen of the current frame; The frame length of all frames of the picture calculates the sleep correction term; the formula for calculating the sleep correction term is as follows:
Figure PCTCN2021129988-appb-000004
Figure PCTCN2021129988-appb-000004
其中,Q代表睡眠修正项,
Figure PCTCN2021129988-appb-000005
代表ExpectedPeriod,EFPS为游戏预设的期望帧率,N代表游戏画面中小窗口的大小,Fi代表游戏画面的小窗口的第i个帧的帧长。
where Q represents the sleep correction term,
Figure PCTCN2021129988-appb-000005
Represents ExpectedPeriod, EFPS is the expected frame rate preset by the game, N represents the size of the small window in the game screen, and Fi represents the frame length of the i-th frame of the small window of the game screen.
其中,所述计算睡眠时间还包括:获取当前帧的游戏画面中的大窗口的大小及小窗口的大小,所述大窗口的大小表示一次纳入计算的帧数,其中,所述大窗口的大小大于所述小窗口的大小;计算长期修正值;根据所述睡眠修正项得出短期修正值;使用所述时间差、所述期望帧长、所述长期修正值及所述睡眠修正项计算出所述睡眠时间;所述睡眠时间的计算公式如下:The calculation of the sleep time further includes: obtaining the size of the large window and the size of the small window in the game screen of the current frame, where the size of the large window represents the number of frames included in the calculation at one time, wherein the size of the large window is larger than the size of the small window; calculate a long-term correction value; obtain a short-term correction value according to the sleep correction term; use the time difference, the expected frame length, the long-term correction value and the sleep correction term to calculate the described sleep time; the calculation formula of described sleep time is as follows:
SleepDuration=ExpectedPeriod-TimeDiff+STC+LTCSleepDuration=ExpectedPeriod-TimeDiff+STC+LTC
其中,SleepDuration代表所述睡眠时间,ExpectedPeriod代表所述期望 帧长,TimeDiff代表所述时间差,LTC代表长期修正值,STC代表所述短期修正值,所述短期修正值与所述睡眠修正项一致。Wherein, SleepDuration represents the sleep time, ExpectedPeriod represents the expected frame length, TimeDiff represents the time difference, LTC represents the long-term correction value, STC represents the short-term correction value, and the short-term correction value is consistent with the sleep correction item.
其中,所述计算长期修正值包括:设定一个档位区间,所述档位区间内每个整数均为一个档位,每个所述档位均代表了一个时间值;将大窗口画面划分为不同的子区域;根据每个所述子区域的时间为每个所述子区域匹配所述档位;获取每个所述子区域匹配到的档位,将被匹配最多的档位作为长期修正值。The calculating the long-term correction value includes: setting a gear interval, each integer in the gear interval is a gear, and each of the gears represents a time value; dividing the large window screen into are different sub-areas; match the gears for each sub-area according to the time of each sub-area; obtain the gears matched by each of the sub-areas, and use the most matched gear as the long-term Correction value.
其中,所述计算长期修正值还包括:使用机器学习或神经网络将每个所述子区域分为不同的类别;将不同的所述类别与不同的所述档位相匹配;将被匹配最多的档位作为长期修正值。Wherein, the calculating the long-term correction value further includes: using machine learning or a neural network to divide each of the sub-regions into different categories; matching different categories with different gears; matching the most The gear is used as the long-term correction value.
其中,所述计算长期修正值包括:获取电子设备至少一项影响游戏画面帧率的当前特征值;将所述当前特征值输入强化学习模型中,并接收所述强化学习模型输出的预备修正值;使用所述预备修正值代替所述长期修正值计算所述睡眠时间;在所述绘图线程的所述休眠时间后,计算游戏画面的平均帧率,并获取在所述当前特征值下的目标帧率;对比所述平均帧率及所述目标帧率;若所述平均帧率大于所述目标帧率,则向所述强化学习模型输入第一负反馈数据,令所述强化学习模型输出的所述预备修正值向变大的方向移动,直至所述平均帧率等于所述目标帧率;若所述平均帧率小于所述目标帧率,则向所述强化学习模型输入第二负反馈数据,令所述强化学习模型输出的所述预备修正值向变小的方向移动,直至所述平均帧率等于所述目标帧率;若所述平均帧率等于所述目标帧率,则将所述预备修正值设定为长期修正值。The calculating the long-term correction value includes: acquiring at least one current feature value of the electronic device that affects the frame rate of the game screen; inputting the current feature value into the reinforcement learning model, and receiving the preliminary correction value output by the reinforcement learning model ; Use the preparatory correction value to replace the long-term correction value to calculate the sleep time; after the sleep time of the drawing thread, calculate the average frame rate of the game screen, and obtain the target under the current feature value frame rate; compare the average frame rate and the target frame rate; if the average frame rate is greater than the target frame rate, input the first negative feedback data to the reinforcement learning model, and make the reinforcement learning model output The preparatory correction value of , moves in the direction of increasing until the average frame rate is equal to the target frame rate; if the average frame rate is less than the target frame rate, input a second negative value to the reinforcement learning model Feedback data to make the preliminary correction value output by the reinforcement learning model move in a direction of decreasing until the average frame rate is equal to the target frame rate; if the average frame rate is equal to the target frame rate, then The preliminary correction value is set as a long-term correction value.
本申请第二方面提供一种电子装置,包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时,实现上述中的任意一项所述方法。A second aspect of the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, when the processor executes the computer program, the above-mentioned any of the methods described in .
本申请第三方面提供一种计算机可读存储介质,其上存储有计算机程 序,所述计算机程序被处理器执行时,实现上述中的任意一项所述方法。A third aspect of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements any one of the methods described above.
本申请上述的电子设备的画面帧率调整方法,在需要降低游戏画面的帧率时,只需将游戏绘图线程睡眠,并在睡眠结束后解除游戏绘图线程的睡眠状态即可,从而将游戏绘图线程对游戏画面帧率的调整睡眠一段时间,因此放慢了游戏绘图线程从缓冲区将游戏画面的输出时间间隔,从而降低了游戏画面的帧率,因此无需使用刷屏频率可随意控制的显示屏应用在电子设备上即可降低游戏画面的频率,降低了电子设备的开发成本,而通过调整睡眠时间,能够调整游戏绘图线程从缓冲区将游戏画面的时间间隔,从而随意的控制游戏画面的帧率,因此电子设备的产商可以依据硬件的性能、功耗、温度来调整帧率,从而提升了游戏帧率的弹性与扩充性。In the above-mentioned method for adjusting the picture frame rate of an electronic device of the present application, when the frame rate of the game picture needs to be reduced, the game drawing thread only needs to be put to sleep, and the sleep state of the game drawing thread is released after the sleep is over, so that the game drawing thread is released from the sleep state. The adjustment of the frame rate of the game screen by the thread sleeps for a period of time, thus slowing down the output interval of the game drawing thread from the buffer to the game screen, thereby reducing the frame rate of the game screen, so there is no need to use the screen refresh rate The display can be controlled at will The application of the screen to the electronic device can reduce the frequency of the game screen and reduce the development cost of the electronic device. By adjusting the sleep time, the time interval of the game drawing thread from the buffer to the game screen can be adjusted, so as to control the game screen at will. Therefore, manufacturers of electronic equipment can adjust the frame rate according to the performance, power consumption and temperature of the hardware, thus improving the flexibility and scalability of the game frame rate.
附图说明Description of drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present application more clearly, the following briefly introduces the drawings that are used in the description of the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those skilled in the art, other drawings can also be obtained from these drawings without creative effort.
图1是本申请实施例的电子设备的画面帧率调整方法流程示意图;1 is a schematic flowchart of a method for adjusting a picture frame rate of an electronic device according to an embodiment of the present application;
图2是本申请实施例的电子设备的画面帧率调整方法的TimeDiff与睡眠时间的关系图;Fig. 2 is the relation diagram of TimeDiff and sleep time of the picture frame rate adjustment method of the electronic device of the embodiment of the present application;
图3是本申请实施例电子装置的结构示意框图。FIG. 3 is a schematic structural block diagram of an electronic device according to an embodiment of the present application.
具体实施方式Detailed ways
下面结合附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请一部分实施例,而非全部实施例。基于本申请中的实施例,本领域技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。在不冲突的情况下,下述 各个实施例及其技术特征可以相互组合。The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of this application. In the case of no conflict, the following various embodiments and their technical features can be combined with each other.
请参阅图1,为本申请提出的一种电子设备的画面帧率调整方法,包括:S1、对电子设备的绘图线程进行识别,得到电子设备运行游戏的游戏绘图线程,并获得例如游戏名,及游戏厂商设置的游戏自带的白名单,白名单内至少具有电子设备不同状态下对应的帧率;S2、根据白名单及电子设备的当前状态判断是否更改游戏帧率;S3、若游戏画面需要降低帧率,则在将游戏绘图线程绘制好的游戏画面装入缓冲区前或装入缓冲区后,或在所述绘图线程呼叫绘图函式库时,计算睡眠时间,将游戏绘图线程睡眠;S4、在睡眠时间结束后,解除游戏绘图线程的睡眠状态,以放慢游戏画面的输出时间间隔,降低游戏画面的帧率。Please refer to FIG. 1 , a method for adjusting the frame rate of an electronic device proposed by the application includes: S1, identifying the drawing thread of the electronic device, obtaining the game drawing thread of the game running on the electronic device, and obtaining, for example, the game name, and the whitelist that comes with the game set by the game manufacturer. The whitelist contains at least the frame rates corresponding to different states of the electronic device; S2. Determine whether to change the game frame rate according to the whitelist and the current state of the electronic device; S3. If the game screen If the frame rate needs to be reduced, before or after loading the game screen drawn by the game drawing thread into the buffer, or when the drawing thread calls the drawing function library, calculate the sleep time and put the game drawing thread to sleep ; S4. After the sleep time ends, release the sleep state of the game drawing thread, so as to slow down the output time interval of the game screen and reduce the frame rate of the game screen.
在实际应用中,负责下达绘图指令的绘图线程会呼叫操作系统的绘图函式库,因此绘图线程容易被识别出,从而可以在游戏或应用的绘图线程呼叫绘图函式库时,根据线程的进程标识(Process Identity,PID)来识别目前的绘图线程是否为稳帧的目标(即:是否需要对其稳帧的游戏)。若属于稳帧的目标,则在当下将绘图线程睡眠一段时间,只要睡眠的时间控制得当,就能让游戏放慢输出画面的时间间隔,系统运算单元也就有较为充裕的时间做计算,从而能以较低的频率进行运算,最终达到减少功耗的目标。In practical applications, the drawing thread responsible for issuing drawing commands will call the drawing function library of the operating system, so the drawing thread can be easily identified, so that when the drawing thread of the game or application calls the drawing function library, according to the process of the thread Identifier (Process Identity, PID) to identify whether the current drawing thread is the target of frame stabilization (that is, whether the game needs to be stabilized). If it belongs to the goal of stable frame, sleep the drawing thread for a period of time at the moment. As long as the sleep time is properly controlled, the game can slow down the time interval of outputting the picture, and the system computing unit will have more time to do calculations, so that It can operate at a lower frequency and ultimately achieve the goal of reducing power consumption.
因此在需要降低游戏画面的帧率时,只需将游戏绘图线程睡眠,并在睡眠结束后解除游戏绘图线程的睡眠状态即可,从而将游戏绘图线程对游戏画面帧率的调整进度进行一段时间的睡眠,因此放慢了游戏绘图线程从缓冲区将游戏画面输出的时间间隔,从而降低了游戏画面的帧率。因此无需使用刷屏频率可随意控制的显示屏应用在电子设备上即可降低游戏画面的频率,降低了电子设备的开发成本,而通过调整睡眠时间,能够调整游戏绘图线程将游戏画面放入系缓冲区的时间间隔,即放慢了绘图线程将游戏画面放入缓冲区的时间,从而随意的降低游戏画面的帧率,因此增加了 游戏帧率的弹性。Therefore, when it is necessary to reduce the frame rate of the game screen, it is only necessary to put the game drawing thread to sleep, and release the sleep state of the game drawing thread after the sleep is over, so as to adjust the progress of the game drawing thread to the frame rate of the game screen for a period of time. sleep, thus slowing down the time interval at which the game drawing thread outputs the game screen from the buffer, thereby reducing the frame rate of the game screen. Therefore, it is not necessary to use a display screen whose refresh rate can be freely controlled to be applied to an electronic device, which can reduce the frequency of the game screen and reduce the development cost of the electronic device. By adjusting the sleep time, the game drawing thread can be adjusted to put the game screen into the system. The time interval of the buffer, that is, slows down the time when the drawing thread puts the game screen into the buffer, thereby arbitrarily reducing the frame rate of the game screen, thus increasing the elasticity of the game frame rate.
本实施例是通过间接影响的方式降低游戏帧率,间接影响指的是与游戏的绘图线程采取某种“同步机制”的模块或线程,该同步机制会让游戏的绘图线程等待该模块或线程执行完成后,才会继续下一帧的工作,因此能够间接影响游戏帧率,其中同步机制涉及的模块或线程包括:进程间通信(Inter-process communication,IPC)呼叫或核心层Hook等。In this embodiment, the frame rate of the game is reduced by means of indirect influence. The indirect influence refers to a module or thread that adopts a certain "synchronization mechanism" with the drawing thread of the game, and the synchronization mechanism makes the drawing thread of the game wait for the module or thread. After the execution is completed, the work of the next frame will continue, so it can indirectly affect the game frame rate. The modules or threads involved in the synchronization mechanism include: Inter-process communication (IPC) calls or core layer Hooks, etc.
其中,计算睡眠时间包括:获取上一帧游戏画面的睡眠结束时间至执行判断当前帧的游戏画面是否需要睡眠的时间差;获取白名单内游戏画面的帧率的期望帧率;使用期望帧率计算出期望帧长;根据时间差及期望帧长计算睡眠时间;睡眠时间的计算公式如下的公式1所示:The calculation of the sleep time includes: the time difference between obtaining the sleep end time of the previous frame of the game screen and executing the judgment on whether the game screen of the current frame needs to sleep; obtaining the expected frame rate of the frame rate of the game screen in the whitelist; using the expected frame rate to calculate The expected frame length is calculated; the sleep time is calculated according to the time difference and the expected frame length; the calculation formula of the sleep time is shown in the following formula 1:
SleepDuration=ExpectedPeriod-TimeDiffSleepDuration=ExpectedPeriod-TimeDiff
其中,SleepDuration代表睡眠时间,ExpectedPeriod代表期望帧长,TimeDiff代表时间差。Among them, SleepDuration represents the sleep time, ExpectedPeriod represents the expected frame length, and TimeDiff represents the time difference.
期望帧长的计算方式为:期望帧长=1/期望帧率;The calculation method of the expected frame length is: expected frame length=1/expected frame rate;
在本实施例中,若想让游戏画面处于50FPS(即帧长20ms)时,依据前次睡眠时间到本次判断睡眠的时间得出TimeDiff,假如TimeDiff为8ms,则依据公式1得到睡眠时间为12ms,需要理解的是,游戏绘图线程从上一次让其睡眠结束后;为了等待游戏其他线程运算完毕,游戏线程还可能会经历一段睡眠时间,等待其他线程运算完毕后,游戏绘图线程才会被叫醒,并届时得到应如何绘制画面。此种睡眠由游戏本身控制,睡眠的时间TimeDiff是本申请所需要的,用于计算SleepDuration。In this embodiment, if you want the game screen to be at 50FPS (that is, the frame length is 20ms), the TimeDiff is obtained according to the time from the previous sleep time to the current sleep judgment time. If the TimeDiff is 8ms, the sleep time obtained according to formula 1 is: 12ms, what needs to be understood is that the game drawing thread has been put to sleep since the last time; in order to wait for other threads of the game to complete the operation, the game thread may also go through a period of sleep time. Wake up and get a picture of how it should be drawn. This kind of sleep is controlled by the game itself, and the sleep time TimeDiff is required by this application and is used to calculate SleepDuration.
请参阅图2,为时间差TimeDiff等于8ms、如上述的睡眠时间SleepDuration等于12ms的示意图,在图2中,最上方为绘图线程,或是会间接影响绘图线程的其他线程,线程中的中间部位(SleepDuration所示部位)表示该线程处于非游戏本身进行的睡眠状态(手机处于本实施例加入的睡眠时间SleepDuration后处于的状态),时长为睡眠时间,图2中入队 (Enqueue)代表将游戏换面塞入缓冲区的模块,而图2中的内容表示了当想让游戏稳在50FPS(帧长为20ms)时,时间差TimeDiff为8ms,睡眠时间(SleepDuration所示区域)为12ms。Please refer to Figure 2, which is a schematic diagram of the time difference TimeDiff equal to 8ms and the above-mentioned sleep time SleepDuration equal to 12ms. In Figure 2, the top is the drawing thread, or other threads that will indirectly affect the drawing thread, the middle part of the thread ( The part shown in SleepDuration) indicates that the thread is in a sleep state that is not performed by the game itself (the mobile phone is in a state after the sleep time SleepDuration added in this embodiment), and the duration is the sleep time. Enqueue in Figure 2 represents changing the game The content in Figure 2 shows that when you want the game to stabilize at 50FPS (frame length is 20ms), the time difference TimeDiff is 8ms, and the sleep time (the area shown by SleepDuration) is 12ms.
但是,虽然上述实施例经过公式1的计算,使得绘图线程睡眠,能够达到的稳帧的效果,将帧率下降到目标值,但是帧率抖动仍可能存在不够稳定的问题,因为未考虑到“长短帧”的情况,因此,在一个实施例中,计算睡眠时间还包括:记录游戏画面每帧的间隔,在计算当前帧的睡眠时间时,计算睡眠修正项;根据记录的游戏画面每帧间隔的时间差、期望帧长及睡眠修正项计算睡眠时间;睡眠时间的计算公式如下的公式2所示:However, although the above embodiment makes the drawing thread sleep through the calculation of formula 1, the effect of stabilizing the frame can be achieved, and the frame rate can be reduced to the target value, but the frame rate jitter may still be unstable, because the " Therefore, in one embodiment, calculating the sleep time further includes: recording the interval of each frame of the game screen, and calculating the sleep correction item when calculating the sleep time of the current frame; according to the recorded interval of each frame of the game screen The sleep time is calculated by the time difference, the expected frame length and the sleep correction term; the calculation formula of the sleep time is shown in the following formula 2:
SleepDuration=ExpectedPeriod-TimeDiff+SleepCorrectionSleepDuration=ExpectedPeriod-TimeDiff+SleepCorrection
其中,SleepDuration代表睡眠时间,ExpectedPeriod代表期望帧长,TimeDiff代表时间差,SleepCorrection代表睡眠修正项。Among them, SleepDuration represents the sleep time, ExpectedPeriod represents the expected frame length, TimeDiff represents the time difference, and SleepCorrection represents the sleep correction item.
多线程游戏的游戏画面每帧的间隔时间可能不相同,长短帧即为游戏可能出现一帧长帧,接下来配一帧短帧的结果。而由于长短帧互补的缘故,整体而言可能不会造成掉帧的情况,而当判断睡眠时间只采用当前帧的数据时,会造成在短帧睡眠太久,使得其无法与长帧产生互补,最终造成帧率下降;而为了使得帧率的抖动更加稳定,需要加入睡眠修正项来修正睡眠时间。The interval time between each frame of the game screen of multi-threaded games may be different. The long and short frames are the result of one long frame and one short frame in the game. However, due to the complementarity of long and short frames, the overall situation may not cause frame drop. When only the data of the current frame is used to determine the sleep time, it will cause the short frame to sleep for too long, making it unable to complement the long frame. , which will eventually cause the frame rate to drop; in order to make the frame rate jitter more stable, a sleep correction item needs to be added to correct the sleep time.
在本实施中,计算睡眠修正项包括:计算游戏画面的所有帧的平均帧长;计算期望帧长与平均帧长的差值,将差值作为睡眠修正项;计算睡眠修正项的公式如下:In this implementation, calculating the sleep correction item includes: calculating the average frame length of all frames of the game screen; calculating the difference between the expected frame length and the average frame length, and using the difference as the sleep correction item; the formula for calculating the sleep correction item is as follows:
Figure PCTCN2021129988-appb-000006
Figure PCTCN2021129988-appb-000006
其中,SleepCorrection代表睡眠修正项,
Figure PCTCN2021129988-appb-000007
代表ExpectedPeriod,EFPS为游戏预设的期望帧率,
Figure PCTCN2021129988-appb-000008
代表平均帧长,N代表当前帧的游戏画 面中小窗口的大小,小窗口的大小表示一次纳入计算的帧数。F i代表第i个帧的帧长,i为当前帧中的第i个帧。
Among them, SleepCorrection represents the sleep correction item,
Figure PCTCN2021129988-appb-000007
Represents ExpectedPeriod, EFPS is the expected frame rate preset by the game,
Figure PCTCN2021129988-appb-000008
Represents the average frame length, N represents the size of the small window in the game screen of the current frame, and the size of the small window represents the number of frames included in the calculation at one time. F i represents the frame length of the ith frame, and i is the ith frame in the current frame.
在其他实施例中,计算睡眠修正项包括:获取游戏画面中小窗口的大小;计算当前帧的游戏画面的帧长;根据期望帧长、小窗口的大小及当前帧的游戏画面的帧长计算睡眠修正项;计算睡眠修正项的公式如下:In other embodiments, calculating the sleep correction item includes: acquiring the size of the small window in the game screen; calculating the frame length of the game screen of the current frame; calculating sleep according to the expected frame length, the size of the small window and the frame length of the game screen of the current frame Correction term; the formula for calculating the sleep correction term is as follows:
Figure PCTCN2021129988-appb-000009
Figure PCTCN2021129988-appb-000009
其中,Q代表睡眠修正项,
Figure PCTCN2021129988-appb-000010
代表ExpectedPeriod,EFPS为游戏预设的期望帧率,N代表游戏画面中小窗口的大小,Fi代表游戏画面的小窗口的第i个帧的帧长。
where Q represents the sleep correction term,
Figure PCTCN2021129988-appb-000010
Represents ExpectedPeriod, EFPS is the expected frame rate preset by the game, N represents the size of the small window in the game screen, and Fi represents the frame length of the i-th frame of the small window of the game screen.
在其他实施例中,睡眠修正项的计算方法还可使用神经网络得出,例如使用人工神经网络(Artificial Neural Networks,ANN)或卷积神经网络(Convolution Neural Networks,CNN)或全连通神经网络(Fully-Connected Neural Networks,FC)。将小窗口数的帧长输入神经网络,神经网络会输出睡眠的修正项,上述网络可经由监督式学习得到,其训练数据可经由记录游戏每帧的帧长与上述的TimeDiff,并经由人工反推得到需要睡眠的时间与睡眠的修正项。In other embodiments, the calculation method of the sleep correction term can also be obtained by using a neural network, for example, using an artificial neural network (Artificial Neural Networks, ANN) or a convolutional neural network (Convolution Neural Networks, CNN) or a fully connected neural network ( Fully-Connected Neural Networks, FC). Input the frame length of the number of small windows into the neural network, and the neural network will output the correction term of sleep. The above network can be obtained through supervised learning, and its training data can be recorded by recording the frame length of each frame of the game and the above TimeDiff, and through artificial countermeasures. Push to get the time you need to sleep and sleep modifiers.
经由公式2计算出的睡眠时间,由于考虑了长帧和短帧的修正,使得游戏画面帧率的平稳度大幅上升。然而由于以公式2为核心的计算方法仅能够对局域的帧率(小窗口画面)进行修正,未考虑到系统或游戏长期的帧率趋势,因此帧率的平稳度仍有上升的空间。为了进一步提升游戏帧率的稳定性,引入长期修正值及短期修正值。The sleep time calculated by formula 2 takes into account the correction of long frames and short frames, which greatly increases the stability of the frame rate of the game screen. However, since the calculation method centered on formula 2 can only correct the local frame rate (small window screen), and does not take into account the long-term frame rate trend of the system or the game, there is still room for improvement in the stability of the frame rate. In order to further improve the stability of the game frame rate, a long-term correction value and a short-term correction value are introduced.
其中,计算睡眠时间还包括:获取游戏画面中的大窗口的大小及小窗口的大小,所述大窗口的大小表示一次纳入计算的帧数,其中,所述大窗口的大小大于所述小窗口的大小;计算长期修正值;根据睡眠修正项得出 短期修正值;使用时间差、期望帧长、长期修正值及睡眠修正项计算睡眠时间;睡眠时间的计算公式如下:Wherein, calculating the sleep time also includes: acquiring the size of the large window and the size of the small window in the game screen, the size of the large window represents the number of frames included in the calculation at one time, wherein the size of the large window is larger than the size of the small window Calculate the long-term correction value; obtain the short-term correction value according to the sleep correction item; use the time difference, expected frame length, long-term correction value and sleep correction item to calculate the sleep time; the calculation formula of the sleep time is as follows:
SleepDuration=ExpectedPeriod-TimeDiff+STC+LTCSleepDuration=ExpectedPeriod-TimeDiff+STC+LTC
其中,SleepDuration代表睡眠时间,ExpectedPeriod代表期望帧长,TimeDiff代表时间差,LTC代表长期修正值,STC代表短期修正值,短期修正值与睡眠修正项一致。Among them, SleepDuration represents the sleep time, ExpectedPeriod represents the expected frame length, TimeDiff represents the time difference, LTC represents the long-term correction value, STC represents the short-term correction value, and the short-term correction value is consistent with the sleep correction item.
其中,计算长期修正值包括:设定一个档位区间,档位区间内每个整数均为一个档位,每个档位均代表了一个时间值;将大窗口画面划分为不同的子区域;根据每个子区域的时间为每个子区域匹配档位;获取每个子区域匹配到的档位,将被匹配最多的档位作为长期修正值。Among them, calculating the long-term correction value includes: setting a gear interval, each integer in the gear interval is a gear, and each gear represents a time value; dividing the large window screen into different sub-areas; Match the gears for each sub-area according to the time of each sub-area; obtain the gears matched by each sub-area, and use the most matched gear as the long-term correction value.
在本实施例中,将长期修正值分为几个档位,例如从-5到+5之间,每个整数都为一个档位,统计一端够长的时间(大窗口画面),例如半秒或一秒的帧率,并把大窗口分割成数个子区域,每个子区域依据内部状况对档位进行投票,最后以票数醉倒的档位当成目前的长期修正值,而每个子区域决定投某个档位的方式,可以有以下方法得出:每个子区域可以用短期修正值的结果四舍五入,最后即对该结果对应的档位进行匹配投票,例如当前的组区域有短期修正值的计算得到+4.3ms,四舍五入后,该子区域即与+4的档位进行匹配,为+4的档位投票。In this embodiment, the long-term correction value is divided into several gears, for example, from -5 to +5, each integer is a gear, and a long enough time (large window screen) is counted at one end, such as half a Second or one second frame rate, and divide the large window into several sub-regions, each sub-region votes on the gear according to the internal situation, and finally uses the vote-drunk gear as the current long-term correction value, and each sub-region decides The method of voting for a certain gear can be obtained in the following ways: each sub-area can be rounded up with the result of the short-term correction value, and finally the corresponding gear corresponding to the result is matched and voted. For example, the current group area has a short-term correction value. +4.3ms is calculated, and after rounding, the sub-region matches the +4 gear and votes for the +4 gear.
而每个子区域决定投某个档位的方式,还可以有以下方法得出:使用机器学习或类神经网络对当前子区域进行分类,每个类别都对应到某个档位。The way each sub-area decides to cast a certain gear can also be obtained by the following methods: use machine learning or a neural network to classify the current sub-area, and each category corresponds to a certain gear.
其中,计算长期修正值还包括:使用机器学习或神经网络将每个子区域分为不同的类别;将不同的类别与不同的档位相匹配;将被匹配最多的档位作为长期修正值。Among them, calculating the long-term correction value also includes: using machine learning or neural network to divide each sub-region into different categories; matching different categories with different gears; taking the most matched gear as the long-term correction value.
其中,计算长期修正值包括:获取电子设备至少一项影响游戏画面帧率的当前特征值;将当前特征值输入强化学习模型中,并接收强化学习模 型输出的预备修正值;使用预备修正值代替长期修正值计算睡眠时间;在游戏绘图线程休眠时间后,计算游戏画面的平均帧率,并获取在当前特征值下的目标帧率;对比平均帧率及目标帧率;若平均帧率大于目标帧率,则向强化学习模型输入第一负反馈数据,令强化学习模型输出的预备修正值向变大的方向移动,直至平均帧率等于目标帧率;若平均帧率小于目标帧率,则向强化学习模型输入第二负反馈数据,令强化学习模型输出的预备修正值向变小的方向移动,直至平均帧率等于目标帧率;若平均帧率等于目标帧率,则将预备修正值设定为长期修正值。The calculation of the long-term correction value includes: obtaining at least one current feature value of the electronic device that affects the frame rate of the game screen; inputting the current feature value into the reinforcement learning model, and receiving the preliminary correction value output by the reinforcement learning model; using the preliminary correction value instead of The long-term correction value calculates the sleep time; after the sleep time of the game drawing thread, the average frame rate of the game screen is calculated, and the target frame rate under the current feature value is obtained; the average frame rate and the target frame rate are compared; if the average frame rate is greater than the target frame rate frame rate, input the first negative feedback data to the reinforcement learning model, so that the preparatory correction value output by the reinforcement learning model moves in the direction of increasing until the average frame rate is equal to the target frame rate; if the average frame rate is less than the target frame rate, then Input the second negative feedback data to the reinforcement learning model, so that the preparatory correction value output by the reinforcement learning model moves to a smaller direction until the average frame rate is equal to the target frame rate; if the average frame rate is equal to the target frame rate, the preparatory correction value will be Set to long-term correction value.
在本实施例中,当前特征值可以为帧长(Frame Length)或执行时间(Runtime)或TimeDiff等,可以理解的是,只要是能够影响游戏画面帧率的特征值,均可以作为本实施例中的当前特征值。In this embodiment, the current feature value may be the frame length (Frame Length), the execution time (Runtime), or TimeDiff, etc. It can be understood that as long as it is a feature value that can affect the frame rate of the game screen, it can be used as the present embodiment. The current eigenvalues in .
在本实施例中,强化模型输出的可为长期修正值对应的档位,也可谓对长期修正值的修改值,例如在长期修正值的基础上,修改值为+2.3ms(为长期修正值增加2.3ms),-1.5ms(为长期修正值减少1.5ms)等。In this embodiment, the output of the enhancement model can be the gear corresponding to the long-term correction value, or it can be described as the modified value of the long-term correction value. Increase 2.3ms), -1.5ms (decrease 1.5ms for long-term correction value), etc.
而强化学习模型,可以为是蒙特卡罗方法(Monte Carlo)等、表格解法(Tabular Solution Methods),也可能是使用人工神经网络(Artificial Neural Networks)等近似解方法(Approximate Solution Methods)。The reinforcement learning model can be a Monte Carlo method, a tabular solution method, or an approximate solution method such as an artificial neural network (Artificial Neural Networks).
在强化学习模型的初始状态,长期修正值为零,在本实施例中,短期修正值的计算方法与睡眠修正项的算法一致,在其他实施例中,短期修正值还可使用强化学习模型得出,强化学习模型直接输出短期修正值。In the initial state of the reinforcement learning model, the long-term correction value is zero. In this embodiment, the calculation method of the short-term correction value is consistent with the algorithm of the sleep correction term. In other embodiments, the short-term correction value can also be obtained by using the reinforcement learning model. out, the reinforcement learning model directly outputs the short-term correction value.
在其他实施例中,长期修正值及短期修正值可由类神经网络代替;例如,使用CNN或FC获取局域数据,模拟出短期修正值的效应。使用长短时记忆模型(Long-Short-Term-Memory,LSTM)等循环神经网络(Recurrent Neural Network,RNN)获取并保留游戏帧率长期趋势的数据,来模拟长期修正值的效应,其中,LSTM具有保留长期记忆机制,因此能够反映游戏负载的长期趋势。In other embodiments, the long-term corrections and short-term corrections may be replaced by a neural network-like network; for example, using CNN or FC to acquire local data and simulate the effects of short-term corrections. Use Recurrent Neural Network (RNN) such as Long-Short-Term-Memory (LSTM) to obtain and retain data on the long-term trend of game frame rates to simulate the effect of long-term correction values, where LSTM has Long-term memory mechanics are preserved, thus reflecting long-term trends in game load.
当使用LSTM替代长期修正值的效应时,输入序列资料,即每帧的帧长,但也可输入Runtime、TimeDiff等可能用来判断游戏运行流畅度的特征,并将数据以另一维度表示。When using LSTM to replace the effect of the long-term correction value, input sequence data, that is, the frame length of each frame, but also input features such as Runtime, TimeDiff, etc. that may be used to judge the running smoothness of the game, and represent the data in another dimension.
在时间为T时,将数帧的帧长输入CNN中获取局域数据,随后再将该数据输入LSTM,LSTM输出当下的总修正值。When the time is T, the frame length of several frames is input into the CNN to obtain local data, and then the data is input into the LSTM, and the LSTM outputs the current total correction value.
在时间为T+1时,同样将数帧的帧长输入CNN中获取局域数据,随后将该数据输入LSTM,在此过程中,LSTM内部会有选择性地保留之前的记忆,并将代表该记忆的“state”送到下一帧,该记忆保留了长期的趋势,如此,模型既能在长期的趋势下,判断睡眠修正项的走势,也具有相应的短期变化的功能,而在具体的实施过程中,长期修正值与短期修正值可由LSTM分开计算。When the time is T+1, the frame length of several frames is also input into the CNN to obtain local data, and then the data is input into the LSTM. During this process, the LSTM will selectively retain the previous memory and will represent The "state" of the memory is sent to the next frame, and the memory retains the long-term trend. In this way, the model can not only judge the trend of the sleep correction item under the long-term trend, but also have the function of corresponding short-term changes. During the implementation of , the long-term correction value and the short-term correction value can be calculated separately by LSTM.
本申请实施例提供一种电子装置,请参阅图2,该电子装置包括:存储器601、处理器602及存储在存储器601上并可在处理器602上运行的计算机程序,处理器602执行该计算机程序时,实现前述中描述的电子设备的画面帧率调整方法。An embodiment of the present application provides an electronic device, please refer to FIG. 2, the electronic device includes: a memory 601, a processor 602, and a computer program stored in the memory 601 and running on the processor 602, and the processor 602 executes the computer When the program is executed, the method for adjusting the picture frame rate of the electronic device described above is implemented.
进一步的,该电子装置还包括:至少一个输入设备603以及至少一个输出设备604。Further, the electronic device further includes: at least one input device 603 and at least one output device 604 .
上述存储器601、处理器602、输入设备603以及输出设备604,通过总线605连接。The above-mentioned memory 601 , processor 602 , input device 603 and output device 604 are connected through a bus 605 .
其中,输入设备603具体可为摄像头、触控面板、物理按键或者鼠标等等。输出设备604具体可为显示屏。The input device 603 may specifically be a camera, a touch panel, a physical button, a mouse, or the like. The output device 604 may specifically be a display screen.
存储器601可以是高速随机存取记忆体(RAM,Random Access Memory)存储器,也可为非不稳定的存储器(non-volatile memory),例如磁盘存储器。存储器601用于存储一组可执行程序代码,处理器602与存储器601耦合。The memory 601 may be a high-speed random access memory (RAM, Random Access Memory) memory, or may be a non-volatile memory (non-volatile memory), such as a disk memory. Memory 601 is used to store a set of executable program codes, and processor 602 is coupled to memory 601 .
进一步的,本申请实施例还提供了一种计算机可读存储介质,该计算 机可读存储介质可以是设置于上述各实施例中的电子装置中,该计算机可读存储介质可以是前述中的存储器601。该计算机可读存储介质上存储有计算机程序,该程序被处理器602执行时实现前述实施例中描述的电子设备的画面帧率调整方法。Further, an embodiment of the present application further provides a computer-readable storage medium, which may be provided in the electronic device in each of the foregoing embodiments, and the computer-readable storage medium may be the foregoing memory 601. A computer program is stored on the computer-readable storage medium, and when the program is executed by the processor 602, the method for adjusting the picture frame rate of the electronic device described in the foregoing embodiments is implemented.
进一步的,该计算机可存储介质还可以是U盘、移动硬盘、只读存储器601(ROM,Read-Only Memory)、RAM、磁碟或者光盘等各种可以存储程序代码的介质。Further, the computer-storable medium may also be a U disk, a removable hard disk, a read-only memory 601 (ROM, Read-Only Memory), a RAM, a magnetic disk or an optical disk and other mediums that can store program codes.
尽管已经相对于一个或多个实现方式示出并描述了本申请,但是本领域技术人员基于对本说明书和附图的阅读和理解将会想到等价变型和修改。本申请包括所有这样的修改和变型,并且仅由所附权利要求的范围限制。特别地关于由上述组件执行的各种功能,用于描述这样的组件的术语旨在对应于执行所述组件的指定功能(例如其在功能上是等价的)的任意组件(除非另外指示),即使在结构上与执行本文所示的本说明书的示范性实现方式中的功能的公开结构不等同。While the application has been shown and described with respect to one or more implementations, equivalent variations and modifications will occur to those skilled in the art based on a reading and understanding of this specification and the accompanying drawings. This application includes all such modifications and variations and is limited only by the scope of the appended claims. In particular with respect to the various functions performed by the above-described components, the terms used to describe such components are intended to correspond to any component that performs the specified function of the component (eg, which is functionally equivalent) (eg, which is functionally equivalent) (unless otherwise indicated) , even if it is not structurally equivalent to the disclosed structure that performs the functions of the exemplary implementations of the specification shown herein.
即,以上所述仅为本申请的实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,例如各实施例之间技术特征的相互结合,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。That is, the above descriptions are only the embodiments of the present application, which are not intended to limit the scope of the patent of the present application. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present application, such as the technical features between the embodiments Combining with each other, or directly or indirectly used in other related technical fields, are also included in the scope of patent protection of this application.
另外,在本申请所提供的几个实施例中,应该理解到,对于前述的各方法实施例,为了简便描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其它顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定都是本申请所必须的。In addition, in the several embodiments provided in this application, it should be understood that, for the convenience of description, the foregoing method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that, The application is not limited by the order of actions described, as certain steps may be performed in other orders or concurrently in accordance with the application. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily all necessary for the present application.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
在本申请中,“示例性”一词是用来表示“用作例子、例证或说明”。本申请中被描述为“示例性”的任何一个实施例不一定被解释为比其它实施例更加优选或更加具优势。为了使本领域任何技术人员能够实现和使用本申请,本申请给出了以上描述。在以上描述中,为了解释的目的而列出了各个细节。应当明白的是,本领域普通技术人员可以认识到,在不使用这些特定细节的情况下也可以实现本申请。在其它实施例中,不会对公知的结构和过程进行详细阐述,以避免不必要的细节使本申请的描述变得晦涩。因此,本申请并非旨在限于所示的实施例,而是与符合本申请所公开的原理和特征的最广范围相一致。In this application, the word "exemplary" is used to mean "serving as an example, illustration, or illustration." Any one embodiment described in this application as "exemplary" is not necessarily to be construed as preferred or advantageous over other embodiments. The above description is presented in the present application to enable any person skilled in the art to make and use the present application. In the above description, various details are set forth for the purpose of explanation. It is to be understood that one of ordinary skill in the art can realize that the present application may be practiced without the use of these specific details. In other instances, well-known structures and procedures have not been described in detail so as not to obscure the description of the present application with unnecessary detail. Therefore, this application is not intended to be limited to the embodiments shown but is to be accorded the widest scope consistent with the principles and features disclosed herein.
以上为对本申请所提供的一种电子设备的画面帧率调整方法、电子装置及存储介质的描述,对于本领域的技术人员,依据本申请实施例的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本申请的限制。The above is a description of a picture frame rate adjustment method of an electronic device, an electronic device, and a storage medium provided by the present application. For those skilled in the art, according to the ideas of the embodiments of the present application, the specific implementation and application scope are all There will be changes. In conclusion, the content of this specification should not be construed as a limitation on this application.

Claims (10)

  1. 一种电子设备的画面帧率调整方法,包括:A picture frame rate adjustment method of an electronic device, comprising:
    对电子设备的绘图线程进行识别,得到电子设备运行游戏的游戏绘图线程;Identify the drawing thread of the electronic device to obtain the game drawing thread of the electronic device running the game;
    根据白名单及电子设备的当前状态判断是否更改游戏帧率,所述白名单内至少具有电子设备不同状态下对应的帧率;若游戏画面需要降低帧率,则在将所述游戏绘图线程绘制好的游戏画面装入缓冲区前或装入所述缓冲区后,或在所述游戏绘图线程呼叫绘图函式库时,计算睡眠时间,将所述游戏绘图线程睡眠;Determine whether to change the game frame rate according to the whitelist and the current state of the electronic device. The whitelist contains at least the frame rates corresponding to different states of the electronic device; if the game screen needs to reduce the frame rate, the game drawing thread is drawn Before the good game picture is loaded into the buffer or after the buffer is loaded, or when the game drawing thread calls the drawing function library, the sleep time is calculated, and the game drawing thread is put to sleep;
    在所述睡眠时间结束后,解除游戏绘图线程的睡眠状态,以放慢游戏画面的输出时间间隔,降低游戏画面的帧率。After the sleep time expires, the sleep state of the game drawing thread is released, so as to slow down the output time interval of the game screen and reduce the frame rate of the game screen.
  2. 根据权利要求1所述的电子设备的画面帧率调整方法,其中,The method for adjusting the frame rate of an electronic device according to claim 1, wherein,
    所述计算睡眠时间包括:The calculating sleep time includes:
    获取上一帧游戏画面的睡眠结束时间至执行所述判断当前帧的游戏画面是否需要睡眠的时间差;The time difference from obtaining the sleep end time of the previous frame of the game screen to executing the described judgment on whether the game screen of the current frame needs to sleep;
    获取白名单内游戏画面的帧率的期望帧率;Get the expected frame rate of the frame rate of the game screen in the whitelist;
    根据期望帧率计算出期望帧长;Calculate the expected frame length according to the expected frame rate;
    根据所述时间差及所述期望帧长计算出所述睡眠时间;calculating the sleep time according to the time difference and the expected frame length;
    所述睡眠时间的计算公式如下:The calculation formula of the sleep time is as follows:
    SleepDuration=ExpectedPeriod-TimeDiffSleepDuration=ExpectedPeriod-TimeDiff
    其中,SleepDuration代表所述睡眠时间,ExpectedPeriod代表所述期望帧长,代表所述时间差。Wherein, SleepDuration represents the sleep time, ExpectedPeriod represents the expected frame length, and represents the time difference.
  3. 根据权利要求2所述的电子设备的画面帧率调整方法,其中,The method for adjusting the frame rate of an electronic device according to claim 2, wherein,
    所述计算睡眠时间还包括:The calculating sleep time also includes:
    记录游戏画面每帧的间隔,在计算当前帧的睡眠时间时,计算睡眠 修正项;Record the interval of each frame of the game screen, and calculate the sleep correction item when calculating the sleep time of the current frame;
    根据记录的游戏画面每帧间隔的时间差、所述期望帧长及所述睡眠修正项计算出所述睡眠时间;Calculate the sleep time according to the recorded time difference between each frame of the game screen, the expected frame length and the sleep correction item;
    所述睡眠时间的计算公式如下:The calculation formula of the sleep time is as follows:
    SleepDuration=ExpectedPeriod-TimeDiff+SleepCorrectionSleepDuration=ExpectedPeriod-TimeDiff+SleepCorrection
    其中,SleepDuration代表所述睡眠时间,ExpectedPeriod代表所述期望帧长,TimeDiff代表所述时间差,SleepCorrection代表所述睡眠修正项。Wherein, SleepDuration represents the sleep time, ExpectedPeriod represents the expected frame length, TimeDiff represents the time difference, and SleepCorrection represents the sleep correction item.
  4. 根据权利要求3所述的电子设备的画面帧率调整方法,其中,The method for adjusting the frame rate of an electronic device according to claim 3, wherein,
    所述计算睡眠修正项包括:The calculating sleep correction term includes:
    计算游戏画面的所有帧的平均帧长;Calculate the average frame length of all frames of the game screen;
    计算所述期望帧长与所述平均帧长的差值,将所述差值作为所述睡眠修正项;calculating the difference between the expected frame length and the average frame length, and using the difference as the sleep correction term;
    所述计算睡眠修正项的公式如下:The formula for calculating the sleep correction term is as follows:
    Figure PCTCN2021129988-appb-100001
    Figure PCTCN2021129988-appb-100001
    其中,SleepCorrection代表所述睡眠修正项,
    Figure PCTCN2021129988-appb-100002
    代表ExpectedPeriod,EFPS为游戏预设的期望帧率,
    Figure PCTCN2021129988-appb-100003
    代表所述平均帧长,N代表当前帧的游戏画面中小窗口的大小,所述小窗口的大小表示一次纳入计算的帧数;F i代表第i个帧的帧长,i为当前帧中的第i个帧。
    Wherein, SleepCorrection represents the sleep correction item,
    Figure PCTCN2021129988-appb-100002
    Represents ExpectedPeriod, EFPS is the expected frame rate preset by the game,
    Figure PCTCN2021129988-appb-100003
    Represents the average frame length, N represents the size of the small window in the game screen of the current frame, and the size of the small window represents the number of frames included in the calculation at one time; F i represents the frame length of the i-th frame, and i is the current frame. ith frame.
  5. 根据权利要求3所述的电子设备的画面帧率调整方法,其中,The method for adjusting the frame rate of an electronic device according to claim 3, wherein,
    所述计算睡眠修正项包括:The calculating sleep correction term includes:
    获取游戏画面中小窗口的大小;Get the size of the small window in the game screen;
    计算当前帧的游戏画面的帧长;Calculate the frame length of the game screen of the current frame;
    根据所述期望帧长、小窗口的大小及当前帧的游戏画面的帧长计算睡眠修正项;Calculate the sleep correction item according to the expected frame length, the size of the small window and the frame length of the game screen of the current frame;
    计算睡眠修正项的公式如下:The formula for calculating the sleep correction term is as follows:
    Figure PCTCN2021129988-appb-100004
    Figure PCTCN2021129988-appb-100004
    其中,Q代表睡眠修正项,
    Figure PCTCN2021129988-appb-100005
    代表ExpectedPeriod,EFPS为游戏预设的期望帧率,N代表游戏画面中小窗口的大小,Fi代表游戏画面的小窗口的第i个帧的帧长。
    where Q represents the sleep correction term,
    Figure PCTCN2021129988-appb-100005
    Represents ExpectedPeriod, EFPS is the expected frame rate preset by the game, N represents the size of the small window in the game screen, and Fi represents the frame length of the i-th frame of the small window of the game screen.
  6. 根据权利要求3所述的电子设备的画面帧率调整方法,其中,The method for adjusting the frame rate of an electronic device according to claim 3, wherein,
    所述计算睡眠时间还包括:The calculating sleep time also includes:
    获取游戏画面中的大窗口的大小及小窗口的大小,所述大窗口的大小表示一次纳入计算的帧数,其中,所述大窗口的大小大于所述小窗口的大小;Obtain the size of the large window and the size of the small window in the game screen, the size of the large window represents the number of frames included in the calculation at one time, wherein the size of the large window is larger than the size of the small window;
    计算长期修正值;Calculate long-term corrections;
    根据所述睡眠修正项得出短期修正值;obtaining a short-term correction value according to the sleep correction term;
    使用所述时间差、所述期望帧长、所述长期修正值及所述睡眠修正项计算出所述睡眠时间;calculating the sleep time using the time difference, the desired frame length, the long-term correction value, and the sleep correction term;
    所述睡眠时间的计算公式如下:The calculation formula of the sleep time is as follows:
    SleepDuration=ExpectedPeriod-TimeDiff+STC+LTCSleepDuration=ExpectedPeriod-TimeDiff+STC+LTC
    其中,SleepDuration代表所述睡眠时间,ExpectedPeriod代表所述期望帧长,TimeDiff代表所述时间差,LTC代表长期修正值,STC代表所述短期修正值,所述短期修正值与所述睡眠修正项一致;Wherein, SleepDuration represents the sleep time, ExpectedPeriod represents the expected frame length, TimeDiff represents the time difference, LTC represents the long-term correction value, STC represents the short-term correction value, and the short-term correction value is consistent with the sleep correction item;
    所述计算长期修正值包括:The calculated long-term correction value includes:
    设定一个档位区间,所述档位区间内每个整数均为一个档位,每个所述档位均代表了一个时间值;Setting a gear interval, each integer in the gear interval is a gear, and each of the gears represents a time value;
    将大窗口画面划分为不同的子区域;Divide the large window screen into different sub-areas;
    根据每个所述子区域的时间为每个所述子区域匹配所述档位;matching the gear for each of the sub-regions according to the time of each of the sub-regions;
    获取每个所述子区域匹配到的档位,将被匹配最多的档位作为长期修正值。The gears matched by each of the sub-regions are acquired, and the most matched gears are used as long-term correction values.
  7. 根据权利要求6所述的电子设备的画面帧率调整方法,其中,The method for adjusting the frame rate of an electronic device according to claim 6, wherein,
    所述计算长期修正值还包括:The calculating long-term correction value also includes:
    使用机器学习或神经网络将每个所述子区域分为不同的类别;classifying each of said sub-regions into different categories using machine learning or neural networks;
    将不同的所述类别与不同的所述档位相匹配;matching different said categories with different said gears;
    将被匹配最多的档位作为长期修正值。The gear that is matched the most is used as the long-term correction value.
  8. 根据权利要求5所述的电子设备的画面帧率调整方法,其中,The picture frame rate adjustment method of an electronic device according to claim 5, wherein,
    所述计算长期修正值包括:The calculated long-term correction value includes:
    获取电子设备至少一项影响游戏画面帧率的当前特征值;Obtain at least one current feature value of the electronic device that affects the frame rate of the game screen;
    将所述当前特征值输入强化学习模型中,并接收所述强化学习模型输出的预备修正值;Inputting the current feature value into the reinforcement learning model, and receiving the preliminary correction value output by the reinforcement learning model;
    使用所述预备修正值代替所述长期修正值计算所述睡眠时间;calculating the sleep time using the preliminary correction value in place of the long-term correction value;
    在所述游戏绘图线程的所述休眠时间后,计算游戏画面的平均帧率,并获取在所述当前特征值下的目标帧率;After the sleep time of the game drawing thread, calculate the average frame rate of the game screen, and obtain the target frame rate under the current feature value;
    对比所述平均帧率及所述目标帧率;comparing the average frame rate and the target frame rate;
    若所述平均帧率大于所述目标帧率,则向所述强化学习模型输入第一负反馈数据,令所述强化学习模型输出的所述预备修正值向变大的方向移动,直至所述平均帧率等于所述目标帧率;If the average frame rate is greater than the target frame rate, input the first negative feedback data to the reinforcement learning model, so that the preliminary correction value output by the reinforcement learning model is moved in a direction of increasing until the The average frame rate is equal to the target frame rate;
    若所述平均帧率小于所述目标帧率,则向所述强化学习模型输入第二负反馈数据,令所述强化学习模型输出的所述预备修正值向变小的方向移动,直至所述平均帧率等于所述目标帧率;If the average frame rate is lower than the target frame rate, input second negative feedback data to the reinforcement learning model, so that the preliminary correction value output by the reinforcement learning model is moved in a direction of decreasing until the The average frame rate is equal to the target frame rate;
    若所述平均帧率等于所述目标帧率,则将所述预备修正值设定为长期修正值。If the average frame rate is equal to the target frame rate, the preliminary correction value is set as a long-term correction value.
  9. 一种电子装置,包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序 时,实现权利要求1至8中的任意一项所述方法。An electronic device, comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, when the processor executes the computer program, the computer program of claims 1 to 8 is implemented any one of the methods.
  10. 一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时,实现权利要求1至8中的任意一项所述方法。A computer-readable storage medium on which a computer program is stored, when the computer program is executed by a processor, the method of any one of claims 1 to 8 is implemented.
PCT/CN2021/129988 2020-11-16 2021-11-11 Picture frame rate adjustment method for electronic device, electronic device, and storage medium WO2022100646A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011283182.X 2020-11-16
CN202011283182.XA CN114510274A (en) 2020-11-16 2020-11-16 Method for adjusting frame rate of image of electronic device, electronic device and storage medium

Publications (1)

Publication Number Publication Date
WO2022100646A1 true WO2022100646A1 (en) 2022-05-19

Family

ID=81546630

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/129988 WO2022100646A1 (en) 2020-11-16 2021-11-11 Picture frame rate adjustment method for electronic device, electronic device, and storage medium

Country Status (2)

Country Link
CN (1) CN114510274A (en)
WO (1) WO2022100646A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117130768A (en) * 2023-02-25 2023-11-28 荣耀终端有限公司 Frequency modulation relation table generation method and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140092103A1 (en) * 2012-09-28 2014-04-03 Nvidia Corporation Method for adaptively adjusting framerate of graphic processing unit and computer system using thereof
CN105049609A (en) * 2015-06-29 2015-11-11 惠州Tcl移动通信有限公司 Method of optimizing game picture and system of optimizing game picture
CN106095541A (en) * 2016-05-31 2016-11-09 深圳市万普拉斯科技有限公司 Dormancy management method and relevant apparatus
CN112516590A (en) * 2019-09-19 2021-03-19 华为技术有限公司 Frame rate identification method and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140092103A1 (en) * 2012-09-28 2014-04-03 Nvidia Corporation Method for adaptively adjusting framerate of graphic processing unit and computer system using thereof
CN105049609A (en) * 2015-06-29 2015-11-11 惠州Tcl移动通信有限公司 Method of optimizing game picture and system of optimizing game picture
CN106095541A (en) * 2016-05-31 2016-11-09 深圳市万普拉斯科技有限公司 Dormancy management method and relevant apparatus
CN112516590A (en) * 2019-09-19 2021-03-19 华为技术有限公司 Frame rate identification method and electronic equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117130768A (en) * 2023-02-25 2023-11-28 荣耀终端有限公司 Frequency modulation relation table generation method and electronic equipment

Also Published As

Publication number Publication date
CN114510274A (en) 2022-05-17

Similar Documents

Publication Publication Date Title
US11062673B2 (en) Closed loop CPU performance control
US20210374511A1 (en) Data processing method, device, computer equipment and storage medium
US20190095794A1 (en) Methods and apparatus for training a neural network
WO2020089759A1 (en) Artificial intelligence-enabled management of storage media access
WO2019233226A1 (en) Face recognition method, classification model training method and device, storage medium and computer device
Ding et al. An adaptive and momental bound method for stochastic learning
WO2018107934A1 (en) Data processing method and apparatus, and electronic device
WO2022100646A1 (en) Picture frame rate adjustment method for electronic device, electronic device, and storage medium
US11954792B2 (en) Real-time GPU rendering with performance guaranteed power management
CN110798626A (en) Automatic exposure adjusting method, system and equipment
WO2020078172A1 (en) Frame rate control method, device, terminal and storage medium
WO2021129415A1 (en) Frame rate adjusting method and apparatus for display screen, terminal, and storage medium
CN106233225B (en) Power mode unit based on delay of power mode for control processor core and associated method and system
CN115268616A (en) Frequency control method and device for memory, electronic device and storage medium
CN112256383B (en) Method, device, equipment and medium for adjusting CPU core number of virtual machine
WO2023193527A1 (en) Thread execution method and apparatus, electronic device, and computer-readable storage medium
US10990444B2 (en) Device and method for controlling data request
US8773442B2 (en) Aligning animation state update and frame composition
CN114510209A (en) Method for adjusting frame rate of image, electronic device and computer-readable storage medium
JP2017502325A (en) Adaptive partial screen update using dynamic backlight control capability
TWI763168B (en) Data processing method and apparatus, computer device, storage medium
TWI837523B (en) Remote control system
CN106802792B (en) Interactive interface operation request queue processing method based on BP neural network
KR20120053857A (en) Apparatus and method for controlling response time of application program
WO2018112738A1 (en) Power state management

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21891166

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 220823)

122 Ep: pct application non-entry in european phase

Ref document number: 21891166

Country of ref document: EP

Kind code of ref document: A1