Support the coded method that odd encoder form multi-process uses simultaneously
Technical field
The invention belongs to network multimedia data coding techniques field, specially network audio-video data encoding technique.
Background technology
Along with flourish in internet, applications of multimedia, the encoding and decoding technique of audio frequency and video increasingly comes into one's own.But it is existing
Encoding and decoding be mostly still employing conventional art, coordinate the output of single form with single input source, then carry out the mode that cross-thread is shared,
Carry out multithreading support.This technology makes each use the thread of code stream to be affected by coded format, it is impossible to according to heterogeneous networks ring
The demand output the most suitably audio, video data in border.
Summary of the invention
The problem existed for network audio-video data tradition encoding and decoding technique, it is many that the present invention proposes a kind of support odd encoder form
The coded method that process uses simultaneously, makes each use the thread of code stream not affected by coded format, can be according to heterogeneous networks
The demand output the most suitably audio, video data of environment.
For achieving the above object, the present invention proposes a kind of coded method supporting odd encoder form multi-process simultaneously to use, specifically
Step is as follows:
(1) data use process Pi to register to controlling pond, and log-on message is that data use process Pi desired data stream
Data form Ai;
(2) controlling pond is that data use process Pi to create record, and record information includes that data use process Pi, desired data
Form Ai, the desired data reading location RPi in data pool, currently writing position WPi in data pool, now WPi=
RPi;
(3) data coding module inquiry controls pond record, needs the data of form Ai as being found to have process Pi, then from control
Writing position WPi in current data pond is obtained in pond;
(4) data coding module obtains real time data from data acquisition module, starts Ai format encoder, to the data obtained
Encode, be written to the data after coding data pool WPi position, update writing position WPi simultaneously;
(5) data use process Pi to read data according to reading location RPi and writing position WPi in control pond from data pool, if
RPi is not equal to WPi, then read WPi position from data pool RPi position always, update reading location information RPi simultaneously, if
RPi is equal to WPi, then wait new data write;
(6) circulation performs step 3,4,5 steps, until data use process Pi to need not data, notice controls pond should
Data use the record information release of process Pi.
Further, in described step (5), if writing position WPi exceedes the maximum of data pool data field, then can be straight
Connect circulation.
Compared with existing encoding and decoding technique, a kind of coding staff supporting odd encoder form multi-process simultaneously to use that the present invention proposes
Method, can obtain the audio, video data of different-format, meets the demand of different network environments.
Accompanying drawing explanation
The system architecture diagram of Fig. 1 present invention;
The flow chart of Fig. 2 the inventive method.
Detailed description of the invention
The invention will be further described with embodiment below in conjunction with the accompanying drawings.
Fig. 1 show the system tray of a kind of coded method supporting odd encoder form multimode process simultaneously to use that the present invention proposes
Composition, uses process including data acquisition module, data coding module, data pool, control pond and several data.Data acquisition
Collection module is responsible for gathering audio, video data and is sent data coding module;Data coding module is internally installed multiple encoder, supports each
Planting the coding work of coded format, the data gathered are encoded and write data pool by the requirement according to controlling pond;Data pool is
The memory block of audio, video data, this region is the memory block of ring logical, places the audio, video data of different-format, and data pool connects
Receiving the data of data coding module and be supplied to data use process, data pool has two pointer WPi and RPi, and the former points to number
According to writing position, the latter points to the reading position of data;Data use process to be the process using audio, video data, work as needs
During data, to the form controlled needed for the registration of pond, according to controlling the current location information of data in pond, get from data pool
Data;Controlling pond is to control shared region, when data use process to need the coding using certain data, can carry out in this pond
Arrange, record demand information and the current state of this process, specifically include data use process Pi, desired data form Ai,
Desired data reading location RPi in data pool, currently writing position WPi in data pool, when certain data uses process to read
During data, reading location RPi can be updated, when data coding module thinks that data pool writes data, writing position WPi can be updated.
Fig. 2 show the flow chart of a kind of coded method supporting odd encoder form multi-process simultaneously to use that the present invention proposes, base
This work process is as follows:
(1) when data use process Pi to need to read data, registering to controlling pond, log-on message is that data use process
The data form Ai of Pi desired data stream;Turn (2nd) step
(2) controlling pond is that data use process Pi to create record, and record information includes that data use process Pi, desired data
Form Ai, the desired data reading location RPi in data pool, currently writing position WPi in data pool, now WPi=
RPi;Turn (3rd) step;
(3) data coding module inquiry controls pond record, needs the data of form Ai as being found to have process Pi, then from control
Obtain writing position WPi in current data pond in pond, turn (4th) step;Otherwise repeat (3rd) step;
(4) data coding module obtains real time data from data acquisition module, starts Ai format encoder, to the data obtained
Encode, be written to the data after coding data pool WPi position, update writing position WPi simultaneously;Turn (5th) step
(5) data use process Pi to read data according to reading location RPi and writing position RPi in control pond from data pool, if
RPi is not equal to WPi, then read WPi position from data pool RPi position always, updates reading location information RPi simultaneously, turns the
(6) step;If RPi is equal to WPi, then waits new data write, turn (4th) step;
(6) judge that data use whether process Pi also needs to read data, if desired, (4th) step of then walking around;As being not required to
Want data, then (7th) step of walking around;
(7) notice control pond discharges the record information of these data use process Pi and terminates.
If now there being process Pj to need the data stream of form Aj, flow process is identical with Pi.