Disclosure of Invention
In order to overcome the above-mentioned drawbacks, the present invention provides a method and an apparatus for performing buffer control on a live digital video stream, which performs buffer control on an MPEG4 image, and has high real-time performance.
In order to achieve the purpose, the invention adopts the following technical scheme: a method for carrying out buffer control on real-time digital video movie stream is used in MPEG4 video coding and decoding process, and comprises the following steps:
step A, sending a partial image area formed by one or more local correlation areas in a video movie stream frame of a real-time digital video movie stream to a data storage area with a preset size in a receiving state; simultaneously, recording the position of the partial image area in the video stream frame;
step B, performing ping-pong operation on the data storage area with the preset size in the receiving state and the data storage area with the preset size in the outputting state;
step C, outputting the partial image area stored in the data storage area in the output state according to the position of the partial image area in the video stream frame; wherein,
the method for dividing the local correlation area comprises the following steps: the video streaming frame is divided into a plurality of areas, the updating sequence in each area can be repeated, and the updating sequence between any two areas is not repeated, so that the area is determined to be the local correlation area.
Preferably: in the method for performing cache control on the real-time digital video stream, in the MPEG4 video coding process, the video stream frame is a video stream input frame; in the MPEG4 video decoding process, the video stream frames are decompressed output frames.
Preferably: in the method for performing cache control on a real-time digital video stream, when no deblocking effect exists, the division of the local relevance region specifically comprises: each 16 pixel rows in each frame is divided into a region of local correlation.
Preferably: in the method for performing cache control on the real-time digital video image stream, in a working mode in which a deblocking function is effective in a video decoding process, if a deblocking effect action area is positive and negative N pixel lines on two sides of a block boundary, the area division of the local correlation is specifically that, for a frame header part, N pixel lines are translated downwards from a frame header of each frame as a local correlation area, from the line N +1 downwards, every 16 pixel lines are used as a local correlation area, to a frame tail part, and from the frame tail upwards, 32-N pixel lines are used as a local correlation area, wherein N is a natural number, and the maximum value of N is 8.
Preferably: in the method for performing cache control on the real-time digital video movie stream, the physical size of the data storage area with the preset size is at least equal to the size of one maximum local relevance area.
Preferably: in the method for performing cache control on the real-time digital video streaming, the physical size of the data storage area with the preset size is equal to the size of a partial image area of a video streaming frame.
An apparatus for performing buffer control on real-time digital video stream, which is used in the MPEG4 video encoding and decoding process, comprises:
the data storage areas in the receiving state can be converted into the output state after receiving partial image areas formed by one or more local correlation areas in the video streaming frame, and the data storage areas in the output state can be converted into the input state after sending partial image areas formed by one or more local correlation areas in the video streaming frame;
a cache control module;
the buffer control module sends a partial image area formed by one or more local correlation areas in a video streaming frame to a data storage area with a preset size in a receiving state, and records the position of the partial image area in the video streaming frame; and outputting the partial image area stored in the data storage area with the preset size in the output state according to the position of the partial image area in the video stream frame.
Preferably: in the apparatus for performing cache control on a real-time digital video stream, the cache control module comprises: an address mapping unit, a transmission control unit and an output mapping unit,
the transmission control unit sends a partial image area formed by one or more local correlation areas in a video stream frame to a data storage area in a receiving state, controls the two data storage areas with preset sizes to carry out ping-pong operation, and enables the data storage area in an output state to output the partial image area;
the address mapping unit is used for recording the absolute address of the partial image area in the video stream frame and sending the absolute address to the output mapping unit through the transmission control unit; when the data storage area in the output state outputs a partial image area, the partial image area is output according to the absolute address of the partial image area in the video stream frame.
Preferably: in the device for performing cache control on the real-time digital video streaming, the physical size of the data storage area with the preset size is equal to the size of a partial image area of a video streaming frame.
The invention adds a partial image area buffer control mechanism at the periphery of a general MPEG4 compression and decompression module to replace the existing frame buffer control mechanism, and utilizes the buffer control module to send data to a data storage area by taking the partial image area of a video stream frame as a unit, and the data storage area carries out ping-pong operation by taking the partial image area as the unit and then outputs; therefore, only two buffer spaces with the size of partial image area are needed for storing and transmitting the digital video stream data, the hardware cost is greatly reduced, the MPEG4 compression and decompression technology is favorably applied to mobile communication equipment supporting larger image size, and the real-time performance of image data processing in the video stream is improved.
Detailed Description
The invention conception of the invention is as follows: and performing ping-pong operation in two data storage areas with preset sizes by taking a partial image area of a video stream frame of the real-time digital video stream as a unit. The partial image region includes at least one local correlation region.
The following explains the method of dividing the local correlation area by taking the output frame output by the MPEG4 video decompression module as an example: the decompressed output frames output by the MPEG4 video decompression module may be divided into several regions with local dependencies in the update order, i.e. within each region, the update order may be repeated one after the other, but there is no repetition of the update order between any two local dependency regions.
Referring to the output frame structure table, in MPEG4, the frame structure is shown in the following table:
that is, when encoding and decoding an image, the MPEG4 generally performs data processing in units of macroblocks (macro blocks) of 16 × 16 pixels, and divides image data of a decompressed output frame into a plurality of macroblocks (X, Y). MPEG4 video decompression is output in units of macroblocks in the order: (1, 1), (1, 2), (1, 3) … (1, N), (2, 1) … (M, 1) … (M, N), from macroblock (1, 1) to macroblock (1, N) referred to as a macroblock row, within each macroblock row the update order of the output data may be repeated jumping back and forth; there are no skip iterations between any two macroblock rows, i.e., there are no skip iterations between the first macroblock row and the second macroblock row or other macroblock rows. Therefore, the above macro block behavior can be said to have a region of local correlation.
In the MPEG4 video encoding process, the video stream frames described in the present invention are video stream input frames; in the MPEG4 video decoding process, the video stream frames described in the present invention are decompressed output frames.
Example 1
The embodiment is a method and a device applied to the MPEG4 video coding process.
Referring to fig. 5, in the MPEG4 video encoding process, the method for performing buffer control on the real-time digital video stream specifically includes the following steps:
step 1, sending a partial image area consisting of one or more local correlation areas in a video shadow stream input frame to a data storage area with a preset size in a receiving state; simultaneously, recording the position of the partial image area in the video movie stream input frame; in this embodiment, the local relevance region may include one or more macroblock rows. The physical size of the predetermined-sized data storage area may be equal to the size of one partial image area.
Step 2, after the partial image area of the data storage area in the receiving state is stored, the data storage area is converted into an output state; meanwhile, another data storage area with the preset size is converted into a receiving state, and the next partial image area is continuously received;
and 3, outputting the partial image area stored in the data storage area in the output state according to the position of the partial image area in the video movie stream input frame.
Referring to fig. 6, the apparatus for performing cache control on a real-time digital video stream includes: the device comprises a video movie stream input module, a cache control module, a system AHB bus, two data storage areas A and B with preset sizes and ping-pong operation with each other, and an MPEG4 video compression module; wherein, the buffer control module includes: the transmission control unit sends a partial image area formed by one or more local correlation areas in a video shadow stream input frame to a data storage area in a receiving state, controls two data storage areas with preset sizes to carry out ping-pong operation, and enables the data storage area in an output state to output the partial image area; the address mapping unit is used for recording the absolute address of a partial image area of the video movie stream input frame in the video movie stream input frame and sending the absolute address to the output mapping unit through the transmission control unit; and when the data storage area in the output state outputs the partial image area of the output frame, outputting the partial image area according to the absolute address of the partial image area in the video movie stream input frame.
The device for carrying out cache control on the real-time digital video movie stream works as follows:
1. video movie stream input module for outputting partial image area for the first time
When the video movie stream input module is ready to output video movie stream input frames, the system default data storage area A is a dynamic update storage area and is in a receivable state; the address mapping unit records the absolute address of a partial image area to be output (taking the partial image area as an example of a macro block line, the first output should be the first macro block line of the first frame) in the video movie stream input frame, then stores the first macro block line output by the video movie stream input module in the data storage area A through a system AHB bus, and simultaneously transmits the recorded absolute address of the first macro block line in the video movie stream input frame to the output mapping unit through the transmission control unit.
And stopping data transmission after the data in the data storage area A is updated. At this time, the transfer control unit puts the data storage area a into an outputable state, and puts the data storage area B into a receivable state because it has no data therein at this time.
2. The video shadow stream input module outputs partial image area for the second time
When the transmission control unit finds that the data storage area a is in an outputable state and the data storage area B is in a receivable state, the video movie input module prepares to output a second partial image area (a second macroblock line of the first frame).
The address mapping unit records the absolute address of the second macroblock row to be output in the video movie stream input frame, then stores the second macroblock row output by the video movie stream input module in the data storage area B via the system AHB bus, and simultaneously transmits the absolute address of the second macroblock row in the video movie stream input frame to the output mapping unit through the transmission control unit. And stopping data transmission after the data updating of the data storage area B is finished, and juxtaposing the data storage area B to be in an output available state.
And the data storage area A outputs the data to the display module according to the absolute address of the first partial image area stored in the output mapping unit in the video movie stream input frame while the data storage area B receives the data, and the data storage area A is set to be in a receivable state after the output is finished.
3. And repeating the steps until 1 to N output frames are output.
Example 2
The embodiment is a method and a device applied to the MPEG4 video decoding process.
As is well known to those skilled in the art, MPEG4 video decoding has a normal mode of operation and a "deblocking" mode of operation.
In a normal operation mode, the present embodiment may use the foregoing method to divide the local correlation area, that is, one local correlation area includes one or more macroblock rows.
While in the mode of operation where the "deblocking" function of the MPEG4 video decompression module is active (the live digital video stream is deblocked during decompression and is not deblocked during compression), referring to fig. 7, the data update of the decompressed output frame still has local correlation similar to the macroblock lines. At this time, if the deblocking effect region is positive and negative N pixel lines on both sides of the block boundary, the region of the local correlation is divided specifically by, for the frame header part, shifting N pixel lines downward from the frame header of each frame as a local correlation region, which is the smallest local correlation region in the frame; from N +1 lines downwards, every 16 pixel lines are taken as a local correlation area, and from the frame end part, 32-N pixel lines are taken from the frame end upwards as a local correlation area, wherein N is a natural number, and the maximum value of N is 8. This is the largest local correlation area in the frame, when the physical size of the predetermined size data storage area is at least equal to the size of one largest local correlation area.
For example: assuming that the region of "deblocking effect" is 8 pixel lines on both sides of the upper and lower boundaries of a 16X16 macroblock, the division of the region of local correlation should be shifted downward by 8 pixel lines from the head of each frame, so that the first region of local correlation in the frame is 8 pixel lines, the middle is 16 pixel lines, and the corresponding last region of local correlation is 24 pixel lines, and at this time, the physical size of the data storage region of the predetermined size is at least equal to the size of one maximum local correlation region (24 pixel lines).
Referring to fig. 8, in the MPEG4 video decoding process, the method for performing buffer control on the real-time digital video stream specifically includes the following steps:
firstly, a buffer control module outputs partial image areas of decompressed output frames output by a video decompression module to a data storage area with a preset size in a receiving state; meanwhile, the buffer control module records the mapping position of the partial image area in the decompression output frame;
after the data storage area in the receiving state stores partial image areas, the data storage area is switched to an output state, and the partial image areas stored in the data storage area are output to the display module; meanwhile, another data storage area with a preset size is converted into a receiving state under the control of the cache control module, and the next partial image area sent by the MPEG4 video decompression module is continuously received;
and thirdly, the display module displays the partial image area sent by the data storage area in the output state at the mapping position recorded by the cache control module.
Referring to fig. 9, in the MPEG4 video decoding process, the apparatus for performing buffer control on the real-time digital video stream includes: the system comprises an MPEG4 video decompression module, a cache control module, a system AHB bus, two data storage areas A and B with preset sizes and mutual ping-pong operation, and a display module; wherein, the buffer control module includes: the transmission control unit sends partial image areas of the decompressed output frame to a data storage area in a receiving state, controls the two data storage areas with preset sizes to carry out ping-pong operation, and enables the data storage area in the output state to output the partial image areas; the address mapping unit is used for recording the absolute address of a partial image area of the output frame in the output frame and sending the absolute address to the output mapping unit through the transmission control unit; when the data storage area in the output state is caused to output the partial image area of the decompressed output frame, the partial image area is output according to the absolute address of the partial image area in the decompressed output frame.
The device for carrying out cache control on the real-time digital video movie stream works as follows:
1. MPEG4 video decompression Module first outputs partial image regions
When the MPEG4 video decompression module is ready to output the decompressed output frame, the default data storage area A of the system is a dynamic update storage area which is in a receivable state; the address mapping unit records the absolute address of the partial image area to be output (the first macroblock line of the first frame should be output for the first time, taking the partial image area as an example of a macroblock line) in the decompressed output frame, then stores the first macroblock line decompressed and output by the MPEG4 video decompression module in the data storage a via the system AHB bus, and transmits the absolute address of the recorded first macroblock line in the decompressed output frame to the output mapping unit through the transmission control unit.
And stopping data transmission after the data in the data storage area A is updated. At this time, the transfer control unit puts the data storage area a into an outputable state, and puts the data storage area B into a receivable state because it has no data therein at this time.
2. MPEG4 video decompression Module outputs partial image regions a second time
When the transmission control unit finds that the data storage area a is in an outputable state and the data storage area B is in a receivable state, the MPEG4 video decompression block prepares to output a second partial image area (second macroblock line of the first frame).
The address mapping unit records the absolute address of the second macroblock line to be output in the decompressed output frame, and then stores the second macroblock line decompressed and output by the MPEG4 video decompression module in the data storage area B via the system AHB bus, and simultaneously transmits the absolute address of the second macroblock line in the decompressed output frame to the output mapping unit through the transmission control unit. And stopping data transmission after the data updating of the data storage area B is finished, and juxtaposing the data storage area B to be in an output available state.
And when the data storage area B receives the data, the data storage area A outputs the data to the display module according to the absolute address of the first partial image area stored in the output mapping unit in the decompression output frame, and after the output is finished, the data storage area A is set to be in a receivable state.
3. And repeating the steps until 1 to N output frames are output. (as shown in fig. 10).