Detailed description of the invention
The embodiment of the present invention provides a kind of method that video data processes, when newly increasing a kind of video format,
Have only to increase and store the state machine that this newly-increased form is corresponding, it is not necessary to change hardware.The embodiment of the present invention is also
Corresponding device and equipment are provided.It is described in detail individually below.
Refering to Fig. 1, an embodiment of the method that the video data that the embodiment of the present invention provides processes includes:
101, obtain and store state machine corresponding to regular expression describing video data format.
Regular expression: in computer science, refers to that one a series of meets certain for describing or mating
The single character string of the character string of individual syntactic rule;General regular expression describes particular data.
State machine is exactly a state transition diagram.Description more precisely is: it is a directed graph, by one
Group node and one group of corresponding transfer function composition.State machine is " RUN " by response sequence of events, often
Individual event is all within belonging to the span of control of transfer function of " currently " node, and wherein the scope of function is joint
One subset of point, function returns " next " (may is that same) node.In these nodes at least
One must be to accept state, when arrival accepts state, and state machine stops.Accept state i.e. final state.
Can understand refering to Fig. 2 A and 2B for state machine, Fig. 2 A and 2B is respectively character string (0 | 1) * 01
Non-determined type state machine (NFA, Non-Deterministic Finite Automation) and deterministic type state
Machine (DFA, Deterministic Finite Automation).Permissible by the state transfer relationship of state machine
Make state table, as table 1 below is: the state table of DFA:
The state table of table 1:DFA
|
Input 0 |
Input 1 |
S0 |
1 |
0 |
S1 |
1 |
2 |
S2 |
1 |
0 |
The operation principle of the DFA state machine provided in the present embodiment as can be seen from Table 1 is: at initial shape
, when the first character joint of coupling is 0, then there is state transfer, jump to next intermediateness S1 in state S0,
If in initial state S0, when the first character joint of coupling is 1, the most not occurring state to shift, also resting on
State S0, if having jumped to intermediateness S 1, then mates second byte again, if second word
Joint is 0, then rest on intermediateness S1, if second byte is 1, then state transfer occurs, jumps to down
One accepts state S2, if having jumped to accept state S2, then mates the 3rd byte, if the 3rd
Individual byte is 0, then jump to intermediateness S1, if the 3rd byte is 1, then jumps to initial state S0.
When newly increasing a kind of video format, the video format newly increased can be compiled one and be used for describing
The regular expression of this video format.As: the regular expression of SiverLight form can be compiled following
Regular expression:
pcre:HTTP/1.1200OK.*Content-Type:text/xml\r\nContent-Length:\d+(\r\n){2}
Action:report represents that these whole load flowed need to report CPU(index file)
pcre:HTTP/1.1200OK.*Content-Type:video/mp4\r\nContent-Length:\d+(\r\n){2}
action:no_report
This regular expression is meant that, the heading index of reference file of SiverLight format video data
Describe, the content of heading is all reported central processing unit (CPU, Central Processing
Unit), the video data of message text part has only to store in memorizer, it is not necessary to report again
CPU。
Between regular expression and state machine can phase transformation mutually, the video data data of different-format can be led to
Cross regular expression to represent, but when data process it is necessary to determined difference by the operation of state machine
How the data of part process.It is, to be determined by the work that state machine runs to accept during state
The video data of message text is not report CPU, or all reports CPU.
When newly increasing a video format, it is only necessary to edit a canonical corresponding with this newly-increased video format
Expression formula, then this regular expression is converted into state machine, data processing equipment obtains and stores this state machine,
Just can process the video data of this newly-increased form.
102, receive video data, and by the video data that receives by the first state machine of the first level by
Individual byte is mated.
The video data of some form has only to the state machine of a level just can know regarding of message text
The result of frequency evidence, or stop reporting CPU, or all report CPU, or skip several
Stop again after individual byte reporting CPU.The state machine of one level just can obtain the video format of result
Including SiverLight, Apple HLS etc., but the state machine of one level of video data of some form is not yet
Can obtain final result completely, so, when arrive the first level the first state machine accept state
After, the state machine that will proceed to the second level proceeds to process.Each level can include multiple state
Machine, the order of level is exactly the order that data process, and data must get ahead the first level state machine,
The second level state machine can be carried out.
After data processing equipment receives video data, start being carried out by state machine of byte-by-byte from heading
Coupling.
103, when matching m-th byte, arrive the state that accepts of described first state machine, obtain institute
Stating the action that the later byte of video data m-th byte is to be performed, described M is whole more than or equal to 1
Number.
Refering to Fig. 2 A or 2B, from initial state S0Start, being mated by state machine of byte-by-byte,
When m-th byte, arrive the first state machine accepts state S2, described M is the integer more than or equal to 1.
Each byte in matching process is to report CPU and storage to hard disk simultaneously, arrives after accepting state, obtains
Taking the action that the later byte of described video data m-th byte is to be performed, this action includes: do not report,
All report, skip stopping report and part report, the implication of each action can be indicated by numeral,
As 0 represent do not report, 1 represent all report, 2 representative parts report, 3 represent and skip stopping and reporting, for
The concrete meaning of digitized representation can be different, and the embodiment of the present invention does not limits.
104, according to the action that the byte that described m-th byte is later is to be performed, described m-th word is processed
Save later byte.
After obtaining the action that the later byte of described video data m-th byte is to be performed, according to this action
Implication determines the later byte of m-th byte, and how this processes.
The embodiment of the present invention uses the shape that the regular expression obtaining and storing description video data format is corresponding
State machine;Receive video data, and the video data received is passed through the first state machine word one by one of the first level
Joint mates;When matching m-th byte, arrive the state that accepts of described first state machine, obtain
The action that the later byte of described video data m-th byte is to be performed, described M is more than or equal to 1
Integer;According to the action that the byte that described m-th byte is later is to be performed, process described m-th byte with
After byte.Compared with prior art, the method that the embodiment of the present invention provides, newly increasing video data lattice
During formula, as long as being stored in FPGA the state machine that should increase video data format newly, it is possible to it is right to realize
The process of the video data of the form newly increased, it is not necessary to change hardware, thus save hardware resource, and
And need not diverter module shunting, also improve data-handling efficiency.
Alternatively, on the basis of the embodiment that above-mentioned Fig. 1 is corresponding, described according to described m-th byte with
After byte action to be performed, process the byte that described m-th byte is later, specifically include: when described
Action is not to give the correct time, and stores the byte that described m-th byte is later, and stops described m-th byte
Later byte reports processor.
Alternatively, on the basis of embodiment corresponding for above-mentioned Fig. 1 or the extension embodiment based on Fig. 1,
The action that the described byte later according to described m-th byte is to be performed, after processing described m-th byte
Byte, specifically include: when described action is given the correct time on all, store the word that described m-th byte is later
Joint, and byte later for described m-th byte is all reported processor.
Alternatively, on the basis of embodiment corresponding for above-mentioned Fig. 1 or the extension embodiment based on Fig. 1,
The action that the described byte later according to described m-th byte is to be performed, after processing described m-th byte
Byte, specifically include: when described action is given the correct time in stopping for skipping, need to skip according in described action
Byte number N, after skipping described N number of byte, store the byte that described the M+N byte is later, and will
The later byte of described M+N byte stops reporting processor, and described N is the integer more than or equal to 1.
Alternatively, on the basis of embodiment corresponding for above-mentioned Fig. 1 or the extension embodiment based on Fig. 1,
The action that the described byte later according to described m-th byte is to be performed, after processing described m-th byte
Byte, specifically include: when described action is to give the correct time in part, described action further indicates m-th word
Save the second state machine of later byte the second level to be proceeded to;By byte later for described m-th byte
Mated by described second state machine;Connecing of described second state machine is arrived when matching the X byte
During by state, obtaining the action that the later byte of the X byte of described video data is to be performed, described X is
Integer more than M;The action to be performed when the byte that described the X byte is later is not to give the correct time, by institute
State the X later byte of byte to stop reporting processor;The byte later when described the X byte is wanted
The action performed is given the correct time on all, and byte later for described the X byte is all reported processor;
The action to be performed when the byte that described the X byte is later is given the correct time in stopping for skipping, and skips needs and skips
Byte number Y after, stop reporting processor by later for described X+Y byte byte, Y is for being more than
In the integer of 1;When the action that the byte that described the X byte is later is to be performed is to give the correct time in part, then by
The state machine of more high-level proceeds coupling, until obtain described action for not reporting, all report or
Skip stopping to report.
In the embodiment of the present invention, when arriving when accepting state of the first state machine, get m-th byte with
After byte action to be performed report for part, illustrate that the video data of this form is also performed to the second level
State machine proceed coupling, specifically to enter the state machine of the second level, action has been made finger
Show, as action:2DFA2, expression state machine to be carried out DFA2 proceed coupling.
The heading of general video format is index file, it is only necessary to the state machine of the first level just can mate
To final result, such as: SiverLight, Apple HLS.If the heading of video format is not index literary composition
Part, then mean to comprise in message text the parameter for describing video contents, such as playback rate, these ginsengs
Number needs to report CPU, and when user's order video program, CPU passes through these state modulator video frequency programs
Play.The state machine of this needs the second level carries out the video format that mates such as: FLV.The present invention implements
In example, only give the state machine of two levels, indeed, it is possible to include the state machine of multiple level, when
When video format is complex, the place of the video data of this form can be completed by the state machine of multiple levels
Reason.
In order to make it easy to understand, below as a example by a concrete application scenarios, describe the embodiment of the present invention in detail
The detailed process that middle video data processes:
It is field programmable gate array 40(FPGA refering to Fig. 3, Fig. 3, Field Programmable Gate
Array) video data process is processed:
Step 1: state machine corresponding for the regular expression describing video data format is handed down to by processor 30
Random access memory (BRAM, Block random access memory) 201 in FPGA.
Step 2: after random access memory 201 gets state machine, delivers to state machine matching module 203 and stores.
Step 3: interface logic biock 202 receives video data, video data can obtain from video server.
Step 4: the video data received is delivered to enter in matching module 203 by interface logic biock 202 one by one
Row coupling, in matching module 203, storage has state machine, carries out byte one by one by the state machine of the first level
Coupling, matches m-th byte and arrives when accepting state, and the byte obtaining m-th byte later to perform
Action, M is the integer more than or equal to 1.According to this action executing step 5 and step 6.
Step 5: byte later for m-th byte is reported CPU.
Step 6: byte later for m-th byte is stored memorizer 204, this memorizer can be DDR3
Memorizer.
Detailed process according to this action executing step 5 and step 6 can understand refering to Fig. 4:
When the action matched in the first level state machine is not for report, then only carry out step 6, when
The action matched in one level states machine, for all to report, performs step 5 and step 6, first the most simultaneously
The action matched in level states machine reports for part, then proceed to the second level state machine, in the second level
What state machine arrived described second level state machine when matching nth byte accepts state, and N is more than M
Integer, match last result for not report, then perform step 6, simply by n-th word in step 6
Save later byte and store memorizer.After matching final result, state machine proceeds to idle condition.
The method that the embodiment of the present invention provides, when newly increasing video data format, as long as depositing in FPGA
Enter the state machine that should increase video data format newly, it is possible to realize the video data to the form newly increased
Process, it is not necessary to change hardware, thus save hardware resource.
The device that the data that the embodiment of the present invention provides process can be FPGA.
Refering to Fig. 5, an embodiment of the device that the data that the embodiment of the present invention provides process includes:
Acquiring unit 401, for obtaining the state machine that the regular expression describing video data format is corresponding;
Memory element 402, for storing the state machine that described acquiring unit 401 obtains;
Receive unit 403, be used for receiving video data;
Matching unit 404, for video data that described reception unit 403 is received by the first level the
One state machine byte-by-byte mates, when described match m-th byte time, arrive described first state
Machine accept state, obtain the action that the later byte of described video data m-th byte is to be performed, described
M is the integer more than or equal to 1;
Processing unit 405, the byte later for the m-th byte according to the acquisition of described acquiring unit 404 is wanted
The action performed, processes the byte that described m-th byte is later.
In the embodiment of the present invention, acquiring unit 401 obtains the regular expression correspondence describing video data format
State machine;Memory element 402 stores the state machine that described acquiring unit 401 obtains;Receive unit 403 to connect
Receive video data;Matching unit 404, passes through first for the video data received by described reception unit 403
First state machine byte-by-byte of level mates, when described match m-th byte time, arrive described
First state machine accept state, obtain to be performed dynamic of the later byte of described video data m-th byte
Making, described M is the integer more than or equal to 1;Processing unit 405, for according to described acquiring unit 404
The action that the later byte of m-th byte that obtains is to be performed, processes the word that described m-th byte is later
Joint.The device that the data that the embodiment of the present invention provides process, can be when newly increasing video data format, only
To be stored in the apparatus the state machine that should increase video data format newly, it is possible to realize newly increasing
The process of the video data of form, it is not necessary to change hardware.Thus save hardware resource.
On the basis of the embodiment that above-mentioned Fig. 5 is corresponding, the device that the data that the embodiment of the present invention provides process
Another embodiment also include:
Described processing unit 405, specifically for not being to give the correct time when described action, stores described m-th word
Save later byte, and stop byte later for described m-th byte is reported processor.
On the basis of embodiment corresponding for above-mentioned Fig. 5 or the extension embodiment based on Fig. 5, the present invention is real
Another embodiment of the device that the data that executing example provides process also includes:
Described processing unit 405, specifically for not being to give the correct time when described action, stores described m-th word
Save later byte, and stop byte later for described m-th byte is reported processor.
On the basis of embodiment corresponding for above-mentioned Fig. 5 or the extension embodiment based on Fig. 5, the present invention is real
Another embodiment of the device that the data that executing example provides process also includes:
Described processing unit 405, specifically for giving the correct time in stopping for skipping when described action, according to described dynamic
Work needs the byte number N skipped, after skipping described N number of byte, after storing described the M+N byte
Byte, and stop reporting processor by later for described M+N byte byte, described N is for being more than
In the integer of 1.
On the basis of embodiment corresponding for above-mentioned Fig. 5 or the extension embodiment based on Fig. 5, refering to Fig. 6,
When described action is to give the correct time in part, and further indicates the later byte of m-th byte in described action to proceed to
The second state machine of the second level;Another embodiment of the device that the data that the embodiment of the present invention provides process
Also include that described processing unit 405, described processing unit 405 include:
Coupling subelement 4051, is additionally operable to byte later for described m-th byte by described second state
Machine mates;
Obtain subelement 4052, be additionally operable to arrive institute when described coupling subelement 4051 matches the X byte
Stating when accepting state of the second state machine, the byte getting the X byte of described video data later to be held
The action of row, described X is the integer more than M;
Process subelement 4053, be additionally operable to described the X the byte when described acquisition subelement 4052 gets
The action that later byte is to be performed is not to give the correct time, and stops reporting by byte later for described the X byte
To processor;The action to be performed when the byte that described the X byte is later is given the correct time, by described on all
The later byte of the X byte all reports processor;The byte later when described the X byte to be held
The action of row is given the correct time in stopping for skipping, after skipping the byte number Y needing to skip, by described X+Y byte
Later byte stops reporting processor, and Y is the integer more than or equal to 1;After described the X byte
Byte action to be performed be to give the correct time in part, then proceeded coupling by the state machine of more high-level, directly
Report to obtaining described action for not reporting, all reporting or skip stopping.
The device that the data that the multiple embodiment of the present invention provides process, can newly increase video data format
Time, as long as being stored in the state machine that should increase video data format newly in the apparatus, it is possible to realize newly
The process of the video data of the form increased, it is not necessary to change hardware, thus save hardware resource, it is also possible to
Improve data-handling efficiency.
Refering to Fig. 7, the equipment that a kind of data that the embodiment of the present invention provides process includes processor 30 and data
The device 40 processed;
Described processor, for issuing the state machine that the regular expression describing video data format is corresponding, and
Receive the data that the device 40 of data process reports.
The device 40 that described data process, for obtaining and store the regular expression of description video data format
Corresponding state machine;Receive video data, and the video data received is passed through the first state of the first level
Machine byte-by-byte mates;When matching m-th byte, arrive described first state machine accepts shape
State, obtains the action that the later byte of described video data m-th byte is to be performed, described M for more than or
Integer equal to 1;According to the action that the byte that described m-th byte is later is to be performed, process described M
The byte that individual byte is later.
The equipment that the embodiment of the present invention provides, can be when newly increasing video data format, as long as at this device
In be stored in the state machine that should increase video data format newly, it is possible to realize video to the form newly increased
The process of data, it is not necessary to change hardware, thus save hardware resource, it is also possible to improve data-handling efficiency.
One of ordinary skill in the art will appreciate that all or part of step in the various methods of above-described embodiment
Suddenly the program that can be by completes to instruct relevant hardware, and this program can be stored in a computer-readable
In storage medium, storage medium may include that ROM, RAM, disk or CD etc..
Method, device and equipment that the video data provided the embodiment of the present invention above processes are carried out
Being discussed in detail, principle and the embodiment of the present invention are set forth by specific case used herein, with
The explanation of upper embodiment is only intended to help to understand method and the core concept thereof of the present invention;Simultaneously for this
The those skilled in the art in field, according to the thought of the present invention, the most all can
Change part, and in sum, this specification content should not be construed as limitation of the present invention.