CN113836101A - Compression method and device and electronic equipment - Google Patents

Compression method and device and electronic equipment Download PDF

Info

Publication number
CN113836101A
CN113836101A CN202111135807.2A CN202111135807A CN113836101A CN 113836101 A CN113836101 A CN 113836101A CN 202111135807 A CN202111135807 A CN 202111135807A CN 113836101 A CN113836101 A CN 113836101A
Authority
CN
China
Prior art keywords
file
compression
size
compressed
decompression
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111135807.2A
Other languages
Chinese (zh)
Inventor
赵闯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Vivo Mobile Communication Co Ltd
Original Assignee
Vivo Mobile Communication Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Vivo Mobile Communication Co Ltd filed Critical Vivo Mobile Communication Co Ltd
Priority to CN202111135807.2A priority Critical patent/CN113836101A/en
Publication of CN113836101A publication Critical patent/CN113836101A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/174Redundancy elimination performed by the file system
    • G06F16/1744Redundancy elimination performed by the file system using compression, e.g. sparse files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems

Abstract

The application discloses a compression method, a compression device and electronic equipment, and belongs to the technical field of data processing. The method comprises the following steps: compressing the first file with the size exceeding the threshold value according to a first compression mode to obtain a first compressed file; and compressing the second file with the size not exceeding the threshold value and the first compressed file according to a second compression mode to obtain the target compressed packet.

Description

Compression method and device and electronic equipment
Technical Field
The application belongs to the technical field of data processing, and particularly relates to a compression method, a compression device and electronic equipment.
Background
Most current applications are increasingly complex in functionality, resulting in larger and larger installation packages. The increase of the installation package can cause the desire of a user to download the installation package to be reduced, the network transmission flow is increased, and the download failure rate is increased.
The production of installation packages (e.g., APKs, etc.) relies on file compression techniques. When the compression package is large, the installation package is necessarily large.
In the future, the Android system only uses 64-bit application, the size of a compressed packet is further increased by 30-50%, and the problem caused by the large compressed packet is more serious.
Disclosure of Invention
An object of the embodiments of the present application is to provide a compression method, an apparatus, and an electronic device, which can solve the problem of a large compression packet.
In a first aspect, an embodiment of the present application provides a compression method, where the method includes:
compressing the first file with the size exceeding the threshold value according to a first compression mode to obtain a first compressed file;
and compressing the second file with the size not exceeding the threshold value and the first compressed file according to a second compression mode to obtain a target compressed packet.
In a second aspect, an embodiment of the present application provides a decompression method, including:
decompressing the target compression packet according to a second decompression mode to obtain a second file and a first compression file, wherein the size of the second file does not exceed the threshold value before compression;
and decompressing the first compressed file according to a first decompression mode to obtain a first file with the size exceeding a threshold value before compression.
In a third aspect, an embodiment of the present application provides a compression apparatus, including:
the first compression module is used for compressing the first file with the size exceeding the threshold value according to a first compression mode to obtain a first compressed file;
and the second compression module is used for compressing the second file with the size not exceeding the threshold value and the first compressed file according to a second compression mode to obtain a target compressed packet.
In a fourth aspect, an embodiment of the present application provides a decompression apparatus, including:
the second decompression module is used for decompressing the target compression packet according to a second decompression mode to obtain a second file of which the size does not exceed the threshold value before compression and the first compression file;
and the first decompression module is used for decompressing the first compressed file according to a first decompression mode to obtain the first file of which the size before compression exceeds a threshold value.
In a fifth aspect, the present application provides an electronic device, which includes a processor, a memory, and a program or instructions stored on the memory and executable on the processor, and when executed by the processor, the program or instructions implement the steps of the method according to the first aspect or the second aspect.
In a sixth aspect, embodiments of the present application provide a readable storage medium, on which a program or instructions are stored, which when executed by a processor implement the steps of the method according to the first or second aspect.
In a seventh aspect, an embodiment of the present application provides a chip, where the chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and the processor is configured to execute a program or instructions to implement the method according to the first aspect or the second aspect.
According to the compression method, the compression device and the electronic equipment, the size of the file is reduced by compressing the larger file in the first compression mode, and the smaller file and the first compressed file are compressed in the second compression mode to obtain the compressed package.
Drawings
FIG. 1 is a schematic flow chart of a compression method provided by an embodiment of the present application;
fig. 2 is a schematic flowchart of a decompression method provided in an embodiment of the present application;
FIG. 3 is a schematic structural diagram of a compression device provided in an embodiment of the present application;
fig. 4 is a schematic structural diagram of a decompression device provided in an embodiment of the present application;
FIG. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
fig. 6 is a schematic hardware structure diagram of an electronic device implementing an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described clearly below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some, but not all, embodiments of the present application. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of the present disclosure.
The terms first, second and the like in the description and in the claims of the present application are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the application may be practiced in sequences other than those illustrated or described herein, and that the terms "first," "second," and the like are generally used herein in a generic sense and do not limit the number of terms, e.g., the first term can be one or more than one. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/" generally means that a preceding and succeeding related objects are in an "or" relationship.
The compression method, the compression device, and the electronic device provided by the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and application scenarios thereof.
Fig. 1 is a schematic flow chart of a compression method provided in an embodiment of the present application. Referring to fig. 1, an embodiment of the present application provides a compression method, which may include:
step 110, compressing the first file with the size exceeding the threshold value according to a first compression mode to obtain a first compressed file;
and step 120, compressing the second file and the first compressed file of which the sizes do not exceed the threshold value according to a second compression mode to obtain a target compressed packet.
It should be noted that the execution subject of the compression method provided in the embodiments of the present application may be an electronic device, a component in an electronic device, an integrated circuit, or a chip. The electronic device may be a mobile electronic device or a non-mobile electronic device. By way of example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palm top computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a Personal Digital Assistant (PDA), and the like, and the non-mobile electronic device may be a server, a Network Attached Storage (NAS), a Personal Computer (PC), a Television (TV), a teller machine or a self-service machine, and the like, and the embodiments of the present application are not particularly limited.
It may first be determined whether there is a first file of the files to be compressed whose size exceeds a threshold. The threshold may be, for example, 10M, 20M, and the like, and the specific size of the threshold may be adjusted according to an actual situation, which is not specifically limited in this embodiment of the application.
The sizes of the files to be compressed can be judged one by one to determine whether the sizes of the files to be compressed exceed the threshold value. For example, assuming that the threshold is 10M and the size of the file a to be compressed is 11M, it may be determined that the file a to be compressed is the first file. At this time, the file a to be compressed may be represented by a key value pair (key ═ O)1,value=S1) Is placed into the first set of files. If the size of the file B to be compressed is 7M, it may be determined that the file B to be compressed is the second file. At this time, the file B to be compressed may be represented by a key value pair (key ═ U)1,value=V1) Into a second set of files.
Wherein, key in the key value pair is the file number, and value is the file size.
After the sizes of the files to be compressed are judged one by one, a first file set F { (key ═ O) can be obtained1,value=S1),(key=O2,value=S2),……,(key=On,value=Sn) N is the number of the first files; and a second set of files S { (key ═ U { (key { (U {)1,value=V1),(key=U2,value=V2),……,(key=Um,value=Vm) Where m is the number of second files.
After the first file set F and the second file set S are determined, in step 110, each first file in the first file set F may be compressed according to a first compression method to obtain each first compressed file.
The first compression method may be a compression method of 7z (7-zip) format. The compression mode of the 7z format has the advantage of high compression efficiency. For example, for a file to be compressed with a size of 179M, after compression in the zip format, the size of a zip compressed packet is 96M; and after compression in the 7z format, the size of the 7z compressed packet is only 64.2M. Therefore, the compression efficiency of the 7z format can be improved by more than 30% compared with the compression of the zip format.
In step 120, each second file in the second file set S and each first compressed file obtained in step 110 may be compressed according to a second compression method, so as to obtain a target compressed package.
The target compression package may be used to make an APK installation package, and the second compression method may be a zip format compression method.
It should be noted that the android system generates the APK installation package by default in a zip format compression manner. Therefore, after the second file and the 7z compression package (the first compression file) are compressed by adopting a zip format compression mode, the APK installation package can still be normally generated, and the function of the APK installation package cannot be influenced.
According to the compression method provided by the embodiment of the application, the size of the file is reduced by compressing the larger file in the first compression mode, and the smaller file and the first compressed file are compressed in the second compression mode to obtain the compressed packet.
In one embodiment, compressing the first file with the size exceeding the threshold according to the first compression mode may include:
splitting the first file into a plurality of subfiles according to the size of the first file and a threshold value;
and compressing each subfile according to the first compression mode.
For the first file O[i]In other words, it can be based on S[i]To a threshold value T, to reduce O[i]Splitting into multiple subfiles O[i][1]=S[i][1]、O[i][2]=S[i][2]、……O[i][j]=S[i][j]Then respectively aligning O according to the first compression mode[i][1]、O[i][2]、……O[i][j]Is compressed to obtain O'[i][1]=S’[i][1]、O’[i][2]=S’[i][2]、……O’[i][j]=S’[i][j]
Wherein i is 1,2, … …, n; j is represented by S[i]Determining with T; o is[i][j]Is O[i]The subfile of (a); o's'[i][j]For O after the first compression[i][j]
According to the compression method provided by the embodiment of the application, the first file is divided into the plurality of subfiles, and then the subfiles are compressed according to the first compression mode, so that the size of the file to be compressed can be further reduced, and the compression efficiency of the compression package is further improved.
In one embodiment, splitting the first file into a plurality of subfiles according to the size of the first file and a threshold value may include:
rounding the quotient of the size of the first file and the threshold upwards to obtain a target number;
the first file is split into a target number of sub-files.
It will be understood that let S be[i]R, when R is an integer, the target number j is R; when R is a decimal, j is the rounding-up of R.
For example, when S[i]In the case of 30M and T being 10M, R is 30/10 ═ 3 and j is 3, so O may be substituted[i]Splitting into multiple subfiles O[i][1]=S[i][1]、O[i][2]=S[i][2]、O[i][3]=S[i][3]Then, according to the first compression mode, respectively aligning O[i][1]、O[i][2]、O[i][3]Is compressed to obtain O'[i][1]=S’[i][1]、O’[i][2]=S’[i][2]、O’[i][3]=S’[i][3]
When S is[i]For 32M, when T is 10M, R is 32/10 ═ 3.2, j is 4, so O may be substituted[i]Splitting into multiple subfiles O[i][1]=S[i][1]、O[i][2]=S[i][2]、O[i][3]=S[i][3]、O[i][4]=S[i][4]Then, according to the first compression mode, respectively aligning O[i][1]、O[i][2]、O[i][3]、O[i][4]Is compressed to obtain O'[i][1]=S’[i][1]、O’[i][2]=S’[i][2]、O’[i][3]=S’[i][3]、O’[i][4]=S’[i][4]
According to the compression method provided by the embodiment of the application, the quotient of the size of the first file and the threshold value is rounded upwards to determine how many sub-files the first file is split into for first compression, so that the specific implementation mode of the first compression can be accurately and quickly determined, and the efficiency of obtaining the compression packet is improved.
In one embodiment, splitting the first file into a target number of sub-files includes any one of:
splitting the first file into j subfiles with equal size;
splitting the first file into j sub-files, wherein the size of at least j-1 sub-files is equal to a threshold value.
According to the size S of the first file[i]After determining the target number j with the threshold T, the first file O can be processed in any way[i]Split into j sub-files O[i][1]、O[i][2]、……O[i][j]
Mode 1: the first file O[i]Splitting into j subfiles O with equal size[i][1]、O[i][2]、……O[i][j]
For example, when S[i]When 32M, j is 4, O may be substituted[i]Splitting to O[i][1]、O[i][2]、O[i][3]And O[i][4]And S is[i][1]=S[i][2]=S[i][3]=S[i][4]=8M。
Mode 2: the first file O[i]Split into j sub-files O[i][1]、O[i][2]、……O[i][j]And wherein the size of at least j-1 of the sub-files is equal to the threshold.
For example, when S[i]When j is 4, 32M, mayTo add O to[i]Splitting to O[i][1]、O[i][2]、O[i][3]And O[i][4]And S is[i][1]=S[i][2]=S[i][3]=30M,S[i][4]=2M。
When S is[i]When j is 4, O may be substituted by 40M[i]Splitting to O[i][1]、O[i][2]、O[i][3]And O[i][4]And S is[i][1]=S[i][2]=S[i][3]=S[i][4]=10M。
According to the compression method provided by the embodiment of the application, the first file is split into the number of the sub-files for first compression in multiple modes, so that compression requirements under various scenes can be met, and the compression efficiency of the compression package is guaranteed.
In one example of practical application, the APK size after packing is 105M directly using zip compression.
After the same file is packaged by the compression method provided by the embodiment of the application, the obtained APK size is only 71M.
The threshold value is set to be 5M, that is, the files exceeding 5M are split, and the split files are compressed in the 7z format, so that one 50M-sized so file is split into 105M files and compressed in the 7z format, and finally the 50M-sized so file is compressed to about 16M, which is reduced by 34M.
Therefore, the compression method provided by the embodiment of the application can obviously reduce the size of the compression packet, and effectively avoids various problems caused by a larger compression packet in the prior art.
Fig. 2 is a schematic flow chart of a decompression method according to an embodiment of the present application. Referring to fig. 2, on the basis of the above embodiment of the compression method, an embodiment of the present application further provides a decompression method, which may include:
step 210, decompressing the target compressed packet according to a second decompression mode to obtain a second file with the size not exceeding a threshold value before compression and a first compressed file;
and step 220, decompressing the first compressed file according to the first decompressing mode to obtain the first file with the size exceeding the threshold value before compression.
It should be noted that the execution subject of the decompression method provided by the embodiment of the present application may be an electronic device, a component in an electronic device, an integrated circuit, or a chip. The electronic device may be a mobile electronic device or a non-mobile electronic device. By way of example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palm top computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a Personal Digital Assistant (PDA), and the like, and the non-mobile electronic device may be a server, a Network Attached Storage (NAS), a Personal Computer (PC), a Television (TV), a teller machine or a self-service machine, and the like, and the embodiments of the present application are not particularly limited.
When the target compressed packet compressed by the compression method is to be decompressed, the target compressed packet may be first decompressed by using the second decompression method to obtain the first compressed file and the second file whose size does not exceed the threshold before compression.
Wherein, the second decompression mode may be a zip decompression mode.
After the second file and the first compressed file are determined in step 210, the first compressed file may be decompressed according to a first decompression method in step 220 to obtain a first file O whose size before compression exceeds a threshold[i]
The first decompression mode may be a 7z format decompression mode.
According to the decompression method provided by the embodiment of the application, the second file and the first compressed file, the size of which does not exceed the threshold value before being compressed, are obtained according to the second decompression mode, and the first compressed file is decompressed according to the first decompression mode to obtain the first file, the size of which exceeds the threshold value before being compressed, so that the target compressed packet, the size of which is obviously smaller than that of the existing compressed packet, can be smoothly decompressed, and various problems caused by the larger compressed packet in the prior art are effectively avoided.
In an embodiment, decompressing the first compressed file according to the first decompressing method to obtain the first file with the size before compression exceeding the threshold may include:
decompressing the first compressed file according to the first decompression mode to obtain each subfile of the first file;
and splicing the subfiles into a first file.
The first compressed file (7z compressed packet) can be decompressed by a 7z format decompression method to obtain each compressed sub-file O'[i][1]=S’[i][1]、O’[i][2]=S’[i][2]、……、O’[i][j]=S’[i][j]Then K decompression threads are enabled to respectively carry out pair O'[i][1]=S’[i][1]、O’[i][2]=S’[i][2]、……、O’[i][j]=S’[i][j]-decompressing to obtain the respective subfile O[i][1]=S[i][1]、O[i][2]=S[i][2]、……、O[i][j]=S[i][j]
Where K is the number of the compressed subfiles.
Then, a target empty file can be created, and the K decompression threads can simultaneously create each subfile O in the target empty file[i][1]=S[i][1]、O[i][2]=S[i][2]、……、O[i][j]=S[i][j]The pre-compression sequence is pressed for copying and splicing to form a first file O[i]=S[i]
Wherein the size of the target empty file is not less than that of each first file O[i]The sum of the magnitudes of (a) and (b).
According to the decompression method provided by the embodiment of the application, each subfile of the first file is obtained by decompressing the first compressed file according to the first decompression mode, and then the subfiles are spliced into the first file, so that the first file before compression can be completely restored, and the function of the target compressed packet is not influenced.
It should be noted that, in the compression method provided in the embodiment of the present application, the execution main body may be a compression device, or a control module in the compression device for executing the compression method. In the embodiment of the present application, a compression apparatus executing a compression method is taken as an example to describe the compression apparatus provided in the embodiment of the present application.
Fig. 3 is a schematic structural diagram of a compression device provided in an embodiment of the present application. Referring to fig. 3, a compression apparatus provided in an embodiment of the present application may include:
the first compression module 310 is configured to compress a first file with a size exceeding a threshold according to a first compression method to obtain a first compressed file;
the second compression module 320 is configured to compress the second file with the size not exceeding the threshold and the first compressed file according to a second compression method, so as to obtain a target compressed packet.
The compression device that this application embodiment provided compresses the file size through first compression mode to great file, and rethread second compression mode compresses less file and first compression file and obtains the compression package, compares in prior art directly to the file compress the technical scheme who generates the compression package, can show the size that reduces the compression package to improve user experience.
In one embodiment, the first compression module 310 is specifically configured to:
splitting the first file into a plurality of subfiles according to the size of the first file and the threshold value;
and compressing each subfile according to the first compression mode.
In one embodiment, the first compression module 310 is specifically configured to:
rounding the quotient of the size of the first file and the threshold upwards to obtain a target number;
and splitting the first file into the target number of sub-files.
In one embodiment, the first compression module 310 is specifically configured to perform any one of:
splitting the first file into j subfiles with equal size;
splitting the first file into j sub-files, wherein the size of at least j-1 sub-files is equal to the threshold value;
wherein j is the target number.
In one embodiment, the first compression method is a compression method of a 7z format, and the second compression method is a compression method of a zip format.
The package compression device in the embodiment of the present application may be a device, or may be a component, an integrated circuit, or a chip in a terminal. The device can be mobile electronic equipment or non-mobile electronic equipment. By way of example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palm top computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a Personal Digital Assistant (PDA), and the like, and the non-mobile electronic device may be a server, a Network Attached Storage (NAS), a Personal Computer (PC), a Television (TV), a teller machine or a self-service machine, and the like, and the embodiments of the present application are not particularly limited.
The package compression device in the embodiments of the present application may be a device having an operating system. The operating system may be an Android (Android) operating system, an ios operating system, or other possible operating systems, and embodiments of the present application are not limited specifically.
The package compression device provided in the embodiment of the present application can implement each process implemented in the method embodiment of fig. 1, and is not described here again to avoid repetition.
It should be noted that, in the decompression method provided in the embodiment of the present application, the execution main body may be a decompression device, or a control module in the decompression device for executing the decompression method. In the embodiment of the present application, a decompression device executes a decompression method as an example, and the decompression device provided in the embodiment of the present application is described.
Fig. 4 is a schematic structural diagram of a decompression device provided in an embodiment of the present application. Referring to fig. 4, a decompression apparatus provided in an embodiment of the present application may include:
the second decompressing module 410 is configured to decompress the target compressed packet according to a second decompressing manner, and obtain a second file whose size does not exceed the threshold before compression, and the first compressed file;
the first decompressing module 420 is configured to decompress the first compressed file according to a first decompressing manner, so as to obtain a first file of which the size before compression exceeds a threshold.
The decompression device provided by the embodiment of the application can enable the size of the file to be obviously smaller than that of a target compression packet of the existing compression packet to be smoothly decompressed by obtaining the second file with the size not exceeding the threshold value before compression according to the second decompression mode and the first compression file and decompressing the first compression file according to the first decompression mode, thereby effectively avoiding various problems caused by the larger compression packet in the prior art.
In one embodiment, the first decompression module 420 is specifically configured to:
decompressing the first compressed file according to the first decompressing mode to obtain each subfile of the first file;
and splicing the sub-files into the first file.
The decompression device in the embodiment of the present application may be a device, or may be a component, an integrated circuit, or a chip in a terminal. The device can be mobile electronic equipment or non-mobile electronic equipment. By way of example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palm top computer, a vehicle-mounted electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a Personal Digital Assistant (PDA), and the like, and the non-mobile electronic device may be a server, a Network Attached Storage (NAS), a Personal Computer (PC), a Television (TV), a teller machine or a self-service machine, and the like, and the embodiments of the present application are not particularly limited.
The decompression device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android (Android) operating system, an ios operating system, or other possible operating systems, and embodiments of the present application are not limited specifically.
The decompression device provided in the embodiment of the present application can implement each process implemented in the method embodiment of fig. 2, and is not described here again to avoid repetition.
Optionally, as shown in fig. 5, an electronic device 500 is further provided in this embodiment of the present application, and includes a processor 501, a memory 502, and a program or an instruction stored in the memory 502 and executable on the processor 501, where the program or the instruction is executed by the processor 501 to implement the processes of the foregoing compression method embodiment or the foregoing decompression method embodiment, and can achieve the same technical effects, and no further description is provided here to avoid repetition.
It should be noted that the electronic device in the embodiment of the present application includes the mobile electronic device and the non-mobile electronic device described above.
Fig. 6 is a schematic diagram of a hardware structure of an electronic device implementing an embodiment of the present application.
The electronic device 600 includes, but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, a processor 610, and the like.
Those skilled in the art will appreciate that the electronic device 600 may further comprise a power source (e.g., a battery) for supplying power to the various components, and the power source may be logically connected to the processor 610 through a power management system, so as to implement functions of managing charging, discharging, and power consumption through the power management system. The electronic device structure shown in fig. 6 does not constitute a limitation of the electronic device, and the electronic device may include more or less components than those shown, or combine some components, or arrange different components, and thus, the description is omitted here.
The processor 610 is configured to compress a first file with a size exceeding a threshold according to a first compression manner to obtain a first compressed file;
and compressing the second file with the size not exceeding the threshold value and the first compressed file according to a second compression mode to obtain a target compressed packet.
The electronic device 600 provided by the embodiment of the application compresses a larger file to reduce the size of the file through the first compression mode, and then compresses a smaller file and the first compressed file to obtain the compressed packet through the second compression mode.
Optionally, the processor 610 is further configured to:
splitting the first file into a plurality of subfiles according to the size of the first file and the threshold value;
and compressing each subfile according to the first compression mode.
Optionally, the processor 610 is further configured to:
rounding the quotient of the size of the first file and the threshold upwards to obtain a target number;
and splitting the first file into the target number of sub-files.
Optionally, the processor 610 is further configured to perform any of:
splitting the first file into j subfiles with equal size;
splitting the first file into j sub-files, wherein the size of at least j-1 sub-files is equal to the threshold value;
wherein j is the target number.
Optionally, the first compression manner is a compression manner of a 7z format, and the second compression manner is a compression manner of a zip format.
Optionally, the processor 610 is further configured to:
decompressing the target compression packet according to a second decompression mode to obtain a second file and a first compression file, wherein the size of the second file does not exceed the threshold value before compression;
and decompressing the first compressed file according to a first decompression mode to obtain a first file with the size exceeding a threshold value before compression.
Optionally, the processor 610 is further configured to:
decompressing the first compressed file according to a first decompression mode to obtain each subfile of the first file;
and splicing the sub-files into the first file.
It is to be understood that, in the embodiment of the present application, the input Unit 604 may include a Graphics Processing Unit (GPU) 6041 and a microphone 6042, and the Graphics Processing Unit 6041 processes image data of a still picture or a video obtained by an image capturing apparatus (such as a camera) in a video capturing mode or an image capturing mode. The display unit 606 may include a display panel 6061, and the display panel 6061 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit 607 includes a touch panel 6071 and other input devices 6072. A touch panel 6071, also referred to as a touch screen. The touch panel 6071 may include two parts of a touch detection device and a touch controller. Other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail herein. The memory 609 may be used to store software programs as well as various data including, but not limited to, application programs and an operating system. The processor 610 may integrate an application processor, which primarily handles operating systems, user interfaces, applications, etc., and a modem processor, which primarily handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor 610.
The embodiment of the present application further provides a readable storage medium, where a program or an instruction is stored on the readable storage medium, and when the program or the instruction is executed by a processor, the program or the instruction implements each process of the compression method embodiment or the decompression method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.
The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and so on.
The embodiment of the present application further provides a chip, where the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is configured to execute a program or an instruction to implement each process of the compression method embodiment or the decompression method embodiment, and the same technical effect can be achieved, and in order to avoid repetition, details are not repeated here.
It should be understood that the chips mentioned in the embodiments of the present application may also be referred to as system-on-chip, system-on-chip or system-on-chip, etc.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Further, it should be noted that the scope of the methods and apparatus of the embodiments of the present application is not limited to performing the functions in the order illustrated or discussed, but may include performing the functions in a substantially simultaneous manner or in a reverse order based on the functions involved, e.g., the methods described may be performed in an order different than that described, and various steps may be added, omitted, or combined. In addition, features described with reference to certain examples may be combined in other examples.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present application may be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present application.
While the present embodiments have been described with reference to the accompanying drawings, it is to be understood that the invention is not limited to the precise embodiments described above, which are meant to be illustrative and not restrictive, and that various changes may be made therein by those skilled in the art without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (11)

1. A method of compression, comprising:
compressing the first file with the size exceeding the threshold value according to a first compression mode to obtain a first compressed file;
and compressing the second file with the size not exceeding the threshold value and the first compressed file according to a second compression mode to obtain a target compressed packet.
2. The compression method according to claim 1, wherein compressing the first file with the size exceeding the threshold according to the first compression mode comprises:
splitting the first file into a plurality of subfiles according to the size of the first file and the threshold value;
and compressing each subfile according to the first compression mode.
3. The compression method according to claim 2, wherein the splitting the first file into a plurality of subfiles according to the size of the first file and the threshold value comprises:
rounding the quotient of the size of the first file and the threshold upwards to obtain a target number;
and splitting the first file into the target number of sub-files.
4. The compression method according to claim 3, wherein the splitting the first file into the target number of sub-files comprises any one of:
splitting the first file into j subfiles with equal size;
splitting the first file into j sub-files, wherein the size of at least j-1 sub-files is equal to the threshold value;
wherein j is the target number.
5. The compression method according to any one of claims 1 to 4, wherein the first compression method is a compression method of a 7z format, and the second compression method is a compression method of a zip format.
6. A decompression method, comprising:
decompressing the target compression packet according to a second decompression mode to obtain a second file and a first compression file, wherein the size of the second file does not exceed the threshold value before compression;
and decompressing the first compressed file according to a first decompression mode to obtain a first file with the size exceeding a threshold value before compression.
7. The decompression method according to claim 6, wherein decompressing the first compressed file according to the first decompression mode to obtain the first file with the size before compression exceeding the threshold comprises:
decompressing the first compressed file according to a first decompression mode to obtain each subfile of the first file;
and splicing the sub-files into the first file.
8. A compression device, comprising:
the first compression module is used for compressing the first file with the size exceeding the threshold value according to a first compression mode to obtain a first compressed file;
and the second compression module is used for compressing the second file with the size not exceeding the threshold value and the first compressed file according to a second compression mode to obtain a target compressed packet.
9. A decompression device, comprising:
the second decompression module is used for decompressing the target compression packet according to a second decompression mode to obtain a second file of which the size does not exceed the threshold value before compression and the first compression file;
and the first decompression module is used for decompressing the first compressed file according to a first decompression mode to obtain the first file of which the size before compression exceeds a threshold value.
10. An electronic device comprising a processor, a memory and a program or instructions stored on the memory and executable on the processor, the program or instructions, when executed by the processor, implementing the steps of the compression method as claimed in any one of claims 1 to 5 or implementing the steps of the compression method as claimed in claim 6 or 7.
11. A readable storage medium, characterized in that it stores thereon a program or instructions which, when executed by a processor, implement the steps of the compression method according to any one of claims 1 to 5, or implement the steps of the compression method according to claim 6 or 7.
CN202111135807.2A 2021-09-27 2021-09-27 Compression method and device and electronic equipment Pending CN113836101A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111135807.2A CN113836101A (en) 2021-09-27 2021-09-27 Compression method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111135807.2A CN113836101A (en) 2021-09-27 2021-09-27 Compression method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN113836101A true CN113836101A (en) 2021-12-24

Family

ID=78970806

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111135807.2A Pending CN113836101A (en) 2021-09-27 2021-09-27 Compression method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN113836101A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090210943A1 (en) * 2004-09-08 2009-08-20 Galit Alon Method to detect viruses hidden inside a password-protected archive of compressed files
CN102761540A (en) * 2012-05-30 2012-10-31 北京奇虎科技有限公司 Data compression method, device and system and server
CN104978319A (en) * 2014-04-02 2015-10-14 东华软件股份公司 Method and equipment used for classified transmission of files
CN105811994A (en) * 2016-03-03 2016-07-27 云南大学 Computer data zipping and processing system
CN107203524A (en) * 2016-03-16 2017-09-26 阿里巴巴集团控股有限公司 A kind of method for APK file of packing, the method and system for loading Bundle files
CN108279941A (en) * 2016-12-31 2018-07-13 阿里巴巴集团控股有限公司 A kind of compression method and device of application program
CN111552899A (en) * 2020-03-20 2020-08-18 广联达科技股份有限公司 Method and system for improving display performance of front-end report

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090210943A1 (en) * 2004-09-08 2009-08-20 Galit Alon Method to detect viruses hidden inside a password-protected archive of compressed files
CN102761540A (en) * 2012-05-30 2012-10-31 北京奇虎科技有限公司 Data compression method, device and system and server
CN104978319A (en) * 2014-04-02 2015-10-14 东华软件股份公司 Method and equipment used for classified transmission of files
CN105811994A (en) * 2016-03-03 2016-07-27 云南大学 Computer data zipping and processing system
CN107203524A (en) * 2016-03-16 2017-09-26 阿里巴巴集团控股有限公司 A kind of method for APK file of packing, the method and system for loading Bundle files
CN108279941A (en) * 2016-12-31 2018-07-13 阿里巴巴集团控股有限公司 A kind of compression method and device of application program
CN111552899A (en) * 2020-03-20 2020-08-18 广联达科技股份有限公司 Method and system for improving display performance of front-end report

Similar Documents

Publication Publication Date Title
US9542461B2 (en) Enhancing performance of extract, transform, and load (ETL) jobs
CN107220020B (en) Display method and electronic equipment
CN106202273A (en) File management method and system
CN112257135A (en) Model loading method and device based on multithreading, storage medium and terminal
CN113015007B (en) Video frame inserting method and device and electronic equipment
CN106843794B (en) Split screen display method and system based on android
CN103076955A (en) Method, device and terminal for adjusting characters of application
CN114610650A (en) Memory compression method and device, storage medium and electronic equipment
CN113873013B (en) Offline package reorganization method and system
CN109636460B (en) Service processing method, device, equipment and storage medium
CN109088636B (en) Data processing method and system, electronic equipment and storage medium
CN112035401A (en) Model data processing method and device, electronic equipment and readable medium
CN113721876A (en) Screen projection processing method and related equipment
CN113835657A (en) Display method and electronic equipment
CN113836101A (en) Compression method and device and electronic equipment
CN105204883B (en) A kind of plug-in unit loading processing method and device
CN113657408B (en) Method and device for determining image characteristics, electronic equipment and storage medium
CN113364915B (en) Information display method and device and electronic equipment
CN105184177A (en) Process hiding method and apparatus
CN114666658A (en) Cloud rendering method, device and system and user terminal
CN105469433B (en) Picture compression method and equipment thereof
CN113821484A (en) File processing method and device, electronic equipment and readable storage medium
CN114070892A (en) Data transmission method and device
CN114253449A (en) Screen capturing method, device, equipment and medium
CN112905072A (en) Application processing method and device and electronic equipment

Legal Events

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