Detailed Description
In the embodiments of the present application, terms such as "first" and "second" are used to distinguish the same or similar items having substantially the same function and action. For example, the first compression ratio and the second compression ratio are only used for distinguishing different compression ratios, and the sequence order thereof is not limited. Those skilled in the art will appreciate that the terms "first," "second," etc. do not denote any order or quantity, nor do the terms "first," "second," etc. denote any order or importance.
It is noted that, in the present application, words such as "exemplary" or "for example" are used to mean exemplary, illustrative, or descriptive. Any embodiment or design described herein as "exemplary" or "e.g.," is not necessarily to be construed as preferred or advantageous over other embodiments or designs. Rather, use of the word "exemplary" or "such as" is intended to present concepts related in a concrete fashion.
In the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone, wherein A and B can be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of the singular or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, a-b, a-c, b-c, or a-b-c, wherein a, b, c may be single or multiple.
The embodiment of the application provides a method for processing a snapshot, which is applied to a terminal with a memory and a flash memory. The terminal may be, for example: the specific type of the terminal is not limited in any way in the embodiments of the present application, such as a mobile phone, a tablet computer, a wearable device, an in-vehicle device, an Augmented Reality (AR)/Virtual Reality (VR) device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, and a Personal Digital Assistant (PDA).
The following describes an embodiment specifically by taking the terminal as a mobile phone 100. It should be understood that the illustrated handset 100 is only one example of a terminal and that the handset 100 may have more or fewer components than shown in the figures, may combine two or more components, or may have a different configuration of components.
As shown in fig. 1, the mobile phone 100 may specifically include: processor 101, Radio Frequency (RF) circuitry 102, memory 103, touch screen 104, bluetooth device 105, one or more sensors 106, Wi-Fi device 107, positioning device 108, audio circuitry 109, peripheral interface 110, and power supply 111. These components may communicate over one or more communication buses or signal lines (not shown in fig. 1). Those skilled in the art will appreciate that the hardware configuration shown in fig. 1 is not intended to be limiting, and that the handset 100 may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The following describes the components of the handset 100 in detail with reference to fig. 1:
the processor 101 is a control center of the cellular phone 100, connects various parts of the cellular phone 100 using various interfaces and lines, and performs various functions of the cellular phone 100 and processes data by running or executing an application program stored in the memory 103 and calling data stored in the memory 103. In some embodiments, processor 101 may include one or more processing units. For example, the processor 101 may be an kylin 960 chip manufactured by Huanti technologies, Inc. In some embodiments of the present application, the processor 101 may further include a fingerprint verification chip for verifying the acquired fingerprint.
The rf circuit 102 may be used for receiving and transmitting wireless signals during the transmission and reception of information or calls. In particular, the rf circuit 102 may receive downlink data of the base station and then process the received downlink data to the processor 101; in addition, data relating to uplink is transmitted to the base station. Typically, the radio frequency circuitry includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier, a duplexer, and the like. In addition, the radio frequency circuitry 102 may also communicate with other devices via wireless communication. The wireless communication may use any communication standard or protocol including, but not limited to, global system for mobile communications, general packet radio service, code division multiple access, wideband code division multiple access, long term evolution, email, short message service, and the like.
The
memory 103 is used for storing application programs and data, and the
processor 101 executes various functions and data processing of the
mobile phone 100 by running the application programs and data stored in the
memory 103. The
memory 103 mainly includes a program storage area and a data storage area, wherein the program storage area can store an operating system and application programs (such as a sound playing function and an image playing function) required by at least one function; the storage data area may store data (e.g., audio data, a phonebook, etc.) created from use of the
handset 100. Further, the
memory 103 may include high speed random access memory, and may also include non-volatile memory, such as a magnetic disk storage device, a flash memory device, or other volatile solid state storage device. The
memory 103 may store various operating systems, such as those developed by apple Inc
Operating System, developed by Google
An operating system, etc. The
memory 103 may be independent and connected to the
processor 101 through the communication bus; the
memory 103 may also be integrated with the
processor 101.
The touch screen 104 may include a touch pad 104-1 and a display (also referred to as a display screen) 104-2. Wherein the touch pad 104-1 can capture touch events on or near the touch pad 104-1 by a user of the cell phone 100 (e.g., user operation on or near the touch pad 104-1 using any suitable object such as a finger, a stylus, etc.), and transmit the captured touch information to other devices, such as the processor 101. Among them, a touch event of a user near the touch pad 104-1 can be called a hover touch; hover touch may refer to a user not having to directly contact the touchpad in order to select, move, or drag a target (e.g., an icon, etc.), but rather only having to be located near the electronic device in order to perform a desired function. In the context of a hover touch application, the terms "touch," "contact," and the like do not imply a direct contact to the touch screen, but rather a nearby or near contact. The touch pad 104-1 capable of performing floating touch can be implemented by using capacitive type, infrared sensing, ultrasonic wave, and the like. In addition, the touch pad 104-1 can be implemented by various types, such as resistive, capacitive, infrared, and surface acoustic wave. The display (which may also be referred to as a display screen) 104-2 may be used to display information entered by or provided to the user as well as various menus of the handset 100. The display 104-2 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The trackpad 104-1 may be overlaid on the display 104-2, and when the trackpad 104-1 detects a touch event thereon or nearby, it is communicated to the processor 101 to determine the type of touch event, and the processor 101 may then provide a corresponding visual output on the display 104-2 based on the type of touch event. Although in FIG. 1, the touch pad 104-1 and the display 104-2 are shown as two separate components to implement the input and output functions of the cell phone 100, in some embodiments, the touch pad 104-1 and the display 104-2 may be integrated to implement the input and output functions of the cell phone 100. It is understood that the touch screen 104 is formed by stacking multiple layers of materials, and only the touch pad (layer) and the display screen (layer) are shown in the embodiment of the present application, and other layers are not described in the embodiment of the present application. In addition, in some other embodiments of the present application, the touch pad 104-1 may be covered on the display 104-2, and the size of the touch pad 104-1 is larger than that of the display 104-2, so that the display 104-2 is completely covered under the touch pad 104-1, or the touch pad 104-1 may be disposed on the front surface of the mobile phone 100 in a full-panel manner, that is, a user's touch on the front surface of the mobile phone 100 can be sensed by the mobile phone, so that a full-touch experience on the front surface of the mobile phone can be achieved. In other embodiments, the touch pad 104-1 is disposed on the front surface of the mobile phone 100 in a full-panel manner, and the display 104-2 may also be disposed on the front surface of the mobile phone 100 in a full-panel manner, so that a Bezel-free (Bezel) structure can be implemented on the front surface of the mobile phone.
The handset 100 may also include a bluetooth device 105 for enabling data exchange between the handset 100 and other short-range electronic devices (e.g., cell phones, smartwatches, etc.). The bluetooth device in the embodiment of the present application may be an integrated circuit or a bluetooth chip.
The handset 100 also includes at least one sensor 106, such as a light sensor, motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that adjusts the brightness of the display of the touch screen 104 according to the brightness of ambient light, and a proximity sensor that turns off the power of the display when the mobile phone 100 is moved to the ear.
The accelerometer sensor can also be used for detecting the size and direction of gravity when the mobile phone is static, and can be used for identifying the application of the gesture of the mobile phone (such as horizontal and vertical screen switching, related games and magnetometer gesture calibration), vibration identification related functions (such as pedometer and knocking) and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured on the mobile phone 100, further description is omitted here.
The Wi-Fi device 107 is used for providing network access for the mobile phone 100 according to Wi-Fi related standard protocols, the mobile phone 100 can be accessed to a Wi-Fi access point through the Wi-Fi device 107, so that the mobile phone helps a user to send and receive e-mails, browse webpages, access streaming media and the like, and wireless broadband internet access is provided for the user. In other embodiments, the Wi-Fi apparatus 107 can also be a Wi-Fi wireless access point, which can provide Wi-Fi network access to other electronic devices.
And a positioning device 108 for providing a geographical position for the handset 100. It is understood that the positioning device 108 may be a receiver of a Global Positioning System (GPS) or a positioning system such as the beidou satellite navigation system, russian GLONASS, etc. After receiving the geographical location transmitted by the positioning system, the positioning device 108 transmits the information to the processor 101 for processing or transmits the information to the memory 103 for storage. In still other embodiments, the positioning device 108 may also be a receiver of an Assisted Global Positioning System (AGPS) that assists the positioning device 108 in performing ranging and positioning services by acting as an assistance server, in which case the assistance positioning server provides positioning assistance by communicating with the positioning device 108 (i.e., GPS receiver) of an electronic device, such as the handset 100, over a wireless communication network. In other embodiments, the location device 108 may also be a Wi-Fi access point based location technology. Since each Wi-Fi access point has a globally unique MAC address, the mobile phone 100 can scan and collect broadcast signals of surrounding Wi-Fi access points when the Wi-Fi is turned on, and thus can acquire the MAC address broadcasted by the Wi-Fi access point; the electronic device sends the data (e.g., MAC address) indicating the Wi-Fi access points to a location server through a wireless communication network, and the location server retrieves the geographical location of each Wi-Fi access point, and calculates the geographical location of the mobile phone 100 according to the strength of the Wi-Fi broadcast signal and sends the geographical location of the mobile phone 100 to the positioning device 108 of the mobile phone 100.
The audio circuitry 109, speaker 113, microphone 114 can provide an audio interface between a user and the handset 100. The audio circuit 109 may transmit the electrical signal converted from the received audio data to the speaker 113, and convert the electrical signal into a sound signal by the speaker 113 to output. On the other hand, the microphone 114 converts the collected sound signal into an electrical signal, converts the electrical signal into audio data after being received by the audio circuit 109, and outputs the audio data to the RF circuit 102 to be transmitted to, for example, another cellular phone, or outputs the audio data to the memory 103 for further processing.
Peripheral interface 110, which is used to provide various interfaces for external input/output devices (e.g., keyboard, mouse, external display, external memory, SIM card, etc.). For example, a mouse via a Universal Serial Bus (USB) interface, and a subscriber identity module card (SIM) card provided by a telecommunications carrier via metal contacts on a SIM card slot. Peripheral interface 110 may be used to couple the aforementioned external input/output peripherals to processor 101 and memory 103.
The mobile phone 100 may further include a power supply device 111 (such as a battery and a power management chip) for supplying power to each component, and the battery may be logically connected to the processor 101 through the power management chip, so as to implement functions of managing charging, discharging, and power consumption through the power supply device 111.
Although not shown in fig. 1, the mobile phone 100 may further include a camera (front camera and/or rear camera), a flash, a micro-projector, a Near Field Communication (NFC) device, etc., which will not be described herein.
The snapshot recorded in the embodiment of the application is generated after the terminal captures the screen of the display interface of the application. The snapshot is described in detail below with reference to fig. 2 and 3:
as shown in fig. 2, a WeChat chat interface 201 shown in (a) of fig. 2 is displayed in the display screen of the terminal. After the terminal receives the operation of exiting the application to the background, the terminal captures a screen of the wechat chat interface, and generates a snapshot 202 of the wechat application as shown in (b) in fig. 2.
Referring to fig. 2 and as shown in fig. 3, when the terminal needs to open the wechat application according to the snapshot 202, the terminal first enters a snapshot display interface shown in (a) of fig. 3. When the terminal detects an operation in which the snapshot 202 is selected (for example, an operation in which the user clicks the snapshot 202 shown in (a) in fig. 3), the terminal restores the wechat application to the wechat interface 201 shown in (b) in fig. 3.
Currently, in order to reduce the storage space occupied by the snapshot, a fixed compression ratio is set in the terminal. If the compression ratio is configured in the terminal, the terminal may compress the snapshot according to the compression ratio after generating the snapshot. And the compressed snapshot is stored in the terminal, so that the storage space occupied by the snapshot can be reduced.
However, once the compression ratio is set in the terminal, it cannot be changed. And the terminal compresses the snapshot according to the compression ratio whether the available storage space is sufficient or not. When the compression ratio is a small compression ratio, the compressed snapshot occupies a small storage space, but the pixels of the snapshot also become low. This will likely affect the user's visual experience with the snapshot functionality. Therefore, when the available storage space of the terminal is larger than the preset value, the terminal does not need to reduce the storage space occupied by the snapshot by compressing the snapshot.
The method for processing a snapshot provided in the embodiment of the present application may be applied to the mobile phone 100 shown in fig. 1, and the method for processing a snapshot provided in the embodiment of the present application will be described in detail below with reference to specific embodiments. As shown in fig. 4, the method includes:
step 101, the terminal determines an available storage space of a memory of the terminal.
The available storage space of the memory is also the remaining storage space in the memory.
In the embodiment of the present application, a memory is a Random Access Memory (RAM), and a flash memory is a flash memory (flash for short) for example.
The available storage space of the memory is the storage space in the RAM that is not occupied by the system, application programs, data, or the like of the terminal.
It should be understood that the available memory space in the RAM is constantly changing as the terminal is running. For example, when the number of applications running on the terminal increases, the available storage space in the RAM decreases accordingly; as the applications run by the terminal decrease, the available memory space in the RAM increases accordingly.
Taking the memory as 4G as an example, and the memory used by the terminal is 3G, the available storage space of the memory is 4G-3G — 1G.
And 102, the terminal determines the compression ratio of the snapshot in the processing terminal according to the relation between the available storage space and the preset threshold value. The compression ratio determined by the terminal is the first compression ratio or the second compression ratio.
In this embodiment of the application, the second compression ratio is smaller than the first compression ratio, so that the storage space occupied by the snapshot processed with the second compression ratio is smaller than the storage space occupied by the snapshot processed with the first compression ratio.
Illustratively, the first compression ratio is 1.0 and the second compression ratio is 0.7.
It should be noted that, when the terminal processes the snapshot by using the first compression ratio of 1.0, the terminal may not perform compression processing on the snapshot, but directly store the snapshot in the cache of the memory. And when the terminal processes the snapshot by adopting the second compression ratio, the terminal processes the snapshot according to the compression ratio of 0.7 and stores the compressed snapshot in the cache of the memory.
For example, taking the snapshot pixel as 720 × 1080 as an example, the pixels of the snapshot generated after the terminal processes the snapshot according to the compression ratio of 0.7 are: (720 × 0.7) × (1080 × 0.7) ═ 504 × 756. After the terminal processes the snapshot according to the compression ratio of 0.7, the storage space occupied by the snapshot can be reduced by about 50%, so that the problem of insufficient available storage space of the terminal memory caused by the fact that the snapshot occupies a large amount of memory space is solved.
And 103, processing the snapshot by the terminal according to the compression ratio. And the storage space occupied by the snapshot processed by the first compression ratio is larger than that occupied by the snapshot processed by the second compression ratio.
Specifically, the storage space occupied by the snapshot processed by the second compression ratio in the memory is smaller than the storage space occupied by the snapshot processed by the first compression ratio in the memory.
Based on the above technical solution, the method for processing a snapshot provided by the present application: and the terminal determines the compression ratio of the processed snapshot according to the available storage space of the memory of the terminal. The terminal processes the snapshot according to the determined compression ratio; the storage space occupied by the snapshot processed by the first compression ratio is larger than that occupied by the snapshot processed by the second compression ratio. Therefore, the terminal can flexibly process the snapshot by adopting different compression ratios according to the size of the available storage space of the terminal memory. The scheme can be applied to the field of Artificial Intelligence (AI) of terminals, computer vision and image processing.
With reference to fig. 5, in a possible embodiment, before step 102, the method provided in this embodiment may further include:
and step 104, the terminal determines the memory state of the memory according to the relation between the available storage space and the preset threshold value.
The preset threshold comprises a first preset threshold and a second preset threshold; the memory state of the memory includes a first state and a second state. The first state represents that the available storage space is greater than or equal to a first preset threshold. The second memory state indicates that the available storage space is less than a second predetermined threshold. The first preset threshold and the second preset threshold may be the same or different.
And the memory state set by the terminal in the Nth period is used for representing the relation between the available storage space determined by the terminal in the Nth period and the preset threshold. N is a positive integer.
It should be understood that, in a period after the nth period, the relationship between the available storage space determined by the terminal in the nth period and the preset threshold may be determined according to the memory state set by the terminal in the nth period.
For example, in the N +1 th period, the terminal determines that the memory state set in the nth period of the terminal is the first state, and then the terminal may determine, according to the first state, that the available memory space determined by the terminal in the nth period is greater than or equal to the first preset threshold.
In a possible implementation manner, the terminal may further determine the memory state of the memory according to a proportional relationship between the available storage space and the memory.
For example, when the terminal sets that the available storage space is greater than or equal to 25% of the memory, the terminal determines that the memory state of the terminal memory is a first state, and when the available storage space is less than 25% of the memory, the terminal determines that the memory state of the terminal memory is a second state.
That is, in practical application, for a terminal with a memory of 4G, when the available storage space is greater than or equal to 1G, the terminal determines that the memory state of the terminal is the first state. And when the available storage space is less than 1G, the terminal determines that the memory state of the terminal is a second state.
As a possible implementation, as shown in fig. 6, step 104 may be implemented by:
step 1041, the terminal determines that the available storage space of the memory is greater than or equal to a first preset threshold, the terminal determines that the memory state of the memory is set to be a first state, and records the time for setting the first state.
In a possible implementation manner, if the terminal determines that the memory state of the memory is the second state in the nth period. And the terminal determines that the available memory space of the memory is greater than or equal to a first preset threshold value in the (N + 1) th period, and the terminal updates the memory state of the terminal to be the first state.
And if the terminal determines that the memory state of the memory is the first state in the Nth period. The terminal determines that the available memory space of the memory is greater than or equal to a first preset threshold value in the (N + 1) th period, the terminal keeps the memory state of the terminal to be a first state, and the terminal acquires the time for setting the first state.
It should be noted that, if the terminal is in the nth cycle to the N + m cycle, it is determined that the memory states of the terminal are all the first states. And the terminal determines the time for setting the first state recorded in the Nth period and determines whether the difference between the time for setting the first state and the current time is greater than a first preset time difference. If the difference between the time for setting the first state and the current time is greater than the first preset time difference, the terminal memory available storage space is greater than or equal to a first preset threshold value and lasts for a first preset time period. The terminal determines that a first preset condition is met between the available storage space of the terminal and a first preset threshold. Further, the terminal determines that the compression ratio of the snapshot in the processing terminal is the first compression ratio. m is a positive integer.
As a possible implementation, as shown in fig. 6, step 104 can also be implemented by:
step 1042, the terminal determines that the available storage space of the memory is smaller than a second preset threshold, the terminal determines that the memory state of the memory is set to be a second state, and records the time for setting the second state.
In a possible implementation manner, if the terminal determines that the memory state of the memory is the first state in the nth period. And the terminal determines that the available memory space of the memory is smaller than a second preset threshold value in the (N + 1) th period, and the terminal updates the memory state of the terminal to be a second state.
And if the terminal determines that the memory state of the memory is the second state in the Nth period. The terminal determines that the available memory space of the memory is smaller than a second preset threshold value in the (N + 1) th period, the terminal keeps the memory state of the terminal in the second state, and the terminal acquires the time for setting the second state.
It should be noted that, if the terminal is in the nth cycle to the N + m cycle, it is determined that the memory states of the terminal are all the second states. And the terminal determines the time for setting the second state recorded in the Nth period and determines whether the difference between the time for setting the second state and the current time is greater than a second preset time difference. And if the difference value between the time for setting the second state and the current time is greater than a second preset time difference value, the available storage space of the terminal memory is smaller than a second preset threshold value and lasts for a second preset time period. And the terminal determines that the available storage space of the terminal and a second preset threshold value meet a second preset condition. Further, the terminal determines that the compression ratio of the snapshot in the processing terminal is the second compression ratio.
Therefore, the terminal can determine whether the memory state of the terminal changes in the continuous period by setting the memory state. Furthermore, the terminal determines the duration of the current memory state of the terminal according to the difference between the setting time of the current memory state of the terminal and the current time, so that the terminal can accurately determine the relationship between the available storage space and the preset threshold value.
Since the compression ratios determined by the terminals are different, the modes of the terminal processing the snapshot are different, and therefore the following description is provided respectively:
example 1) compression ratio of the first compression ratio
As a possible embodiment of the present application, as shown in fig. 6, step 102 in the embodiment of the present application may be implemented in the following manner:
step 1021, when the first preset condition is met, the terminal determines that the compression ratio is the first compression ratio.
Wherein the first preset condition is as follows: the available storage space is greater than or equal to a first preset threshold; alternatively, the available storage space is greater than or equal to a first preset threshold value and lasts for a first preset time period.
Illustratively, the first preset threshold is 1100M and the first preset time period is 20 minutes.
As a possible implementation manner, as shown in fig. 6, when the first preset condition is: when the available storage space is greater than or equal to the first preset threshold and lasts for the first preset time period, before step 1021, the method may further include:
in step 1022, the terminal determines whether a difference between the time for marking the first state and the current time is greater than a first preset time difference.
In a possible implementation manner, a memory monitoring program is provided in the terminal, and the terminal periodically determines a relationship between an available storage space of the terminal and the memory through the memory monitoring program.
For example, in step 1022, the relationship between the available storage space of the terminal and the first preset threshold determined by the terminal memory monitoring program is shown in fig. 7. Wherein, the first preset threshold is 1100M.
The terminal continuously records the available storage space, and when the available storage space is greater than or equal to 1100M within the continuous preset time, the terminal determines that the relation between the available storage space of the terminal and the first preset threshold meets a first preset condition.
In case that the terminal determines that the difference between the time of marking the first state and the current time is greater than the first preset time difference, the terminal performs step 1023.
Step 1023, the terminal determines that the available storage space of the memory and the first preset threshold value meet a first preset condition.
It should be noted that, the terminal determines that the difference between the time for marking the first state and the current time is greater than the first preset time difference, and the duration of the time period during which the available storage space of the terminal is greater than or equal to the first preset threshold is greater than the duration of the first preset time period. Further, the terminal determines that a relationship between the available storage space of the terminal and a first preset threshold satisfies a first preset condition.
It should be understood that the memory state of the available storage space is the first state, and the difference between the time of marking the first state and the current time is greater than the first preset time difference, the terminal determines that the available storage space is greater than or equal to the first preset threshold, and lasts for the first preset time period. Furthermore, the terminal determines that the available storage space of the memory and the first preset threshold value meet a first preset condition.
In case that the terminal determines that the difference between the time marking the first state and the current time is less than or equal to a first preset time difference, the terminal performs step 101.
It should be noted that, the difference between the time for marking the first state and the current time is determined by the terminal to be less than or equal to the first preset time difference, which indicates that the duration of the time period during which the available storage space of the terminal is greater than or equal to the first preset threshold is less than the duration of the first preset time period. Further, the terminal determines that the relation between the available storage space of the terminal and the preset threshold does not satisfy a first preset condition.
Accordingly, with reference to fig. 6, step 103 in the embodiment of the present application may be implemented by:
and step 1031, the terminal processes the first snapshot according to the first compression ratio. And the terminal stores the first snapshot processed by adopting the first compression ratio in a memory of the terminal.
The first snapshot is a snapshot between the current time and a first time node; the first time node is a time node after the current time and when the compression ratio determined by the terminal changes.
For example, the terminal generates a first snapshot before the current time reaches a first time node: snapshot 1, snapshot 2, and snapshot 3. And the terminal respectively processes the snapshot 1, the snapshot 2 and the snapshot 3 by adopting a first compression ratio. And storing the compressed snapshots 1, 2 and 3 in the memory of the terminal. And further, the terminal stores the compressed snapshots 1, 2 and 3 in a cache of a terminal memory, so that the terminal can call the snapshots more quickly.
For the cached snapshot, the terminal processes the snapshot by using the method described in step 1032 or step 1033.
Step 1032, the terminal processes the cache snapshot stored in the flash memory by adopting the first compression ratio, and replaces the cache snapshot processed by adopting the second compression ratio in the memory by adopting the cache snapshot processed by the first compression ratio.
And the cache snapshot stored in the flash memory is not processed by adopting the first compression ratio.
For example, at the current time, the terminal determines that a cache snapshot is stored in a flash memory of the terminal: snapshot 4 and snapshot 5. Snapshot 4 and snapshot 5 are the original-scale snapshots generated by the terminal. Correspondingly, the snapshot 4 compressed by the second compression ratio and the snapshot 5 compressed by the second compression ratio are stored in the memory of the terminal.
The terminal processes the snapshot 4 and the snapshot 5 with a first compression ratio. The terminal replaces the snapshot 4 processed by the second compression ratio in the memory with the snapshot 4 processed by the first compression ratio; and replacing the snapshot 5 processed by the second compression ratio in the memory by the snapshot 5 processed by the first compression ratio.
1033. And the terminal replaces the cache snapshot processed by the second compression ratio in the memory by the cache snapshot processed by the first compression ratio. Wherein the cache snapshot stored in the flash memory is a cache snapshot processed by adopting a first compression ratio,
for example, at the current time, the terminal determines that a cache snapshot is stored in a flash memory of the terminal: snapshot 6 processed with the first compression ratio and snapshot 7 processed with the first compression ratio. Correspondingly, a snapshot 6 compressed by the second compression ratio and a snapshot 7 compressed by the second compression ratio are stored in the memory of the terminal.
The terminal replaces the snapshot 6 processed by the second compression ratio in the memory with the snapshot 6 processed by the first compression ratio; and replacing the snapshot 7 processed by the second compression ratio in the memory by the snapshot 7 processed by the first compression ratio.
It should be noted that, when the terminal does not process the cache snapshot stored in the flash memory according to the first compression ratio, the terminal processes the cache snapshot in the terminal according to the scheme described in step 1032.
When the terminal uses the first compression ratio to process the cache snapshot stored in the flash memory, the terminal uses the scheme recorded in step 1033 to process the cache snapshot in the terminal.
In a possible implementation manner, after the terminal replaces the cache snapshot processed at the second compression ratio in the memory with the cache snapshot processed at the first compression ratio, the terminal may delete the cache snapshot processed at the first compression ratio stored in the flash memory, so as to achieve the purpose of reducing the available storage space of the terminal flash memory occupied by the snapshots.
Example 2) compression ratio of the second compression ratio
As a possible embodiment of the present application, as shown in fig. 6, step 102 in the embodiment of the present application may be implemented in the following manner:
and step 1024, when a second preset condition is met, the terminal determines that the compression ratio is a second compression ratio.
The second preset condition is as follows: the available storage space is smaller than a second preset threshold; or the available storage space is smaller than a second preset threshold value and lasts for a second preset time period.
Illustratively, the second preset threshold is 900M and the second preset time period is 30 minutes.
It should be noted that, in the embodiment of the present application, the first preset threshold and the second preset threshold may be equal or unequal. The first preset time difference and the second preset time difference may be equal or unequal. The terminal can be flexibly set according to actual conditions.
In practical application, the terminal can achieve the purpose of avoiding the terminal from frequently switching and processing the compression ratio of the snapshot by setting the first preset threshold to be larger than the second preset threshold. The terminal can enable the terminal to process snapshots more by adopting the first compression ratio by setting the first preset time difference value to be smaller than the second preset time difference value, so that the terminal is prevented from displaying the snapshots with low pixels for a long time.
As a possible implementation manner, with reference to fig. 6, when the second preset condition is: the available storage space is less than a second preset threshold and lasts for a second preset time period. Before step 1024, the method may further include:
in step 1025, the terminal determines whether the difference between the time for marking the second state and the current time is greater than a second preset time difference.
For example, in step 1025, the relationship between the available storage space of the terminal and the second predetermined threshold determined by the terminal memory monitor is shown in fig. 8. Wherein the second preset threshold is equal to 900M.
And the terminal continuously records the available storage space, and when the available storage space is less than 1100M within the continuous preset time, the terminal determines that the relation between the available storage space of the terminal and the second preset threshold meets a second preset condition.
In case that the terminal determines that the difference between the time for marking the second state and the current time is greater than a second preset time difference, the terminal performs step 1026.
In step 1026, the terminal determines that a second preset condition is satisfied between the available storage space of the memory and a second preset threshold.
It should be noted that, the terminal determines that the difference between the time for marking the second state and the current time is greater than a second preset time difference, and the duration of the time period during which the available storage space of the terminal is smaller than the second preset threshold is greater than the duration of the second preset time period. Further, the terminal determines that a relationship between the available storage space of the terminal and a second preset threshold satisfies a second preset condition.
It should be understood that the memory state of the available storage space is the second state, and the difference between the time of marking the second state and the current time is greater than the second preset time difference, and the terminal determines that the available storage space is smaller than the second preset threshold and lasts for the second preset time period. And then, the terminal determines that the available storage space of the memory and a second preset threshold value meet a second preset condition.
In case that the terminal determines that the difference between the time marking the second state and the current time is less than or equal to a second preset time difference, the terminal performs step 101.
It should be noted that, the terminal determines that the difference between the time for marking the second state and the current time is less than or equal to a second preset time period, which indicates that the duration of the time period during which the available storage space of the terminal is less than the second preset threshold is less than the duration of the second preset time period. Further, the terminal determines that the relation between the available storage space of the terminal and the preset threshold does not satisfy a second preset condition.
Accordingly, with reference to fig. 6, step 103 in the embodiment of the present application may be implemented by:
step 1034, the terminal stores at least one of the cache snapshot and the first snapshot in the flash memory.
In a possible implementation manner, if a memory of the terminal stores a cache snapshot, the terminal obtains the cache snapshot stored in the memory and stores the cache snapshot in the flash memory. And if the terminal generates a first snapshot between the current time and the first time node, the terminal stores the first snapshot into the flash memory.
For example, the terminal determines that the memory of the terminal includes the cache snapshot at the current time: snapshot 8 and snapshot 9. And the terminal stores the snapshot 8 and the snapshot 9 in the flash memory for backup. The terminal generates a first snapshot between the current time and a first time node: snapshot 10 and snapshot 11, the terminal stores snapshot 10 and snapshot 11 in the flash memory for backup.
In another possible implementation manner, the cache snapshot stored in the memory of the terminal is a snapshot compressed by using the first compression ratio. And the terminal acquires the snapshot compressed by the first compression ratio and stores the snapshot in the flash memory.
Step 1035, the terminal processes at least one of the cache snapshot and the first snapshot according to the second compression ratio, and stores at least one of the cache snapshot and the first snapshot processed by the second compression ratio in the memory.
In a possible implementation manner, if the terminal stores the cache snapshot, the terminal compresses the cache snapshot according to the second compression ratio, and stores the compressed cache snapshot in the memory of the terminal. And if the terminal generates the first snapshot between the current time and the first time node, the terminal compresses the first snapshot according to the second compression ratio and stores the compressed first snapshot in the memory of the terminal.
For example, corresponding to step 1034, the terminal determines that the memory of the terminal includes the cache snapshot at the current time: snapshot 8 and snapshot 9. The terminal processes the snapshot 8 with the second compression ratio and processes the snapshot 9 with the second compression ratio. The terminal adopts a second compression ratio to process the snapshot 8 to replace the snapshot 8 in the cache; and replacing the snapshot 9 in the cache by the snapshot 9 processed by the second compression ratio.
The terminal generates a first snapshot between the current time and a first time node: snapshot 10 and snapshot 11, snapshot 10 being processed with a second compression ratio, and snapshot 11 being processed with the second compression ratio, respectively. And the terminal stores the snapshot 10 processed by the second compression ratio and the snapshot 11 processed by the second compression ratio in the memory of the terminal.
Based on the technical scheme, under the condition that the available storage space of the terminal is sufficient, the terminal determines that the snapshot is processed by adopting the first compression ratio, so that the pixels of the snapshot processed by the terminal are higher, and the visual experience of a user is improved. Under the condition that the available storage space of the terminal is insufficient, the terminal determines to adopt the second compression ratio to process the snapshot, so that the storage space occupied by the processed snapshot can be reduced, and the problem that the mobile phone cannot run smoothly due to the fact that the storage space of the RAM occupied by the snapshot is large is avoided.
It is understood that the above terminal includes hardware structures and/or software modules for performing the respective functions in order to realize the above functions. Those of skill in the art will readily appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as hardware or combinations of hardware and computer software. Whether a function is performed as hardware or computer software drives hardware depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the embodiments of the present application.
In the embodiment of the present application, the terminal may be divided into the functional modules according to the method example, for example, each functional module may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. It should be noted that, in the embodiment of the present application, the division of the module is schematic, and is only one logic function division, and there may be another division manner in actual implementation.
In the case of dividing each functional module by corresponding functions, fig. 9 shows a schematic structural diagram of a snapshot processing apparatus according to the foregoing embodiment, where the snapshot processing apparatus includes: a processing unit 301.
An example of the snapshot processing apparatus is a terminal or a chip applied in the terminal, and the processing unit 301 is configured to execute the steps 101, 102, and 103.
In a possible implementation manner, the processing unit 301 is further configured to execute the step 104.
In a possible implementation manner, the processing unit 301 is further configured to execute step 1041 and step 1042.
In a possible implementation manner, the processing unit 301 is further configured to execute the step 1021 and the step 1024.
In a possible implementation manner, the processing unit 301 is further configured to execute the step 1022, the step 1023, the step 1025 and the step 1026.
In a possible implementation, the processing unit 301 is further configured to execute step 1031, step 1032 and step 1033 described above.
In a possible implementation manner, the processing unit 301 is further configured to perform the steps 1034 and 1035.
Optionally, the apparatus for processing the snapshot may further include a storage unit 302, where the storage unit 302 is configured to store the snapshot. All relevant contents of each step related to the above method embodiment may be referred to the functional description of the corresponding functional module, and are not described herein again.
In the case of an integrated unit, fig. 10 shows a schematic diagram of a possible structure of the apparatus for processing snapshots in the above embodiment. The apparatus for processing the snapshot includes: a processing module 412 and a communication module 413. The processing module 412 is used for controlling and managing the actions of the device for processing the snapshot. The communication module 413 is used to support the snapshot processing apparatus to communicate with other network entities. The apparatus for processing a snapshot may further include a storage module 411 for storing program codes and data of the apparatus for processing a snapshot.
In an example, the snapshot processing apparatus is a terminal or a chip applied in the terminal, and the processing module 412 is configured to perform the steps 101, 102, and 103.
In a possible implementation manner, the processing module 412 is further configured to execute the step 104.
In a possible implementation manner, the processing module 412 is further configured to perform the step 1041 and the step 1042.
In a possible implementation manner, the processing module 412 is further configured to perform the step 1021 and the step 1024.
In a possible implementation manner, the processing module 412 is further configured to execute the step 1022, the step 1023, the step 1025 and the step 1026.
In a possible implementation manner, the processing module 412 is further configured to perform the steps 1031, 1032 and 1033.
In one possible implementation, the processing module 412 is further configured to perform the steps 1034 and 1035.
The Processing module 412 may be a Processor or a controller, such as a Central Processing Unit (CPU), a general purpose Processor, a Digital Signal Processor (DSP), an Application-Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor may also be a combination of computing functions, e.g., comprising one or more microprocessors, DSPs, and microprocessors, among others. The storage module 411 may be a memory.
When the processing module 412 is the processor 101 and the storage module 411 is the memory 103, the terminal provided in the embodiment of the present application may be the terminal shown in fig. 1.
Fig. 11 is a schematic structural diagram of a chip 150 according to an embodiment of the present disclosure. Chip 150 includes one or more (including two) processors 1510 and a communication interface 1530.
Optionally, the chip 150 further includes a memory 1540, which may include both read-only memory and random access memory, and provides operating instructions and data to the processor 1510. A portion of memory 1540 may also include non-volatile random access memory (NVRAM).
In some embodiments, memory 1540 stores elements, execution modules, or data structures, or a subset thereof, or an expanded set thereof.
In the embodiment of the present application, by calling an operation instruction stored in the memory 1540 (the operation instruction may be stored in an operating system), a corresponding operation is performed.
One possible implementation is: the chips used for the terminals are similar in structure, and different devices can use different chips to realize respective functions.
The processor 1510 controls processing operations of any one of the terminals, and the processor 1510 may also be referred to as a Central Processing Unit (CPU).
Memory 1540 can include both read-only memory and random-access memory, and provides instructions and data to processor 1510. A portion of memory 1540 may also include non-volatile random access memory (NVRAM). For example, in an application where memory 1540, communications interface 1530 and memory 1540 are coupled together by bus system 1520, where bus system 1520 may include a power bus, control bus, status signal bus, etc. in addition to a data bus. For clarity of illustration, however, the various buses are labeled in FIG. 11 as bus system 1520.
The method disclosed in the embodiments of the present application may be applied to the processor 1510 or implemented by the processor 1510. The processor 1510 may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by instructions in the form of hardware, integrated logic circuits, or software in the processor 1510. The processor 1510 may be a general purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, or discrete hardware components. The various methods, steps, and logic blocks disclosed in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present application may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in the memory 1540, and the processor 1510 reads the information in the memory 1540, and performs the steps of the above method in combination with the hardware thereof.
In a possible implementation manner, the processor 1510 is configured to perform step 101, step 102, step 103, step 104, step 1041, step 1042, step 1021, step 1022, step 1023, step 1024, step 1025, step 1026, step 1031, step 1032, step 1033, step 1034, and step 1035 in the embodiment.
In the above embodiments, the instructions stored by the memory for execution by the processor may be implemented in the form of a computer program product. The computer program product may be written in the memory in advance or may be downloaded in the form of software and installed in the memory.
The computer program product includes one or more computer instructions. The procedures or functions according to the embodiments of the present application are all or partially generated when the computer program instructions are loaded and executed on a computer. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, e.g., the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. A computer-readable storage medium may be any available medium that a computer can store or a data storage device including one or more available media integrated servers, data centers, and the like. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
In further embodiments of the present application, a computer-readable storage medium is provided, in which instructions are stored, which when executed, cause an apparatus for processing a snapshot to perform step 101, step 102, step 103, step 104, step 1041, step 1042, step 1021, step 1022, step 1023, step 1024, step 1025, step 1026, step 1031, step 1032, step 1033, step 1034, and step 1035 in the embodiments.
The aforementioned readable storage medium may include: u disk, removable hard disk, read only memory, random access memory, magnetic or optical disk, etc. for storing program codes.
In one aspect, a computer program product is provided, which includes instructions stored therein, which when executed, cause an apparatus for processing a snapshot to perform step 101, step 102, step 103, step 104, step 1041, step 1042, step 1021, step 1022, step 1023, step 1024, step 1025, step 1026, step 1031, step 1032, step 1033, step 1034, and step 1035 in an embodiment.
In one aspect, a chip is provided, where the chip is applied in a terminal, and the chip includes at least one processor and a communication module, where the communication module is coupled to the at least one processor, and the processor is configured to execute instructions to perform step 101, step 102, step 103, step 104, step 1041, step 1042, step 1021, step 1022, step 1023, step 1024, step 1025, step 1026, step 1031, step 1032, step 1033, step 1034, and step 1035 in the embodiments.
In the above embodiments, all or part of the implementation may be realized by software, hardware, firmware or any combination thereof. When implemented using a software program, may take the form of a computer program product, either entirely or partially. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
Finally, it should be noted that: the above is only an embodiment of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.