WO2023173852A1 - 一种图像编码方法、装置及设备 - Google Patents

一种图像编码方法、装置及设备 Download PDF

Info

Publication number
WO2023173852A1
WO2023173852A1 PCT/CN2022/138979 CN2022138979W WO2023173852A1 WO 2023173852 A1 WO2023173852 A1 WO 2023173852A1 CN 2022138979 W CN2022138979 W CN 2022138979W WO 2023173852 A1 WO2023173852 A1 WO 2023173852A1
Authority
WO
WIPO (PCT)
Prior art keywords
coding block
image
encoding
block
coding
Prior art date
Application number
PCT/CN2022/138979
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 WO2023173852A1 publication Critical patent/WO2023173852A1/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/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
    • H04N19/154Measured or subjectively estimated visual quality after decoding, e.g. measurement of distortion
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
    • H04N19/17Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
    • H04N19/176Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/20Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using video object coding

Definitions

  • the present application relates to the field of images, and in particular, to an image coding method, device and equipment.
  • the encoder predetermines the quantization parameter (QP) used for encoding and allocates the code rate through the QP.
  • QP quantization parameter
  • the quality of the encoded image is related to many factors.
  • the encoder uses a predetermined QP for encoding, which may result in unsatisfactory quality of the encoded image, and the quality of different areas in the encoded image may vary greatly.
  • This application provides an image encoding method, device and equipment to ensure the quality of the encoded image.
  • the encoding device can encode the image at least twice, adjust the QP of the corresponding encoding block based on the quality parameters of each encoding block obtained from the previous encoding, and then encode the image based on the adjusted QP.
  • the encoding device can adjust the encoding parameter QP of this encoding based on the quality of the last actual encoding, thereby ensuring the quality of the encoded image.
  • the coding device may Determine the first QP offset value corresponding to the first coding block based on the quality parameter of the first coding block in the data; then, based on the first QP corresponding to the first coding block and the first QP offset value corresponding to the first coding block The first QP offset value corresponding to a coding block determines the second QP corresponding to the first coding block.
  • the encoding device can first determine the first QP offset value corresponding to the first encoding block, and then determine the first QP offset value corresponding to the first encoding block based on the first QP offset value corresponding to the first encoding block.
  • the second QP corresponding to the block Generally, the offset value of the first QP is smaller relative to the second QP; thus, the amount of calculation required to determine the offset value of the first QP is smaller, and fewer resources are required to transmit or store the offset value of the first QP. .
  • the encoding device may determine that the absolute value of the first QP offset value corresponding to the first coding block is equal to the QP offset value corresponding to the second range; wherein, the absolute value of the first QP offset value corresponding to the first coding block
  • the first QP offset value is a negative number
  • the encoding device may determine that the first QP offset value corresponding to the first encoding block is 0.
  • the first QP offset value is a negative value; thus, the coding quality of the coding block can be improved by reducing the QP, bring it close to the target quality.
  • the first QP offset value is a positive value; thus, the coding quality of the coding block can be reduced by increasing the QP to bring it closer to the target quality.
  • the encoding device can allocate the code rate within the first image, that is, reduce the code rate of the coding blocks whose coding quality exceeds the target quality, and allocate the saved code words to the coding blocks whose coding quality is lower than the target quality.
  • coding blocks so as to increase the code rate of the coding blocks whose coding quality is lower than the target quality, thereby improving the overall coding quality of the first image and making the coding quality of the first image more balanced.
  • this design can reduce the overall code rate required for the image by reducing the quality of coding blocks whose coding quality exceeds the target quality.
  • the coding device may use the following method to determine the pair of coding blocks according to the first QP pair corresponding to the second coding block.
  • the second encoding block is encoded:
  • the encoding device may perform quantization processing on the second encoding block according to the first QP corresponding to the second encoding block to obtain quantized data; and then quantize the quantized data according to the first QP corresponding to the second encoding block. Perform inverse quantization and inverse transformation processing to obtain inversely transformed residual data; then, the encoding device can obtain the reconstructed data of the second coding block based on the prediction data and residual data of the second coding block, and perform The reconstructed data is filtered to obtain image data corresponding to the second encoding block in the first image data.
  • the coding device may, according to the first information and the second QP corresponding to the third coding block, The third encoding block is encoded.
  • the first information may be intermediate data obtained when the third encoding block is encoded according to the first QP corresponding to the third encoding block.
  • the first information may include at least one of the following: the prediction mode of the third coding block determined when the third coding block is coded according to the first QP corresponding to the third coding block; The motion vector of the third coding block is determined when the first QP corresponding to the third coding block codes the third coding block.
  • each coding block in at least one coding block is separately coded according to the second QP corresponding to each coding block
  • the above-mentioned at least one coding block according to the first QP corresponding to each coding block can be multiplexed.
  • this encoding can reuse the intermediate results of the previous encoding, which can simplify the encoding process and improve encoding efficiency.
  • the coding device may save the second information.
  • the second information may be used to represent the quality parameter of each encoding block in the second image data.
  • the second information may be a matrix containing quality parameters of each coding block in the second image data.
  • the encoding device can save the second information representing the quality parameters of each encoding block in the second image data; in this way, the encoding device can encode the first image in the video.
  • the second information can be referred to, thereby improving the encoding quality of subsequent images.
  • the first image may be the n-th frame image in the video, where n is a positive integer; after saving the second information, the encoding device may encode the first image according to the second information of the first image. Subsequent images in the video are encoded. Specifically, the encoding device may obtain the n+1th frame image in the video (hereinafter referred to as the second image).
  • the second image contains N encoding blocks, and N is a positive integer.
  • the encoding device may determine, in the at least one encoding block in the first image, at least one target encoding block associated with a fourth encoding block in the second image; wherein the fourth encoding block may be the N In any one of the coding blocks, the content in the fourth coding block is included in the at least one target coding block.
  • the encoding device may predict the encoded fourth coding block based on the quality parameter of the at least one target coding block.
  • the quality parameter of the coding block is determined based on the quality parameter of the coding block, and the third QP corresponding to the fourth coding block is determined accordingly.
  • the encoding device may encode the fourth encoding block according to the third QP corresponding to the fourth encoding block.
  • the encoding device can encode the first image in the video at least twice, thereby improving the encoding quality of the first image. Then, the encoding device can encode the second image in the video once based on the first image whose encoding quality has been improved; specifically, the encoding device predicts the video based on the encoding quality of the target encoding block in the first image whose encoding quality has been improved.
  • the coding quality of similar coding blocks in subsequent images is calculated, and the QP is adjusted according to the predicted coding quality, thereby improving the coding quality of similar coding blocks in subsequent images in the video, thereby improving the coding quality of the second image.
  • the encoding device may determine the second QP corresponding to the fourth encoding block according to the target quality parameter of the second image and the predicted quality parameter of the fourth encoding block after encoding. After the offset value, the third QP corresponding to the fourth coding block is determined according to the second QP offset value corresponding to the fourth coding block.
  • the encoding device can first determine the second QP offset value corresponding to the fourth encoding block, and then determine the second QP offset value corresponding to the fourth encoding block based on the second QP offset value corresponding to the fourth encoding block.
  • the third QP corresponding to the block Generally, the offset value of the second QP is smaller relative to the third QP; in this way, the amount of calculation required to determine the offset value of the second QP is smaller, and fewer resources are required to transmit or store the offset value of the second QP. .
  • the encoding device may determine the second QP offset value corresponding to the fourth encoding block in the following manner:
  • the encoding device may determine that a second QP offset value corresponding to the fourth encoding block is equal to a QP offset value corresponding to the third range; wherein the second QP offset value corresponding to the fourth encoding block is a positive number; or
  • the encoding device may determine that the absolute value of the second QP offset value corresponding to the fourth coding block is equal to the QP offset value corresponding to the fourth range; wherein, the absolute value of the second QP offset value corresponding to the fourth coding block
  • the second QP offset value is a negative number
  • the encoding device may determine that the second QP offset value corresponding to the fourth encoding block is 0.
  • the second QP offset value is a negative value; thus, the coding quality of the coding block can be improved by reducing the QP.
  • the second QP offset is a positive value; thus, the code rate required for the coding block can be reduced by increasing the QP, and the code saved The rate can be used to improve the encoding quality of the encoding blocks in the second image that are lower than the target quality of the second image; in this way, the overall encoding quality of the second image can be improved without increasing the overall bit rate.
  • the quality parameters of any coding block may include at least one of the following: peak signal-to-noise ratio, structural similarity, and multi-scale structural similarity.
  • an image encoding device including a unit for performing each step in the above-mentioned first aspect and any possible design of the first aspect.
  • embodiments of the present application further provide a computer program, which when the computer program is run on a computer, causes the computer to execute the method in the above-mentioned first aspect and any possible design of the first aspect.
  • embodiments of the present application further provide a computer-readable storage medium.
  • a computer program is stored in the computer-readable storage medium. When the computer program is executed by a computer, it causes the computer to execute the above-mentioned first step. aspects and methods in any possible design of the first aspect.
  • embodiments of the present application further provide a chip, which is used to read a computer program stored in a memory and execute the method in the above-mentioned first aspect and any possible design of the first aspect.
  • embodiments of the present application further provide a chip system.
  • the chip system includes a processor and is configured to support a computer device to implement the method in the above-mentioned first aspect and any possible design of the first aspect.
  • the chip system further includes a memory, and the memory is used to store necessary programs and data for the computer device.
  • the chip system can be composed of chips or include chips and other discrete devices.
  • Figure 1 is a structural diagram of a coding device
  • Figure 2 is a schematic diagram of an AQ solution
  • Figure 3 is a flow chart of an image encoding method provided by an embodiment of the present application.
  • Figure 4 is a structural diagram of an encoding device provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a processing flow of the QP adjustment module 33 provided by the embodiment of the present application.
  • FIG. 6 is a schematic diagram of another processing flow of the QP adjustment module 33 provided by the embodiment of the present application.
  • Figure 7 is a structural diagram of another encoding device provided by an embodiment of the present application.
  • Figure 8 is a structural diagram of the predictive coding module 41 provided by the embodiment of the present application.
  • Figure 9 is a schematic diagram of an encoding method provided by an embodiment of the present application.
  • Figure 10 is a structural diagram of yet another encoding device provided by an embodiment of the present application.
  • Figure 11 is a schematic diagram of the processing flow of the QP calculation module 116 provided by the embodiment of the present application.
  • Figure 12 is a schematic diagram of a coding block association relationship provided by an embodiment of the present application.
  • Figure 14 is a structural diagram of an image coding device provided by an embodiment of the present application.
  • This application provides an image encoding method, device and equipment to ensure the quality of the encoded image.
  • the method, device and equipment are based on the same technical concept. Since the principles of solving the problem are similar, the implementation of the device, device and method can be referred to each other, and the repeated points will not be repeated.
  • the encoding device can acquire the first QP corresponding to each coding block in at least one coding block in the first image; and then, according to the corresponding coding block of each coding block
  • the first QP each coding block in the at least one coding block is separately coded (hereinafter referred to as first coding), and the first image data is obtained.
  • the encoding device determines a second QP corresponding to each encoding block according to the quality parameter of each encoding block in the first image data; and according to the second QP corresponding to each encoding block, the encoding device determines each encoding block in the at least one encoding block.
  • the encoding blocks are encoded to obtain the second image data.
  • the encoding device can encode the image at least twice, adjust the QP of the corresponding encoding block based on the quality parameters of each encoding block obtained from the previous encoding, and then encode the image based on the adjusted QP. In this way, the encoding device can adjust the QP of this encoding based on the quality of the last encoding, thereby ensuring the image quality after this encoding.
  • Image coding usually involves processing (for example, by compressing) the original image to reduce the amount of data required to represent the image, representing the image or the information contained in the image with a smaller number of bits, thereby more efficiently storing and /or transmission.
  • Video coding usually refers to the processing of image sequences that form a video or video sequence.
  • Video encoding generally involves processing (e.g., by compressing) a raw video image to reduce the amount of data required to represent the video image so that it can be stored and/or transmitted more efficiently.
  • the terms "picture”, "frame” or "image” may be used as synonyms.
  • Block is the processing unit of image coding or video coding, also called image block.
  • Each image may include at least one block.
  • Some video coding standards extend blocks further.
  • MB macroblock
  • the macroblock can be further divided into multiple prediction blocks (partitions) that can be used for predictive coding.
  • CU coding unit
  • PU prediction unit
  • TU transform unit
  • CU is the basic unit for dividing and encoding images.
  • PU can correspond to a prediction block and is the basic unit of predictive coding.
  • TU can correspond to a transformation block and is the basic unit for transforming prediction residuals.
  • CU, PU and TU are essentially blocks.
  • the image block to be encoded in the current encoding image can be called a coding block;
  • the block in the reference image that provides prediction information for the encoding block is a prediction block, where the prediction information can represent the prediction block.
  • pixel value, sample value or sample signal can represent the prediction block.
  • Encoding equipment is a general term for equipment that can encode images or videos.
  • the encoding device may be a desktop computer, a notebook computer, a tablet computer, a set-top box, a mobile phone, a television, a camera, a video camera, a display device, a digital media player, a video game console or a video streaming device, etc.
  • the number of nouns means “singular noun or plural noun", that is, “one or more”, unless otherwise specified. "At least one” means one or more, and “plurality” means two or more. "And/or” describes the relationship between associated objects, indicating that there can be three relationships. For example, A and/or B can mean: A alone exists, A and B exist simultaneously, and B alone exists. “At least one of the following” or similar expressions refers to any combination of these items (items), including any combination of a single item (items) or a plurality of items (items).
  • the encoding device may include an encoder 10 and a code control module 20.
  • the encoder 10 includes: an intra prediction module 102, an inter prediction module 104, a mode decision and residual calculation module 106, a transformation and quantization module 108, an inverse quantization and inverse transformation module 110, a filtering module 112, and an entropy coding module. 114.
  • the following description takes the encoding device encoding the current encoding block in the input image Fn (ie, the nth frame image in the video, where n is a positive integer) as an example.
  • the current coding block may be any coding block in the input image Fn.
  • the code control module 20 may provide the encoder 10 with the frame-level QP (ie, QP_frame) of the input image Fn and the block-level ⁇ QP of the current encoding block.
  • the block-level ⁇ QP of the current coding block is the offset value between the QP of the current coding block and the frame-level QP of the image where the current coding block is located.
  • the code control module 20 can determine the frame-level QP of Fn through frame-level code control. Specifically, the code control module 20 can calculate the frame-level QP of the input image Fn according to at least one of the following: the size of the output code stream corresponding to the video where the input image Fn is located, the target code rate, and other control parameters (such as the scene switching information of the two frames before and after). , the allowed code rate fluctuation range index, etc.). For example, when the ratio of the size and time of the output code stream corresponding to the video in which the input image Fn is located is greater than the target code rate, the code control module 20 can increase the frame-level QP of the input image Fn to reduce the code rate corresponding to the input image Fn.
  • the code control module 20 can adjust the frame-level QP of the input image Fn to increase the code rate corresponding to the input image Fn. , thereby improving the overall bit rate of the video where the input image Fn is located, making it close to the target bit rate.
  • the method for the code control module 20 to determine the block-level ⁇ QP of the current coding block may refer to the following description of FIG. 2 , which will not be elaborated here.
  • the mode in which intra prediction module 102 performs prediction may be referred to as an intra prediction mode.
  • Inter prediction module 104 may include a motion estimation unit and a motion compensation unit.
  • the motion estimation unit can find the most similar prediction block currently to be encoded in the reference image Fn-1 (that is, the n-1th frame image in the video), where the similarity can be measured according to a certain metric specified by the user, such as The sum absolute of difference (SAD) or SSD of the prediction residuals.
  • the motion estimation process also includes operations such as fractional pixel interpolation and search.
  • the result of motion estimation is the optimal motion vector (MV); where the optimal MV is the MV corresponding to the prediction block most similar to the current coding block.
  • the motion compensation unit may extract or generate a prediction block based on the motion vector determined by the motion estimation unit, and obtain prediction data; wherein the prediction data may include information such as identification and MV of the prediction block.
  • the inter prediction module 104 may be used for prediction.
  • the mode in which the inter prediction module 104 is used for prediction may be referred to as an inter prediction mode.
  • the mode decision and residual calculation module 106 may include a mode decision unit and a residual calculation unit.
  • the mode decision unit is used to select whether to use intra prediction mode or inter prediction mode for prediction. For example, when the cost of encoding through the intra prediction mode is less than or equal to the cost of encoding through the inter prediction mode, the mode decision unit may choose to perform prediction through the intra prediction mode; when encoding through the intra prediction mode When the cost of is greater than the cost of encoding through the inter prediction mode, the mode decision unit may choose to perform prediction through the inter prediction mode.
  • the residual calculation unit is used to calculate the pixel value difference between the pixels of the current encoding block and the pixels of the prediction block obtained by the prediction mode (intra prediction mode or inter prediction mode) selected by the mode decision unit, that is, the residual.
  • the above method can also be applied to video encoding.
  • the encoding device uses the above method to encode each frame of image in the video, or uses the above method to encode key frames in the video (for example, images containing moving objects in the video).
  • the way in which the encoding device obtains the second image may refer to the way in which the encoding device obtains the first image in S301, which will not be described again here.
  • the encoding device determines the quality parameter of the at least one target encoding block in the second image data based on the second information.
  • S311 includes C1-C2.
  • the method of obtaining the target quality parameter of the second image may refer to the method of obtaining the target quality parameter of the first image, which will not be described again here.
  • the quality parameter of the fourth coding block is greater than the target quality parameter of the second image (that is, the coding quality of the fourth coding block is higher than the target quality of the second image), and the quality parameter of the fourth coding block is the same as the second image
  • the difference between the target quality parameters is in the third range, it is determined that ⁇ QP4b corresponding to the fourth coding block is equal to the QP offset value corresponding to the third range; wherein ⁇ QP4b corresponding to the fourth coding block is a positive number.
  • the encoding device determines the third QP corresponding to the fourth encoding block based on the second QP offset value corresponding to the fourth encoding block.
  • the encoding device can use the entire encoding process shown in Figure 1 to encode the current encoding block, output the code stream, and obtain the reconstructed image.
  • the QP of the current coding block is replaced with the third QP, which will not be described again here.
  • the second image can also be replaced by the n+mth frame, where m is an integer greater than 1.
  • the encoding device can encode the first image in the video at least twice, thereby improving the encoding quality of the first image. Then, the encoding device can encode the second image in the video once based on the first image whose encoding quality has been improved; specifically, the encoding device predicts the video based on the encoding quality of the target encoding block in the first image whose encoding quality has been improved.
  • the coding quality of similar coding blocks in subsequent images is calculated, and the QP is adjusted according to the predicted coding quality, thereby improving the coding quality of similar coding blocks in subsequent images in the video, thereby improving the coding quality of the second image.
  • encoding devices often use low bit rates for encoding, resulting in uneven image quality. For example, for static complex background areas, the clarity of the area after encoding is very high; for moving areas and weak texture areas, problems such as local blur, smearing, and color residue often exist in the area after encoding.
  • the encoding device can use the method of this application to adjust the QP according to the encoded image quality by setting appropriate target quality parameters, and encode the image according to the adjusted QP, thereby improving the overall quality of the image. Encoding quality.
  • the code control module 20 may provide the first encoder 31 and the second encoder 32 with the frame-level QP (ie, QP_frame1a) of the first image and the block-level ⁇ QP (ie, ⁇ QPa) of the current encoding block in the first image. That is to say, the first encoder 31 and the second encoder 32 share a code control module 20 . In this way, the first encoder 31 and the second encoder 32 can use the same frame-level QP and block-level ⁇ QP when encoding each encoding block in the first image.
  • the QP adjustment module 33 may determine the QP offset value corresponding to each coding block in the first image (ie, ⁇ QP4a in the method shown in FIG. 3) by performing step S304.
  • the QP adjustment module 33 will be described below with reference to FIG. 5 . As shown in FIG. 5 , the QP adjustment module 33 can determine the QP offset value corresponding to any encoding block in the first image by performing operations D1-D3.
  • the QP adjustment module 33 may calculate the coding parameter corresponding to the first coding block that needs to be adjusted, for example, ⁇ QP4a, based on the difference between the quality parameter T1 of the first coding block and the target quality parameter T of the first image.
  • ⁇ QP4a can be a positive number or a negative number. For example, if the larger the quality parameter, the better. When T1 is greater than T, ⁇ QP4a is a positive number; when T1 is less than T, ⁇ QP4a is a negative number. For another example, if the smaller the quality parameter, the better. When T1 is greater than T, ⁇ QP4a is a negative number; when T1 is less than T, ⁇ QP4a is a positive number.
  • the QP adjustment module 33 can determine ⁇ QP4a through the following code.
  • Diff is the difference between the quality parameter T1 of the first encoding block and the target quality parameter T of the first image
  • abs(Diff) is the absolute value of Diff
  • QualityThr[8] is the threshold, used to determine the first encoding The interval in which the difference between the block's quality parameter T1 and the target quality parameter T of the first image lies.
  • eight thresholds such as a1, a2, a3, a4, a4, a6, a7, a8 are used as examples for explanation. It should be understood that in actual use, other numbers of thresholds (eg, 4, 5, 6, etc.) may also be used.
  • the QP adjustment module 33 can also save the coding parameters that need to be adjusted corresponding to the first coding block.
  • the second encoder 32 may be the encoder shown in FIG. 1 or an encoder with other architectures (for example, an image JPEG or H.264/H.265 video encoder).
  • the second encoder 32 may adjust the frame-level QP of the first image (eg, QP_frame1a) and the block-level QP of each encoding block (eg, ⁇ QPa) output by the code control module 20, and each encoding output by the QP adjustment module 33.
  • the block-level QP of the block determines the second QP corresponding to each coding block in the first image as QP_frame1a+ ⁇ QPa+ ⁇ QP4a (for details, please refer to S304), and based on the QP corresponding to each coding block
  • the second QP encodes each coding block in the first image and outputs the final video or image code stream (for details, please refer to S305).
  • the size of the coding block used by the second encoder 32 when encoding the first image is the same as the size of the coding block used by the first encoder 31 when encoding the first image; the first image used in the two encodings The dimensions are also the same.
  • the QP corresponding to the coded block when encoded by the second encoder 32 is adjusted according to the coding quality of the coded block after coding by the first encoder 31, which can effectively improve the coding quality of the coded block.
  • the second encoder 32 when the second encoder 32 is a video encoder, the second encoder 32 may also output a reconstructed image of the first image so as to serve as a reference image for the next frame of image in the video.
  • a reconstructed image of the first image For specific content, please refer to S305 and will not be repeated here.
  • the first encoder 31 can also output an intermediate result of encoding the first image (for example, the first information in the method shown in Figure 3), etc.; in this way, the second encoder 32 can use these intermediate results to The first image is encoded (for details, please refer to Method 2 in S305), thereby reducing the amount of calculation required by the second encoder 32 to encode the first image, thereby improving encoding efficiency.
  • the first encoder 31 and the second encoder 32 may be different encoders with the same architecture; they may be the same encoder; or they may be encoders with different architectures (for example, as shown in FIG. 7 ).
  • the encoding device can call the same encoder to encode each encoding block in the first image through time division multiplexing. For example, first Call the encoder to perform steps S301-S303, and then call the encoder to perform step S305.
  • the QP adjustment module 33 may determine the QP corresponding to each coding block in the first image, and output the QP corresponding to each coding block in the first image to the second encoder 32 ;
  • the second encoder 32 may separately encode each encoding block in the first image according to the QP determined by the QP adjustment module 33, and output the final video or image code stream (for details, please refer to S305).
  • Figure 6 shows the manner in which the QP adjustment module 33 determines the QP respectively corresponding to each coding block in the first image.
  • the encoding device can encode the image at least twice. Specifically, after the encoding device encodes each encoding block in the first image through the first encoder 31, the encoding device can adjust the encoding parameters corresponding to the corresponding encoding block (for example, adjust the QP) according to the encoding quality of each encoding block, The adjusted QP is then used by the second encoder 32 to encode the corresponding coding block in the first image. In this way, the encoding device can adjust the encoding parameter QP of this encoding based on the quality of the last actual encoding, thereby ensuring the quality of the encoded image.
  • the encoding device can adjust the encoding parameter QP of this encoding based on the quality of the last actual encoding, thereby ensuring the quality of the encoded image.
  • the first encoder 31 may include an intra prediction module 102, an inter prediction module 104, a mode decision and residual calculation module 106, a transform and quantization module 108-1, and an inverse quantization and inverse transform module 110-1.
  • the second encoder 32 may include a prediction encoding module 41, a filtering module 112, and an entropy encoding module 114.
  • each module in the first encoder 31 can encode each coding block in the first image to obtain the first reconstructed data (ie, the first image data in step S303), and output the first reconstructed data to QP adjustment module 33.
  • the mode decision and residual calculation module 106 may output the determined intermediate results to the prediction encoding module 41 and the entropy encoding module 114.
  • the intermediate results may include: prediction mode and/or MV.
  • the prediction encoding module 41 may use the intermediate result and the QP corresponding to each encoding block to separately encode each encoding block in the first image, thereby outputting the quantized data corresponding to each encoding block to the entropy encoding module 114, And output the second reconstructed data respectively corresponding to each coding block to the filtering module 112.
  • the predictive coding module 41 please refer to the description of FIG. 8 below.
  • the filtering module 112 may filter the reconstructed data corresponding to each coding block to obtain reconstructed data corresponding to each coding block in the first image.
  • the filtering module 112 may also output filtering information (eg, SAO mode information, compensation information, etc.) to the entropy encoding module 114.
  • filtering information eg, SAO mode information, compensation information, etc.
  • the entropy encoding module 114 may apply an entropy encoding scheme to one or more of quantized data, prediction data, SAO mode information, compensation information, etc., to obtain an encoded code stream.
  • an entropy encoding scheme to one or more of quantized data, prediction data, SAO mode information, compensation information, etc.
  • the following describes the processing process of the predictive coding module 41 with reference to FIG. 8 , taking the first coding block in the first image as an example.
  • the first coding block is any coding block in the first image.
  • the prediction coding module 41 includes: a prediction unit 412, a residual calculation unit 414, a transformation and quantization module 108-2, an inverse quantization and inverse transformation module 110-2, and a data calculation unit 416.
  • the prediction unit 412 may use the intermediate results from the mode decision and residual calculation module 106 to predict the first coding block, generate prediction data of the first coding block, and output the prediction data of the first coding block to the residual calculation. unit 414 and data calculation unit 416.
  • the intermediate results may include: prediction modes, adjacent reference data, and compensation data in the time domain (eg, MV).
  • MV compensation data in the time domain
  • the residual calculation unit 414 may generate a residual of the first coding block according to the original data of the first coding block and the prediction data of the first coding block in the first image, and output the residual of the first coding block to transform and quantization. Module 108-2.
  • the specific process of the residual calculation unit 414 generating the residual of the first coding block may refer to the description of FIG. 1 and will not be described again here.
  • the transform and quantization module 108-2 may use the QP of the first coding block from the QP adjustment module 33 to process the residual of the first coding block to obtain the quantized data of the first coding block, and convert the quantized data of the first coding block into Output to entropy encoding module 114 and inverse quantization and inverse transform module 110-2.
  • the specific process by which the transformation and quantization module 108-2 obtains quantized data may refer to the description of Figure 1 and will not be described again here.
  • the inverse quantization and inverse transformation module 110-2 After processing the quantized data of the first coding block, the inverse quantization and inverse transformation module 110-2 obtains the inverse-transformed residual of the first coding block (which may also be referred to as the reconstruction residual), and converts the first coding block into The reconstructed residual is output to the data calculation unit 416.
  • the specific process by which the inverse quantization and inverse transformation module 110-2 obtains the residual after inverse transformation may refer to the description of FIG. 1 and will not be described again here.
  • the data calculation unit 416 obtains the reconstructed data of the first encoding block (ie, the second reconstructed data in Figure 7) based on the prediction data of the first encoding block and the inverse-transformed residual of the first encoding block, and converts the first encoding block into The reconstructed data of the block is output to the filtering module 112 .
  • the reconstructed data is the result of adding the predicted data and the residual after inverse transformation.
  • encoding a coding block is taken as an example for description.
  • the encoding device can also encode with smaller prediction granularity.
  • a block may contain multiple coding units, and different coding units may use different coding modes.
  • the encoding of adjacent coding units may have certain spatial dependence. Therefore, the encoding device of this embodiment can be used for smaller prediction encoding granularity (eg, CU).
  • Figure 9 shows a schematic diagram of encoding using the encoding device shown in Figure 4 or Figure 7.
  • the first encoder 31 uses the frame-level QP sum of the first image and each coding block in the first image.
  • the corresponding block-level QP i.e., ⁇ QP
  • the quality parameter T1 of each coding block in the first image data is shown in Figure 9.
  • the encoding device may separately adjust the QP corresponding to each encoding block in the first image according to the difference between T1 and T of each encoding block.
  • the encoding device may determine the QP corresponding to the first encoding block.
  • the QP offset value ⁇ QP4a corresponding to each coding block in the image is determined; and then the QP corresponding to each coding block in the first image is determined based on the ⁇ QP4a corresponding to each coding block.
  • the second encoder 32 may use the QP corresponding to each coding block to separately encode each coding block in the first image to obtain a second reconstructed image of the first image (i.e., the second reconstructed image in the method shown in FIG. 3 image data).
  • the quality parameter T2 of each coding block in the second image data is shown in Figure 9.
  • the quality parameter T2 of each coding block in the second image data is closer to the target quality parameter T.
  • Different coding in the second image data The gaps between the quality parameters of the blocks are also smaller and the quality is more uniform.
  • the encoding device can encode the image at least twice, adjust the QP corresponding to each encoding block in the image according to the quality parameters of each encoding block obtained from the previous encoding, and then adjust the QP according to the adjusted QP.
  • the image is encoded.
  • the encoding device can adjust the encoding parameter QP of this encoding based on the quality of the last actual encoding, thereby ensuring the quality of the encoded image.
  • the encoding device uses the intermediate result of the previous encoding, thereby simplifying the encoder structure of this encoding, which can effectively reduce the performance consumption of the encoding device.
  • the encoder 10 may include: an intra prediction module 102, an inter prediction module 104, a mode decision and residual calculation module 106, a transformation and quantization module 108, an inverse quantization and inverse transformation module 110, a filtering module 112, and an entropy coding module. 114. QP calculation module 116, reconstruction quality calculation module 118.
  • the encoding device may encode the image at least twice.
  • the encoding device calls the encoder 10 at least twice to encode each encoding block in the image through time division multiplexing, and adjusts each encoding block in the image during this encoding according to the encoding quality of the encoding block in the image after the last encoding.
  • the QP corresponding to the coding block respectively.
  • the encoding device can, based on the encoding quality of the target coding block in the nth frame image in the video, Predict the coding quality of similar coding blocks in subsequent images in the video, and adjust the QP corresponding to each similar coding block based on the predicted coding quality. This is described in detail below, taking the image to be encoded as the second image and the reference image as the first image as an example.
  • the code control module 20 may output the frame-level QP (QP_frame1b) of the second image and the block-level ⁇ QP ( ⁇ QPb) of the current encoding block to the QP calculation module 116 .
  • the current coding block may be any coding block in the second image.
  • the QP calculation module 116 may determine the QP corresponding to the current coding block in the second image (ie, the third QP in the method shown in FIG. 3) by performing S308-S311, and output the determined QP to the intra prediction module 102 and Inter prediction module 104; The encoder 10 may then encode the current encoding block in the second image using the third QP with reference to the description of FIGS. 1 and 3 .
  • the reconstruction quality calculation module 118 may determine a quality matrix representing the encoding quality of each encoding block in the second image based on the second image and the reconstructed image of the second image from the filtering module 112 .
  • the QP calculation module 116 may determine the QP corresponding to the current encoding block in the second image by performing operations E1-E3.
  • the QP calculation module 116 predicts the quality parameter T3 of each coding block in the second image based on the first image and the quality matrix of the first image.
  • the QP calculation module 116 may use motion estimation to find at least one target coding block closest to the current coding block in the first image.
  • the at least one target coding block may also be called a target coding block associated with the current coding block.
  • the QP calculation module 116 may determine the quality parameter of the at least one target coding block according to the quality matrix of the first image.
  • the mass matrix may be a two-dimensional mass matrix.
  • the QP calculation module 116 may predict the quality parameter of the current coding block according to the quality parameter of the at least one target coding block.
  • the encoding device may predict that the quality parameter of the current coding block is a weighted average of the quality parameters of the multiple target coding blocks.
  • the current coding block in the second image is coding block A
  • the coding blocks associated with coding block A in the first image include BLK7, BLK8, BLK11 and BLK12, that is, the first The blocks in the image that match coding block A (hereinafter referred to as reference blocks) are located in BLK7, BLK8, BLK11 and BLK12.
  • the QP calculation module 116 can predict the quality parameters of coding block A as:
  • w1, w2, w3, and w4 are the weights corresponding to BLK7, BLK8, BLK11, and BLK12 respectively.
  • the weight corresponding to each block can be the ratio of the number of pixels in the corresponding block according to the reference block to the total number of pixels in the reference block.
  • the QP calculation module 116 determines the QP offset value of the QP corresponding to each coding block in the second image according to the predicted quality parameter T3 of each coding block in the encoded second image (i.e., in the method shown in Figure 3 ⁇ QP4b).
  • the method by which the QP calculation module 116 determines ⁇ QP4b may refer to the method by which the QP adjustment module 33 determines ⁇ QP4a, which will not be described again here.
  • the encoding device may encode a part of the images in the video at least twice, and encode other images in the video once. For example, when the frame rate of the video to be encoded is 25fps, the encoding device can select 5 frames of images within one second to encode at least twice, and encode other frame images within one second once.
  • the encoding device can encode the first image in the video at least twice, thereby improving the encoding quality of the first image. Then, the encoding device can encode the second image in the video once based on the first image whose encoding quality has been improved; specifically, the encoding device predicts the video based on the encoding quality of the target encoding block in the first image whose encoding quality has been improved.
  • the coding quality of similar coding blocks in subsequent images in the video is adjusted, and the QP corresponding to each similar coding block is adjusted according to the predicted coding quality, thereby improving the coding quality of similar coding blocks in subsequent images in the video, and thereby improving the second image. encoding quality.
  • this embodiment has smaller changes to the encoder and reduces the number of encoders, thereby simplifying the architecture of the encoding device.
  • the encoding device may also use the method in this embodiment to encode all images in the video once.
  • the encoding device predicts the encoding quality of similar encoding blocks in subsequent images in the video based on the encoding quality of the target encoding block in the encoded image, and adjusts the QP corresponding to each similar encoding block based on the predicted encoding quality, so that it can Improving the coding quality of similar coding blocks in subsequent images in the video can, in turn, improve the coding quality of subsequent images.
  • the embodiment of the present application provides an image encoding device through Figure 13, which can be used to perform the functions of the relevant steps in the above embodiment.
  • the functions described can be implemented by hardware, or can be implemented by software or hardware executing corresponding software.
  • the hardware or software includes one or more modules corresponding to the above functions.
  • the image encoding device 1300 may include: an acquisition unit 1301 and a processing unit 1302.
  • the acquisition unit 1301 is used to: acquire a first image, where the first image contains at least one coding block; acquire a first quantization parameter QP corresponding to each coding block in the at least one coding block;
  • the processing unit 1302 is configured to: respectively encode each coding block in the at least one coding block according to the first QP corresponding to each coding block to obtain first image data; according to each coding block in the first image data The quality parameter of the coding block determines the second QP corresponding to each coding block; according to the second QP corresponding to each coding block, each coding block in the at least one coding block is separately coded to obtain the second QP. image data.
  • the processing unit 1302 is specifically configured to: determine the first encoding block corresponding to the first encoding block according to the target quality parameter of the first image and the quality parameter of the first encoding block in the first image data.
  • QP offset value wherein the first coding block is any coding block in the at least one coding block; according to the first QP corresponding to the first coding block and the first coding block corresponding to The first QP offset value determines the second QP corresponding to the first coding block.
  • processing unit 1302 is specifically used to:
  • the quality parameter of the first coding block is greater than the target quality parameter of the first image, and the difference between the quality parameter of the first coding block and the target quality parameter of the first image is in the first range, It is determined that the first QP offset value corresponding to the first coding block is equal to the QP offset value corresponding to the first range; wherein the first QP offset value corresponding to the first coding block is a positive number ;or
  • the absolute value of the difference between the quality parameter of the first coding block and the target quality parameter of the first image is located at the second
  • the range is within the range, it is determined that the absolute value of the first QP offset value corresponding to the first coding block is equal to the QP offset value corresponding to the second range; wherein, the first QP offset value corresponding to the first coding block The offset value is negative; or
  • the quality parameter of the first coding block is equal to the target quality parameter of the first image, it is determined that the first QP offset value corresponding to the first coding block is 0.
  • the processing unit 1302 is specifically configured to: after encoding each encoding block in the at least one encoding block according to the first QP corresponding to each encoding block, compare the first image data and the first image data. According to the first image, the quality parameters of each coding block in the first image data are obtained.
  • the processing unit 1302 is specifically configured to: perform quantization processing on the second coding block according to the first QP corresponding to the second coding block to obtain quantized data; wherein the second coding block is the at least Any coding block in a coding block; according to the first QP corresponding to the second coding block, perform inverse quantization and inverse transformation processing on the quantized data to obtain inversely transformed residual data; according to the first QP corresponding to the second coding block
  • the prediction data and residual data of the two coding blocks are used to obtain the reconstructed data of the second coding block; the reconstructed data is filtered to obtain the image data corresponding to the second coding block in the first image data.
  • the processing unit 1302 is specifically configured to: encode the third encoding block according to the first information and the second QP corresponding to the third encoding block; wherein the third encoding block is the at least one Any coding block in the coding block; wherein the first information includes at least one of the following: when the third coding block is coded according to the first QP corresponding to the third coding block, the determined The prediction mode of the third coding block; the motion vector of the third coding block determined when the third coding block is coded according to the first QP corresponding to the third coding block.
  • the processing unit 1302 is specifically configured to: after encoding each coding block in the at least one coding block according to the second QP corresponding to each coding block, save the second information; wherein, the The second information is used to represent the quality parameter of each encoding block in the second image data.
  • the fourth coding block performs coding, where n is a positive integer.
  • the processing unit 1302 is specifically configured to: determine the second QP offset corresponding to the fourth encoding block according to the target quality parameter of the second image and the predicted quality parameter of the encoded fourth encoding block. shift value; determine the third QP corresponding to the fourth coding block according to the second QP offset value corresponding to the fourth coding block.
  • the second QP offset value corresponding to the fourth coding block is equal to the QP offset value corresponding to the third range; wherein the second QP offset value corresponding to the fourth coding block is a positive number ;
  • the quality parameters of any coding block include at least one of the following:
  • Peak signal-to-noise ratio structural similarity, multi-scale structural similarity.
  • FIG. 14 is a schematic block diagram of the image encoding device 1400 according to the embodiment of the present application. It should be understood that the image encoding device 1400 is capable of performing various steps performed by the encoding device in the above embodiments shown in FIGS. 3 to 12 .
  • Image encoding device 1400 includes a processor 1401 and a memory 1402 coupled to processor 1401 .
  • the memory 1402 can be used to store program codes; the processor 1401 can call the program codes stored in the memory to execute the above image encoding method.
  • the processor 1401 can be a central processing unit (CPU), or other general-purpose processor, digital signal processor (DSP), application specific integrated circuit (application specific integrated circuit), ASIC), field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof.
  • DSP digital signal processor
  • ASIC application specific integrated circuit
  • FPGA field programmable gate array
  • a general-purpose processor can be a microprocessor or any conventional processor.
  • Memory 1401 may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.
  • non-volatile memory can be read-only memory (Read-Only Memory, ROM), programmable read-only memory (Programmable ROM, PROM), erasable programmable read-only memory (Erasable PROM, EPROM), electrically removable memory.
  • Erase programmable read-only memory Electrically EPROM, EEPROM
  • Volatile memory can be RAM, which acts as an external cache.
  • RAM static random access memory
  • DRAM dynamic random access memory
  • DRAM synchronous dynamic random access memory
  • SDRAM double data rate synchronous dynamic random access memory
  • Double Data Rate SDRAM DDR SDRAM
  • enhanced SDRAM ESDRAM
  • Synchlink DRAM SLDRAM
  • Direct Rambus RAM Direct Rambus RAM
  • the processor 1401 and the memory 1402 may be connected to each other through a bus 1403.
  • the bus 1403 may be a peripheral component interconnect standard (PCI) bus or an extended industry standard architecture (EISA) bus, etc.
  • PCI peripheral component interconnect standard
  • EISA extended industry standard architecture
  • the bus 1403 can be divided into an address bus, a data bus, a control bus, etc. For ease of presentation, only one thick line is used in Figure 14, but it does not mean that there is only one bus or one type of bus.
  • embodiments of the present application also provide a computer program, which when the computer program is run on a computer, causes the computer to execute the method provided in the above embodiments.
  • embodiments of the present application also provide a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program.
  • the computer program When the computer program is executed by a computer, it causes the computer to execute the method provided in the above embodiments. .
  • the storage medium may be any available medium that can be accessed by the computer.
  • computer-readable media may include RAM, ROM, EEPROM or other optical disk storage, magnetic disk storage media or other magnetic storage devices, or may be used to carry or store desired programs in the form of instructions or data structures. code and any other medium that can be accessed by a computer.
  • embodiments of the present application also provide a chip, which is used to read the computer program stored in the memory and implement the method provided in the above embodiments.
  • the chip system includes a processor and is used to support the computer device to implement the functions involved in each device in the above embodiments.
  • the chip system further includes a memory, and the memory is used to store necessary programs and data of the computer device.
  • the chip system may be composed of chips, or may include chips and other discrete devices.
  • embodiments of the present application provide an image coding method, device and equipment.
  • the coding device can acquire the information related to each coding block in at least one coding block in the first image.
  • the first QP corresponding to the coding block respectively; then, each coding block in the at least one coding block is separately coded according to the first QP corresponding to each coding block to obtain the first image data.
  • the encoding device may determine the second QP corresponding to each encoding block according to the quality parameter of each encoding block in the first image data; and according to the second QP corresponding to each encoding block, the at least one encoding block Each encoding block is encoded separately to obtain second image data.
  • the encoding device can adjust the encoding parameter QP of this encoding based on the quality of the last actual encoding, thereby ensuring the quality of the encoded image.
  • embodiments of the present application may be provided as methods, systems, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment that combines software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, etc.) having computer-usable program code embodied therein.
  • a computer-usable storage media including, but not limited to, disk storage, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions
  • the device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
  • These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device.
  • Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.

Landscapes

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

Abstract

本申请公开了一种图像编码方法、装置及设备,用于保证编码后图像的质量。该方法包括: 编码设备在获取到第一图像之后,可以获取与第一图像中至少一个编码块中每个编码块分别对应的第一QP; 然后,根据与每个编码块对应的第一QP,对该至少一个编码块中每个编码块分别进行编码,得到第一图像数据。编码设备可根据第一图像数据中每个编码块的质量参数,确定与每个编码块分别对应的第二QP; 并根据与每个编码块对应的第二QP,对该至少一个编码块中每个编码块分别进行编码,得到第二图像数据。通过该方法,编码设备可以根据上一次实际编码的质量来调整本次编码的量化参数QP,从而可以保证编码后图像的质量。

Description

一种图像编码方法、装置及设备
相关申请的交叉引用
本申请要求在2022年03月15日提交中国专利局、申请号为202210255919.X、申请名称为“一种图像编码方法、装置及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及图像领域,尤其涉及一种图像编码方法、装置及设备。
背景技术
随着信息技术的发展,图像和视频成为数字信息内容的主要组成部分。为了便于传输,需要对图像或视频进行更好的压缩编码,使其占用的空间更小、主观效果更好。目前,可以通过以下两个方面来实现该目标:
一方面,通过研究更加复杂的编码工具来提升预测准确度(比如增强更多预测模式)、变换的能量集中性(比如更加灵活的变换)等,从而提升视频的压缩率。各大视频编码标准组织(例如,动态图像专家组高级视频编码(moving picture experts group-advanced video coding,MPEG-AVC)、高效率视频编码(high efficiency video coding,HEVC)、音视频编码标准(Audio Video coding Standard,AVS)1/2/3等)一直进行这方面的工作。
另一方面,在标准框架下,在视频压缩过程中,根据人类视觉系统(human visual system,HVS)特性来提升编码的主客观效果。例如,通过自适应量化(adaptive quantization,AQ)技术,基于纹理强度、边缘强度、亮度或时域特征等来分配码率。在码率一定的情况下,获得更好的编码后的图像质量。
在目前的编码方法中,编码器会预先确定用于编码的量化参数(quantization parameter,QP),并通过QP来分配码率。但是,编码后图像的质量与很多因素有关。编码器采用预先确定的QP进行编码,可能会导致编码后图像的质量不理想,编码后图像中不同区域的质量可能会有很大差异。
因此,本领域需要一种能够保证编码后图像的质量的图像编码方案。
发明内容
本申请提供一种图像编码方法、装置及设备,用于保证编码后图像的质量。
第一方面,本申请提供了一种图像编码方法。该方法包括:编码设备在获取到第一图像之后,可以获取与第一图像中至少一个编码块中每个编码块分别对应的第一QP;然后,根据与每个编码块对应的第一QP,对该至少一个编码块中每个编码块分别进行编码,得到第一图像数据。编码设备可根据第一图像数据中每个编码块的质量参数,确定与每个编码块分别对应的第二QP;并根据与每个编码块对应的第二QP,对该至少一个编码块中每个编码块分别进行编码,得到第二图像数据。
通过该方法,编码设备可以对图像进行至少两次编码,并根据上一次编码得到的每个 编码块的质量参数,调整相应编码块的QP,再根据调整后的QP对图像进行编码。这样,编码设备可以根据上一次实际编码的质量来调整本次编码的编码参数QP,从而可以保证编码后的图像质量。
在一种可能的设计中,对于所述至少一个编码块中的任一编码块(下面称为第一编码块),编码设备可根据所述第一图像的目标质量参数和所述第一图像数据中的所述第一编码块的质量参数,确定与所述第一编码块对应的第一QP偏移值;然后,根据与所述第一编码块对应的第一QP和与所述第一编码块对应的第一QP偏移值,确定与所述第一编码块对应的第二QP。通过该设计,编码设备可先确定与所述第一编码块对应的第一QP偏移值,再根据与所述第一编码块对应的第一QP偏移值,确定与所述第一编码块对应的第二QP。一般情况下,相对于第二QP,第一QP偏移值较小;这样,确定第一QP偏移值的计算量较小,传输或存储第一QP偏移值所需的资源也较少。
在一种可能设计中,编码设备可通过如下方式确定与所述第一编码块对应的第一QP偏移值:
当所述第一编码块的质量参数大于所述第一图像的目标质量参数,且所述第一编码块的质量参数与所述第一图像的目标质量参数的差值位于第一范围时,编码设备可确定与所述第一编码块对应的第一QP偏移值等于与所述第一范围对应的QP偏移值;其中,与所述第一编码块对应的第一QP偏移值为正数;或者
当所述第一编码块的质量参数小于所述第一图像的目标质量参数,且所述第一编码块的质量参数与所述第一图像的目标质量参数的差值的绝对值位于第二范围时,编码设备可确定与所述第一编码块对应的第一QP偏移值的绝对值等于与所述第二范围对应的QP偏移值;其中,与所述第一编码块对应的第一QP偏移值为负数;或者
当所述第一编码块的质量参数等于所述第一图像的目标质量参数时,编码设备可确定与所述第一编码块对应的第一QP偏移值为0。
通过该设计,当第一图像中的编码块的编码质量低于第一图像的目标质量时,第一QP偏移值为负值;从而可以通过调小QP来提高该编码块的编码质量,使其接近目标质量。当第一图像中的编码块的编码质量高于第一图像的目标质量时,第一QP偏移值为正值;从而可通过调大QP来降低该编码块的编码质量,使其接近目标质量。这样,当目标码率固定时,编码设备可以在第一图像内部分配码率,即,调低编码质量超过目标质量的编码块的码率,将节省的码字分配给编码质量低于目标质量的编码块,以便提高编码质量低于目标质量的编码块的码率,从而可以提高第一图像的整体编码质量,使得第一图像的编码质量更加均衡。当目标码率可变时,该设计可以通过降低编码质量超过目标质量的编码块的质量来降低图像整体需要的码率。
在一种可能的设计中,根据与每个编码块对应的第一QP,对所述至少一个编码块中每个编码块分别进行编码之后,编码设备可比较所述第一图像数据和所述第一图像,从而得到所述第一图像数据中每个编码块的质量参数。通过该设计,编码设备可准确确定出通过与每个编码块对应的第一QP对所述至少一个编码块中每个编码块分别进行编码后,每个编码块的质量参数。
在一种可能的设计中,对于所述至少一个编码块中的任一编码块(下面称为第二编码块),编码设备可通过如下方式来根据与第二编码块对应的第一QP对第二编码块进行编码:
编码设备可根据与第二编码块对应的第一QP,对所述第二编码块进行量化处理,得 到量化数据;再根据与所述第二编码块对应的第一QP,对所述量化数据进行反量化和反变换处理,得到反变换后的残差数据;然后,编码设备可根据所述第二编码块的预测数据和残差数据,得到所述第二编码块的重建数据,并对所述重建数据进行滤波,从而得到所述第一图像数据中与所述第二编码块对应的图像数据。
通过该设计,在根据与每个编码块对应的第一QP,对上述至少一个编码块中每个编码块分别进行编码时,确定出用于下一次编码的第一图像数据即可,无需输出码流,从而可以提高编码效率。
在一种可能的设计中,对于所述至少一个编码块中的任一编码块(下面称为第三编码块),编码设备可根据第一信息以及与第三编码块对应的第二QP,对所述第三编码块进行编码。其中,所述第一信息可以为根据与所述第三编码块对应的第一QP对所述第三编码块进行编码时得到的中间数据。例如,第一信息可包括以下至少一项:根据与所述第三编码块对应的第一QP对所述第三编码块进行编码时,确定的所述第三编码块的预测模式;根据与所述第三编码块对应的第一QP对所述第三编码块进行编码时,确定的所述第三编码块的运动矢量。通过该设计,在根据与每个编码块对应的第二QP,对至少一个编码块中每个编码块分别进行编码时,可复用根据与每个编码块对应的第一QP对上述至少一个编码块中每个编码块分别进行编码得到的中间结果。换句话说,本次编码可复用上一次编码的中间结果,从而可以简化编码流程,提高编码效率。
在一种可能的设计中,在根据与每个编码块对应的第二QP,对所述至少一个编码块中每个编码块分别进行编码之后,编码设备可保存第二信息。其中,所述第二信息可用于表示所述第二图像数据中每个编码块的质量参数。
可选的,所述第二信息可为包含所述第二图像数据中每个编码块的质量参数的矩阵。
通过该设计,编码设备在对第一图像进行编码后,可以保存用于表示第二图像数据中每个编码块的质量参数的第二信息;这样,编码设备在对第一图像所在视频中的后续图像进行编码时,可以参考第二信息,从而可以提高后续图像的编码质量。
在一种可能的设计中,所述第一图像可为视频中的第n帧图像,其中,n为正整数;在保存第二信息之后,编码设备可根据第一图像的第二信息来对视频中的后续图像进行编码。具体的,编码设备可获取所述视频中第n+1帧图像(下面称为第二图像),所述第二图像中包含N个编码块,N为正整数。编码设备可在第一图像中的所述至少一个编码块中,确定与所述第二图像中第四编码块关联的至少一个目标编码块;其中,所述第四编码块可为所述N个编码块中的任一个编码块,所述第四编码块中的内容包含在所述至少一个目标编码块中。在根据所述第二信息,确定所述第二图像数据中所述至少一个目标编码块的质量参数之后,编码设备可根据所述至少一个目标编码块的质量参数,预测编码后所述第四编码块的质量参数,并据此确定与所述第四编码块对应的第三QP。然后,编码设备可根据与所述第四编码块对应的第三QP,对所述第四编码块进行编码。
通过该设计,编码设备可以对视频中的第一图像进行至少两次编码,从而提高第一图像的编码质量。然后,编码设备可根据已提高编码质量的第一图像,对视频中的第二图像进行一次编码;具体的,编码设备根据已提高编码质量的第一图像中目标编码块的编码质量,预测视频中后续图像中相似编码块的编码质量,并根据预测的编码质量调整QP,从而可提高视频中后续图像中相似编码块的编码质量,进而可提高第二图像的编码质量。
在一种可能的设计中,编码设备可在根据所述第二图像的目标质量参数和预测的编码 后所述第四编码块的质量参数,确定与所述第四编码块对应的第二QP偏移值之后,根据与所述第四编码块对应的第二QP偏移值,确定与所述第四编码块对应的第三QP。通过该设计,编码设备可先确定与所述第四编码块对应的第二QP偏移值,再根据与所述第四编码块对应的第二QP偏移值,确定与所述第四编码块对应的第三QP。一般情况下,相对于第三QP,第二QP偏移值较小;这样,确定第二QP偏移值的计算量较小,传输或存储第二QP偏移值所需的资源也较少。
在一种可能的设计中,编码设备可通过如下方式确定与所述第四编码块对应的第二QP偏移值:
当所述第四编码块的质量参数大于所述第二图像的目标质量参数,且所述第四编码块的质量参数与所述第二图像的目标质量参数的差值位于第三范围时,编码设备可确定与所述第四编码块对应的第二QP偏移值等于与所述第三范围对应的QP偏移值;其中,与所述第四编码块对应的第二QP偏移值为正数;或者
当所述第四编码块的质量参数小于所述第二图像的目标质量参数,且所述第四编码块的质量参数与所述第二图像的目标质量参数的差值的绝对值位于第四范围时,编码设备可确定与所述第四编码块对应的第二QP偏移值的绝对值等于与所述第四范围对应的QP偏移值;其中,与所述第四编码块对应的第二QP偏移值为负数;或者
当预测的编码后所述第四编码块的质量参数等于所述第二图像的目标质量参数时,编码设备可确定与第四编码块对应的第二QP偏移值为0。
通过该设计,当第二图像中的编码块的质量低于第二图像的目标质量时,第二QP偏移值为负值;从而可以通过调小QP来提高该编码块的编码质量。当第二图像中的编码块的质量高于第一图像的目标质量时,第二QP偏移为正值;从而可通过调大QP来降低该编码块所需的码率,而节约的码率可用于提高第二图像中质量低于第二图像的目标质量的编码块的编码质量;这样,无需提高整体码率,即可提高第二图像的整体编码质量。
在一种可能的设计中,任一编码块的质量参数可包括以下至少一项:峰值信噪比、结构相似度、多尺度结构相似度。
第二方面,提供了一种图像编码装置,包括用于执行上述第一方面及第一方面任一可能的设计中各个步骤的单元。
第三方面,提供了一种图像编码设备,包括处理器以及耦合至所述处理器的存储器。其中,该存储器可用于存储程序代码;处理器可调用存储在所述存储器中的程序代码以执行上述第一方面及第一方面任一可能的设计中的方法。
第四方面,本申请实施例还提供了一种计算机程序,当所述计算机程序在计算机上运行时,使得所述计算机执行上述第一方面及第一方面任一可能的设计中的方法。
第五方面,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,当所述计算机程序被计算机执行时,使得所述计算机执行上述第一方面及第一方面任一可能的设计中的方法。
第六方面,本申请实施例还提供了一种芯片,所述芯片用于读取存储器中存储的计算机程序,执行上述第一方面及第一方面任一可能的设计中的方法。
第七方面,本申请实施例还提供了一种芯片系统,该芯片系统包括处理器,用于支持计算机装置实现上述第一方面及第一方面任一可能的设计中的方法。在一种可能的设计中, 所述芯片系统还包括存储器,所述存储器用于保存该计算机装置必要的程序和数据。该芯片系统可以由芯片构成,也可以包含芯片和其他分立器件。
上述第二方面至第七方面中任一方面可以达到的技术效果可以参照上述第一方面及第一方面中任一可能的设计可以达到的技术效果说明,重复之处不予论述。
附图说明
图1为一种编码设备的结构图;
图2为一种AQ方案的示意图;
图3为本申请实施例提供的一种图像编码方法的流程图;
图4为本申请实施例提供的一种编码设备的结构图;
图5为本申请实施例提供的QP调整模块33的一种处理流程的示意图;
图6为本申请实施例提供的QP调整模块33的另一种处理流程的示意图;
图7为本申请实施例提供的另一种编码设备的结构图;
图8为本申请实施例提供的预测编码模块41的结构图;
图9为本申请实施例提供的一种编码方法的示意图;
图10为本申请实施例提供的又一种编码设备的结构图;
图11为本申请实施例提供的QP计算模块116的处理流程示意图;
图12为本申请实施例提供的一种编码块关联关系的示意图;
图13为本申请实施例提供的一种图像编码装置的结构图;
图14为本申请实施例提供的一种图像编码设备的结构图。
具体实施方式
本申请提供一种图像编码方法、装置及设备,用以保证编码后图像的质量。其中,方法、装置和设备是基于同一技术构思的,由于解决问题的原理相似,因此装置、设备与方法的实施可以相互参见,重复之处不再赘述。
通过本申请实施例提供的方案,编码设备在获取到第一图像之后,可以获取与第一图像中至少一个编码块中每个编码块分别对应的第一QP;然后,根据每个编码块对应的第一QP,对该至少一个编码块中每个编码块分别进行编码(下面称为第一编码),得到第一图像数据。编码设备根据第一图像数据中每个编码块的质量参数,确定与每个编码块分别对应的第二QP;并根据与每个编码块对应的第二QP,对该至少一个编码块中每个编码块进行编码,得到第二图像数据。通过该方案,编码设备可以对图像进行至少两次编码,根据上一次编码得到的每个编码块的质量参数,调整相应编码块的QP,再根据调整后的QP对图像进行编码。这样,编码设备可以根据上一次编码的质量来调整本次编码的QP,从而可以保证本次编码后的图像质量。
以下,对本申请实施例中的部分用语进行解释说明,以便于本领域技术人员理解。
1)、图像编码,通常包括处理(例如,通过压缩)原始图像以减少表示该图像所需的数据量,以较少的比特数表示图像或图像中所包含的信息,从而更高效地存储和/或传输。
2)、视频编码,通常是指处理形成视频或视频序列的图像序列。视频编码通常包括处理(例如,通过压缩)原始视频图像以减少表示该视频图像所需的数据量,从而更高效地 存储和/或传输。在视频编码领域,术语“图片(picture)”、“帧(frame)”或“图像(image)”可以用作同义词。
3)、块(block),是图像编码或视频编码的处理单位,又称为图像块。
每个图像可包括至少一个块。一些视频编码标准对块进行了进一步的扩展。例如,在H.264标准中有宏块(macroblock,MB),宏块可进一步划分成多个可用于预测编码的预测块(partition)。又例如,在HEVC标准中,采用编码单元(coding unit,CU)、预测单元(prediction unit,PU)和变换单元(transform unit,TU)等基本概念。CU是对图像进行划分和编码的基本单元。PU可以对应预测块,是预测编码的基本单元。TU可以对应变换块,是对预测残差进行变换的基本单元。CU、PU和TU本质上都属于块。
本文中,为了便于描述和理解,可将当前编码图像中待编码的图像块称为编码块;将参考图像中为编码块提供预测信息的块为预测块,其中,预测信息可表示预测块内的像素值、采样值或者采样信号。
4)、编码设备,是能够对图像或视频进行编码的设备的统称。例如,编码设备可以为台式计算机、笔记型计算机、平板计算机、机顶盒、手机、电视、照相机、摄影机、显示装置、数字媒体播放器、视频游戏控制台或视频流传输装置等。
本申请实施例中,对于名词的数目,除非特别说明,表示“单数名词或复数名词”,即“一个或多个”。“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。“以下至少一项(个)”或其类似表达,是指这些项(个)中的任意组合,包括单项(个)或复数项(个)的任意组合。
另外,需要理解的是,在本申请的描述中,“第一”、“第二”等词汇,仅用于区分描述的目的,而不应理解为指示或暗示相对重要性,也不应理解为指示或暗示顺序。
为了便于理解本申请,下面参考图1介绍编码设备进行编码的过程。
如图1所示,按照编码过程中的功能逻辑划分,编码设备可包括编码器10和码控模块20。其中,编码器10中包括:帧内预测模块102、帧间预测模块104、模式判决及残差计算模块106、变换和量化模块108、反量化和反变换模块110、滤波模块112、熵编码模块114。
下面以该编码设备对输入图像Fn(即视频中的第n帧图像,其中,n为正整数)中的当前编码块进行编码为例进行说明。其中,当前编码块可以为输入图像Fn中的任一编码块。
码控模块20可为编码器10提供输入图像Fn的帧级QP(即QP_frame)和当前编码块的块级ΔQP。其中,当前编码块的块级ΔQP为当前编码块的QP与当前编码块所在的图像的帧级QP之间的偏移值。
其中,码控模块20可通过帧级码控来确定Fn的帧级QP。具体的,码控模块20可根据以下至少一项计算输入图像Fn的帧级QP:输入图像Fn所在视频对应的输出码流的大小、目标码率和其他控制参数(比如前后2帧场景切换信息,允许的码率波动幅度指标等)。例如,当输入图像Fn所在视频对应的输出码流的大小与时间的比值大于目标码率时,码控模块20可以调大输入图像Fn的帧级QP,以便减小输入图像Fn对应的码率,从而降低输入图像Fn所在视频的整体码率,使其接近目标码率。又例如,当输入图像Fn所在视频 对应的输出码流的大小与时间的比值小于目标码率时,码控模块20可以调小输入图像Fn的帧级QP,以便提高输入图像Fn对应的码率,从而提高输入图像Fn所在视频的整体码率,使其接近目标码率。
码控模块20确定当前编码块的块级ΔQP的方法可以参考以下对图2的说明,此处暂不展开。
帧内预测模块102可获取输入图像Fn中的当前编码块的参考数据(例如,相邻位置已经编码的重建数据)。然后,帧内预测模块102可根据预定的一种或多种预测模式进行帧内模式的选择,并输出选择出的最优模式对应的代价(比如,cost=distortion+lambda*bits,其中,cost为代价;distortion为失真,可以用平方误差和(sum square of difference,SSD)来度量;bits为对变化量化系数编码所使用的比特数(bits),lambda为权重)和预测数据,其中,预测数据可包括预测块的预测角度标识等信息,最优模式为代价最小的模式。帧内预测模块102进行预测的模式可以被称为帧内预测模式。
帧间预测模块104可包括运动估计单元和运动补偿单元。运动估计单元可以在参考图像Fn-1(即视频中的第n-1帧图像)中寻找当前待编码最相似的预测块,其中相似性的度量可以按照用户指定某种度量指标来度量,比如预测残差的绝对值之和(sum absolute of difference,SAD)或SSD。在主流的视频编码器中在运动估计过程还会包含分数像素的插值与搜索等操作。运动估计的结果得到最优的运动向量(motion vector,MV);其中,最优的MV为与当前编码块最相似的预测块对应的MV。运动补偿单元可根据运动估计单元确定的运动向量取出或生成预测块,并得到预测数据;其中,预测数据可包括预测块的标识、MV等信息。当n为大于1的整数时,可采用帧间预测模块104进行预测。采用帧间预测模块104进行预测的模式可以被称为帧间预测模式。
模式判决及残差计算模块106可以包括模式判决单元和残差计算单元。其中,模式判决单元用于选择采用帧内预测模式还是帧间预测模式进行预测。例如,当通过帧内预测模式进行编码时的代价小于或等于通过帧间预测模式进行编码时的代价时,模式判决单元可以选择通过帧内预测模式进行预测;当通过帧内预测模式进行编码时的代价大于通过帧间预测模式进行编码时的代价时,模式判决单元可以选择通过帧间预测模式进行预测。残差计算单元用于计算当前编码块的像素与模式判决单元选择的预测模式(帧内预测模式或帧间预测模式)得到的预测块的像素之间的像素值差异,即残差。
变换和量化模块108可包括变换单元和量化单元。其中,变换单元用于对残差进行变换,将其转化为变换系数(transform coefficient)。常用的变换可包括以下之一:离散余弦变换(discrete cosine transform,DCT)、离散正弦变换(discrete sine transform,DST)、小波变换等。量化单元用于对变换系数进行量化处理。量化是指对变换系数进行量化以减少用以表示量化系数的数据的量,从而实现进一步的压缩。具体的,量化单元可根据来自码控模块的当前编码块的块级ΔQP以及输入图像Fn的帧级QP(QP_frame),确定当前编码块的QP(即QP_frame+ΔQP);并使用当前编码块的QP定义的量化步长,对变换系数进行量化处理,得到量化数据(也可以称为经量化的变换系数或量化后的变换系数)。
反量化和反变换模块110可包括反量化单元和反变换单元。其中,反量化单元可用于对量化数据进行反量化处理,得到反量化后的变换系数。反变换单元用于对反量化后的变换系数进行反变换处理(例如,逆DCT、逆整数变换或概念上类似的逆变换过程),从而得到反变换后的残差(也可以称为重构残差)。
滤波模块112可以对重建数据进行滤波,得到当前编码块的图像数据(也可称为重构数据、重构图像或重构块),从而减少失真,提高图像质量。其中,重建数据是根据反变换后的残差确定的,例如,可以为预测数据和反变换后的残差相加的结果。由于滤波模块112输出的图像数据经过量化处理,且可能存在失真,因此,该图像数据还可以被称为量化失真的重构数据。滤波模块112在对输入图像的所有编码块进行滤波之后,可输出输入图像的重构图像(即图1中的重构图像Fn)。另外,滤波模块112还可以将滤波信息(例如,样本自适应偏移(sample-adaptive offset,SAO)模式信息及补偿信息等)输出至熵编码模块114。滤波模块112可以包含以下至少一项:去块滤波器、SAO滤波器、双边滤波器、自适应环路滤波器(adaptive loop filter,ALF)、锐化或平滑滤波器、协同滤波器。
熵编码模块114用于将熵编码方案应用于量化数据、预测数据、SAO模式信息及补偿信息等中的一个或多个上,以获取经编码的码流,并输出该码流。其中,熵编码方案可以为以下之一:可变长度编码(variable length coding,VLC)方案、上下文自适应VLC(context adaptive VLC,CAVLC)方案、算术编码方案、上下文自适应二进制算术编码(context adaptive binary arithmetic coding,CABAC)、基于语法的上下文自适应二进制算术编码(syntax-based context-adaptive binary arithmetic coding,SBAC)、概率区间分割熵(probability interval partitioning entropy,PIPE)等。另外,熵编码模块114还可将码流的比特数上报给码控模块20。
应理解,虽然图1是以编码器10为视频编码器为例进行说明的,但是,本申请也可用于图像编码领域中。此时,图1中的编码器10可以为图像编码器,编码器10可以不包含帧间预测模块104和模式判决单元。
编码设备在进行编码时,可通过AQ方案来提高编码后的主客观质量。下面结合图2说明AQ方案。如图2所示,在AQ方案中,编码设备(例如,编码设备中的码控模块20)可对原始图像进行分析,根据空域特征、时域特征和亮度特征来确定当前编码块的QP偏移值,从而调节当前编码块的QP。下面分别对其进行说明。
根据空域特性调整QP:编码设备对输入图像Fn(也可称为原始图像)进行纹理分析,根据纹理分析结果确定当前编码块的第一种QP偏移值(即ΔQP1)。可选的,编码设备计算输入图像Fn中当前编码块的亮色度的方差,根据该方差计算当前编码块的ΔQP1。当前编码块的方差越大,ΔQP1越大。例如,x264和x265的开源编码器中使用的AQ算法就是通过这种方法来计算ΔQP1的。该方法主要利用HVS特性,对含有复杂频率成分的编码块使用更大的量化步长,从而可减小对视觉的影响。
根据时域特性调整QP:编码设备可进行时域分析,即根据视频序列时域的相关性来确定当前编码块的第二种QP偏移值(即ΔQP2)。可选的,编码设备根据当前编码块对其他编码块(例如,未编码的编码块)的贡献来确定ΔQP2,从而调整当前编码块的编码图像质量。通常一个编码块的信息被其他编码块参考得越多,该编码块的ΔQP2越小,编码图像质量越高。反之,该编码块的ΔQP2越大,编码图像质量越差。例如,x264和x265中的宏块树(macroblock tree,Mbtree)和编码单元树(coding unit tree,Cutree)技术就是采用这种方法来计算ΔQP2的。
根据亮度特性调整QP:编码设备可进行亮度分析,即根据亮度来确定当前编码块的第三种QP偏移值(即ΔQP3)。利用人眼对不同亮度区间失真敏感度不同,编码设备可为 当前编码块设置与当前编码块亮度对应的ΔQP3。通过该方法,可以根据人眼视觉特性,针对不同亮度块来分配不同的码率,从而可以合理分配码率,改善主观图像质量。
通过上述AQ方案,当前编码块的QP=ΔQP1+ΔQP2+ΔQP3+QP_frame=ΔQP+QP_frame。其中,QP_frame为当前编码块所在图像的帧级QP;ΔQP为当前编码块的QP偏移量(也称为块级ΔQP)。
应理解,在实际应用中,可以选择上述一种或多种调节QP的方法。例如,编码设备可根据空域特征和亮度特征来调节当前编码块的QP;此时,当前编码块的QP=ΔQP1+ΔQP3+QP_frame=ΔQP+QP_frame。又例如,编码设备可根据亮度特征来调节当前编码块的QP;此时,当前编码块的QP=ΔQP3+QP_frame=ΔQP+QP_frame。
使用上述AQ方案确定ΔQP,可能会存在以下问题。
在上述AQ方案中,编码设备都是在对当前编码块进行编码前确定当前编码块的ΔQP,从而对QP进行调整的;也就是说,编码设备是基于“预分析/预判”的方式来确定当前编码块的QP的。然而,实际编码的效果还会受到预测模式、变换尺寸、目标码率、场景时域和空域的复杂程度等影响;采用预先确定的QP进行编码时,编码后图像内不同区域的质量可能会存在较大差异,例如,有些区域很清楚,包含很多细节,但有些区域却很模糊。
另外,上述AQ方案中,编码设备根据原始图像来确定QP偏移值,并没有考虑实际场景中的编码压力(例如,目标码率、当前QP)。当目标码率较低时,由于码率的限制,若图像块的QP不能过低,从而可能导致图像中某些编码块的编码质量较低,进而使得图像的编码质量很可能是不均匀的。此外,当前主流的视频编码标准中,量化步长与QP之间的关系是非线性的指数关系。例如,随着QP的增大,QP变化1,对应的量化步长会显著增加,对图像的编码质量的影响也会显著增加,从而可能导致图像的编码质量不均匀。
为了保证编码后图像的质量,本申请实施例提供了一种图像编码方法。下面参阅图3所示的流程图,对该方法的流程进行具体说明。
S301:编码设备获取第一图像。其中,第一图像中包含至少一个编码块。
其中,该第一图像为待编码的图像。该第一图像可以是单独的图像,也可以是视频中的某一帧图像(例如,第n帧图像,其中,n为正整数)。
另外,编码设备可以从本地存储的图像或视频中获取第一图像,也可以从来自其他设备的图像或视频中获取第一图像,还可以从通过摄像设备预览的图像中获取第一图像。
S302:编码设备获取与第一图像中至少一个编码块中每个编码块对应的第一QP。
其中,编码设备可包括图1所示的码控模块20。编码设备可根据从码控模块20获取第一图像的帧级QP和每个编码块对应的块级ΔQP,从而确定出每个编码块对应的第一QP。
例如,第一编码块为第一图像中的任一编码块;编码设备在从码控模块20获取第一图像的帧级QP(QP_frame1a)和第一编码块对应的块级ΔQP(即ΔQPa)之后,可确定第一编码块对应的第一QP为QP_frame1a+ΔQPa。
S303:编码设备根据与每个编码块对应的第一QP,对上述至少一个编码块中每个编码块分别进行编码,得到第一图像数据。
其中,第一图像数据可以为重构数据或重建数据。
可选的,S303可通过以下方式之一来实现:
方式一:编码设备采用图1所示的全部编码过程对上述至少一个编码块中的每个编码 块进行编码,输出码流,并得到第一图像数据。具体内容可参考对图1的说明,此处不再赘述。
方式二:编码设备采用图1所示的部分编码过程对上述至少一个编码块中的每个编码块进行编码,得到第一图像数据。
下面以第二编码块为例对方式二的实现过程进行说明。其中,第二编码块可为上述至少一个编码块中的任一编码块。
对于第二编码块,S303可包括A1-A4。
A1:编码设备根据与第二编码块对应的第一QP,对第二编码块进行量化处理,得到量化数据。
A2:编码设备根据与第二编码块对应的第一QP,对量化数据进行反量化和反变换处理,得到反变换后的残差数据。
A3:编码设备根据第二编码块的预测数据和残差数据,得到第二编码块的重建数据。
A4:编码设备对重建数据进行滤波,得到第一图像数据中与第二编码块对应的图像数据。
其中,A1-A4的具体内容可参考对图1的说明,此处不再赘述。
在该方式二中,本次编码可确定用于下一次编码的第一图像数据,无需输出码流,从而可以提高编码效率。
S304:编码设备根据第一图像数据中每个编码块的质量参数,确定与每个编码块分别对应的第二QP。
其中,编码设备可通过比较第一图像数据和第一图像,得到第一图像数据中每个编码块的质量参数;然后,编码设备可根据第一图像数据中每个编码块的质量参数,确定与每个编码块分别对应的第二QP。其中,任一编码块的质量参数可包括以下至少一项:峰值信噪比(peak signal noise ratio,PSNR)、结构相似度(structure similarity index metric,SSIM)、多尺度结构相似度(multiple scalar structure similarity index metric,MS-SSIM)。
下面以第一编码块为例对S304的实现过程进行说明。其中,第一编码块可为第一图像中至少一个编码块中的任一编码块。
对于第一编码块,S304可包括B1-B2。
B1:编码设备可根据第一图像的目标质量参数和第一图像数据中的第一编码块的质量参数,确定与第一编码块对应的第一QP偏移值(下面简称为ΔQP4a)。
其中,第一图像的目标质量参数可以是固定的,也可以是可变的。
在一些可能的实施方式中,第一图像的目标质量参数可为用户输入的固定目标质量参数。
在另一些可能的实施方式中,编码设备可根据图像内容和编码压力调整目标质量参数。例如,在目标码率固定的情况下,编码设备可将已编码的图像的平均质量参数确定为第一图像的目标质量参数;也可以确定第一图像的目标质量参数为已编码的图像的平均质量参数与第一偏移值之和,其中,第一偏移值可以为正数、负数或0。这样,当图像中显示的场景比较简单时,编码所需的码字较少(也就是说编码压力较小),图像的编码质量较好,已编码的图像的平均质量参数也会较高(假设质量参数越高,质量越高),据此确定的第一图像的目标质量参数也较大;当图像中显示的场景较为复杂时,编码所需的码字较多(也就是说编码压力较大),图像的编码质量较低,已编码的图像的平均质量参数也会较低, 据此确定的第一图像的目标质量参数也较小。
可选的,所述编码设备可以通过以下步骤,执行B1:
当第一编码块的质量参数大于第一图像的目标质量参数(也就是说,第一编码块的编码质量高于第一图像的目标质量),且第一编码块的质量参数与第一图像的目标质量参数的差值位于第一范围时,编码设备可确定与第一编码块对应的ΔQP4a等于与第一范围对应的QP偏移值;其中,与第一编码块对应的ΔQP4a为正数。这样,当第一编码块的编码质量高于第一图像的目标质量时,编码设备可以调大第一编码块的QP,从而在满足对第一编码块的质量需求的前提下,可降低第一编码块的码率。
当第一编码块的质量参数小于第一图像的目标质量参数(也就是说,第一编码块的编码质量低于第一图像的目标质量),且第一编码块的质量参数与第一图像的目标质量参数的差值的绝对值位于第二范围时,编码设备可确定与第一编码块对应的ΔQP4a的绝对值等于与第二范围对应的QP偏移值;其中,与第一编码块对应的ΔQP4a为负数。这样,当第一编码块的编码质量低于第一图像的目标质量时,编码设备可以调小第一编码块的QP,从而可提高第一编码块的编码质量。
当第一编码块的质量参数等于第一图像的目标质量参数时,编码设备可确定与第一编码块对应的ΔQP4a为0。
通过该方法,当第一图像中的编码块的编码质量低于第一图像的目标质量时,ΔQP4a为负值;从而可以通过调小QP来提高该编码块的编码质量,使其接近目标质量。当第一图像中的编码块的编码质量高于第一图像的目标质量时,ΔQP4a为正值;从而可通过调大QP来降低该编码块的编码质量,使其接近目标质量。
这样,当目标码率固定(即,固定比特率(constant bit rate,CBR))时,编码设备可以在第一图像内部分配码率,即,调低编码质量超过目标质量的编码块的码率,将节省的码字分配给编码质量低于目标质量的编码块,以便提高编码质量低于目标质量的编码块的码率,从而可以提高第一图像的整体编码质量,使得第一图像的编码质量更加均衡。
当目标码率可变时,该方法可以通过降低编码质量超过目标质量的编码块的质量来降低图像整体需要的码率。
另外,该方法还可用于SHVC、SVC的分层编码(例如,质量分层编码)中。一般情况下,对于分层编码,层数越高,使用的QP越小,编码质量就越好。编码设备可根据编码块上各个层的编码质量是否达到目标质量,来动态调整更高层的QP。例如,当编码块上某一个层的编码质量大于或等于目标质量时,不需要再提高该编码块更高层的目标质量;具体的,在编码更高层对应相同位置的编码块时就不需要再进一步降低QP,可以采用相同的QP或着更大QP,从而达到保证达到目标质量前提下,降低更高层的码率,进而降低整体的码率。
B2:编码设备根据与第一编码块对应的第一QP和与第一编码块对应的ΔQP4a,确定与第一编码块对应的第二QP。
其中,编码设备可包括图1所示的码控模块20。编码设备可以重新从码控模块20获取第一图像的帧级QP(QP_frame1a)和第一编码块的块级ΔQP(即ΔQPa),并据此确定与第一编码块对应的第一QP;也可以直接获取S302中确定的第一QP。然后,编码设备可以确定与第一编码块对应的第二QP为QP_frame1a+ΔQPa+ΔQP4a。
S305:编码设备根据与每个编码块对应的第二QP,对第一图像中至少一个编码块中 每个编码块分别进行编码,得到第二图像数据。
其中,第二图像数据可以为重构数据或重建数据。
可选的,S305可通过以下方式之一来实现:
方式1:编码设备采用图1所示的全部编码过程对上述至少一个编码块中的每个编码块进行编码,输出码流,并得到第二图像数据。具体内容可参考对图1的说明,只是将当前编码块的QP替换为第二QP,此处不再赘述。
方式2:编码设备使用S303中的中间结果对上述至少一个编码块中的每个编码块进行编码,输出码流,并得到第二图像数据。
下面以第三编码块为例对方式2的实现过程进行说明。其中,第三编码块可为上述至少一个编码块中的任一编码块。
在方式2中,编码设备可根据第一信息(即中间结果)以及与第三编码块对应的第二QP,对第三编码块进行编码。
第一信息可包括以下至少一项:步骤S303中确定的第三编码块的预测模式,即根据与第三编码块对应的第一QP对第三编码块进行编码时,确定的第三编码块的预测模式;步骤S303中确定的第三编码块的MV,即根据与第三编码块对应的第一QP对第三编码块进行编码时,确定的第三编码块的MV。
例如,当在S303中,编码设备确定第三编码块的预测模式为帧内预测模式时,在S305中,编码设备可不再判断采用帧内预测模式还是帧间预测模式,直接使用帧内预测模式确定预测数据,进行残差计算,并使用与第三编码块对应的第二QP进行后续的编码操作。
又例如,当在S303中,编码设备确定第三编码块的预测模式为帧间预测模式,并确定出第三编码块对应的MV时,在S305中,编码设备可不再判断采用帧内预测模式还是帧间预测模式,直接使用帧间预测模式和第三编码块对应的MV确定预测数据,进行残差计算,并使用与第三编码块对应的第二QP进行后续的编码操作。
通过该方式2,本次编码可以复用上一次编码的中间结果,从而可以简化编码流程,提高编码效率。
应理解,本申请并不限于对图像进行两次编码,也可以对图像进行多于两次编码(例如,3次、4次,甚至更多次)。当对图像进行多于两次编码时,编码设备可根据上一次编码得到的每个编码块的质量参数,调整本次编码时与上述至少一个编码块中每个编码块分别对应的QP。
应理解,上述方法也可以应用于视频编码。例如,编码设备对视频中的每一帧图像都采用上述方法进行编码,或者,对视频中的关键帧(例如,视频中包含活动物体的图像)采用上述方法进行编码。
通过上述步骤S301-S305,编码设备可以对图像进行至少两次编码,根据上一次编码得到的每个编码块的质量参数,调整每个编码块的QP,再根据调整后的QP对图像进行编码。这样,编码设备可以根据上一次实际编码的质量来调整本次编码的编码参数QP,从而可以保证编码后的图像质量。
可选的,在上述方法的一种实施场景中,在S305之后,该方法还包括:
S306:编码设备保存第二信息。其中,第二信息可用于表示第二图像数据中每个编码块的质量参数。
可选的,第二信息为包含第二图像数据中每个编码块的质量参数的矩阵(也可以称为质量矩阵)。此外,第二信息也可以为其他表现形式,例如,第二图像数据中每个编码块与质量参数的对应关系表。
通过该方法,编码设备在对第一图像进行编码后,可以保存用于表示第二图像数据中每个编码块的质量参数的第二信息;这样,编码设备在对第一图像所在视频中的后续图像进行编码时,可以参考第二信息,从而可以提高后续图像的编码质量。
可选的,在上述方法的一种实施场景中,当第一图像为视频中的第n帧图像时,在S306之后,该方法还可包括:
S307:编码设备获取第二图像。
其中,第二图像可为待编码图像。第二图像可为视频中第n+1帧图像,且包含N个编码块,N为正整数。
编码设备获取第二图像的方式可以参考S301中编码设备获取第一图像的方式,此处不再赘述。
S308:编码设备在第一图像中的上述至少一个编码块中,确定与第二图像中第四编码块关联的至少一个目标编码块。其中,第四编码块可为上述N个编码块中的任一个编码块。
在视频中,一个场景可能会对应多帧图像,这些图像中会存在相似块。这样,第二图像中第四编码块的内容可能包含在第一图像中的至少一个目标编码块中。通过对第一图像和第二图像进行运动估计,编码设备可以确定出第一图像中与第四编码块关联的至少一个目标编码块。
S309:编码设备根据第二信息,确定第二图像数据中上述至少一个目标编码块的质量参数。
例如,当第二信息为包含第二图像数据中每个编码块的质量参数的矩阵时,编码设备可以通过查找质量矩阵,确定出第一图像中上述至少一个目标编码块编码后的质量参数。
又例如,当第二信息为第二图像数据中每个编码块与质量参数的对应关系表时,编码设备可以通过查表的方式,确定出第一图像中上述至少一个目标编码块编码后的质量参数。
S310:编码设备根据上述至少一个目标编码块的质量参数,预测编码后第四编码块的质量参数。
在一些可能的方式中,当第四编码块关联的上述至少一个目标编码块为一个目标编码块时,编码设备可以预测第四编码块的质量参数为该一个目标编码块的质量参数。
在另一些可能的方式中,当第四编码块关联的上述至少一个目标编码块为多个目标编码块时,编码设备可以预测第四编码块的质量参数为该多个目标编码块的质量参数的加权平均值。其中,每个目标编码块的质量参数的权重可以是相同的,也可以是与每个目标编码块包含的第四编码块中的内容所对应的像素值成正比。
S311:编码设备根据预测的编码后第四编码块的质量参数,确定与第四编码块对应的第三QP。
其中,第四编码块的质量参数可包括以下至少一项:PSNR、SSIM、MS-SSIM。
可选的,S311包括C1-C2。
C1:编码设备根据第二图像的目标质量参数和预测的编码后第四编码块的质量参数,确定与第四编码块对应的第二QP偏移值(下面简称为ΔQP4b)。
其中,获取第二图像的目标质量参数的方式可以参考获取第一图像的目标质量参数的方式,此处不再赘述。
可选的,所述编码设备可以通过以下步骤,执行C1:
当第四编码块的质量参数大于第二图像的目标质量参数(也就是说,第四编码块的编码质量高于第二图像的目标质量),且第四编码块的质量参数与第二图像的目标质量参数的差值位于第三范围时,确定与第四编码块对应的ΔQP4b等于与第三范围对应的QP偏移值;其中,与第四编码块对应的ΔQP4b为正数。这样,当第四编码块的编码质量高于第二图像的目标质量时,编码设备可以调大第四编码块的QP,从而在满足对第四编码块的质量需求的前提下,可以降低第四编码块的码率。
当第四编码块的质量参数小于第二图像的目标质量参数(也就是说,第四编码块的编码质量低于第二图像的目标质量),且第四编码块的质量参数与第二图像的目标质量参数的差值的绝对值位于第四范围时,确定与第四编码块对应的ΔQP4b的绝对值等于与第四范围对应的QP偏移值;其中,与第四编码块对应的ΔQP4b为负数。这样,当第四编码块的编码质量低于第二图像的目标质量时,编码设备可以调小第四编码块的QP,从而可以提高第四编码块的编码质量。
当预测的编码后第四编码块的质量参数等于第二图像的目标质量参数时,编码设备可确定与第四编码块对应的ΔQP4b为0。
通过该方法,当第二图像中的编码块的质量低于第二图像的目标质量时,ΔQP4b为负值;从而可以通过调小QP来提高该编码块的编码质量。当第二图像中的编码块的质量高于第一图像的目标质量时,ΔQP4b为正值;从而可通过调大QP来降低该编码块所需的码率,而节约的码率可用于提高第二图像中质量低于第二图像的目标质量的编码块的编码质量;这样,无需提高整体码率,即可提高第二图像的整体编码质量。
C2:编码设备根据与第四编码块对应的第二QP偏移值,确定与第四编码块对应的第三QP。
其中,编码设备可以从码控模块20获取第二图像的帧级QP(QP_frame1b)和第四编码块的块级ΔQP(即ΔQPb)。然后,编码设备可以确定与第四编码块对应的第三QP为QP_frame1b+ΔQPb+ΔQP4b。
S312:编码设备可根据与第四编码块对应的第三QP,对第四编码块进行编码。
编码设备可采用图1所示的全部编码过程对当前编码块进行编码,输出码流,并得到重构图像。具体内容可参考对图1的说明,只是将当前编码块的QP替换为第三QP,此处不再赘述。
可选的,第二图像也可以替换为第n+m帧,其中,m为大于1的整数。
需要说明的是,上述N个编码块可以是第二图像中的所有编码块,也可以是第二图像中的部分编码块。也就是说,编码设备可以对第二图像中的所有编码块采用步骤S308-S312的方法进行编码,也可以对第二图像中的部分编码块采用步骤S308-S312的方法进行编码。当编码设备对第二图像中的部分编码块采用步骤S308-S312的方法进行编码时,对于第二图像中的其他编码块,编码设备可以采用步骤S302-S305的方法进行至少两次编码,也可以仅进行一次编码。
通过上述方法,编码设备可以对视频中的第一图像进行至少两次编码,从而提高第一图像的编码质量。然后,编码设备可根据已提高编码质量的第一图像,对视频中的第二图 像进行一次编码;具体的,编码设备根据已提高编码质量的第一图像中目标编码块的编码质量,预测视频中后续图像中相似编码块的编码质量,并根据预测的编码质量调整QP,从而可提高视频中后续图像中相似编码块的编码质量,进而可提高第二图像的编码质量。
图3所示方法可以应用于编码器性能存在冗余,且需要提升编码器输出图像质量的应用场景中。例如,该方法可应用于以下场景:
应用场景一:手机摄像或视频通话应用场景。
在该场景下,手机实际采集的图像的分辨率为1080P@30帧/秒(frame per second,fps)或720P@30fps。而多数手机中编码器的分辨率至少为4K@30fps。因此,在该场景下,手机可通过本申请的方法,对手机实际采集的图像进行至少两次编码,从而提高编码器输出的图像的整体编码质量。
应用场景二:视频监控场景。
在该场景下,编码设备常使用低码率进行编码,从而导致图像质量不均匀。例如,对于静止的复杂背景区域,编码后该区域的清晰度很高;而对于运动区域以及弱纹理区域,编码后该区域常存在局部模糊、拖尾以及色彩残留等问题。在该场景下,编码设备可采用本申请的方法,通过设置适当的目标质量参数来根据编码后的图像质量对QP进行调整,并根据调整后的QP对图像进行编码,从而可以提高图像的整体编码质量。
下面分别结合图4-图12介绍图3所示的方法的实现方式。其中,图4-图9主要介绍其中的可能的情况一,即编码设备对图像进行至少两次编码,根据上一次编码得到的每个编码块的质量参数,调整相应编码块的QP,再根据调整后的QP对图像进行编码;图10-图12主要介绍其中的可能的情况二,即编码设备对视频中的第一图像进行至少两次编码,并根据第一图像中关联编码块的编码质量,预测视频中第二图像中编码块的QP,对视频中的第二图像进行一次编码。
下面结合图4-图9,介绍上述可能的情况一的实现方式。
如图4所示,编码设备可以包括:第一编码器31、第二编码器32、QP调整模块33和码控模块20。
码控模块20可以为第一编码器31和第二编码器32提供第一图像的帧级QP(即QP_frame1a)和第一图像中当前编码块的块级ΔQP(即ΔQPa)。也就是说,第一编码器31和第二编码器32共用一个码控模块20。这样,第一编码器31和第二编码器32在对第一图像中的每个编码块进行编码时,可采用相同的帧级QP和块级ΔQP。
第一编码器31可为图1所示的编码器10或其它架构的编码器(例如,联合图像专家组(joint photographic experts group,JPEG)图像编码器或H.264/H.265等视频编码器)。第一编码器31可通过执行步骤S301-S303来对第一图像中的每个编码块进行编码,并输出经过量化失真的重构数据。可选的,该重构数据可不写入双倍速率(double data rate,DDR)内存中作为下一帧图像的参考数据。
QP调整模块33可通过执行步骤S304来确定与第一图像中每个编码块对应的QP偏移值(即图3所示方法中的ΔQP4a)。
下面参考图5对QP调整模块33进行说明。如图5所示,QP调整模块33可通过执行D1-D3的操作来确定与第一图像中任一编码块对应的QP偏移值。
D1:QP调整模块33可通过比较第一图像(即原始图像)和第一编码器31输出的重 构数据,来计算通过第一编码器31对第一图像中的第一编码块进行编码后第一编码块的质量参数(也可以称为图像质量的度量指标)T1。其中,第一编码块为第一图像中任一编码块;质量参数可以是PSNR、SSIM、MS-SSIM等客观指标,也可以是其他自定义的各种指标(,比如,编码前后每个编码块频域(例如DCT变换)能量(例如可以用变换系数的绝对值之和来表示)变化幅度)。
D2:QP调整模块33可根据第一编码块的质量参数T1与第一图像的目标质量参数T之间的差异,计算与第一编码块对应的需要调整的编码参数,例如,ΔQP4a。
其中,ΔQP4a可以为正数,也可以为负数。例如,如果质量参数越大越好,当T1大于T时,ΔQP4a为正数;当T1小于T时,ΔQP4a为负数。又例如,如果质量参数越小越好,当T1大于T时,ΔQP4a为负数;当T1小于T时,ΔQP4a为正数。
可选的,QP调整模块33可通过如下代码来确定ΔQP4a。
Figure PCTCN2022138979-appb-000001
其中,Diff为第一编码块的质量参数T1与第一图像的目标质量参数T之间的差异;abs(Diff)为对Diff取绝对值;QualityThr[8]为阈值,用于确定第一编码块的质量参数T1与第一图像的目标质量参数T之间的差异所在的区间。在该代码中,以a1,a2,a3,a4,a4,a6,a7,a8等8个阈值为例进行说明。应理解,在实际使用中,也可以使用其他数量(例如,4、5或6等)的阈值。
D3:QP调整模块33可以将与第一编码块对应的需要调整的编码参数输出至第二编码器32。
可选的,在D2之后,QP调整模块33还可以保存与第一编码块对应的需要调整的编码参数。
第二编码器32可为图1所示的编码器或其它架构的编码器(例如,图像JPEG或H.264/H.265等视频编码器)。第二编码器32可根据码控模块20输出的第一图像的帧级QP(例如,QP_frame1a)和每个编码块的块级QP(例如,ΔQPa),以及QP调整模块33输出的每个编码块的块级QP(例如,ΔQP4a),确定与第一图像中每个编码块分别对应的第二QP为QP_frame1a+ΔQPa+ΔQP4a(具体内容可参考S304),并根据与每个编码块对应的第二QP对第一图像中的每个编码块进行编码,输出最终的视频或图像码流(具体内容可 参考S305)。
其中,第二编码器32对第一图像进行编码时使用的编码块的大小与第一编码器31对第一图像进行编码时使用的编码块的大小相同;两次编码所使用的第一图像的尺寸也相同。这样,根据第一编码器31编码后编码块的编码质量来调整第二编码器32编码时编码块对应的QP,可以有效提高编码块的编码质量。
可选的,当第二编码器32为视频编码器时,第二编码器32还可输出第一图像的重构图像,以便作为视频中下一帧图像的参考图像。具体内容可参考S305,此处不再赘述。
可选的,第一编码器31还可输出对第一图像进行编码的中间结果(例如,图3所示方法中的第一信息)等;这样,第二编码器32可使用这些中间结果对第一图像进行编码(具体可参考S305中的方式2),从而可减少第二编码器32对第一图像进行编码的计算量,进而可以提高编码效率。
其中,第一编码器31和第二编码器32可以是具有相同架构的不同编码器;也可以是同一个编码器;还可以是具有不同架构的编码器(例如,如图7所示)。当第一编码器31和第二编码器32是同一个编码器时,编码设备可通过时分复用的方式调用同一个编码器来对第一图像中的每个编码块进行编码,例如,先调用编码器执行步骤S301-S303,再调用编码器执行步骤S305。
在一些可能的实现方式中,QP调整模块33可以确定与第一图像中每个编码块分别对应的QP,并将与第一图像中每个编码块分别对应的QP输出至第二编码器32;第二编码器32可根据QP调整模块33确定的QP对第一图像中的每个编码块分别进行编码,并输出最终的视频或图像码流(具体内容可参考S305)。图6示出了QP调整模块33确定与第一图像中每个编码块分别对应的QP的方式。如图6所示,在图4的基础上,QP调整模块33在确定与第一图像中每个编码块分别对应的QP偏移值之后,还可以确定与每个编码块分别对应的QP为QP=QP_frame1a+ΔQPa+ΔQP4a(即步骤S304中的第二QP,具体内容可参考步骤S304),并将确定的QP输出至第二编码器32。
通过本实施例,编码设备可以对图像进行至少两次编码。具体的,编码设备在通过第一编码器31对第一图像中的每个编码块进行编码之后,可根据每个编码块的编码质量调整相应编码块对应的编码参数(例如,调整QP),再通过第二编码器32使用调整后的QP来对第一图像中的相应编码块进行编码。这样,编码设备可以根据上一次实际编码的质量来调整本次编码的编码参数QP,从而可以保证编码后的图像质量。
图7示出了图4所示的编码设备的一种可能的结构。下面结合图7进行具体说明。
第一编码器31可包括帧内预测模块102、帧间预测模块104、模式判决及残差计算模块106、变换和量化模块108-1、反量化和反变换模块110-1。
第二编码器32可包括预测编码模块41、滤波模块112、熵编码模块114。
其中,第一编码器31中的各模块可对第一图像中的每个编码块进行编码,得到第一重建数据(即步骤S303中的第一图像数据),并将第一重建数据输出至QP调整模块33。
另外,模式判决及残差计算模块106可将确定的中间结果输出至预测编码模块41和熵编码模块114。其中,中间结果可以包括:预测模式和/或MV。
其中,第一编码器31中的各模块的具体内容可参考对图1和图3的说明,此处不再 赘述。
QP调整模块33可确定与第一图像中每个编码块分别对应的QP,并将确定的与每个编码块分别对应的QP输出至预测编码模块41。QP调整模块33的具体内容可参考对图4-图6的说明,此处不再赘述。
预测编码模块41可使用中间结果和与每个编码块对应的QP,对第一图像中每个编码块分别进行编码,从而将与每个编码块分别对应的量化数据输出至熵编码模块114,并将与每个编码块分别对应的第二重建数据输出至滤波模块112。预测编码模块41的具体内容可参考下文对图8的说明。
滤波模块112可对与每个编码块分别对应的重建数据进行滤波后,得到与第一图像中每个编码块分别对应的重构数据。另外,滤波模块112还可将滤波信息(例如,SAO模式信息及补偿信息等)输出至熵编码模块114。滤波模块112的具体内容可以参考对图1的说明,此处不再赘述。
熵编码模块114可将熵编码方案应用于量化数据、预测数据、SAO模式信息及补偿信息等中的一个或多个上,以获取经编码的码流。熵编码模块114的具体内容可参考对图1的说明,此处不再赘述。
下面结合图8,以第一图像中的第一编码块为例,对预测编码模块41的处理过程进行说明。其中,第一编码块为第一图像中的任一编码块。
如图8所示,预测编码模块41包括:预测单元412,残差计算单元414、变换和量化模块108-2、反量化和反变换模块110-2、数据计算单元416。
其中,预测单元412可使用来自模式判决及残差计算模块106的中间结果对第一编码块进行预测,生成第一编码块的预测数据,并将第一编码块的预测数据输出至残差计算单元414和数据计算单元416。其中,中间结果可包括:预测模式、相邻参考数据以及时域的补偿数据(例如,MV)。预测单元412生成预测数据的方式可参考对帧内预测模块102或帧间预测模块104的说明,此处不再赘述。
残差计算单元414可根据第一图像中第一编码块的原始数据和第一编码块的预测数据,生成第一编码块的残差,并将第一编码块的残差输出至变换和量化模块108-2。残差计算单元414生成第一编码块的残差的具体过程可参考对图1的说明,此处不再赘述。
变换和量化模块108-2可使用来自QP调整模块33的第一编码块的QP对第一编码块的残差进行处理,得到第一编码块的量化数据,并将第一编码块的量化数据输出至熵编码模块114和反量化和反变换模块110-2。变换和量化模块108-2得到量化数据的具体过程可参考对图1的说明,此处不再赘述。
反量化和反变换模块110-2对第一编码块的量化数据进行处理后,得到第一编码块的反变换后的残差(也可称为重构残差),并将第一编码块的重构残差输出至数据计算单元416。反量化和反变换模块110-2得到反变换后的残差的具体过程可参考对图1的说明,此处不再赘述。
数据计算单元416根据第一编码块的预测数据和第一编码块的反变换后的残差,得到第一编码块的重建数据(即图7中的第二重建数据),并将第一编码块的重建数据输出至滤波模块112。其中,重建数据为预测数据和反变换后的残差相加的结果。
应理解,在本实施例中,以对编码块进行编码为例进行说明。该编码设备也可以以更 小的预测粒度进行编码。例如,在一些视频编码标准中,如,H.265或多功能视频编码(versatile video coding,VVC)等标准中,一个块中可能包含多个编码单元,不同编码单元可能采用不同的编码模式,相邻编码单元的编码可能具有一定的空间依赖性。因此,本实施例的编码设备可用于更小的预测编码粒度(例如,CU)。
图9示出了采用图4或图7所示的编码设备进行编码的示意图,如图9所示,第一编码器31使用第一图像的帧级QP和与第一图像中每个编码块对应的块级QP(即ΔQP),对第一图像中的每个编码块分别进行编码后,得到第一图像的第一重构图像(即图3所示方法中的第一图像数据)。第一图像数据中每个编码块的质量参数T1如图9所示。当目标质量参数T为5时,编码设备可根据每个编码块的T1和T之间的差异来分别调整与第一图像中每个编码块对应的QP,例如,编码设备可确定与第一图像中每个编码块分别对应的QP偏移值ΔQP4a;再根据与每个编码块对应的ΔQP4a,确定与第一图像中每个编码块分别对应的QP。第二编码器32可使用与每个编码块对应的QP,对第一图像中每个编码块分别进行编码,得到第一图像的第二重构图像(即图3所示方法中的第二图像数据)。第二图像数据中每个编码块的质量参数T2如图9所示。参见图9可知,相对于第一图像数据中每个编码块的质量参数T1,第二图像数据中每个编码块的质量参数T2与目标质量参数T更为接近,第二图像数据中不同编码块的质量参数之间的差距也较小,质量更为均匀。
通过本实施例,编码设备可以对图像进行至少两次编码,根据上一次编码得到的每个编码块的质量参数,调整与图像中每个编码块分别对应的QP,再根据调整后的QP对图像进行编码。这样,编码设备可以根据上一次实际编码的质量来调整本次编码的编码参数QP,从而可以保证编码后的图像质量。并且,在进行本次编码时,编码设备使用了上一次编码的中间结果,从而简化了本次编码的编码器结构,进而可以有效降低编码设备的性能消耗。
下面结合图10至图12,介绍上述可能的情况二的实现方式。
如图10所示,编码设备可以包括:编码器10和码控模块20。
其中,编码器10可包括:帧内预测模块102、帧间预测模块104、模式判决及残差计算模块106、变换和量化模块108、反量化和反变换模块110、滤波模块112、熵编码模块114、QP计算模块116、重构质量计算模块118。
在本实施例中,对于视频中的部分图像(例如,视频中的第n帧图像,即图3所示方法中的第一图像),编码设备可对图像进行至少两次编码。例如,编码设备通过时分复用的方式至少调用两次编码器10对图像中的每个编码块进行编码,根据上一次编码后图像中编码块的编码质量来调整本次编码时图像中每个编码块分别对应的QP。此时,编码设备可仅调用编码器10中的以下模块对图像进行编码:帧内预测模块102、帧间预测模块104、模式判决及残差计算模块106、变换和量化模块108、反量化和反变换模块110、滤波模块112、熵编码模块114。具体编码过程可以参考对图3-图6的说明,此处不再赘述。
对于视频中的其他图像(例如,视频中的第n+1帧图像,即图3所示方法中的第二图像),编码设备可根据视频中第n帧图像中目标编码块的编码质量,预测视频中后续图像中相似编码块的编码质量,并根据预测的编码质量调整与每个相似编码块对应的QP。下面以待编码的图像为第二图像,参考图像为第一图像为例,对此进行具体说明。
码控模块20可将第二图像的帧级QP(QP_frame1b)和当前编码块的块级ΔQP(ΔQPb)输出至QP计算模块116。其中,当前编码块可为第二图像中的任一编码块。
QP计算模块116可通过执行S308-S311来确定与第二图像中当前编码块对应的QP(即图3所示方法中的第三QP),并将确定的QP输出至帧内预测模块102和帧间预测模块104;然后,编码器10可参考对图1和图3的说明来使用第三QP对第二图像中的当前编码块进行编码。
重构质量计算模块118可根据第二图像以及来自滤波模块112的第二图像的重构图像,确定用于表示第二图像中每个编码块的编码质量的质量矩阵。
下面结合图11说明QP计算模块116确定第二图像中当前编码块对应的QP的过程。如图11所示,QP计算模块116可通过执行E1-E3的操作来确定与第二图像中当前编码块对应的QP。
E1:QP计算模块116根据第一图像和第一图像的质量矩阵,预测第二图像中每个编码块的质量参数T3。
具体的,QP计算模块116可通过运动估计在第一图像中查找与当前编码块最接近的至少一个目标编码块,该至少一个目标编码块也可以称为与当前编码块关联的目标编码块。然后,QP计算模块116可根据第一图像的质量矩阵确定该至少一个目标编码块的质量参数。其中,该质量矩阵可以为二维质量矩阵。QP计算模块116可根据该至少一个目标编码块的质量参数预测当前编码块的质量参数。
其中,当与当前编码块关联的目标编码块可以包括多个目标编码块时,编码设备可以预测当前编码块的质量参数为该多个目标编码块的质量参数的加权平均值。例如,如图12所示,第二图像中的当前编码块为编码块A,第一图像(即参考图像)中与编码块A关联的编码块包括BLK7、BLK8、BLK11和BLK12,即第一图像中与编码块A匹配的块(下面简称为参考块)位于BLK7、BLK8、BLK11和BLK12内。假设BLK7、BLK8、BLK11和BLK12的质量参数分别为Q7、Q8、Q11和Q12,则QP计算模块116可预测编码块A的质量参数为:
QA=w1*Q7+w2*Q8+w3*Q11+w4*Q12;
其中,w1、w2、w3、w4分别为BLK7、BLK8、BLK11、BLK12对应的权重,每个块对应的权重可以为根据参考块在相应块中的像素个数与参考块像素总数的比值。
E2:QP计算模块116根据预测的编码后第二图像中每个编码块的质量参数T3,确定与第二图像中每个编码块对应的QP的QP偏移值(即图3所示方法中的ΔQP4b)。QP计算模块116确定ΔQP4b的方法可以参考QP调整模块33确定ΔQP4a的方法,此处不再赘述。
E3:QP计算模块116根据每个编码块对应的ΔQP4b,确定与第二图像中每个编码块对应的QP为QP=QP_frame1b+ΔQPb+ΔQP4b(即图3所示方法中的第三QP)。
E1-E3的具体内容可参考图3所示的方法,此处不再赘述。
在本实施例中,编码设备可以对视频中的一部分图像进行至少两次编码,对视频中的其他图像进行一次编码。例如,当待编码的视频的帧率为25fps时,编码设备可以在一秒内选择5帧图像进行至少两次编码,对一秒内的其他帧图像进行一次编码。
编码设备可以灵活的选择进行至少两次编码的图像和进行一次编码的图像。可选的,在对视频中的某一帧进行编码前,编码设备可预先判断采用至少两次编码还是采用一次编 码。预先判断的原理为:视频序列中,一个场景(镜头)可以对应连续多帧图像;这些图像的编码结果较为接近;此时,可以利用上一帧图像的编码质量来预测当前帧图像中相似编码块的编码质量。基于该原理,当存在多帧相似图像时,编码设备可以在多帧相似图像中选择部分图像进行两次编码,其他图像进行一次编码。
通过本实施例,编码设备可以对视频中的第一图像进行至少两次编码,从而提高第一图像的编码质量。然后,编码设备可根据已提高编码质量的第一图像,对视频中的第二图像进行一次编码;具体的,编码设备根据已提高编码质量的第一图像中目标编码块的编码质量,预测视频中后续图像中相似编码块的编码质量,并根据预测的编码质量调整与每个相似编码块分别对应的QP,从而可提高视频中后续图像中相似编码块的编码质量,进而可提高第二图像的编码质量。
另外,与图4-9所示的实施例相比,本实施例对编码器的改动较小,且减少了编码器的数量,从而可以简化编码设备的架构。
可选的,编码设备也可对视频中的所有图像采用本实施例中的方法进行一次编码。这样,编码设备根据已编码的图像中目标编码块的编码质量,预测视频中后续图像中相似编码块的编码质量,并根据预测的编码质量调整与每个相似编码块分别对应的QP,从而可提高视频中后续图像中相似编码块的编码质量,进而可提高后续图像的编码质量。
基于与图3至图12所示实施例相同的发明构思,本申请实施例通过图13提供了一种图像编码装置,可用于执行上述实施例中相关步骤的功能。所述功能可以通过硬件实现,也可以通过软件或者硬件执行相应的软件实现。所述硬件或软件包括一个或多个与上述功能相对应的模块。如图13所示,该图像编码装置1300可包括:获取单元1301和处理单元1302。
其中,获取单元1301用于:获取第一图像,所述第一图像中包含至少一个编码块;获取与所述至少一个编码块中每个编码块分别对应的第一量化参数QP;
处理单元1302用于:根据与每个编码块对应的第一QP,对所述至少一个编码块中每个编码块分别进行编码,得到第一图像数据;根据所述第一图像数据中每个编码块的质量参数,确定与每个编码块分别对应的第二QP;根据与每个编码块对应的第二QP,对所述至少一个编码块中每个编码块分别进行编码,得到第二图像数据。
可选的,处理单元1302具体用于:根据所述第一图像的目标质量参数和所述第一图像数据中的第一编码块的质量参数,确定与所述第一编码块对应的第一QP偏移值;其中,所述第一编码块为所述至少一个编码块中的任一个编码块;根据与所述第一编码块对应的第一QP和与所述第一编码块对应的第一QP偏移值,确定与所述第一编码块对应的第二QP。
可选的,处理单元1302具体用于:
当所述第一编码块的质量参数大于所述第一图像的目标质量参数,且所述第一编码块的质量参数与所述第一图像的目标质量参数的差值位于第一范围时,确定与所述第一编码块对应的第一QP偏移值等于与所述第一范围对应的QP偏移值;其中,与所述第一编码块对应的第一QP偏移值为正数;或者
当所述第一编码块的质量参数小于所述第一图像的目标质量参数,且所述第一编码块的质量参数与所述第一图像的目标质量参数的差值的绝对值位于第二范围时,确定与所述 第一编码块对应的第一QP偏移值的绝对值等于与所述第二范围对应的QP偏移值;其中,与所述第一编码块对应的第一QP偏移值为负数;或者
当所述第一编码块的质量参数等于所述第一图像的目标质量参数时,确定与所述第一编码块对应的第一QP偏移值为0。
可选的,处理单元1302具体用于:在根据与每个编码块对应的第一QP,对所述至少一个编码块中每个编码块分别进行编码之后,比较所述第一图像数据和所述第一图像,得到所述第一图像数据中每个编码块的质量参数。
可选的,处理单元1302具体用于:根据与第二编码块对应的第一QP,对所述第二编码块进行量化处理,得到量化数据;其中,所述第二编码块为所述至少一个编码块中的任一编码块;根据与所述第二编码块对应的第一QP,对所述量化数据进行反量化和反变换处理,得到反变换后的残差数据;根据所述第二编码块的预测数据和残差数据,得到所述第二编码块的重建数据;对所述重建数据进行滤波,得到所述第一图像数据中与所述第二编码块对应的图像数据。
可选的,处理单元1302具体用于:根据第一信息以及与第三编码块对应的第二QP,对所述第三编码块进行编码;其中,所述第三编码块为所述至少一个编码块中的任一编码块;其中,所述第一信息包括以下至少一项:根据与所述第三编码块对应的第一QP对所述第三编码块进行编码时,确定的所述第三编码块的预测模式;根据与所述第三编码块对应的第一QP对所述第三编码块进行编码时,确定的所述第三编码块的运动矢量。
可选的,处理单元1302具体用于:在根据与每个编码块对应的第二QP,对所述至少一个编码块中每个编码块分别进行编码之后,保存第二信息;其中,所述第二信息用于表示所述第二图像数据中每个编码块的质量参数。
可选的,所述第二信息为包含所述第二图像数据中每个编码块的质量参数的矩阵。
可选的,获取单元1301具体用于:当所述第一图像为视频中的第n帧图像时,在保存第二信息之后,获取第二图像;其中,所述第二图像为所述视频中第n+1帧图像,所述第二图像中包含N个编码块,N为正整数;处理单元1302具体用于:在所述至少一个编码块中,确定与所述第二图像中第四编码块关联的至少一个目标编码块;其中,所述第四编码块为所述N个编码块中的任一个编码块,所述第四编码块中的内容包含在所述至少一个目标编码块中;根据所述第二信息,确定所述第二图像数据中所述至少一个目标编码块的质量参数;根据所述至少一个目标编码块的质量参数,预测编码后所述第四编码块的质量参数;根据预测的编码后所述第四编码块的质量参数,确定与所述第四编码块对应的第三QP;根据与所述第四编码块对应的第三QP,对所述第四编码块进行编码,其中,n为正整数。
可选的,处理单元1302具体用于:根据所述第二图像的目标质量参数和预测的编码后所述第四编码块的质量参数,确定与所述第四编码块对应的第二QP偏移值;根据与所述第四编码块对应的第二QP偏移值,确定与所述第四编码块对应的第三QP。
可选的,处理单元1302具体用于:
当所述第四编码块的质量参数大于所述第二图像的目标质量参数,且所述第四编码块的质量参数与所述第二图像的目标质量参数的差值位于第三范围时,确定与所述第四编码块对应的第二QP偏移值等于与所述第三范围对应的QP偏移值;其中,与所述第四编码块对应的第二QP偏移值为正数;或者
当所述第四编码块的质量参数小于所述第二图像的目标质量参数,且所述第四编码块的质量参数与所述第二图像的目标质量参数的差值的绝对值位于第四范围时,确定与所述第四编码块对应的第二QP偏移值的绝对值等于与所述第四范围对应的QP偏移值;其中,与所述第四编码块对应的第二QP偏移值为负数;或者
当预测的编码后所述第四编码块的质量参数等于所述第二图像的目标质量参数时,确定与第四编码块对应的第二QP偏移值为0。
可选的,任一编码块的质量参数包括以下至少一项:
峰值信噪比、结构相似度、多尺度结构相似度。
图14是本申请实施例的图像编码设备1400的示意性框图。应理解,所述图像编码设备1400能够执行上述图3至图12所示实施例中由编码设备执行的各个步骤。图像编码设备1400包括:处理器1401以及耦合至处理器1401的存储器1402。存储器1402可用于存储程序代码;处理器1401可调用所述存储器中存储的程序代码,以执行上述图像编码方法。
其中,所述处理器1401可以是为中央处理单元(central processing unit,CPU),还可以是其它通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现场可编程门阵列(field programmable gate array,FPGA)或者其它可编程逻辑器件、晶体管逻辑器件,硬件部件或者其任意组合。通用处理器可以是微处理器,也可以是任何常规的处理器。
存储器1401可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是RAM,其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DR RAM)。应注意,本文描述的系统和方法的存储器旨在包括但不限于这些和任意其它适合类型的存储器。
可选的,处理器1401以及存储器1402之间可通过总线1403相互连接。总线1403可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。总线1403可以分为地址总线、数据总线、控制总线等。为便于表示,图14中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
基于以上实施例,本申请实施例还提供了一种计算机程序,当所述计算机程序在计算机上运行时,使得所述计算机执行以上实施例提供的方法。
基于以上实施例,本申请实施例还提供了一种计算机可读存储介质,该计算机可读存 储介质中存储有计算机程序,所述计算机程序被计算机执行时,使得计算机执行以上实施例提供的方法。
其中,存储介质可以是计算机能够存取的任何可用介质。以此为例但不限于:计算机可读介质可以包括RAM、ROM、EEPROM或其他光盘存储、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质。
基于以上实施例,本申请实施例还提供了一种芯片,所述芯片用于读取存储器中存储的计算机程序,实现以上实施例提供的方法。
基于以上实施例,本申请实施例提供了一种芯片系统,该芯片系统包括处理器,用于支持计算机装置实现以上实施例中各设备所涉及的功能。在一种可能的设计中,所述芯片系统还包括存储器,所述存储器用于保存该计算机装置必要的程序和数据。该芯片系统,可以由芯片构成,也可以包含芯片和其他分立器件。
综上所述,本申请实施例提供了一种图像编码方法、装置及设备,在该方法中,编码设备在获取到第一图像之后,可以获取与第一图像中至少一个编码块中每个编码块分别对应的第一QP;然后,根据与每个编码块对应的第一QP,对该至少一个编码块中每个编码块分别进行编码,得到第一图像数据。编码设备可根据第一图像数据中每个编码块的质量参数,确定与每个编码块分别对应的第二QP;并根据与每个编码块对应的第二QP,对该至少一个编码块中每个编码块分别进行编码,得到第二图像数据。通过该方法,编码设备可以根据上一次实际编码的质量来调整本次编码的编码参数QP,从而可以保证编码后图像的质量。
在本申请的各个实施例中,如果没有特殊说明以及逻辑冲突,不同的实施例之间的术语和/或描述具有一致性、且可以相互引用,不同的实施例中的技术特征根据其内在的逻辑关系可以组合形成新的实施例。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他 可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (15)

  1. 一种图像编码方法,其特征在于,包括:
    获取第一图像,所述第一图像中包含至少一个编码块;
    获取与所述至少一个编码块中每个编码块分别对应的第一量化参数QP;
    根据与每个编码块对应的第一QP,对所述至少一个编码块中每个编码块分别进行编码,得到第一图像数据;
    根据所述第一图像数据中每个编码块的质量参数,确定与每个编码块分别对应的第二QP;
    根据与每个编码块对应的第二QP,对所述至少一个编码块中每个编码块分别进行编码,得到第二图像数据。
  2. 如权利要求1所述的方法,其特征在于,根据所述第一图像数据中每个编码块的质量参数,确定与每个编码块分别对应的第二QP,包括:
    根据所述第一图像的目标质量参数和所述第一图像数据中的第一编码块的质量参数,确定与所述第一编码块对应的第一QP偏移值;其中,所述第一编码块为所述至少一个编码块中的任一个编码块;
    根据与所述第一编码块对应的第一QP和与所述第一编码块对应的第一QP偏移值,确定与所述第一编码块对应的第二QP。
  3. 如权利要求2所述的方法,其特征在于,根据所述第一图像的目标质量参数和所述第一图像数据中第一编码块的质量参数,确定与所述第一编码块对应的第一QP偏移值,包括:
    当所述第一编码块的质量参数大于所述第一图像的目标质量参数,且所述第一编码块的质量参数与所述第一图像的目标质量参数的差值位于第一范围时,确定与所述第一编码块对应的第一QP偏移值等于与所述第一范围对应的QP偏移值;其中,与所述第一编码块对应的第一QP偏移值为正数;或者
    当所述第一编码块的质量参数小于所述第一图像的目标质量参数,且所述第一编码块的质量参数与所述第一图像的目标质量参数的差值的绝对值位于第二范围时,确定与所述第一编码块对应的第一QP偏移值的绝对值等于与所述第二范围对应的QP偏移值;其中,与所述第一编码块对应的第一QP偏移值为负数;或者
    当所述第一编码块的质量参数等于所述第一图像的目标质量参数时,确定与所述第一编码块对应的第一QP偏移值为0。
  4. 如权利要求1至3任一项所述的方法,其特征在于,根据与每个编码块对应的第一QP,对所述至少一个编码块中每个编码块分别进行编码之后,所述方法还包括:
    比较所述第一图像数据和所述第一图像,得到所述第一图像数据中每个编码块的质量参数。
  5. 如权利要求1至4任一项所述的方法,其特征在于,根据与每个编码块对应的第一QP,对所述至少一个编码块中每个编码块分别进行编码,得到第一图像数据,包括:
    根据与第二编码块对应的第一QP,对所述第二编码块进行量化处理,得到量化数据;其中,所述第二编码块为所述至少一个编码块中的任一编码块;
    根据与所述第二编码块对应的第一QP,对所述量化数据进行反量化和反变换处理, 得到反变换后的残差数据;
    根据所述第二编码块的预测数据和残差数据,得到所述第二编码块的重建数据;
    对所述重建数据进行滤波,得到所述第一图像数据中与所述第二编码块对应的图像数据。
  6. 如权利要求1至5任一项所述的方法,其特征在于,根据与每个编码块对应的第二QP,对所述至少一个编码块中每个编码块分别进行编码,包括:
    根据第一信息以及与第三编码块对应的第二QP,对所述第三编码块进行编码;其中,所述第三编码块为所述至少一个编码块中的任一编码块;
    其中,所述第一信息包括以下至少一项:
    根据与所述第三编码块对应的第一QP对所述第三编码块进行编码时,确定的所述第三编码块的预测模式;
    根据与所述第三编码块对应的第一QP对所述第三编码块进行编码时,确定的所述第三编码块的运动矢量。
  7. 如权利要求1至6任一项所述的方法,其特征在于,在根据与每个编码块对应的第二QP,对所述至少一个编码块中每个编码块分别进行编码之后,所述方法还包括:
    保存第二信息;其中,所述第二信息用于表示所述第二图像数据中每个编码块的质量参数。
  8. 如权利要求7所述的方法,其特征在于,所述第二信息为包含所述第二图像数据中每个编码块的质量参数的矩阵。
  9. 如权利要求7或8所述的方法,其特征在于,所述第一图像为视频中的第n帧图像,其中,n为正整数;在保存第二信息之后,所述方法还包括:
    获取第二图像;其中,所述第二图像为所述视频中第n+1帧图像,所述第二图像中包含N个编码块,N为正整数;
    在所述至少一个编码块中,确定与所述第二图像中第四编码块关联的至少一个目标编码块;其中,所述第四编码块为所述N个编码块中的任一个编码块,所述第四编码块中的内容包含在所述至少一个目标编码块中;
    根据所述第二信息,确定所述第二图像数据中所述至少一个目标编码块的质量参数;
    根据所述至少一个目标编码块的质量参数,预测编码后所述第四编码块的质量参数;
    根据预测的编码后所述第四编码块的质量参数,确定与所述第四编码块对应的第三QP;
    根据与所述第四编码块对应的第三QP,对所述第四编码块进行编码。
  10. 如权利要求9所述的方法,其特征在于,根据预测的编码后所述第四编码块的质量参数,确定与所述第四编码块对应的第三QP,包括:
    根据所述第二图像的目标质量参数和预测的编码后所述第四编码块的质量参数,确定与所述第四编码块对应的第二QP偏移值;
    根据与所述第四编码块对应的第二QP偏移值,确定与所述第四编码块对应的第三QP。
  11. 如权利要求10所述的方法,其特征在于,根据所述第二图像的目标质量参数和预测的编码后所述第四编码块的质量参数,确定与所述第四编码块对应的第二QP偏移值,包括:
    当所述第四编码块的质量参数大于所述第二图像的目标质量参数,且所述第四编码块的质量参数与所述第二图像的目标质量参数的差值位于第三范围时,确定与所述第四编码 块对应的第二QP偏移值等于与所述第三范围对应的QP偏移值;其中,与所述第四编码块对应的第二QP偏移值为正数;或者
    当所述第四编码块的质量参数小于所述第二图像的目标质量参数,且所述第四编码块的质量参数与所述第二图像的目标质量参数的差值的绝对值位于第四范围时,确定与所述第四编码块对应的第二QP偏移值的绝对值等于与所述第四范围对应的QP偏移值;其中,与所述第四编码块对应的第二QP偏移值为负数;或者
    当预测的编码后所述第四编码块的质量参数等于所述第二图像的目标质量参数时,确定与第四编码块对应的第二QP偏移值为0。
  12. 如权利要求1至11任一项所述的方法,其特征在于,任一编码块的质量参数包括以下至少一项:
    峰值信噪比、结构相似度、多尺度结构相似度。
  13. 一种图像编码设备,其特征在于,包括:处理器以及耦合至所述处理器的存储器,所述处理器调用存储在所述存储器中的程序代码以执行如权利要求1-12任一项所述的方法。
  14. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,当所述计算机程序在计算机上运行时,使得所述计算机执行权利要求1-12任一项所述的方法。
  15. 一种芯片,其特征在于,所述芯片与存储器耦合,所述芯片读取所述存储器中存储的计算机程序,执行权利要求1-12任一项所述的方法。
PCT/CN2022/138979 2022-03-15 2022-12-14 一种图像编码方法、装置及设备 WO2023173852A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210255919.XA CN116800967A (zh) 2022-03-15 2022-03-15 一种图像编码方法、装置及设备
CN202210255919.X 2022-03-15

Publications (1)

Publication Number Publication Date
WO2023173852A1 true WO2023173852A1 (zh) 2023-09-21

Family

ID=88022154

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/138979 WO2023173852A1 (zh) 2022-03-15 2022-12-14 一种图像编码方法、装置及设备

Country Status (2)

Country Link
CN (1) CN116800967A (zh)
WO (1) WO2023173852A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080260042A1 (en) * 2007-04-23 2008-10-23 Qualcomm Incorporated Methods and systems for quality controlled encoding
CN108574841A (zh) * 2017-03-07 2018-09-25 北京金山云网络技术有限公司 一种基于自适应量化参数的编码方法及装置
CN108769693A (zh) * 2011-06-10 2018-11-06 茨特里克斯系统公司 质量感知视频优化中的宏块级自适应量化
US20210120230A1 (en) * 2018-07-25 2021-04-22 SZ DJI Technology Co., Ltd. Image encoding control method and apparatus, storage medium, and unmanned aerial vehicle

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080260042A1 (en) * 2007-04-23 2008-10-23 Qualcomm Incorporated Methods and systems for quality controlled encoding
CN108769693A (zh) * 2011-06-10 2018-11-06 茨特里克斯系统公司 质量感知视频优化中的宏块级自适应量化
CN108574841A (zh) * 2017-03-07 2018-09-25 北京金山云网络技术有限公司 一种基于自适应量化参数的编码方法及装置
US20210120230A1 (en) * 2018-07-25 2021-04-22 SZ DJI Technology Co., Ltd. Image encoding control method and apparatus, storage medium, and unmanned aerial vehicle

Also Published As

Publication number Publication date
CN116800967A (zh) 2023-09-22

Similar Documents

Publication Publication Date Title
US11528506B2 (en) Intra-prediction using a cross-component linear model in video coding
KR0183688B1 (ko) 영상부호화방법 및 장치
TWI669955B (zh) 視訊解碼/編碼裝置與方法、儲存位元串流的記錄媒體
TW202044834A (zh) 用於處理視訊內容的方法及系統
TWI682661B (zh) 在計算設備中實現的方法
KR20210141772A (ko) 다중 레퍼런스 라인을 이용한 인트라 예측
JP2023103292A (ja) エンコーダ、デコーダ、および対応するイントラ予測方法
EP1797722A1 (en) Adaptive overlapped block matching for accurate motion compensation
CN103782598A (zh) 用于无损编码的快速编码方法
JP2021523590A (ja) ルマおよびクロマブロックパーティショニング
JP2007049680A (ja) イメージ圧縮デバイス及びその方法
US9641847B2 (en) Method and device for classifying samples of an image
US11343501B2 (en) Video transcoding method and device, and storage medium
CN114402620A (zh) 用于视频编解码的交叉分量自适应环路滤波的比特移位
CN115836525A (zh) 用于从多个交叉分量进行预测的方法和系统
JP7247349B2 (ja) イントラ予測のための成分間線形モデリングの方法、装置、デコーダ、エンコーダ、およびプログラム
US20110249959A1 (en) Video storing method and device based on variable bit allocation and related video encoding and decoding apparatuses
WO2023173852A1 (zh) 一种图像编码方法、装置及设备
CN110650337B (zh) 一种图像编码方法、解码方法、编码器、解码器及存储介质
KR20020026189A (ko) 고정된 비율 압축을 이용하는 효율적인 비디오 데이터엑세스
CN116156168A (zh) 一种图像编解码方法及装置
CN115550666A (zh) 用于视频数据的编码方法、解码方法、计算设备和介质
KR102543449B1 (ko) 이미지 처리 장치 및 이미지 처리 장치의 동작 방법
US20180367806A1 (en) Video encoding apparatus and video decoding apparatus
JP7068925B2 (ja) 予測符号化法決定装置、動画像符号化装置、及び動画像復号装置、並びにプログラム

Legal Events

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

Ref document number: 22931860

Country of ref document: EP

Kind code of ref document: A1