Electronic equipment, storage medium formatting method and device thereof and program product
By determining the storage location of the PS stream file in the storage medium and performing local space formatting, combined with a virtual mapping table and multi-level formatting mode, the problem of long hardware-level full card erase time is solved, achieving efficient data formatting and extending the lifespan of the storage medium.
Patent Information
- Application Number
- CN202511010303.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-21
- Publication Date
- 2025-11-07
AI Technical Summary
In existing technologies, performing a hardware-level full card erase on the storage medium takes a long time, resulting in low data formatting efficiency.
The storage location is determined by a preset PS stream file location identifier, and local space formatting is performed based on this location. The formatting operation is optimized by combining a virtual mapping table and a multi-level formatting mode.
It effectively reduces formatting time, improves data formatting efficiency, extends the lifespan of storage media, and meets the formatting requirements of different needs.
Smart Images

Figure CN120909513A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data storage, and in particular to an electronic device, a storage medium formatting method, apparatus and program product thereof. BACKGROUND
[0002] In the field of security monitoring, it is often necessary to store video monitoring data (such as PS (Program Stream) stream format video data) using a storage medium (such as an SD card). For reasons of data security or performance optimization, it can be necessary to format the storage medium.
[0003] For a storage medium of a PS stream file structure, after the data storage space is used up, the storage medium with written data usually needs to be formatted to facilitate writing of new PS stream files. If a hardware-level full card erasure is performed, it takes a long time, which is not conducive to improving data formatting efficiency. SUMMARY
[0004] Therefore, embodiments of the present application provide an electronic device, a storage medium formatting method, apparatus and program product thereof to solve the problem that a hardware-level full card erasure of a storage medium takes a long time and is not conducive to improving data formatting efficiency in the prior art.
[0005] A first aspect of embodiments of the present application provides a storage medium formatting method of an electronic device, and the method comprises:
[0006] determining a storage location of the PS stream file in the storage medium according to a preset positioning identifier of the PS stream file;
[0007] performing formatting processing according to a local space determined according to the storage location of the PS stream file in the storage medium.
[0008] In combination with the first aspect, in a first possible implementation manner of the first aspect, the positioning identifier comprises a start identifier and an end identifier;
[0009] determining a storage location of the PS stream file in the storage medium according to a preset positioning identifier of the PS stream file, comprises:
[0010] determining a start cluster and an end cluster where the PS stream file is located through a file allocation table;
[0011] performing scanning in the start cluster according to the start identifier to determine a start sector of the PS stream file;
[0012] performing scanning in the end cluster according to the end identifier to determine an end sector of the PS stream file.
[0013] In a second possible implementation manner of the first aspect, according to the start identifier, scanning in the start cluster to determine the start sector of the PS stream file comprises:
[0014] According to the start identifier, scanning in the start cluster to determine the start sector of the PS stream file comprises:
[0015] According to the end identifier, scanning in the end cluster to determine the end sector of the PS stream file comprises:
[0016] According to the end identifier, scanning in the end cluster to determine the end sector of the PS stream file comprises:
[0017] In a third possible implementation manner of the first aspect, according to a local space determined according to a storage position of the PS stream file in the storage medium, performing format processing comprises:
[0018] In the memory of the electronic device, establishing a virtual mapping table of the PS stream file, the virtual mapping table comprising a physical address and a state of a PS packet in the PS stream file;
[0019] Marking the state of the PS packet in the virtual mapping table as an invalid state.
[0020] In a fourth possible implementation manner of the first aspect, the virtual mapping table further comprises an erasing number of a physical block where the PS packet is located.
[0021] After establishing the virtual mapping table of the PS stream file in the memory of the electronic device, the method further comprises:
[0022] According to the state of the PS packet and the erasing number of the physical block, and in combination with a system clock reference of the PS packet acquired in advance, writing a new PS stream file.
[0023] In a fifth possible implementation manner of the first aspect, according to a local space determined according to a storage position of the PS stream file in the storage medium, performing format processing comprises:
[0024] According to a size of a new PS stream file to be written, through a pre-erasing instruction integrated by a device driver layer, pre-erasing, in a serial manner or in a parallel manner, a target block matching the size of the PS stream file to perform format processing on the target block.
[0025] In a sixth possible implementation manner of the first aspect, the formatting processing according to the local space determined according to the storage location of the PS stream file in the storage medium comprises:
[0026] obtaining a formatting type instruction, the formatting type instruction comprising an efficiency priority instruction, a normal instruction and a security priority instruction;
[0027] when the formatting type instruction is the efficiency priority instruction, clearing data related to the PS stream file in a file allocation table and overwriting a first sector of the storage location;
[0028] when the formatting type instruction is the normal instruction, performing physical block erasing on data in the storage location of the PS stream file in the storage medium and overwriting predetermined data for a predetermined number of times;
[0029] when the formatting type instruction is the security priority instruction, performing block decomposition erasing on data in the storage location of the PS stream file in the storage medium.
[0030] A second aspect of the embodiments of the present application provides a storage medium formatting apparatus of an electronic device, the apparatus comprising:
[0031] a storage location determining unit configured to determine a storage location of a PS stream file in a storage medium according to a preset positioning identifier of the PS stream file;
[0032] a formatting processing unit configured to perform formatting processing according to a local space determined according to the storage location of the PS stream file in the storage medium.
[0033] A third aspect of the embodiments of the present application provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the electronic device implements the method according to any one of the first aspect.
[0034] A fourth aspect of the embodiments of the present application provides a computer program product, when executed on a computer, causes the computer to execute the method according to the first aspect or any implementation manner thereof.
[0035] A fifth aspect of the embodiments of the present application provides a computer readable storage medium, the computer readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of the first aspect are implemented.
[0036] The sixth aspect of the embodiments of the present application provides a chip for implementing the method in the above-mentioned first aspect and the implementation manners thereof. Specifically, the chip comprises a processor configured to invoke and run a computer program from a memory, so that a device installed with the chip performs the method in the above-mentioned first aspect or the implementation manners thereof.
[0037] Compared with the prior art, the embodiments of the present application have the beneficial effects that: when the storage medium storing the PS stream file is formatted, the storage position of the PS stream file in the storage medium is determined based on the preset positioning identifier of the PS stream file, the local space of the storage medium is determined based on the storage position, the local space is formatted, the workload of the formatting processing can be effectively reduced, the formatting time of the storage medium of the PS stream file structure is reduced, and the data formatting efficiency is improved. BRIEF DESCRIPTION OF DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0039] Figure 1 is an implementation flow diagram of a storage medium formatting method of an electronic device provided by the embodiments of the present application;
[0040] Figure 2 is a virtual mapping representation intention provided by the embodiments of the present application;
[0041] Figure 3 is a multi-mode formatting diagram provided by the embodiments of the present application;
[0042] Figure 4 is a schematic diagram of a storage medium formatting device of an electronic device provided by the embodiments of the present application;
[0043] Figure 5 is a schematic diagram of an electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0044] In the following description, specific details are set forth in order to provide a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application can be practiced in other embodiments without these specific details. In other instances, well-known systems, devices, circuits, and methods have not been described in detail in order to avoid obscuring the description of the present application.
[0045] In order to illustrate the technical solutions described in the present application, specific embodiments are used to illustrate the technical solutions described in the present application.
[0046] In application scenarios such as security monitoring, storage media (such as SD cards) are often used to store video monitoring data, and the most common video data is in the PS (Program Stream) stream format. Due to data security protection or system performance optimization considerations, sometimes the storage media needs to be formatted.
[0047] For storage media storing PS stream file structures, when the data storage space is used up, in order to write new PS stream files, the storage media with written data usually needs to be formatted. If a hardware-level full-card erasing method is used, it will take a long time, which has obvious deficiencies in improving data formatting efficiency.
[0048] To solve the above problems, the embodiments of the present application propose a storage medium formatting method of an electronic device, which determines the storage location of the PS stream file in the storage medium through a pre-set positioning identifier of the PS stream file, and performs formatting processing based on the local space determined by the storage location of the PS stream file, which can effectively reduce the formatting workload and improve the formatting efficiency of the storage medium storing PS streams.
[0049] In order to improve the service life of the storage medium, the embodiments of the present application establish a virtual mapping table of the PS stream file, record the erase-write times of the physical blocks and the state of the physical addresses, select the PS packets with invalid state markers and fewer erase-write times (such as the PS packets with the least erase-write times) in combination with the system clock reference of the PS packets, and determine the PS packets with longer time intervals from the current time (such as the PS packets with the longest time intervals from the current time) as target PS packets, and write new PS stream files. The erase-write times and the time intervals from the current time can be assigned weight coefficients, and the best PS packets obtained by calculation are used as target PS packets to write new PS stream files.
[0050] In order to meet the formatting requirements of different needs, multi-level formatting modes are set. According to different formatting type instructions, including efficiency priority instructions, regular instructions and safety priority instructions, different formatting operation modes are controlled to meet the diverse formatting needs of users.
[0051] Figure 1 The implementation flowchart of the storage medium formatting method of the electronic device proposed in the embodiments of the present application is shown in the following detailed description:
[0052] In S101, the storage location of the PS stream file in the storage medium is determined according to a pre-set positioning identifier of the PS stream file.
[0053] In the embodiment, the PS stream refers to a program stream, which is a format for storing multimedia data, and is used to combine multiple basic data streams (such as video, audio, subtitles, etc.) with a common time reference into a single continuous stream. The PS stream contains video, audio and other data, which can be packaged into PS packets (Program Stream Packets).
[0054] In the electronic device, the PS stream file is usually stored in a storage medium (such as a hard disk, a flash memory, an SD card, etc.). When the storage medium needs to be formatted, the conventional method usually formats the entire storage medium, which is a large amount of work and is prone to low efficiency.
[0055] The method provided in the embodiment can accurately locate the storage position of the PS stream in the storage medium, and only format the data corresponding to the storage position, thereby improving the formatting efficiency and reducing resource waste.
[0056] The locating identifier in the embodiment of the application can include a start identifier and an end identifier. For example, according to the encoding protocol, the PS stream file has a start identifier (0x000001BA) and an end identifier (0x000001B9), and each PS packet contains a system clock reference (SCR for short, System Clock Reference for full name) and rate information (program_mux_rate) and other key fields. The system clock reference is a timestamp embedded in the PS stream.
[0057] In a possible implementation manner, the embodiment of the application can sequentially search for the start identifier in each sector according to the start identifier, and if the start identifier is found in the sector, the sector is taken as the start sector of the PS stream file. After the start sector is found, the sectors are matched with the end identifier one by one in reverse order, and the sector including the end identifier is taken as the end sector of the PS stream file.
[0058] In order to further improve the locating efficiency of the storage position of the PS stream file, the embodiment of the application can further combine the file allocation table for preliminary positioning, and then further determine the specific sector according to the preliminary positioning, so as to reduce the number of sector comparisons and improve the positioning efficiency of the storage position.
[0059] Specifically, when the locating identifier includes the start identifier and the end identifier, the start cluster and the end cluster where the PS stream file is located can be determined through the file allocation table, the start sector of the PS stream file is determined by scanning the start cluster according to the start identifier, and the end sector of the PS stream file is determined by scanning the end cluster according to the end identifier.
[0060] Wherein, the end cluster can determine the cluster number of the end cluster according to the cluster number of the start cluster and the size of the PS stream file. For example, the cluster number of the start cluster is x1, the size of the PS stream file is x2, and the size of a single cluster is x3, then the cluster number of the end cluster can be x1+|x2 / x3| or x1+|x2 / x3|+1.
[0061] In a possible implementation, after determining the start sector in the start cluster, the number of sectors occupied by the PS stream file can be determined according to the size of the PS stream file, and the end sector can be determined according to the start sector and the number of occupied sectors.
[0062] A complete PS stream file always starts with 0x000001BA and ends with 0x000001B9. Assuming that a file allocation table (which can include, for example, a FAT file system directory or an exFAT file system directory) determines the start cluster, and assuming that a cluster includes 8 sectors and each sector includes 512 bytes, if the file allocation table records that the PS stream file start cluster number is 1000, then the cluster number of the start cluster is determined to be 1000. In the 1000th cluster, the start identifier 0x000001BA is matched byte by byte, the first sector of the cluster is 8000, and if 0x000001BA is found in the 3rd sector of the 1000th cluster, then the actual start sector of the PS stream file is 8002.
[0063] The cluster number of the end cluster can be estimated according to the file size. Assuming that the size of the PS stream file is 40M, according to the size of the space occupied by each cluster, it can be determined that the PS stream file occupies 10 clusters, and the cluster number of the end cluster is 1009. Starting from the start sector of the end cluster, if the end code is found in the 5th sector, then the end sector is 8076.
[0064] In a possible implementation, after determining the start cluster, the start sector of the PS stream file can be determined by scanning the start identifier in the start cluster using multiple independent hardware scanning modules to scan the start identifier in the start cluster in parallel, and the start sector in the PS stream file that matches the start identifier can be determined. Correspondingly, after determining the end cluster, the end sector in the PS stream file that matches the end identifier can be determined by scanning the end identifier in the end cluster using multiple independent hardware scanning modules to scan the end identifier in the end cluster in parallel.
[0065] For example, in the start cluster including 8 sectors, a hardware-level start code scanning accelerator can be implemented using an FPGA to scan the storage medium, such as an SD card physical sector, in parallel, and each clock cycle can process 4 sectors (512 bytes x 4) in parallel to detect whether the start identifier is located in the detected sector, thereby greatly shortening the scanning time in a single cluster.
[0066] In S102, the local space determined according to the storage location of the PS stream file in the storage medium is formatted.
[0067] The local space is determined based on the PS stream file in the storage location of the storage medium, i.e., the storage space of the PS stream in the storage medium. The erasing process is performed based on the determined local space, and the erasing command of the SD card is used, including, for example, ACMD23 pre-erasing, CMD32 / 33 batch erasing, and only erasing the physical block occupied by the PS stream file. The ACMD23 pre-erasing is pre-erasing a specified number of blocks before multi-block writing, so as to improve the writing efficiency. The CMD32 / 33 batch erasing is batch erasing the continuous sectors by specifying the start address (CMD32) and the end address (CMD33).
[0068] For example, by calculating the size of the PS stream file, the block range to be erased is determined, and the hardware-level erasing can be performed by calling the SD card protocol interface. Taking a 64 GB SD card as an example, compared with the time of full-card erasing, the time of formatting the local space can be shortened from 2-3 hours to tens of seconds, greatly reducing the formatting efficiency of the storage medium.
[0069] In a possible implementation manner, in order to further improve the data formatting efficiency, the virtual mapping table of the PS stream file can be established in the memory of the electronic device, the virtual mapping table including the physical address and the state of the PS packet in the PS stream file; and the state of the PS packet in the virtual mapping table is marked as an invalid state.
[0070] For example Figure 2 FIG. 1 shows a schematic diagram of a virtual mapping table constructed in the memory according to an embodiment of the present application. The mapping table includes the PS packet ID, the physical address of the PS packet, the start sector and the end sector of the PS packet, the state of the PS packet, and the erasing frequency of the physical block where the PS packet is located. The state of the PS packet includes the "valid" state and the "invalid" state. When the state of the PS packet is valid, it indicates that the PS packet data in the storage medium cannot be overwritten. When the state of the PS packet is invalid, it indicates that the PS packet data in the storage medium can be overwritten. When the local space where the PS stream file is located is formatted, the state of the PS packet in the virtual mapping table is updated to the "invalid" state. After the new PS stream file is overwritten, the erasing frequency of the physical block where the PS stream file is located in the virtual mapping table is updated accordingly.
[0071] By constructing the virtual mapping table, only the state of the physical address in the virtual mapping table needs to be updated, so that the overwriting (overwriting) state of the PS stream file can be quickly updated. When new data is written, the system directly overwrites the invalid area according to the mapping table, without physical erasing, so that the data writing efficiency can be effectively improved.
[0072] In a possible implementation, the virtual mapping table can further include an encrypted hash value of the PS package. The encrypted hash value can be used to perform erasure verification to determine whether the PS package has been erased.
[0073] To further improve the service life of the storage medium, the embodiment of the application can write a new PS stream file according to the state of the PS package and the erase-write times of the physical block, in combination with a system clock reference of the PS package obtained in advance.
[0074] In general, the longer the system clock reference is from the current time, the smaller the heat of the data, the colder the data, and the greater the probability of being overwritten.
[0075] At the same time, the fewer the erase-write times of the data block, the greater the probability of being overwritten for improving the service quality of the storage medium.
[0076] The system clock reference of the PS package and the erase-write times of the physical block can be comprehensively considered, and when the state of the PS package is the invalid state, a comprehensive score is determined according to the system clock reference of the PS package and the erase-write times of the physical block. For example, the priority can be represented as: α × (1 / data freshness) + β × erase-write times. Wherein, α and β are weight coefficients, and the data freshness is the time length from the data write time to the current time.
[0077] In a possible implementation, the embodiment of the application can use a pre-erase instruction integrated by a device driver layer, such as ACMD23, to pre-erase a target block matching the size of the PS stream file in a serial manner or in a parallel manner according to the size of the new PS stream file to be written, and perform formatting processing on the target block.
[0078] For example, in a monitoring scene, when it is detected that the remaining space of the SD card is insufficient, the pre-erase is automatically triggered to ensure that the new video recording can be continuously written, and fragmentation is avoided.
[0079] When performing the pre-erase, for the SD card supporting the UHS-I or UHS-II protocol, the multi-channel parallel erase function is used to simultaneously process the erase operation of multiple blocks, and the speed is further improved.
[0080] Wherein, the erase time consumption can be represented as: T = (N_block × T_block) / N_channel + T_overhead, wherein N_block represents the number of blocks to be erased, T_block represents the erase time of a single block, N_channel represents the number of parallel channels inside the storage card, and T_overhead represents the controller overhead, including command transmission and state query.
[0081] In a possible implementation, in order to balance the privacy requirements and formatting time requirements of different levels, the embodiments of the present application can set multiple erasing modes. For example, a formatting type instruction can be obtained, the formatting type instruction including an efficiency priority instruction, a regular instruction, and a security priority instruction; when the formatting type instruction is the efficiency priority instruction, the data related to the PS stream file in the file allocation table is cleared and the first sector of the storage location of the PS stream file is overwritten; when the formatting type instruction is the security priority instruction, the data in the storage location of the PS stream file in the storage medium is block-decomposed and erased; and when the formatting type instruction is the regular instruction, the data in the storage location of the PS stream file in the storage medium is physically block-erased and predetermined data is overwritten for a predetermined number of times.
[0082] The formatting type instruction can be determined by a mode selection instruction. As shown in FIG. 6, the mode selection instruction can be received, a basic mode is selected in an emergency cleaning scenario, the efficiency priority instruction is obtained in a regular use scenario, a security mode is selected in a confidential scenario, and the security priority instruction is obtained. Figure 3
[0083] In the basic mode, only the index of the file allocation table is cleared, and the file data is still retained in the physical block. The first sector in the storage area of the PS stream file in the storage device is overwritten, which can be used for fast initialization of the device or cleaning of non-sensitive data. The ACMD23 pre-erasing instruction can be called, and the number of write blocks pre-erased before writing is set. After the value is set, the subsequent multi-block write operation will be faster than the same operation without using the ACMD23.
[0084] In the security mode, physical block erasing can be triggered, and the target block is written with predetermined data for a predetermined number of times. For example, the data is overwritten three times, and oxff, ox00, and a random number are written in each storage cell in the local space in turn, so as to cover the charge residue and meet the data erasing requirement and efficiency requirement. The DMA erasing engine can be started, and specific values (such as all zeros or random data) are written to a specific storage area to cover the original data, so as to achieve an effect similar to erasing. Unlike the real hardware erasing operation, it is not through a physical mechanism to clear the data in the storage cell, but through a write operation under software or hardware logic control to realize the “pseudo” erasing of the data.
[0085] In the high-security mode, the NAND physical layer interface can be activated, the physical block is split into page (Page) level operations, the charge state is reset page by page, and a random sequence can be generated in combination with an encryption algorithm, and each page is overwritten multiple times to meet the requirement of high security performance.
[0086] The base mode is entered according to the efficiency priority instruction, the formatting rate is the fastest, but the data security is not as good as that in the security mode and the high security mode. The security mode is entered according to the regular instruction, the formatting efficiency and the data security performance are moderate, that is, the formatting efficiency is higher than that in the high security mode, and the data security of the formatting is higher than that in the efficiency priority mode. The high security mode is entered according to the security priority instruction, and the data security can be further improved compared with the security mode.
[0087] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0088] Figure 4 A schematic diagram of a storage medium formatting device of an electronic device provided by the embodiments of the present application is shown, and the device comprises:
[0089] The storage location determination unit 401 is configured to determine the storage location of the PS stream file in the storage medium according to the preset positioning identifier of the PS stream file.
[0090] The formatting processing unit 402 is configured to perform formatting processing according to the local space determined by the storage location of the PS stream file in the storage medium.
[0091] Figure 4 The storage medium formatting device of the electronic device shown corresponds to the storage medium formatting method of the electronic device shown. Figure 1 The storage medium formatting method of the electronic device shown corresponds to the storage medium formatting device of the electronic device shown.
[0092] Figure 5 A schematic diagram of an electronic device provided by the embodiments of the present application is shown. As shown in the figure, Figure 5 The electronic device 5 of the embodiment comprises a processor 50, a memory 51, and a computer program 52 stored in the memory 51 and executable on the processor 50, such as a storage medium formatting program of an electronic device. The processor 50 implements the steps in each of the above-mentioned electronic device storage medium formatting method embodiments when executing the computer program 52. Alternatively, the processor 50 implements the functions of each module / unit in the above-mentioned device embodiments when executing the computer program 52.
[0093] For example, the computer program 52 can be divided into one or more modules / units, which are stored in the memory 51 and executed by the processor 50 to complete the present application. The one or more modules / units can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program 52 in the electronic device 5.
[0094] The electronic device 5 can be a desktop computer, a notebook computer, a palm computer, a cloud server, and the like. The electronic device can include, but is not limited to, a processor 50, a memory 51. Those skilled in the art can understand that Figure 5 The electronic device 5 is only an example and does not constitute a limitation on the electronic device 5, and can include more or fewer components than shown, or combine certain components, or different components, for example, the electronic device can also include an input / output device, a network access device, a bus, and the like.
[0095] The processor 50 can be a central processing unit (CPU), and can also be other general-purpose processors, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, and the like. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor.
[0096] The memory 51 can be an internal storage unit of the electronic device 5, such as a hard disk or a memory of the electronic device 5. The memory 51 can also be an external storage device of the electronic device 5, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, and the like. Further, the memory 51 can include both the internal storage unit and the external storage device of the electronic device 5. The memory 51 is used to store the computer program and other programs and data required by the electronic device. The memory 51 can also be used to temporarily store data that has been output or will be output.
[0097] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be realized in the form of hardware or software. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction, and do not limit the protection scope of the present application. The specific working process of the units and modules in the above system can refer to the corresponding process in the foregoing method embodiments, which will not be described here.
[0098] In the above embodiments, the description of each embodiment has its own emphasis, and the parts not described or recorded in detail in a certain embodiment can be referred to the related description of other embodiments.
[0099] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be realized in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are executed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0100] In the embodiments provided in the present application, it should be understood that the disclosed apparatus / terminal device and method can be implemented in other ways. For example, the apparatus / terminal device embodiments described above are only schematic, and the division of the modules or units is only a logical function division, and there can be another division in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.
[0101] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
[0102] In addition, each of the function units in each of the embodiments of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit.
[0103] The integrated module / unit, if realized in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, all or part of the processes in the above-mentioned embodiment methods can also be completed by computer program instruction related hardware, and the computer program can be stored in a computer readable storage medium. When the processor executes the computer program, the steps of each method embodiment described above can be implemented. The computer program includes computer program code, which can be in the form of source code, object code, executable file or some intermediate form. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0104] In addition, the embodiments of the present application also provide a computer program product which, when running on a computer, causes the computer to execute the method in each of the above-mentioned implementations.
[0105] The above-mentioned embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to some technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. A storage medium formatting method of an electronic device, characterized by, The method comprises: According to the preset positioning mark of the PS stream file, the storage location of the PS stream file in the storage medium is determined; According to the local space determined by the storage location of the PS stream file in the storage medium, the formatting processing is performed.
2. The method of claim 1, wherein, The positioning mark comprises a start mark and an end mark; According to the preset positioning mark of the PS stream file, the storage location of the PS stream file in the storage medium is determined, which comprises: The start cluster and the end cluster where the PS stream file is located are determined through a file allocation table; According to the start mark, the start sector of the PS stream file is determined by scanning the start cluster; According to the end mark, the end sector of the PS stream file is determined by scanning the end cluster.
3. The method of claim 2, wherein, According to the start mark, the start sector of the PS stream file is determined by scanning the start cluster, which comprises: Through a plurality of independent hardware scanning modules, the start sector in the PS stream file matching the start mark is determined by scanning the start mark in the start cluster in parallel; According to the end mark, the end sector of the PS stream file is determined by scanning the end cluster; Through a plurality of independent hardware scanning modules, the end sector in the PS stream file matching the end mark is determined by scanning the end mark in the end cluster in parallel.
4. The method of claim 1, wherein, According to the local space determined by the storage location of the PS stream file in the storage medium, the formatting processing is performed, which comprises: A virtual mapping table of the PS stream file is established in the memory of the electronic device, and the virtual mapping table comprises the physical address and the state of the PS packet in the PS stream file; The state of the PS packet in the virtual mapping table is marked as an invalid state.
5. The method of claim 4, wherein, The virtual mapping table further comprises the erase count of the physical block where the PS packet is located; After the virtual mapping table of the PS stream file is established in the memory of the electronic device, the method further comprises: According to the state of the PS packet and the erase count of the physical block, in combination with the system clock reference of the PS packet acquired in advance, a new PS stream file is written.
6. The method of claim 1, wherein, According to the local space determined by the storage location of the PS stream file in the storage medium, the formatting processing is performed, which comprises: Through a pre-erase instruction integrated by a device driver layer, according to the size of the new PS stream file to be written, the target block matching the size of the PS stream file is pre-erased in a serial manner or in a parallel manner, and the target block is formatted.
7. The method of claim 1, wherein, According to the local space determined by the storage location of the PS stream file in the storage medium, the formatting processing is performed, which comprises: A formatting type instruction is acquired, and the formatting type instruction comprises an efficiency priority instruction, a regular instruction and a safety priority instruction; When the formatting type instruction is the efficiency priority instruction, the data related to the PS stream file in the file allocation table is cleared and the first sector of the storage location is overwritten; When the formatting type instruction is the regular instruction, the data in the storage location of the PS stream file in the storage medium is physically block-erased, and a predetermined number of predetermined data is overwritten. When the format type instruction is a security first instruction, the data in the storage location of the PS stream file in the storage medium is block-erased.
8. A storage medium formatting apparatus for an electronic device, characterized in that, The apparatus comprises: a storage location determining unit configured to determine a storage location of the PS stream file in the storage medium according to a preset locating identifier of the PS stream file; a format processing unit configured to perform format processing according to a local space determined by the storage location of the PS stream file in the storage medium.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the computer program, so that the electronic device implements the method in any one of claims 1-7.
10. A computer program product comprising computer program instructions, characterised in that, The computer program is run, so that the method in any one of claims 1-7 is executed.