Frequency adjustment method and device
By obtaining the load information, image processing time and thread computing power requirements during image frame acquisition, dynamically adjusting the frequency of the hardware unit of the electronic device, solving the problem of difficulty in balancing fluency and heating in the prior art, achieving more accurate frequency adjustment and better thermal management effects.
Patent Information
- Application Number
- CN202411753977.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-04-08
AI Technical Summary
When adjusting the CPU frequency of electronic devices, it is difficult to balance the smoothness and heat generation, resulting in inaccurate frequency adjustment, which affects the smoothness of image preview and the thermal management of the equipment.
By obtaining the load information, image processing time and thread computing power requirements during image frame acquisition, the hardware unit frequency in the electronic device is dynamically adjusted to ensure that the processing time of each image frame is stable and avoiding too high or too low frequency.
The balance between fluency and heating is achieved, ensuring the smoothness of image preview, while delaying the heating of electronic devices, improving the accuracy of frequency adjustment and energy-saving effect.
Smart Images

Figure CN119784570A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of electronic technology, and specifically relates to a frequency adjustment method and a device thereof. Background Art
[0002] With the continuous development of electronic technology, the image acquisition and processing functions of electronic devices are also constantly improving. However, due to the complexity of the software and hardware systems of electronic devices, when electronic devices use image acquisition and processing functions, problems such as unsmooth image preview and rapid heating of electronic devices begin to occur.
[0003] In order to solve the above problems, in the related art, electronic devices can use dynamic voltage and frequency scaling (DVFS) technology to increase or decrease the frequency of the central processing unit (CPU) of the electronic device.
[0004] However, the above adjustment method may adjust the CPU frequency to too high or too low. For example, if the frequency is too high, the electronic device may heat up, while if the frequency is too low, the image preview may not be smooth. Therefore, it is impossible to effectively ensure the balance between smoothness and heating. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a frequency adjustment method and device thereof, which can effectively ensure the balance between smoothness and heat generation of electronic equipment.
[0006] In a first aspect, an embodiment of the present application provides a frequency adjustment method, the method comprising: obtaining first information when acquiring a first image frame; adjusting the frequency of a first module in an electronic device based on the first information; wherein the first information comprises at least one of the following: a first load, image processing time, and thread computing power requirement information; the first load is the load of the first module in a first time period before the first image frame.
[0007] In a second aspect, an embodiment of the present application provides a frequency adjustment device, which includes an acquisition module and a processing module. The acquisition module is used to acquire first information when capturing a first image frame; the processing module is used to adjust the frequency of a first module in an electronic device according to the first information acquired by the acquisition module. The first information includes at least one of the following: a first load, image processing time, and thread computing power requirement information; the first load is the load of the first module in a first time period before the first image frame.
[0008] In a third aspect, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the frequency adjustment method described in the first aspect are implemented.
[0009] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the frequency adjustment method described in the first aspect are implemented.
[0010] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the frequency adjustment method as described in the first aspect.
[0011] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the frequency adjustment method as described in the first aspect.
[0012] In an embodiment of the present application, the first information when the first image frame is collected is obtained, and the frequency of the first module in the electronic device is adjusted according to the first information. Wherein, the first information may include at least one of the following: the first load, the image processing time, and the computing power requirement information of the thread; the first load is the load of the first module in the first time period before the first image frame. In the above scheme, in one case, since the electronic device can adjust the frequency of the hardware unit (such as the first module) according to the load situation in a time period before the image frame when collecting any image frame (such as the first image frame), that is, each image frame adjusts the frequency of the hardware unit according to the corresponding load situation, therefore, the timing of adjusting the frequency is more accurate and energy-saving, and the adjusted frequency is more suitable for the hardware unit that processes the current image frame. In another case, since the electronic device can adjust the frequency of the hardware unit according to the image processing time corresponding to the image frame when processing any image frame, therefore, it can ensure that the image processing time corresponding to each image frame will not be too short or too long, and ensure that the display of the image frame is stable, and delay the heating of the electronic device while satisfying the fluency. In another case, since the electronic device can adjust the frequency of the hardware unit according to the computing power requirement information of the thread corresponding to the image frame when processing any image frame, the adjusted frequency is more suitable for the thread to perform the image frame processing task, ensuring the smoothness of the displayed image. In this way, through the above method, it is possible to avoid adjusting the frequency of the hardware unit to too high or too low a frequency, and the adjusted frequency can effectively ensure the balance between the smoothness and heat generation of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 This is one of the flow charts of the frequency adjustment method provided in the embodiment of the present application;
[0014] Figure 2 This is the second flow chart of the frequency adjustment method provided in the embodiment of the present application;
[0015] Figure 3 This is the third flow chart of the frequency adjustment method provided in the embodiment of the present application;
[0016] Figure 4 It is a schematic diagram of the video recording software architecture and CPU adjustment effect provided by the embodiment of the present application;
[0017] Figure 5 This is a fourth flow chart of the frequency adjustment method provided in an embodiment of the present application;
[0018] Figure 6 This is the fifth flow chart of the frequency adjustment method provided in the embodiment of the present application;
[0019] Figure 7 This is the sixth schematic diagram of the frequency adjustment method and device provided in the embodiment of the present application;
[0020] Figure 8 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0021] Fig. 9 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0022] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0023] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0024] The terms "at least one (item)", "at least one of" and the like in the specification and claims of the present application refer to any one, any two or a combination of more than two of the objects included therein. For example, at least one (item) of a, b, and c can be represented by: "a", "b", "c", "a and b", "a and c", "b and c" and "a, b and c", where a, b, and c can be single or multiple. Similarly, "at least two (items)" refers to two or more, and its meaning is similar to that of "at least one (item)".
[0025] The frequency adjustment method and device provided in the embodiments of the present application are described in detail below through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0026] The frequency adjustment method provided in the embodiment of the present application can be applied to image acquisition and processing scenarios, which may specifically include photo taking scenarios or video recording scenarios.
[0027] In the video recording scene, the electronic device continuously captures image frames, continuously performs preliminary processing on each image frame, and then continuously previews and displays each image frame after preliminary processing, so as to achieve the effect of previewing and displaying the video recording. Alternatively, in the photo taking scene, the electronic device captures images, performs preliminary processing on the images, and then displays the images after preliminary processing, so as to achieve the effect of displaying preview photos.
[0028] The embodiment of the present application provides a frequency adjustment method, which obtains the first information when the first image frame is collected, and adjusts the frequency of the first module in the electronic device according to the first information. Wherein, the first information may include at least one of the following: the first load, the image processing time, and the computing power requirement information of the thread; the first load is the load of the first module in the first time period before the first image frame. In the above scheme, in one case, since the electronic device can adjust the frequency of the hardware unit (such as the first module) according to the load situation in a time period before the image frame when collecting any image frame (such as the first image frame), that is, each image frame adjusts the frequency of the hardware unit according to the corresponding load situation, therefore, the timing of adjusting the frequency is more accurate and energy-saving, and the adjusted frequency is more suitable for the hardware unit that processes the current image frame. In another case, since the electronic device can adjust the frequency of the hardware unit according to the image processing time corresponding to the image frame when processing any image frame, therefore, it can ensure that the image processing time corresponding to each image frame will not be too short or too long, ensure that the display of the image frame is stable, and delay the heating of the electronic device while meeting the fluency. In another case, since the electronic device can adjust the frequency of the hardware unit according to the computing power requirement information of the thread corresponding to the image frame when processing any image frame, the adjusted frequency is more suitable for the thread to perform the image frame processing task, ensuring the smoothness of the displayed image. In this way, through the above method, it is possible to avoid adjusting the frequency of the hardware unit to too high or too low a frequency, and the adjusted frequency can effectively ensure the balance between the smoothness and heat generation of the electronic device.
[0029] In the recording scenario, the electronic device starts the recording software to start recording. For each image frame captured by the recording software, the electronic device can obtain at least one of the first load, image processing time and thread computing power requirement information corresponding to each captured image frame, and then adjust the frequency of the first module according to at least one of the above items.
[0030] The execution subject of the frequency adjustment method provided in the embodiment of the present application may be a frequency adjustment device. Exemplarily, the frequency adjustment device may be an electronic device, or a functional component or functional entity in the electronic device. The frequency adjustment method provided in the embodiment of the present application will be exemplarily described below by taking the execution subject as an electronic device as an example.
[0031] Figure 1 is a flow chart of the frequency adjustment method provided in the embodiment of the present application, such as Figure 1 As shown, the frequency adjustment method provided in the embodiment of the present application may include the following steps 101 and 102.
[0032] Step 101: An electronic device obtains first information when capturing a first image frame.
[0033] Optionally, in an embodiment of the present application, the first image frame may be any image frame captured by an electronic device.
[0034] It should be noted that the embodiment of the present application only illustrates the frequency adjustment method using the first image frame as an example. In actual use, the electronic device can obtain the first information when capturing each image frame, and continue to execute the subsequent steps of the embodiment of the present application to achieve the purpose of adjusting the frequency of the first module.
[0035] Optionally, in the embodiment of the present application, the electronic device can collect and process images through installed image collection software. Exemplarily, the image collection software can be video recording software or photo taking software.
[0036] In an embodiment of the present application, the above-mentioned first information may include at least one of the following: the first load, the image processing time, and the computing power requirement information of the thread.
[0037] In the embodiment of the present application, the first load may be a load of the first module in a first time period before the first image frame.
[0038] Optionally, in the embodiment of the present application, the first load may be an average load of the first module in a first time period before the first image frame, or may be an average of the loads of the first module at multiple moments in the first time period.
[0039] Optionally, in an embodiment of the present application, the first time period may be a time period from a first moment before the first image frame to a moment when the first image frame is captured, and the first moment may be determined according to the length of the first time period.
[0040] It should be noted that the duration of the first time period can be set by default or can be set or adjusted according to actual needs, and the embodiments of the present application do not limit this. For example, the duration of the first time period can be the duration of an image frame, or the duration of the first time period can be greater than the duration of an image frame.
[0041] Exemplarily, taking the duration of an image frame as 50 milliseconds, the duration of the first time period can be set to 50 milliseconds. Assuming that the first image frame is collected at 1 minute and 50 milliseconds, then the first moment can be the moment of the 1st minute, and the first time period is from the 1st minute to the 1st minute and 50 milliseconds. The first load can be the load of the first module in the time period from the 1st minute to the 1st minute and 50 milliseconds.
[0042] Optionally, in the embodiment of the present application, the first module may be a hardware unit in the electronic device. The first module may be a hardware unit such as a CPU, a graphics processing unit (GPU), a double data rate (DDR) memory, etc., which is not limited in the embodiment of the present application.
[0043] Optionally, in an embodiment of the present application, the electronic device may periodically obtain the load when the first image frame is captured, and the period may be calculated based on the frame rate, and may be a multiple of the frame interval or a multiple of the duration of an image frame. For example, assuming that the frame rate (FPS, Frames Per Second) is 25, the frame interval is 0.04 seconds, and the above period may be set to 0.04 seconds or 0.08 seconds.
[0044] Exemplarily, taking the above period as a frame interval, the electronic device can collect an image frame every frame interval, and calculate the current load of the first module once to obtain the above first load. For example, taking the first module as a CPU, the electronic device can set a timer to collect an image frame every frame interval, and calculate the current load of the CPU once to obtain the above first load.
[0045] Exemplarily, taking the acquisition of the first image frame as an example, the electronic device may calculate the current load condition of the first module when the first image frame is acquired, and obtain the first load when the first image frame is acquired.
[0046] Optionally, in an embodiment of the present application, the above-mentioned image processing time may be the time taken by the electronic device to process the first image frame based on an image processing algorithm, and the image processing algorithm may include at least one of algorithms such as noise reduction, face detection, format conversion, and cropping.
[0047] Optionally, in an embodiment of the present application, after the electronic device processes the first image frame based on the image processing algorithm, it can obtain the time consumed for this processing, and use the time consumed for this processing as the image processing duration when the first image frame is captured. Exemplarily, the electronic device can start timing through a timer each time it starts to execute the image processing algorithm, and end timing after the execution of the image processing algorithm is completed, thereby obtaining the image processing duration when the first image frame is captured.
[0048] Optionally, in the embodiment of the present application, the above-mentioned image processing algorithm may be a key algorithm for processing image frames, and the key algorithm may be an algorithm that has a greater impact on the smoothness of image preview among the image processing algorithms for processing image frames. For example, the above-mentioned key algorithm may include a noise reduction algorithm and a face detection algorithm.
[0049] Optionally, in an embodiment of the present application, after the electronic device processes the first image frame based on the key algorithm, it can obtain the time consumed for this processing, and use the time consumed for this processing as the image processing duration when the first image frame is captured. Exemplarily, the electronic device can start timing through a timer each time the key algorithm is executed, and end timing after the key algorithm is executed, thereby obtaining the image processing duration when the first image frame is captured.
[0050] Optionally, in an embodiment of the present application, the above-mentioned image processing duration may be the duration used by the electronic device to execute one or more processes from the start of image acquisition to the preview and display of the image.
[0051] It should be noted that the electronic device executing one process can be understood as the electronic device processing the image frame based on the image processing algorithm in the one process. The electronic device executing multiple processes can be understood as the electronic device processing the image frame based on the image processing algorithms in the multiple processes.
[0052] Optionally, in an embodiment of the present application, the process from starting to capture the first image frame to previewing and displaying the first image frame can be divided into multiple processes, and the electronic device can record the duration of executing any process when executing the process to obtain the image processing duration when capturing the first image frame. Alternatively, the electronic device can record the duration of executing a key process among multiple processes to obtain the image processing duration when capturing the first image frame.
[0053] Exemplarily, the key processes mentioned above may be one or more processes that have a greater impact on image fluency during the process from starting to capture an image to previewing and displaying the image.
[0054] Optionally, in an embodiment of the present application, the thread may be a thread called from image acquisition to image preview display, and the thread is used to perform image processing tasks. The computing power requirement information of the thread may be the computing power required by the thread when performing image processing tasks. For example, the computing power requirement information of the thread may include at least one of the memory, computing resources, hardware resources, and processing time required by the thread.
[0055] It should be noted that the computing power requirement information of the above-mentioned threads can be set in advance by the user according to actual needs, or can be set by default, and the embodiments of the present application do not limit this.
[0056] Optionally, in an embodiment of the present application, the above-mentioned thread can be a key thread called in the process from image acquisition to image preview display, and the key thread performs a relatively important image processing task. The execution of the image processing task by the key thread has a greater impact on the smoothness of the image.
[0057] Optionally, in an embodiment of the present application, the electronic device may pre-set computing power requirement information for the key thread, and during the processing of the first image frame, detect the called thread. If it is detected that the called thread is the key thread, the computing power requirement information set for the key thread is obtained, and the computing power requirement information of the thread when the first image frame is captured is obtained.
[0058] Step 102: The electronic device adjusts the frequency of the first module in the electronic device according to the first information.
[0059] Optionally, in the embodiment of the present application, the electronic device may adjust the frequency of the first module according to one piece of first information, or may determine how to adjust the frequency of the first module by combining at least two pieces of first information.
[0060] In a first implementation manner of the embodiment of the present application, the first information may include a first load, and the step 102 may be specifically implemented through the following step 1021.
[0061] Step 1021: When the first load is different from the reference load, the electronic device adjusts the frequency of the first module according to a first difference between the first load and the reference load.
[0062] In this embodiment of the present application, the above-mentioned reference load may include a second load or a load threshold.
[0063] In an embodiment of the present application, the second load may be the load of the first module in a second time period before a second image frame, the second image frame may be an image frame before the first image frame, and the second time period is the same length as the first time period.
[0064] Optionally, in an embodiment of the present application, the second image frame may be an image frame that is before the first image frame and adjacent to the first image frame, or may be an image frame that is before the first image frame and not adjacent to the first image frame, and this embodiment of the present application is not limited to this.
[0065] Optionally, in an embodiment of the present application, the electronic device may calculate the current load of the first module when the second image frame is captured to obtain the above-mentioned second load.
[0066] For example, assuming that the first image frame is captured at 1 minute and 50 milliseconds, and the duration of the first time period is 80 milliseconds, then the duration of the second time period is 80 milliseconds. If the electronic device captures the second image frame at 1 minute and 100 milliseconds, the electronic device can calculate the load of the first module in the time period from 1 minute and 20 milliseconds to 1 minute and 100 milliseconds to obtain the above-mentioned second load.
[0067] It should be noted that, assuming that the first load is referred to as the load acquired by the electronic device this time, the second load can be understood as the load acquired by the electronic device last time. Therefore, the above “the electronic device adjusts the frequency of the first module according to the first difference between the first load and the reference load” can be understood as the electronic device adjusting the frequency of the first module according to the difference between the load acquired this time and the load acquired last time, that is, the load change of the first module.
[0068] Optionally, in the embodiment of the present application, the load threshold may be a load value when the electronic device requires the first module to operate, and may be preset based on experience or demand. For example, the reference load may be 75%.
[0069] Optionally, in an embodiment of the present application, the above-mentioned load threshold may be a load range when the electronic device requires the first module to operate. It can be understood that when the load of the first module is within this load range, a balance between smoothness and heating conditions can be ensured to a certain extent.
[0070] Optionally, in an embodiment of the present application, the load threshold may include an upper load limit and a lower load limit. The upper load limit is the maximum load that the first module can bear. If the upper load limit is exceeded, the heating of the electronic device may be accelerated, or even damage the electronic device. The lower load limit is the minimum load that the first module can bear. If the load limit is lower than the lower load limit, the energy consumption of the electronic device may increase.
[0071] It should be noted that the above load thresholds can be set by default or according to actual needs, and the present application embodiment does not limit this. For example, the load upper limit value in the above load threshold can be set to 80%, and the load upper limit value in the above load threshold can be set to 70%.
[0072] Optionally, in an embodiment of the present application, when the first load is different from the reference load, it indicates that the load condition of the first module has changed, and the change can be reflected by a first difference between the first load and the reference load. The electronic device can calculate the first difference between the first load and the reference load, determine an adjusted frequency according to the first difference, and then adjust the frequency of the first module to the adjusted frequency to achieve flexible adjustment of the frequency of the first module.
[0073] Optionally, in an embodiment of the present application, the step of “adjusting the frequency of the first module according to the first difference between the first load and the reference load” in the above step 1021 can be specifically implemented by the following step 10211 or step 10212.
[0074] Step 10211: When the first load is greater than the reference load, the electronic device increases the frequency of the first module to the first frequency.
[0075] In the embodiment of the present application, the first frequency can be determined based on the first difference.
[0076] Optionally, in the embodiment of the present application, the above-mentioned first difference may also be referred to as a load difference.
[0077] Optionally, in an embodiment of the present application, when the reference load is the second load, if the first load is greater than the second load, the electronic device can determine the increased first frequency based on a first difference between the first load and the second load, and increase the frequency of the first module to the first frequency.
[0078] Optionally, in the embodiment of the present application, the electronic device may determine a frequency adjustment amount according to the first difference, and then determine the sum of the frequency adjustment amount and the current frequency of the first module as the first frequency.
[0079] Optionally, in an embodiment of the present application, multiple sets of correspondences between load difference and frequency adjustment amount may be pre-stored in the electronic device, and the electronic device may search for the frequency adjustment amount corresponding to the first difference from the multiple sets of correspondences. Alternatively, the electronic device may calculate the frequency adjustment amount corresponding to the first difference according to a calculation formula between the load difference and the frequency adjustment amount. Alternatively, the electronic device may calculate the frequency adjustment amount corresponding to the first difference according to a functional relationship between the load difference and the frequency adjustment amount.
[0080] Exemplarily, assuming that the first load is 70% and the second load is 60%, the first load is greater than the second load and the first difference is 10%. The electronic device finds from multiple sets of correspondences between the load difference and the frequency adjustment amount that the frequency adjustment amount corresponding to the first difference is 500MHz, and the current frequency of the first module is 1.5GHz, then the first frequency is calculated to be 1.5GHz+500MHz=2.0GHz, therefore, the electronic device can increase the frequency of the first module to 2.0GHz.
[0081] Optionally, in an embodiment of the present application, when the reference load is a load threshold and the load threshold is a load value, if the first load is greater than the load threshold, the electronic device can determine the increased first frequency based on a first difference between the first load and the load threshold, and increase the frequency of the first module to the first frequency.
[0082] Exemplarily, assuming that the first load is 80% and the load threshold is 75%, the first load is greater than the second load and the first difference is 5%. The electronic device finds from multiple groups of correspondences between the load difference and the frequency adjustment amount that the frequency adjustment amount corresponding to the first difference is 300 MHz, and the current frequency of the first module is 1.7 GHz. The first frequency is calculated to be 1.7 GHz + 300 MHz = 2.0 GHz. Therefore, the electronic device can increase the frequency of the first module to 2.0 GHz.
[0083] Optionally, in an embodiment of the present application, when the reference load is a load threshold and the load threshold includes a load upper limit value and a load lower limit value, if the first load is greater than the load upper limit value in the load threshold, the electronic device can determine the increased first frequency based on a first difference between the first load and the load upper limit value, and increase the frequency of the first module to the first frequency.
[0084] Exemplarily, assuming that the first load is 85% and the load upper limit is 80%, the first load is greater than the second load and the first difference is 5%. The electronic device finds from multiple groups of correspondences between the load difference and the frequency adjustment amount that the frequency adjustment amount corresponding to the first difference is 300 MHz, and the current frequency of the first module is 1.9 GHz. The first frequency is calculated to be 1.9 GHz + 300 MHz = 2.2 GHz. Therefore, the electronic device can increase the frequency of the first module to 2.2 GHz.
[0085] Step 10212: When the first load is smaller than the reference load, the electronic device lowers the frequency of the first module to the second frequency.
[0086] In the embodiment of the present application, the first frequency and the second frequency are both determined based on the first difference.
[0087] Optionally, in an embodiment of the present application, when the reference load is the second load, if the first load is smaller than the second load, the electronic device may determine the lowered second frequency based on a first difference between the first load and the second load, and lower the frequency of the first module to the second frequency.
[0088] Optionally, in the embodiment of the present application, the electronic device may determine a frequency adjustment amount according to the first difference, and then determine the difference between the current frequency of the first module and the adjustment amount as the second frequency.
[0089] Exemplarily, assuming that the first load is 70% and the second load is 80%, the first load is less than the second load and the first difference is 10%. The electronic device finds from multiple groups of correspondences between the load difference and the frequency adjustment amount that the frequency adjustment amount corresponding to the first difference is 500MHz, and the current frequency of the first module is 1.8GHz, then the second frequency is calculated to be 1.8GHz-500MHz=1.3GHz, therefore, the electronic device can lower the frequency of the first module to 1.3GHz.
[0090] Optionally, in an embodiment of the present application, when the reference load is a load threshold and the load threshold is a load value, if the first load is less than the load threshold, the electronic device can determine the increased second frequency based on a first difference between the first load and the load threshold, and lower the frequency of the first module to the second frequency.
[0091] Exemplarily, assuming that the first load is 70% and the load threshold is 75%, the first load is less than the second load and the first difference is 5%. The electronic device finds from multiple groups of correspondences between the load difference and the frequency adjustment amount that the frequency adjustment amount corresponding to the first difference is 300 MHz, and the current frequency of the first module is 1.7 GHz, then the second frequency is calculated to be 1.7 GHz - 300 MHz = 1.4 GHz, therefore, the electronic device can lower the frequency of the first module to 1.4 GHz.
[0092] Optionally, in an embodiment of the present application, when the reference load is a load threshold and the load threshold includes a load upper limit value and a load lower limit value, if the first load is less than the load lower limit value in the load threshold, the electronic device can determine the lowered first frequency based on a first difference between the first load and the load upper limit value, and adjust the frequency of the first module to the second frequency.
[0093] Exemplarily, assuming that the first load is 65% and the lower limit of the load is 70%, the first load is less than the second load and the first difference is 5%. The electronic device finds from multiple groups of correspondences between the load difference and the frequency adjustment amount that the frequency adjustment amount corresponding to the first difference is 300MHz, and the current frequency of the first module is 1.9GHz, then the second frequency is calculated to be 1.9GHz-300MHz=1.6GHz, therefore, the electronic device can lower the frequency of the first module to 1.6GHz.
[0094] In addition, it should be noted that, when the first load is the same as the reference load, the electronic device may not adjust the frequency of the first module.
[0095] In the embodiment of the present application, the electronic device determines whether the current frequency of the first module meets the requirements of fluency and heating conditions according to the change of the load condition (first load) of the first module in the previous period of time (first time period), and adjusts the frequency of the first module based on the load difference between the first load and the second load, thereby realizing flexible adjustment of the frequency. Alternatively, the electronic device determines whether and how to adjust the frequency of the first module according to whether the load condition of the first module in the previous period of time is within the range of the upper load limit and the lower load limit. Since the balance between fluency and heating conditions can be guaranteed to a certain extent when the load of the first module is within the range of the upper load limit and the lower load limit, the frequency of the first module is adjusted to ensure that the load of the first module meets the requirements, thereby achieving the effect of maintaining a balance between the fluency of the image preview and the heating condition of the electronic device.
[0096] In a second implementation of the embodiment of the present application, the first information may include image processing time, which may be the time used to process the first image frame based on a key algorithm. The step 102 may be implemented specifically through the following step 1022.
[0097] Step 1022: When the image processing duration is different from the expected duration, the electronic device adjusts the frequency of the first module according to a second difference between the image processing duration and the expected duration.
[0098] Optionally, in an embodiment of the present application, the expected duration may be the expected duration of processing an image frame by a key algorithm.
[0099] Optionally, in an embodiment of the present application, the above-mentioned image processing duration is the actual duration used to execute the key process, and the above-mentioned expected duration may be the expected duration used to execute the key process.
[0100] It should be noted that the explanation of the key algorithm can be found in the relevant description of step 101 above, and the embodiments of the present application will not be repeated here.
[0101] Optionally, in the embodiment of the present application, the expected duration can be calculated based on the preview frame rate of the image. Alternatively, the expected duration can be set by default or based on experience or actual needs, which is not limited in the embodiment of the present application.
[0102] Optionally, in an embodiment of the present application, when the image processing duration is different from the expected duration, the electronic device can determine the adjusted frequency based on the second difference between the image processing duration and the expected duration, and then adjust the frequency of the first module to the adjusted frequency.
[0103] Optionally, in an embodiment of the present application, the step of "adjusting the frequency of the first module according to the second difference between the image processing duration and the expected duration" in the above step 1022 can be specifically implemented by following the steps 10221 or 10222.
[0104] Step 10221: When the image processing time is longer than the expected time, the electronic device increases the frequency of the first module to a third frequency.
[0105] In the embodiment of the present application, the third frequency can be determined based on the second difference.
[0106] Optionally, in the embodiment of the present application, the second difference may also be referred to as a duration difference.
[0107] Optionally, in an embodiment of the present application, when the image processing time is longer than the expected time, it means that the time for the key algorithm to process the first image frame is longer and the efficiency is reduced. Therefore, the electronic device can determine the increased third frequency based on the second difference between the image processing time and the expected time, and adjust the frequency of the first module to the third frequency.
[0108] Optionally, in the embodiment of the present application, the electronic device may determine a frequency adjustment amount according to the second difference, and then determine the sum of the frequency adjustment amount and the current frequency of the first module as the third frequency.
[0109] For example, assuming that the image processing time is 20 milliseconds and the expected time is 18 milliseconds, the image processing time is greater than the expected time and the second difference is 2 milliseconds. The electronic device searches for the frequency adjustment amount corresponding to the second difference from multiple sets of correspondences between the time difference and the frequency adjustment amount, and the frequency adjustment amount is 100 MHz. If the current frequency of the first module is 1.9 GHz, the electronic device calculates the third frequency after adjustment based on the frequency of the first module and the frequency adjustment amount corresponding to the second difference to be 1.9 GHz + 100 MHz = 2.0 GHz, and then the electronic device adjusts the frequency of the first module to 2.0 GHz.
[0110] Optionally, in an embodiment of the present application, multiple sets of correspondences between duration differences and frequency adjustment amounts may be pre-stored in the electronic device, and the electronic device may search for the frequency adjustment amount corresponding to the second difference from the multiple sets of correspondences. Alternatively, the electronic device may calculate the frequency adjustment amount corresponding to the second difference according to a calculation formula between the duration difference and the frequency adjustment amount. Alternatively, the electronic device may calculate the frequency adjustment amount corresponding to the second difference according to a functional relationship between the duration difference and the frequency adjustment amount.
[0111] Step 10222: When the image processing time is shorter than the expected time, the electronic device lowers the frequency of the first module to the fourth frequency.
[0112] In the embodiment of the present application, the third frequency and the fourth frequency are both determined based on the second difference.
[0113] Optionally, in an embodiment of the present application, when the image processing time is shorter than the expected time, it means that the time for the key algorithm to process the first image frame is shorter, and the frequency of the first module may be higher. Therefore, the electronic device can determine the lowered third frequency based on the second difference between the image processing time and the expected time, and lower the frequency of the first module to the fourth frequency.
[0114] Optionally, in the embodiment of the present application, the electronic device may determine a frequency adjustment amount according to the second difference, and then determine the difference between the frequency adjustment amount and the current frequency of the first module as the fourth frequency.
[0115] Exemplarily, assuming that the image processing time is 12 milliseconds and the expected time is 18 milliseconds, the image processing time is less than the expected time and the second difference is 6 milliseconds. The electronic device searches for the frequency adjustment amount corresponding to the second difference of 500 MHz from multiple sets of correspondences between the time difference and the frequency adjustment amount, and the current frequency of the first module is 2.5 GHz. The electronic device calculates the fourth frequency after adjustment as 2.5 GHz - 500 MHz = 2.0 GHz based on the frequency of the first module and the frequency adjustment amount corresponding to the second difference, and then adjusts the frequency of the first module down to 2.0 GHz.
[0116] It should be noted that the number of the above-mentioned key algorithms can be one or more. For each key algorithm, the electronic device can collect the image processing time of processing the first image frame based on the key algorithm, and determine how to adjust the frequency of the first module according to the relationship between the image processing time and the expected time.
[0117] In an embodiment of the present application, the process from starting to acquire an image to previewing and displaying the image includes multiple processes. According to the second difference between the image processing time and the expected time, the frequency of the first module is increased or decreased, thereby ensuring that the image processing time of each process remains stable, ensuring that the image processing time corresponding to each image frame is not too short or too long, and ensuring that the display of the image frame is smooth. Ultimately, the smoothness of the entire process from acquiring an image to previewing and displaying an image can be guaranteed.
[0118] Optionally, in an embodiment of the present application, the step of "adjusting the frequency of the first module according to the second difference between the image processing duration and the expected duration" in the above step 1022 can be specifically implemented by the following step 10223.
[0119] Step 10223: At the start time of processing the third image frame based on the key algorithm, adjust the frequency of the first module according to the second difference.
[0120] In the embodiment of the present application, the third image frame may be an image frame subsequent to the first image frame.
[0121] Optionally, in the embodiment of the present application, the third image frame may be the next image frame adjacent to the first image frame, or the third image frame may be any image frame acquired after the first image frame.
[0122] Optionally, in an embodiment of the present application, the electronic device may adjust the frequency of the first module through step 10221 or step 10222 when starting to process the third image frame based on the key algorithm.
[0123] Optionally, in an embodiment of the present application, the electronic device first calculates the adjusted frequency (the third frequency or the fourth frequency) through the relevant steps in the above step 10221 or step 10222, and then adjusts the frequency of the first module to the adjusted frequency when starting to process the third image frame based on the key algorithm.
[0124] In this way, the electronic device adjusts the frequency of the first module the next time it uses the key algorithm to process the image frame (i.e., the third image frame). This can ensure that the image processing time for the next image frame is close to the expected time, and will not affect the first module from performing other operations. The adjustment timing is more precise, and can effectively ensure the balance between image smoothness and heat generation of the electronic device.
[0125] Optionally, in an embodiment of the present application, assuming that the image processing time of a key algorithm for processing an image frame is higher than the expected time for multiple times in a row, the electronic device can increase the frequency of the first module. After multiple times, the frequency of the first module may have been increased to the highest frequency. At this time, it can be determined whether the load of the first module is greater than the upper limit of the load. If so, it indicates that there may be background fluctuations during this period, and subsequent operations can continue. However, if the load of the first module is very low, such as lower than the lower limit of the load, it indicates that there may be certain problems with the application that performs image acquisition and preview display during this period, such as too low configuration time of the key algorithm or other abnormalities. At this time, an abnormal prompt message can be displayed to prompt the user that an abnormality has occurred. The user can provide feedback to the engineer, and the engineer can analyze and solve the problem from the software code level.
[0126] In a third implementation manner of the embodiment of the present application, the above-mentioned first information may include computing power requirement information, and the above-mentioned step 102 can be specifically implemented through the following step 1023.
[0127] Step 1023: The electronic device adjusts the frequency of the first module to the fifth frequency according to the computing power requirement information.
[0128] In this embodiment of the present application, the fifth frequency may be a frequency corresponding to the computing power requirement information.
[0129] Optionally, in an embodiment of the present application, multiple sets of correspondences between computing power requirement information and frequency may be pre-stored in the electronic device, and the electronic device may search for the frequency corresponding to the above computing power requirement information from the multiple sets of correspondences. Alternatively, the electronic device may calculate the frequency corresponding to the computing power requirement information based on the calculation formula between the computing power requirement information and the frequency. Alternatively, the electronic device may calculate the frequency corresponding to the computing power requirement information based on the functional relationship between the computing power requirement information and the frequency.
[0130] Optionally, in an embodiment of the present application, the electronic device may determine a fifth frequency based on computing power requirement information, and adjust the frequency of the first module to the fifth frequency.
[0131] Optionally, in the embodiment of the present application, the electronic device may adjust the frequency of the first module to the fifth frequency according to the computing power requirement information at the start time of calling the key thread to process the third image frame. Alternatively, the electronic device may determine the fifth frequency according to the computing power requirement information, and then adjust the frequency of the first module to the fifth frequency at the start time of calling the key thread to process the third image frame.
[0132] In this way, for the key thread that has a greater impact on the smoothness of the image, computing power requirement information can be set for the key thread, and the frequency of the first module can be adjusted according to the computing power requirement information. The adjusted frequency of the first module can meet the needs of the key thread to execute tasks, and thus meet the requirements of image smoothness.
[0133] In a fourth implementation of the embodiment of the present application, the first information includes the first load, image processing time and computing power requirement information. Figure 1 ,like Figure 2 As shown, the above step 102 can be specifically implemented through the following steps 1024 and 1025.
[0134] Step 1024: The electronic device determines a sixth frequency according to the first load, determines a seventh frequency according to the image processing duration, and determines an eighth frequency according to the computing power requirement information.
[0135] It should be noted that the sixth frequency is the first frequency or the second frequency in the above embodiment, and the implementation process of the electronic device determining the sixth frequency according to the first load can refer to the relevant description of the above steps 1021, 10211 and 10212. The seventh frequency is the third frequency or the fourth frequency in the above embodiment, and the implementation process of the electronic device determining the seventh frequency according to the image processing duration can refer to the relevant description of the above steps 1022, 10221 and 10222. The seventh frequency is the fifth frequency in the above embodiment, and the implementation process of the electronic device determining the eighth frequency according to the computing power requirement information can refer to the relevant description of the above step 1023. To avoid repetition, the embodiments of the present application will not be repeated here.
[0136] Step 1025: The electronic device adjusts the frequency of the first module according to the sixth frequency and the first weight value, the seventh frequency and the second weight value, and the eighth frequency and the third weight value.
[0137] Optionally, in an embodiment of the present application, the first weight value can be understood as the influence of the load of the first module on the frequency adjustment of the first module, corresponding to the sixth frequency. The second weight value can be understood as the influence of the image processing duration on the frequency adjustment of the first module, corresponding to the seventh frequency. The third weight value can be understood as the influence of the computing power requirement information of the thread on the frequency adjustment of the first module, corresponding to the eighth frequency.
[0138] Optionally, in the embodiment of the present application, the first weight value, the second weight value, and the third weight value can be set by default or according to actual needs, and the embodiment of the present application does not limit this. In addition, the larger the weight value, the greater the influence of the information corresponding to the weight value on the frequency adjustment of the first module, or the most important thing is to meet the demand for information corresponding to the weight value in the process of using the electronic device.
[0139] For example, assuming that the first weight value is 0.3, the second weight value is 0.3, and the third weight value is 0.4, it means that the computing power requirement information of the thread has the greatest impact on the frequency adjustment of the first module, or that it is most important to meet the computing power requirement information of the thread during the use of the electronic device. Alternatively, assuming that the first weight value is 0.2, the second weight value is 0.5, and the third weight value is 0.3, it means that the image processing duration has the greatest impact on the frequency adjustment of the first module, or that it is most important to meet the image processing duration requirement during the use of the electronic device.
[0140] Optionally, in the embodiment of the present application, the electronic device may adjust the frequency of the first module to a frequency corresponding to the maximum weight value.
[0141] Exemplarily, assuming that the largest of the first weight value, the second weight value, and the third weight value is the first weight value, the electronic device can adjust the frequency of the first module to the sixth frequency. Alternatively, assuming that the largest of the first weight value, the second weight value, and the third weight value is the third weight value, the electronic device can adjust the frequency of the first module to the eighth frequency. Alternatively, assuming that the largest of the first weight value, the second weight value, and the third weight value is the second weight value, the electronic device can adjust the frequency of the first module to the seventh frequency when it is detected that the image frame is processed based on the key algorithm next time.
[0142] Optionally, in an embodiment of the present application, the electronic device may perform weighted summation according to the sixth frequency and the first weight value, the seventh frequency and the second weight value, and the eighth frequency and the third weight value to obtain the tenth frequency, and then adjust the frequency of the first module to the tenth frequency.
[0143] For example, assuming that the sixth frequency is 2.0 GHz, the first weight value is 0.2, the seventh frequency is 2.1 GHz, the first weight value is 0.3, the sixth frequency is 2.2 GHz, the first weight value is 0.5, then the weighted average is 2.0 GHz × 0.2 + 2.1 GHz × 0.3 + 2.2 GHz × 0.5 = 2.2 GHz, then the electronic device can adjust the frequency of the first module to 2.2 GHz.
[0144] In this way, the electronic device adjusts the frequency of the first module based on the three information of the first load, image processing time and computing power requirement information and three weight values, which can improve the accuracy and flexibility of the frequency adjustment, and suppress the frequency adjustment to a certain extent to avoid adjusting the frequency of the first module to too high or too low a frequency, and can delay the heating of the electronic device while ensuring smoothness, that is, maintain a balance between smoothness and heating.
[0145] In the fifth implementation of the present application, the above-mentioned first information may include at least two items of the first load, image processing time and computing power requirement information, and the above-mentioned step 102 can be specifically implemented by the following steps 1026, 1027 or 1028.
[0146] Step 1026: When the first information includes the first load and the image processing time, the electronic device can determine the sixth frequency according to the first load, and determine the seventh frequency according to the image processing time, and then adjust the frequency of the first module according to the sixth frequency and the first weight value, and the seventh frequency and the second weight value.
[0147] Step 1027, when the first information includes the first load and computing power requirement information, the electronic device can determine the sixth frequency based on the first load, and determine the eighth frequency based on the computing power requirement information, and then adjust the frequency of the first module based on the sixth frequency and the first weight value, and the eighth frequency and the third weight value.
[0148] Step 1028. When the first information includes image processing time and computing power requirement information, the electronic device can determine the seventh frequency based on the image processing time, and determine the eighth frequency based on the computing power requirement information, and then adjust the frequency of the first module based on the seventh frequency and the second weight value, and the eighth frequency and the third weight value.
[0149] It should be noted that the implementation process of the above steps 1026, 1027 and 1028 can refer to the relevant description of the above steps 1024 and 1005, and the embodiments of the present application will not be repeated here.
[0150] Optionally, in the embodiment of the present application, after the above step 102, the frequency adjustment method provided in the embodiment of the present application may further include the following step 103.
[0151] Step 103: When the fourth image frame is captured, the electronic device adjusts the frequency of the first module to a ninth frequency.
[0152] In the embodiment of the present application, the ninth frequency may be an adjustment frequency corresponding to an image frame before the fourth image frame.
[0153] Optionally, in the embodiment of the present application, the fourth image frame may be any image frame after the first image frame.
[0154] Optionally, in an embodiment of the present application, the electronic device may record a frequency adjustment rule, including an adjustment timing and an adjustment frequency, during the process of adjusting the frequency of the first module using the frequency adjustment method provided in the embodiment of the present application, and then adjust the frequency of the first module to the adjustment frequency at the above-mentioned adjustment timing when the fourth image frame is captured.
[0155] Exemplarily, assuming that the frequency adjustment rule recorded by the electronic device is to increase the frequency to the ninth frequency every 1 second, then in the next second, the electronic device can adjust the frequency of the first module to the ninth frequency when the fourth image frame is captured.
[0156] In this way, adjusting the frequency of the first module according to a rule can reduce the amount of calculation, thereby alleviating the burden on the electronic device.
[0157] The frequency adjustment method provided in the embodiment of the present application obtains the first information when the first image frame is collected, and adjusts the frequency of the first module in the electronic device according to the first information. Wherein, the first information may include at least one of the following: the first load, the image processing time, and the computing power requirement information of the thread; the first load is the load of the first module in the first time period before the first image frame. In the above scheme, in one case, since the electronic device can adjust the frequency of the hardware unit (such as the first module) according to the load situation in a time period before the image frame when collecting any image frame (such as the first image frame), that is, each image frame adjusts the frequency of the hardware unit according to the corresponding load situation, therefore, the timing of adjusting the frequency is more accurate and energy-saving, and the adjusted frequency is more suitable for the hardware unit that processes the current image frame. In another case, since the electronic device can adjust the frequency of the hardware unit according to the image processing time corresponding to the image frame when processing any image frame, therefore, it can ensure that the image processing time corresponding to each image frame will not be too short or too long, ensure that the display of the image frame is stable, and delay the heating of the electronic device while satisfying the fluency. In another case, since the electronic device can adjust the frequency of the hardware unit according to the computing power requirement information of the thread corresponding to the image frame when processing any image frame, the adjusted frequency is more suitable for the thread to execute the image frame processing task, ensuring the smoothness of the displayed image. In this way, through the above method, it is possible to avoid adjusting the frequency of the hardware unit to too high or too low frequency, and the adjusted frequency can effectively ensure the balance between smoothness and heat generation. That is to say, in the recording scene, the frequency of the hardware unit is adjusted according to the frame rate, and the adjustment timing is more accurate and energy-saving, which can effectively ensure the smoothness of the recording; and, according to the current load of the hardware unit and the image processing time of the key process in the recording scene, the frequency of the hardware unit is adjusted in time, which can delay the heating of the device under the premise of meeting the smoothness, and no manual debugging operation is required; and, the computing power requirement information is set in advance for the key threads that may affect the smoothness, and the frequency of the hardware ternary is adjusted according to the computing power requirement information, which can meet the requirements of smoothness.
[0158] Figure 3 301 to 307 are steps of the method for adjusting the frequency according to the embodiment of the present application.
[0159] Step 301: The electronic device obtains the CPU load in a first time period before the current moment at every frame interval.
[0160] Step 302: The electronic device determines an adjusted CPU frequency, ie, a sixth frequency, according to the acquired load.
[0161] Optionally, in an embodiment of the present application, the electronic device increases the frequency of the CPU when it is determined that the acquired load increases, and decreases the frequency of the CPU when it is determined that the acquired load decreases.
[0162] For example, a timer may be set inside the electronic device to calculate the CPU load every frame interval (i.e., every time an image frame is captured). If the CPU load increases relative to the last calculated load, the CPU frequency is increased until the CPU load is within the load range, which can be configured by a technician in a configuration file; if the CPU load decreases relative to the last calculated load, the CPU frequency is decreased.
[0163] Step 303: When the electronic device uses the key algorithm to process the first image frame, the electronic device obtains the image processing time length of processing the first image frame based on the key algorithm.
[0164] Step 304: The electronic device determines the adjusted CPU frequency, ie, the seventh frequency, according to the acquired image processing time.
[0165] Optionally, in an embodiment of the present application, the electronic device compares the image processing time with the expected time. If the image processing time is shorter than the expected time, the CPU frequency is increased; if the image processing time is longer than the expected time, the CPU frequency is decreased.
[0166] For example, every time the key algorithm in the video recording software starts to execute, the electronic device starts timing, and when the key algorithm is executed, the electronic device stops timing, and the time consumed to execute the key algorithm is obtained, that is, the above-mentioned image processing time. Then the image processing time is compared with the expected time configured by the technician. If the image processing time is lower than the expected time, the CPU frequency is increased, and if the image processing time is higher than the expected time, the CPU frequency is decreased.
[0167] Step 305: When the electronic device uses the key thread to execute the image processing task of processing the first image frame, the electronic device obtains the computing power requirement information pre-set for the key thread.
[0168] Step 306: The electronic device determines the adjusted CPU frequency, that is, the eighth frequency, according to the computing power requirement information.
[0169] Exemplarily, the electronic device detects the called thread, and when detecting that a critical thread is called, obtains the computing power requirement information of the critical thread, and adjusts the frequency of the CPU according to the computing power requirement information.
[0170] It should be noted that there is no strict order of execution between the above-mentioned steps 301, 303 and 305. The figure only illustrates the example of first executing steps 301 and 302, then executing steps 303 and 304, and finally executing steps 305 and 306, which does not constitute a limitation on the embodiments of the present application.
[0171] Step 307: The electronic device determines an adjusted CPU frequency, that is, a ninth frequency, according to the sixth frequency and the first weight value, the seventh frequency and the second weight value, and the eighth frequency and the third weight value, and adjusts the CPU frequency to the ninth frequency.
[0172] For example, next, Figure 4 The frequency adjustment method provided in the embodiment of the present application is described. In the video recording scenario, the electronic device uses the video recording software to record the video. The architecture of the video recording software is as follows: Figure 4 As shown, the recording software includes a load detection module, a key process delay detection module, a key thread computing power demand information response module and a CPU frequency decision module.
[0173] Among them, the load detection module: in the process of collecting image frames (such as image frame 1, image frame 2, ..., image frame n), calculates the CPU load once every frame interval (that is, each time an image frame is collected), and when the CPU load increases relative to the load calculated last time, increases the CPU frequency until the CPU frequency meets a certain standard, which standard can be a frequency parameter configured by the technician in the configuration file; when the CPU load decreases relative to the load calculated last time, lowers the CPU frequency.
[0174] Among them, the key process delay detection module: the recording software includes processes (Node) 1, Node2, ..., Noden, a total of n processes. Whenever the key process in the recording software starts to execute, the module will start timing, and the timing will end after the key process is executed, thereby obtaining the execution delay (i.e., the image processing duration). Then the recorded execution delay is compared with the performance index configured by the technician (such as the expected duration). Once it is lower than the performance index, the CPU frequency will be increased; otherwise, the CPU frequency will be reduced.
[0175] Among them, the key thread computing power requirement information response module: during the recording process of the recording software, the threads to be called include thread 1 executing task 1, thread 2 executing task 2, ..., thread n executing task n. The module can detect the executed threads and compare the executed threads with the key threads configured by the technicians. Once the scheduled thread is a key thread, the CPU frequency will be adjusted according to the computing power requirement information of the key thread read.
[0176] Among them, CPU frequency decision module: This module collects the adjustment strategies of the first three modules for the CPU frequency. The adjustment strategies include increasing the CPU frequency to x frequency or decreasing the CPU frequency to y frequency. And according to the internal decision logic, according to the corresponding weight value and adjustment strategy of each module, it decides how to adjust the CPU frequency and performs the adjustment operation.
[0177] In the present application embodiment, Figure 4 As shown in the CPU frequency adjustment results, through the coordination and cooperation of various modules, the final decision is made to meet the performance requirements of smoothness while suppressing the CPU frequency as low as possible, so that the CPU frequency meets the actual computing power requirements of the scene, saves power consumption and delays the heating of electronic equipment, effectively ensuring the balance between smoothness and heating.
[0178] It should be noted that the specific implementation process of the above steps 301 to 307 can refer to the relevant description of the above embodiment. To avoid repetition, this embodiment will not be repeated here.
[0179] Figure 5 4 is a flow chart of a frequency adjustment method provided in an embodiment of the present application. Taking adjusting the CPU frequency based on the CPU load as an example, the method may include the following steps 501 to 502.
[0180] Step 501: Each time an electronic device captures an image frame, it detects the average CPU load within z milliseconds before the image frame.
[0181] Exemplarily, the average load of the CPU within z milliseconds before the above image frame is the above first load, and the above z milliseconds are the first time period in the above embodiment.
[0182] Step 502: When the electronic device determines that the average CPU load in the previous z milliseconds is higher than y%, it increases the CPU frequency to reduce the load; when the average CPU load in the previous z milliseconds is lower than x%, it decreases the CPU frequency to increase the load.
[0183] For example, in a video recording scenario, a CPU load range of x% to y% may be configured. During the entire video recording process, the CPU load is ensured to be between x% and y%, thereby achieving the best effect.
[0184] In this way, through real-time monitoring of the CPU load, the CPU frequency can be adjusted in time to ensure the balance between smoothness and heat generation as much as possible, which can reduce the load impact of algorithm switching, software background work, etc. during the recording process, which causes CPU load fluctuations, and ensure the stability of the CPU load without the need for engineers to manually adjust the CPU frequency parameter configuration file.
[0185] It should be noted that the specific implementation process of the above steps 501 to 502 can refer to the relevant description of the above embodiment, and to avoid repetition, this embodiment will not be repeated here. In addition, the above steps 501 and 502 can be performed in combination with the above steps 301 to 307.
[0186] Figure 6 It is a flow chart of the frequency adjustment method provided in an embodiment of the present application. Taking adjusting the CPU frequency based on the image processing duration of a key process as an example, the method may include the following steps 601 to 602.
[0187] Step 601: When the electronic device executes a key process from capturing an image to previewing and displaying the image, the electronic device obtains the time taken to execute the process, that is, the image processing time.
[0188] Step 602: The electronic device determines the adjusted CPU frequency, ie, the seventh frequency, based on the acquired image processing time.
[0189] It should be noted that the entire process from the CPU receiving the image to the video file saving may include multiple processes. If the working time of each process can be guaranteed to remain stable, the smoothness of the entire video recording process can be guaranteed.
[0190] For example, it is assumed that the entire process may include three processes (Nodes), namely Node1, Node2 and Node3, and the expected time consumption of these three Nodes is set to X1, X2 and X3 milliseconds respectively. During the entire working process, if the working time consumption of a certain Node is higher than the expected time consumption, the electronic device can increase the CPU frequency when the Node is running in the next frame to ensure the running time of the Node; conversely, if the time consumption of a certain Node is lower than the expected time consumption, the electronic device can reduce the CPU frequency when the Node is running in the next frame to ensure that the CPU will not overheat when the Node is running.
[0191] In this way, triggered by the principle of the recording process, a better balance between smoothness and temperature rise is ensured.
[0192] It should be noted that the specific implementation process of the above steps 601 and 602 can refer to the relevant description of the above embodiment. To avoid repetition, this embodiment will not be repeated here. In addition, the above steps 601 and 602 can be performed in combination with the above steps 301 to 307, or in combination with the above steps 501 and 502, or in combination with steps 301 to 307, and steps 501 and 502.
[0193] Thus, this embodiment is combined with Figure 3 , Figure 4 and Figure 5 The corresponding embodiments are executed in combination to further avoid extreme situations in the operation of the entire system and prevent the frequency configuration from being too high or too low.
[0194] For example, when the working time of a certain Node is higher than the expected time for many consecutive times, the electronic device will increase the CPU frequency to the highest frequency. At this time, the CPU load can be used to determine whether the current CPU status is normal. If the CPU load is also very high, there may be background fluctuations during this period; but if the CPU load is very low, it means that there may be certain problems with the recording software during this period, such as the Node configuration time is too low or other abnormalities. At this time, an exception can be thrown from the software code level and provided to engineers for analysis and resolution.
[0195] It should be noted that the above-mentioned method embodiments, or various possible implementation methods in each method embodiment, can be executed separately, or any two or more can be executed in combination with each other. The specific implementation method can be determined according to actual usage requirements, and the embodiments of the present application do not impose any restrictions on this.
[0196] The frequency adjustment method provided in the embodiment of the present application can be executed by a frequency adjustment device. In the embodiment of the present application, the frequency adjustment device provided in the embodiment of the present application is described by taking the frequency adjustment method executed by the frequency adjustment device as an example.
[0197] Figure 7 70 is a schematic diagram of the structure of a frequency adjustment device provided in an embodiment of the present application. The frequency adjustment device includes: an acquisition module 701 and a processing module 702.
[0198] The acquisition module 701 is used to acquire first information when capturing the first image frame.
[0199] The processing module 702 is used to adjust the frequency of the first module in the electronic device according to the first information obtained by the obtaining module 701.
[0200] Among them, the above-mentioned first information includes at least one of the following: a first load, image processing time, and thread computing power requirement information; the first load is the load of the first module in the first time period before the first image frame.
[0201] Optionally, in the embodiment of the present application, the first information includes a first load;
[0202] The processing module 702 is specifically configured to adjust the frequency of the first module according to a first difference between the first load and the reference load when the first load is different from the reference load, and the reference load includes a second load or a load threshold;
[0203] The second load is the load of the first module in a second time period before a second image frame, the second image frame is an image frame before the first image frame, and the second time period is the same as the first time period.
[0204] Optionally, in the embodiment of the present application, the processing module 702 is specifically configured to increase the frequency of the first module to the first frequency when the first load is greater than the reference load; or, when the first load is less than the reference load, decrease the frequency of the first module to the second frequency;
[0205] The first frequency and the second frequency are both determined based on the first difference.
[0206] Optionally, in an embodiment of the present application, the first information includes image processing time, where the image processing time is the time used to process the first image frame based on the key algorithm;
[0207] The processing module 702 is specifically used to adjust the frequency of the first module according to a second difference between the image processing time and the expected time when the image processing time is different from the expected time, where the expected time is the expected time for processing the image frame by the key algorithm.
[0208] Optionally, in the embodiment of the present application, the processing module 702 is specifically configured to increase the frequency of the first module to the third frequency when the image processing time is longer than the expected time; or, when the image processing time is shorter than the expected time, decrease the frequency of the first module to the fourth frequency;
[0209] The third frequency and the fourth frequency are both determined based on the second difference.
[0210] Optionally, in an embodiment of the present application, the processing module 702 is specifically used to adjust the frequency of the first module according to the second difference at the start time of processing the third image frame based on the key algorithm, and the third image frame is an image frame after the first image frame.
[0211] Optionally, in an embodiment of the present application, the first information includes computing power requirement information;
[0212] The processing module 702 is specifically used to adjust the frequency of the first module to the fifth frequency according to the computing power requirement information, and the fifth frequency is the frequency corresponding to the computing power requirement information.
[0213] Optionally, in an embodiment of the present application, the first information includes the first load, image processing time and computing power requirement information;
[0214] The above-mentioned processing module 702 is specifically used to determine the sixth frequency according to the first load, determine the seventh frequency according to the image processing time, and determine the eighth frequency according to the computing power requirement information; and adjust the frequency of the first module according to the sixth frequency and the first weight value, the seventh frequency and the second weight value, and the eighth frequency and the third weight value.
[0215] Optionally, in an embodiment of the present application, the processing module 702 is further used to adjust the frequency of the first module to a ninth frequency when a fourth image frame is captured, where the ninth frequency is an adjustment frequency corresponding to an image frame before the fourth image frame.
[0216] In the frequency adjustment device provided in the embodiment of the present application, in one case, since the frequency adjustment device can adjust the frequency of the hardware unit (such as the first module) according to the load conditions in a time period before the image frame when collecting any image frame (such as the first image frame), that is, each image frame adjusts the frequency of the hardware unit according to the corresponding load conditions, so the timing of adjusting the frequency is more accurate and energy-saving, and the adjusted frequency is more suitable for the hardware unit that processes the current image frame. In another case, since the frequency adjustment device can adjust the frequency of the hardware unit according to the image processing time corresponding to the image frame when processing any image frame, it can ensure that the image processing time corresponding to each image frame is not too short or too long, ensure that the display of the image frame is stable, and delay the heating of the electronic device while meeting the fluency. In another case, since the frequency adjustment device can adjust the frequency of the hardware unit according to the computing power requirement information of the thread corresponding to the image frame when processing any image frame, the adjusted frequency is more suitable for the thread to perform the image frame processing task, ensuring the fluency of the displayed image. In this way, through the above method, it is possible to avoid adjusting the frequency of the hardware unit to an excessively high or low frequency, and the adjusted frequency can effectively ensure the balance between the smoothness and heat generation of the frequency adjustment device.
[0217] The frequency adjustment device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than a terminal. For example, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device, an augmented reality / virtual reality device, a robot, a wearable device, a super mobile personal computer, a netbook or a personal digital assistant, etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0218] The frequency adjustment device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0219] The frequency adjustment device provided in the embodiment of the present application can implement each process implemented by each embodiment of the above-mentioned frequency adjustment method, and will not be described again here to avoid repetition.
[0220] Alternatively, if Figure 8 As shown, an embodiment of the present application further provides an electronic device 900, including a processor 901 and a memory 902, wherein the memory 902 stores programs or instructions that can be executed on the processor 901, and when the program or instructions are executed by the processor 901, the various steps of the above-mentioned frequency adjustment method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, they are not described here.
[0221] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0222] Fig. 9 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0223] The electronic device 1000 includes but is not limited to: a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009, and a processor 1010 and other components.
[0224] Those skilled in the art will appreciate that the electronic device 1000 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1010 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig. 9 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0225] The processor 1010 is used to obtain first information when the first image frame is captured, and adjust the frequency of the first module in the electronic device according to the first information.
[0226] Among them, the above-mentioned first information includes at least one of the following: a first load, image processing time, and thread computing power requirement information; the first load is the load of the first module in the first time period before the first image frame.
[0227] Optionally, in the embodiment of the present application, the first information includes a first load;
[0228] The processor 1010 is specifically configured to adjust the frequency of the first module according to a first difference between the first load and the reference load when the first load is different from the reference load, wherein the reference load includes the second load or the load threshold;
[0229] The second load is the load of the first module in a second time period before a second image frame, the second image frame is an image frame before the first image frame, and the second time period is the same as the first time period.
[0230] Optionally, in the embodiment of the present application, the processor 1010 is specifically configured to increase the frequency of the first module to the first frequency when the first load is greater than the reference load; or, when the first load is less than the reference load, decrease the frequency of the first module to the second frequency;
[0231] The first frequency and the second frequency are both determined based on the first difference.
[0232] Optionally, in an embodiment of the present application, the first information includes image processing time, where the image processing time is the time used to process the first image frame based on the key algorithm;
[0233] The processor 1010 is specifically used to adjust the frequency of the first module according to a second difference between the image processing time and the expected time when the image processing time is different from the expected time, where the expected time is the expected time for processing the image frame through the key algorithm.
[0234] Optionally, in the embodiment of the present application, the processor 1010 is specifically configured to increase the frequency of the first module to the third frequency when the image processing time is longer than the expected time; or, when the image processing time is shorter than the expected time, decrease the frequency of the first module to the fourth frequency;
[0235] The third frequency and the fourth frequency are both determined based on the second difference.
[0236] Optionally, in an embodiment of the present application, the processor 1010 is specifically used to adjust the frequency of the first module according to the second difference at the start moment of processing the third image frame based on the key algorithm, and the third image frame is an image frame after the first image frame.
[0237] Optionally, in an embodiment of the present application, the first information includes computing power requirement information;
[0238] The processor 1010 is specifically used to adjust the frequency of the first module to a fifth frequency according to the computing power requirement information, where the fifth frequency is a frequency corresponding to the computing power requirement information.
[0239] Optionally, in an embodiment of the present application, the first information includes the first load, image processing time and computing power requirement information;
[0240] The above-mentioned processor 1010 is specifically used to determine the sixth frequency according to the first load, determine the seventh frequency according to the image processing time, and determine the eighth frequency according to the computing power requirement information; and adjust the frequency of the first module according to the sixth frequency and the first weight value, the seventh frequency and the second weight value, and the eighth frequency and the third weight value.
[0241] Optionally, in an embodiment of the present application, the processor 1010 is further configured to adjust the frequency of the first module to a ninth frequency when a fourth image frame is captured, where the ninth frequency is an adjustment frequency corresponding to an image frame before the fourth image frame.
[0242] In the electronic device provided by the embodiment of the present application, in one case, since the electronic device can adjust the frequency of the hardware unit (such as the first module) according to the load condition in a time period before the image frame when collecting any image frame (such as the first image frame), that is, each image frame adjusts the frequency of the hardware unit according to the corresponding load condition, therefore, the timing of adjusting the frequency is more accurate and energy-saving, and the adjusted frequency is more suitable for the hardware unit that processes the current image frame. In another case, since the electronic device can adjust the frequency of the hardware unit according to the image processing time corresponding to the image frame when processing any image frame, therefore, it can ensure that the image processing time corresponding to each image frame will not be too short or too long, ensure that the display of the image frame is stable, and delay the heating of the electronic device while satisfying the fluency. In another case, since the electronic device can adjust the frequency of the hardware unit according to the computing power requirement information of the thread corresponding to the image frame when processing any image frame, therefore, the adjusted frequency is more suitable for the thread to perform the processing task of the image frame, ensuring the fluency of the displayed image. In this way, through the above method, it is possible to avoid adjusting the frequency of the hardware unit to too high or too low frequency, and the adjusted frequency can effectively ensure the balance between fluency and heating of the electronic device.
[0243] It should be understood that in the embodiment of the present application, the input unit 1004 may include a graphics processor (Graphics Processing Unit, GPU) 10041 and a microphone 10042, and the graphics processor 10041 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1006 may include a display panel 10061, and the display panel 10061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072. The touch panel 10071 is also called a touch screen. The touch panel 10071 may include two parts: a touch detection device and a touch controller. Other input devices 10072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0244] The memory 1009 can be used to store software programs and various data. The memory 1009 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 109 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0245] The processor 1010 may include one or more processing units; optionally, the processor 1010 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 1010.
[0246] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, each process of the above-mentioned frequency adjustment method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0247] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0248] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned frequency adjustment method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0249] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0250] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned frequency adjustment method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0251] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0252] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0253] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A frequency adjustment method, characterized in that: The method comprises: Acquire first information when capturing a first image frame; adjusting the frequency of a first module in the electronic device according to the first information; Among them, the first information includes at least one of the following: a first load, image processing time, and thread computing power requirement information; the first load is the load of the first module in a first time period before the first image frame.
2. The method according to claim 1, characterized in that The first information includes the first load; The step of adjusting the frequency of a first module in the electronic device according to the first information includes: In a case where the first load is different from a reference load, adjusting the frequency of the first module according to a first difference between the first load and the reference load, the reference load comprising a second load or a load threshold; The second load is the load of the first module in a second time period before a second image frame, the second image frame is an image frame before the first image frame, and the second time period is the same in length as the first time period.
3. The method according to claim 1, characterized in that The first information includes the image processing time, where the image processing time is the time used to process the first image frame based on a key algorithm; The step of adjusting the frequency of a first module in the electronic device according to the first information includes: When the image processing time is different from the expected time, the frequency of the first module is adjusted according to a second difference between the image processing time and the expected time, where the expected time is the expected time for processing the image frame by the key algorithm.
4. The method according to claim 1, characterized in that The first information includes the computing power requirement information; The step of adjusting the frequency of a first module in the electronic device according to the first information includes: According to the computing power requirement information, the frequency of the first module is adjusted to a fifth frequency, and the fifth frequency is a frequency corresponding to the computing power requirement information.
5. The method according to any one of claims 1 to 4, characterized in that After adjusting the frequency of the first module in the electronic device according to the first information, the method further includes: When the fourth image frame is acquired, the frequency of the first module is adjusted to a ninth frequency, where the ninth frequency is an adjustment frequency corresponding to an image frame before the fourth image frame.
6. A frequency adjustment device, characterized in that: The device comprises: an acquisition module and a processing module; The acquisition module is used to acquire the first information when the first image frame is captured; The processing module is used to adjust the frequency of the first module in the electronic device according to the first information acquired by the acquisition module; Among them, the first information includes at least one of the following: a first load, image processing time, and thread computing power requirement information; the first load is the load of the first module in a first time period before the first image frame.
7. The device according to claim 6, characterized in that The first information includes the first load; The processing module is specifically configured to adjust the frequency of the first module according to a first difference between the first load and the reference load when the first load is different from a reference load, wherein the reference load includes a second load or a load threshold; The second load is the load of the first module in a second time period before a second image frame, the second image frame is an image frame before the first image frame, and the second time period is the same in length as the first time period.
8. The device according to claim 6, characterized in that The first information includes the image processing time, where the image processing time is the time used to process the first image frame based on a key algorithm; The processing module is specifically used to adjust the frequency of the first module according to a second difference between the image processing time and the expected time when the image processing time is different from the expected time, and the expected time is the expected time for processing the image frame by the key algorithm.
9. The device according to claim 6, characterized in that The first information includes the computing power requirement information; The processing module is specifically used to adjust the frequency of the first module to a fifth frequency according to the computing power requirement information, and the fifth frequency is a frequency corresponding to the computing power requirement information.
10. The device according to any one of claims 6 to 9, characterized in that The processing module is further configured to adjust the frequency of the first module to a ninth frequency when a fourth image frame is acquired, where the ninth frequency is an adjustment frequency corresponding to an image frame before the fourth image frame.