Data compression method and device and electronic equipment

By dynamically selecting the application's reference and target compression algorithms from multiple preset compression algorithms in the data compression method, the problem of insufficient flexibility in the existing technology is solved, and the adaptability of application data compression and the operating system's performance are improved. Overall compression efficiency.

CN118801896APending Publication Date: 2024-10-18GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310394062.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-12
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

Existing data compression methods are insufficient in flexibility and cannot dynamically adjust compression algorithms according to the needs of different applications, resulting in low adaptability and flexibility of data compression for different applications.

Method used

A data compression method is proposed. By responding to the compression task trigger of the application, the reference compression algorithm corresponding to the application is determined from multiple preset compression algorithms. When the compression effect reaches the preset standard, it is used as the target compression algorithm. Data compression for applications.

Benefits of technology

It improves the adaptability and flexibility of data compression for different applications, ensures that different applications can have different target compression algorithms that meet preset standards, and optimizes the compression efficiency and user experience of the operating system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118801896A_ABST
    Figure CN118801896A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a data compression method and device and electronic equipment. The method comprises the following steps: in response to triggering of a compression task of an application program, determining a reference compression algorithm corresponding to the application program from a plurality of preset compression algorithms; compressing the data of the application program based on a reference compression algorithm, and obtaining a compression effect corresponding to the application program; and if the compression effect reaches a preset standard, determining the reference compression algorithm as a target compression algorithm. By means of the mode, the reference compression algorithm corresponding to the application program can be determined from the multiple preset compression algorithms in response to triggering of the compression task of the application program, and when the compression effect corresponding to the application program reaches the preset standard, the reference compression algorithm can serve as the target compression algorithm of the application program; therefore, different application programs can have different target compression algorithms conforming to the preset standard, and the adaptability and the flexibility of compressing the data of the different application programs are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a data compression method, device and electronic device. Background Art

[0002] With the rapid development of technologies such as big data, cloud computing, artificial intelligence, and machine learning, the processing of high-concurrency massive data has put forward higher requirements on existing memory. In related methods, the content in the memory can be compressed through a preset compression algorithm so that the operating system can run with less physical memory, thereby improving the response speed and performance of the operating system. However, related compression methods still have the problem of low flexibility. Summary of the invention

[0003] In view of the above problems, the present application proposes a data compression method, device and electronic device to improve the above problems.

[0004] In a first aspect, the present application provides a data compression method, the method comprising: in response to the triggering of a compression task of an application, determining a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms; compressing the data of the application based on the reference compression algorithm, and obtaining a compression effect corresponding to the application, the compression effect being the compression effect of the reference compression algorithm on the data of the application; if the compression effect reaches a preset standard, determining the reference compression algorithm as a target compression algorithm, the target compression algorithm being used to compress the data of the application when the compression task of the application is triggered.

[0005] In a second aspect, the present application provides a data compression device, which includes: a reference compression algorithm acquisition unit, which is used to determine a reference compression algorithm corresponding to the application from multiple preset compression algorithms in response to the triggering of a compression task of the application; a compression effect acquisition unit, which is used to compress the data of the application based on the reference compression algorithm and obtain the compression effect corresponding to the application, wherein the compression effect is the compression effect of the reference compression algorithm on the data of the application; and a target compression algorithm acquisition unit, which is used to determine that the target compression algorithm is the reference compression algorithm if the compression effect reaches a preset standard, and the target compression algorithm is used to compress the data of the application when the compression task of the application is triggered.

[0006] In a third aspect, the present application provides an electronic device comprising one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above-mentioned method.

[0007] In a fourth aspect, the present application provides a computer-readable storage medium, in which program code is stored, wherein the above method is executed when the program code is run.

[0008] The present application provides a data compression method, device, electronic device, and storage medium. After responding to the triggering of a compression task of an application, a reference compression algorithm corresponding to the application is determined from a plurality of preset compression algorithms; the data of the application is compressed based on the reference compression algorithm, and the compression effect of the reference compression algorithm on the data of the application is obtained; if the compression effect reaches a preset standard, the reference compression algorithm is determined as the target compression algorithm for compressing the data of the application when the compression task of the application is triggered. Through the above-mentioned manner, in response to the triggering of the compression task of the application, the reference compression algorithm corresponding to the application can be determined from a plurality of preset compression algorithms, and when the compression effect corresponding to the application reaches a preset standard, the reference compression algorithm can be used as the target compression algorithm of the application, so that different applications can have different target compression algorithms that meet the preset standards, thereby improving the adaptability and flexibility of compressing data of different applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0010] Figure 1 A flow chart of a data compression method proposed in an embodiment of the present application is shown;

[0011] Figure 2 A flow chart of a data compression method proposed in another embodiment of the present application is shown;

[0012] Figure 3 A structural block diagram of a data compression device proposed in an embodiment of the present application is shown;

[0013] Figure 4 A structural block diagram of an electronic device proposed in this application is shown;

[0014] Figure 5 It is a storage unit of an embodiment of the present application for storing or carrying a program code for implementing a data compression method according to an embodiment of the present application. DETAILED DESCRIPTION

[0015] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0016] With the continuous advancement of science and technology and the advent of the big data era, data compression has become a hot topic in research. In related methods, the content in the memory can be compressed through a preset compression algorithm so that the operating system can run with less physical memory, thereby improving the response speed and performance of the operating system.

[0017] The inventors found in the relevant research that the relevant compression methods still have the problem of low flexibility. For example, ZRAM can be configured with different compression algorithms to compress data, but once the configuration scheme is determined, it cannot be changed unless it is reconfigured. Among them, ZRAM can refer to a technology of the Linux kernel that achieves memory optimization by providing virtual memory compression. ZRAM can improve performance by paging on compressed block devices in RAM (Random Access Memory) until the swap space on the hard disk must be used to avoid paging on the disk.

[0018] Therefore, the inventors have proposed a data compression method, device, and electronic device in the present application, which, in response to the triggering of a compression task of an application, determine a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms; compress the data of the application based on the reference compression algorithm, and obtain the compression effect of the reference compression algorithm on the data of the application; if the compression effect reaches a preset standard, determine the reference compression algorithm as the target compression algorithm for compressing the data of the application when the compression task of the application is triggered. Through the above-mentioned manner, in response to the triggering of the compression task of the application, the reference compression algorithm corresponding to the application can be determined from a plurality of preset compression algorithms, and when the compression effect corresponding to the application reaches a preset standard, the reference compression algorithm can be used as the target compression algorithm of the application, so that different applications can have different target compression algorithms that meet the preset standards, thereby improving the adaptability and flexibility of compressing data of different applications.

[0019] See also Figure 1 , an embodiment of the present application provides a data compression method, the method comprising:

[0020] S110: In response to triggering of a compression task of an application, determining a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms.

[0021] The preset compression algorithm may refer to an algorithm preset by the electronic device for memory compression, for example, compression algorithms such as ZSTD, LZ4, LZ77, LZ78, DEFLATE, and GZIP. The compression task of the application may be used to compress a page of the application.

[0022] As a method, in response to the triggering of a compression task of an application, the electronic device can randomly select a preset compression algorithm from a plurality of preset compression algorithms, and use the selected preset compression algorithm as a reference compression algorithm corresponding to the application.

[0023] The electronic device may refer to a user terminal device, such as a mobile phone, a computer, etc., or an IoT device. It should be noted that the data compression algorithm provided in the present application may also be applied to a virtual machine, a data center, etc. of a virtualization platform.

[0024] As another way, the electronic device can first perform data type statistics on the data contained in its own application to obtain statistical results, which can be the result of sorting different data types in descending order based on their respective frequencies of occurrence; and determine the correspondence between each data type and multiple preset compression algorithms, which correspondence can represent the data type applicable to each preset compression algorithm; then, based on the statistical results and the correspondence, obtain the sorting results of multiple preset compression algorithms, which can be the result of sorting in descending order based on the estimated usage frequencies of each of the multiple preset compression algorithms. In this way, when the electronic device responds to the triggering of the compression task of the application, it can determine the reference compression algorithm corresponding to the application from multiple preset compression algorithms based on the sorting results of multiple preset compression algorithms.

[0025] Optionally, when the electronic device detects that the compression task of the application is triggered for the first time, the preset compression algorithm ranked first can be determined as the reference compression algorithm corresponding to the application. Exemplarily, the statistical results corresponding to the application of the electronic device itself can be: data type A, data type B, data type C, and the corresponding relationship between the data type and the multiple preset compression algorithms can be: data type A-algorithm X, data type B-algorithm Z, data type C-algorithm Y, and the ranking results of the multiple preset algorithms can be algorithm X, algorithm Z, algorithm Y. When the electronic device detects that the compression task of the application is triggered for the first time, algorithm X can be determined as the reference compression algorithm corresponding to the application.

[0026] Optionally, statistics may be collected on the data of all applications of the electronic device to obtain statistical results corresponding to the electronic device; statistics may also be collected on the data of each application of the electronic device to obtain statistical results corresponding to each application.

[0027] In the embodiment of the present application, there are multiple ways to trigger the compression task of the application.

[0028] As a method, the electronic device can detect the remaining capacity of the memory, and when the remaining capacity cannot meet the needs of the application, the compression task of the application can be triggered. For example, when the electronic device detects that the remaining memory space is 100MB, and the application may need to occupy 150MB of memory space, the compression task of the application can be triggered.

[0029] As another way, the user can also trigger the compression task of the application according to his own needs through interaction with the electronic device (such as voice control, screen sliding, screen tapping, etc.).

[0030] S120: compressing the data of the application based on the reference compression algorithm, and obtaining a compression effect corresponding to the application, where the compression effect is a compression effect of compressing the data of the application using the reference compression algorithm.

[0031] The compression effect may include compression ratio and / or compression speed. The compression ratio may refer to the ratio between the amount of data compressed by the compression algorithm and the original amount of data, or the compression ratio may refer to the ratio between the difference between the amount of data compressed by the compression algorithm and the original amount of data and the original amount of data. The compression speed may refer to the amount of data that can be compressed by the compression algorithm per unit time.

[0032] As a method, the initial data volume of the application data and the compressed data volume after compression can be obtained, and the compression rate can be obtained through the formula: compressed data volume / initial data volume or the formula: (initial data volume-compressed data volume) / initial data volume.

[0033] As a method, the initial data volume and compression duration of the application data can be obtained, and the compression speed can be obtained through the formula: initial data volume / compression duration.

[0034] S130: If the compression effect reaches a preset standard, determine the reference compression algorithm as a target compression algorithm, and the target compression algorithm is used to compress the data of the application when the compression task of the application is triggered.

[0035] The preset standard may include at least one of a preset compression rate and a preset compression speed.

[0036] As a method, after obtaining the compression effect of the application based on step S120, the obtained compression effect can be compared with a preset standard. If the compression effect reaches the preset standard, the reference compression algorithm can be determined as the target compression algorithm.

[0037] Optionally, after the target compression algorithm is determined, the electronic device can bind the application to the target compression algorithm and store the binding relationship in a specified location. Exemplarily, the binding relationship can be as shown in Table 1. When the value corresponding to "whether there is a corresponding target compression algorithm" is 1, it can indicate that there is a corresponding target compression algorithm; when the value corresponding to "whether there is a corresponding target compression algorithm" is 0, it can indicate that there is no corresponding target compression algorithm.

[0038] Table 1

[0039]

[0040]

[0041] Optionally, after the target compression algorithm is determined, in response to triggering of a compression task of the application, the data of the application is compressed directly based on the target compression algorithm.

[0042] In the embodiment of the present application, there are multiple ways to determine whether the compression effect corresponding to the application reaches a preset standard.

[0043] Among them, as a method, when the preset standard is a preset compression rate, the corresponding compression effect can be the compression rate. If the compression rate of the application is greater than or equal to the preset compression rate, it can be determined that the compression effect corresponding to the application meets the preset standard; if the compression rate of the application is less than the preset compression rate, it can be determined that the compression effect corresponding to the application does not meet the preset standard.

[0044] As another way, when the preset standard is a preset compression speed, the corresponding compression effect can be the compression speed. If the compression speed of the application is greater than or equal to the preset compression speed, it can be determined that the compression effect corresponding to the application meets the preset standard; if the compression speed of the application is less than the preset compression speed, it can be determined that the compression effect corresponding to the application does not meet the preset standard.

[0045] As another way, when the preset standard is a preset compression rate and a preset compression speed, the corresponding compression effect can be a compression rate and a compression speed. If the compression rate of the application is greater than or equal to the preset compression rate and the compression speed of the application is greater than or equal to the preset compression speed, it is determined that the compression effect corresponding to the application meets the preset standard; if the compression rate of the application is less than the preset compression rate or the compression speed of the application is less than the preset compression speed, it is determined that the compression effect corresponding to the application does not meet the preset standard.

[0046] Optionally, the preset compression rate may be determined based on the storage space of the compression result corresponding to the application program, and the larger the storage space, the smaller the preset compression rate may be.

[0047] The storage space of the compression result corresponding to the application may refer to the memory of the electronic device. Determining the preset compression rate based on the storage space of the compression result corresponding to the application can make it possible to give priority to a compression algorithm with a faster compression speed as the target compression algorithm of the application when the storage space is sufficient, thereby improving the data processing speed and user experience; and when the storage space is insufficient, a compression algorithm with a higher compression rate can be given priority as the target compression algorithm of the application, thereby saving storage space and avoiding, to a certain extent, electronic device operation errors caused by insufficient storage space.

[0048] Optionally, the preset compression speed may be determined based on the data generation speed corresponding to the application program. The faster the data generation speed, the greater the preset compression speed.

[0049] Among them, determining the preset compression speed based on the data generation speed corresponding to the application can ensure that when the data generation speed is faster, the compression algorithm with a faster compression speed can be prioritized as the target compression algorithm of the application, thereby improving the data processing speed and avoiding data congestion; when the data generation speed is slower, the compression algorithm with a higher compression ratio can be prioritized as the target compression algorithm of the application, thereby saving storage space and avoiding electronic device operation errors caused by insufficient storage space to a certain extent.

[0050] In the embodiment of the present application, by compressing the data of the application, the startup time of the application can be reduced and the user experience can be improved. In addition, by configuring different target compression algorithms for different applications, the overall compression efficiency of the operating system can be effectively improved, and the time and cost of the operating system storing and processing compressed data can be reduced.

[0051] The present embodiment provides a data compression method, which determines a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms in response to the triggering of a compression task of an application; compresses the data of the application based on the reference compression algorithm, and obtains a compression effect of the reference compression algorithm on the data of the application; if the compression effect reaches a preset standard, determines the reference compression algorithm as a target compression algorithm for compressing the data of the application when the compression task of the application is triggered. Through the above manner, in response to the triggering of the compression task of the application, the reference compression algorithm corresponding to the application can be determined from a plurality of preset compression algorithms, and when the compression effect corresponding to the application reaches a preset standard, the reference compression algorithm can be used as the target compression algorithm of the application, so that different applications can have different target compression algorithms that meet the preset standards, thereby improving the adaptability and flexibility of compressing data of different applications.

[0052] See also Figure 2 , an embodiment of the present application provides a data compression method, the method comprising:

[0053] S210: In response to triggering of a compression task of an application, determining whether the application corresponds to the target compression algorithm.

[0054] As a method, in response to triggering of a compression task of an application, the electronic device may search for relevant information of the application based on Table 1, and confirm whether the application corresponds to a target compression algorithm based on the searched information.

[0055] S220: If the application does not correspond to the target compression algorithm, determine a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms that have not been selected.

[0056] Among them, the compression algorithm that has never been selected among the multiple preset compression algorithms may refer to a compression algorithm that has never been selected for compressing data for the application from the first triggering of the compression task of the application to the triggering of the current compression task of the application.

[0057] As a method, if the electronic device determines that the application does not correspond to a target compression algorithm, it can randomly select a preset compression algorithm from multiple preset compression algorithms that have not been selected, and use the selected preset compression algorithm as a reference compression algorithm corresponding to the application.

[0058] As another way, if the electronic device determines that the application does not correspond to a target compression algorithm, it can determine a reference compression algorithm corresponding to the application from multiple preset compression algorithms based on the sorting result of the multiple preset compression algorithms obtained in step S110.

[0059] Optionally, the compression algorithm that is ranked highest among the multiple preset compression algorithms and that has not been selected may be used as a reference compression algorithm corresponding to the application.

[0060] Exemplarily, multiple preset compression algorithms may include algorithm A, algorithm B, algorithm C, algorithm D, and algorithm E, and the corresponding sorting results may be: algorithm A, algorithm C, algorithm D, algorithm B, and algorithm E. The compression algorithms that have never been selected from the multiple preset compression algorithms may be algorithm B, algorithm C, algorithm D, and algorithm E. At this time, algorithm C may be used as the reference compression algorithm corresponding to the application.

[0061] Optionally, each time a compression task of an application is triggered, statistics may be collected for the corresponding application in the manner shown in Table 2, thereby determining a compression algorithm that has never been selected from among the current plurality of preset compression algorithms.

[0062] Table 2

[0063]

[0064] Optionally, each time a compression task of an application is triggered, statistics may be collected for the corresponding application in the manner shown in Table 3, thereby determining a compression algorithm that has never been selected from among the current plurality of preset compression algorithms.

[0065] Table 3

[0066]

[0067] As a method, if the electronic device determines that the application corresponds to a target compression algorithm, the current compression task of the application can be directly executed based on the target compression algorithm.

[0068] S230: compressing the data of the application based on the reference compression algorithm, and obtaining a compression effect corresponding to the application, where the compression effect is a compression effect of compressing the data of the application using the reference compression algorithm.

[0069] S240: If the compression effect reaches a preset standard, determine the reference compression algorithm as a target compression algorithm, and the target compression algorithm is used to compress the data of the application when the compression task of the application is triggered.

[0070] S250: If the compression effect does not meet the preset standard, the corresponding target compression algorithm is not configured for the application.

[0071] As a method, if the current compression effect does not meet the preset standard, the corresponding target compression algorithm may not be configured for the application.

[0072] Exemplarily, the preset compression algorithm may include algorithm A, algorithm B, algorithm C, and algorithm D. When the compression task of application 1 is triggered for the first time, algorithm A may be used as a reference compression algorithm to compress the first data and obtain the corresponding compression effect; when the compression effect of the first compression does not meet the preset standard, the corresponding target compression algorithm may not be configured for application 1, and the triggering of the second compression task may continue. When the compression task of application 1 is triggered for the first time, an algorithm (such as algorithm B) may be selected from the preset algorithms that have never been selected: algorithm B, algorithm C, and algorithm D as the reference compression algorithm for the second compression task, and the corresponding compression effect may be obtained; when the compression effect of the second compression does not meet the preset standard, the corresponding target compression algorithm may not be configured for application 1, and the triggering of the third compression task may continue. When the compression task of application 1 is triggered for the third time, an algorithm (such as algorithm C) may be selected from the preset algorithms that have never been selected: algorithm C and algorithm D as the reference compression algorithm for the third compression task, and the corresponding compression effect may be obtained; when the compression effect of the third compression meets the preset standard, algorithm C may be configured as the target compression algorithm corresponding to application 1.

[0073] As a method, if the compression effects of multiple preset compression algorithms on the application program do not reach the preset standard, the preset compression algorithm whose compression effect corresponding to the application program is closest to the preset standard is used as the target compression algorithm.

[0074] In the embodiment of the present application, there are multiple ways to determine the target compression algorithm.

[0075] As a method, when the preset standard is a preset compression rate, the corresponding compression effect can be a compression rate, and the preset compression algorithm whose compression rate is closest to the preset compression rate can be used as the target compression algorithm, that is, the preset compression algorithm whose difference between the preset compression rate and the compression rate is the smallest can be used as the target compression algorithm. For example, the preset compression rate can be 50%, the compression rate of algorithm A can be 30%, and the compression rate of algorithm B can be 40%, then algorithm B can be selected as the target compression algorithm.

[0076] As another way, when the preset standard is a preset compression speed, the corresponding compression effect can be the compression speed, and the preset compression algorithm whose compression speed is closest to the preset compression speed can be used as the target compression algorithm, that is, the preset compression algorithm whose difference between the preset compression speed and the compression speed is the smallest can be used as the target compression algorithm.

[0077] As another way, when the preset standard is a preset compression rate and a preset compression speed, the corresponding compression effect can be a compression rate and a compression speed, and the preset compression algorithm closest to the preset standard can be determined based on the first difference and the second difference, wherein the first difference can refer to the difference between the preset compression rate and the compression rate, and the second difference can refer to the difference between the preset compression speed and the compression speed.

[0078] Optionally, it can be determined whether there is a preset compression algorithm among multiple preset compression algorithms with the smallest first difference and the smallest second difference. If so, the corresponding preset compression algorithm can be used as the target compression algorithm; if not, the preset compression algorithm with the smallest first difference or the preset compression algorithm with the smallest second difference can be used as the target compression algorithm.

[0079] S260: Detect the version of the application program.

[0080] As a way, the application version can be tested periodically.

[0081] As another way, when it is detected that a new version of the application exists, the version of the application may be continuously detected for a preset time to determine whether the application has been updated.

[0082] S270: If it is detected that the application has been updated, in response to triggering a compression task for the updated application, a target compression algorithm corresponding to the updated application is re-determined from the plurality of preset compression algorithms.

[0083] As a method, if it is detected that an application has been updated, the electronic device can respond to the triggering of the compression task of the updated application and re-determine the target compression algorithm corresponding to the updated application from multiple preset compression algorithms based on steps S110-S130.

[0084] The data compression method provided in this embodiment can determine the reference compression algorithm corresponding to the application from multiple preset compression algorithms in response to the triggering of the compression task of the application through the above-mentioned method, and when the compression effect corresponding to the application reaches the preset standard, the reference compression algorithm can be used as the target compression algorithm of the application, so that different applications can have different target compression algorithms that meet the preset standards, thereby improving the adaptability and flexibility of compressing data of different applications. In addition, in this embodiment, after the application version is updated, the target program of the updated application is re-determined, and the corresponding target program can be adjusted in real time based on the application, thereby improving the adaptability and reliability of compression.

[0085] See also Figure 3The present application provides a data compression device 600, the device 600 comprising:

[0086] A reference compression algorithm acquisition unit 610 is used to determine a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms in response to the triggering of a compression task of the application;

[0087] A compression effect acquisition unit 620, configured to compress the data of the application based on the reference compression algorithm and acquire a compression effect corresponding to the application, wherein the compression effect is a compression effect of the reference compression algorithm on the data of the application;

[0088] The target compression algorithm acquisition unit 630 is used to determine the target compression algorithm as the reference compression algorithm if the compression effect reaches a preset standard. The target compression algorithm is used to compress the data of the application when the compression task of the application is triggered.

[0089] As a method, the reference compression algorithm acquisition unit 610 is specifically used to respond to the triggering of the compression task of the application, determine whether the application corresponds to the target compression algorithm; if the application does not correspond to the target compression algorithm, determine the reference compression algorithm corresponding to the application from the compression algorithms that have not been selected in multiple preset compression algorithms. The target compression algorithm acquisition unit 630 is specifically used to not configure the corresponding target compression algorithm for the application if the compression effect does not meet the preset standard.

[0090] Optionally, the target compression algorithm acquisition unit 630 is specifically used to use the preset compression algorithm whose compression effect is closest to the preset standard as the target compression algorithm if the compression effects of the multiple preset compression algorithms on the application do not meet the preset standard.

[0091] As a method, the compression effect includes a compression rate or a compression speed, the preset standard includes a preset compression rate or a preset compression speed, and the compression effect acquisition unit 620 is specifically used to determine that the compression effect reaches the preset standard if the compression rate is greater than or equal to the preset compression rate; or if the compression speed is greater than or equal to the preset compression speed, determine that the compression effect reaches the preset standard.

[0092] As another way, the compression effect includes compression rate and compression speed, the preset standard includes a preset compression rate and a preset compression speed, and the compression effect acquisition unit 620 is specifically used to determine that the compression effect meets the preset standard if the compression rate is greater than or equal to the preset compression rate and the compression speed is greater than or equal to the preset compression speed.

[0093] Optionally, the preset compression rate is determined based on the storage space of the compression result corresponding to the application, and the larger the storage space, the smaller the preset compression rate; the preset compression speed is determined based on the data generation speed corresponding to the application, and the faster the data generation speed, the larger the preset compression speed.

[0094] As a method, the target compression algorithm acquisition unit 630 is specifically used to detect the version of the application; if it is detected that the application has been updated, in response to the triggering of the compression task of the application after the version update, the target compression algorithm corresponding to the application after the version update is re-determined from the multiple preset compression algorithms.

[0095] The following will be combined Figure 4 An electronic device provided by the present application is described.

[0096] See also Figure 4 Based on the above data compression method and device, the embodiment of the present application also provides another electronic device 100 that can execute the above data compression method. The electronic device 100 includes a processor 102 and a memory 104, wherein the memory 104 stores a program that can execute the content of the above embodiment, and the processor 102 can execute the program stored in the memory 104.

[0097] Among them, the processor 102 may include one or more processing cores. The processor 102 uses various interfaces and lines to connect various parts within the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 104, and calling data stored in the memory 104. Optionally, the processor 102 can be implemented in at least one hardware form of a network processor (Neural network Processing Unit, NPU), a digital signal processing (Digital Signal Processing, DSP), a field programmable gate array (Field-Programmable Gate Array, FPGA), and a programmable logic array (Programmable Logic Array, PLA). The processor 102 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU), a network processor (Neural network Processing Unit, NPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing display content; the NPU is responsible for processing multimedia data such as video and images; and the modem is used to process wireless communications. It is understandable that the above-mentioned modem may not be integrated into the processor 102, but may be implemented separately through a communication chip.

[0098] The memory 104 may include a random access memory (RAM), and may also include a read-only memory (RAM) and a double data rate synchronous dynamic random access memory (DDR). The memory 104 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 104 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the terminal 100 during use.

[0099] Please refer to Figure 5, which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable storage medium 800 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0100] The computer readable storage medium 800 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer readable storage medium 800 has storage space for program code 810 that performs any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 810 can be compressed, for example, in an appropriate form.

[0101] In summary, the present application provides a data compression method, device, and electronic device, which, in response to the triggering of a compression task of an application, determines a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms; compresses the data of the application based on the reference compression algorithm, and obtains a compression effect of the reference compression algorithm on the data of the application; if the compression effect reaches a preset standard, determines the reference compression algorithm as a target compression algorithm for compressing the data of the application when the compression task of the application is triggered. Through the above manner, in response to the triggering of the compression task of the application, the reference compression algorithm corresponding to the application can be determined from a plurality of preset compression algorithms, and when the compression effect corresponding to the application reaches a preset standard, the reference compression algorithm can be used as the target compression algorithm of the application, so that different applications can have different target compression algorithms that meet the preset standards, thereby improving the adaptability and flexibility of compressing data of different applications.

[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A data compression method, characterized in that: The method comprises: In response to triggering of a compression task of an application, determining a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms; Compressing the data of the application based on the reference compression algorithm, and obtaining a compression effect corresponding to the application, the compression effect being a compression effect of compressing the data of the application by the reference compression algorithm; If the compression effect reaches a preset standard, the reference compression algorithm is determined to be a target compression algorithm, and the target compression algorithm is used to compress the data of the application when the compression task of the application is triggered.

2. The method according to claim 1, characterized in that The step of determining a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms in response to triggering of the compression task of the application comprises: In response to triggering of a compression task of an application, determining whether the application corresponds to the target compression algorithm; If the application does not correspond to the target compression algorithm, determining a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms that have not been selected; The method further comprises: If the compression effect does not meet the preset standard, the corresponding target compression algorithm is not configured for the application.

3. The method according to claim 2, characterized in that The method further comprises: If the compression effects of the multiple preset compression algorithms on the application program do not meet the preset standard, the preset compression algorithm whose compression effect is closest to the preset standard is used as the target compression algorithm.

4. The method according to claim 1, characterized in that: The compression effect includes a compression rate or a compression speed, the preset standard includes a preset compression rate or a preset compression speed, and if the compression effect reaches the preset standard, before determining the target compression algorithm as the reference compression algorithm, the method further includes: If the compression rate is greater than or equal to the preset compression rate, it is determined that the compression effect reaches the preset standard; or If the compression speed is greater than or equal to the preset compression speed, it is determined that the compression effect reaches the preset standard.

5. The method according to claim 1, characterized in that The compression effect includes a compression rate and a compression speed, the preset standard includes a preset compression rate and a preset compression speed, and if the compression effect reaches the preset standard, before determining the target compression algorithm as the reference compression algorithm, the method further includes: If the compression rate is greater than or equal to the preset compression rate and the compression speed is greater than or equal to the preset compression speed, it is determined that the compression effect reaches the preset standard.

6. The method according to claim 5, characterized in that The preset compression rate is determined based on the storage space of the compression result corresponding to the application. The larger the storage space, the smaller the preset compression rate. The preset compression speed is determined based on the data generation speed corresponding to the application. The faster the data generation speed, the greater the preset compression speed.

7. The method according to claim 1, characterized in that If the compression effect reaches the preset standard, after determining the reference compression algorithm as the target compression algorithm, the method further includes: Detecting the version of the application; If it is detected that the application has been updated, in response to triggering of a compression task for the updated application, a target compression algorithm corresponding to the updated application is re-determined from the plurality of preset compression algorithms.

8. A data compression device, characterized in that: The device comprises: A reference compression algorithm acquisition unit, configured to determine a reference compression algorithm corresponding to the application from a plurality of preset compression algorithms in response to a triggering of a compression task of the application; A compression effect acquisition unit, used to compress the data of the application based on the reference compression algorithm, and acquire a compression effect corresponding to the application, wherein the compression effect is a compression effect of the reference compression algorithm on the data of the application; The target compression algorithm acquisition unit is used to determine the target compression algorithm as the reference compression algorithm if the compression effect reaches a preset standard. The target compression algorithm is used to compress the data of the application when the compression task of the application is triggered.

9. An electronic device, characterized in that: including one or more processors and memory; One or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, wherein when the program code is run, the method according to any one of claims 1 to 7 is executed.

Citation Information

Cited By

  • Compression processing method, electronic equipment and computer readable storage medium

    CN119576882A