WO2017177675A1 - 视频编码方法和装置 - Google Patents

视频编码方法和装置 Download PDF

Info

Publication number
WO2017177675A1
WO2017177675A1 PCT/CN2016/105844 CN2016105844W WO2017177675A1 WO 2017177675 A1 WO2017177675 A1 WO 2017177675A1 CN 2016105844 W CN2016105844 W CN 2016105844W WO 2017177675 A1 WO2017177675 A1 WO 2017177675A1
Authority
WO
WIPO (PCT)
Prior art keywords
frame
background
background frame
quality indicator
candidate
Prior art date
Application number
PCT/CN2016/105844
Other languages
English (en)
French (fr)
Inventor
张怡轩
陈绍林
吴东昇
秘谧
李明
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2017177675A1 publication Critical patent/WO2017177675A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/503Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving temporal prediction
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/587Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving temporal sub-sampling or interpolation, e.g. decimation or subsequent interpolation of pictures in a video sequence

Definitions

  • the present invention relates to the field of video coding technologies, and in particular, to a video coding method and apparatus.
  • the video encoding refers to a method of converting a video format file into another video format file by using a specific compression technique.
  • a camera device such as a surveillance camera
  • the reference frame is determined mainly by the background modeling method or the background frame selection manner.
  • the specific process of the background modeling mode is: first acquiring at least one image input to the encoder in a period of time, and then obtaining the at least one image.
  • the background area image of each image is then recombined with the background area image of all images, and a complete background frame is obtained by modeling, and then the background frame is inserted into the video sequence to be encoded, and the background frame is As a reference frame, it is referred to when it is encoded by the inter-coded frame after the background frame.
  • the reference frame includes a long-term reference frame and a short-term reference frame.
  • the background frame is always used as a reference frame until a new background frame is inserted into the video sequence to be encoded.
  • the background frame may be used as an Instantaneous Decoding Refresh (IDR) frame in the video sequence to be encoded, that is, the first intra-coded frame (the intra-coded frame is also called an I frame), and is used.
  • IDR Instantaneous Decoding Refresh
  • the specific process of the background frame selection method is: first acquiring at least one image input to the encoder for a period of time, and then evaluating the proportion of the background area of each image in the at least one image, and then selecting the image with the highest proportion of the background region as the background.
  • the frame is inserted into the video sequence to be encoded, and the selected background frame is used as a reference frame.
  • the video of the embodiment of the present invention provides a video. Coding method and device.
  • the technical solution is as follows:
  • a video encoding method comprising:
  • each candidate background frame in the at least one candidate background frame satisfies a preset rule, and the at least one candidate background frame is a background frame obtained by using a preset background frame acquisition manner;
  • the target background frame is inserted as a reference frame of the inter-coded frame in the video sequence to be encoded into the video sequence to be encoded for video encoding.
  • the video encoding is capable of determining an target background frame in an alternate background frame that satisfies a preset rule when the candidate background frame satisfies a preset rule in the at least one candidate background frame, and using the target background frame as the video sequence to be encoded
  • the reference frame of the inter-coded frame is inserted into the video sequence to be encoded, which avoids inserting the poor quality background frame into the occupied code rate in the video sequence to be encoded, thereby improving the efficiency of video coding.
  • the preset rule is: the quality indicator parameter of the background frame meets a preset quality requirement, and the quality indicator parameter is a parameter used to measure the quality of the background frame.
  • the candidate background frame that satisfies the preset rule in the at least one candidate background frame is a background frame
  • the candidate background frame is directly determined as the target background frame.
  • the background frame obtaining manner may be a background modeling manner, a background frame selection manner, or any other background frame acquisition manner, such as a frame pixel average method or a mixed Gaussian modeling method, and the background frame.
  • the acquisition manner may also be various combinations of the foregoing multiple background frame acquisition methods. Each background frame acquisition method gets a background frame.
  • the quality indicator parameter is the first quality indicator
  • the value of the first quality indicator is equal to the candidate background.
  • the similarity between the frame and the inter-coded frame to be encoded at the current time in the video sequence to be encoded, the quality requirement is: the value of the quality indicator parameter is greater than a preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes Determining a target background frame in at least two background frames in an alternate background frame that satisfies a preset rule, including:
  • the quality requirement may be: the value of the quality indicator parameter is greater than the random value generated during the video encoding process.
  • the video coding method can determine, by using the quality indicator parameter, which of the at least two background frame acquisition modes, the candidate background frame is obtained as the reference frame of the inter-coded frame in the video sequence to be encoded, and improves the reference frame. Insert the flexibility of the background frame and the efficiency of video encoding.
  • the quality indicator parameter is a third quality indicator, and the value of the third quality indicator is equal to 1-P, where P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded, and the quality
  • P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded
  • the quality The requirement is that the value of the quality indicator parameter is smaller than a preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is smaller than the quality threshold includes at least two background frames, and the target background frame is determined in the candidate background frame that satisfies the preset rule.
  • the quality requirement may be: the value of the quality indicator parameter is smaller than the random value generated during the video coding process.
  • the video coding method can determine, by using the quality indicator parameter, which of the at least two background frame acquisition modes, the candidate background frame is obtained as the reference frame of the inter-coded frame in the video sequence to be encoded, and improves the reference frame. Insert the flexibility of the background frame and the efficiency of video encoding.
  • the quality indicator parameter is a second quality indicator
  • the value of the second quality indicator is iteratively obtained by the value of the first quality indicator, where the value of the first quality indicator is equal to the current background time of the candidate background frame and the to-be-coded video sequence to be encoded.
  • the similarity of the inter-coded frame, the quality requirement is: the value of the quality indicator parameter is greater than a preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two backgrounds
  • the method further includes: before determining whether each of the candidate background frames meets the preset rule in the at least one candidate background frame, the method further includes:
  • Determining the target background frame in an alternate background frame that satisfies the preset rule including:
  • a background frame having the largest value of the quality indicator parameter is selected as the target background frame in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold.
  • the quality indicator parameter in the video coding method may be the first quality indicator, the second quality indicator, the third quality indicator, or any other parameter used to measure the quality of the background frame.
  • the video coding method can determine, by using the quality indicator parameter, which of the at least two background frame acquisition modes, the candidate background frame is obtained as the reference frame of the inter-coded frame in the video sequence to be encoded, and improves the reference frame. Insert the flexibility of the background frame and the efficiency of video encoding.
  • the video encoding method can also continuously update the value of the quality indicator parameter during the video encoding process, thereby accurately determining whether to insert a background frame.
  • determining a value of the second quality indicator of each candidate background frame according to a value of the first quality indicator of each candidate background frame including:
  • a is a weight coefficient and 0 ⁇ a ⁇ 1
  • t represents the number of frames.
  • each of the candidate background frames and the inter-coded frames to be encoded at the current moment respectively include at least one background block, and the similarity between each candidate background frame and the inter-coded frame to be encoded at the current moment is calculated, including:
  • the second background block is used as the target background block
  • the ratio of the number of target background blocks on the alternate background frame to the total number of background blocks is taken as the similarity.
  • the video coding method can determine the value of the quality indicator parameter of the candidate background frame by determining the similarity between the candidate background frame and the inter-coded frame to be encoded at the current time in the to-be-coded video sequence, thereby determining the at least one candidate background frame. Whether each candidate background frame satisfies a preset rule.
  • the method further includes:
  • the existing frame in the video sequence to be encoded is defined by a preset group of pictures (English: Group of Picture; GOP)
  • the reference relationship is video encoded.
  • the video coding may be performed according to other preset manners, such as performing video coding according to parameters such as the interval of the frame.
  • the video coding method is capable of not inserting a background frame when all the candidate background frames in the at least one candidate background frame do not satisfy the preset rule, and the existing frame in the video sequence to be encoded is defined by the preset GOP structure.
  • Video coding is performed in a reference relationship or other preset manner, and the flexibility of inserting a background frame is improved compared to the prior art.
  • the preset GOP structure includes any one of an IPPP structure and an IBBBP structure.
  • the background frame acquisition manner may include a background modeling manner and a background frame selection manner.
  • the method further includes:
  • the encoded frame in which the target background frame is inserted includes a target background frame and an inter-coded frame, wherein the target background frame is encoded by using an intra-frame coding mode,
  • the inter-coded frame is encoded with an inter-frame coding mode reference target background frame.
  • the target background frame may be encoded according to a preset quantization step by using an intra coding mode, and the target background frame may be encoded according to a smaller quantization step by using an intra coding mode, which not only improves the target background.
  • the effect of the quality of the inter-coded frames in the frame and the video sequence to be encoded also achieves the effect of consuming a smaller code rate.
  • the reference frame includes any one of a long-term reference frame and a short-term reference frame.
  • the target background frame in the video encoding method is not limited to being referenced by the inter-coded frame in the video sequence to be encoded only in the manner of a long-term reference frame, and the number of frames in the video sequence to be encoded is not large, or If the requirement of occupying the bit rate is not high, the target background frame may be referred to by the inter-coded frame in the video sequence to be encoded in the manner of a short-term reference frame.
  • the method further includes:
  • a syntax element of the target background frame is added within a parameter set of the inter-coded frame in the video sequence to be encoded, and the syntax element is used to indicate the manner in which the target background frame is used as the long-term reference frame.
  • a syntax element of the target background frame is added within a parameter set of the inter-coded frame in the video sequence to be encoded to encode the inter-coded frame in the encoded video sequence.
  • the method further includes:
  • a syntax element of at least one inter-coded frame in the video sequence to be encoded is added to a parameter set of an inter-coded frame in the video sequence to be encoded.
  • the inter-coded frame in the video sequence to be encoded may refer to the target background frame, and may also refer to other one or more inter-coded frames, and the other one or more inter-coded frames may be used as the long-term reference frame in the video sequence to be encoded.
  • the reference to the inter-coded frame may also be referred to as a short-term reference frame referenced by the inter-coded frame in the video sequence to be encoded.
  • the parameter set includes a sequence parameter set and a reference image set.
  • the video encoding method may also not directly evaluate the quality of the background frame, but may use other signals to decide whether to insert the background frame. For example, in the case where the imaging device is in a dithered state, or in the case where the illumination intensity is in a rapidly changing state, or in the case where the noise intensity of the video image is greater than the preset noise intensity value, etc., it may be decided not to insert the background frame. .
  • a signal for indicating the jitter state of the image pickup device, a signal for indicating the light intensity, and a signal for indicating the noise intensity of the video image can be obtained by the sensing device.
  • the video encoding method may further determine whether to insert the background frame according to other methods, such as: inserting the background frame in the first preset time period, Simultaneously tracking and recording the code rate consumed by the video coding in the first preset time period and the quality of the reconstructed frame of the video image, and inserting the background frame in the second preset time period after the first preset time period, and simultaneously tracking Recording a code rate consumed by the video coding in the second preset time period and a quality of the reconstructed frame of the video image, and then comparing the code rate of the two recordings and the quality of the reconstructed frame, when the code in the first preset time period When the rate is smaller and the quality of the reconstructed frame is better, video coding is performed by inserting a background frame in a subsequent video encoding process; when the code rate is smaller in the second preset time period, and the reconstructed frame is used When the quality is
  • a video encoding apparatus comprising:
  • a first determining unit configured to determine whether each candidate background frame in the at least one candidate background frame satisfies a preset rule, where the at least one candidate background frame is a background frame obtained by using a preset background frame acquiring manner;
  • a first determining unit configured to: when there is an alternative background frame that satisfies a preset rule in the at least one candidate background frame, determine the target background frame in the candidate background frame that satisfies the preset rule;
  • an insertion unit configured to insert the target background frame as a reference frame of the inter-coded frame in the video sequence to be encoded into the video sequence to be encoded for video coding.
  • the preset rule is: the quality indicator parameter of the background frame satisfies a preset quality requirement, and the quality indicator parameter is a parameter used to measure the quality of the background frame.
  • the first determining unit is configured to determine, when the candidate background frame that satisfies the preset rule in the at least one candidate background frame is a background frame, directly determine the candidate background frame as the target background frame.
  • the background frame obtaining manner may be a background modeling manner, a background frame selection manner, or any other background frame acquisition manner, such as a frame pixel average method or a mixed Gaussian modeling method, and the background frame.
  • the acquisition manner may also be various combinations of the foregoing multiple background frame acquisition methods. Each background frame acquisition method gets a background frame.
  • the quality indicator parameter is a first quality indicator
  • the value of the first quality indicator is equal to the similarity between the candidate background frame and the inter-coded frame to be encoded at the current time in the to-be-coded video sequence
  • the quality requirement is: the quality indicator parameter.
  • the value of the value is greater than the preset quality threshold
  • the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames
  • the first determining unit includes:
  • a first selection module configured to select, as the target background frame, a background frame having the largest value of the quality indicator parameter in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold;
  • a second selection module configured to randomly select a background frame as the target background frame in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold.
  • the quality requirement may be: the value of the quality indicator parameter is greater than the random value generated during the video coding process.
  • the quality indicator parameter is a third quality indicator, and the value of the third quality indicator is equal to 1-P, where P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded, and the quality
  • P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded
  • the quality The requirement is that the value of the quality indicator parameter is smaller than the preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is smaller than the quality threshold includes at least two background frames, and the first determining unit includes:
  • a fourth selection module configured to select, as the target background frame, a background frame with the smallest value of the quality indicator parameter in the candidate background frame whose value of the quality indicator parameter is less than the quality threshold;
  • a fifth selecting module configured to randomly select a background frame as the target background frame in the candidate background frame whose value of the quality indicator parameter is less than the quality threshold.
  • the quality requirement may also be: the value of the quality indicator parameter is smaller than the random value generated in the video coding process.
  • the quality indicator parameter is a second quality indicator
  • the value of the second quality indicator is iteratively obtained by the value of the first quality indicator, where the value of the first quality indicator is equal to the current background time of the candidate background frame and the to-be-coded video sequence to be encoded.
  • the similarity of the inter-coded frame, the quality requirement is: the value of the quality indicator parameter is greater than the preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames, and the device further includes:
  • a second determining unit configured to determine a value of the second quality indicator of each candidate background frame according to a value of the first quality indicator of each candidate background frame
  • the first determining unit comprises:
  • a third selection module configured to select, as the target background frame, a background frame with the largest value of the quality indicator parameter in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold.
  • the second determining unit includes:
  • a determining module configured to calculate a value C(t) of the second quality indicator of each candidate background frame according to a quality calculation formula according to a value D(t) of the first quality indicator of each candidate background frame, and calculate a second
  • the mass calculation formula for the value of the quality indicator C(t) is:
  • a is a weight coefficient and 0 ⁇ a ⁇ 1
  • t represents the number of frames.
  • each of the candidate background frames and the inter-coded frames to be encoded at the current moment respectively include at least one background block
  • the apparatus further includes:
  • a second determining unit configured to determine whether a difference between a pixel of the first background block of the inter-coded frame to be encoded at the current time and a pixel of the second background block of each candidate background frame is less than a preset difference threshold, The position of the first background block on the inter-coded frame to be encoded at the current time corresponds to the position of the second background block on each of the alternate background frames;
  • a first processing unit configured, for each candidate background frame, when the difference between the pixels of the first background block and the pixels of the second background block is less than a difference threshold, the second background block is used as the target background block,
  • a third determining unit configured to determine a number of target background blocks on the candidate background frame
  • a second processing unit configured to use a ratio of the number of target background blocks on the candidate background frame to the total number of background blocks as the similarity.
  • the device further includes:
  • a third processing unit configured to: when all the candidate background frames in the at least one candidate background frame do not satisfy the preset rule, perform video according to the reference relationship defined by the preset GOP structure coding.
  • the third processing unit is further configured to: when all the candidate background frames in the at least one candidate background frame do not satisfy the preset rule, perform video encoding according to other preset manners, such as according to parameters such as a frame interval. Video coding.
  • the preset GOP structure includes any one of an IPPP structure and an IBBBP structure.
  • the background frame acquisition manner may include a background modeling manner and a background frame selection manner.
  • the device further includes:
  • a coding unit configured to encode a coded frame in a video sequence to be encoded in which a target background frame is inserted, where the coded frame in which the target background frame is inserted includes a target background frame and an inter-coded frame, wherein the target background frame is intra-coded
  • the mode is encoded, and the inter-coded frame is encoded by referring to the target background frame using the inter-frame coding mode.
  • the reference frame includes any one of a long-term reference frame and a short-term reference frame.
  • the device further includes:
  • a first adding unit configured to add a syntax element of the target background frame in a parameter set of the inter-coded frame in the video sequence to be encoded, where the syntax element is used to indicate that the target background frame is used as a long-term reference frame.
  • the device further includes:
  • a second adding unit configured to add, in a parameter set of the inter-coded frame in the video sequence to be encoded, a syntax element of at least one inter-coded frame in the video sequence to be encoded.
  • the parameter set includes a sequence parameter set and a reference image set.
  • a video encoding apparatus comprising: a processor, a memory, a network interface, and a bus.
  • the bus is used to connect a processor, a memory, and a network interface, and the processor is configured to execute a program stored in the memory.
  • the processor can execute the program to implement the encoder and cause the encoder to perform the following video encoding method:
  • the candidate background frame is a background frame obtained by a preset background frame acquisition manner
  • the target background frame is inserted as a reference frame of the inter-coded frame in the video sequence to be encoded into the video sequence to be encoded for video encoding.
  • the preset rule is: the quality indicator parameter of the background frame satisfies a preset quality requirement, and the quality indicator parameter is a parameter used to measure the quality of the background frame.
  • the candidate background frame that satisfies the preset rule in the at least one candidate background frame is a background frame
  • the candidate background frame is directly determined as the target background frame.
  • the background frame obtaining manner may be a background modeling manner, a background frame selection manner, or any other background frame acquisition manner, such as a frame pixel average method or a mixed Gaussian modeling method, and the background frame.
  • the acquisition manner may also be various combinations of the foregoing multiple background frame acquisition methods. Each background frame acquisition method gets a background frame.
  • the quality indicator parameter is a first quality indicator
  • the value of the first quality indicator is equal to the similarity between the candidate background frame and the inter-coded frame to be encoded at the current time in the to-be-coded video sequence
  • the quality requirement is: the quality indicator parameter.
  • the value of the value is greater than the preset quality threshold
  • the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames
  • the target background frame is determined in the candidate background frame that satisfies the preset rule, including:
  • the quality requirement may be: the value of the quality indicator parameter is greater than the random value generated during the video coding process.
  • the quality indicator parameter is a third quality indicator, and the value of the third quality indicator is equal to 1-P, where P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded, and the quality
  • P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded
  • the quality The requirement is that the value of the quality indicator parameter is smaller than a preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is smaller than the quality threshold includes at least two background frames, and the target background frame is determined in the candidate background frame that satisfies the preset rule.
  • the quality requirement may also be: the value of the quality indicator parameter is smaller than the random value generated in the video coding process.
  • the quality indicator parameter is a second quality indicator
  • the value of the second quality indicator is iteratively obtained by the value of the first quality indicator, where the value of the first quality indicator is equal to the current background time of the candidate background frame and the to-be-coded video sequence to be encoded.
  • the similarity of the inter-coded frame, the quality requirement is: the value of the quality indicator parameter is greater than a preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames, and at least one device is determined.
  • the method further includes:
  • Determining the target background frame in an alternate background frame that satisfies the preset rule including:
  • a background frame having the largest value of the quality indicator parameter is selected as the target background frame in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold.
  • determining a value of the second quality indicator of each candidate background frame according to a value of the first quality indicator of each candidate background frame including:
  • a is a weight coefficient and 0 ⁇ a ⁇ 1
  • t represents the number of frames.
  • each of the candidate background frames and the inter-coded frames to be encoded at the current moment respectively include at least one background block, and the similarity between each candidate background frame and the inter-coded frame to be encoded at the current moment is calculated, including:
  • the difference between the pixels of the first background block and the pixels of the second background block is small
  • the second background block is used as the target background block.
  • the ratio of the number of target background blocks on the alternate background frame to the total number of background blocks is taken as the similarity.
  • the method further includes:
  • the existing frames in the video sequence to be encoded are video-encoded according to a reference relationship defined by the preset GOP structure.
  • the video coding may be performed according to other preset manners, such as performing video coding according to parameters such as the interval of the frame.
  • the preset GOP structure includes any one of an IPPP structure and an IBBBP structure.
  • the background frame acquisition manner may include a background modeling manner and a background frame selection manner.
  • the method further includes:
  • Encoding the encoded frame in the video sequence to be encoded with the target background frame inserted, and inserting the encoded frame of the target background frame includes a target background frame and an inter-coded frame, wherein the target background frame is encoded by the intra-frame coding mode, and the frame is encoded.
  • the inter-coded frame is encoded with an inter-frame coding mode reference target background frame.
  • the reference frame includes any one of a long-term reference frame and a short-term reference frame.
  • the method further includes:
  • a syntax element of the target background frame is added within a parameter set of the inter-coded frame in the video sequence to be encoded, and the syntax element is used to indicate the manner in which the target background frame is used as the long-term reference frame.
  • the method further includes:
  • a syntax element of at least one inter-coded frame in the video sequence to be encoded is added to a parameter set of an inter-coded frame in the video sequence to be encoded.
  • the parameter set includes a sequence parameter set and a reference image set.
  • An embodiment of the present invention provides a video encoding method and apparatus, which can determine a target background frame in an alternative background frame that satisfies a preset rule when there is an alternative background frame that satisfies a preset rule in at least one candidate background frame. And the target background frame is inserted as a reference frame of the inter-coded frame in the video sequence to be encoded In the video sequence to be encoded, compared with the prior art, the background frame with poor quality is prevented from being inserted into the video sequence to be encoded, thereby improving the efficiency of video coding.
  • FIG. 1 is a flowchart of a video encoding method according to an embodiment of the present invention
  • 2-2 is a flowchart of determining a value of a quality indicator parameter of an alternate background frame according to an embodiment of the present invention
  • 2-3 is a schematic structural diagram of an alternate background frame and an inter-coded frame to be encoded at a current time
  • FIG. 2-4 is a schematic structural diagram of a video sequence to be encoded after a target background frame is inserted into a to-be-coded video sequence as a reference frame of an inter-coded frame in a video sequence to be encoded in the embodiment shown in FIG. 2-1;
  • FIG. 2-5 is a schematic structural diagram of video coding of an existing frame in a video sequence to be encoded according to a reference relationship defined by an IPPPP structure in the embodiment shown in FIG. 2-1;
  • 3-1 is a schematic structural diagram of a video encoding apparatus according to an embodiment of the present invention.
  • FIG. 3-1 is a schematic structural diagram of a first determining unit in the embodiment shown in FIG. 3-1;
  • 3-3 is a schematic structural diagram of another first determining unit in the embodiment shown in FIG. 3-1;
  • 3-4 is a schematic structural diagram of still another first determining unit in the embodiment shown in FIG. 3-1;
  • FIG. 3-1 is a schematic structural diagram of still another first determining unit in the embodiment shown in FIG. 3-1;
  • FIG. 3-6 are schematic structural diagrams of another video encoding apparatus according to an embodiment of the present invention.
  • FIG. 3-7 is a schematic structural diagram of a first determining unit in the embodiment shown in FIG. 3-1;
  • 3-8 is a schematic structural diagram of a second determining unit in the embodiment shown in FIG. 3-6;
  • FIG. 4 is a schematic structural diagram of a video encoding apparatus according to an embodiment of the present invention.
  • An embodiment of the present invention provides a video encoding method for an encoder. As shown in FIG. 1, the video encoding method includes:
  • Step 101 Determine whether each candidate background frame in the at least one candidate background frame satisfies a preset rule, where the at least one candidate background frame is a background frame obtained by using a preset background frame acquisition manner.
  • Step 102 When there is an alternative background frame that satisfies a preset rule in the at least one candidate background frame, the target background frame is determined in the candidate background frame that satisfies the preset rule.
  • Step 103 Insert the target background frame as a reference frame of the inter-coded frame in the video sequence to be encoded into the video sequence to be encoded for video coding.
  • the video coding method provided by the embodiment of the present invention is capable of determining, in an alternative background frame that satisfies a preset rule, when there is an alternative background frame that satisfies a preset rule in at least one candidate background frame.
  • the target background frame is inserted into the to-be-coded video sequence as the reference frame of the inter-coded frame in the video sequence to be encoded.
  • the poor quality background frame is prevented from being inserted into the to-be-coded video. In the sequence, therefore, the efficiency of video coding is improved.
  • An embodiment of the present invention provides another video encoding method, which is used in an encoder.
  • the video encoding method may include:
  • Step 201 Acquire at least one candidate background frame by using a preset background frame acquisition manner.
  • the background frame acquisition manner may include a background frame acquisition manner, and may also include at least two background frame acquisition manners.
  • the background frame acquisition mode may be a background modeling manner, a background frame selection manner, or any other background frame acquisition manner, such as a frame pixel average method or a mixed Gaussian modeling method, or Various combinations of the above various background frame acquisition methods, each background frame acquisition manner can obtain a background frame.
  • the specific form of the background frame acquisition mode is not limited in the embodiment of the present invention.
  • Step 202 Determine whether each candidate background frame in the at least one candidate background frame satisfies a preset rule.
  • the preset rule may be: the quality indicator parameter of the background frame meets a preset quality requirement, and the quality indicator parameter is a parameter used to measure the quality of the background frame.
  • the quality indicator parameter may be a first quality indicator, where the value of the first quality indicator is equal to the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded, the quality requirement may be The value of the quality indicator parameter is greater than a preset quality threshold (which can be obtained by experimental statistics), and the value of the first quality indicator is equal to the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded. Similarity, so the larger the value of the quality indicator parameter, the better the quality of the background frame.
  • the quality requirement may also be that the value of the quality indicator parameter is greater than the random value generated during the video encoding process. The content of the quality requirement is not limited in the embodiment of the present invention.
  • the quality indicator parameter may also be a third quality indicator, where the value of the third quality indicator is equal to 1-P, where P is the phase of the candidate background frame and the inter-coded frame to be encoded at the current time in the video sequence to be encoded.
  • the quality requirement may be: the value of the quality indicator parameter is less than the preset quality threshold, and the value of the third quality indicator is equal to 1-P, so the smaller the value of the quality indicator parameter, the better the quality of the background frame.
  • the quality requirement may be that the value of the quality indicator parameter is smaller than the random value generated during the video encoding process.
  • the content of the quality requirement is not limited in the embodiment of the present invention.
  • the video coding method may further include:
  • Step 2021 Calculate the similarity between each candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded.
  • each of the candidate background frames and the inter-coded frames to be encoded at the current moment respectively include at least one background block.
  • Figure 2-3 shows a schematic diagram of the structure of an alternate background frame and an inter-coded frame to be encoded at the current time.
  • the alternate background frame and the inter-coded frame to be encoded at the current time include 2*2 background blocks, that is, the candidate background frame includes 4 background blocks, and the inter-coded frame to be encoded at the current time includes 4 Background block.
  • the candidate background frame includes a background block D1, a background block D2, a background block D3, and a background block D4.
  • the inter-coded frame to be encoded at the current time includes a background block E1, a background block E2, a background block E3, and a background block E4.
  • the position of the background block D1 on the alternate background frame corresponds to the position of the background block E1 on the inter-coded frame to be encoded at the current time;
  • the position of the background block D2 on the alternate background frame and the background block E2 are currently Corresponding to the position on the inter-coded frame to be coded;
  • the position of the background block D3 on the candidate background frame corresponds to the position of the background block E3 on the inter-coded frame to be encoded at the current time;
  • the background block D4 is The position on the alternate background frame corresponds to the position of the background block E4 on the inter-coded frame to be encoded at the current time.
  • step 2021 can include:
  • the position of the first background block on the inter-coded frame to be encoded at the current time corresponds to the position of the second background block on each of the alternate background frames.
  • the preset difference threshold is y and y is greater than 0
  • the second background block is used as the target background block, and then the candidate background frame is determined.
  • the number of target background blocks, and finally the ratio of the number of target background blocks on the candidate background frame to the total number of background blocks as the similarity.
  • the difference threshold is y (y>0)
  • the second The background block is used as the target background block, and then the total number of target background blocks satisfying the condition is counted, and finally The ratio of the number of target background blocks on each candidate background frame to the total number of background blocks is taken as the similarity, thereby determining the value of the quality indicator parameter of each candidate background frame.
  • the difference threshold is y (y > 0)
  • the absolute value of the difference between the pixel of the background block E1 and the pixel of the background block D1 is less than y
  • the pixel of the background block E2 and the background block D2 The absolute value of the difference of the pixels is greater than y
  • the absolute value of the difference between the pixel of the background block E3 and the pixel of the background block D3 is greater than y
  • the absolute value of the difference between the pixel of the background block E4 and the pixel of the background block D4 is greater than y
  • the number of target background blocks on the candidate background frame is 1, so that the similarity between the inter-coded frame to be encoded at the current time and the candidate background frame is 1/4.
  • Step 2022 Determine a value of the first quality indicator or a value of the third quality indicator of each candidate background frame according to the similarity.
  • the value of the first quality indicator of the candidate background frame may be determined according to the similarity between the candidate background frame and the inter-coded frame to be encoded at the current time in the to-be-coded video sequence.
  • the candidate background frame may be The similarity of the inter-coded frame to be encoded at the current time in the to-be-coded video sequence is used as the value of the first quality indicator of the candidate background frame; on the other hand, according to the candidate background frame and the current time in the video sequence to be encoded
  • the similarity of the coded inter-coded frame determines the value of the third quality indicator of the candidate background frame.
  • the value of 1-P may be used as the value of the third quality indicator of the candidate background frame, where P is the value The similarity between the candidate background frame and the inter-coded frame to be encoded at the current time in the video sequence to be encoded.
  • step 202 may comprise: determining a quality indicator parameter of each candidate background frame in the at least one candidate background frame. Whether the value is greater than the quality threshold, that is, determining whether the value of the first quality indicator of each candidate background frame in the at least one candidate background frame is greater than a quality threshold.
  • step 202 may include determining a quality indicator parameter for each candidate background frame in the at least one candidate background frame. Whether the value is less than the quality threshold, that is, whether the value of the first quality indicator of each candidate background frame in the at least one candidate background frame is less than a quality threshold.
  • the quality threshold is a quality threshold corresponding to the third quality indicator.
  • the quality indicator parameter may also be a second quality indicator, and the value of the second quality indicator is first The value of the quality indicator is iteratively obtained.
  • the value of the first quality indicator is equal to the similarity between the candidate background frame and the inter-coded frame to be encoded at the current time in the video sequence to be encoded.
  • the quality requirement may be: the value of the quality indicator parameter is greater than the preset.
  • the quality threshold, the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames.
  • the video encoding method may further include: determining a second quality indicator of each candidate background frame according to a value of the first quality indicator of each candidate background frame. Value.
  • determining, according to the value of the first quality indicator of each candidate background frame, a value of the second quality indicator of each candidate background frame including:
  • a is a weight coefficient, and 0 ⁇ a ⁇ 1, and t represents the number of frames.
  • D(t) refers to the value of the first quality indicator of the candidate background frame of the t-th frame, that is, the inter-coded frame of the t-th frame (the inter-coded frame to be encoded at the current time) and the preparation of the t-th frame
  • the similarity of the background frame is selected, and the candidate background frame of the t-th frame refers to an alternative background frame obtained by the background frame acquisition manner according to the inter-coded frame of the 0th to t-1th frames.
  • D(0) is the value of the first quality indicator of the candidate background frame of the 0th frame, that is, the similarity between the inter-frame coded frame of the 0th frame and the candidate background frame of the 0th frame
  • D(1) refers to Is the value of the first quality indicator of the candidate background frame of the first frame, that is, the similarity between the inter-coded frame of the first frame and the candidate background frame of the first frame
  • D(2) refers to the second frame The value of the first quality indicator of the candidate background frame, that is, the similarity between the inter-frame coded frame of the second frame and the candidate background frame of the second frame.
  • step 202 may include: determining whether a value of a quality indicator parameter of each candidate background frame in the at least one candidate background frame is greater than a quality threshold, that is, determining at least one candidate background frame Whether the value of the second quality indicator of each candidate background frame is greater than a quality threshold.
  • the quality threshold is a quality threshold corresponding to the second quality indicator. This quality threshold can be obtained by experimental statistics.
  • the quality indicator parameter may be the first quality indicator, the second quality indicator, the third quality indicator, or any other parameter used to measure the quality of the background frame.
  • This embodiment of the present invention does not limit this.
  • the video encoding method can also continuously update the value of the quality indicator parameter during the video encoding process, thereby accurately determining whether to insert a background frame.
  • Step 203 When there is an alternative background frame that satisfies a preset rule in the at least one candidate background frame, the target background frame is determined in the candidate background frame that satisfies the preset rule. Go to step 204.
  • the candidate background frame that satisfies the preset rule in the at least one candidate background frame is a background frame
  • the candidate background frame is directly determined as the target background frame.
  • the quality indicator parameter is a first quality indicator, where the value of the first quality indicator is equal to the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded, and the quality requirement is: a quality indicator.
  • the value of the parameter is greater than the preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames.
  • step 203 may include: the candidate that the value of the quality indicator parameter is greater than the quality threshold
  • the background frame with the largest value of the quality indicator parameter is selected as the target background frame in the background frame, that is, the background frame with the largest value of the first quality indicator is selected as the target background frame in the candidate background frame whose value of the first quality indicator is greater than the quality threshold.
  • the background frame F1, the background frame F2, and the background frame F3 in step 202 are taken as an example.
  • the value of the first quality indicator of the background frame F1 is known to be w1
  • the value of the first quality indicator of the background frame F2 is w2.
  • the value of the first quality indicator of the background frame F3 is w3, and the quality threshold is z.
  • This kind of background mode determination target frame may be used as a target frame F2 background background frame.
  • the target background frame is obtained by comparing the values of the quality indicator parameters of the candidate background frame, which improves the robustness of the video coding.
  • step 203 may include randomly selecting one background frame as the target background frame in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold, that is, the candidate background frame whose value of the first quality indicator is greater than the quality threshold.
  • a background frame is randomly selected as the target background frame.
  • the background frame F1, the background frame F2, and the background frame F3 in step 202 are taken as an example. Since the value of the first quality indicator of the short-term quality indicator of the background frame F2 is w2 (w2 is greater than the quality threshold z), the background frame The short-term quality indicator of F3 has the value of w3 (w3 is also greater than the quality threshold z).
  • a background frame can be randomly selected from the background frame F2 and the background frame F3 according to the method of determining the target background frame.
  • the background frame F2 may be used as the target background frame, or the background frame F3 may be used as the target background frame.
  • step 201 is obtained by a background frame acquisition method (such as background modeling).
  • a background frame acquisition method such as background modeling
  • the candidate background frame may be directly determined as the target background frame, and the target background frame is used as the to-be-coded video.
  • a reference frame of an inter-coded frame in the sequence if step 201 is to obtain three candidate background frames by using three background frame acquisition methods, if the value of the first quality indicator is greater than the quality threshold in the three candidate background frames
  • a target background frame may be determined in an alternative background frame in which the value of the first quality indicator is greater than the quality threshold.
  • one background frame may also be randomly selected as the target background frame in the alternative background frame in which the value of the first quality indicator is greater than the quality threshold. If the number of candidate background frames whose value of the first quality indicator is greater than the quality threshold is 1, the candidate background frame is directly used as the target background frame. Therefore, the video coding method provided by the embodiment of the present invention can determine whether an alternative background frame obtained by a background frame acquisition manner is used as a reference frame of an inter-coded frame in a video sequence to be encoded, and can also determine at least two types. Which of the background frame acquisition methods obtains the candidate background frame as the reference frame of the inter-coded frame in the video sequence to be encoded, which improves the flexibility of inserting the background frame and the efficiency of video coding.
  • the quality indicator parameter is a third quality indicator, and the value of the third quality indicator is equal to 1-P, where P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded.
  • the quality requirement is: the value of the quality indicator parameter is less than the preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is less than the quality threshold includes at least two background frames.
  • step 203 may include: The background frame in which the value of the selected quality indicator parameter is the smallest among the candidate background frames whose value is smaller than the quality threshold is used as the target background frame.
  • step 203 can include randomly selecting a background frame as the target background frame in an alternate background frame in which the value of the quality indicator parameter is less than the quality threshold.
  • the process of determining the target background frame in the candidate background frame that satisfies the preset rule may refer to the quality indicator parameter as the first quality indicator, in the candidate background frame that satisfies the preset rule. The process of determining the target background frame.
  • the quality indicator parameter is a second quality indicator
  • the quality requirement is: the value of the quality indicator parameter is greater than a preset quality threshold
  • the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames
  • the step 203 may include: selecting, in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold, a background frame having the largest value of the quality indicator parameter as the target background frame, that is, the device whose value of the second quality indicator is greater than the quality threshold. Select the second quality indicator in the background frame to choose the largest value.
  • the background frame is used as the target background frame.
  • step 201 is to obtain an alternate background frame by using a background frame acquisition method (such as background modeling mode)
  • a background frame acquisition method such as background modeling mode
  • the method may directly
  • the candidate background frame is determined as a target background frame, and the target background frame is used as a reference frame of the inter-coded frame in the video sequence to be encoded; and step 201 is to obtain three candidate background frames by using three background frame acquisition methods.
  • the embodiment of the present invention does not limit the manner in which a target background frame is determined in an alternative background frame in which the value of the second quality indicator is greater than the quality threshold.
  • Step 204 Insert the target background frame as a reference frame of the inter-coded frame in the video sequence to be encoded into the video sequence to be encoded, to perform video coding. Go to step 205.
  • the reference frame includes a long-term reference frame and a short-term reference frame.
  • the long-term reference frame can be referenced by a farther inter-coded frame in the video sequence to be encoded compared to the short-term reference frame.
  • the effective range of the short-term reference frame is 16 frames (ie, 16 inter-frame encoded frames after the short-term reference frame can refer to the short-term reference frame), and the effective range of the long-term reference frame can exceed 16 frames (ie, after the long-term reference frame)
  • the 16-frame inter-coded frame can refer to the long-term reference frame).
  • the reference frame in the embodiment of the present invention includes any one of a long-term reference frame and a short-term reference frame.
  • the reference frame in the embodiment of the present invention may be a long-term reference frame, or may be a short-term reference frame, that is, in the embodiment of the present invention.
  • the target background frame is not limited to being referenced by the inter-coded frame in the video sequence to be encoded only in the form of a long-term reference frame, and the number of frames of the video sequence to be encoded is not large, or the requirement for the additional occupied code rate is not high.
  • the target background frame may be referenced by the inter-coded frame in the video sequence to be encoded in the manner of a short-term reference frame.
  • the specific form of the reference frame is not limited in the embodiment of the present invention. Since the target background frame is inserted after a certain period of time, in a practical application, a detection point can be inserted in the determined target background frame, and the detection point is used to instruct to start encoding a GOP.
  • FIG. 2-4 are diagrams showing the structure of a video sequence to be encoded after the target background frame is inserted into the video frame to be encoded in the reference frame of the inter-coded frame in the video sequence to be encoded, and the I frame in FIG. 2-4 is Target background frame, P frame after I frame is inter-coded frame, and I frame is used as video sequence to be encoded After the reference frame of the P frame is inserted into the video sequence to be encoded, when encoding, the P frame after the I frame can be encoded with reference to the I frame.
  • Step 205 Encode the encoded frame in the video sequence to be encoded in which the target background frame is inserted.
  • the encoded frame in which the target background frame is inserted includes a target background frame and an inter-coded frame.
  • the target background frame is encoded by using an intra-frame coding mode
  • the inter-coded frame is coded by referring to the target background frame by using an inter-frame coding mode.
  • the intra coding mode refers to the encoding process not referring to other frames, the intra coding mode is usually used for the start of a GOP, and the compression rate when encoding by the intra coding mode is low.
  • the inter-coding mode refers to that the encoding process needs to refer to a frame that has been previously encoded, and the compression ratio when encoding in the inter-coding mode is high.
  • the target background frame may be encoded according to a preset quantization step by using an intra coding mode, and the quantization step may be a smaller value. This quantization step size can be changed during the encoding process.
  • the target background frame since the target background frame only occupies a small portion of the video sequence to be encoded, although encoding the target background frame with a smaller quantization step size increases the consumed code rate, the entire video sequence to be encoded is used. The impact is small.
  • the target background frame since the target background frame is referenced by the subsequent inter-coded frame (such as P frame or B frame), the high quality part of the target background frame is copied to the subsequent inter-coded frame a large number of times. Therefore, encoding the target background frame according to the smaller quantization step by using the intra coding mode not only improves the quality of the inter-coded frame in the target background frame and the video sequence to be encoded, but also achieves consumption. The effect of small code rate.
  • the target background frame is encoded with high quality, and the target background frame is used as the long-term reference frame for the subsequent inter-coded frame to refer to the target background frame when encoding, in a relatively static scene.
  • the encoding process has the following advantages: 1. reducing the code rate consumed during encoding under the premise of ensuring video quality; 2. obtaining higher quality images in the background region; 3. reducing the respiratory effect generated during the encoding process.
  • the respiratory effect refers to a phenomenon in which the video is discontinuous caused by a large difference in the quality of adjacent frames; 4. when the foreground object is moved, the occluded background portion appears again in the image of the background region. quality.
  • the process of encoding the inter-coded frame by using the inter-frame coding mode may be: adding a syntax element of the target background frame in a parameter set of the inter-coded frame in the video sequence to be encoded.
  • This syntax element is used to indicate how the target background frame is used as a long-term reference frame.
  • the parameter set includes a sequence parameter set (English: Sequence Parameter Set; abbreviated as: SPS) and a reference picture set (English: Reference Picture Set; abbreviation: RPS).
  • the scene frame can be used by the corresponding decoder in a manner consistent with video international standards or video domestic standards.
  • the video international standard can be H.264 and H.265, etc.
  • H.264 is also called Advanced Video Coding (English: Advanced Video Coding; abbreviation: AVC)
  • H.265 is also called high-efficiency video coding (English: High EfficiencyVideo) Coding; referred to as: HEVC)
  • the domestic standard of video can be audio and video coding standard (English: Audio Video coding Standard; abbreviation: AVS).
  • H.264 is the International Telecommunication Union-Telecommunication Standardization Sector (English-Telecommunication Union-Telecommunication Standardization Sector: ITU-T) Video Coding Experts Group (English: Video Coding Experts Group; abbreviation: VCEG) and international standardization Joint video group composed of the organization (English: International Organization for Standardization; ISO) and the International Electrotechnical Commission (English: Moving Pictures Experts Group; MPEG) (English: JointVideo Team; referred to as: JVT) proposed a highly compressed digital video codec standard.
  • H.265 is a new video coding standard developed by ITU-TVCEG following H.264.
  • the video sequence to be encoded may also be added in the RPS of the inter-coded frame in the video sequence to be encoded.
  • the code stream generated when the target background frame is encoded may be transmitted to the decoder according to the prior art, and the reconstructed frame of the target background frame may be reconstructed.
  • the already encoded image needs to be decoded, and the decoded image is called a reconstructed frame
  • the reference frame buffer for reference to the inter-coded frame in the video sequence to be encoded.
  • Step 206 When all the candidate background frames in the at least one candidate background frame do not satisfy the preset rule, the existing frames in the video sequence to be encoded are video-encoded according to a reference relationship defined by the preset GOP structure.
  • the reference relationship defined by the preset GOP structure refers to a reference relationship between frames in a GOP.
  • the RPS defines a reference relationship between frames in a GOP, for example, the second frame needs The first frame is encoded with reference to the first frame, and the third frame needs to be encoded with reference to the first frame and the second frame, and the like.
  • the quality requirement is that the value of the quality indicator parameter is greater than the preset quality threshold
  • the step 206 may include: when the first quality indicator of all the candidate background frames in the at least one candidate background frame When the values are not greater than the quality threshold, the existing frames in the video sequence to be encoded are video-encoded according to the reference relationship defined by the preset GOP structure.
  • the preset GOP structure includes any one of an IPPP structure and an IBBBP structure, that is, the preset GOP structure may be a low-latency IPPP structure or an IBBBP structure with high coding efficiency, where IPPP
  • the structure and IBBBP structure refer to the encoded GOP structure.
  • IPPP is in a GOP, the first frame is an I frame, and the first frame is followed by a plurality of P frames.
  • IBBBP is in a GOP, the first frame is an I frame, the first frame is followed by 3 B frames, and the 3 B frames are followed by a P frame.
  • each frame represents a still image
  • I frame is a key frame
  • I frame is a complete reservation of the frame picture
  • P frame represents the difference between this frame and a previous key frame (or P frame)
  • P frame It is a difference frame
  • a B frame indicates the difference between this frame and the preceding and succeeding frames
  • the B frame is a bidirectional difference frame.
  • the preset GOP structure includes, but is not limited to, any one of an IPPP structure and an IBBBP structure, and the preset GOP structure may also be an IPPPP structure, which is not limited by the embodiment of the present invention.
  • 2-5 are schematic diagrams showing the structure of video encoding an existing frame in a video sequence to be encoded according to a reference relationship defined by an IPPPP structure.
  • the IPPPP structure in FIG. 2-5 is a preset GOP structure, followed by an IPPPP structure.
  • the P frame is an inter-coded frame. When all the candidate background frames in the at least one candidate background frame do not satisfy the preset rule, the P frame following the IPPPP structure in the video sequence to be encoded is referenced according to the IPPPP structure.
  • Video encoding is a schematic diagrams showing the structure of video encoding an existing frame in a video sequence to be encoded according to a reference relationship defined by an IPPPP structure.
  • the IPPPP structure in FIG. 2-5 is a preset GOP structure, followed
  • the first P frame after the IPPPP structure refers to the I frame in the IPPPP structure for video coding
  • the second P frame, the third P frame, and the fourth P frame after the IPPPP structure refer to the IPPPP structure.
  • Four P frames are video encoded.
  • the video coding may be performed according to other preset manners, such as performing video coding according to parameters such as the interval of the frame.
  • step 201 may be implemented by a background modeling module
  • step 202 may be selected by a background quality evaluation module and a reference frame structure.
  • the module (such as a reference frame structure selector) is implemented
  • step 203 can be implemented by a frame selection module
  • step 204 can be implemented by a background frame insertion module (such as a background frame inserter)
  • step 205 can be performed by a video coding module (video coding).
  • Step 206 can be implemented by a background quality evaluation module, a reference frame structure selection module, and a video coding module.
  • the video encoding method may not directly evaluate the quality of the background frame, but may use other signals to determine whether to insert the background frame. For example, in the case where the imaging device is in a dithered state, or in the case where the illumination intensity is in a rapidly changing state, or in the case where the noise intensity of the video image is greater than the preset noise intensity value, etc., it may be decided not to insert the background frame. .
  • a signal for indicating the jitter state of the image pickup device, a signal for indicating the light intensity, and a signal for indicating the noise intensity of the video image can be obtained by the sensing device.
  • the video encoding method can determine whether to insert a background frame or not, by directly evaluating the quality of the background frame, or by other signals, and determining whether to insert a background frame, for example, in the first preset. Inserting a background frame in the time period, while tracking and recording the code rate consumed by the video coding in the first preset time period and the quality of the reconstructed frame of the video image, in the second preset time period after the first preset time period The background frame is not inserted, and the code rate consumed by the video coding in the second preset time period and the quality of the reconstructed frame of the video image are tracked, and then the code rate of the two recordings and the quality of the reconstructed frame are compared, when the first When the code rate in the preset time period is smaller, and the quality of the reconstructed frame is better, the video frame is selected by inserting the background frame in the subsequent video encoding process; when the code rate in the second preset time period is more If the quality of the reconstructed frame is small,
  • a relatively complete and clear background frame can be obtained from the video captured by the surveillance camera, such as in the case of a still scene or a video with fewer foreground objects.
  • the background modeling method is difficult to obtain a relatively complete and clear, good quality background frame.
  • the background frame obtained by background modeling is More ambiguous, the quality of the background frame is poor, so the background frame is not suitable as a reference frame. For example, when a car passes under a pedestrian bridge, the surveillance camera set on the pedestrian bridge will shake, and when a large number of people pass by the surveillance camera, the surveillance camera will also shake, and when the indoor light is on and off.
  • the background frame selection method can ensure the quality of the background frame in the case that the foreground object is not much or the efficiency of the background modeling mode is decreased (such as monitoring camera shake), there are many current scene objects or scenes with frequent dynamic and static switching.
  • the background modeling method and the background frame selection method are used to improve the quality of the background frame, the effect of the background frame quality is relatively poor, and an additional burden is placed on the encoding, which reduces the coding efficiency, because the background frame needs to be occupied by the above two methods. Quite a lot of code streams.
  • the video coding method provided by the embodiment of the present invention is an adaptive selection of different background frames as parameters.
  • the method for testing a frame the method first determining whether the obtained background frame is suitable as a reference frame, and when the background frame is suitable as a reference frame, inserting the background frame into the video sequence to be encoded for inter-coding in the video sequence to be encoded Frame reference, and the method may also select a background frame that is most suitable as a reference frame from a plurality of background frames that are suitable as reference frames for reference to the inter-coded frame in the video sequence to be encoded; when the background frame is not suitable As a reference frame, the background frame is not inserted into the video sequence to be encoded, but the existing frame in the video sequence to be encoded is video-encoded according to the reference relationship defined by the preset GOP structure, so the adaptive selection background
  • the frame method avoids inserting a poor quality background frame into the video sequence to be encoded, improves the flexibility of inserting the background frame, improves the video coding quality, improves the
  • the video coding method can determine the target background in the candidate background frame that satisfies the preset rule when there is an alternative background frame that satisfies the preset rule in the at least one candidate background frame.
  • the background frame is not inserted, and the existing frame in the video sequence to be encoded is video-encoded according to the reference relationship defined by the preset GOP structure.
  • the background frame with poor quality is prevented from being inserted into the video to be encoded. In the sequence, therefore, the flexibility of inserting the background frame is improved, the efficiency of video coding is improved, the video coding quality is improved, the power consumption of the encoder is reduced, and the effect of video coding is improved.
  • An embodiment of the present invention provides a video encoding apparatus, which may be implemented as part or all of an encoder by software, hardware, or a combination of both. As shown in FIG. 3-1, the video encoding apparatus may include:
  • the first determining unit 410 is configured to determine whether each candidate background frame in the at least one candidate background frame satisfies a preset rule, and the at least one candidate background frame is a background frame obtained by using a preset background frame acquiring manner.
  • the first determining unit 420 is configured to determine the target background frame in the candidate background frame that satisfies the preset rule when there is an alternative background frame that satisfies the preset rule in the at least one candidate background frame.
  • the inserting unit 430 is configured to insert the target background frame as a reference frame of the inter-coded frame in the video sequence to be encoded into the video sequence to be encoded for video encoding.
  • the video encoding apparatus can determine in an alternative background frame that satisfies a preset rule when there is an alternative background frame that satisfies a preset rule in at least one candidate background frame.
  • the target background frame is inserted into the to-be-coded video sequence as the reference frame of the inter-coded frame in the video sequence to be encoded.
  • the poor quality background frame is prevented from being inserted into the to-be-coded video. In the sequence, therefore, the efficiency of video coding is improved.
  • the preset rule is: the quality indicator parameter of the background frame satisfies a preset quality requirement, and the quality indicator parameter is a parameter used to measure the quality of the background frame.
  • the first determining unit 420 is configured to determine, when the candidate background frame that meets the preset rule in the at least one candidate background frame is a background frame, directly determine the candidate background frame as the target background frame.
  • the background frame obtaining manner may be a background modeling manner, a background frame selection manner, or any other background frame acquisition manner, such as a frame pixel average method or a mixed Gaussian modeling method, and the background frame.
  • the acquisition manner may also be various combinations of the foregoing multiple background frame acquisition methods.
  • Each background frame acquisition method gets a background frame.
  • the background frame acquisition manner may include a background modeling manner and a background frame selection manner.
  • the preset GOP structure includes any one of an IPPP structure and an IBBBP structure.
  • the reference frame includes any one of a long-term reference frame and a short-term reference frame.
  • the quality indicator parameter is a first quality indicator
  • the value of the first quality indicator is equal to the similarity between the candidate background frame and the inter-coded frame to be encoded at the current time in the to-be-coded video sequence, and the quality requirement is: the quality indicator parameter.
  • the value of the value is greater than the preset quality threshold.
  • the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames.
  • the first determining unit 420 includes:
  • the first selection module 421 is configured to select, as the target background frame, a background frame with the largest value of the quality indicator parameter in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold.
  • the first determining unit 420 includes:
  • the second selecting module 422 is configured to randomly select a background frame as the target background frame in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold.
  • the quality requirement may also be: the value of the quality indicator parameter is greater than the random value generated during the video encoding process.
  • the quality requirement may be: the value of the quality indicator parameter is greater than the random value generated during the video encoding process.
  • the quality indicator parameter is a third quality indicator, and the value of the third quality indicator is equal to 1-P, where P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded, and the quality
  • P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded
  • the quality The requirement is that the value of the quality indicator parameter is smaller than the preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is smaller than the quality threshold includes at least two background frames, as shown in FIG. 3-4, the first determining unit 420, include:
  • the fourth selection module 423 is configured to select, as the target background frame, a background frame with the smallest value of the quality indicator parameter in the candidate background frame whose value of the quality indicator parameter is less than the quality threshold.
  • the first determining unit 420 includes:
  • the fifth selecting module 424 is configured to randomly select a background frame as the target background frame in the candidate background frame whose value of the quality indicator parameter is less than the quality threshold.
  • the quality requirement may also be: the value of the quality indicator parameter is smaller than the random value generated during the video encoding process.
  • the quality indicator parameter is a second quality indicator
  • the value of the second quality indicator is iteratively obtained by the value of the first quality indicator, where the value of the first quality indicator is equal to the current background time of the candidate background frame and the to-be-coded video sequence to be encoded.
  • the similarity of the inter-coded frame, the quality requirement is: the value of the quality indicator parameter is greater than the preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames, as shown in Figure 3-6.
  • the apparatus may further include: a second determining unit 440, configured to determine a value of the second quality indicator of each candidate background frame according to a value of the first quality indicator of each candidate background frame.
  • the first determining unit 420 includes:
  • the third selection module 425 is configured to select, as the target background frame, a background frame with the largest value of the quality indicator parameter in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold.
  • the second determining unit 440 includes:
  • a determining module 441 configured to calculate a value C(t) of the second quality indicator of each candidate background frame according to a quality calculation formula according to a value D(t) of the first quality indicator of each candidate background frame, and calculate a The mass calculation formula for the value of the two quality indicators C(t) is:
  • a is a weight coefficient and 0 ⁇ a ⁇ 1
  • t represents the number of frames.
  • each of the candidate background frames and the inter-coded frames to be encoded at the current time include at least one background block, as shown in FIG. 3-6.
  • the device further includes:
  • the second determining unit 450 is configured to determine whether a difference between a pixel of the first background block of the inter-coded frame to be encoded at the current time and a pixel of the second background block of each candidate background frame is less than a preset difference threshold.
  • the position of the first background block on the inter-coded frame to be encoded at the current time corresponds to the position of the second background block on each of the alternate background frames.
  • a first processing unit 460 configured, for each candidate background frame, when the pixels of the first background block are When the difference between the pixels of the two background blocks is less than the difference threshold, the second background block is taken as the target background block.
  • the third determining unit 470 is configured to determine the number of target background blocks on the candidate background frame.
  • the second processing unit 480 is configured to use a ratio of the number of target background blocks on the candidate background frame to the total number of background blocks as the similarity.
  • the device further includes:
  • the third processing unit 490 is configured to: when all the candidate background frames in the at least one candidate background frame do not satisfy the preset rule, perform the existing frame in the video sequence to be encoded according to the reference relationship defined by the preset GOP structure. Video coding.
  • the third processing unit 490 is further configured to: when all the candidate background frames in the at least one candidate background frame do not satisfy the preset rule, perform video encoding according to other preset manners, such as according to a frame interval and the like. Video encoding.
  • the apparatus further includes: an encoding unit 510, configured to encode a coded frame in a video sequence to be encoded in which a target background frame is inserted, where the coded frame in which the target background frame is inserted includes a target background frame and An inter-coded frame, wherein the target background frame is encoded in an intra-frame coding mode, and the inter-coded frame is encoded in an inter-frame coding mode with reference to a target background frame.
  • the first determining unit 410, the first determining unit 420, and the inserting unit 430 in FIGS. 3-6 can be explained with reference to FIG. 3-1.
  • the device further includes:
  • a first adding unit configured to add, in a parameter set of the inter-coded frame in the video sequence to be encoded, a syntax element of the target background frame, where the syntax element is used to indicate that the target background frame is used as a long-term reference frame.
  • the parameter set includes a sequence parameter set and a reference image set.
  • a second adding unit configured to add, in a parameter set of the inter-coded frame in the video sequence to be encoded, a syntax element of at least one inter-coded frame in the video sequence to be encoded.
  • the background frame obtaining unit is configured to acquire at least one candidate background frame by using a preset background frame acquisition manner.
  • the background frame obtaining unit may include:
  • the first background frame obtaining module is configured to acquire an alternate background frame by using a background modeling manner.
  • a second background frame obtaining module configured to acquire an alternate background frame by using a background frame selection manner.
  • each unit in FIG. 3-1 can be described with reference to the embodiment shown in FIG. 1.
  • the specific working process of each unit in FIG. 3-6 can be described with reference to the embodiment shown in FIG. 2-1.
  • the video encoding apparatus can be in at least one alternative background.
  • the target background frame is determined in the candidate background frame that satisfies the preset rule, and the target background frame is inserted as a reference frame of the inter-coded frame in the video sequence to be encoded.
  • the background frame is not inserted, and the existing frame in the video sequence to be encoded is according to the preset GOP structure.
  • the defined reference relationship is video-encoded.
  • the background frame with poor quality is prevented from being inserted into the video sequence to be encoded. Therefore, the flexibility of inserting the background frame is improved, and the efficiency of video coding is improved and improved.
  • the video encoding quality reduces the power consumption of the encoder and improves the effect of video encoding.
  • the video encoding apparatus includes a processor 1001, a memory 1002, a network interface 1003, and a bus 1004.
  • the bus 1004 is used to connect the processor 1001, the memory 1002, and the network interface 1003.
  • the processor 1001 is configured to execute the program 10021 stored in the memory 1002.
  • the processor 1001 can execute the program 10021 to implement the encoder and cause the encoder to perform the following video encoding method:
  • each candidate background frame in the at least one candidate background frame satisfies a preset rule, and the at least one candidate background frame is a background frame obtained by using a preset background frame acquisition manner;
  • the target background frame is inserted as a reference frame of the inter-coded frame in the video sequence to be encoded into the video sequence to be encoded for video encoding.
  • the preset rule is: the quality indicator parameter of the background frame satisfies a preset quality requirement, and the quality indicator parameter is a parameter used to measure the quality of the background frame.
  • the candidate background frame that satisfies the preset rule in the at least one candidate background frame is a background frame
  • the candidate background frame is directly determined as the target background frame.
  • the background frame obtaining manner may be a background modeling manner, a background frame selection manner, or any other background frame acquisition manner, such as a frame pixel average method or a mixed Gaussian modeling method, and the background frame.
  • the acquisition manner may also be various combinations of the foregoing multiple background frame acquisition methods. Each background frame acquisition method gets a background frame.
  • the quality indicator parameter is a first quality indicator
  • the value of the first quality indicator is equal to the similarity between the candidate background frame and the inter-coded frame to be encoded at the current time in the to-be-coded video sequence, and the quality requirement is: the quality indicator parameter.
  • the value of the quality indicator parameter is greater than the preset quality threshold, and the value of the quality indicator parameter is greater than the quality threshold.
  • the selected background frame includes at least two background frames, and the target background frame is determined in the candidate background frame that satisfies the preset rule, including:
  • the quality requirement may also be: the value of the quality indicator parameter is greater than the random value generated during the video encoding process.
  • the quality indicator parameter is a third quality indicator, and the value of the third quality indicator is equal to 1-P, where P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded, and the quality
  • P is the similarity between the candidate background frame and the inter-coded frame to be encoded at the current moment in the video sequence to be encoded
  • the quality The requirement is that the value of the quality indicator parameter is smaller than a preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is smaller than the quality threshold includes at least two background frames, and the target background frame is determined in the candidate background frame that satisfies the preset rule.
  • the quality requirement may also be: the value of the quality indicator parameter is smaller than the random value generated during the video encoding process.
  • the quality indicator parameter is a second quality indicator
  • the value of the second quality indicator is iteratively obtained by the value of the first quality indicator, where the value of the first quality indicator is equal to the current background time of the candidate background frame and the to-be-coded video sequence to be encoded.
  • the similarity of the inter-coded frame, the quality requirement is: the value of the quality indicator parameter is greater than a preset quality threshold, and the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold includes at least two background frames, and at least one device is determined.
  • the method further includes:
  • a value of a second quality indicator for each candidate background frame is determined based on a value of a first quality indicator for each candidate background frame.
  • the target background frame is determined in the candidate background frame that satisfies the preset rule, including:
  • a background frame having the largest value of the quality indicator parameter is selected as the target background frame in the candidate background frame whose value of the quality indicator parameter is greater than the quality threshold.
  • each candidate background frame The value of the second quality indicator, including:
  • a is a weight coefficient and 0 ⁇ a ⁇ 1
  • t represents the number of frames.
  • each of the candidate background frames and the inter-coded frames to be encoded at the current moment respectively include at least one background block, and the similarity between each candidate background frame and the inter-coded frame to be encoded at the current moment is calculated, including:
  • the second background block is used as the target background block
  • the ratio of the number of target background blocks on the alternate background frame to the total number of background blocks is taken as the similarity.
  • the method further includes:
  • the existing frames in the video sequence to be encoded are video-encoded according to a reference relationship defined by the preset GOP structure.
  • the video coding may be performed according to other preset manners, such as performing video coding according to parameters such as the interval of the frame.
  • the preset GOP structure includes any one of an IPPP structure and an IBBBP structure.
  • the background frame acquisition manner may include a background modeling manner and a background frame selection manner.
  • the method further includes:
  • the code mode is encoded, and the inter-coded frame is encoded by referring to the target background frame using the inter-frame coding mode.
  • the reference frame includes any one of a long-term reference frame and a short-term reference frame.
  • the method further includes:
  • a syntax element of the target background frame is added within a parameter set of the inter-coded frame in the video sequence to be encoded, and the syntax element is used to indicate the manner in which the target background frame is used as the long-term reference frame.
  • the method further includes:
  • a syntax element of at least one inter-coded frame in the video sequence to be encoded is added to a parameter set of an inter-coded frame in the video sequence to be encoded.
  • the parameter set includes a sequence parameter set and a reference image set.
  • the video encoding apparatus can determine the target background in the candidate background frame that satisfies the preset rule when there is an alternative background frame that satisfies the preset rule in the at least one candidate background frame.
  • the background frame is not inserted, and the existing frame in the video sequence to be encoded is video-encoded according to the reference relationship defined by the preset picture group GOP structure.
  • the background frame with poor quality is prevented from being inserted.
  • the flexibility of inserting the background frame is improved, the efficiency of video encoding is improved, the video encoding quality is improved, the power consumption of the encoder is reduced, and the effect of video encoding is improved.
  • the disclosed apparatus and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. You can choose some or all of them according to actual needs.
  • the unit is to achieve the purpose of the solution of the embodiment.
  • a person skilled in the art may understand that all or part of the steps of implementing the above embodiments may be completed by hardware, or may be instructed by a program to execute related hardware, and the program may be stored in a computer readable storage medium.
  • the storage medium mentioned may be a read only memory, a magnetic disk or an optical disk or the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

本发明公开了一种视频编码方法和装置,属于视频编码技术领域。该方法包括:判断至少一个备选背景帧中每个备选背景帧是否满足预设规则,至少一个备选背景帧是通过预设的背景帧获取方式得到的背景帧;当至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧;将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中进行视频编码,本发明解决了在无背景场景中插入背景帧时降低编码效率的问题,提高了视频编码的效率。

Description

视频编码方法和装置
本申请要求于2016年4月11日提交中国专利局、申请号为201610222405.9、发明名称为“视频编码方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及视频编码技术领域,特别涉及一种视频编码方法和装置。
背景技术
在视频录制场景中,为了减少视频的存储空间,需要进行视频编码,视频编码是指通过特定的压缩技术,将某个视频格式的文件转换成另一种视频格式文件的方式。为了进行视频编码,需要根据摄像装置(如监控摄像机)拍摄的视频确定参考帧,该参考帧为帧间编码帧(Inter frame)编码时所需参考的帧。
现有技术中主要通过背景建模方式或背景帧选取方式来确定参考帧,背景建模方式的具体过程为:先获取一段时间内输入到编码器的至少一个图像,再得到该至少一个图像中每个图像的背景区域图像,然后对所有图像的背景区域图像进行重新组合,通过建模方式得到一副完整的背景帧,接着将该背景帧插入到待编码视频序列中,且将该背景帧作为参考帧,以被该背景帧之后的帧间编码帧编码时所参考。参考帧包括长期参考帧和短期参考帧。该背景帧会被一直作为参考帧直到新的背景帧插入到待编码视频序列中。此外,可以将该背景帧作为待编码视频序列中的瞬时解码刷新(英文:Instantaneous Decoding Refresh;简称:IDR)帧,即首个帧内编码帧(帧内编码帧又称I帧),并使用较低量化参数进行编码。背景帧选取方式的具体过程为:先获取一段时间内输入到编码器的至少一个图像,再评估该至少一个图像中每个图像的背景区域所占比例,然后选取背景区域比例最高的图像作为背景帧,插入到待编码视频序列中,并将选取的背景帧作为参考帧。
上述方式能够在静止场景(如摄像装置始终处于静止状态)或视频的前景物体较少时,得到质量较好的背景帧,进而得到质量较好的参考帧,但由于实 际视频录制场景中,摄像装置所处背景的稳定程度或视频的前景物体的多少是无法预知的,所以当存在频繁进行动静切换(如摄像装置时而静止时而抖动)的场景或视频的前景物体较多时,上述方式得到的背景图像包含的背景区域较少或者较为模糊,背景帧的质量较差,最终得到的参考帧的质量较差,而如果继续将质量较差的背景帧插入待编码视频序列中,会降低编码效率。
发明内容
为了解决现有技术中视频编码过程中,在无背景场景中(例如存在频繁进行动静切换或视频的前景物体较多时)插入背景帧时降低编码效率的问题,本发明实施例提供了一种视频编码方法和装置。所述技术方案如下:
第一方面,提供了一种视频编码方法,该方法包括:
判断至少一个备选背景帧中每个备选背景帧是否满足预设规则,至少一个备选背景帧是通过预设的背景帧获取方式得到的背景帧;
当至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧;
将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,以进行视频编码。
该视频编码能够在至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧,并将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,该过程避免了将质量较差的背景帧插入待编码视频序列中占用码率,从而提高了视频编码的效率。
可选的,预设规则为:背景帧的质量指标参数满足预设的质量要求,该质量指标参数为用于衡量背景帧质量的参数。
可选的,当至少一个备选背景帧中满足预设规则的备选背景帧为一个背景帧时,则直接将该备选背景帧确定为目标背景帧。
可选的,背景帧获取方式可以为背景建模方式,也可以为背景帧选取方式,还可以为其他任一背景帧获取方式,如帧像素平均值方式或混合高斯建模方式等,背景帧获取方式还可以为上述多种背景帧获取方式的各种组合。每一种背景帧获取方式得到一个背景帧。
可选的,质量指标参数为第一质量指标,第一质量指标的值等于备选背景 帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,在满足预设规则的备选背景帧中确定目标背景帧,包括:
在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧;
或,在质量指标参数的值大于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
可选的,质量要求还可以为:质量指标参数的值大于视频编码过程中产生的随机值。
该视频编码方法能够通过质量指标参数决定将至少两种背景帧获取方式中的哪一种背景帧获取方式获取的备选背景帧作为待编码视频序列中的帧间编码帧的参考帧,提高了插入背景帧的灵活度和视频编码的效率。
可选的,质量指标参数为第三质量指标,第三质量指标的值等于1-P,P为备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值小于预设的质量阈值,质量指标参数的值小于质量阈值的备选背景帧包括至少两个背景帧,在满足预设规则的备选背景帧中确定目标背景帧,包括:
在质量指标参数的值小于质量阈值的备选背景帧中选择质量指标参数的值最小的背景帧作为目标背景帧;
或,在质量指标参数的值小于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
可选的,质量要求还可以为:质量指标参数的值小于视频编码过程中产生的随机值。
该视频编码方法能够通过质量指标参数决定将至少两种背景帧获取方式中的哪一种背景帧获取方式获取的备选背景帧作为待编码视频序列中的帧间编码帧的参考帧,提高了插入背景帧的灵活度和视频编码的效率。
可选的,质量指标参数为第二质量指标,第二质量指标的值由第一质量指标的值迭代得到,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景 帧,在判断至少一个备选背景帧中每个备选背景帧是否满足预设规则之前,该方法还包括:
根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的第二质量指标的值;
在满足预设规则的备选背景帧中确定目标背景帧,包括:
在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧。
该视频编码方法中的质量指标参数可以为第一质量指标,也可以为第二质量指标,还可以为第三质量指标,还可以为其他任一用于衡量背景帧质量的参数。该视频编码方法能够通过质量指标参数决定将至少两种背景帧获取方式中的哪一种背景帧获取方式获取的备选背景帧作为待编码视频序列中的帧间编码帧的参考帧,提高了插入背景帧的灵活度和视频编码的效率。该视频编码方法还可以在视频编码过程中,不断更新质量指标参数的值,从而能够准确判断是否插入背景帧。
可选的,根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的第二质量指标的值,包括:
根据每个备选背景帧的第一质量指标的值D(t)按照质量计算公式确定每个备选背景帧的第二质量指标的值C(t),并且计算第二质量指标的值C(t)的质量计算公式为:
Figure PCTCN2016105844-appb-000001
其中,a为权重系数,且0≤a≤1,t表示帧数。
可选的,每个备选背景帧和当前时刻待编码的帧间编码帧分别包括至少一个背景块,计算每个备选背景帧与当前时刻待编码的帧间编码帧的相似度,包括:
判断当前时刻待编码的帧间编码帧的第一背景块的像素与每个备选背景帧的第二背景块的像素的差值是否小于预设的差值阈值,第一背景块在当前时刻待编码的帧间编码帧上的位置与第二背景块在每个备选背景帧上的位置相对应;
对于每个备选背景帧,当第一背景块的像素与第二背景块的像素的差值小于差值阈值时,将第二背景块作为目标背景块,
确定备选背景帧上的目标背景块的个数,
将备选背景帧上的目标背景块的个数与背景块的总数的比值作为相似度。
该视频编码方法能够通过备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,确定备选背景帧的质量指标参数的值,从而判断至少一个备选背景帧中每个备选背景帧是否满足预设规则。
可选的,在判断至少一个备选背景帧中每个备选背景帧是否满足预设规则之后,该方法还包括:
当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,将待编码视频序列中的已有帧按照预设画面组(英文:Group of Picture;简称:GOP)结构所定义的参考关系进行视频编码。
可选的,当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,还可以按照其他预设方式进行视频编码,如按照帧的间隔等参数进行视频编码。
该视频编码方法能够在至少一个备选背景帧中所有备选背景帧均不满足预设规则时,则不插入背景帧,将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系或其他预设方式进行视频编码,相较于现有技术,提高了插入背景帧的灵活度。
可选的,预设GOP结构包括IPPP结构和IBBBP结构中的任意一种。
可选的,背景帧获取方式可以包括背景建模方式和背景帧选取方式。
可选的,在将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中之后,该方法还包括:
对插入了目标背景帧的待编码视频序列中的编码帧进行编码,该插入了目标背景帧的编码帧包括目标背景帧和帧间编码帧,其中,目标背景帧采用帧内编码模式进行编码,帧间编码帧采用帧间编码模式参考目标背景帧进行编码。
为了提高视频质量,可以采用帧内编码模式按照预设的量化步长对目标背景帧进行编码,采用帧内编码模式按照较小的量化步长对目标背景帧进行编码,不仅实现了提高目标背景帧和待编码视频序列中的帧间编码帧的质量的效果,还实现了消耗较小码率的效果。
可选的,参考帧包括长期参考帧和短期参考帧中的任意一种。
该视频编码方法中的目标背景帧不限于仅以长期参考帧的方式被待编码视频序列中的帧间编码帧所参考,在待编码视频序列的帧数不多,或者对额外 占用码率的要求不高的情况下,目标背景帧可以以短期参考帧的方式被待编码视频序列中的帧间编码帧所参考。
可选的,在将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中之后,该方法还包括:
在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素,语法元素用于指示目标背景帧作为长期参考帧的使用方式。
在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素,以对待编码视频序列中的帧间编码帧进行编码。
可选的,在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素之后,该方法还包括:
在待编码视频序列中的帧间编码帧的参数集内添加待编码视频序列中的至少一个帧间编码帧的语法元素。
待编码视频序列中的帧间编码帧可以参考目标背景帧,同时还可以参考其他一个或多个帧间编码帧,其他一个或多个帧间编码帧可以作为长期参考帧被待编码视频序列中的帧间编码帧所参考,也可以作为短期参考帧被待编码视频序列中的帧间编码帧所参考。
可选的,参数集包括序列参数集和参考图像集。
该视频编码方法还可以不直接评估背景帧的质量,而是通过其它一些信号来决定是否插入背景帧。如在摄像装置处于抖动状态的情况下,或者,在光照强度处于快速变化状态的情况下,或者,在视频图像的噪音强度大于预设噪音强度值的情况下等等都可以决定不插入背景帧。其中,用于指示摄像装置的抖动状态的信号、用于指示光照强度的信号及用于指示视频图像的噪音强度的信号均可以由感应装置获得。
该视频编码方法除了通过直接评估背景帧的质量,或通过其它一些信号来决定是否插入背景帧,还可以按照其它方式决定是否插入背景帧,如:在第一预设时间段内插入背景帧,同时跟踪记录第一预设时间段内的视频编码消耗的码率和视频图像的重构帧的质量,在第一预设时间段之后的第二预设时间段内不插入背景帧,同时跟踪记录第二预设时间段内的视频编码消耗的码率和视频图像的重构帧的质量,然后比较两次记录的码率和重构帧的质量,当第一预设时间段内的码率更小,且重构帧的质量更好时,在以后的视频编码过程中选择插入背景帧的方式进行视频编码;当第二预设时间段内的码率更小,且重构帧 的质量更好时,在以后的视频编码过程中选择不插入背景帧的方式进行视频编码。
第二方面,提供了一种视频编码装置,该装置包括:
第一判断单元,用于判断至少一个备选背景帧中每个备选背景帧是否满足预设规则,至少一个备选背景帧是通过预设的背景帧获取方式得到的背景帧;
第一确定单元,用于当至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧;
插入单元,用于将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,以进行视频编码。
可选的,预设规则为:背景帧的质量指标参数满足预设的质量要求,质量指标参数为用于衡量背景帧质量的参数。
可选的,第一确定单元用于当至少一个备选背景帧中满足预设规则的备选背景帧为一个背景帧时,则直接将该备选背景帧确定为目标背景帧。
可选的,背景帧获取方式可以为背景建模方式,也可以为背景帧选取方式,还可以为其他任一背景帧获取方式,如帧像素平均值方式或混合高斯建模方式等,背景帧获取方式还可以为上述多种背景帧获取方式的各种组合。每一种背景帧获取方式得到一个背景帧。
可选的,质量指标参数为第一质量指标,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,第一确定单元,包括:
第一选择模块,用于在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧;
或,第二选择模块,用于在质量指标参数的值大于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
可选的,质量指标参数为第一质量指标时,质量要求还可以为:质量指标参数的值大于视频编码过程中产生的随机值。
可选的,质量指标参数为第三质量指标,第三质量指标的值等于1-P,P为备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值小于预设的质量阈值,质量指标参数的值小于质量阈值的备选背景帧包括至少两个背景帧,第一确定单元,包括:
第四选择模块,用于在质量指标参数的值小于质量阈值的备选背景帧中选择质量指标参数的值最小的背景帧作为目标背景帧;
或,第五选择模块,用于在质量指标参数的值小于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
可选的,质量指标参数为第三质量指标时,质量要求还可以为:质量指标参数的值小于视频编码过程中产生的随机值。
可选的,质量指标参数为第二质量指标,第二质量指标的值由第一质量指标的值迭代得到,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,该装置还包括:
第二确定单元,用于根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的第二质量指标的值;
第一确定单元,包括:
第三选择模块,用于在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧。
可选的,第二确定单元,包括:
确定模块,用于根据每个备选背景帧的第一质量指标的值D(t)按照质量计算公式计算每个备选背景帧的第二质量指标的值C(t),并且计算第二质量指标的值C(t)的质量计算公式为:
Figure PCTCN2016105844-appb-000002
其中,a为权重系数,且0≤a≤1,t表示帧数。
可选的,每个备选背景帧和当前时刻待编码的帧间编码帧分别包括至少一个背景块,该装置还包括:
第二判断单元,用于判断当前时刻待编码的帧间编码帧的第一背景块的像素与每个备选背景帧的第二背景块的像素的差值是否小于预设的差值阈值,第一背景块在当前时刻待编码的帧间编码帧上的位置与第二背景块在每个备选背景帧上的位置相对应;
第一处理单元,用于对于每个备选背景帧,当第一背景块的像素与第二背景块的像素的差值小于差值阈值时,将第二背景块作为目标背景块,
第三确定单元,用于确定备选背景帧上的目标背景块的个数,
第二处理单元,用于将备选背景帧上的目标背景块的个数与背景块的总数的比值作为相似度。
可选的,该装置还包括:
第三处理单元,用于当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系进行视频编码。
可选的,第三处理单元,还用于当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,按照其他预设方式进行视频编码,如按照帧的间隔等参数进行视频编码。
可选的,预设GOP结构包括IPPP结构和IBBBP结构中的任意一种。
可选的,背景帧获取方式可以包括背景建模方式和背景帧选取方式。
可选的,该装置还包括:
编码单元,用于对插入了目标背景帧的待编码视频序列中的编码帧进行编码,插入了目标背景帧的编码帧包括目标背景帧和帧间编码帧,其中,目标背景帧采用帧内编码模式进行编码,帧间编码帧采用帧间编码模式参考目标背景帧进行编码。
可选的,参考帧包括长期参考帧和短期参考帧中的任意一种。
可选的,该装置还包括:
第一添加单元,用于在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素,语法元素用于指示目标背景帧作为长期参考帧的使用方式。
可选的,该装置还包括:
第二添加单元,用于在待编码视频序列中的帧间编码帧的参数集内添加待编码视频序列中的至少一个帧间编码帧的语法元素。
可选的,参数集包括序列参数集和参考图像集。
第三方面,提供了一种视频编码装置,该装置包括:处理器、存储器、网络接口和总线。其中,总线用于连接处理器、存储器和网络接口,处理器用于执行存储器中存储的程序。处理器可以执行该程序来实现编码器,并使得该编码器执行下述视频编码方法:
判断至少一个备选背景帧中每个备选背景帧是否满足预设规则,至少一个 备选背景帧是通过预设的背景帧获取方式得到的背景帧;
当至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧;
将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,以进行视频编码。
可选的,预设规则为:背景帧的质量指标参数满足预设的质量要求,质量指标参数为用于衡量背景帧质量的参数。
可选的,当至少一个备选背景帧中满足预设规则的备选背景帧为一个背景帧时,则直接将该备选背景帧确定为目标背景帧。
可选的,背景帧获取方式可以为背景建模方式,也可以为背景帧选取方式,还可以为其他任一背景帧获取方式,如帧像素平均值方式或混合高斯建模方式等,背景帧获取方式还可以为上述多种背景帧获取方式的各种组合。每一种背景帧获取方式得到一个背景帧。
可选的,质量指标参数为第一质量指标,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,在满足预设规则的备选背景帧中确定目标背景帧,包括:
在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧;
或,在质量指标参数的值大于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
可选的,质量指标参数为第一质量指标时,质量要求还可以为:质量指标参数的值大于视频编码过程中产生的随机值。
可选的,质量指标参数为第三质量指标,第三质量指标的值等于1-P,P为备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值小于预设的质量阈值,质量指标参数的值小于质量阈值的备选背景帧包括至少两个背景帧,在满足预设规则的备选背景帧中确定目标背景帧,包括:
在质量指标参数的值小于质量阈值的备选背景帧中选择质量指标参数的值最小的背景帧作为目标背景帧;
或,在质量指标参数的值小于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
可选的,质量指标参数为第三质量指标时,质量要求还可以为:质量指标参数的值小于视频编码过程中产生的随机值。
可选的,质量指标参数为第二质量指标,第二质量指标的值由第一质量指标的值迭代得到,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,在判断至少一个备选背景帧中每个备选背景帧是否满足预设规则之前,该方法还包括:
根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的第二质量指标的值;
在满足预设规则的备选背景帧中确定目标背景帧,包括:
在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧。
可选的,根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的第二质量指标的值,包括:
根据每个备选背景帧的第一质量指标的值D(t)按照质量计算公式确定每个备选背景帧的第二质量指标的值C(t),并且计算第二质量指标的值C(t)的质量计算公式为:
Figure PCTCN2016105844-appb-000003
其中,a为权重系数,且0≤a≤1,t表示帧数。
可选的,每个备选背景帧和当前时刻待编码的帧间编码帧分别包括至少一个背景块,计算每个备选背景帧与当前时刻待编码的帧间编码帧的相似度,包括:
判断当前时刻待编码的帧间编码帧的第一背景块的像素与每个备选背景帧的第二背景块的像素的差值是否小于预设的差值阈值,第一背景块在当前时刻待编码的帧间编码帧上的位置与第二背景块在每个备选背景帧上的位置相对应;
对于每个备选背景帧,当第一背景块的像素与第二背景块的像素的差值小 于差值阈值时,将第二背景块作为目标背景块,
确定备选背景帧上的目标背景块的个数,
将备选背景帧上的目标背景块的个数与背景块的总数的比值作为相似度。
可选的,在判断至少一个备选背景帧中每个备选背景帧是否满足预设规则之后,该方法还包括:
当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系进行视频编码。
可选的,当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,还可以按照其他预设方式进行视频编码,如按照帧的间隔等参数进行视频编码。
可选的,预设GOP结构包括IPPP结构和IBBBP结构中的任意一种。
可选的,背景帧获取方式可以包括背景建模方式和背景帧选取方式。
可选的,在将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中之后,该方法还包括:
对插入了目标背景帧的待编码视频序列中的编码帧进行编码,插入了目标背景帧的编码帧包括目标背景帧和帧间编码帧,其中,目标背景帧采用帧内编码模式进行编码,帧间编码帧采用帧间编码模式参考目标背景帧进行编码。
可选的,参考帧包括长期参考帧和短期参考帧中的任意一种。
可选的,在将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中之后,该方法还包括:
在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素,语法元素用于指示目标背景帧作为长期参考帧的使用方式。
可选的,在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素之后,该方法还包括:
在待编码视频序列中的帧间编码帧的参数集内添加待编码视频序列中的至少一个帧间编码帧的语法元素。
可选的,参数集包括序列参数集和参考图像集。
本发明实施例提供的技术方案带来的有益效果是:
本发明实施例提供了一种视频编码方法和装置,能够在至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧,并将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插 入待编码视频序列中,相较于现有技术,避免了将质量较差的背景帧插入待编码视频序列中,因此,提高了视频编码的效率。
附图说明
图1是本发明实施例提供的一种视频编码方法的流程图;
图2-1是本发明实施例提供的另一种视频编码方法的流程图;
图2-2是本发明实施例提供的一种确定备选背景帧的质量指标参数的值的流程图;
图2-3是一个备选背景帧和当前时刻待编码的帧间编码帧的结构示意图;
图2-4是图2-1所示实施例中将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中之后的待编码视频序列的结构示意图;
图2-5是图2-1所示实施例中将待编码视频序列中的已有帧按照IPPPP结构所定义的参考关系进行视频编码的结构示意图;
图3-1是本发明实施例提供的一种视频编码装置的结构示意图;
图3-2是图3-1所示实施例中一种第一确定单元的结构示意图;
图3-3是图3-1所示实施例中另一种第一确定单元的结构示意图;
图3-4是图3-1所示实施例中又一种第一确定单元的结构示意图;
图3-5是图3-1所示实施例中再一种第一确定单元的结构示意图;
图3-6是本发明实施例提供的另一种视频编码装置的结构示意图;
图3-7是图3-1所示实施例中一种第一确定单元的结构示意图;
图3-8是图3-6所示实施例中一种第二确定单元的结构示意图;
图4是本发明实施例提供的一种视频编码装置的结构示意图。
具体实施方式
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本发明实施方式作进一步地详细描述。
本发明实施例提供了一种视频编码方法,用于编码器,如图1所示,该视频编码方法包括:
步骤101、判断至少一个备选背景帧中每个备选背景帧是否满足预设规则,该至少一个备选背景帧是通过预设的背景帧获取方式得到的背景帧。
步骤102、当至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧。
步骤103、将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,以进行视频编码。
综上所述,本发明实施例提供的视频编码方法,该方法能够在至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧,并将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,相较于现有技术,避免了将质量较差的背景帧插入待编码视频序列中,因此,提高了视频编码的效率。
本发明实施例提供了另一种视频编码方法,用于编码器,如图2-1所示,该视频编码方法可以包括:
步骤201、通过预设的背景帧获取方式获取至少一个备选背景帧。
至少一个备选背景帧可以设置在一个背景帧库中。背景帧获取方式可以包括一种背景帧获取方式,也可以包括至少两种背景帧获取方式。示例的,背景帧获取方式可以为背景建模方式,也可以为背景帧选取方式,还可以为其他任一背景帧获取方式,如帧像素平均值方式或混合高斯建模方式等,还可以为上述多种背景帧获取方式的各种组合,每一种背景帧获取方式可以得到一个背景帧。本发明实施例对背景帧获取方式的具体形式不做限定。
步骤202、判断至少一个备选背景帧中每个备选背景帧是否满足预设规则。
可选的,该预设规则可以为:背景帧的质量指标参数满足预设的质量要求,该质量指标参数为用于衡量背景帧质量的参数。
可选的,质量指标参数可以为第一质量指标,该第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度时,质量要求可以为:质量指标参数的值大于预设的质量阈值(该质量阈值可以通过实验统计得到),第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,所以质量指标参数的值越大,表明背景帧的质量越好。此外,质量要求还可以为:质量指标参数的值大于视频编码过程中产生的随机值。本发明实施例对质量要求的内容不做限定。
质量指标参数也可以为第三质量指标,该第三质量指标的值等于1-P时,其中,P为备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相 似度,质量要求可以为:质量指标参数的值小于预设的质量阈值,第三质量指标的值等于1-P,所以质量指标参数的值越小,表明背景帧的质量越好。此外,质量要求还可以为:质量指标参数的值小于视频编码过程中产生的随机值。本发明实施例对质量要求的内容不做限定。
在步骤202之前,如图2-2所示,该视频编码方法还可以包括:
步骤2021、计算每个备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度。
具体的,每个备选背景帧和当前时刻待编码的帧间编码帧分别包括至少一个背景块。图2-3示出了某一备选背景帧和当前时刻待编码的帧间编码帧的结构示意图。图2-3中,备选背景帧和当前时刻待编码的帧间编码帧包括2*2个背景块,即备选背景帧包括4个背景块,当前时刻待编码的帧间编码帧包括4个背景块。如图2-3所示,该备选背景帧包括背景块D1,背景块D2,背景块D3和背景块D4。当前时刻待编码的帧间编码帧包括背景块E1,背景块E2,背景块E3和背景块E4。背景块D1在该备选背景帧上的位置与背景块E1在当前时刻待编码的帧间编码帧上的位置相对应;背景块D2在该备选背景帧上的位置与背景块E2在当前时刻待编码的帧间编码帧上的位置相对应;背景块D3在该备选背景帧上的位置与背景块E3在当前时刻待编码的帧间编码帧上的位置相对应;背景块D4在该备选背景帧上的位置与背景块E4在当前时刻待编码的帧间编码帧上的位置相对应。
相应的,步骤2021可以包括:
判断当前时刻待编码的帧间编码帧的第一背景块的像素与每个备选背景帧的第二背景块的像素的差值是否小于预设的差值阈值。第一背景块在当前时刻待编码的帧间编码帧上的位置与第二背景块在每个备选背景帧上的位置相对应。示例的,假设预设的差值阈值为y,且y大于0,那么可以通过该过程来判断第一背景块的像素与第二背景块的像素的差值的绝对值是否小于y。
其中,对于每个备选背景帧,当第一背景块的像素与第二背景块的像素的差值小于差值阈值时,将第二背景块作为目标背景块,再确定备选背景帧上的目标背景块的个数,最后将备选背景帧上的目标背景块的个数与背景块的总数的比值作为相似度。假设差值阈值为y(y>0),那么对于每个备选背景帧,当第一背景块的像素与第二背景块的像素的差值的绝对值小于y时,就可以将第二背景块作为目标背景块,然后统计满足该条件的目标背景块的总个数,最后 将每个备选背景帧上的目标背景块的个数与背景块的总数的比值作为相似度,从而确定每个备选背景帧的质量指标参数的值。
以图2-3为例,假设差值阈值为y(y>0),背景块E1的像素与背景块D1的像素的差值的绝对值小于y,背景块E2的像素与背景块D2的像素的差值的绝对值大于y,背景块E3的像素与背景块D3的像素的差值的绝对值大于y,背景块E4的像素与背景块D4的像素的差值的绝对值大于y,那么该备选背景帧上的目标背景块的个数为1,因此,当前时刻待编码的帧间编码帧与该备选背景帧的相似度为1/4。
步骤2022、根据相似度确定每个备选背景帧的第一质量指标的值或第三质量指标的值。
一方面,可以根据备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度确定备选背景帧的第一质量指标的值,具体的,可以将备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度作为该备选背景帧的第一质量指标的值;另一方面,可以根据备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度确定备选背景帧的第三质量指标的值,具体的,可以将1-P的值作为备选背景帧的第三质量指标的值,其中,P为该备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度。
相应的,如果步骤2022中将相似度作为每个备选背景帧的第一质量指标的值,那么步骤202可以包括:判断至少一个备选背景帧中每个备选背景帧的质量指标参数的值是否大于质量阈值,即判断至少一个备选背景帧中每个备选背景帧的第一质量指标的值是否大于质量阈值,示例的,假设该质量阈值为z,至少一个备选背景帧包括背景帧F1,背景帧F2和背景帧F3,假设背景帧F1的第一质量指标的值为w1,背景帧F2的第一质量指标的值为w2,背景帧F3的第一质量指标的值为w3,那么可以判断w1是否大于z,w2是否大于z,w3是否大于z。如果步骤2022中将1-P的值作为每个备选背景帧的第三质量指标的值,那么步骤202可以包括:判断至少一个备选背景帧中每个备选背景帧的质量指标参数的值是否小于质量阈值,即判断至少一个备选背景帧中每个备选背景帧的第一质量指标的值是否小于质量阈值。该质量阈值为第三质量指标对应的质量阈值。
可选的,质量指标参数还可以为第二质量指标,第二质量指标的值由第一 质量指标的值迭代得到,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求可以为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧。当质量指标参数为第二质量指标时,在步骤202之前,该视频编码方法还可以包括:根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的第二质量指标的值。
具体的,根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的第二质量指标的值,包括:
根据每个备选背景帧的第一质量指标的值D(t)按照质量计算公式计算每个备选背景帧的第二质量指标的值C(t),并且计算第二质量指标的值C(t)的质量计算公式为:
Figure PCTCN2016105844-appb-000004
该质量计算公式中,a为权重系数,且0≤a≤1,t表示帧数。D(t)指的是第t帧的备选背景帧的第一质量指标的值,也就是第t帧的帧间编码帧(当前时刻待编码的帧间编码帧)与第t帧的备选背景帧的相似度,该第t帧的备选背景帧指的是根据第0至第t-1帧的帧间编码帧通过背景帧获取方式得到的备选背景帧。示例的,当计算第一个备选背景帧的第二质量指标的值时,假设待编码视频序列中当前时刻待编码的帧间编码帧为第2帧,即t=2,那么第一个备选背景帧的第二质量指标的值C(2)=C(1)*(1-a)+D(2)*a,其中,C(1)=C(0)*(1-a)+D(1)*a,C(0)=D(0),所以,为了得到C(2),需要先确定D(0),D(1)和D(2)。其中,D(0)为第0帧的备选背景帧的第一质量指标的值,即第0帧的帧间编码帧与第0帧的备选背景帧的相似度;D(1)指的是第1帧的备选背景帧的第一质量指标的值,即第1帧的帧间编码帧与第1帧的备选背景帧的相似度;D(2)指的是第2帧的备选背景帧的第一质量指标的值,即第2帧的帧间编码帧与第2帧的备选背景帧的相似度。
当质量指标参数为第二质量指标时,步骤202可以包括:判断至少一个备选背景帧中每个备选背景帧的质量指标参数的值是否大于质量阈值,即判断至少一个备选背景帧中每个备选背景帧的第二质量指标的值是否大于质量阈值。该质量阈值为第二质量指标对应的质量阈值。该质量阈值可以通过实验统计得到。
需要说明的是,质量指标参数可以为第一质量指标,也可以为第二质量指标,还可以为第三质量指标,还可以为其他任一用于衡量背景帧质量的参数。本发明实施例对此不做限定。该视频编码方法还可以在视频编码过程中,不断更新质量指标参数的值,从而能够准确判断是否插入背景帧。
步骤203、当至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧。执行步骤204。
可选的,当至少一个备选背景帧中满足预设规则的备选背景帧为一个背景帧时,则直接将该备选背景帧确定为目标背景帧。
可选的,质量指标参数为第一质量指标,该第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,一方面,步骤203可以包括:在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧,即在第一质量指标的值大于质量阈值的备选背景帧中选择第一质量指标的值最大的背景帧作为目标背景帧,以步骤202中的背景帧F1,背景帧F2和背景帧F3为例进行说明,已知背景帧F1的第一质量指标的值为w1,背景帧F2的第一质量指标的值为w2,背景帧F3的第一质量指标的值为w3,质量阈值为z,同时根据步骤202判断得到w1小于z,w2大于z,w3大于z,且w2大于w3,因此,按照该种确定目标背景帧的方式可以将背景帧F2作为目标背景帧。该种方式通过对备选背景帧的质量指标参数的值进行比较得到目标背景帧,提高了视频编码的鲁棒性。
另一方面,步骤203可以包括:在质量指标参数的值大于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧,即在第一质量指标的值大于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。同样的,以步骤202中的背景帧F1,背景帧F2和背景帧F3为例进行说明,由于背景帧F2的短期质量指标第一质量指标的值为w2(w2大于质量阈值z),背景帧F3的短期质量指标第一质量指标的值为w3(w3也大于质量阈值z),因此,按照该种确定目标背景帧的方式可以从背景帧F2和背景帧F3中随机选择一个背景帧作为目标背景帧,即可以将背景帧F2作为目标背景帧,也可以将背景帧F3作为目标背景帧。
示例的,假设步骤201是通过一种背景帧获取方式(如背景建模方式)获 取一个备选背景帧,那么当该备选背景帧的第一质量指标的值大于质量阈值时,可以直接将该备选背景帧确定为目标背景帧,并将该目标背景帧作为待编码视频序列中的帧间编码帧的参考帧;假设步骤201是通过三种背景帧获取方式获取三个备选背景帧,那么当该三个备选背景帧中存在第一质量指标的值大于质量阈值的备选背景帧时,如第一质量指标的值大于质量阈值的备选背景帧的个数为2,可以在第一质量指标的值大于质量阈值的备选背景帧中确定一个目标背景帧作为待编码视频序列中的帧间编码帧的参考帧,确定一个目标背景帧时可以在第一质量指标的值大于质量阈值的备选背景帧中选择第一质量指标参数的值最大的背景帧作为目标背景帧,也可以在第一质量指标的值大于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。如第一质量指标的值大于质量阈值的备选背景帧的个数为1,则直接将该备选背景帧作为目标背景帧。所以,本发明实施例提供的视频编码方法,能够决定是否将由一种背景帧获取方式获取的备选背景帧作为待编码视频序列中的帧间编码帧的参考帧,也能够决定将至少两种背景帧获取方式中的哪一种背景帧获取方式获取的备选背景帧作为待编码视频序列中的帧间编码帧的参考帧,提高了插入背景帧的灵活度和视频编码的效率。
可选的,质量指标参数为第三质量指标,第三质量指标的值等于1-P,其中,P为备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值小于预设的质量阈值,质量指标参数的值小于质量阈值的备选背景帧包括至少两个背景帧,一方面,步骤203可以包括:在质量指标参数的值小于质量阈值的备选背景帧中选择质量指标参数的值最小的背景帧作为目标背景帧。另一方面,步骤203可以包括:在质量指标参数的值小于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。质量指标参数为第三质量指标时,在满足预设规则的备选背景帧中确定目标背景帧的过程可以参考质量指标参数为第一质量指标时,在满足预设规则的备选背景帧中确定目标背景帧的过程。
可选的,质量指标参数为第二质量指标,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,相应的,步骤203可以包括:在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧,即在第二质量指标的值大于质量阈值的备选背景帧中选择第二质量指标的值最大的 背景帧作为目标背景帧。同样的,假设步骤201是通过一种背景帧获取方式(如背景建模方式)获取一个备选背景帧,那么当该备选背景帧的第二质量指标的值大于质量阈值时,可以直接将该备选背景帧确定为目标背景帧,并将该目标背景帧作为待编码视频序列中的帧间编码帧的参考帧;假设步骤201是通过三种背景帧获取方式获取三个备选背景帧,那么当该三个备选背景帧中存在第二质量指标的值大于质量阈值的备选背景帧时,如第二质量指标的值大于质量阈值的备选背景帧的个数为2,可以在第二质量指标的值大于质量阈值的备选背景帧中确定一个目标背景帧作为待编码视频序列中的帧间编码帧的参考帧,例如,可以在第二质量指标的值大于质量阈值的备选背景帧中选择第二质量指标的值最大的背景帧作为目标背景帧。如第二质量指标的值大于质量阈值的备选背景帧的个数为1,则直接将该备选背景帧作为目标背景帧。本发明实施例对在第二质量指标的值大于质量阈值的备选背景帧中确定一个目标背景帧的方式不做限定。
步骤204、将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,以进行视频编码。执行步骤205。
现有技术中,参考帧包括长期参考帧和短期参考帧。长期参考帧相较于短期参考帧,可以被待编码视频序列中更远的帧间编码帧所参考。例如,短期参考帧的有效范围为16帧(即短期参考帧之后的16个帧间编码帧可以参考该短期参考帧),长期参考帧的有效范围可以超出16帧(即长期参考帧之后的多于16个帧间编码帧可以参考该长期参考帧)。
本发明实施例中的参考帧包括长期参考帧和短期参考帧中的任意一种,本发明实施例中的参考帧可以为长期参考帧,也可以为短期参考帧,也即本发明实施例中的目标背景帧不限于仅以长期参考帧的方式被待编码视频序列中的帧间编码帧所参考,在待编码视频序列的帧数不多,或者对额外占用码率的要求不高的情况下,目标背景帧可以以短期参考帧的方式被待编码视频序列中的帧间编码帧所参考。本发明实施例对参考帧的具体形式不做限定。由于目标背景帧是隔一段时间才插入的,所以在实际应用中,可以在确定出的目标背景帧中插入一个检测点,该检测点用于指示开始编码一个GOP。
图2-4示出了将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中之后的待编码视频序列的结构示意图,图2-4中的I帧为目标背景帧,I帧之后的P帧为帧间编码帧,将I帧作为待编码视频序列中 的P帧的参考帧插入待编码视频序列中之后,进行编码时,可以参考I帧对I帧之后的P帧进行编码。
步骤205、对插入了目标背景帧的待编码视频序列中的编码帧进行编码。
插入了目标背景帧的编码帧包括目标背景帧和帧间编码帧。其中,目标背景帧采用帧内编码模式进行编码,帧间编码帧采用帧间编码模式参考目标背景帧进行编码。帧内编码模式指的是编码过程不参考其他帧,帧内编码模式通常用于一个GOP的开始,采用帧内编码模式进行编码时的压缩率较低。帧间编码模式指的是编码过程需要参考之前已经编码过的帧,采用帧间编码模式进行编码时的压缩率较高。进一步的,为了提高视频质量,可以采用帧内编码模式按照预设的量化步长对目标背景帧进行编码,该量化步长可以为一个较小值。该量化步长在编码过程中是可以改变的。
需要说明的是,由于目标背景帧仅占待编码视频序列的一小部分,所以,虽然采用较小的量化步长对目标背景帧进行编码会增加消耗的码率,但对整个待编码视频序列的影响较小。同时,由于目标背景帧会被之后的帧间编码帧(如P帧或B帧)所参考,所以目标背景帧中的高质量的部分会被大量多次地复制到之后的帧间编码帧中,因此,采用帧内编码模式按照较小的量化步长对目标背景帧进行编码,不仅实现了提高目标背景帧和待编码视频序列中的帧间编码帧的质量的效果,还实现了消耗较小码率的效果。
在视频编码过程中,对目标背景帧进行高质量的编码,并将该目标背景帧作为长期参考帧以供之后的帧间编码帧在编码时都参考该目标背景帧,在相对静止的场景下,该编码过程具有如下几个优点:1、在保证视频质量的前提下减小编码时消耗的码率;2、在背景区域获取较高质量的图像;3、减少编码过程中产生的呼吸效应,该呼吸效应指的是相邻帧的质量存在的较大差异而引起的让人感到视频不连续的现象;4、提高前景物体移动时,被遮挡的背景部分再次出现在背景区域的图像的质量。
具体的,参考目标背景帧,采用帧间编码模式对帧间编码帧进行编码的过程可以为:在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素。该语法元素用于指示目标背景帧作为长期参考帧的使用方式。该参数集包括序列参数集(英文:Sequence Parameter Set;简称:SPS)和参考图像集(英文:Reference Picture Set;简称:RPS)。在待编码视频序列中的帧间编码帧的SPS和RPS中以长期参考帧的方式添加语法元素,能够确保该目标背 景帧可以以符合视频国际标准或视频国内标准的方式被相应的解码器使用。其中,视频国际标准可以为H.264和H.265等,H.264又称作高级视频编码(英文:AdvancedVideo Coding;简称:AVC),H.265又称作高效视频编码(英文:High EfficiencyVideo Coding;简称:HEVC),视频国内标准可以为音视频编码标准(英文:Audio Video coding Standard;简称:AVS)。其中,H.264是由国际电信联盟远程通信标准化组织(英文:International Telecommunication Union-Telecommunication Standardization Sector;简称:ITU-T)视频编码专家组(英文:Video Coding Experts Group;简称:VCEG)和国际标准化组织(英文:International Organization for Standardization;简称:ISO)和国际电工委员会(英文:International Electrotechnical Commission;简称:IEC)动态图像专家组(英文:Moving Pictures Experts Group;简称:MPEG)联合组成的联合视频组(英文:JointVideo Team;简称:JVT)提出的高度压缩数字视频编解码器标准。H.265是ITU-TVCEG继H.264之后所制定的新的视频编码标准。
需要说明的是,在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素之后,还可以在待编码视频序列中的帧间编码帧的RPS内添加待编码视频序列中的至少一个帧间编码帧的语法元素,以便于被待编码视频序列中的帧间编码帧所参考。也就是说,待编码视频序列中的帧间编码帧可以参考目标背景帧,同时还可以参考其他一个或多个帧间编码帧,其他一个或多个帧间编码帧可以作为长期参考帧被待编码视频序列中的帧间编码帧所参考,也可以作为短期参考帧被待编码视频序列中的帧间编码帧所参考。
需要补充说明的是,采用帧内编码模式对目标背景帧进行编码后,可以按照现有技术将对目标背景帧进行编码时产生的码流传输至解码器,同时将目标背景帧的重构帧(在编码的过程中,需要对已经编码的图像进行解码,解码后的图像称作重构帧)存储在参考帧缓存中,以供待编码视频序列中的帧间编码帧参考。
步骤206、当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系进行视频编码。
预设GOP结构所定义的参考关系指的是在一个GOP中各帧之间的参考关系,现有技术中,RPS定义了在一个GOP中各帧之间的参考关系,比如,第2帧需要参考第1帧进行编码,第3帧需要参考第1帧和第2帧进行编码等等。
以质量指标参数为第一质量指标为例,质量要求为质量指标参数的值大于预设的质量阈值,步骤206可以包括:当至少一个备选背景帧中所有备选背景帧的第一质量指标的值均不大于质量阈值时,将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系进行视频编码。
可选的,该预设GOP结构包括IPPP结构和IBBBP结构中的任意一种,即该预设GOP结构可以为低延时的IPPP结构,也可以为编码效率较高的IBBBP结构,其中,IPPP结构和IBBBP结构指的是编码的GOP结构,IPPP是在一个GOP中,第一帧为I帧,第一帧之后为多个P帧。IBBBP是在一个GOP中,第一帧为I帧,第一帧之后为3个B帧,3个B帧之后为一个P帧。视频压缩中,每帧代表一幅静止的图像,I帧是关键帧,I帧是对本帧画面的完整保留;P帧表示本帧与之前的一个关键帧(或P帧)的差别,P帧为差别帧;B帧表示本帧与前后帧的差别,B帧为双向差别帧。
需要说明的是,该预设GOP结构包括但不限于IPPP结构和IBBBP结构中的任意一种,预设GOP结构还可以为IPPPP结构,本发明实施例对此不做限定。图2-5示出了将待编码视频序列中的已有帧按照IPPPP结构所定义的参考关系进行视频编码的结构示意图,图2-5中的IPPPP结构为预设GOP结构,IPPPP结构之后的P帧为帧间编码帧,当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,将待编码视频序列中的IPPPP结构之后的P帧按照IPPPP结构所定义的参考关系进行视频编码。具体的,IPPPP结构之后的第一个P帧参考IPPPP结构中的I帧进行视频编码,IPPPP结构之后的第二个P帧、第三个P帧及第四个P帧参考IPPPP结构中的第四个P帧进行视频编码。
需要说明的是,当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,还可以按照其他预设方式进行视频编码,如按照帧的间隔等参数进行视频编码。
需要补充的是,本发明实施例提供的视频编码方法中的步骤可以通过不同功能的模块实现,如步骤201可以通过背景建模模块来实现,步骤202可以通过背景质量评估模块和参考帧结构选择模块(如参考帧结构选择器)来实现,步骤203可以通过选帧模块来实现,步骤204可以通过背景帧插入模块(如背景帧插入器)来实现,步骤205可以通过视频编码模块(视频编码器)来实现。步骤206可以通过背景质量评估模块、参考帧结构选择模块和视频编码模块来实现。
还需要说明的是,该视频编码方法还可以不直接评估背景帧的质量,而是通过其它一些信号来决定是否插入背景帧。如在摄像装置处于抖动状态的情况下,或者,在光照强度处于快速变化状态的情况下,或者,在视频图像的噪音强度大于预设噪音强度值的情况下等等都可以决定不插入背景帧。其中,用于指示摄像装置的抖动状态的信号、用于指示光照强度的信号及用于指示视频图像的噪音强度的信号均可以由感应装置获得。
还需要补充说明的是,该视频编码方法除了通过直接评估背景帧的质量,或通过其它一些信号来决定是否插入背景帧,还可以按照其它方式决定是否插入背景帧,如:在第一预设时间段内插入背景帧,同时跟踪记录第一预设时间段内的视频编码消耗的码率和视频图像的重构帧的质量,在第一预设时间段之后的第二预设时间段内不插入背景帧,同时跟踪记录第二预设时间段内的视频编码消耗的码率和视频图像的重构帧的质量,然后比较两次记录的码率和重构帧的质量,当第一预设时间段内的码率更小,且重构帧的质量更好时,在以后的视频编码过程中选择插入背景帧的方式进行视频编码;当第二预设时间段内的码率更小,且重构帧的质量更好时,在以后的视频编码过程中选择不插入背景帧的方式进行视频编码。
需要补充说明的是,虽然现有技术中,很多情况下,可以从监控摄像机拍摄的视频中得到一个相对完整清晰的背景帧,如在静止场景或视频的前景物体比较少的情况下,可以得到相对完整清晰,质量较高的背景帧,但是在有些情况下,背景建模方式是难以获得一个相对完整清晰,质量较好的背景帧,在有些情况下,背景建模方式获得的背景帧是比较模糊的,该背景帧的质量较差,所以该背景帧是不适合被作为参考帧的。例如,当汽车从人行天桥下经过时,设置在人行天桥上的监控摄像机会抖动,又如当大量的人群从监控摄像机前经过时,监控摄像机也会抖动,再如当室内电灯在开与关的状态间切换时,设置在室内的监控摄像机拍摄的视频中的背景区域的面积会较小或者视频会比较模糊等等。而背景帧选取方式虽然可以在前景物体不多或者背景建模方式的效率下降(如监控摄像机抖动)的情况下,保证背景帧的质量,但是当前景物体较多或者存在频繁进行动静切换的场景时,采用背景建模方式和背景帧选取方式来改善背景帧质量的效果都会比较差,同时还会对编码带来额外的负担,降低了编码效率,因为通过上述两种方式得到背景帧需要占用相当多的码流。所以本发明实施例提供的视频编码方法,是一种自适应选择不同的背景帧作为参 考帧的方法,该方法先判断获得的背景帧是否适合作为参考帧,当背景帧适合作为参考帧时,再将背景帧插入待编码视频序列中,以供待编码视频序列中的帧间编码帧参考,而且该方法还可以从多个都适合作为参考帧的背景帧中选取一个最适合作为参考帧的背景帧,以供待编码视频序列中的帧间编码帧参考;当背景帧不适合作为参考帧时,则不将背景帧插入待编码视频序列中,而是将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系进行视频编码,所以,该自适应选择背景帧的方法避免了将质量较差的背景帧插入待编码视频序列中,提高了插入背景帧的灵活度,提高了视频编码质量,提高了视频编码的效率,降低了编码器(即视频编码器)的功耗,提高了视频编码的效果。
综上所述,本发明实施例提供的视频编码方法,能够在至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧,并将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,而在至少一个备选背景帧中所有备选背景帧均不满足预设规则时,则不插入背景帧,将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系进行视频编码,相较于现有技术,避免了将质量较差的背景帧插入待编码视频序列中,因此,提高了插入背景帧的灵活度,提高了视频编码的效率,提高了视频编码质量,降低了编码器的功耗,提高了视频编码的效果。
本发明实施例提供了一种视频编码装置,该视频编码装置可以通过软件、硬件或者两者的结合实现成为编码器的部分或全部。如图3-1所示,该视频编码装置可以包括:
第一判断单元410,用于判断至少一个备选背景帧中每个备选背景帧是否满足预设规则,至少一个备选背景帧是通过预设的背景帧获取方式得到的背景帧。
第一确定单元420,用于当至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧。
插入单元430,用于将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,以进行视频编码。
综上所述,本发明实施例提供的视频编码装置,能够在至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定 目标背景帧,并将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,相较于现有技术,避免了将质量较差的背景帧插入待编码视频序列中,因此,提高了视频编码的效率。
可选的,预设规则为:背景帧的质量指标参数满足预设的质量要求,质量指标参数为用于衡量背景帧质量的参数。
可选的,第一确定单元420用于当至少一个备选背景帧中满足预设规则的备选背景帧为一个背景帧时,则直接将该备选背景帧确定为目标背景帧。
可选的,背景帧获取方式可以为背景建模方式,也可以为背景帧选取方式,还可以为其他任一背景帧获取方式,如帧像素平均值方式或混合高斯建模方式等,背景帧获取方式还可以为上述多种背景帧获取方式的各种组合。每一种背景帧获取方式得到一个背景帧。可选的,背景帧获取方式可以包括背景建模方式和背景帧选取方式。
可选的,预设GOP结构包括IPPP结构和IBBBP结构中的任意一种。
可选的,参考帧包括长期参考帧和短期参考帧中的任意一种。
可选的,质量指标参数为第一质量指标,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,如图3-2所示,第一确定单元420,包括:
第一选择模块421,用于在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧。
或,如图3-3所示,第一确定单元420,包括:
第二选择模块422,用于在质量指标参数的值大于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
质量指标参数为第一质量指标时,质量要求还可以为:质量指标参数的值大于视频编码过程中产生的随机值。
可选的,质量要求还可以为:质量指标参数的值大于视频编码过程中产生的随机值。
可选的,质量指标参数为第三质量指标,第三质量指标的值等于1-P,P为备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值小于预设的质量阈值,质量指标参数的值小于质量阈值的备选背景帧包括至少两个背景帧,如图3-4所示,第一确定单元420, 包括:
第四选择模块423,用于在质量指标参数的值小于质量阈值的备选背景帧中选择质量指标参数的值最小的背景帧作为目标背景帧。
或,如图3-5所示,第一确定单元420,包括:
第五选择模块424,用于在质量指标参数的值小于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
质量指标参数为第三质量指标时,质量要求还可以为:质量指标参数的值小于视频编码过程中产生的随机值。
可选的,质量指标参数为第二质量指标,第二质量指标的值由第一质量指标的值迭代得到,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,如图3-6所示,该装置还可以包括:第二确定单元440,用于根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的第二质量指标的值。相应的,如图3-7所示,第一确定单元420,包括:
第三选择模块425,用于在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧。
可选的,如图3-8所示,第二确定单元440,包括:
确定模块441,用于根据每个备选背景帧的第一质量指标的值D(t)按照质量计算公式计算每个备选背景帧的第二质量指标的值C(t),并且计算第二质量指标的值C(t)的质量计算公式为:
Figure PCTCN2016105844-appb-000005
其中,a为权重系数,且0≤a≤1,t表示帧数。
可选的,每个备选背景帧和当前时刻待编码的帧间编码帧分别包括至少一个背景块,如图3-6所示,该装置还包括:
第二判断单元450,用于判断当前时刻待编码的帧间编码帧的第一背景块的像素与每个备选背景帧的第二背景块的像素的差值是否小于预设的差值阈值,第一背景块在当前时刻待编码的帧间编码帧上的位置与第二背景块在每个备选背景帧上的位置相对应。
第一处理单元460,用于对于每个备选背景帧,当第一背景块的像素与第 二背景块的像素的差值小于差值阈值时,将第二背景块作为目标背景块。
第三确定单元470,用于确定备选背景帧上的目标背景块的个数。
第二处理单元480,用于将备选背景帧上的目标背景块的个数与背景块的总数的比值作为相似度。
可选的,如图3-6所示,该装置还包括:
第三处理单元490,用于当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系进行视频编码。
可选的,第三处理单元490,还用于当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,按照其他预设方式进行视频编码,如按照帧的间隔等参数进行视频编码。
如图3-6所示,该装置还包括:编码单元510,用于对插入了目标背景帧的待编码视频序列中的编码帧进行编码,插入了目标背景帧的编码帧包括目标背景帧和帧间编码帧,其中,目标背景帧采用帧内编码模式进行编码,帧间编码帧采用帧间编码模式参考目标背景帧进行编码。此外,图3-6中的第一判断单元410、第一确定单元420和插入单元430可以参考图3-1进行说明。
可选的,该装置还包括:
第一添加单元,用于在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素,该语法元素用于指示目标背景帧作为长期参考帧的使用方式。其中,参数集包括序列参数集和参考图像集。
第二添加单元,用于在待编码视频序列中的帧间编码帧的参数集内添加待编码视频序列中的至少一个帧间编码帧的语法元素。
背景帧获取单元,用于通过预设的背景帧获取方式获取至少一个备选背景帧。
示例的,当背景帧获取方式包括两种背景帧获取方式,如背景建模方式和背景帧选取方式,那么背景帧获取单元可以包括:
第一背景帧获取模块,用于通过背景建模方式获取备选背景帧。
第二背景帧获取模块,用于通过背景帧选取方式获取备选背景帧。
图3-1中各单元的具体工作过程可以参考图1所示的实施方式进行说明,图3-6中各单元的具体工作过程可以参考图2-1所示的实施方式进行说明。
综上所述,本发明实施例提供的视频编码装置,能够在至少一个备选背景 帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧,并将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,而在至少一个备选背景帧中所有备选背景帧均不满足预设规则时,则不插入背景帧,将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系进行视频编码,相较于现有技术,避免了将质量较差的背景帧插入待编码视频序列中,因此,提高了插入背景帧的灵活度,提高了视频编码的效率,提高了视频编码质量,降低了编码器的功耗,提高了视频编码的效果。
本发明实施例提供了另一种视频编码装置,如图4所示,该视频编码装置包括:处理器1001、存储器1002、网络接口1003和总线1004。其中,总线1004用于连接处理器1001、存储器1002和网络接口1003,处理器1001用于执行存储器1002中存储的程序10021。处理器1001可以执行该程序10021来实现编码器,并使得该编码器执行下述视频编码方法:
判断至少一个备选背景帧中每个备选背景帧是否满足预设规则,至少一个备选背景帧是通过预设的背景帧获取方式得到的背景帧;
当至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧;
将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,以进行视频编码。
可选的,预设规则为:背景帧的质量指标参数满足预设的质量要求,质量指标参数为用于衡量背景帧质量的参数。
可选的,当至少一个备选背景帧中满足预设规则的备选背景帧为一个背景帧时,则直接将该备选背景帧确定为目标背景帧。
可选的,背景帧获取方式可以为背景建模方式,也可以为背景帧选取方式,还可以为其他任一背景帧获取方式,如帧像素平均值方式或混合高斯建模方式等,背景帧获取方式还可以为上述多种背景帧获取方式的各种组合。每一种背景帧获取方式得到一个背景帧。
可选的,质量指标参数为第一质量指标,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备 选背景帧包括至少两个背景帧,在满足预设规则的备选背景帧中确定目标背景帧,包括:
在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧;
或,在质量指标参数的值大于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
质量指标参数为第一质量指标时,质量要求还可以为:质量指标参数的值大于视频编码过程中产生的随机值。
可选的,质量指标参数为第三质量指标,第三质量指标的值等于1-P,P为备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值小于预设的质量阈值,质量指标参数的值小于质量阈值的备选背景帧包括至少两个背景帧,在满足预设规则的备选背景帧中确定目标背景帧,包括:
在质量指标参数的值小于质量阈值的备选背景帧中选择质量指标参数的值最小的背景帧作为目标背景帧;
或,在质量指标参数的值小于质量阈值的备选背景帧中随机选择一个背景帧作为目标背景帧。
质量指标参数为第三质量指标时,质量要求还可以为:质量指标参数的值小于视频编码过程中产生的随机值。
可选的,质量指标参数为第二质量指标,第二质量指标的值由第一质量指标的值迭代得到,第一质量指标的值等于备选背景帧与待编码视频序列中当前时刻待编码的帧间编码帧的相似度,质量要求为:质量指标参数的值大于预设的质量阈值,质量指标参数的值大于质量阈值的备选背景帧包括至少两个背景帧,在判断至少一个备选背景帧中每个备选背景帧是否满足预设规则之前,该方法还包括:
根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的第二质量指标的值。
相应的,在满足预设规则的备选背景帧中确定目标背景帧,包括:
在质量指标参数的值大于质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为目标背景帧。
具体的,根据每个备选背景帧的第一质量指标的值确定每个备选背景帧的 第二质量指标的值,包括:
根据每个备选背景帧的第一质量指标的值D(t)按照质量计算公式确定每个备选背景帧的第二质量指标的值C(t),并且计算第二质量指标的值C(t)的质量计算公式为:
Figure PCTCN2016105844-appb-000006
其中,a为权重系数,且0≤a≤1,t表示帧数。
可选的,每个备选背景帧和当前时刻待编码的帧间编码帧分别包括至少一个背景块,计算每个备选背景帧与当前时刻待编码的帧间编码帧的相似度,包括:
判断当前时刻待编码的帧间编码帧的第一背景块的像素与每个备选背景帧的第二背景块的像素的差值是否小于预设的差值阈值,第一背景块在当前时刻待编码的帧间编码帧上的位置与第二背景块在每个备选背景帧上的位置相对应;
对于每个备选背景帧,当第一背景块的像素与第二背景块的像素的差值小于差值阈值时,将第二背景块作为目标背景块,
确定备选背景帧上的目标背景块的个数,
将备选背景帧上的目标背景块的个数与背景块的总数的比值作为相似度。
可选的,在判断至少一个备选背景帧中每个备选背景帧是否满足预设规则之后,该方法还包括:
当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,将待编码视频序列中的已有帧按照预设GOP结构所定义的参考关系进行视频编码。
可选的,当至少一个备选背景帧中所有备选背景帧均不满足预设规则时,还可以按照其他预设方式进行视频编码,如按照帧的间隔等参数进行视频编码。
可选的,预设GOP结构包括IPPP结构和IBBBP结构中的任意一种。
可选的,背景帧获取方式可以包括背景建模方式和背景帧选取方式。
可选的,在将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中之后,该方法还包括:
对插入了目标背景帧的待编码视频序列中的编码帧进行编码,插入了目标背景帧的编码帧包括目标背景帧和帧间编码帧,其中,目标背景帧采用帧内编 码模式进行编码,帧间编码帧采用帧间编码模式参考目标背景帧进行编码。
可选的,参考帧包括长期参考帧和短期参考帧中的任意一种。
可选的,在将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中之后,该方法还包括:
在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素,语法元素用于指示目标背景帧作为长期参考帧的使用方式。
可选的,在待编码视频序列中的帧间编码帧的参数集内添加目标背景帧的语法元素之后,该方法还包括:
在待编码视频序列中的帧间编码帧的参数集内添加待编码视频序列中的至少一个帧间编码帧的语法元素。
可选的,参数集包括序列参数集和参考图像集。
综上所述,本发明实施例提供的视频编码装置,能够在至少一个备选背景帧中存在满足预设规则的备选背景帧时,在满足预设规则的备选背景帧中确定目标背景帧,并将目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入待编码视频序列中,而在至少一个备选背景帧中所有备选背景帧均不满足预设规则时,则不插入背景帧,将待编码视频序列中的已有帧按照预设画面组GOP结构所定义的参考关系进行视频编码,相较于现有技术,避免了将质量较差的背景帧插入待编码视频序列中,因此,提高了插入背景帧的灵活度,提高了视频编码的效率,提高了视频编码质量,降低了编码器的功耗,提高了视频编码的效果。
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部 单元来实现本实施例方案的目的。
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。
以上所述仅为本申请的可选实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。

Claims (20)

  1. 一种视频编码方法,其特征在于,所述方法包括:
    判断至少一个备选背景帧中每个备选背景帧是否满足预设规则,所述至少一个备选背景帧是通过预设的背景帧获取方式得到的背景帧;
    当所述至少一个备选背景帧中存在满足所述预设规则的备选背景帧时,在满足所述预设规则的备选背景帧中确定目标背景帧;
    将所述目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入所述待编码视频序列中,以进行视频编码。
  2. 根据权利要求1所述的方法,其特征在于,
    所述预设规则为:背景帧的质量指标参数满足预设的质量要求,所述质量指标参数为用于衡量背景帧质量的参数。
  3. 根据权利要求2所述的方法,其特征在于,所述质量指标参数为第一质量指标,所述第一质量指标的值等于备选背景帧与所述待编码视频序列中当前时刻待编码的帧间编码帧的相似度,所述质量要求为:所述质量指标参数的值大于预设的质量阈值,所述质量指标参数的值大于所述质量阈值的备选背景帧包括至少两个背景帧,
    所述在满足所述预设规则的备选背景帧中确定目标背景帧,包括:
    在所述质量指标参数的值大于所述质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为所述目标背景帧;
    或,在所述质量指标参数的值大于所述质量阈值的备选背景帧中随机选择一个背景帧作为所述目标背景帧。
  4. 根据权利要求2所述的方法,其特征在于,所述质量指标参数为第二质量指标,所述第二质量指标的值由第一质量指标的值迭代得到,所述第一质量指标的值等于备选背景帧与所述待编码视频序列中当前时刻待编码的帧间编码帧的相似度,所述质量要求为:所述质量指标参数的值大于预设的质量阈值,所述质量指标参数的值大于所述质量阈值的备选背景帧包括至少两个背景帧,
    在所述判断至少一个备选背景帧中每个备选背景帧是否满足预设规则之前,所述方法还包括:
    根据所述每个备选背景帧的第一质量指标的值确定所述每个备选背景帧的第二质量指标的值;
    所述在满足所述预设规则的备选背景帧中确定目标背景帧,包括:
    在所述质量指标参数的值大于所述质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为所述目标背景帧。
  5. 根据权利要求4所述的方法,其特征在于,所述根据所述每个备选背景帧的第一质量指标的值确定所述每个备选背景帧的第二质量指标的值,包括:
    根据所述每个备选背景帧的第一质量指标的值D(t)按照质量计算公式计算所述每个备选背景帧的第二质量指标的值C(t),并且计算所述第二质量指标的值C(t)的质量计算公式为:
    Figure PCTCN2016105844-appb-100001
    其中,所述a为权重系数,且0≤a≤1,所述t表示帧数。
  6. 根据权利要求3至5任一所述的方法,其特征在于,所述每个备选背景帧和所述当前时刻待编码的帧间编码帧分别包括至少一个背景块,计算所述每个备选背景帧与所述当前时刻待编码的帧间编码帧的相似度,包括:
    判断所述当前时刻待编码的帧间编码帧的第一背景块的像素与所述每个备选背景帧的第二背景块的像素的差值是否小于预设的差值阈值,所述第一背景块在所述当前时刻待编码的帧间编码帧上的位置与所述第二背景块在所述每个备选背景帧上的位置相对应;
    对于所述每个备选背景帧,当所述第一背景块的像素与所述第二背景块的像素的差值小于所述差值阈值时,将所述第二背景块作为目标背景块,
    确定所述备选背景帧上的目标背景块的个数,
    将所述备选背景帧上的目标背景块的个数与背景块的总数的比值作为所述相似度。
  7. 根据权利要求1至6任一所述的方法,其特征在于,在所述判断至少一 个备选背景帧中每个备选背景帧是否满足预设规则之后,所述方法还包括:
    当所述至少一个备选背景帧中所有备选背景帧均不满足所述预设规则时,将所述待编码视频序列中的已有帧按照预设画面组GOP结构所定义的参考关系进行视频编码。
  8. 根据权利要求7所述的方法,其特征在于,所述预设画面组GOP结构包括IPPP结构和IBBBP结构中的任意一种。
  9. 根据权利要求1至8任一所述的方法,其特征在于,在所述将所述目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入所述待编码视频序列中之后,所述方法还包括:
    对插入了所述目标背景帧的待编码视频序列中的编码帧进行编码,所述插入了所述目标背景帧的编码帧包括所述目标背景帧和所述帧间编码帧,其中,所述目标背景帧采用帧内编码模式进行编码,所述帧间编码帧采用帧间编码模式参考所述目标背景帧进行编码。
  10. 根据权利要求1至9任一所述的方法,其特征在于,所述参考帧包括长期参考帧和短期参考帧中的任意一种。
  11. 一种视频编码装置,其特征在于,所述装置包括:
    第一判断单元,用于判断至少一个备选背景帧中每个备选背景帧是否满足预设规则,所述至少一个备选背景帧是通过预设的背景帧获取方式得到的背景帧;
    第一确定单元,用于当所述至少一个备选背景帧中存在满足所述预设规则的备选背景帧时,在满足所述预设规则的备选背景帧中确定目标背景帧;
    插入单元,用于将所述目标背景帧作为待编码视频序列中的帧间编码帧的参考帧插入所述待编码视频序列中,以进行视频编码。
  12. 根据权利要求11所述的装置,其特征在于,
    所述预设规则为:背景帧的质量指标参数满足预设的质量要求,所述质量指标参数为用于衡量背景帧质量的参数。
  13. 根据权利要求12所述的装置,其特征在于,所述质量指标参数为第一质量指标,所述第一质量指标的值等于备选背景帧与所述待编码视频序列中当前时刻待编码的帧间编码帧的相似度,所述质量要求为:所述质量指标参数的值大于预设的质量阈值,所述质量指标参数的值大于所述质量阈值的备选背景帧包括至少两个背景帧,所述第一确定单元,包括:
    第一选择模块,用于在所述质量指标参数的值大于所述质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为所述目标背景帧;
    或,第二选择模块,用于在所述质量指标参数的值大于所述质量阈值的备选背景帧中随机选择一个背景帧作为所述目标背景帧。
  14. 根据权利要求12所述的装置,其特征在于,所述质量指标参数为第二质量指标,所述第二质量指标的值由第一质量指标的值迭代得到,所述第一质量指标的值等于备选背景帧与所述待编码视频序列中当前时刻待编码的帧间编码帧的相似度,所述质量要求为:所述质量指标参数的值大于预设的质量阈值,所述质量指标参数的值大于所述质量阈值的备选背景帧包括至少两个背景帧,
    所述装置还包括:
    第二确定单元,用于根据所述每个备选背景帧的第一质量指标的值确定所述每个备选背景帧的第二质量指标的值;
    所述第一确定单元,包括:
    第三选择模块,用于在所述质量指标参数的值大于所述质量阈值的备选背景帧中选择质量指标参数的值最大的背景帧作为所述目标背景帧。
  15. 根据权利要求14所述的装置,其特征在于,所述第二确定单元,包括:确定模块,用于根据所述每个备选背景帧的第一质量指标的值D(t)按照质量计算公式计算所述每个备选背景帧的第二质量指标的值C(t),并且计算所述第二质量指标的值C(t)的质量计算公式为:
    Figure PCTCN2016105844-appb-100002
    其中,所述a为权重系数,且0≤a≤1,所述t表示帧数。
  16. 根据权利要求13至15任一所述的装置,其特征在于,所述每个备选背景帧和所述当前时刻待编码的帧间编码帧分别包括至少一个背景块,所述装置还包括:
    第二判断单元,用于判断所述当前时刻待编码的帧间编码帧的第一背景块的像素与所述每个备选背景帧的第二背景块的像素的差值是否小于预设的差值阈值,所述第一背景块在所述当前时刻待编码的帧间编码帧上的位置与所述第二背景块在所述每个备选背景帧上的位置相对应;
    第一处理单元,用于对于所述每个备选背景帧,当所述第一背景块的像素与所述第二背景块的像素的差值小于所述差值阈值时,将所述第二背景块作为目标背景块,
    第三确定单元,用于确定所述备选背景帧上的目标背景块的个数,
    第二处理单元,用于将所述备选背景帧上的目标背景块的个数与背景块的总数的比值作为所述相似度。
  17. 根据权利要求11至16任一所述的装置,其特征在于,所述装置还包括:
    第三处理单元,用于当所述至少一个备选背景帧中所有备选背景帧均不满足所述预设规则时,将所述待编码视频序列中的已有帧按照预设画面组GOP结构所定义的参考关系进行视频编码。
  18. 根据权利要求17所述的装置,其特征在于,所述预设画面组GOP结构包括IPPP结构和IBBBP结构中的任意一种。
  19. 根据权利要求11至18任一所述的装置,其特征在于,所述装置还包括:
    编码单元,用于对插入了所述目标背景帧的待编码视频序列中的编码帧进行编码,所述插入了所述目标背景帧的编码帧包括所述目标背景帧和所述帧间编码帧,其中,所述目标背景帧采用帧内编码模式进行编码,所述帧间编码帧采用帧间编码模式参考所述目标背景帧进行编码。
  20. 根据权利要求11至19任一所述的装置,其特征在于,所述参考帧包 括长期参考帧和短期参考帧中的任意一种。
PCT/CN2016/105844 2016-04-11 2016-11-15 视频编码方法和装置 WO2017177675A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610222405.9A CN105872556B (zh) 2016-04-11 2016-04-11 视频编码方法和装置
CN201610222405.9 2016-04-11

Publications (1)

Publication Number Publication Date
WO2017177675A1 true WO2017177675A1 (zh) 2017-10-19

Family

ID=56637430

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/105844 WO2017177675A1 (zh) 2016-04-11 2016-11-15 视频编码方法和装置

Country Status (2)

Country Link
CN (1) CN105872556B (zh)
WO (1) WO2017177675A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114363700A (zh) * 2020-10-12 2022-04-15 阿里巴巴集团控股有限公司 数据处理方法、装置、存储介质及计算机设备
CN116489342A (zh) * 2023-06-20 2023-07-25 中央广播电视总台 确定编码延时的方法、装置、及电子设备、存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105872556B (zh) * 2016-04-11 2020-01-03 华为技术有限公司 视频编码方法和装置
US10484710B2 (en) 2018-03-21 2019-11-19 Novatek Microelectronics Corp. Video encoding apparatus and method
CN110636334B (zh) * 2019-08-23 2022-12-09 西安万像电子科技有限公司 数据传输方法及系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102665077A (zh) * 2012-05-03 2012-09-12 北京大学 一种基于宏块分类的快速高效编转码方法
US20140368669A1 (en) * 2012-10-04 2014-12-18 Google Inc. Gpu-accelerated background replacement
CN104702956A (zh) * 2015-03-24 2015-06-10 武汉大学 一种面向视频编码的背景建模方法
CN104717511A (zh) * 2013-12-13 2015-06-17 联发科技(新加坡)私人有限公司 视频编码或解码的方法及装置
CN105872556A (zh) * 2016-04-11 2016-08-17 华为技术有限公司 视频编码方法和装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103167283B (zh) * 2011-12-19 2016-03-02 华为技术有限公司 一种视频编码方法及设备
CN103475882B (zh) * 2013-09-13 2017-02-15 北京大学 监控视频的编码、识别方法和监控视频的编码、识别系统
CN103824086A (zh) * 2014-03-24 2014-05-28 东方网力科技股份有限公司 一种图像匹配方法及装置
CN104618715B (zh) * 2014-07-22 2018-10-30 腾讯科技(北京)有限公司 一种获取最小率失真代价的方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102665077A (zh) * 2012-05-03 2012-09-12 北京大学 一种基于宏块分类的快速高效编转码方法
US20140368669A1 (en) * 2012-10-04 2014-12-18 Google Inc. Gpu-accelerated background replacement
CN104717511A (zh) * 2013-12-13 2015-06-17 联发科技(新加坡)私人有限公司 视频编码或解码的方法及装置
CN104702956A (zh) * 2015-03-24 2015-06-10 武汉大学 一种面向视频编码的背景建模方法
CN105872556A (zh) * 2016-04-11 2016-08-17 华为技术有限公司 视频编码方法和装置

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114363700A (zh) * 2020-10-12 2022-04-15 阿里巴巴集团控股有限公司 数据处理方法、装置、存储介质及计算机设备
CN116489342A (zh) * 2023-06-20 2023-07-25 中央广播电视总台 确定编码延时的方法、装置、及电子设备、存储介质
CN116489342B (zh) * 2023-06-20 2023-09-15 中央广播电视总台 确定编码延时的方法、装置、及电子设备、存储介质

Also Published As

Publication number Publication date
CN105872556A (zh) 2016-08-17
CN105872556B (zh) 2020-01-03

Similar Documents

Publication Publication Date Title
WO2017177675A1 (zh) 视频编码方法和装置
EP3780618A1 (en) Method and device for obtaining motion vector of video image
US10097821B2 (en) Hybrid-resolution encoding and decoding method and a video apparatus using the same
US20220058775A1 (en) Video denoising method and apparatus, and storage medium
CN111200734B (zh) 视频编码方法及装置
ES2652132T3 (es) Método y aparato para codificar y descodificar un bloque de textura mediante el uso de partición de bloque basada en la profundidad
US6959044B1 (en) Dynamic GOP system and method for digital video encoding
US7054367B2 (en) Edge detection based on variable-length codes of block coded video
KR101834688B1 (ko) 저 지연 조명 보상 프로세스 및 깊이 룩업 테이블 기반 코딩을 위한 방법
KR101859155B1 (ko) 높은 프레임 레이트 및 가변 프레임 레이트 캡처를 위한 비디오 압축 튜닝
JP3957915B2 (ja) フェード検出装置及び情報符号化装置
US9307241B2 (en) Video encoding method and a video encoding apparatus using the same
JP2006519565A (ja) ビデオ符号化
JP2011176811A (ja) 監視ビデオをエンコードするための方法及び装置
WO2010109564A1 (ja) 画像符号化装置及び画像符号化方法
KR20040037104A (ko) 비디오 비트스트림에서의 씬 컷 검출
JP5396302B2 (ja) 映像信号符号化装置及び映像信号符号化方法
CN110366851B (zh) 编码、解码方法及编码、解码设备
WO2017015958A1 (zh) 一种视频编解码方法及装置
US10856002B2 (en) Method, device and system for method of encoding a sequence of frames in a video stream
CN117616751A (zh) 动态图像组的视频编解码
KR20170095047A (ko) 동적 프레임 삭제 장치 및 방법
US9542611B1 (en) Logo detection for macroblock-based video processing
WO2017104011A1 (ja) 画像符号化装置
US11197014B2 (en) Encoding apparatus, decoding apparatus, and image processing system

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16898488

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 16898488

Country of ref document: EP

Kind code of ref document: A1