A kind of storage method and a kind of camera system
Technical field
The present invention relates to digital technology field, particularly relate to a kind of storage method and a kind of camera system.
Background technology
Along with the development of electronic technology, electronic equipment multifunction increasingly, such as, present many electronics
Product all has video recording, the function of recording.Described video recording, sound-recording function, refer to various camera head,
If video camera, digital camera, photographic head or computer etc. are by data such as the video got, audio frequency, write
Enter in storage device, such as SD safe digital card, hard disk etc., then by these storage devices data to write
Store.
But, inventor finds in the research process of the application, and data are being write by existing camera head
When entering storage device, through mono-recordable repeatedly, one piece of data to could be write from camera head storage
In equipment, each mono-recordable is not at best able to the data volume of write storage device with the difference of storage device and not
With, and mono-recordable is all it is possible that skip write and suitable situation about writing every time, wherein, is accomplished by looking into during skip write
Look for the multiple memory fragmentations in described camera head, and obtain the data in the plurality of memory fragmentation, so
After be written in storage device, in this case, because memory fragmentation to be searched, when can expend a large amount of
Between;Along when writing, owing in each memory fragmentation, the data capacity of storage is less, thus by described shooting
Data in device store to storage device, must increase the number of times of mono-recordable, also can make
The process of storage takes considerable time.In this case, video recording quality can be had a strong impact on, even occur
The phenomenon of frame.
Such as, described camera head is when storing data to SD card, and mono-recordable may time-consumingly reach
700MS, in this case, the video recording frame per second of system can be reduced to 1 frame.And the video recording frame per second of high-quality
Being 25 frames, this will ask storage device can complete mono-recordable once in 40S.And existing storage skill
Art is because of skip write, along writing the consuming causing the time, and video recording frame per second can not reach the requirement of high-quality video recording,
Even there is frame, had a strong impact on the quality of video recording.
Summary of the invention
In view of this, the invention provides a kind of storage method and a kind of video recording system, to solve existing depositing
Due to skip write in storage technology, cause the consuming of time along writing so that inferior problem of recording a video.
A kind of storage method, including:
Gathering the image of the program including parameter preset, described parameter preset at least includes: preset
The number of big relief area and the size of each big relief area, described storage device in described each is the most slow
Rush the sevtor address that district is the most corresponding, the data address that each big relief area described is the most corresponding;
Described image is resolved, creates the big relief area corresponding with described parameter preset;
With reference to sevtor address the most corresponding with each big relief area described in described storage device, to described
Big relief area is ranked up;
When needs storage data, described in corresponding with described data to be stored for data to be stored write
In big relief area;
After writing data in described big relief area, create extra buffer, and by the one or more
Data write extra buffer in big relief area;
By in the sector of the data write storage device write in described extra buffer.
Preferably, minibuffer district, the amount of capacity in described each minibuffer district are comprised in described big relief area
It is the size of a sector, and described each minibuffer district is according to the sevtor address of corresponding storage device
Sequence.
Preferably, when described storage device is two or more, described pre-conditioned also include: described greatly
The storage device that relief area is corresponding.
Preferably, the capacity of described extra buffer is not less than the capacity of described big relief area.
Preferably, the method that described data to be stored write in described big relief area is included:
51) storage that the described big relief area that created is to be write with described data to be stored is judged
The sector of equipment is corresponding, if it is, perform step 55), if it is not, then perform step 52);
52) judge whether the region at place, described big relief area has enough memory spaces, if it did not,
Then perform step 53), if it has, then perform step 54);
53) by the data write storage device in the big relief area of original written data, and step is entered
Rapid 54);
54) the big relief area that the sector of the storage device to be write with described data to be stored is corresponding is created,
And described data to be stored are write in described newly created big relief area, and according to described data to be stored
The sevtor address of corresponding storage device, is ranked up described big relief area;
55) described data to be stored are write in described big relief area.
Preferably, the process that the data of said write relief area write extra buffer includes:
61) judge whether described big relief area has data to be stored, if it has, perform step 62);
62) extra buffer is created;
63) by the data to be stored in described big relief area, it is sequentially written in institute according to described big relief area
State in extra buffer, and return execution step 61).
Accordingly, the invention also discloses a kind of camera system, including:
Acquisition module, for gathering the image of the program including parameter preset, described parameter preset is at least
Including in: the number of big relief area set in advance and the size of each big relief area, described storage device
The sevtor address the most corresponding with each big relief area described, the number that each big relief area described is the most corresponding
According to address;
Creation module, for resolving described image, creates corresponding with described parameter preset big
Relief area;
Order module, for according to fan the most corresponding with each big relief area described in described storage device
Regional address, is ranked up described big relief area;
Big relief area writing module, for, during when needs storage data, treating data to be stored write with described
In the described big relief area that storage data are corresponding;
Extra buffer creation module, for after writing data in described big relief area, creates interim slow
Rush district, and the data in the one or more big relief area are write extra buffer;
Storage device writing module, for the data write storage device that will write in described extra buffer
Sector in.
Preferably, described big relief area writing module includes:
First judging unit, for judge the described big relief area that created whether with described data to be stored
The sector of storage device to be write is corresponding;
Second judging unit, for judging whether the region at place, described big relief area has enough storages empty
Between;
Creating unit, for creating new big relief area, and by described newly created for the write of described data to be stored
Big relief area in, and according to the sevtor address of storage device corresponding to described data to be stored, to described
Big relief area is ranked up;
First writing unit, for writing described data to be stored in described big relief area.
Preferably, described extra buffer creation module includes:
3rd judging unit, for judging whether there are data to be stored in described big relief area;
Extra buffer creating unit, is used for creating extra buffer;
Second writing unit, for by the data to be stored in described big relief area, according to described big relief area
Sequence write in described extra buffer.
Preferably, described acquisition module is particularly as follows: photographic head.
By storage method disclosed in the present application, when writing data into storage device, be first by described number
According to writing in relief area, and the data in one or more relief areas are write in extra buffer.Due to
The capacity of described extra buffer is bigger, it is possible to store more data simultaneously, thus by described interim slow
When rushing the data write storage device in district, can be the most with the data of write once, and, described greatly
Relief area, described minibuffer district are all tactic, are writing after described extra buffer, described in treat
Storage data are also to arrange in order, storage device of writing direct, it is no longer necessary to search internal memory broken
Sheet, it is to avoid because skip write, along writing the time delay caused, improve video recording quality.
Accompanying drawing explanation
In order to be illustrated more clearly that the embodiment of the present invention or technical scheme of the prior art, below will be to reality
Execute the required accompanying drawing used in example or description of the prior art to be briefly described, it should be apparent that below,
Accompanying drawing in description is only some embodiments of the present invention, for those of ordinary skill in the art,
On the premise of not paying creative work, it is also possible to obtain other accompanying drawing according to these accompanying drawings.
Fig. 1 is the workflow schematic diagram of a kind of memory technology disclosed by the invention;
Fig. 2 is a kind of relief area disclosed by the invention chained list schematic diagram;
Fig. 3 is the workflow schematic diagram of another memory technology disclosed by the invention;
Fig. 4 is a kind of relief area disclosed by the invention chained list schematic diagram when writing data;
Fig. 5 is the workflow schematic diagram of another memory technology disclosed by the invention;
Fig. 6 is the structural representation of a kind of camera system disclosed by the invention;
Fig. 7 is the structural representation of big relief area writing module in a kind of camera system disclosed by the invention;
Fig. 8 is the structural representation of extra buffer creation module in a kind of camera system disclosed by the invention.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out
Clearly and completely describe, it is clear that described embodiment is only a part of embodiment of the present invention, and
It is not all, of embodiment.Based on the embodiment in the present invention, those of ordinary skill in the art are not making
Go out the every other embodiment obtained under creative work premise, broadly fall into the scope of protection of the invention.
The invention discloses a kind of storage method, be used for solving present in prior art video recording system will
Data exist when being stored in storage device, the longest owing to writing, the inferior problem of video recording caused.
Seeing flow chart 1, storage method disclosed by the invention comprises the following steps:
Step S1, collection include the image of the program of parameter preset, and described parameter preset at least includes:
With described in the number of big relief area set in advance and the size of each big relief area, described storage device
The sevtor address that each big relief area is the most corresponding, the data address that each big relief area described is the most corresponding;
It addition, when video recording system is provided with multiple storage device, described pre-conditioned also include: described greatly
The storage device that relief area is corresponding, in order to select suitable storage device, it is achieved the storage to data;Its
In, can be completed containing pre-conditioned program by the shooting of the photographic head of video camera, computer is first-class
The collection of image.
Step S2, described image is resolved, create the big relief area corresponding with described parameter preset.
During actual application, can be carried out by the image of the described program to collecting of the processor in camera system
Dissection process, to create described big relief area, furthermore it is possible to set in storage by described big setting buffers
Standby interface layer, naturally it is also possible to be arranged on other regions.Meanwhile, when arrange big relief area be multiple
Time, the plurality of big relief area can be arranged on different regions, but generally, selection is by described
Multiple big setting buffers are in same region, such as the interface layer of described storage device, in order to can be in time
Storage allocation and releasing memory, reduce the waste of internal memory.Wherein, described can containing pre-conditioned program
With as follows:
When arranging relief area, it is contemplated that the problem of memory fragmentation, if application and releasing memory frequently,
By increasing the burden of video recording system, being therefore also provided with minibuffer district, described big relief area can store one
Or the data of multiple sector, and the amount of capacity in each minibuffer district is a sector-size, say, that
Each big relief area comprises one or more minibuffer district.
It addition, in terms of arranging big relief area, multiple big relief area can be arranged by a program simultaneously,
Such as, the size pre-setting described big relief area is 64K, then, when arranging all big relief areas
If the parameter of capacity sum is 128K, then be provided with two big relief areas the most simultaneously.
By program above it will be seen that each big relief area comprises N number of minibuffer district, the number of N
Value size is by program: " BIG_ASAY_BUF_SIZE/ sector-size " determines, generally by described big slow
Rush district and be set to 8K byte, or be set to the capacity of other sizes.
Step S3, with reference to sevtor address respectively the most corresponding with each big relief area described in described storage device,
Described big relief area is ranked up;By program above, data to be stored should be stored in
Which sector of storage equipment is fixing, and when creating big relief area, has preset described big slow
Rushing the sevtor address of described storage device corresponding to district, described big relief area sets according to corresponding described storage
The address sort of standby sector, and the minibuffer district in described big relief area is also carried out according to sevtor address
Sequence, for example, it is possible to from small to large described big relief area is ranked up according to sevtor address, the most every
Minibuffer district in individual big relief area also arranges according to the sevtor address of the described storage device of its correspondence
Sequence, thus, the minibuffer district in described each big relief area, and described multiple big relief area, energy
Enough form a tactic chained list, by the head of big relief area as gauge outfit.See Fig. 2, be
The chained list schematic diagram of the relief area created.
Step S4, when needs storage data time, by data to be stored write relative with described data to be stored
In the described big relief area answered;When needs storage data, system can produce write order, and write described
Order is sent to described big relief area, and then performs described data to be stored are write described big relief area
Operation.
Step S5, write after data in described big relief area, create extra buffer, and by described one
Data write extra buffer in individual or multiple big relief area;In writing data into described big relief area
After, create an extra buffer, the capacity of described extra buffer however less than described big relief area,
When as described in the size of big relief area be 8K byte time, described extra buffer can be 64K byte,
Or it is the capacity of other sizes, after described data to be stored write extra buffer, then faces described
Time relief area in data write storage device time, can be the most with the data of write once, and, by
In described big relief area, described minibuffer district be all tactic, it is not necessary to the process of lookup, thus
That avoid that prior art occurs because skip write, along writing the longest time-consuming problem caused.
It addition, be by a big relief area or by the data write extra buffer in multiple big relief areas,
Depend on the amount of capacity of described extra buffer, if the size of described extra buffer and described big slow
The size rushing district is identical, can the most only write the data of a big relief area, if described interim buffering
If the size in district is the size of multiple big relief area, can the data of multiple big relief areas be write every time
In extra buffer.
Step S6, by the sector of the data write storage device write in described extra buffer.Writing
When entering storage device, if described video recording system is provided with multiple storage device, can be according to above
Program language, select corresponding storage device, by described extra buffer data write described in deposit
In storage equipment.
By the method for step S1 to step S6, when writing data into storage device, be first by described
In data write relief area, and the data in one or more relief areas are write in extra buffer, by
Bigger in the capacity of described extra buffer, it is possible to store more data simultaneously, thus by described temporarily
During data write storage device in relief area, can be the most with the data of write once, and, described
Big relief area, described minibuffer district are all tactic, after writing described extra buffer, described
Data to be stored are also to arrange in order, storage device of writing direct, it is no longer necessary to search internal memory
Fragment, it is to avoid because skip write, along writing the time delay caused, improve video recording quality.
It addition, shown in schematic flow sheet as disclosed in fig. 3, by described to be stored data writes institute
When stating big relief area, comprise the following steps:
The described big relief area that step S21, judgement have created is to be write with described data to be stored
The sector of storage device is corresponding.Due to described data to be stored want write storage device which sector it
In be fixing, and according to program provided above, described big relief area is when creating,
Specify that the corresponding relation of sevtor address with described storage device.Accordingly, it would be desirable to judge the institute created
The sector stating the big relief area storage device to be write with described data to be stored is corresponding, if
It is then to perform step S25, if it is not, then perform step S22.
Step S22, judge whether the region at place, described big relief area has enough memory spaces, such as,
When the interface layer that the region at place, described big relief area is described storage device, described interface layer to be judged
Whether also have enough memory spaces, if it is not, perform step S23, if it has, then perform step
S24;
Step S23, in step S22, when the region judging place, described big relief area does not has enough
During memory space, explanation system does not have internal memory can distribute, therefore, big by original written data
In data write storage device in relief area, to obtain new internal memory, and enter step S24.
Step S24, corresponding the delaying greatly in sector of the storage device that establishment is to be write with described data to be stored
Rush district, and described data to be stored are write in described newly created big relief area, and deposit according to described waiting
The sevtor address of the storage device that storage data are corresponding, is ranked up described big relief area.Such as, original
The sevtor address coming last minibuffer district of first big relief area is 0XFFFFFF00, original second
The sevtor address in first minibuffer district of individual big relief area is 0XFFFFFFFF, newly created big buffering
Sevtor address in district is between 0XFFFFFF00 and 0XFFFFFFFF, then by newly created big buffering
District inserts between the former first big relief area and former second largest relief area, and is set to second largest relief area,
Postponing in former second largest relief area and big relief area afterwards, i.e. revises the information of original chained list.
Step S25, described data to be stored are write in described big relief area.When specifically performing,
When described data to be stored are write in described big relief area, if there have been data described big relief area
Time, described data to be stored can be re-write, to cover original data.
When being embodied as, understand, just with reference to the schematic diagram by described data write relief area shown in Fig. 4
When creating a big relief area, owing to not writing data, so the relief area linked list head used points to sky,
When needs storage data, if the described big relief area created, to write with described data to be stored
The sector of storage device there is corresponding relation, then described data to be stored are write in this big relief area
If originally there are data in described big relief area, then it is assumed that existing data are old data,
By described data cover to be stored at this big relief area, if originally there are not data, treat described
In the corresponding minibuffer district of storage data write, and this minibuffer district is added to use buffering
On the chained list in district, and ensure the sortord of the relief area used.If when writing data, the most enough
The relief area of size, and when system is not reaching to the threshold values of internal memory, then application is next big the most again
Relief area, and when system has reached the threshold value of internal memory, the data in each big relief area can be write
Storage device, and re-create new relief area.
By described step S21 to workflow disclosed in step S25, data to be stored can be write
In described big relief area, and in the sector of described data to be stored described storage device to be write with
When the big relief area created does not exists corresponding relation, new big relief area can be created, and new creating
Behind big relief area, still it is ranked up according to the sevtor address of corresponding described storage device.It addition, this
Bright disclosed scheme, increases the technology of relief area in a storage arrangement, can allow a thread that data are write
Enter relief area, the most directly return, it is not necessary to wait, be returned to after data are write, thus do not have
Every time write time-consuming the biggest is set because storing, causes certain operations to be normally carried out.And write relief area
Data will carry out writing when backstage during storage arranges by another independent thread.
It addition, shown in schematic flow sheet 5 as disclosed in figure, the data of said write relief area are being write
When entering extra buffer, comprise the following steps:
Step S31, judge whether described big relief area has data to be stored.When in described big relief area
When having data to be stored, write order can be produced, to perform the operation of step S32;If through judging,
When there is no data to be stored, block the thread writing data into extra buffer, until judging described
There are data to be stored in big relief area.
Step S32, establishment extra buffer, the capacity of described extra buffer is greater than described big relief area
Capacity, meanwhile, described extra buffer can be arranged on interface layer, it is also possible to is arranged on other positions,
The application does not limits.But in order to reduce the time of described data to be stored write extra buffer,
Currently preferred mode is that described extra buffer is arranged on the region of described big setting buffers, with
Reach to distribute in time, the purpose of releasing memory.
Step S33, by the data to be stored in described big relief area, according to the sequential write of described big relief area
Enter in described extra buffer, and return execution step S31, i.e. the data in described big relief area being write
After entering described extra buffer, more whether there are data to be stored in judging described big relief area.Concrete real
Shi Shi, inquire about the address in the relief area of last use whether with the big relief area of this secondary use
Address is continuous, if continuous print, the described big setting buffers that will use is used, from
And update link table information, and if discontinuous, then by little slow for first in described big buffering to be used
Rush the linked list head address that the address in district is set to use
In memory technology disclosed in the present application, it is one by the process that data to be stored write big relief area
Individual thread, and during by data write storage device in described big relief area, be to be performed by another thread
, thus by arranging the technology of relief area, it is achieved that the method for multithreading, i.e. will by a thread
Data to be stored write big relief area, by another thread.This process is referred to as asynchronous write.
It addition, in above-mentioned thread, when performing write operation, principle is first in first out mechanism.And by institute
State the priority of thread in the sector of the data write storage device in big relief area, be defined as low preferentially
Level, will be higher than system idle thread less than general application thread.Because electronic product exists
A lot of threads, wherein said system idle thread refers to not make the thread of any operation, is in wait shape
State, this time thus can be utilized to carry out first carrying out the independent thread of asynchronous write.If it addition,
This separate threads is defined as priority ratio higher, then will very this separate threads of some priority ratios low
The operation of thread be waited for, as video recording arises that frame treats problem, thus by described thread
Priority be defined as low priority, it is possible to play the effect of scheduling time.
By memory technology disclosed in the present application, when writing data into storage device, first by described number
According to writing in relief area, and the data in one or more relief areas are write in extra buffer, due to
The capacity of described extra buffer is bigger, it is possible to store more data simultaneously, thus by described interim slow
When rushing the data write storage device in district, can be the most with the data of write once, and, described greatly
Relief area, described minibuffer district are all tactic, are writing after described extra buffer, described in treat
Storage data are also to arrange in order, storage device of writing direct, it is no longer necessary to search internal memory broken
Sheet, it is to avoid because skip write, along writing the time delay caused, improve video recording quality.
Accordingly, the invention also discloses a kind of camera system, its structural representation as shown in Figure 6, wraps
Include: acquisition module 1, creation module 2, order module 3, big relief area writing module 4, buffer temporarily
District's creation module 5 and storage device writing module 6, wherein:
Described acquisition module 1, for gathering the image of the program including parameter preset, described parameter preset
At least include: the number of big relief area set in advance and the size of each big relief area, described storage set
Sevtor address the most corresponding with each big relief area described in Bei, each big relief area described correspondence respectively
Data address;When specifically applying, described acquisition module 1 can be the photographic head of camera system;
Described creation module 2, for resolving described image, creates corresponding with described parameter preset
Big relief area;
Described order module 3, for according to the most corresponding with each big relief area described in described storage device
Sevtor address, described big relief area is ranked up;
Described big relief area writing module 4, for when needs storage data time, by data to be stored write with
In the described big relief area that described data to be stored are corresponding;
Described extra buffer creation module 5, for after writing data in described big relief area, establishment is faced
Time relief area, and by the one or more big relief area data write extra buffer;
Described storage device writing module 6, for the data write storage that will write in described extra buffer
In equipment.
It addition, see Fig. 7, described big relief area writing module 4 includes: the first judging unit 41,
Two judging units 42, creating unit 43 and the first writing unit 44, wherein:
Described first judging unit 41, for judging whether the described big relief area created deposits with described waiting
The sector of the storage device that storage data are to be write is corresponding;
Described second judging unit 42, for judging whether the region at place, described big relief area has enough
Memory space;
Described data to be stored for creating new big relief area, and are write institute by described creating unit 43
State in newly created big relief area, and according to the sevtor address of storage device corresponding to described data to be stored,
Described big relief area is ranked up;
Described first writing unit 44, for writing described data to be stored in described big relief area.
It addition, with reference to Fig. 8, described extra buffer creation module 5 includes: the 3rd judging unit 51,
Extra buffer creating unit 52 and the second writing unit 53, wherein:
Described 3rd judging unit 51, for judging whether there are data to be stored in described big relief area;
Described extra buffer creating unit 52, is used for creating extra buffer;
Described second writing unit 53, for by the data to be stored in described big relief area, according to described
The sequence of big relief area writes in described extra buffer.
By camera system disclosed in this invention, can data write to be stored be pre-created is big
In relief area, and the data in one or more big relief areas are write extra buffer, then by described
Extra buffer writes data in storage device, such that it is able to the data realizing write once are the most,
And avoid the time searching memory fragmentation, improve the performance writing data, improve video recording quality.
Described above to the disclosed embodiments, makes professional and technical personnel in the field be capable of or uses
The present invention.Multiple amendment to these embodiments will be aobvious and easy for those skilled in the art
See, generic principles defined herein can without departing from the spirit or scope of the present invention,
Realize in other embodiments.Therefore, the present invention is not intended to be limited to the embodiments shown herein,
And it is to fit to the widest scope consistent with principles disclosed herein and features of novelty.