A kind of method for building up of medium file system
Technical field
The invention belongs to the computer memory technical field of multimedia file, be specifically related to a kind of method for building up of medium file system.
Background technology
Existing medium file system adopts multilevel index structure, media file information such as video are that unit carries out Computer Storage and transmission with the piece, so on messaging devices such as video server during media file such as accessing video, normally be that unit proposes the access requirement with the logical record, therefore, whether the length of physical block length on the storage medium and logical record mates the addressing that directly has influence on file.Generally can be divided into three kinds of situations:
(1) logical record length and physical block appearance etc.;
(2) logical record length is the integer factor of physics block length;
(3) logical record length is not the integer factor of physics block length;
Therefore, step is as follows when addressing:
A. according to logical record length, determine the relative block number rb of n bar record place physical block;
B. determine that by record length and physical length the shared physical block piece of this record counts n;
C. calculate the displacement d1 that is recorded in the shared first physical block;
D. calculate the displacement d2 in the shared last physical block of record, promptly be recorded in the length that occupies in the last piece;
E. according to physics block length bs and d1 that calculates and d2, judge whether record strides piece; Then revise n value and d2 value if stride piece.
Like this, will cause the very big time-delay of reading of file.For video file, it all is unfixed that every frame compresses back length, and the situation that every logical record is striden physical block exists in a large number.A plurality of read operations simultaneously will greatly influence file system performance, and current file system is not suitable for the operation of media file.
In the video technique field, use multimedia file and other system file that a great difference is arranged, multimedia file is generally all bigger, takies huge storage unit; The multimedia file read-write motion is sent by system and is real-time.It is real-time that professional domain is used the important requirement of multimedia file, and promptly the processing speed that reads the decoding output data of file data is constant, and the time strictness of each frame is limited in 40 milliseconds of scopes.In the prior art, traditional file system has very big uncertainty aspect read operation, and a plurality of read operations simultaneously will greatly influence performance; For the video server that has a plurality of passages, the order of Yin Ruing at any time will influence the real-time of output, even broadcast quality.Traditional file system is used standard file format, and is made up of a plurality of files, has increased the addressing number of times of hard disk, greatly influences the performance of storage system; These files are not often supported flow transmission; Have multiple formatted file and deposit and size situation about differing greatly, accelerate like this to produce the hard disk fragment, it is a lot of that performance of storage system is descended, and stays a lot of hidden danger for stable broadcast.
Summary of the invention
At the defective that exists in the prior art, the method for building up that the purpose of this invention is to provide a kind of medium file system, this medium file system can guarantee video equipment real-time workings such as video server, improve the reading performance of hard disk storage system, improve the number of channels that the separate unit video server has, be particularly suitable for the storage of video files such as multimedia.
For reaching above purpose, the technical solution used in the present invention is: a kind of method for building up of medium file system may further comprise the steps:
(1) at first establish the storage mode of media file on the disk, be about to disk and be divided into the district, comprise system region, index area and data field, the basic disk allocation unit is a piece;
(2) in the medium file system be that unit preserves media file then with the image sets on disk, the storage cell of media file is a data block, and each data block is preserved image sets data, and corresponding with the index entry of disk index area.
Further, in the step (1), the data in magnetic disk of this document system distributes in the following ways: comprise system block, index block and data block in the disk, system region comprises layout, quantity of documents, the quantity of piece and the reference position of vacant disk block chained list of system, the index of index area include file clauses and subclauses and file, the essential information of file entries include file and piece index, include file metadata information in the essential information, data block that all have distributed and assignable data block composition data district.
Further, obtain invention effect better for making the present invention, in the step (2), the data in the data block comprise video data and voice data.Each piece can independently be decoded.Data in the data block comprise data directory, video data, voice data successively, and a byte comprises frame index, audio index in the piece in the piece, and these index are made up of side-play amount and size of data.
Further, on disk, set up data block in the step (2) and adopt following method to carry out: at first determine the size of image sets, and then according to fixed bit rate specified data block size, the index record of data block is in the index block of disk.The size of data block is greater than the size of data of maximum image group.
Further, in the step (2), the index entry of disk index area and the corresponding relation of data block are data blocks of index entry index of each index area, i.e. complete image sets of index and audio content thereof, and described image sets is preferably the compressed image group.
Further, described image sets is the image sets after compressing, and image sets is big more, and the performance of native system is higher more than the performance of traditional file systems.
Effect of the present invention is: the medium file system that adopts the method for the invention to set up, video equipments such as video server are worked long-term and stably, improve the reading performance of hard disk storage system greatly, and improve the number of channels that the separate unit video server has.Therefore the present invention can be widely used in the storage of video files such as multimedia.
Why the present invention has above-mentioned effect, mainly be because: the storage feature of the reading of media file and disk is combined closely, and this system need not special audio file simultaneously, can read file quickly, reduce hard disk addressing number of times, significantly reduce the hard disk fragment.So both avoid the index of Audio Video Interleaved form (avi) to be distributed in the file, be difficult to retrieval, solved the shortcoming that does not have index in the form (mepg) that Motion Picture Experts Group formulates again, improved the availability of video file; Also avoided these files to stride the shortcoming of piece storage.
Description of drawings
Fig. 1 is the disk distribution schematic diagram;
Fig. 2 is the process flow diagram that adopts the medium file system store media files that the method for the invention sets up.
Embodiment
The present invention will be further described below in conjunction with the drawings and the specific embodiments:
A kind of method for building up of medium file system may further comprise the steps:
(1) at first establish the storage mode of media file on the disk, be about to disk and be divided into the district, comprise system region, index area and data field, the basic disk allocation unit is a piece;
(2) in the medium file system be that unit preserves media file then with the image sets on disk, the storage cell of media file is a data block, and each data block is preserved image sets data, and corresponding with the index entry of disk index area.
As shown in Figure 1, the upper strata rectangle is represented the distribution of whole magnetic disk, and initial as can be seen from Figure 1 disk is system region 1 and index area 2, and other parts are data field 3.Each data block comprises an image sets in the data field 3, represents with the rectangle of lower floor, and each data block all is made of frame and audio index 4, the data division 5 of head.Image sets in the present embodiment is the image sets after compressing.
In the present embodiment, the data in magnetic disk of medium file system distributes in the following ways: according to the function difference disk is divided into the district, concrete disk distributes and comprises system region, index area and data field.The basic disk allocation unit is a piece.System region comprises layout, quantity of documents, the quantity of piece and the reference position of vacant disk block chained list of system, the index of index area include file clauses and subclauses and file, the essential information of file entries include file and piece index, include file metadata information in the essential information, data block that all have distributed and assignable data block composition data district.
Medium file system is different from other storage systems on function, disk exists as a kind of independently storage organization.Medium file system is made up of index part and data division:
System region 1 comprises: the layout of videotex system, quantity of documents, the reference position of the quantity of piece and vacant disk block chained list.
Index node is divided into two kinds of file item node and address nodes, is 128 bytes of regular length.The file item node section, be docile and obedient preface and be respectively: index part comprises file size, the 8 byte creation-times of 8 byte file names, 64 bytes, the retaining space of 44 bytes, and last 4 bytes are the index of address block.
The address node is total to nybble with 0X00000001 to begin; Be by document order arranged blocks allocation index subsequently, four bytes of each block address index, totally 30, with last 4 bytes of the file item node index that is address block.The end of file when the address index is 0X00000000.
In the present embodiment, data comprise video data and voice data in the data block.Each piece can independently be decoded.Data comprise data directory, video data, voice data successively in the data block, and a byte comprises frame index, audio index in the piece in the piece, these index by side-play amount, size of data and timing code totally 16 form;
Be initiated with the index of frame piece and audio block in this piece at the data segment of data block, the timing code that comprises start address, frame sign and this frame of each frame, the voice data index is closelyed follow thereafter as the index of a frame, if like this system definition gop size be n, in each piece index, comprised n+1 index point so.Each piece has been stored the video data of an image sets and time period corresponding audio data therewith.
In addition, described in the present embodiment file system is applicable to the environment that the multimedia material is had unified compression method, especially better effects if is being arranged under the situation of interframe compression.When setting up the corresponding relation of piece and image sets on the disk, adopt following method to carry out, concrete steps are as follows: the size of at first determining image sets is the N frame, and then according to fixed bit rate B specified data block size, the index record of piece is in the index block of disk.
The size of data block equals ((N/25) * B+ (N/25) * 48K+N*16)/512+1) * 512.
In the above-mentioned formula, (N/25) * B is a video section length, and (N/25) * 48K is an audio-frequency unit length, and N*16 is the length of index and timing code part.The 512nd, the least unit of harddisk access, the block length of system divides are 512 integral multiples.
As shown in Figure 2, when adopting the medium file system store media files that the method for the invention sets up, at first before using disk,, determine the size of disk block according to above-mentioned formula, and format diskette according to user-selected compression parameters.
Secondly, in use: for non-read write command, create or deleted file, in index block, the disk block information that preservation or deleted file take, and revise the interior content relevant of system block with this document, finish the establishment and the disk allocation of file.
For read command, calculate the image sets at user's desire visit frame place earlier.From disk, read this image sets for the data that do not have in the disk buffering; For the existing data of disk buffering, find frame data according to the index information of this data block head, and return to the user.
For write order, the metadata cache that receives from the user at disk, is generated index information simultaneously, by the time after accepting complete image sets, the index of this image sets and data write-once disk, last use of in the index block of disk, registering this disk block.
Method of the present invention is not limited to the embodiment described in the embodiment, and those skilled in the art's technical scheme according to the present invention draws other embodiment, belongs to technological innovation scope of the present invention equally.