Video frame fade-in/fade-out detection method and apparatus

A video frame fade-in/fade-out detection method is provided, the detection method includes: before motion search, performing inter-frame comparison on block direct current components in some rows of a picture or performing inter-frame comparison on block direct current components in a partial area of a picture; collecting statistics on an inter-frame comparison result; determining whether fade-in/fade-out exists, to choose whether prediction is in a weighted mode; and if it is detected, by means of inter-frame comparison on block direct current components on some rows, that no global fade-in/fade-out exists, selecting a partial area within a range of some detected rows to perform inter-frame comparison on block direct current components again, and detecting local fade-in/fade-out. In the present invention, fade-in/fade-out is detected under the premise that easy hardware implementation is ensured, which saves a bandwidth and improves block match accuracy; in addition, the present invention proposes a solution for local fade-in/fade-out.

TECHNICAL FIELD

The present invention relates to the field of communications technologies, and in particular, to a video frame fade-in/fade-out detection method and apparatus.

BACKGROUND

In modern times, as the living standard of people improves, video applications are increasingly widely applied in both Internet transmission and handheld terminal playback. However, because an existing transmission bandwidth is limited, it is required that a video bandwidth is compressed and the coding efficiency is improved as much as possible. In addition, some devices such as a television terminal have a high requirement on a frame rate during video playback, but a limited bandwidth determines that a high frame rate cannot be reached during transmission. Therefore, to achieve an effect of smooth playback, a frame rate conversion module or the like needs to be added, and in this case, effective video processing is required, so as to achieve an ideal effect.

In video technology application, because motion estimation is a common method for eliminating video redundancy, motion estimation is needed for both video coding and decoding and video processing. However, in a specific scenario, pixel based motion estimation match has a rather high requirement on pixel precision. If fade-in/fade-out or the like occurs, match accuracy is affected. Therefore, to improve motion estimation match accuracy, we need to detect a fade-in/fade-out scenario to perform effective processing.

A known method provides a video frame detection method, including collecting statistics on pixels of a single-frame picture of a video to obtain a histogram of the pixels of the picture, where the histogram identifies the number of occurrences of each pixel in a single-frame picture; comparing a relationship between histograms of contiguous frames to determine similarity of the histograms and an overall offset of an inter-frame direct current component. The method also includes determining whether fade-in/fade-out exists in a current video frame; and if the fade-in/fade-out exists, using a weighted prediction method during motion estimation match, so as to improve match accuracy.

It is found that this method has at least the following defects. First, in this method, entire-frame detection needs to be first performed according to a current picture and a reference frame, and processing is then performed; therefore, a delay exists. Second, during hardware implementation, a picture needs to be first loaded to perform fade-in/fade-out detection, and picture data needs to be loaded again during motion estimation match; therefore, the burden of bandwidth is increased. Finally, in this method, only a global fade-in/fade-out case is considered, and detection and processing on local fade-in/fade-out cannot be performed.

Another known method considers both global fade-in/fade-out and local fade-in/fade-out. The method includes calculating a residual by using both a direct match method and a weighted prediction method during motion estimation match, then comparing the residuals of the two methods; and then selecting a method having a smaller residual, and marking whether weighted prediction is used.

According to this method, the inventor finds that defects of this method are also rather obvious. That is, if this prior art is applied to the frame rate conversion module, this method is very likely to cause wrong estimation on local fade-in/fade-out in a case without local fade-in/fade-out, thereby affecting motion vector calculation accuracy.

SUMMARY

According to a first aspect, a video frame fade-in/fade-out detection method is provided. The method includes acquiring pixel luminance information within a preset area of a current video frame, and calculating, on a block basis according to the acquired pixel luminance information within the preset area of the current video frame, a direct current component of a unit pixel block located within the preset area of the current video frame, to acquire the block direct current component of the unit pixel block. The method also includes acquiring pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the preset area of the current video frame. The method also includes calculating a block direct current component of the reference pixel block according to the pixel luminance information of the reference pixel block; comparing the acquired block direct current component of the unit pixel block located within the preset area of the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame. The method also includes collecting statistics on a comparison result of the direct current components, and determining, according to a statistics collection result, whether fade-in/fade-out exists; and marking, when it is detected that fade-in/fade-out exists, a current to-be-processed object, so that motion match is performed by using a weighted prediction mode.

With reference to the first aspect, in a first possible implementation manner of the first aspect, the comparing the acquired block direct current component of the unit pixel block located within the preset area of the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame includes: comparing the block direct current component DC0ijof the unit pixel located within the preset area of the current video frame with the direct current component DC1ij, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame, to fFlagij, where fFlagijis obtained according to the following relation:

fFlagij={1D⁢⁢C⁢⁢0ij<D⁢⁢C⁢⁢1ij0D⁢⁢C⁢⁢0ij>D⁢⁢C⁢⁢1ij;
and
Correspondingly, the collecting statistics on a comparison result of the direct current components, and determining, according to a statistics collection result, whether fade-in/fade-out exists includes separately collecting, according to the following formulas, statistics on a quantity fiNumgof unit pixels within the preset area of the current video frame and satisfying that the block direct current component DC0ijis less than the direct current component DC1ij, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame, and a quantity foNumgof unit pixels within the preset area of the current video frame and satisfying that the block direct current component DC0ijis greater than the direct current component DC1ij, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame.
fiNumg=ΣfFlagij; and
foNumg=Σ(1−fFlagij); and

if fiNumg>R or foNumg>R, determining that fade-in/fade-out exists in the unit pixel block within the preset area of the current video frame, where R is a preset threshold for determining fade-in/fade-out.

With reference to the first aspect or the first possible implementation manner of the first aspect, in a second possible implementation manner, the acquiring pixel luminance information within a preset area of a current video frame includes acquiring the pixel luminance information within a range of a current row and total L surrounding rows within the current video frame. The calculating, on a block basis according to the acquired pixel luminance information within the preset area of the current video frame, a direct current component of a unit pixel block located within the preset area of the current video frame, to acquire the block direct current component of the unit pixel block includes calculating, on a block basis according to the pixel luminance information within the range of the current row and the total L surrounding rows within the current video frame, a direct current component of a unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame, to acquire the block direct current component of the unit pixel block. The acquiring pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the preset area of the current video frame includes acquiring pixel luminance information of a reference pixel block, in the reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame. The comparing the acquired block direct current component of the unit pixel block located within the preset area of the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame includes comparing the acquired block direct current component of the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame. The marking, when it is detected that fade-in/fade-out exists, a current to-be-processed object, so that motion match is performed by using a weighted prediction mode includes marking all unit pixel blocks located within the current row within the current video frame, so that the motion match is performed by using the weighted prediction mode.

With reference to the second possible implementation manner of the first aspect, in a third possible implementation manner, R is calculated according to the following relation:
R=L*(width−D0)
where L is the acquired current row and total L surrounding rows within the current video frame, width is a quantity of blocks in one row of a frame picture, and D0is an error value of a quantity of blocks, in one row, having a letter box.

With reference to the second possible implementation manner of the first aspect, in a fourth possible implementation manner, if it is detected that no fade-in/fade-out exists, the acquiring pixel luminance information within a preset area of a current video frame further includes acquiring, within the range of the detected current row and total L surrounding rows within the current frame, the pixel luminance information within a rectangular area whose center is a current block and that has a predetermined size. The calculating, on a block basis according to the acquired pixel luminance information within the preset area of the current video frame, a direct current component of a unit pixel block located within the preset area of the current video frame, to acquire the block direct current component of the unit pixel block includes calculating, on a block basis according to the acquired pixel luminance information that is acquired within the range of the detected current row and total L surrounding rows within the current frame and that is within the rectangular area whose center is the current block and that has the predetermined size, a direct current component of a unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size, to acquire the block direct current component of the unit pixel block. The acquiring pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the preset area of the current video frame includes acquiring pixel luminance information of a reference pixel block, in the reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size. The comparing the acquired block direct current component of the unit pixel block located within the preset area of the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame includes comparing the acquired block direct current component of the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size. The marking, when it is detected that fade-in/fade-out exists, a current to-be-processed object, so that motion match is performed by using a weighted prediction mode includes marking a current unit pixel block located within the current video frame, so that the motion match is performed by using the weighted prediction mode.

With reference to the first aspect or the first possible implementation manner of the first aspect, in a fifth possible implementation manner, the acquiring pixel luminance information within a preset area of a current video frame further includes acquiring the pixel luminance information within a rectangular area whose center is a current block, that has a predetermined size, and that is set within the current video frame. The calculating, on a block basis according to the acquired pixel luminance information within the preset area of the current video frame, a direct current component of a unit pixel block located within the preset area of the current video frame, to acquire the block direct current component of the unit pixel block further includes calculating, on a block basis according to the pixel luminance information within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame, a direct current component of a unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame, to acquire the block direct current component of the unit pixel block; the acquiring pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the preset area of the current video frame includes acquiring pixel luminance information of a reference pixel block, in the reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame. The comparing the acquired block direct current component of the unit pixel block located within the preset area of the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame includes comparing the acquired block direct current component of the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame. The marking, when it is detected that fade-in/fade-out exists, a current to-be-processed object, so that motion match is performed by using a weighted prediction mode includes marking a current unit pixel block located within the current video frame, so that the motion match is performed by using the weighted prediction mode.

With reference to the fifth possible implementation manner of the first aspect, in a sixth possible implementation manner, R is calculated according to the following relation:
R=blkNums−D1;
where blkNums is a quantity of blocks within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame, and D1is an allowed error quantity of blocks.

According to a second aspect, a video frame fade-in/fade-out detection apparatus is provided, including a first acquiring unit, configured to acquire pixel luminance information within a preset area of a current video frame. Also included is a first calculation unit, configured to calculate, on a block basis according to the acquired pixel luminance information within the preset area of the current video frame, a direct current component of a unit pixel block located within the preset area of the current video frame, to acquire the block direct current component of the unit pixel block. Also included is a second acquiring unit, configured to acquire pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the preset area of the current video frame. Also included is a second calculation unit, configured to calculate a block direct current component of the reference pixel block according to the pixel luminance information of the reference pixel block. Also included is a first comparison unit, configured to compare the acquired block direct current component of the unit pixel block located within the preset area of the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame. Also included is a first determining unit, configured to collect statistics on a comparison result of the direct current components, and determine, according to a statistics collection result, whether fade-in/fade-out exists. Also included is a first processing unit, configured to, when it is detected that fade-in/fade-out exists, mark a current to-be-processed object, so that motion match is performed by using a weighted prediction mode.

With reference to the second aspect, in a first possible implementation manner of the second aspect, the first comparison unit is specifically configured to compare the block direct current component DC0ijof the unit pixel located within the preset area of the current video frame with the direct current component DC1ij, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame, to obtain fFlagij, where fFlagijis obtained according to the following relation:

fFlagij={1D⁢⁢C⁢⁢0ij<D⁢⁢C⁢⁢1ij0D⁢⁢C⁢⁢0ij>D⁢⁢C⁢⁢1ij
Correspondingly, the first determining unit is specifically configured to separately collect, according to the following formulas, statistics on a quantity fiNumgof unit pixels within the preset area of the current video frame and satisfying that the block direct current component DC0ijis less than the direct current component DC1ij, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame, and a quantity foNumgof unit pixels within the preset area of the current video frame and satisfying that the block direct current component DC0ijis greater than the direct current component DC1ij, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame:
fiNumg=ΣfFlagij; and
foNumg=Σ(1−fFlagij); and

if fiNumg>R or foNumg>R, determine that fade-in/fade-out exists in the unit pixel block within the preset area of the current video frame, where R is a preset threshold for determining fade-in/fade-out.

With reference to the second aspect or the first possible implementation manner of the second aspect, in a second possible implementation manner, the first acquiring unit includes a first acquiring subunit, and the first acquiring subunit is configured to acquire the pixel luminance information within a range of a current row and total L surrounding rows within the current video frame. Correspondingly, the first calculation unit is further configured to calculate, on a block basis according to the pixel luminance information within the range of the current row and the total L surrounding rows within the current video frame, a direct current component of a unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame, to acquire the block direct current component of the unit pixel block. The second acquiring unit is further configured to acquire pixel luminance information of a reference pixel block, in the reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame. The first comparison unit is further configured to: compare the acquired block direct current component of the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame. The first processing unit is further configured to mark all unit pixel blocks located within the current row within the current video frame, so that the motion match is performed by using the weighted prediction mode.

With reference to the second possible implementation manner of the second aspect, in a third possible implementation manner, R is calculated by using the following formula:
R=L*(width−D0),
where L is the acquired current row and total L surrounding rows within the current video frame, width is a quantity of blocks in one row of a frame picture, and D0is an error value of a quantity of blocks, in one row, having a letter box.

With reference to the second possible implementation manner of the second aspect, in a fourth possible implementation manner, if the first determining unit detects that no fade-in /fade-out exists, the first acquiring unit further includes a second acquiring subunit, and the second acquiring subunit is configured to acquire, within the range of the detected current row and total L surrounding rows within the current frame, the pixel luminance information within a rectangular area whose center is a current block and that has a predetermined size. Correspondingly, the first calculation unit is further configured to calculate, on a block basis according to the acquired pixel luminance information that is acquired within the range of the detected current row and total L surrounding rows within the current frame and that is within the rectangular area whose center is the current block and that has the predetermined size, a direct current component of a unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size, to acquire the block direct current component of the unit pixel block. The second acquiring unit is further configured to: acquire pixel luminance information of a reference pixel block, in the reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size. The first comparison unit is further configured to compare the acquired block direct current component of the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size; and the first processing unit is further configured to mark a current unit pixel block located within the current video frame, so that the motion match is performed by using the weighted prediction mode.

With reference to the second aspect or the first possible implementation manner of the second aspect, in a fifth possible implementation manner, the first acquiring unit is further configured to acquire the pixel luminance information within a rectangular area whose center is a current block, that has a predetermined size, and that is set within the current video frame. Correspondingly, the first calculation unit is further configured to calculate, on a block basis according to the pixel luminance information within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame, a direct current component of a unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame, to acquire the block direct current component of the unit pixel block. The second acquiring unit is further configured to acquire pixel luminance information of a reference pixel block, in the reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame. The first comparison unit is further configured to compare the acquired block direct current component of the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame. The first processing unit is further configured to mark a current unit pixel block located within the current video frame, so that the motion match is performed by using the weighted prediction mode.

With reference to the fifth possible implementation manner of the second aspect, in a sixth possible implementation manner, R is calculated according to the following relation:
R=blkNums−D1,
where blkNums is a quantity of blocks within the rectangular area whose center is the current block, hat has the predetermined size, and that is set within the acquired current video frame, and D1is an allowed error quantity of blocks.

Beneficial effects are as follows. In the video frame fade-in/fade-out detection method and apparatus provided, pixel luminance information within a preset area of a current video frame is acquired, and meanwhile, a direct current component of a unit pixel block is calculated according to the acquired pixel luminance information. Moreover, once a block is acquired, the block is detected, and processing is performed in time, and no entire-frame detection needs to be performed on a current picture before processing, thereby avoiding a delay caused by the fact that in the prior art, entire-frame detection is performed before processing. Moreover, pixel luminance information is acquired, and meanwhile, a direct current component of a unit pixel block is calculated; fade-in/fade-out is detected, and meanwhile, whether to perform weighted prediction is determined in time. Therefore, this synchronous running mode enables the method to save a sum of bandwidths resulting from hardware implementation and motion estimation. Finally, because fade-in/fade-out is detected in time and processing is performed in time, motion estimation match accuracy is improved.

DETAILED DESCRIPTION OF ILLUSTRATIVE EMBODIMENTS

This embodiment provides a video frame fade-in/fade-out detection method100. Referring toFIG. 1, the method specifically includes the following steps.

S110: Acquire pixel luminance information within a preset area of a current video frame.

S111: Calculate, on a block basis according to the acquired pixel luminance information within the preset area of the current video frame, a direct current component of a unit pixel block located within the preset area of the current video frame, to acquire the block direct current component of the unit pixel block.

S112: Acquire pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the preset area of the current video frame.

S113: Calculate a block direct current component of the reference pixel block according to the pixel luminance information of the reference pixel block.

S114: Compare the acquired block direct current component of the unit pixel block located within the preset area of the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame.

S115: Collect statistics on a comparison result of the direct current components, and determine, according to a statistics collection result, whether fade-in/fade-out exists.

S116: When it is detected that fade-in/fade-out exists, mark a current to-be-processed object, so that motion match is performed by using a weighted prediction mode.

In the video frame fade-in/fade-out detection method100provided in this embodiment, pixel luminance information within a preset area of a current video frame is acquired, and meanwhile, a direct current component of a unit pixel block is calculated according to the acquired pixel luminance information. Moreover, once a block is acquired, the block is detected, and processing is performed in time, and no entire-frame detection needs to be performed on a current picture before processing, thereby avoiding a delay caused by the fact that in the prior art, entire-frame detection is performed before processing. Moreover, pixel luminance information is acquired, and meanwhile, a direct current component of a unit pixel block is calculated; fade-in/fade-out is detected, and meanwhile, whether to perform weighted prediction is determined in time. Therefore, this synchronous running mode enables the method to save a sum of bandwidths resulting from hardware implementation and motion estimation. Finally, because fade-in/fade-out is detected in time and processing is performed in time, motion estimation match accuracy is improved. Therefore, the method provided in this embodiment achieves beneficial effects of avoiding a delay, saving a bandwidth, and improving motion estimation match accuracy.

This embodiment provides another video frame fade-in/fade-out detection method200. Referring toFIG. 2AandFIG. 2B, specifically, step S110in implementation manner1of the present invention specifically includes the following steps.

S210: Acquire pixel luminance information within a range of a current row and total L surrounding rows within a current video frame.

S211: Calculate, on a block basis according to the pixel luminance information within the range of the current row and the total L surrounding rows within the current video frame, a direct current component of a unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame, to acquire the block direct current component of the unit pixel block.

Specifically, step S210of acquiring pixel luminance information may specifically include the following steps: setting a size of a search window to H*M, and a size of a block to N*N; and based on the block with the size of N*N, loading pixel luminance information of the first N rows of the current frame, where a video format is generally YUV, and in this case, a loaded pixel component is luminance information Y.

Specifically, step S211of calculating a block direct current component may specifically include the following steps: calculating an average value of pixel luminance information Y of each macroblock that is obtained by dividing the loaded rows according to the size of N*N, and using the average value as a direct current component DC00of the macroblock, that is:

1N2⁢∑i,j⁢Yij;
and
loading pixel luminance information of the second N rows, and calculating a block direct current component DC01; loading pixel luminance information of the third N rows, and calculating a block direct current component DC02; and loading pixel luminance information of the LthN rows, and calculating a block direct current component DC0L.

S212: Acquire pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame.

S213: Calculate a block direct current component of the reference pixel block according to the pixel luminance information of the reference pixel block.

Specifically, specific steps of step S212are the same as those of S210of acquiring pixel luminance information.

Specifically, specific steps of step S213are the same as those of S211of calculating a block direct current component.

S214: Compare the acquired block direct current component of the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame with the direct current component of the reference pixel block, in the reference frame, corresponding to the unit pixel block within the range of the current row and the total L surrounding rows within the current video frame.

Specifically, step S214of comparing the block direct current components includes the following steps: determining a range within the L rows according to a current macroblock and based on a width of a picture and a height of the search window; comparing a direct current component DC0ijof a current block of the current frame with a direct current component DC1ijof a block at a corresponding location of the reference frame, to obtain fFlagij, where fFlagijis obtained according to the following relation:

S215: Collect statistics on a comparison result of the direct current components, and determine, according to a statistics collection result, whether fade-in/fade-out exists, which specifically includes the following steps.

Specifically, step S215of determining whether fade-in/fade-out exists includes the following steps: collecting statistics on the comparison result of the direct current components, collecting statistics on a quantity fiNumgof current blocks, of the current frame, satisfying that a direct current component DC0ijis less than a direct current component DC1ijof a block at a corresponding location of the reference frame, and similarly collecting statistics on a quantity foNumgof current blocks, of the current frame, satisfying that a direct current component DC0ijis greater than a direct current component DC1ijof a block at a corresponding location of the reference frame, where
fiNumg=ΣfFlagij; and
foNumg=Σ(1−fFlagij); and

if fiNumg>R or foNumg>R, considering that fade-in/fade-out exists in a current row, determining that the fade-in/fade-out is global fade-in/fade-out, and performing step216; or

if fiNumg≤R and foNumg≤R , considering that no global fade-in/fade-out exists in a current row, and performing step S217,

where R=L*(width−D0), L is the acquired current row and total L surrounding rows within the current video frame, width is a quantity of blocks in one row of a frame picture, and D0is an error value of a quantity of blocks, in one row, having a letter box.

S216: When it is detected that fade-in/fade-out exists in a current row, consider that global fade-in/fade-out exists, and mark all unit pixel blocks in the current row, so that a weighted prediction mode is used during motion match.

S217: When it is detected that no global fade-in/fade-out exists, acquire, within the range of the detected current row and total L surrounding rows within the current frame, the pixel luminance information within a rectangular area whose center is a current block and that has a predetermined size.

Specifically, specific steps of step S217of acquiring pixel luminance information are the same as those of S210.

S218: Calculate, on a block basis according to the acquired pixel luminance information that is acquired within the range of the current row and total L surrounding rows within the current frame and that is within the rectangular area whose center is the current block and that has the predetermined size, a direct current component of a unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size, to acquire the block direct current component of the unit pixel block.

Specifically, specific steps of step S218of calculating a block direct current component are the same as those of S211.

S219: Acquire pixel luminance information of a reference pixel block, in the reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size.

Specifically, specific steps of step S219of acquiring pixel luminance information are the same as those of S210.

S220: Calculate a block direct current component of the reference pixel block according to the pixel luminance information of the reference pixel block.

Specifically, specific steps of step S220of calculating a block direct current component are the same as those of S211.

S221: Compare the acquired block direct current component of the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size.

Specifically, specific steps of step S221of comparing the block direct current components include: determining a range within the L rows according to a current macroblock and based on a width of a picture and a height of the search window; comparing a direct current component DC0ijof the current block of the current frame with a direct current component DC1ijof a block at a corresponding location of the reference frame, to obtain fFlagij, where fFlagijis obtained according to the following relation:

S222: Collect statistics on a comparison result of the direct current components, and determine, according to a statistics collection result, whether fade-in/fade-out exists.

Specifically, specific steps of step S222of collecting statistics on the comparison result of the block direct current components include: collecting statistics on the comparison result of the direct current components, collecting statistics on a quantity fiNumgof current blocks, of the current frame, satisfying that a direct current component DC0ijis less than a direct current component DC1ijof a block at a corresponding location of the reference frame, and collecting statistics on a quantity foNumgof current blocks, of the current frame, satisfying that a direct current component DC0ijis greater than a direct current component DC1ijof a block at a corresponding location of the reference frame, where
fiNumg=ΣfFlagij; and
foNumg=Σ(1−fFlagij); and

if fiNumg>R or foNumg>R, considering that fade-in/fade-out exists in a current to-be-processed block, determining that the fade-in/fade-out is local fade-in/fade-out, and performing step223, where a size of a local area is P*Q, P and Q are natural numbers greater than 1, and Q is less than the height of the search window, and ensures that the local area is within the picture; and R=blkNums−D1, where blkNum: is a quantity of macroblocks within the local area, and D1is an allowed error quantity of blocks.

S223: Mark a current to-be-processed block, so that the weighted prediction mode is used during motion match.

In the video frame fade-in/fade-out detection method200provided in this embodiment of the present invention, pixel luminance information within a range of a current row and total L surrounding rows within a current video frame is acquired, and meanwhile, a direct current component of a unit pixel block is calculated according to the acquired pixel luminance information. Moreover, once a block is acquired, the block is detected, and processing on a current to-be-processed row is performed in time, and no entire-frame detection needs to be performed on a current picture before processing, thereby avoiding a delay caused by the fact that in the prior art, entire-frame detection is performed before processing. Moreover, pixel luminance information is acquired, and meanwhile, a direct current component of a unit pixel block is calculated; fade-in/fade-out is detected, and meanwhile, whether to perform weighted prediction is determined in time; therefore, this synchronous running mode enables the method to save a sum of bandwidths resulting from hardware implementation and motion estimation. Finally, because fade-in/fade-out is detected in time and processing is performed in time, motion estimation match accuracy is improved. In a case in which it is detected that no fade-in/fade-out exists in the current row, the pixel luminance information within a rectangular area whose center is a current block and that has a predetermined size is further acquired within the range of the detected current row and total L surrounding rows within the current frame, and a direct current component of a unit pixel block is synchronously calculated according to the acquired pixel luminance information. Moreover, once a block is acquired, the block is detected, and processing on a current to-be-processed block is performed in time, and no entire-frame detection needs to be performed on a current picture before processing, thereby avoiding a delay caused by the fact that in the prior art, entire-frame detection is performed before processing. Moreover, pixel luminance information is acquired, and meanwhile, a direct current component of a unit pixel block is calculated; fade-in/fade-out is detected, and meanwhile, whether to perform weighted prediction is determined in time; therefore, this synchronous running mode enables the method to save a sum of bandwidths resulting from hardware implementation and motion estimation. Finally, because fade-in/fade-out is detected in time and processing is performed in time, motion estimation match accuracy is improved. Therefore, the method provided in this embodiment achieves beneficial effects of avoiding a delay, saving a bandwidth, and improving motion estimation match accuracy. Moreover, fade-in/fade-out detection is first performed on the current to-be-processed row of some rows, and block fade-in/fade-out detection is further performed, in the rectangular area whose center is the current block, that has the predetermined size, and that is within the rows, on the current to-be-processed block. The method further reduces a detection amount, thereby performing processing more quickly, further avoiding a delay and saving a bandwidth, and further improving motion estimation match accuracy.

This embodiment provides still another video frame fade-in/fade-out detection method300. Referring toFIG. 3, specifically, step S110in implementation manner1of the present invention specifically includes the following steps.

S310: Acquire pixel luminance information within a rectangular area whose center is a current block, that has a predetermined size, and that is set within a current video frame.

S311: Calculate, on a block basis according to the pixel luminance information within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame, a direct current component of a unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame, to acquire the block direct current component of the unit pixel block.

Specifically, step S310of acquiring pixel luminance information may specifically include the following steps: setting a size of a search window to H*M, and a size of a block to N*N; and based on the block with the size of N*N, loading pixel luminance information of the first N rows of the current frame, where a video format is generally YUV, and in this case, a loaded pixel component is luminance information Y.

Specifically, step S311of calculating a block direct current component may specifically include the following steps: calculating an average value of pixel luminance information Y of each macroblock that is obtained by dividing the loaded rows according to the size of N*N, and using the average value as a direct current component DC00of the macroblock, that is,

1N2⁢∑i,j⁢Yij;
and
loading pixel luminance information of the second N rows, and calculating a block direct current component DC01; loading pixel luminance information of the third N rows, and calculating a block direct current component DC02; and loading pixel luminance information of the LthN rows, and calculating a block direct current component DC0L.

S312: Acquire pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame.

S313: Calculate a block direct current component of the reference pixel block according to the pixel luminance information of the reference pixel block.

Specifically, specific steps of step S312are the same as those of S310of acquiring pixel luminance information.

Specifically, specific steps of step S313are the same as those of S311of calculating a block direct current component.

S314: Compare the acquired block direct current component of the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame.

Specifically, step S314includes the following steps: determining a range of a rectangular area of a size according to a current macroblock and based on a width of a picture and a height of the search window; comparing a direct current component DC0ijof the current block of the current frame with a direct current component DC1ijof a block that is at a corresponding location of the reference frame and that is pointed at by a time-domain motion vector of the current block (if the location of the corresponding block, which is pointed at, of the reference frame exceeds the search window, a block, closest to the corresponding block, within the search window is acquired), to obtain fFlagij, where fFlagijis obtained by using the following equation:

S315: Collect statistics on a comparison result of the direct current components, and determine, according to a statistics collection result, whether fade-in/fade-out exists, which specifically includes the following steps:

Specifically, step S315includes the following steps: collecting statistics on the comparison result of the direct current components, collecting statistics on a quantity fiNumgof macroblocks that are among all macroblocks within a local area whose center is a current block of the current frame and that satisfy that a direct current component DC0ijis less than direct current components DC1ijof all macroblocks within a local area whose center is a block at a specified location of the reference frame, and similarly collecting statistics on a quantity foNumgof macroblocks that are among all macroblocks within a local area whose center is a current block of the current frame and that satisfy that a direct current component DC0ijis greater than direct current components DC1ijof all macroblocks within a local area whose center is a block at a specified location of the reference frame, where
fiNumg=ΣfFlagij; and
foNumg=Σ(1−fFlagij); and

if fiNumg>R or foNumg>R, considering that fade-in/fade-out exists in a current to-be-processed block, determining that the fade-in/fade-out is local fade-in/fade-out, and performing step316, where a size of a local area is P×Q, P and Q are natural numbers greater than 1, and Q is less than the height of the search window, and ensures that the local area is within the picture; and R=blkNums−D1, where blkNums is a quantity of macroblocks within the local area, and D1is an allowed error quantity of blocks.

S316: Mark a current to-be-processed block, so that a weighted prediction mode is used during motion match.

In the video frame fade-in/fade-out detection method300provided in this embodiment of the present invention, pixel luminance information within a rectangular area whose center is a current block, that has a predetermined size, and that is set within a current video frame is acquired, and meanwhile, a direct current component of a unit pixel block is calculated according to the acquired pixel luminance information. Moreover, once a block is acquired, the block is detected, and processing on a current to-be-processed block is performed in time, and no entire-frame detection needs to be performed on a current picture before processing, thereby avoiding a delay caused by the fact that in the prior art, entire-frame detection is performed before processing. Moreover, pixel luminance information is acquired, and meanwhile, a direct current component of a unit pixel block is calculated; fade-in/fade-out is detected, and meanwhile, whether to perform weighted prediction is determined in time; therefore, this synchronous running mode enables the method to save a sum of bandwidths resulting from hardware implementation and motion estimation. Finally, because fade-in/fade-out is detected in time and processing is performed in time, motion estimation match accuracy is improved. Therefore, the method provided in this embodiment achieves beneficial effects of avoiding a delay, saving a bandwidth, and improving motion estimation match accuracy.

This embodiment further provides a video frame fade-in/fade-out detection apparatus400. Referring toFIG. 4, the apparatus specifically includes a first acquiring unit410, configured to acquire pixel luminance information within a preset area of a current video frame. Also included is a first calculation unit411, configured to calculate, on a block basis according to the acquired pixel luminance information within the preset area of the current video frame, a direct current component of a unit pixel block located within the preset area of the current video frame, to acquire the block direct current component of the unit pixel block. Also included is a second acquiring unit412, configured to acquire pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the preset area of the current video frame. Also included is a second calculation unit413, configured to calculate a block direct current component of the reference pixel block according to the pixel luminance information of the reference pixel block. Also included is a first comparison unit414, configured to compare the acquired block direct current component of the unit pixel block located within the preset area of the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the preset area of the current video frame. Also included is a first determining unit415, configured to collect statistics on a comparison result of the direct current components, and determine, according to a statistics collection result, whether fade-in/fade-out exists. Also included is a first processing unit416, configured to, when it is detected that fade-in/fade-out exists, mark a current to-be-processed object, so that motion match is performed by using a weighted prediction mode.

In the video frame fade-in/fade-out detection apparatus400provided in this embodiment, pixel luminance information within a preset area of a current video frame is acquired, and meanwhile, a direct current component of a unit pixel block is calculated according to the acquired pixel luminance information. Moreover, once a block is acquired, the block is detected, and processing is performed in time, and no entire-frame detection needs to be performed on a current picture before processing, thereby avoiding a delay caused by the fact that in the prior art, entire-frame detection is performed before processing. Moreover, pixel luminance information is acquired, and meanwhile, a direct current component of a unit pixel block is calculated; fade-in/fade-out is detected, and meanwhile, whether to perform weighted prediction is determined in time; therefore, this synchronous running mode enables the method to save a sum of bandwidths resulting from hardware implementation and motion estimation. Finally, because fade-in/fade-out is detected in time and processing is performed in time, motion estimation match accuracy is improved. Therefore, the method provided in this embodiment achieves beneficial effects of avoiding a delay, saving a bandwidth, and improving motion estimation match accuracy.

This embodiment provides another video frame fade-in/fade-out detection apparatus500. Referring toFIG. 5aandFIG. 5b, specifically, a first acquiring unit510includes a first acquiring subunit510aand a second acquiring subunit510b.

The first acquiring subunit510ais configured to acquire pixel luminance information within a range of a current row and total L surrounding rows within a current video frame.

Correspondingly, a first calculation unit511is configured to calculate, on a block basis according to the pixel luminance information within the range of the current row and the total L surrounding rows within the current video frame, a direct current component of a unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame, to acquire the block direct current component of the unit pixel block.

Specifically, the acquiring pixel luminance information by the first acquiring subunit510ais specifically: setting a size of a search window to H*M, and a size of a block to N*N; and based on the block with the size of N*N, loading pixel luminance information of the first N rows of the current frame, where a video format is generally YUV, and in this case, a loaded pixel component is luminance information Y.

Specifically, the calculating a block direct current component by the first calculation unit511may be specifically: calculating an average value of pixel luminance information Y of each macroblock that is obtained by dividing the loaded rows according to the size of N*N, and using the average value as a direct current component DC00of the macroblock, that is,

1N2⁢∑i,j⁢Yij;
and
loading pixel luminance information of the second N rows, and calculating a block direct current component DC01; loading pixel luminance information of the third N rows, and calculating a block direct current component DC02;and loading pixel luminance information of the LthN rows, and calculating a block direct current component DC0L.

A second acquiring unit512is configured to acquire pixel luminance information of a reference pixel block, in the reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame.

A second calculation unit513is configured to calculate a block direct current component of the reference pixel block according to the pixel luminance information of the reference pixel block.

Specifically, specific operations of acquiring the pixel luminance information by the second acquiring unit512and the first acquiring subunit510aare the same.

Specifically, specific operations of calculating the block direct current components by the second calculation unit513and the first calculation unit511are the same.

A first comparison unit514is configured to compare the acquired block direct current component of the unit pixel block located within the range of the current row and the total L surrounding rows within the current video frame with the direct current component of the reference pixel block, in the reference frame, corresponding to the unit pixel block within the range of the current row and the total L surrounding rows within the current video frame.

Specifically, the comparing the block direct current components by the first comparison unit514is specifically: determining a range within the L rows according to a current macroblock and based on a width of a picture and a height of the search window; comparing a direct current component DC0ijof a current block of the current frame with a direct current component DC1ijof a block at a corresponding location of the reference frame, to obtain fFlagij, where fFlagijis obtained by using the following equation:

A first determining unit515is configured to collect statistics on a comparison result of the direct current components, and determine, according to a statistics collection result, whether fade-in/fade-out exists, which specifically includes the following steps.

Specifically, the determining whether fade-in/fade-out exists by the first determining unit515is specifically: collecting statistics on the comparison result of the direct current components, collecting statistics on a quantity fiNumgof current blocks, of the current frame, satisfying that a direct current component DC0ijis less than a direct current component DC1ijof a block at a corresponding location of the reference frame, and similarly collecting statistics on a quantity foNumgof current blocks, of the current frame, satisfying that a direct current component DC0ijis greater than a direct current component DC1ijof a block at a corresponding location of the reference frame, where
fiNumg=ΣfFlagij; and
foNumg=Σ(1−fFlagij); and

if fiNumg>R or foNumg>R, considering that fade-in/fade-out exists in a current row, determining that the fade-in/fade-out is global fade-in/fade-out, and going to a first processing unit516; or

if fiNumg≤R and foNumg≤R , considering that no global fade-in/fade-out exists in a current row, and going to the second acquiring subunit510bof the first acquiring unit510,

where R=L*(width−D0), L is the acquired current row and total L surrounding rows within the current video frame, width is a quantity of blocks in one row of a frame picture, and D0is an error value of a quantity of blocks, in one row, having a letter box.

The first processing unit516is configured to: when it is detected that fade-in/fade-out exists in a current row, consider that global fade-in/fade-out exists, and mark all unit pixel blocks in the current row, so that a weighted prediction mode is used during motion match.

The second acquiring subunit510bis configured to: when it is detected that no global fade-in/fade-out exists, acquire, within the range of the detected current row and total L surrounding rows within the current frame, the pixel luminance information within a rectangular area whose center is a current block and that has a predetermined size.

Specifically, specific operations of acquiring the pixel luminance information by the second acquiring subunit510band the first acquiring subunit510aare the same, and the luminance information acquired by the second acquiring subunit510bis fed back to the first calculation unit511.

The first calculation unit511is further configured to calculate, on a block basis according to the acquired pixel luminance information that is acquired within the range of the detected current row and total L surrounding rows within the current frame and that is within the rectangular area whose center is the current block and that has the predetermined size, a direct current component of a unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size, to acquire the block direct current component of the unit pixel block.

The second acquiring unit512is further configured to acquire pixel luminance information of a reference pixel block, in the reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size.

The first comparison unit514is further configured to compare the acquired block direct current component of the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the rectangular area whose center is the current block and that has the predetermined size.

Specifically, the comparing the block direct current components by the first comparison unit514is specifically: determining a range within the L rows according to a current macroblock and based on a width of a picture and a height of the search window; comparing a direct current component DC0ijof the current block of the current frame with a direct current component DC1ijof a block at a corresponding location of the reference frame, to obtain fFlagij, where fFlagijis obtained by using the following equation:

The first determining unit515is configured to collect statistics on a comparison result of the direct current components, and determine, according to a statistics collection result, whether fade-in/fade-out exists.

Specifically, the collecting statistics on the comparison results of the block direct current components by the first determining unit515is specifically: collecting statistics on the comparison result of the direct current components, collecting statistics on a quantity fiNumgof current blocks, of the current frame, satisfying that a direct current component DC0ijis less than a direct current component DC1ijof a block at a corresponding location of the reference frame, and collecting statistics on a quantity foNumgof current blocks, of the current frame, satisfying that a direct current component DC0ijis greater than a direct current component DC1ijof a block at a corresponding location of the reference frame, where
fiNumg=ΣfFlagij; and
foNumg=Σ(1−fFlagij); and

if fiNumg>R or foNumg>R, considering that fade-in/fade-out exists in a current to-be-processed block, determining that the fade-in/fade-out is local fade-in/fade-out, and going to the first processing unit516,

where a size of a local area is P×Q, P and Q are natural numbers greater than 1, and Q is less than the height of the search window, and ensures that the local area is within the picture; and R=blkNums−D1, where blkNum: is a quantity of macroblocks within the local area, and D1is an allowed error quantity of blocks.

The first processing unit516is further configured to mark a current to-be-processed block, so that the weighted prediction mode is used during motion match.

In the video frame fade-in/fade-out detection apparatus500provided in this embodiment of the present invention, pixel luminance information within a range of a current row and total L surrounding rows within a current video frame is acquired, and meanwhile, a direct current component of a unit pixel block is calculated according to the acquired pixel luminance information. Moreover, once a block is acquired, the block is detected, and processing on a current to-be-processed row is performed in time, and no entire-frame detection needs to be performed on a current picture before processing, thereby avoiding a delay caused by the fact that in the prior art, entire-frame detection is performed before processing. Moreover, pixel luminance information is acquired, and meanwhile, a direct current component of a unit pixel block is calculated; fade-in/fade-out is detected, and meanwhile, whether to perform weighted prediction is determined in time; therefore, this synchronous running mode enables the method to save a sum of bandwidths resulting from hardware implementation and motion estimation. Finally, because fade-in/fade-out is detected in time and processing is performed in time, motion estimation match accuracy is improved. In a case in which it is detected that no fade-in/fade-out exists in the current row, the pixel luminance information within a rectangular area whose center is a current block and that has a predetermined size is further acquired within the range of the detected current row and total L surrounding rows within the current frame, and a direct current component of a unit pixel block is synchronously calculated according to the acquired pixel luminance information. Moreover, once a block is acquired, the block is detected, and processing on a current to-be-processed block is performed in time, and no entire-frame detection needs to be performed on a current picture before processing, thereby avoiding a delay caused by the fact that in the prior art, entire-frame detection is performed before processing. Moreover, pixel luminance information is acquired, and meanwhile, a direct current component of a unit pixel block is calculated; fade-in/fade-out is detected, and meanwhile, whether to perform weighted prediction is determined in time; therefore, this synchronous running mode enables the method to save a sum of bandwidths resulting from hardware implementation and motion estimation. Finally, because fade-in/fade-out is detected in time and processing is performed in time, motion estimation match accuracy is improved. Therefore, the method provided in this embodiment achieves beneficial effects of avoiding a delay, saving a bandwidth, and improving motion estimation match accuracy. Moreover, fade-in/fade-out detection is first performed on the current to-be-processed row of some rows, and block fade-in/fade-out detection is further performed, in the rectangular area whose center is the current block, that has the predetermined size, and that is within the rows, on the current to-be-processed block. The method further reduces a detection amount, thereby performing processing more quickly, further avoiding a delay and saving a bandwidth, and further improving motion estimation match accuracy.

This embodiment provides another video frame fade-in/fade-out detection apparatus600. Referring toFIG. 6, the apparatus specifically includes a first acquiring unit610, configured to acquire pixel luminance information within a rectangular area whose center is a current block, that has a predetermined size, and that is set within a current video frame. Also included is a first calculation unit611, configured to calculate, on a block basis according to the pixel luminance information within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame, a direct current component of a unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame, to acquire the block direct current component of the unit pixel block.

Specifically, the acquiring pixel luminance information by the first acquiring unit610is specifically: setting a size of a search window to H*M, and a size of a block to N*N; and based on the block with the size of N*N, loading pixel luminance information of the first N rows of the current frame, where a video format is generally YUV, and in this case, a loaded pixel component is luminance information Y.

Specifically, the calculating a block direct current component by the first calculation unit611may be specifically calculating an average value of pixel luminance information Y of each macroblock that is obtained by dividing the loaded rows according to the size of N*N, and using the average value as a direct current component DC00of the macroblock, that is,

1N2⁢∑i,j⁢Yij;
and
loading pixel luminance information of the second N rows, and calculating a block direct current component DC01; loading pixel luminance information of the third N rows, and calculating a block direct current component DC02; and loading pixel luminance information of the LthN rows, and calculating a block direct current component DC0L.

Also included is second acquiring unit612, configured to acquire pixel luminance information of a reference pixel block, in a reference frame corresponding to the current video frame, corresponding to the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame. Also included is a second calculation unit613, configured to calculate a block direct current component of the reference pixel block according to the pixel luminance information of the reference pixel block.

Specifically, specific operations of acquiring the pixel luminance information by the second acquiring unit612and the first acquiring unit610are the same.

Specifically, specific operations of calculating the block direct current components by the second calculation unit613and the first calculation unit611are the same. a first comparison unit614, configured to compare the acquired block direct current component of the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame with the direct current component, of the reference pixel block in the reference frame, corresponding to the direct current component of the unit pixel block located within the rectangular area whose center is the current block, that has the predetermined size, and that is set within the current video frame;

Specifically, the comparing the block direct current components by the first comparison unit614is specifically: determining a range of a rectangular area of a size according to a current macroblock based on a width of a picture and a height of the search window; comparing a direct current component DC0ijof the current block of the current frame with a direct current component DC1ijof a block that is at a corresponding location of the reference frame and that is pointed at by a time-domain motion vector of the current block (if the location of the corresponding block, which is pointed at, of the reference frame exceeds the search window, a block, closest to the corresponding block, within the search window is acquired), to obtain fFlagij, where fFlagijis obtained by using the following equation:

fFlagij={1D⁢⁢C⁢⁢0ij<D⁢⁢C⁢⁢1ij0D⁢⁢C⁢⁢0ij>D⁢⁢C⁢⁢1ij.
Also included is a first determining unit615, configured to collect statistics on a comparison result of the direct current components, and determine, according to a statistics collection result, whether fade-in/fade-out exists, which specifically includes the following steps:

Specifically, the determining whether fade-in/fade-out exists by the first determining unit615is specifically: collecting statistics on the comparison result of the direct current components, collecting statistics on a quantity fiNumgof macroblocks that are among all macroblocks within a local area whose center is a current block of the current frame and that satisfy that a direct current component DC0ijis less than direct current components DC1ijof all macroblocks within a local area whose center is a block at a specified location of the reference frame, and similarly collecting statistics on a quantity foNumgof macroblocks that are among all macroblocks within a local area whose center is a current block of the current frame and that satisfy that a direct current component DC0ijis greater than direct current components DC1ijof all macroblocks within a local area whose center is a block at a specified location of the reference frame, where
fiNumg=ΣfFlagij; and
foNumg=Σ(1−fFlagij); and

if fiNumg>R or foNumg>R, considering that fade-in/fade-out exists in a current to-be-processed block, determining that the fade-in/fade-out is local fade-in/fade-out, and going to a first processing unit616, where a size of a local area is P×Q, P and Q are natural numbers greater than 1, and Q is less than the height of the search window, and ensures that the local area is within the picture; and R=blkNums−D1, where blkNum is a quantity of macroblocks within the local area, and D1is an allowed error quantity of blocks.

The first processing unit616is configured to mark a current to-be-processed block, so that the weighted prediction mode is used during motion match.

In the video frame fade-in/fade-out detection apparatus600provided in this embodiment of the present invention, pixel luminance information within a rectangular area whose center is a current block, that has a predetermined size, and that is set within a current video frame is acquired, and meanwhile, a direct current component of a unit pixel block is calculated according to the acquired pixel luminance information. Moreover, once a block is acquired, the block is detected, and processing on a current to-be-processed block is performed in time, and no entire-frame detection needs to be performed on a current picture before processing, thereby avoiding a delay caused by the fact that in the prior art, entire-frame detection is performed before processing. Moreover, pixel luminance information is acquired, and meanwhile, a direct current component of a unit pixel block is calculated; fade-in/fade-out is detected, and meanwhile, whether to perform weighted prediction is determined in time; therefore, this synchronous running mode enables the method to save a sum of bandwidths resulting from hardware implementation and motion estimation. Finally, because fade-in/fade-out is detected in time and processing is performed in time, motion estimation match accuracy is improved. Therefore, the method provided in this embodiment achieves beneficial effects of avoiding a delay, saving a bandwidth, and improving motion estimation match accuracy.

It should be noted that, for the foregoing method embodiments, for simplicity of description, the method embodiments are described as a combination of a series of actions, but it should be clear to a person skilled in the art that the present invention is not limited by the order of the actions, as some steps can, in accordance with the present invention, be performed in other orders or concurrently. Next, a person skilled in the art should also know that, the embodiments described in the specification all fall within exemplary embodiments, and the related actions and modules are not necessarily required by the present invention.

In the foregoing embodiments, description of each embodiment has its focus. For a part that is not described in detail in an embodiment, reference may be made to related descriptions in other embodiments.