WO2023070403A1 - 编码方法、装置、电子设备和计算机可读介质 - Google Patents

编码方法、装置、电子设备和计算机可读介质 Download PDF

Info

Publication number
WO2023070403A1
WO2023070403A1 PCT/CN2021/126836 CN2021126836W WO2023070403A1 WO 2023070403 A1 WO2023070403 A1 WO 2023070403A1 CN 2021126836 W CN2021126836 W CN 2021126836W WO 2023070403 A1 WO2023070403 A1 WO 2023070403A1
Authority
WO
WIPO (PCT)
Prior art keywords
coding
unit
optimal
coding unit
transformation
Prior art date
Application number
PCT/CN2021/126836
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 深圳市大疆创新科技有限公司
Priority to PCT/CN2021/126836 priority Critical patent/WO2023070403A1/zh
Priority to CN202180102578.6A priority patent/CN117981304A/zh
Publication of WO2023070403A1 publication Critical patent/WO2023070403A1/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/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/119Adaptive subdivision aspects, e.g. subdivision of a picture into rectangular or non-rectangular coding blocks
    • 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/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/12Selection from among a plurality of transforms or standards, e.g. selection between discrete cosine transform [DCT] and sub-band transform or selection between H.263 and H.264
    • H04N19/122Selection of transform size, e.g. 8x8 or 2x4x8 DCT; Selection of sub-band transforms of varying structure or type
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/50Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding
    • H04N19/503Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using predictive coding involving temporal prediction
    • H04N19/51Motion estimation or motion compensation
    • H04N19/57Motion estimation characterised by a search window with variable size or shape

Definitions

  • the embodiments of the present application relate to the field of computer technology, and specifically relate to an encoding method, device, electronic equipment, and computer-readable medium.
  • a video is a continuous image sequence consisting of consecutive frames, and a frame is an image. Due to the high similarity between consecutive frames, in order to facilitate storage and transmission, the original video needs to be encoded and compressed to remove redundancy in space and time dimensions.
  • the video coding process needs to go through stages such as prediction, transform, quantization, and entropy coding.
  • the video frame needs to be divided into coding tree units (Coding Tree Unit, CTU), and the coding tree units are divided into coding units (Coding Unit, CU) for prediction.
  • the coding unit needs to be further divided into transformation units (Transform Unit, TU) for transformation and quantization.
  • the disadvantage of the existing technology is that due to the various ways of dividing the coding unit and the transformation unit, it is necessary to traverse all the combinations when determining the optimal coding unit and the optimal transformation unit, resulting in high computational complexity and low decision-making efficiency.
  • the embodiment of the present application proposes an encoding method, device, electronic equipment, and computer-readable medium to solve the technical problems of high computational complexity and low decision-making efficiency in the process of determining the optimal CU and optimal TU in the prior art .
  • the embodiment of the present application provides an encoding method, including: determining the optimal coding unit of the coding tree unit through motion search; determining the optimal transformation unit of the optimal coding unit; based on the optimal transformation unit Encode the optimal coding unit.
  • an embodiment of the present application provides a coding device, including: a first determining unit configured to determine an optimal coding unit of a coding tree unit through motion search; a second determining unit configured to determine the optimal coding unit An optimal TU of an optimal CU; a coding unit configured to encode the optimal CU based on the optimal TU.
  • the embodiment of the present application provides an electronic device, including: a processor and a memory; the memory is used to store program instructions; the processor is used to execute the program instructions stored in the memory, and when the program instructions are executed, the processing
  • the device is configured to perform the following steps: determine an optimal coding unit of a coding tree unit through motion search; determine an optimal transformation unit of the optimal coding unit; and encode the optimal coding unit based on the optimal transformation unit.
  • the embodiment of the present application provides a computer-readable medium on which a computer program is stored, and when the program is executed by a processor, the above encoding method is implemented.
  • the encoding method, device, electronic equipment, and computer-readable medium provided by the embodiments of the present application reduce the computational complexity in the process of deciding the optimal encoding unit and the optimal transformation unit, and improve the decision-making efficiency.
  • FIG. 1 is a schematic diagram of a video encoding process
  • Fig. 2 is a schematic diagram of a pipeline stage of an encoder
  • Fig. 3 is a flowchart of an embodiment of the encoding method of the present application.
  • FIG. 4 is a flowchart of a method for determining an optimal coding unit of the present application
  • FIG. 5 is a schematic diagram of the division method of coding tree units into coding units in the present application.
  • FIG. 6 is a schematic diagram of dividing coding tree units into optimal transformation units in the present application.
  • FIG. 7 is a flow chart of another optimal coding unit determination method of the present application.
  • FIG. 8 is a flowchart of a method for determining an optimal transformation unit of the present application.
  • FIG. 9 is a flow chart of another method for determining an optimal transformation unit of the present application.
  • FIG. 10 is a schematic structural diagram of an embodiment of an encoding device according to the present application.
  • Fig. 11 is a schematic structural diagram of an embodiment of an electronic device according to the present application.
  • the so-called video encoding method refers to the method of converting the original video format file into another video format file through compression technology.
  • the traditional video encoding process after receiving a video frame to be encoded, the traditional video encoding process usually includes processes such as prediction, transformation, quantization, and entropy encoding, and finally outputs a video code stream.
  • the decoding end usually decodes the received code stream according to the reverse process of the above process, so as to restore the video information before encoding.
  • the prediction, transformation, quantization and entropy coding processes are introduced respectively below.
  • Video data has a strong correlation, so there is a lot of redundant information.
  • the redundant information can be divided into air domain redundant information and time domain redundant information.
  • the purpose of prediction is to use the predicted image block data to reduce redundant information of the current image block to be encoded, that is, to remove the correlation between data.
  • Prediction generally includes two types of intra prediction and inter prediction.
  • the intra-frame prediction is to use the encoded image block in the same video frame to predict the current image block to be encoded, so as to reduce redundant information.
  • Inter-frame prediction is to predict the current image block to be encoded by using the image block that has been encoded in the previous frame or multiple frames, so as to reduce redundant information in the time domain.
  • the processing process of the prediction stage specifically includes the following steps:
  • the current image to be encoded is divided into several image blocks to be encoded.
  • the image block to be coded is further divided into several sub-image blocks.
  • the entire image block to be encoded may also be directly used as a sub-image block.
  • the coding tree unit can be further divided into coding units (Coding Unit, CU). If the size of the coding tree unit is 64 ⁇ 64, the size of the coding unit into which it can be generally divided may include 64 ⁇ 64, 32 ⁇ 32, 16 ⁇ 16, 8 ⁇ 8 and so on.
  • prediction is performed for each sub-image block.
  • one of intra-frame prediction and inter-frame prediction can be selected for prediction.
  • the sub-image block may be predicted using an encoded image block in the same video frame to obtain a predicted image block.
  • the image block that best matches the current sub-image block can be searched in the reference image (such as the previous frame image) as the predicted image block. At this time, the relative displacement between the predicted image block and the current sub-image block is the motion vector.
  • the sub-image block is subtracted from the pixel value of the predicted image block to obtain a residual block corresponding to the sub-image block.
  • the residual block of the image block to be encoded can be obtained, thereby completing the prediction process.
  • transformation After the prediction process is performed, processes such as transformation, quantization, and entropy coding need to be performed in sequence.
  • This process requires further division of sub-image blocks (such as coding units) to obtain smaller blocks, such as transform units (Transform Unit, TU).
  • the sub-image blocks may not be divided, and in this case, the size of the transformation unit is also equal to the size of the coding unit.
  • the transformation unit is the smallest unit of the change and quantization process. For example, if the size of the coding unit is 32 ⁇ 32, the size of the transformation unit may include 32 ⁇ 32, 16 ⁇ 16, or 8 ⁇ 8.
  • the transform operation is used to convert the residual block obtained in the prediction process from the time domain to the frequency domain.
  • the transformation method may include discrete cosine transform (discrete cosine transform, DCT), discrete wavelet transform (discrete wavelet transform, DWT), etc. After transforming the residual block, a transformation coefficient matrix can be obtained.
  • the quantization operation is used to reduce the coefficient of variation obtained after transformation, thereby facilitating entropy coding.
  • Entropy coding that is, coding that does not lose any information according to the principle of entropy during the coding process.
  • Common entropy coding includes: Shannon coding, Huffman coding and arithmetic coding (arithmetic coding).
  • an entropy coded bit stream can be obtained.
  • the video encoding process can be completed by storing or sending the entropy encoded bit stream and related information (such as mode information, motion vector, etc.) to the decoding end.
  • the residual block (which can be called the reconstructed residual block) can also be restored by inverse quantization and inverse transformation, and then the reconstructed residual block is added to the predicted image block to obtain the reconstructed image block, and finally perform in-loop filtering on the reconstructed image block to obtain the final reconstructed image, so as to provide the subsequent encoded image for inter-frame prediction.
  • the in-loop filtering may include but not limited to deblocking filtering, pixel adaptive offset (Sample adaptive offset, SAO) and the like.
  • the encoding of the video can be completed.
  • entropy decoding can be performed on the obtained entropy coded bit stream to obtain the corresponding residual block, and then the predicted image block corresponding to the image block to be decoded can be found according to the information such as the motion vector obtained by decoding, and finally according to the predicted image block
  • the value of each pixel in the image block to be decoded is obtained by summing the residual, so as to realize video decoding.
  • Figure 2 is a schematic diagram of the pipeline stages of an encoder.
  • the pipeline level is divided into 5 levels, which are integer pixel search, sub-pixel search, intra prediction, mode decision, entropy coding and filtering.
  • the N+2th image block is performing integer pixel search
  • the N+1th image block is performing sub-pixel searching
  • the Nth image block is performing intra-frame prediction.
  • FIG. 2 is only a schematic illustration. In fact, more image blocks (such as 5 blocks) can be processed in parallel at the same time, and other division methods can also be used to set the pipeline level.
  • the optimal coding unit and the optimal transformation unit are generally determined by traversing all combinations of the coding unit and the transformation unit. Since both the coding unit and the transformation unit have multiple partitioning methods, this process leads to high computational complexity, low decision-making efficiency, and high complexity of the further encoder. Therefore, it is urgent to find a method that can reduce the computational complexity, thereby improving the decision-making efficiency and reducing the complexity of the encoder.
  • FIG. 3 shows a flow chart of the encoding method according to the present application.
  • the subject of execution of the encoding method may be various electronic devices capable of video encoding. Examples include cell phones, tablets, laptops, desktops, servers, etc.
  • the flow of the encoding method includes the following steps:
  • Step 301 determine the optimal coding unit of the coding tree unit through motion search.
  • the determining the optimal coding unit of the coding tree unit through motion search includes: respectively dividing the coding tree unit into coding units according to different scales to obtain a coding unit set; from the coding unit set Selecting some coding units, and determining the coding costs of the selected coding units through motion search; based on the determined coding costs of the coding units, selecting the optimal coding unit of the coding tree unit.
  • the determining the optimal coding unit of the coding tree unit through motion search includes: dividing the coding tree unit into coding units according to different scales; determining the coding cost of each coding unit after the division through motion search; based on the determined coding The coding cost of the unit is used to select the optimal coding unit of the coding tree unit.
  • the motion search includes integer pixel search and/or sub-pixel search. It should be noted that, before the optimal coding unit of the coding tree unit is determined through motion search, the video frame to be coded may be obtained, and the video frame is divided into coding tree units according to a preset size.
  • an optimal coding unit of a coding tree unit may be determined through an integer pixel search.
  • the subject of the encoding method can determine the optimal coding unit for determining the coding tree unit through motion search (for example, integer pixel search and/or sub-pixel search).
  • the coding tree unit may be obtained in advance by obtaining a video frame to be coded and dividing the above video frame into coding tree units according to a preset size (such as 64 ⁇ 64).
  • Integer pixel search can also be called integer pixel motion estimation, which is a motion estimation method and an important part of a video compression processing system. Since there is a certain correlation between the scene in the current image to be coded and the scene in the adjacent frame, the best matching position of each image block in the current image to be coded in the adjacent frame can be searched out, and the two The relative offset between the spatial positions (that is, the motion vector), this process is called motion estimation. The image block corresponding to the best matching position is the predicted image block.
  • the motion estimation using the integer pixel position as the search position is integer pixel search.
  • the executive body may first divide the coding tree unit into coding units according to different scales, and then perform integer pixel search on some or all of the coding units, and then perform the integer pixel search based on the integer pixel search results.
  • the obtained predicted image block can determine the coding cost of the corresponding coding unit.
  • the coding cost can be used to evaluate the quality of the coding unit. The smaller the coding cost, the better the coding unit, and the better the coding effect of coding using this coding unit. Therefore, the coding unit division method that minimizes the coding cost can be selected.
  • the coding unit division method at this time is the optimal coding unit division method, and the coding tree unit is divided according to this division method to obtain the optimal coding unit.
  • sub-pixel search may also be performed after performing integer-pixel search.
  • Sub-pixel search may also be called sub-pixel motion estimation, sub-pixel search, or sub-pixel motion estimation.
  • the best matching position of the current block to be encoded found by the integer pixel search is the integer pixel position.
  • the whole pixel search can be used to interpolate the best matching position in the neighborhood, such as interpolating 1/2 pixel points, so as to select the optimal 1/2 pixel point as the new best matching position .
  • 1/4 sub-pixel search and 1/8 sub-pixel search can also be continued.
  • the final optimal matching position and the position offset between the current block to be encoded is the final optimal motion vector. Performing pixel-by-pixel search after the whole-pixel search can improve the accuracy of motion search, thereby improving the performance of encoding.
  • the sub-pixel search process usually does not affect the division method of the optimal coding unit determined in the whole-pixel search process. That is to say, the optimal coding unit of the coding tree unit is only determined during the integer pixel search process. At the same time, the decision-making of the optimal coding unit is performed in the whole-pixel search stage without considering the sub-pixel search process, which can improve the decision-making speed of the optimal coding unit compared with the sub-pixel search stage. In addition, the scheme of determining the optimal coding unit of the coding tree unit during the integer pixel search can reduce the number of sub-pixel searches.
  • the optimal coding unit of the coding tree unit may be determined by sub-pixel searching.
  • the subject of execution of the encoding method may determine the optimal coding unit of the coding tree unit through pixel-by-pixel search.
  • the coding tree unit may be obtained in advance by obtaining a video frame to be coded and dividing the above video frame into coding tree units according to a preset size (such as 64 ⁇ 64).
  • Sub-pixel search can also be called sub-pixel motion estimation, which is also a motion estimation method and an important part of a video compression processing system. simply put.
  • the motion estimation with sub-pixel position as the search position is called sub-pixel search.
  • the optimal coding unit for the coding tree unit can be determined according to the above-mentioned method when performing the integer pixel search; The optimal coding unit for .
  • the above-mentioned executive body can first further divide the optimal coding unit according to different scales, and divide the optimal coding unit into A sub-coding unit with respect to a better coding unit. Further, a pixel-by-pixel search is performed on some sub-coding units or all sub-coding units, and then the coding cost of the corresponding coding unit can be determined based on the predicted image block obtained from the pixel-by-pixel search result. The coding cost can be used to evaluate the pros and cons of the sub-coding unit. The smaller the coding cost, the better the sub-coding unit, and the better the coding effect of coding using this sub-coding unit.
  • the sub-coding unit division manner that minimizes the encoding cost can be selected.
  • the way of dividing the sub-coding units at this time is the optimal way of dividing the coding units.
  • the coding performance can be improved by obtaining a better coding unit in the integer pixel search stage and obtaining the optimal coding unit in the sub-pixel search stage.
  • the integer pixel search is only performed on the basis of coding units of all sizes or partial sizes. Then, the sub-pixel search is further performed in the coding unit corresponding to these sizes in the sub-pixel search stage. Afterwards, based on the predicted image block obtained from the sub-pixel search result, the coding cost of the corresponding coding unit can be determined.
  • the coding cost can be used to evaluate the quality of the coding unit. The smaller the coding cost, the better the coding unit, and the better the coding effect of coding using this coding unit. Therefore, the coding unit division method that minimizes the coding cost can be selected.
  • the coding unit division manner at this time is the optimal coding unit division manner.
  • an optimal coding unit can be obtained.
  • the coding performance can also be improved by obtaining the optimal coding unit in the sub-pixel search stage.
  • the optimal coding unit of the coding tree unit may be determined according to the following substeps S11 to S13:
  • sub-step S11 the coding tree units are divided into coding units according to different scales.
  • the coding tree unit can be divided into coding units with the same length and width, and the scale is the length or width of the coding unit.
  • FIG. 5 shows a schematic diagram of a division manner of dividing a coding tree unit into coding units.
  • the size of the coding tree unit is 64 ⁇ 64, and the coding tree unit can be directly used as the coding unit, and the size of the coding unit is 64 at this time. It can also be divided into four 32 ⁇ 32 coding units, and the scale of the coding unit is 32 at this time. It can also be divided into 16 coding units of 16 ⁇ 16, and the size of the coding unit is 16 at this time. It can also be divided into 64 8 ⁇ 8 coding units, and the size of the coding unit is 8 at this time. And not limited to the above list.
  • sub-step S12 the encoding cost of each divided coding unit is determined by integer pixel search.
  • an integer pixel search may be performed on each divided coding unit, and an encoding cost of each coding unit may be calculated based on an integer pixel search result.
  • the coding cost of the coding unit may be obtained by calculating a Sum of Absolute Difference (SAD).
  • SAD Sum of Absolute Difference
  • the absolute error refers to the absolute value of the difference between the measured value and the real value.
  • the absolute error of the pixel is the difference between the pixel value of the pixel in the predicted image block and the coding unit the absolute value of .
  • the coding cost of the coding unit may be obtained by calculating a sum of absolute values after Hadamard product transformation (Sum of Absolute Transformed Difference, SATD).
  • SATD Average Transformed Difference
  • the optimal coding unit is usually determined through a rate-distortion optimized (Rate Distortion Optimized, RDO) strategy.
  • Rate-distortion optimization is a cost function scheme proposed on the basis of rate-distortion theory. The main idea of rate-distortion optimization is that when calculating the cost function, the constraints of two factors, the code rate and the degree of distortion, are considered to ensure low distortion. While ensuring a low bit rate, it is more conducive to the transmission of video streams. Therefore, to determine the optimal coding unit through rate-distortion optimization, not only the integer pixel search result, but also the code rate after encoding needs to be considered.
  • the existing technology needs to traverse various combinations of coding units and transformation units, and select the best The optimal combination method is used to determine the optimal coding unit (and the optimal transformation unit), so the calculation amount is large and the search efficiency is low.
  • the encoding cost is deduced by SAD or SATD, and the value of the encoding cost can be calculated only through the integer pixel search result, without considering the code rate after encoding, so the decision-making process of the encoding unit does not need to make a decision on the transformation unit, let alone It is necessary to consider the division of the transformation unit and the combination of the coding unit and the transformation unit, so that the decision-making process of the coding unit and the transformation unit is separated, thereby reducing the amount of calculation and improving the search efficiency.
  • sub-step S13 based on the determined coding costs of each coding unit, an optimal coding unit of the coding tree unit is selected.
  • the coding unit corresponding to the division method with the smallest sum of encoding costs can be selected as the optimal coding unit of the coding tree unit.
  • the optimal coding unit may be selected according to the following steps:
  • the scales of the coding units whose coding costs have been determined are sorted in ascending order, to obtain the first sorting result.
  • the coding unit divided by the smallest scale in the first sorting result is marked as the optimal coding unit, and a scale is selected from the first sorting result as the first target scale.
  • the coding unit divided by the first target scale is used as the target coding unit, and the coding cost of the target coding unit and the sum of the coding costs of the coding units marked with the optimal coding unit included in the target coding unit are respectively determined .
  • the fourth step for the target coding unit, if the coding cost of the target coding unit is less than or equal to the sum of the coding costs of the coding units marked with the optimal coding unit contained in the target coding unit, mark the target coding unit as the optimal coding unit. Excellent coding unit.
  • selecting a scale from the first sorting result as the first target scale in the second step may include: starting from the second scale in the first sorting result, sequentially selecting a scale in the first sorting result as the first target scale A target size for selecting the optimal coding unit of the coding tree unit, until the last size in the first sorting result is used as the first target size.
  • the fourth step may also include: if the coding cost of the target coding unit is less than or equal to the sum of coding costs of the coding units marked with the optimal coding unit contained in the target coding unit, then deleting the coding cost contained in the target coding unit The optimal coding unit label of each coding unit of .
  • the size of the coding tree unit is 64x64.
  • the coding units for which the coding cost has been determined include 8 ⁇ 8 coding units, 16 ⁇ 16 coding units, 32 ⁇ 32 coding units, and 64 ⁇ 64 coding units, and the first sorting results are 8, 16, and 32 in order , 64.
  • the coding unit divided by the smallest scale of 8 in the first sorting result is marked as the optimal coding unit, all 8 ⁇ 8 coding units can be marked with the optimal coding unit.
  • select a scale in the first sorting result as the first target scale in turn as an example.
  • scale 16 can be selected as the first target scale
  • 64 is selected as the first target scale in the third round.
  • the first target scale is 16, so the 16 ⁇ 16 coding unit divided by the first target scale of 16 is used as the target coding unit.
  • Each 16 ⁇ 16 target CU may include four 8 ⁇ 8 CUs with optimal CU marks.
  • the coding cost of each 16 ⁇ 16 target coding unit and each coding unit marked with the optimal coding unit included in the 16 ⁇ 16 target coding unit can be determined separately The sum of encoding costs of .
  • the coding cost of the 16 ⁇ 16 target coding unit is less than or equal to the sum of the coding costs of the four 8 ⁇ 8 coding units contained in the target coding unit, it means The coding effect of the 16 ⁇ 16 target coding unit is better than the coding effect of the four 8 ⁇ 8 coding units contained in it, so the 16 ⁇ 16 target coding unit can be marked as the most optimal coding unit at this time. Excellent coding unit.
  • the optimal coding unit mark of each 8 ⁇ 8 coding unit contained in the 16 ⁇ 16 target coding unit can be deleted, so as to update the optimal coding unit, so as to facilitate the next round of comparison.
  • the coding cost of the 16 ⁇ 16 target coding unit is greater than the sum of the coding costs of the four 8 ⁇ 8 first coding units contained in the target coding unit, it means that the 16 ⁇ 16 target coding unit
  • the effect of encoding is inferior to the encoding effect of encoding with the four 8 ⁇ 8 coding units contained in it, so at this time, these four 8 ⁇ 8 coding units can still be edited with the optimal coding unit, that is, no Do anything.
  • the first target scale is 32, so the 32 ⁇ 32 coding unit divided by the first target scale 32 is used as the target coding unit.
  • the coding cost of each 32 ⁇ 32 target coding unit and the sum of coding costs of coding units marked with an optimal coding unit included in the 32 ⁇ 32 target coding unit may be respectively determined.
  • the coding cost of the 32 ⁇ 32 target coding unit is less than or equal to the sum of the coding costs of the coding units marked with the optimal coding unit contained in the target coding unit, then It means that the coding effect of the 32 ⁇ 32 target coding unit is better than the overall coding effect of the coding unit marked with the optimal coding unit contained in it, so the 32 ⁇ 32 target coding unit can be used at this time Marked as the optimal coding unit.
  • the optimal coding unit flags of the coding units with optimal coding unit flags included in the 32 ⁇ 32 target coding unit may be deleted, so as to update the optimal coding unit for the next round of comparison.
  • the coding cost of the 32 ⁇ 32 target coding unit is greater than the sum of the coding costs of the coding units marked with the optimal coding unit contained in the target coding unit, it means that the 32 ⁇ 32 target coding unit is used for coding.
  • the encoding effect is inferior to the overall encoding effect of the coding units marked with the optimal coding unit contained therein, so no operation may be performed at this time.
  • CU 32 a 32 ⁇ 32 target coding unit
  • CU 16-1 can accommodate four 8 ⁇ 8 coding units, which are respectively recorded as CU 8-1-1 , CU 8-1-2 , CU 8-1-3 , and CU 8-1-4 .
  • CU 16-2 can accommodate four 8 ⁇ 8 coding units, which are respectively recorded as CU 8-2-1 , CU 8-2-2 , CU 8-2-3 , and CU 8-2-4 .
  • CU 16-3 can accommodate four 8 ⁇ 8 coding units, which are respectively recorded as CU 8-3-1 , CU 8-3-2 , CU 8-3-3 , and CU 8-3-4 .
  • CU 16-4 can accommodate four 8 ⁇ 8 coding units, which are respectively recorded as CU 8-4-1 , CU 8-4-2 , CU 8-4-3 , and CU 8-4-4 .
  • the coding cost of CU 16-1 is greater than the sum of the coding costs of CU 8-1-1 , CU 8-1-2 , CU 8-1-3 , and CU 8-1-4 .
  • the encoding cost of CU 16-2 is less than or equal to the sum of the encoding costs of CU 8-2-1 , CU 8-2-2 , CU 8-2-3 , and CU 8-2-4 , and the encoding cost of CU 16-3 Less than or equal to the sum of the encoding costs of CU 8-3-1 , CU 8-3-2 , CU 8-3-3 , and CU 8-3-4, and the encoding cost of CU 16-4 is less than or equal to CU 8- 4-1 , CU 8-4-2 , CU 8-4-3 , CU 8-4-4 and the sum of coding costs, then CU 8-1-1 , CU 8-1-2 , CU 8-1- 3.
  • CU 8-1-4 , CU 16-2 , CU 16-3 , and CU 16-4 are all marked as optimal coding units.
  • the area where the 32 ⁇ 32 target coding unit CU 32 is located includes three 16 ⁇ 16 coding units (respectively CU 16-2 , CU 16-3 , CU 16-4 ) and four 8 ⁇ 8 coding units (respectively CU 8-1-1 , CU 8-1-2 , CU 8-1-3 , CU 8- 1-4 ).
  • the coding cost of the 32 ⁇ 32 target coding unit CU 32 can be compared with CU 16-2 , CU 16-3 , CU 16-4 , CU 8-1-1 , CU 8-1- 2.
  • the sum of coding costs of CU 8-1-3 and CU 8-1-4 is compared. If the coding cost of the 32 ⁇ 32 target coding unit CU 32 is less than or equal to CU 16-2 , CU 16-3 , CU 16-4 , CU 8-1-1 , CU 8-1-2 , CU 8-1- 3.
  • the sum of the coding costs of CU 8-1-4 means that the coding effect of the 32 ⁇ 32 target coding unit CU 32 is better than the coding effect of the optimal coding unit in this area determined in the previous round, Therefore, at this time, the 32 ⁇ 32 target coding unit CU 32 can be marked as the optimal coding unit, and CU 16-2 , CU 16-3 , CU 16-4 , CU 8-1-1 , and CU 8-1 can be deleted -2 , CU 8-1-3 , and CU 8-1-4 optimal coding unit marks.
  • the coding cost of the 32 ⁇ 32 target coding unit CU 32 is greater than CU 16-2 , CU 16-3 , CU 16-4 , CU 8-1-1 , CU 8-1-2 , CU 8-1- 3.
  • the sum of the coding costs of CU 8-1-4 means that the coding effect of the 32 ⁇ 32 target coding unit CU 32 is inferior to the coding effect of the optimal coding unit in the area determined in the previous round, Therefore, no operation may be performed at this time, that is, the current optimal coding unit in the region is maintained.
  • the other 32 ⁇ 32 target coding units are similar to the above process, which will not be repeated here.
  • the first target scale is 64, so the 64 ⁇ 64 coding unit divided by the first target scale of 64 is used as the target coding unit.
  • the coding cost of the 64 ⁇ 64 target coding unit and the sum of coding costs of the coding units marked with the optimal coding unit included in the 64 ⁇ 64 target coding unit may be respectively determined.
  • the coding cost of the 64 ⁇ 64 target coding unit is less than or equal to the sum of the coding costs of the coding units marked with the optimal coding unit contained in the target coding unit, it means The coding effect of the 64 ⁇ 64 target coding unit is better than the overall coding effect of the coding unit marked with the optimal coding unit contained in it, so at this time, the 64 ⁇ 64 target coding unit can be marked as optimal coding unit.
  • the best coding unit flags of the coding units with the best coding unit flag included in the 64 ⁇ 64 target coding unit may be deleted, so as to update the best coding unit for the next round of comparison.
  • the coding cost of the 64 ⁇ 64 target coding unit is greater than the sum of the coding costs of the coding units marked with the optimal coding unit contained in the target coding unit, it means that the 64 ⁇ 64 target coding unit is used for coding.
  • the encoding effect is inferior to the overall encoding effect of the coding units marked with the optimal coding unit contained therein, so no operation may be performed at this time.
  • the process of the third round of comparison is similar to that of the second round of comparison, and will not be repeated here.
  • the coding units are compared in order of scale from small to large, which can avoid repeated comparison of coding units, so that the optimal coding unit can be determined conveniently and quickly.
  • an example is used below for description. If the 16 16 ⁇ 16 coding units in the first round of decision-making are all optimal coding units, and the 8 ⁇ 8 coding units in each 16 ⁇ 16 coding unit are not optimal coding units, then in the second round of comparison For synchronization, it is only necessary to compare each 32 ⁇ 32 coding unit with the four 16 ⁇ 16 coding units contained in it, and it is not necessary to compare the 32 ⁇ 32 coding unit with the 16 8 ⁇ 8 coding units.
  • the coding unit is compared, and there is no need to combine the 32 ⁇ 32 coding unit with the 16 ⁇ 16 coding unit and the 8 ⁇ 8 coding unit (for example, three 16 ⁇ 16 coding units and four 8 ⁇ 8 coding units).
  • the combination of coding units, the combination of two 16 ⁇ 16 coding units and eight 8 ⁇ 8 coding units, and the combination of one 16 ⁇ 16 coding unit and twelve 8 ⁇ 8 coding units) are compared. In this way, repeated comparison of coding units can be avoided, so that an optimal coding unit can be determined conveniently and quickly.
  • FIG. 6 shows a schematic diagram of dividing a coding tree unit into optimal transformation units.
  • the size of the coding tree unit in this diagram is 64 ⁇ 64.
  • the coding tree unit may be divided into 13 16 ⁇ 16 optimal coding units and 12 8 ⁇ 8 optimal transformation units.
  • the optimal coding unit of the coding tree unit may also be determined according to the following substeps S21 to S23:
  • sub-step S21 the coding tree units are divided into coding units according to different scales respectively to obtain a coding unit set.
  • the coding unit division of the coding tree unit according to different scales may be referred to. After the coding units are obtained after division, the coding units can be aggregated to obtain a coding unit set.
  • sub-step S22 select some coding units from the coding unit set, and determine the coding cost of each selected coding unit through integer pixel search.
  • some coding units may be selected from the coding unit set to perform integer pixel search, and the coding cost of each selected coding unit may be calculated based on the integer pixel search result.
  • sub-step S23 based on the determined coding costs of each coding unit, an optimal coding unit of the coding tree unit is selected.
  • the coding unit corresponding to the division method with the smallest sum of encoding costs can be selected as the optimal coding unit of the coding tree unit.
  • This step is basically similar to the above step S13, and reference may be made to the process in the above S13, which will not be repeated here.
  • Step 302 determining an optimal transformation unit of an optimal coding unit.
  • the execution subject only needs to make a decision on the transformation unit of the optimal coding unit, and determine the optimal transformation unit of the optimal coding unit.
  • no TU decision is required.
  • the calculation amount of the decision-making process of the transformation unit can be greatly reduced, thereby improving the search efficiency.
  • the operation of determining the optimal transformation unit of the optimal coding unit is performed in the rate-distortion decision stage, and the rate-distortion operation is performed by the rate-distortion decision module.
  • the rate-distortion decision-making stage mainly performs transformation, quantization, inverse transformation, inverse quantization, estimated distortion, and operations on coded bits.
  • the motion search stage is mainly for coding unit decision of inter mode.
  • Motion search and rate-distortion decision belong to different execution phases respectively. That is, motion search operations and rate-distortion decision operations belong to different pipeline stages. That is, the step of determining the optimal CU of the coding tree unit through motion search is performed by the motion search module, and the step of determining the optimal TU of the optimal CU is performed by the rate-distortion decision module wherein, the motion search module and the rate-distortion decision module respectively belong to different pipeline stages.
  • the execution subject first divides the optimal coding unit into transformation units according to different scales, and then performs coding cost calculation on some or all of the transformation units, and selects the transformation unit division method with the smallest coding cost.
  • the transformation unit division method at this time is the optimal transformation unit division method.
  • the optimal transformation unit of the optimal coding tree may be determined according to the following substeps S31 to S33:
  • the optimal coding unit is divided into transformation units according to different scales.
  • the optimal coding unit may be divided into transformation units with the same length and width, and the above scale is the length or width of the transformation unit.
  • the optimal coding unit may be directly used as a transformation unit, and the size of the transformation unit is 32 at this time. It can also be divided into four 16 ⁇ 16 transformation units, and the scale of the transformation unit is 16 at this time. It can also be divided into 16 8 ⁇ 8 transformation units, and the scale of the transformation unit is 8 at this time.
  • the optimal coding unit may be directly used as a transformation unit, and the size of the transformation unit is 16 at this time. It can also be divided into four 8 ⁇ 8 transformation units, and the scale of the transformation unit is 8 at this time.
  • the scale of the optimal coding unit may be used as the second largest scale (may be denoted as C), the M power of a preset value (such as 2) may be used as the divisor, and the quotient of the second largest scale and the divisor may be used as
  • optimal coding units of different sizes may be divided into different proportions.
  • at least one division ratio of the optimal coding unit may be determined based on the scale of the optimal coding unit, and each division ratio of the optimal coding unit is used respectively to perform a calculation on the optimal coding unit Transform unit division.
  • the division ratios of a 32 ⁇ 32 coding unit may be 0.5 and 0.25
  • the division ratios of a 16 ⁇ 16 coding unit may be 1 and 0.5.
  • the division ratio is 0.5
  • the length or width of the coding unit is multiplied by 0.5 to obtain a length or width of 16 corresponding to the 32 ⁇ 32 coding unit.
  • the size of the transformation unit corresponding to the 32 ⁇ 32 coding unit is 16 ⁇ 16 through the above method.
  • the division ratio is 0.25
  • the length or width of the coding unit is multiplied by 0.25 to obtain a length or width of 8 corresponding to the 32 ⁇ 32 coding unit. Therefore, it can be determined that the size of the transformation unit corresponding to the 32 ⁇ 32 coding unit is 8 ⁇ 8 through the above method.
  • the division ratio is 1, the length or width of the coding unit is multiplied by 1 to obtain the length or width of the transform unit corresponding to the 16 ⁇ 16 coding unit is 16.
  • the size of the transformation unit corresponding to the 16 ⁇ 16 coding unit can be determined to be 16 ⁇ 16 through the above method.
  • the division ratio is 0.5
  • the length or width of the coding unit is multiplied by 0.5 to obtain a length or width of 8 corresponding to the 16 ⁇ 16 coding unit. Therefore, it can be determined that the size of the transformation unit corresponding to the 16 ⁇ 16 coding unit is 8 ⁇ 8 through the above method.
  • the present application is not limited thereto. In one embodiment, different division ratios may be set for the length and width of the coding unit respectively.
  • the size of the transformation unit corresponding to the 32 ⁇ 32 coding unit is 16 ⁇ 8 through the above method.
  • other sizes of the transformation units may also be obtained according to other division ratios.
  • sizes of transformation units corresponding to coding units of different sizes may be predefined.
  • a rate-distortion optimization method is used to determine the encoding cost of each divided transformation unit.
  • the rate-distortion optimization method when used to determine the encoding cost of the transformation unit, the residual mean square sum of the reconstructed block in the current prediction mode and the source image can be calculated as the distortion amount in the rate-distortion optimization calculation . Then, the number of bits required to encode the transform unit is calculated. Finally, the rate-distortion-optimized coding cost is obtained by combining the above-mentioned distortion amount and the number of bits at the same time. The lower the coding cost, the better the final coding effect.
  • sub-step S33 based on the determined coding cost of each transformation unit, an optimal transformation unit of the optimal coding unit is selected.
  • the method of selecting the optimal TU of the optimal CU based on the determined coding cost of each TU is determined to be similar to the method of selecting the optimal CU based on the coding cost of each CU in sub-step S13. Since the smaller the encoding cost, the better the final encoding effect, and thus the transformation unit corresponding to the division method with the smallest sum of encoding costs can be selected as the optimal transformation unit of the optimal coding unit.
  • the optimal transformation unit may be selected according to the following steps:
  • the scales of the transformation units whose encoding costs have been determined are sorted in ascending order, to obtain a second sorting result.
  • the transformation unit divided by the smallest scale in the second sorting result is marked as the optimal transformation unit, and a scale is selected from the second sorting result as the second target scale.
  • the transformation unit divided by the second target scale is used as the target transformation unit, and the encoding cost of the target transformation unit and the sum of the encoding costs of the transformation units marked with the optimal transformation unit contained in the target transformation unit are respectively determined .
  • Step 4 For the target transformation unit, if the coding cost of the target transformation unit is less than or equal to the sum of the coding costs of the transformation units marked with the optimal transformation unit contained in the target transformation unit, mark the target transformation unit as the optimal transformation unit. Excellent transformation unit.
  • selecting a scale from the second sorting result as the second target scale in the second step may include: starting from the second scale in the second sorting result, sequentially selecting a scale in the second sorting result as the second target scale
  • the second target size is used for selecting the optimal transformation unit of the coding tree unit, until the last size in the second sorting result is used as the second target size.
  • the fourth step may also include: if the coding cost of the target transformation unit is less than or equal to the sum of the coding costs of the transformation units marked with the optimal transformation unit included in the target transformation unit, then delete the The optimal transformation unit mark of each transformation unit of .
  • the size of an optimal coding unit is 32 ⁇ 32.
  • the TUs for which the encoding cost has been determined include 8 ⁇ 8 TUs, 16 ⁇ 16 TUs, and 32 ⁇ 32 TUs, and the second sorting results are 8, 16, and 32 in sequence.
  • all 8 ⁇ 8 transformation units can be marked with the optimal transformation unit.
  • select one of the scales in the second sorting result as the second target scale as an example.
  • scale 16 can be selected as the second target scale.
  • the second target scale is 16, so the 16 ⁇ 16 transformation unit divided by the second target scale of 16 is used as the target transformation unit.
  • Each 16 ⁇ 16 target TU may include four 8 ⁇ 8 TUs with optimal TU marks.
  • the encoding cost of each 16 ⁇ 16 target transformation unit and the transformation units with the optimal transformation unit mark included in the 16 ⁇ 16 target transformation unit can be determined separately The sum of encoding costs of .
  • the coding cost of the 16 ⁇ 16 target transformation unit is less than or equal to the sum of the coding costs of the four 8 ⁇ 8 transformation units contained in the target transformation unit, it means The encoding effect of the 16 ⁇ 16 target transformation unit is better than that of the four 8 ⁇ 8 transformation units contained in it, so the 16 ⁇ 16 target transformation unit can be marked as the most effective at this time. Excellent transformation unit.
  • the optimal TU flags of the 8 ⁇ 8 TUs included in the 16 ⁇ 16 target TU may be deleted, so as to update the optimal TU for the next round of comparison.
  • the coding cost of the 16 ⁇ 16 target transformation unit is greater than the sum of the coding costs of the four 8 ⁇ 8 second transformation units included in the target transformation unit, it means that the 16 ⁇ 16 target transformation unit
  • the effect of encoding is inferior to the encoding effect of encoding with the four 8 ⁇ 8 TUs contained in it, so at this time, these four 8 ⁇ 8 TUs can still be edited with the optimal TU, that is, no Do anything.
  • the second target scale is 32, so the 32 ⁇ 32 transformation unit divided by the second target scale 32 is used as the target transformation unit.
  • the encoding cost of each 32 ⁇ 32 target TU and the sum of the encoding costs of the TUs marked with the optimal TU contained in the 32 ⁇ 32 target TU may be respectively determined.
  • the coding cost of the 32 ⁇ 32 target TU is less than or equal to the sum of the coding costs of the TUs marked with the optimal TU contained in the target TU, then It means that the encoding effect of the 32 ⁇ 32 target transformation unit is better than the overall encoding effect of the transformation unit marked with the optimal transformation unit contained in it, so the 32 ⁇ 32 target transformation unit can be used at this time Marked as the optimal transformation unit.
  • the optimal TU flags of the TUs with optimal TU flags included in the 32 ⁇ 32 target TU may be deleted, so as to update the optimal TU for the next round of comparison.
  • the encoding cost of the 32 ⁇ 32 target transformation unit is greater than the sum of the encoding costs of the transformation units marked with the optimal transformation unit included in the target transformation unit, it means that the 32 ⁇ 32 target transformation unit is used for The encoding effect is inferior to the overall encoding effect of the TUs marked with the optimal TUs contained therein, so no operation may be performed at this time.
  • a 32 ⁇ 32 target transformation unit (which can be recorded as TU 32 ) is located in an area that can accommodate four 16 ⁇ 16 transformation units, which can be recorded as TU 16-1 , TU 16-2 , TU 16-3 , TU 16-4 .
  • TU 16-1 can accommodate four 8 ⁇ 8 transformation units, which are respectively recorded as TU 8-1-1 , TU 8-1-2 , TU 8-1-3 , and TU 8-1-4 .
  • TU 16-2 can accommodate four 8 ⁇ 8 transformation units, which are respectively marked as TU 8-2-1 , TU 8-2-2 , TU 8-2-3 , and TU 8-2-4 .
  • TU 16-3 can accommodate four 8 ⁇ 8 transformation units, which are respectively recorded as TU 8-3-1 , TU 8-3-2 , TU 8-3-3 , and TU 8-3-4 .
  • TU 16-4 can accommodate four 8 ⁇ 8 transformation units, which are respectively recorded as TU 8-4-1 , TU 8-4-2 , TU 8-4-3 , and TU 8-4-4 .
  • the coding cost of TU 16-1 is greater than the sum of the coding costs of TU 8-1-1 , TU 8-1-2 , TU 8-1-3 , and TU 8-1-4 .
  • the coding cost of TU 16-2 is less than or equal to the sum of the coding costs of TU 8-2-1 , TU 8-2-2 , TU 8-2-3 , and TU 8-2-4 , and the coding cost of TU 16-3 Less than or equal to the sum of the encoding costs of TU 8-3-1 , TU 8-3-2 , TU 8-3-3 , and TU 8-3-4, and the encoding cost of TU 16-4 is less than or equal to TU 8- 4-1 , TU 8-4-2 , TU 8-4-3 , and TU 8-4-4 encoding costs, then TU 8-1-1 , TU 8-1-2 , TU 8-1- 3.
  • TU 8-1-4 , TU 16-2 , TU 16-3 , and TU 16-4 are all marked as optimal transformation units.
  • the region where the 32 ⁇ 32 target TU 32 is located includes three 16 ⁇ 16 TUs (respectively TU 16-2 , TU 16-3 , TU 16-4 ) and four 8 ⁇ 8 transformation units with optimal transformation unit marks (respectively TU 8-1-1 , TU 8-1-2 , TU 8-1-3 , TU 8- 1-4 ).
  • the coding cost of the 32 ⁇ 32 target transform unit TU 32 can be compared with TU 16-2 , TU 16-3 , TU 16-4 , TU 8-1-1 , TU 8-1- 2.
  • the sum of the coding costs of TU 8-1-3 and TU 8-1-4 is compared. If the coding cost of the 32 ⁇ 32 target transform unit TU 32 is less than or equal to TU 16-2 , TU 16-3 , TU 16-4 , TU 8-1-1 , TU 8-1-2 , TU 8-1- 3.
  • the sum of the coding costs of TU 8-1-4 means that the coding effect of the 32 ⁇ 32 target transformation unit TU 32 is better than the coding effect of the optimal transformation unit in the area determined in the previous round, Therefore, at this time, the 32 ⁇ 32 target transformation unit TU 32 can be marked as the optimal transformation unit, and TU 16-2 , TU 16-3 , TU 16-4 , TU 8-1-1 , and TU 8-1 can be deleted -2 , TU 8-1-3 , TU 8-1-4 optimal transformation unit mark. Conversely, if the coding cost of the 32 ⁇ 32 target transform unit TU 32 is greater than TU 16-2 , TU 16-3 , TU 16-4 , TU 8-1-1 , TU 8-1-2 , TU 8-1- 3.
  • the sum of the coding costs of TU 8-1-4 means that the coding effect of the 32 ⁇ 32 target transformation unit TU 32 is inferior to the coding effect of the optimal transformation unit in the region determined in the previous round, Therefore, no operation may be performed at this time, that is, the current optimal transformation unit in the region is maintained.
  • the other 32 ⁇ 32 target transformation units are similar to the above process, which will not be repeated here.
  • the transformation units are compared in order of scale from small to large, which can avoid repeated comparisons of transformation units, so that the optimal transformation unit can be determined conveniently and quickly.
  • an example is used below for description. If all 16 16 ⁇ 16 transformation units are optimal transformation units in the first round of decision-making, and none of the 8 ⁇ 8 transformation units in each 16 ⁇ 16 transformation unit is the optimal transformation unit, then in the second round of comparison When correct, you only need to compare the 32 ⁇ 32 transformation unit with the four 16 ⁇ 16 transformation units contained in it, and there is no need to compare the 32 ⁇ 32 transformation unit with the 16 8 ⁇ 8 transformation units.
  • the optimal transformation unit of the optimal coding tree may be determined according to the following substeps S41 to S43:
  • the optimal coding unit is divided into transformation units according to different scales respectively to obtain a transformation unit set.
  • sub-step S31 may be referred to for dividing the transformation unit of the optimal coding unit according to different scales. After the transformation units are obtained after division, the transformation units can be aggregated to obtain a transformation unit set.
  • sub-step S42 select some transformation units from the transformation unit set, and determine the encoding cost of each selected transformation unit in a rate-distortion optimization manner.
  • some transformation units may be selected from the transformation unit set to perform encoding cost calculation.
  • the amount of encoding cost calculation can be reduced, thereby improving the decision-making efficiency of the optimal transform unit.
  • Sub-step S43 based on the determined coding cost of each transformation unit, select the optimal transformation unit of the optimal coding unit.
  • This step is basically similar to the above-mentioned step S33, and reference may be made to the process in the above-mentioned S33, which will not be repeated here.
  • Step 303 encode the optimal coding unit based on the optimal transformation unit.
  • the residual block between the predicted image block and the optimal coding unit may be determined. Therefore, taking the optimal transformation unit of the optimal coding unit as a unit, the above residual block is sequentially transformed, quantized, and entropy encoded, and each optimal transformation unit is encoded, so as to obtain the encoding result of the optimal coding unit .
  • the execution subject may first predict the optimal coding unit (for example, further perform sub-pixel search on the basis of integer pixel search), and obtain the predicted image of the optimal coding unit piece. Then determine the optimal coding unit and the residual block of the predicted image block. Afterwards, based on the optimal transformation unit, the above residual block is sequentially transformed, quantized and entropy coded, so as to obtain a coding result of the optimal coding unit. Therefore, a sub-pixel search process is added to improve the encoding quality.
  • the optimal coding unit for example, further perform sub-pixel search on the basis of integer pixel search
  • the optimal coding unit of the coding tree unit is determined through integer pixel search; then, the optimal transformation unit of the above-mentioned optimal coding unit is determined; finally, the above-mentioned optimal
  • the coding unit is encoded, because there is no need to consider the transformation unit division of the non-optimal coding unit, and there is no need to combine each coding unit and transformation unit, thus reducing the computational complexity in the process of deciding the optimal coding unit and the optimal transformation unit. Improved decision-making efficiency.
  • the present application provides an embodiment of an encoding device, and the device embodiment corresponds to the foregoing method embodiment.
  • the electronic device can be in various electronic devices.
  • the coding device 1000 described in this embodiment includes: a first determining unit 1001 configured to determine the optimal coding unit of a coding tree unit through motion search; a second determining unit 1002 configured to determine the optimal coding unit of the coding tree unit The optimal transformation unit of the optimal coding unit; the encoding unit 1003 is configured to encode the optimal coding unit based on the optimal transformation unit.
  • the first determining unit is further configured to: respectively divide the coding tree units into coding units according to different scales to obtain a coding unit set; select some coding units from the coding unit set, And determine the coding cost of each coding unit selected through the motion search; based on the determined coding cost of each coding unit, select the optimal coding unit of the coding tree unit.
  • the first determination unit is further configured to: respectively divide the coding tree units into coding units according to different scales; determine the coding cost of each divided coding unit through the motion search; The cost is to select the optimal coding unit of the coding tree unit.
  • the motion search includes integer pixel search and/or sub-pixel search.
  • the first determining unit 1001 is further configured to: divide the coding tree units into coding units according to different scales respectively to obtain a coding unit set; from the coding unit set Select some coding units, and determine the coding cost of each coding unit by integer pixel search; based on the determined coding cost of each coding unit, select the optimal coding unit of the coding tree unit.
  • the optimal coding unit of the coding tree unit may be determined by sub-pixel searching.
  • the first determination unit 1001 is further configured to: respectively divide the coding tree units into coding units according to different scales to obtain a coding unit set; select some coding units from the coding unit set, and determine the coding units by sub-pixel search.
  • the first determining unit 1001 is further configured to: perform a sub-pixel search after performing the full pixel search.
  • the optimal coding unit for the coding tree unit can be determined according to the above-mentioned method when performing the integer pixel search; The optimal coding unit for .
  • the above-mentioned executive body can first further divide the optimal coding unit according to different scales, and divide the optimal coding unit into A sub-coding unit with respect to a better coding unit. Further, a pixel-by-pixel search is performed on some sub-coding units or all sub-coding units, and then the coding cost of the corresponding coding unit can be determined based on the predicted image block obtained from the pixel-by-pixel search result. The coding cost can be used to evaluate the pros and cons of the sub-coding unit. The smaller the coding cost, the better the sub-coding unit, and the better the coding effect of coding using this sub-coding unit.
  • the sub-coding unit division manner that minimizes the encoding cost can be selected.
  • the way of dividing the sub-coding units at this time is the optimal way of dividing the coding units.
  • the coding performance can be improved by obtaining a better coding unit in the integer pixel search stage and obtaining the optimal coding unit in the sub-pixel search stage.
  • the integer pixel search is only performed on the basis of coding units of all sizes or partial sizes. Then, the sub-pixel search is further performed in the coding unit corresponding to these sizes in the sub-pixel search stage. Afterwards, based on the predicted image block obtained from the sub-pixel search result, the coding cost of the corresponding coding unit can be determined.
  • the coding cost can be used to evaluate the quality of the coding unit. The smaller the coding cost, the better the coding unit, and the better the coding effect of coding using this coding unit. Therefore, the coding unit division method that minimizes the coding cost can be selected.
  • the coding unit division manner at this time is the optimal coding unit division manner.
  • an optimal coding unit can be obtained.
  • the coding performance can also be improved by obtaining the optimal coding unit in the sub-pixel search stage.
  • the first determination unit 1001 is a motion search module
  • the second determination unit 1002 is a rate-distortion decision module; wherein, the motion search module 1001 and the The rate-distortion decision module 1002 is located in different pipeline stages.
  • the first determination unit 1001 is further configured to: divide the coding tree unit into coding units according to different scales; determine the divided coding units by integer pixel search The coding cost of each coding unit; based on the determined coding cost of each coding unit, select the optimal coding unit of the coding tree unit.
  • the second determination unit 1002 is further configured to: respectively divide the optimal coding unit into transformation units according to different scales to obtain a transformation unit set; from the Select some transformation units from the transformation unit set, and determine the encoding cost of each selected transformation unit by using rate-distortion optimization; based on the determined encoding cost of each transformation unit, select the optimal transformation unit of the optimal coding unit.
  • the second determination unit 1002 is further configured to: divide the optimal coding unit into transformation units according to different scales; The coding cost of each transformation unit; based on the determined coding cost of each transformation unit, select the optimal transformation unit of the optimal coding unit.
  • the coding unit 1003 is further configured to: predict the optimal coding unit to obtain a predicted image block of the optimal coding unit; determine the optimal coding unit An optimal coding unit and a residual block of the predicted image block; based on the optimal transform unit, sequentially perform transformation, quantization, and entropy encoding on the residual block.
  • the first determination unit 1001 is further configured to: take the scale of the coding tree unit as the first maximum scale, and use the Nth power of a preset value as the divisor , using the quotient of the first maximum scale and the divisor as a first candidate scale, and dividing the coding tree unit into coding units according to at least one first candidate scale; wherein, N is a non-negative integer.
  • the coding cost of the coding unit includes at least one of the following: a sum of absolute errors and a sum of absolute values after Hadamard product transformation.
  • the first determining unit 1001 is further configured to: sort the scales of the coding units whose coding costs have been determined in ascending order, to obtain the first Sorting results; mark the coding unit divided by the smallest scale in the first sorting result as the optimal coding unit, and select a scale from the first sorting result as the first target scale; use the first target
  • the scale-divided coding unit is used as the target coding unit, and the coding cost of the target coding unit and the sum of the coding costs of the coding units marked with the optimal coding unit included in the target coding unit are respectively determined; and if the If the coding cost of the target coding unit is less than or equal to the sum of coding costs of the coding units marked with the optimal coding unit included in the target coding unit, then the target coding unit is marked as the optimal coding unit.
  • the first determining unit 1001 is further configured to: start from the second scale in the first sorting result, and sequentially select A scale of is used as the first target scale for selecting the optimal coding unit of the coding tree unit until the last size in the first sorting result is used as the first target size.
  • the first determining unit 1001 is further configured to: if the coding cost of the target coding unit is less than or equal to the If the sum of coding costs of each coding unit marked by an optimal coding unit is used, the optimal coding unit marks of each coding unit included in the target coding unit are deleted.
  • the second determination unit 1002 is further configured to: take the scale of the optimal coding unit as the second maximum scale, and use the M power of a preset value as Divisor, using the quotient of the second largest scale and the divisor as a second candidate scale, and dividing the optimal coding unit into transformation units according to at least one second candidate scale; wherein, M is a non-negative integer.
  • the second determining unit 1002 is further configured to: for each optimal coding unit, determine the optimal coding unit's At least one division ratio, and each division ratio of the optimal coding unit is used respectively to divide the transformation unit of the optimal coding unit.
  • the second determination unit 1002 is further configured to: sort the scales of the transformation units whose encoding costs have been determined in ascending order, to obtain the second Sorting results; mark the transformation unit divided by the smallest scale in the second sorting result as the optimal transformation unit, select a scale from the second sorting result as the second target scale; use the second target
  • the scale-divided transformation unit is used as the target transformation unit, and the encoding cost of the target transformation unit and the sum of the encoding costs of the transformation units marked with the optimal transformation unit included in the target transformation unit are respectively determined; and if the If the encoding cost of the target TU is less than or equal to the sum of the encoding costs of the TUs marked with the optimal TU included in the target TU, then the target TU is marked as the optimal TU.
  • the second determining unit 1002 is further configured to: start from the second scale in the second sorting result, and sequentially select A scale of is used as the second target scale for selecting the optimal transform unit of the coding tree unit until the last size in the second sorting result is used as the second target size.
  • the second determination unit 1002 is further configured to: if the coding cost of the target transformation unit is less than or equal to the The sum of the encoding costs of the TUs marked by the optimal TU is deleted, and the optimal TU marks of the TUs included in the target TU are deleted.
  • the above device further includes: an acquisition unit configured to acquire a video frame to be encoded; a division unit configured to encode the video frame according to a preset size into a tree unit divided.
  • the coding device provided by the above-mentioned embodiments of the present application firstly determines the optimal coding unit of the coding tree unit through integer pixel search; then determines the optimal transformation unit of the optimal coding unit;
  • the above-mentioned optimal coding unit is encoded, because there is no need to consider the division of the transformation unit of the non-optimal coding unit, and there is no need to combine each coding unit and transformation unit, thus reducing the calculation in the process of deciding the optimal coding unit and the optimal transformation unit Complexity, improve decision-making efficiency.
  • the present application provides an embodiment of an electronic device, which corresponds to the method embodiment above.
  • the electronic device may specifically include: a processor 1101 and a memory 1102 .
  • the above-mentioned memory 1101 may be used to store program instructions.
  • the above-mentioned processor 1102 may be configured to execute the program instructions stored in the above-mentioned memory.
  • the above-mentioned processor may be configured to perform the following steps: determine the optimal coding unit of the coding tree unit through motion search; determine the optimal coding unit An optimal transformation unit of an optimal coding unit; encoding the optimal coding unit based on the optimal transformation unit.
  • the determining the optimal coding unit of the coding tree unit through motion search includes: respectively dividing the coding unit of the coding tree unit according to different scales to obtain a coding unit set; selecting some coding units from the coding unit set , and determine the coding cost of each selected coding unit through motion search; based on the determined coding cost of each coding unit, select the optimal coding unit of the coding tree unit.
  • the determining the optimal coding unit of the coding tree unit through motion search includes: dividing the coding tree unit into coding units according to different scales; determining the coding cost of each divided coding unit through motion search; Select the optimal coding unit of the coding tree unit based on the obtained coding cost of each coding unit.
  • the determining the optimal transformation unit of the optimal coding unit includes: respectively dividing the transformation unit of the optimal coding unit according to different scales to obtain a transformation unit set; selecting from the transformation unit set part of the TUs, and determine the encoding cost of each selected TU in a rate-distortion optimization manner; based on the determined encoding costs of each TU, select the optimal TU of the optimal CU.
  • the determining the optimal transformation unit of the optimal coding unit includes: dividing the optimal coding unit into transformation units according to different scales respectively; Coding cost: based on the determined coding cost of each transformation unit, select an optimal transformation unit of the optimal coding unit.
  • the encoding the optimal coding unit based on the optimal transformation unit includes: predicting the optimal coding unit to obtain a predicted image block of the optimal coding unit; determining the An optimal coding unit and a residual block of the predicted image block; based on the optimal transform unit, sequentially perform transformation, quantization, and entropy encoding on the residual block.
  • the dividing the coding tree unit into coding units according to different scales includes: taking the scale of the coding tree unit as the first maximum scale, taking the Nth power of a preset value as the divisor, and dividing the coding tree unit A quotient of a maximum scale and the divisor is used as a first candidate scale, and the coding tree units are respectively divided into coding units according to at least one first candidate scale; wherein, N is a non-negative integer.
  • the coding cost of the coding unit includes at least one of the following: a sum of absolute errors and a sum of absolute values after Hadamard product transformation.
  • the selecting the optimal coding unit of the coding tree unit based on the determined coding cost of each coding unit includes: performing a scale of the coding unit for which the coding cost has been determined in ascending order Sorting to obtain a first sorting result; marking the coding unit divided by the smallest scale in the first sorting result as an optimal coding unit, and selecting a scale from the first sorting result as the first target scale;
  • the coding unit divided by the first target scale is used as the target coding unit, and the coding cost of the target coding unit and the sum of the coding costs of the coding units marked with the optimal coding unit contained in the target coding unit are respectively determined ; and if the coding cost of the target coding unit is less than or equal to the sum of the coding costs of the coding units marked with the optimal coding unit contained in the target coding unit, marking the target coding unit as optimal coding unit.
  • the selecting a scale from the first sorting result as the first target scale includes: starting from the second scale in the first sorting result, sequentially selecting the One scale is used as the first target scale for selecting the optimal coding unit of the coding tree unit until the last size in the first sorting result is used as the first target size.
  • the selecting the optimal coding unit of the coding tree unit based on the determined coding cost of each coding unit further includes: if the coding cost of the target coding unit is less than or equal to The sum of the encoding costs of the included coding units marked with the optimal coding unit, then delete the optimal coding unit tags of the coding units included in the target coding unit.
  • the dividing the transformation unit of the optimal coding unit according to different scales includes: using the scale of the optimal coding unit as the second largest scale, and using the M power of a preset value as a divisor, Taking the quotient of the second largest scale and the divisor as a second candidate scale, respectively dividing the optimal coding unit into transformation units according to at least one second candidate scale; wherein, M is a non-negative integer.
  • the dividing the transformation unit of the optimal coding unit according to different scales includes: for each optimal coding unit, based on the scale of the optimal coding unit, determining at least one of the optimal coding units division ratios, and respectively adopt each division ratio of the optimal coding unit to divide the transformation unit of the optimal coding unit.
  • the selecting the optimal transformation unit of the optimal coding unit based on the determined coding cost of each transformation unit includes: in ascending order, the scale of the transformation unit whose coding cost has been determined Perform sorting to obtain a second sorting result; mark the transformation unit divided by the smallest scale in the second sorting result as the optimal transformation unit, and select a scale from the second sorting result as the second target scale; Using the transformation unit divided by the second target scale as the target transformation unit, respectively determine the coding cost of the target transformation unit and the coding cost of each transformation unit marked with the optimal transformation unit included in the target transformation unit sum; and if the coding cost of the target transformation unit is less than or equal to the sum of the coding costs of the transformation units marked with the optimal transformation unit included in the target transformation unit, marking the target transformation unit as the optimal transformation unit Excellent transformation unit.
  • the selecting a scale from the second sorting result as the second target scale includes: starting from the second scale in the second sorting result, sequentially selecting the One scale is used as the second target scale for selecting the optimal transformation unit of the coding tree unit until the last size in the second sorting result is used as the second target size.
  • the selecting the optimal transformation unit of the coding tree unit based on the determined coding costs of each transformation unit further includes: if the coding cost of the target transformation unit is less than or equal to The sum of the encoding costs of the included transformation units with the optimal transformation unit flags, then delete the optimal transformation unit flags of the transformation units included in the target transformation unit.
  • the processor is further configured to perform the following steps: acquiring a video frame to be encoded; dividing the video frame into coding tree units according to a preset size.
  • the step of determining the optimal coding unit of the coding tree unit through motion search is performed by a motion search module, and the step of determining the optimal transformation unit of the optimal coding unit is performed by rate-distortion decision module; wherein, the motion search module and the rate-distortion decision module respectively belong to different pipeline stages.
  • Motion search includes integer pixel search and/or sub-pixel search.
  • the electronic device provided by the above-mentioned embodiments of the present application first determines the optimal coding unit of the coding tree unit through an integer pixel search; then determines the optimal transformation unit of the optimal coding unit; and finally determines the optimal transformation unit based on the optimal transformation unit
  • the encoding of the optimal coding unit does not need to consider the transformation unit division of the non-optimal coding unit, and does not need to combine each coding unit and transformation unit, thus reducing the time spent in the process of deciding the optimal coding unit and the optimal transformation unit.
  • Computational complexity improves decision-making efficiency.
  • the description is relatively simple, and for related parts, please refer to part of the description of the method embodiment.
  • the embodiment of the present application also provides a computer-readable medium, on which a computer program is stored.
  • a computer program is stored.
  • each process of the above-mentioned coding method embodiment is implemented, and the same technical effect can be achieved.
  • the various processes of the embodiments of the above-mentioned methods are implemented, which will not be repeated here.
  • the embodiments of the present application may be provided as methods, apparatuses, or computer program products. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-readable media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied thereon.
  • computer-readable media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the The instruction means implements the functions specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

Landscapes

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

Abstract

本申请实施例公开了编码方法、装置、电子设备和计算机可读介质。该方法包括:通过运动搜索确定编码树单元的最优编码单元;确定最优编码单元的最优变换单元;基于最优变换单元对最优编码单元进行编码。该实现方式降低了决策最优编码单元和最优变换单元过程中的计算复杂度,提高了决策效率。

Description

编码方法、装置、电子设备和计算机可读介质 技术领域
本申请实施例涉及计算机技术领域,具体涉及编码方法、装置、电子设备和计算机可读介质。
背景技术
视频是连续的图像序列,由连续的帧构成,一帧即为一幅图像。由于连续的帧之间相似性极高,为便于储存和传输,需要对原始的视频进行编码压缩,以去除空间、时间维度的冗余。以H.265视频压缩标准为例,视频编码过程需要经过预测(prediction)、变换(transform)、量化(quantization)、熵编码(entropy coding)等阶段。此过程中,需要将视频帧划分为编码树单元(Coding Tree Unit,CTU),并将编码树单元划分为编码单元(Coding Unit,CU),进行预测。以及,需将编码单元进一步划分为变换单元(Transform Unit,TU),进行变换和量化。
现有技术中,通常需要对编码单元划分方式和变换单元划分方式进行组合,来确定出最优的划分方式。例如,编码单元共有N种划分方式,每个编码单元具有M种变换单元划分方式,则此时共有M×N种组合,需要遍历这M×N种组合,从中选取最优的组合。
现有技术的不足之处在于,由于编码单元和变换单元的划分方式多样,在确定最优编码单元和最优变换单元时需要遍历全部组合,导致计算复杂度较大,决策效率较低。
发明内容
本申请实施例提出了一种编码方法、装置、电子设备和计算机可读介质,以解决现有技术中确定最优CU和最优TU过程中计算复杂度较大、决策效率较低的技术问题。
第一方面,本申请实施例提供了一种编码方法,包括:通过运动搜索确定编码树单元的最优编码单元;确定所述最优编码单元的最优变换单元;基于所述最优变换单元对所述最优编码单元进行编码。
第二方面,本申请实施例提供了一种编码装置,包括:第一确定单元,被配置成通过运动搜索确定编码树单元的最优编码单元;第二确定单元,被配置成确定所述最优编码单元的最优变换单元;编码单元,被配置成基于所述最优变换单元对所述最优编码单元进行编码。
第三方面,本申请实施例提供了一种电子设备,包括:处理器和存储器;存储器,用于存储程序指令;处理器,用于执行存储器存储的程序指令,当程序指令被执行时,处理器用于执行如下步骤:通过运动搜索确定编码树单元的最优编码单元;确定所述最优编码单元的最优变换单元;基于所述最优变换单元对所述最优编码单元进行编码。
第四方面,本申请实施例提供了一种计算机可读介质,其上存储有计算机程序,该程序被处理器执行时实现如上述编码方法。
本申请实施例提供的编码方法、装置、电子设备和计算机可读介质,降低了决策最优编码单元和最优变换单元过程中的计算复杂度,提高了决策效率。
附图说明
通过阅读参照以下附图所作的对非限制性实施例所作的详细描述,本申请的其它特征、目的和优点将会变得更明显:
根据本申请的
图1是视频编码过程的示意图;
图2是编码器的流水级的示意图;
图3是本申请的编码方法的一个实施例的流程图;
图4是本申请的一个最优编码单元确定方法的流程图;
图5是本申请中将编码树单元划分为编码单元的划分方式的示意图;
图6是本申请中将编码树单元划分为最优变换单元的示意图;
图7是本申请的另一个最优编码单元确定方法的流程图;
图8是本申请的一个最优变换单元确定方法的流程图;
图9本申请的另一个最优变换单元确定方法的流程图;
图10是根据本申请的编码装置的一个实施例的结构示意图;
图11是根据本申请的电子设备的一个实施例的结构示意图。
具体实施例
下面结合附图和实施例对本申请作进一步的详细说明。可以理解的是,此处所描述的具体实施例仅仅用于解释相关发明,而非对该发明的限定。另外还需要说明的是,为了便于描述,附图中仅示出了与有关发明相关的部分。
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。
为便于理解,先结合图1,对常规的视频编码过程进行简单介绍。所谓视频编码方式就是指通过压缩技术,将原始视频格式的文件转换成另一种视频格式文件的方式。
如图1所示,在接到待编码的视频帧后,传统视频编码过程通常包括预测、变换、量化和熵编码等过程,最终输出视频的码流。解码端通常是按照上述过程的逆过程对接收到的码流进行解码,以恢复出编码前的视频信息。下面分别对预测、变换、量化和熵编码过程进行介绍。
视频数据有很强的相关性,因而存在大量的冗余信息。其中冗余信息可分为空域冗余信息和时域冗余信息。预测的目的在于利用预测图像块数据减少当前待编码图像块的冗余信息,即去除数据之间的相关性。
预测通常包括帧内预测和帧间预测两种类型。其中,帧内预测是使用同一视频帧中已经编码的图像块对当前的待编码图像块进行预测,以减少空余冗余信息。帧间预测是使用前一帧或前多帧已经编码的图像块对当前待编码图像块进行预测,以减少时域冗余信息。
预测阶段的处理过程具体包括如下步骤:
首先,将当前待编码图像划分成若干个待编码图像块。如H.264视频压缩标准中的宏块(Macro Block,MB)、H.265视频压缩标准中的编码树单元(Coding Tree Unit,CTU)等。
而后,将待编码图像块进一步划分,划分成若干个子图像块。此处,也可直接将待编码图像块整体作为子图像块。以H.265视频压缩标准为例,编码树单元可进一步划分为编码单元(Coding Unit,CU)。若编码树单元的尺寸为64×64,则通常可将其划分成的编码单元的尺寸可以包括64×64、32×32、16×16、8×8等。
之后,针对每个子图像块进行预测。通常可选取帧内预测以及帧间预测中的其中一种方式进行预测。对于帧内预测,可将使用同一视频帧中已经编码的图像块对该子图像块进行预测,得到预测图像块。对于帧间预测,可在参考图像(如上一帧图像)中搜索与当前子图像块最匹配的图像块作为预测图像块,此时,预测图像块与当前子图像块的相对位移,即为运动矢量。
最后,将该子图像块与预测图像块的像素值相减得到该子图像块对应的残差块。将得到的各子图像块对应的残差块组合在一起,即可得到待编码图像块的残差块,从而完成预测过程。
在执行预测过程后,需要依次执行变换、量化以及熵编码等过程。此过程需要对子图像块(如编码单元)进一步划分,得到更小的块,如变换单元(Transform Unit,TU)。此外,也可不对子图像块进行划分,此时变换单元的大小也等于编码单元的大小。变换单元为变化、量化过程的最小单元。例如,若编码单元的尺寸为32×32,则变换单元的尺寸可以包括32×32、16×16或8×8等。
变换操作用于将预测过程中得到的残差块从时域转换成频域。变换方式可包括离散余弦变换(discrete cosine transform,DCT)、离散小波变换(discretewavelet transform,DWT)等。对残差块进行变换后,可得到一个变换系数矩阵。
量化操作用于减小变换后所得到的变化系数,从而便于进行熵编码。
熵编码,即编码过程中按熵原理不丢失任何信息的编码。常见的熵编码有:香农(Shannon)编码、哈夫曼(Huffman)编码和算术编码(arithmetic coding)等。熵编码处理后,可得到熵编码比特流。将熵编码比特流以及相关信息(如模式信息、运动矢量等信息)进行存储或发送到解码端,即可完成视频编码过程。
需要说明的是,在进行量化和变换后,还可以通过反量化和反变换恢复出残差块(可称为重建残差块),然后将重建残差块与预测图像块相加,得到重建图像块,最后对重建图像块进行环内滤波,得到最终的重建图像,以便提供给之后的编码图像进行帧间预测。其中,环内滤波可以包括但不限于去块滤波、像素自适应补偿(Sample adaptive offset,SAO)等。
通过上述过程,即可完成视频的编码。在视频的解码端,可对获得的熵编码比特流进行熵解码,得到相应的残差块,而后根据解码得到的运动矢量等信息找到待解码图像块对应的预测图像块,最后根据预测图像块与残差得到待解码图像块中各像素点的值,从而实现视频解码。
在硬件中,通常可使用流水级的方式实现编码器。作为示例,图2是一个编码器的流水级的示意图。流水级一共分为了5级,分别是整像素搜索、分像素搜索、帧内预测、模式决策、熵编码和滤波。在流水级中,当第N+2个图像块在进行整像素搜索时,第N+1个图像块进行分像素搜索,第N个图像块进行帧内预测。
需要说明的是,图2仅为示意,实际上,可同时对更多的图像块(如5个块)进行并行处理,也可采用其他划分方式设定流水级。
由于视频编码过程需要使用编码单元进行预测,并使用变换单元进行量化和编码等操作,因而通常需要选取最优的编码单元和变换单元的组合。现有技术通常通过遍历编码单元和变换单元的全部组合的方式,确定出最优编码单元和最优变换单元。由于编码单元和变换单元均具有多种划分方式,因而此过程导致计算复杂度较大,决策效率较低,进一步编码器的复杂度较高。因此,亟待寻找一种能够降低计算复杂度,从而提升决策效率以及降低编码器的复杂度的方法。
请参考图3,其示出了根据本申请的编码方法的流程图。该编码方法的执行主体可以为能够进行视频编码的各种电子设备。例如手机、平板电脑、膝上便携式计算机、台式计算机、服务器等。
该编码方法的流程包括以下步骤:
步骤301,通过运动搜索确定编码树单元的最优编码单元。
根据本申请的一实施方式,所述通过运动搜索确定编码树单元的最优编码单元,包括:分别按照不同尺度对编码树单元进行编码单元划分,得到编码单元集合;从所述编码单元集合中选取部分编码单元,并通过运动搜索确定所选取的各编码单元的编码代价;基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。所述通过运动搜索确定编码树单元的最优编码单元,包括:分别按照不同尺度对编码树单元进行编码单元划分;通过运动搜索确定划分后的各编码单元的编码代价;基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。其中,运动搜索包括整像素搜索和/或分像素搜索。需要说明的是,在通过运动搜索确定编码树单元的最优编码单元之前,可以获取待编码的视频帧,并且按照预设尺寸对所述视频帧进行编码树单元划分。
根据本申请的一实施例,可以通过整像素搜索确定编码树单元的最优编码单元。
在本实施例中,编码方法的执行主体(如上述电子设备)可以通过运动搜索(例如,整像 素搜索和/或分像素搜索)确定出确定编码树单元的最优编码单元。其中,编码树单元可以预先通过获取待编码的视频帧并按照预设尺寸(如64×64)对上述视频帧进行编码树单元划分得到。
整像素搜索也可称为整像素运动估计,是一种运动估计方式,是视频压缩处理***中的一个重要组成部分。由于当前待编码图像中的景物与邻近帧中的景物存在着一定的相关性,因而可搜索出当前待编码图像中的每个图像块在邻近帧中的最佳匹配位置,并得出两者之间的空间位置的相对偏移量(即运动矢量),此过程即为运动估计。该最佳匹配位置对应的图像块即为预测图像块。以整像素位置作为搜索位置的运动估计,即为整像素搜索。
在本实施例中,在整像素搜索阶段,上述执行主体可以首先按照不同尺度将编码树单元划分成编码单元,而后对其中的部分或全部编码单元进行整像素搜索,之后基于整像素搜索结果所得到的预测图像块,即可确定出相应的编码单元的编码代价。编码代价可用于评价编码单元的优劣,编码代价越小,则编码单元越优,使用此编码单元进行编码的编码效果越优。由此可选取使编码代价最小的编码单元划分方式。此时的编码单元划分方式即为最优的编码单元划分方式,按照此划分方式进行编码树单元划分,即可得到最优编码单元。
需要说明的是,运动估计过程中,在执行整像素搜索后,还可以进行分像素搜索。分像素搜索也可称为分像素运动估计、亚像素搜索、亚像素运动估计。整像素搜索所搜索到的当前待编码块的最佳匹配位置为整像素位置。通过分像素搜索,可对整像素搜索得到在最佳匹配位置所在邻域进行插值,如对1/2像素点进行插值,从而从中选取最优的1/2像素点作为新的最佳匹配位置。进一步地,还可以继续进行1/4分像素搜索和1/8分像素搜索。最终所得到的最佳的匹配位置与当前待编码块之前的位置偏移即为最终的最佳运动矢量。在整像素搜索后进行分像素搜索,可提高提高运动搜索的精度,从而提高编码的性能。
由于分像素搜索仅在整像素搜索的结果上起到微调的作用,因而分像素搜索过程通常不会对整像素搜索过程中确定出的最优编码单元的划分方式产生影响。也就是说,仅在整像素搜索过程中确定编码树单元的最优编码单元。同时,最优编码单元的决策在整像素搜索阶段进行无需考虑分像素搜索过程,相较于在分像素搜索阶段进行,能够提高最优编码单元的决策速度。此外,在整像素搜索过程中确定编码树单元的最优编码单元的方案可以减少分像素搜索的次数。
然而,本申请并非限于此。根据本申请的另一实施例,可以通过分像素搜索确定编码树单元的最优编码单元。
在本实施例中,编码方法的执行主体(如上述电子设备)可以通过分像素搜索确定出编码树单元的最优编码单元。其中,编码树单元可以预先通过获取待编码的视频帧并按照预设尺寸(如64×64)对上述视频帧进行编码树单元划分得到。
分像素搜索也可称为分像素运动估计,也是一种运动估计方式,并且也是视频压缩处理***中的一个重要组成部分。简单来说。以分像素位置作为搜索位置的运动估计,即为分像素搜索。
在本实施例中,在执行完整像素搜索之后,进入分像素搜索阶段。需要说明的是,在本实施例中,可以在执行整像素搜索时依据上述提到的方法确定关于编码树单元的较优编码单元;也可以在执行整像素搜索时暂时不确定关于编码树单元的最优编码单元。
若在整像素搜索阶段确定了关于编码树单元的较优编码单元,则在分像素搜索阶段,上述执行主体可以首先按照不同尺度将较优编码单元做进一步划分,而将较优编码单元划分为关于较优编码单元的子编码单元。进一步地,对部分子编码单元或全部子编码单元进行分像素搜索,之后基于分像素搜索结果所得到的预测图像块,即可确定出相应的编码单元的编码代价。编码代价可用于评价子编码单元的优劣,编码代价越小,则子编码单元越优,使用此子编码单元进行编码的编码效果越优。由此可选取使编码代价最小的子编码单元划分方式。此时的子编码单元划分方式即为最优的编码单元划分方式。通过在整像素搜索阶段得到较优编码单元,并且在分像素搜索阶段得到最优编码单元的方案,可以提高编码性能。
此外,若在整像素搜索阶段没有确定关于编码树单元的较优编码单元,而仅是在所有尺寸或部分尺寸的编码单元的基础上进行整像素搜索。然后,在对应这些尺寸的编码单元在分像素搜索阶段进一步进行分像素搜索。之后,基于分像素搜索结果所得到的预测图像块,即可确定出相应的编码单元的编码代价。编码代价可用于评价编码单元的优劣,编码代价越小,则编码单元越优,使用此编码单元进行编码的编码效果越优。由此可选取使编码代价最小的编码单元划分方式。此时的编码单元划分方式即为最优的编码单元划分方式。按照此划分方式进行编码树单元划分,即可得到最优编码单元。通过在分像素搜索阶段得到最优编码单元的方案,也可以提高编码性能。
在本实施例的一些可选的实现方式中,如图4所示,可按照如下子步骤S11至子步骤S13确定编码树单元的最优编码单元:
子步骤S11,分别按照不同尺度对编码树单元进行编码单元划分。
此处,可将编码树单元划分为长和宽相同的编码单元,尺度即为编码单元的长或宽。作为示例,图5示出了将编码树单元划分为编码单元的划分方式的示意图。如图5所示,编码树单元尺寸为64×64,可将编码树单元直接作为编码单元,此时编码单元的尺度为64。也可将其划分为4个32×32的编码单元,此时编码单元的尺度为32。也可将其划分为16个16×16的编码单元,此时编码单元的尺度为16。还可将其划分为64个8×8的编码单元,此时编码单元的尺度为8。且不限于上述列举。
可选的,可以以编码树单元的尺度作为第一最大尺度(可记为A),以预设数值(如2)的N次方作为除数,将第一最大尺度与该除数的商作为第一候选尺度(可记为B),分别对上述编码树单元按照至少一个第一候选尺度进行编码单元划分。即B=A/2 N。其中,N为非负整数。具体的,以A=64为例,当N=0时,B=64。当N=1时,B=32。当N=2时,B=16。当N=3时,B=8,以此类推。
子步骤S12,通过整像素搜索确定划分后的各编码单元的编码代价。
此处,可对划分后的各编码单元进行整像素搜索,并基于整像素搜索结果计算出各编码单元的编码代价。
作为示例,编码单元的编码代价可通过计算绝对误差和(Sum of Absolute Difference,SAD)的方式得到。编码代价越小,则最终的编码效果最优。具体的,对于每一个编码单元,在通过整像素搜索确定出的该编码单元的预测图像块后,可以计算该预测图像块与该编码单元中的各像素的绝对误差之和。之后,可以通过绝对误差和、运动矢量的编码比特数和率失真参数lambda来推导出编码单元的编码代价。即,编码代价C=绝对误差和SAD+率失真参数Lambda*运动矢量的编码比特数MVBits。其中,绝对误差是指测量值与真实值之差的绝对值,此处,对于每一个像素点,该像素点的绝对误差为该像素点在预测图像块与该编码单元中的像素值之差的绝对值。
作为又一示例,编码单元的编码代价可通过计算哈达玛积变换后的绝对值之和(Sum of Absolute Transformed Difference,SATD)的方式得到。编码代价越小,则最终的编码效果最优。具体的,对于每一个编码单元,在通过整像素搜索确定出的该编码单元的预测图像块后,即可计算该预测图像块与该编码单元的残差块。对该残差块进行哈达玛积变换,即可得到一个新的矩阵,对变换所得到的矩阵求其元素的绝对值之和。之后,可以通过哈达玛积变换后的绝对值之和、运动矢量的编码比特数和率失真参数lambda来推导出编码单元的编码代价。即,编码代价C=哈达玛积变换后的绝对值之和SATD+率失真参数Lambda*运动矢量的编码比特数MVBits。
在现有技术中,通常通过率失真优化(Rate Distortion Optimized,RDO)策略决策最优编码单元。率失真优化是在率失真理论的基础上提出的一种代价函数方案,率失真优化的主要思想是,在计算代价函数时,同时考虑码率和失真度两方面因素的制约,在保证低失真度的同时保证低 码率,这样更加有利于视频流的传输。由此,通过率失真优化决策最优编码单元,不仅需要考虑整像素搜索结果,还需要考虑编码后的码率。由于码率需要通过变换、量化以及熵编码过程才能得知,而变换、量化以及熵编码过程需要使用变换单元进行,因而现有技术需要遍历编码单元和变换单元的各种组合方式,从中选取最优组合方式,进而确定最优编码单元(以及最优变换单元),因而计算量较大,搜索效率较低。
本实施例中通过SAD或SATD来推导编码代价,仅通过整像素搜索结果即可计算出编码代价的值,无需考虑编码后的码率,因而编码单元决策过程无需进行变换单元的决策,更不需要考虑变换单元的划分以及编码单元和变换单元的组合,使得编码单元和变换单元的决策过程分离,从而降低了计算量,提高了搜索效率。
子步骤S13,基于确定出的各编码单元的编码代价,选取编码树单元的最优编码单元。
由于编码代价越小,最终的编码效果越优,因而可以选取编码代价总和最小的划分方式对应的编码单元,作为编码树单元的最优编码单元。
在一些可选的实现方式中,可以按照如下步骤选取最优编码单元:
第一步,按照从小到大的次序,对已确定出编码代价的编码单元的尺度进行排序,得到第一排序结果。
第二步,将以第一排序结果中的最小尺度划分的编码单元标记为最优编码单元,从第一排序结果中选择一个尺度作为第一目标尺度。
第三步,将以第一目标尺度划分的编码单元作为目标编码单元,分别确定目标编码单元的编码代价和目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和。
第四步,对于目标编码单元,若目标编码单元的编码代价小于或等于目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则将目标编码单元标记为最优编码单元。
其中,第二步中的从第一排序结果中选择一个尺度作为第一目标尺度,可以包括:从第一排序结果中的第二个尺度开始,依次选择第一排序结果中的一个尺度作为第一目标尺度,以用于选取编码树单元的最优编码单元,直到将第一排序结果中的最后一个尺寸作为第一目标尺寸为止。
其中,第四步中还可以包括:若目标编码单元的编码代价小于或等于目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则删除目标编码单元所包含的各编码单元的最优编码单元标记。
下面以一具体示例进行说明。
在该示例中,编码树单元的尺度为64×64。已确定出编码代价的编码单元的包括8×8的编码单元、16×16的编码单元、32×32的编码单元、64×64的编码单元,则第一排序结果依次为8、16、32、64。将以第一排序结果中的最小尺度8划分的编码单元标记为最优编码单元后,即可使8×8的编码单元均带有最优编码单元标记。以从第一排序结果中第二个尺度开始,依次选择第一排序结果中的一个尺度作为第一目标尺度为例,可在第一轮选择尺度16作为第一目标尺度,在第二轮选择32作为第一目标尺度,在第三轮选择64作为第一目标尺度。
在第一轮比对中,第一目标尺度为16,因而以第一目标尺度16划分的16×16的编码单元作为目标编码单元。每一个16×16的目标编码单元中,可包含4个带有最优编码单元标记的8×8的编码单元。可分别确定每一个16×16的目标编码单元的编码代价和该16×16的目标编码单元中所包含的带有最优编码单元标记的各编码单元(即4个8×8的编码单元)的编码代价总和。
对于每一个16×16的目标编码单元,若该16×16的目标编码单元的编码代价小于或等于该目标编码单元所包含的4个8×8的编码单元的编码代价之和,则意味着以该16×16的目标编码单元进行编码的效果优于以其所包含的4个8×8的编码单元进行编码的编码效果,因而此时可将该16×16的目标编码单元标记为最优编码单元。并可以删除该16×16的目标编码单元所包含 的各8×8的编码单元的最优编码单元标记,从而更新最优编码单元,以便于下一轮比对。反之,若该16×16的目标编码单元的编码代价大于该目标编码单元所包含的4个8×8的第一编码单元的编码代价之和,则意味着以该16×16的目标编码单元进行编码的效果劣于以其所包含的4个8×8的编码单元进行编码的编码效果,因而此时可仍使这4个8×8的编码单元持有最优编码单元编辑,即不进行任何操作。
在第二轮比对中,第一目标尺度为32,因而以第一目标尺度32划分的32×32的编码单元作为目标编码单元。可分别确定每一个32×32的目标编码单元的编码代价和该32×32的目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和。
对于每一个32×32的目标编码单元,若该32×32的目标编码单元的编码代价小于或等于该目标编码单元所包含的带有最优编码单元标记的各编码单元的编码代价总和,则意味着以该32×32的目标编码单元进行编码的效果优于以其所包含的带有最优编码单元标记的编码单元整体的编码效果,因而此时可将该32×32的目标编码单元标记为最优编码单元。并可以删除该32×32的目标编码单元所包含的各带有最优编码单元标记的编码单元的最优编码单元标记,从而更新最优编码单元,以便于下一轮比对。反之,若该32×32的目标编码单元的编码代价大于该目标编码单元所包含的带有最优编码单元标记的编码单元的编码代价总和,则意味着以该32×32的目标编码单元进行编码的效果劣于以其所包含的带有最优编码单元标记的编码单元的整体编码效果,因而此时可不进行任何操作。
下面以一具体示例进行说明第二轮的比对过程。若某一个32×32的目标编码单元(可记为CU 32)所在区域,可容纳4个16×16的编码单元,可分别记为CU 16-1、CU 16-2、CU 16-3、CU 16-4。其中,CU 16-1可容纳4个8×8的编码单元,分别记为CU 8-1-1、CU 8-1-2、CU 8-1-3、CU 8-1-4。CU 16-2可容纳4个8×8的编码单元,分别记为CU 8-2-1、CU 8-2-2、CU 8-2-3、CU 8-2-4。CU 16-3可容纳4个8×8的编码单元,分别记为CU 8-3-1、CU 8-3-2、CU 8-3-3、CU 8-3-4。CU 16-4可容纳4个8×8的编码单元,分别记为CU 8-4-1、CU 8-4-2、CU 8-4-3、CU 8-4-4
若在上一轮比对中,CU 16-1的编码代价大于CU 8-1-1、CU 8-1-2、CU 8-1-3、CU 8-1-4的编码代价之和,CU 16-2的编码代价小于或等于CU 8-2-1、CU 8-2-2、CU 8-2-3、CU 8-2-4的编码代价之和,CU 16-3的编码代价小于或等于CU 8-3-1、CU 8-3-2、CU 8-3-3、CU 8-3-4的编码代价之和,且CU 16-4的编码代价小于或等于CU 8-4-1、CU 8-4-2、CU 8-4-3、CU 8-4-4的编码代价之和,则CU 8-1-1、CU 8-1-2、CU 8-1-3、CU 8-1-4、CU 16-2、CU 16-3、CU 16-4均被标记为最优编码单元。此时,32×32的目标编码单元CU 32所在区域中包括上一轮确定出的三个带有最优编码单元标记的16×16的编码单元(分别为CU 16-2、CU 16-3、CU 16-4)和4个带有最优编码单元标记的8×8的编码单元(分别为CU 8-1-1、CU 8-1-2、CU 8-1-3、CU 8-1-4)。在第二轮比对中,可将32×32的目标编码单元CU 32的编码代价与CU 16-2、CU 16-3、CU 16-4、CU 8-1-1、CU 8-1-2、CU 8-1-3、CU 8-1-4的编码代价之和进行比较。若32×32的目标编码单元CU 32的编码代价小于或等于CU 16-2、CU 16-3、CU 16-4、CU 8-1-1、CU 8-1-2、CU 8-1-3、CU 8-1-4的编码代价之和,则意味着以该32×32的目标编码单元CU 32的编码效果优于上一轮确定出的该区域的最优编码单元的编码效果,因而此时可将该32×32的目标编码单元CU 32标记为最优编码单元,并删除CU 16-2、CU 16-3、CU 16-4、CU 8-1-1、CU 8-1-2、CU 8-1-3、CU 8-1-4的最优编码单元标记。反之,若32×32的目标编码单元CU 32的编码代价大于CU 16-2、CU 16-3、CU 16-4、CU 8-1-1、CU 8-1-2、CU 8-1-3、CU 8-1-4的编码代价之和,则意味着以该32×32的目标编码单元CU 32的编码效果劣于上一轮确定出的该区域的最优编码单元的编码效果,因而此时可不进行任何操作,即维持该区域内当前最优编码单元。其他的32×32的目标编码单元与上述过程类似,此处不再赘述。
在第三轮比对中,第一目标尺度为64,因而以第一目标尺度64划分的64×64的编码单元作为目标编码单元。可分别确定64×64的目标编码单元的编码代价和该64×64的目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和。
对于64×64的目标编码单元,若该64×64的目标编码单元的编码代价小于或等于该目标编 码单元所包含的带有最优编码单元标记的各编码单元的编码代价总和,则意味着以该64×64的目标编码单元进行编码的效果优于以其所包含的带有最优编码单元标记的编码单元整体的编码效果,因而此时可将该64×64的目标编码单元标记为最优编码单元。并可以删除该64×64的目标编码单元所包含的各带有最优编码单元标记的编码单元的最优编码单元标记,从而更新最优编码单元,以便于下一轮比对。反之,若该64×64的目标编码单元的编码代价大于该目标编码单元所包含的带有最优编码单元标记的编码单元的编码代价总和,则意味着以该64×64的目标编码单元进行编码的效果劣于以其所包含的带有最优编码单元标记的编码单元的整体编码效果,因而此时可不进行任何操作。第三轮比对与第二轮比对的过程类似,此处不再赘述。
按照尺度由小到大的次序进行编码单元的比对,可避免编码单元的重复比对,从而方便快捷地决策出最优编码单元。为便于理解,下面以一示例进行说明。若第一轮决策出16个16×16的编码单元均为最优编码单元,各个16×16的编码单元中的8×8的编码单元均不为最优编码单元,则在第二轮比对时,仅需对将每一个32×32的编码单元与其中所包含的4个16×16的编码单元进行比对,无需将该32×32的编码单元与其中的16个8×8的编码单元进行比对,也无需将该32×32的编码单元与其中的16×16的编码单元及8×8的编码单元的组合(如3个16×16的编码单元与4个8×8的编码单元的组合、2个16×16的编码单元与8个8×8的编码单元的组合、1个16×16的编码单元与12个8×8的编码单元的组合)进行对比。由此,可避免编码单元的重复比对,从而方便快捷地决策出最优编码单元。
如图6所示,图6示出了一个编码树单元划分为最优变换单元的示意图。该示意图中的编码树单元的尺度为64×64。该编码树单元可被划分为13个16×16的最优编码单元和12个8×8的最优变换单元。
在本实施例的一些可选的实现方式中,如图7所示,也可按照如下子步骤S21至子步骤S23确定编码树单元的最优编码单元:
子步骤S21,分别按照不同尺度对编码树单元进行编码单元划分,得到编码单元集合。
此处,按照不同尺度对编码树单元进行编码单元划分可参见子步骤S11。在划分后得到编码单元后,可将各编码单元进行汇总,即可得到编码单元集合。
子步骤S22,从编码单元集合中选取部分编码单元,并通过整像素搜索确定所选取的各编码单元的编码代价。
此处,可从编码单元集合中选取部分编码单元进行整像素搜索,并基于整像素搜索结果计算出所选取的各编码单元的编码代价。通过对部分编码单元而非全部编码进行整像素搜索,能够降低整像素搜索的数量,从而提高最优编码单元的决策效率。
子步骤S23,基于确定出的各编码单元的编码代价,选取编码树单元的最优编码单元。
由于编码代价越小,最终的编码效果越优,因而可以选取编码代价总和最小的划分方式对应的编码单元,作为编码树单元的最优编码单元。此步骤与上述步骤S13基本相似,可参见上述S13中的过程,此处不再赘述。
步骤302,确定最优编码单元的最优变换单元。
在本实施例中,上述执行主体仅需对最优编码单元的变换单元进行决策,确定该最优编码单元的最优变换单元。对于其他编码单元,则无需进行变换单元决策。由此,可大大降低变换单元决策过程的计算量,从而能够提升搜索效率。需要说明的是,确定最优编码单元的最优变换单元的操作是在率失真决策阶段进行的,并且率失真操作由率失真决策模块来执行。率失真决策阶段主要进行变换、量化、反变换、反量化、估计失真、以及编码比特的操作。运动搜索阶段主要进行帧间模式的编码单元决策。运动搜索和率失真决策分别属于不同的执行阶段。即,运动搜索操作和率失真决策操作属于不同的流水级。也就是说,通过运动搜索确定编码树单元的最优编码单元的步骤是由运动搜索模块来执行的,并且确定所述最优编码单元的最优变换单元的步骤是由率失真决策模块来执行的;其中,所述运动搜索模块和所述率失真决策模块分别 属于不同的流水级。
具体地,上述执行主体首先按照不同尺度将最优编码单元进行划分成变换单元,而后对其中的部分或全部变换单元进行编码代价计算,从中选取编码代价最小的变换单元划分方式。此时的变换单元划分方式即为最优的变换单元划分方式。按照此划分方式将最优编码单元进行划分,即可得到最优变换单元。
在本实施例的一些可选的实现方式中,如图8所示,可按照如下子步骤S31至子步骤S33确定最优编码树的最优变换单元:
子步骤S31,分别按照不同尺度对最优编码单元进行变换单元划分。
此处,与对编码树单元的划分方式类似,可将最优编码单元划分为长和宽相同的变换单元,上述尺度即为变换单元的长或宽。作为示例,某一最优编码单元尺寸为32×32,可将该最优编码单元直接作为变换单元,此时变换单元的尺度为32。也可将其划分为4个16×16的变换单元,此时变换单元的尺度为16。还可将其划分为16个8×8的变换单元,此时变换单元的尺度为8。作为又一示例,某一最优编码单元尺寸为16×16,可将该最优编码单元直接作为变换单元,此时变换单元的尺度为16。也可将其划分为4个8×8的变换单元,此时变换单元的尺度为8。
可选的,可以以最优编码单元的尺度作为第二最大尺度(可记为C),以预设数值(如2)的M次方作为除数,将第二最大尺度与该除数的商作为第二候选尺度(可记为D),分别对该最优编码单元按照至少一个第二候选尺度进行变换单元划分。即D=C/2 M。其中,M为非负整数。具体的,以C=32为例,当N=0时,D=32。当N=1时,D=16。当N=2时,D=8,以此类推。
可选的,不同尺寸的最优编码单元,可进行不同比例的划分。对于每一个最优编码单元,可以基于该最优编码单元的尺度,确定该最优编码单元的至少一个划分比例,并分别采用该最优编码单元的各划分比例,对该最优编码单元进行变换单元划分。例如,32×32的编码单元的划分比例可以是0.5和0.25,而16×16的编码单元的划分比例可以是1和0.5。对于32×32的编码单元来说,若划分比例为0.5,则将编码单元的长度或者宽度乘以0.5得到32×32的编码单元对应的变换单元的长度或宽度为16。因此,可以通过上述方法可以确定32×32的编码单元对应的变换单元的尺寸为16×16。对于32×32的编码单元来说,若划分比例为0.25,则将编码单元的长度或者宽度乘以0.25得到32×32的编码单元对应的变换单元的长度或宽度为8。因此,可以通过上述方法可以确定32×32的编码单元对应的变换单元的尺寸为8×8。同理,对于16×16的编码单元来说,若划分比例为1,则将编码单元的长度或者宽度乘以1得到16×16的编码单元对应的变换单元的长度或宽度为16。因此,可以通过上述方法可以确定16×16的编码单元对应的变换单元的尺寸为16×16。对于16×16的编码单元来说,若划分比例为0.5,则将编码单元的长度或者宽度乘以0.5得到16×16的编码单元对应的变换单元的长度或宽度为8。因此,可以通过上述方法可以确定16×16的编码单元对应的变换单元的尺寸为8×8。然而,本申请并非限于此。在一个实施方式中,可以分别针对编码单元的长和宽设置不同的划分比例。例如,对于32×32的编码单元来说,若对于长度的划分比例为0.5,对于宽度的划分比例为0.25,则将编码单元的长度乘以0.5,得到32×32的编码单元对应的变换单元的长度为16;或者将编码单元的宽度乘以0.25,得到32×32的编码单元对应的变换单元的长度或宽度为8。因此,可以通过上述方法可以确定32×32的编码单元对应的变换单元的尺寸为16×8。在另一实施方式中,也可以根据其他划分比例来得到的变换单元的其他尺寸。在又一实施方式中,可以预先定义不同尺寸的编码单元对应的变换单元的尺寸。
子步骤S32,采用率失真优化方式确定划分后的各变换单元的编码代价。
对于某一变换单元,在采用率失真优化方式确定该变换单元的编码代价时,可首先计算当前预测模式下的重建块与源图像的残差均方和,作为率失真优化计算中的失真量。而后,计算编码该变换单元所需要的比特数。最后,同时结合上述失真量和比特数,得到率失真优化的编码代价。编码代价越小,最终的编码效果越优秀。
子步骤S33,基于确定出的各变换单元的编码代价,选取最优编码单元的最优变换单元。
此处,确定基于确定出的各变换单元的编码代价选取最优编码单元的最优变换单元的方式,与子步骤S13中基于各编码单元的编码代价选取最优编码单元的的方式相似。由于编码代价越小,最终的编码效果越优,因而可以选取编码代价总和最小的划分方式对应的变换单元,作为最优编码单元的最优变换单元。
在一些可选的实现方式中,可以按照如下步骤选取最优变换单元:
第一步,按照从小到大的次序,对已确定出编码代价的变换单元的尺度进行排序,得到第二排序结果。
第二步,将以第二排序结果中的最小尺度划分的变换单元标记为最优变换单元,从第二排序结果中选择一个尺度作为第二目标尺度。
第三步,将以第二目标尺度划分的变换单元作为目标变换单元,分别确定目标变换单元的编码代价和目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和。
第四步,对于目标变换单元,若目标变换单元的编码代价小于或等于目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则将目标变换单元标记为最优变换单元。
其中,第二步中的从第二排序结果中选择一个尺度作为第二目标尺度,可以包括:从第二排序结果中的第二个尺度开始,依次选择第二排序结果中的一个尺度作为第二目标尺度,以用于选取编码树单元的最优变换单元,直到将第二排序结果中的最后一个尺寸作为第二目标尺寸为止。
其中,第四步中还可以包括:若目标变换单元的编码代价小于或等于目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则删除目标变换单元所包含的各变换单元的最优变换单元标记。
下面以一具体示例进行说明。
在该示例中,某一最优编码单元的尺度为32×32。已确定出编码代价的变换单元的包括8×8的变换单元、16×16的变换单元和32×32的变换单元,则第二排序结果依次为8、16、32。将以第二排序结果中的最小尺度8划分的变换单元标记为最优变换单元后,即可使8×8的变换单元均带有最优变换单元标记。以从第二排序结果中第二个尺度开始,依次选择第二排序结果中的一个尺度作为第二目标尺度为例,可在第二轮选择尺度16作为第二目标尺度,在第二轮选择32作为第二目标尺度。
在第二轮比对中,第二目标尺度为16,因而以第二目标尺度16划分的16×16的变换单元作为目标变换单元。每一个16×16的目标变换单元中,可包含4个带有最优变换单元标记的8×8的变换单元。可分别确定每一个16×16的目标变换单元的编码代价和该16×16的目标变换单元中所包含的带有最优变换单元标记的各变换单元(即4个8×8的变换单元)的编码代价总和。
对于每一个16×16的目标变换单元,若该16×16的目标变换单元的编码代价小于或等于该目标变换单元所包含的4个8×8的变换单元的编码代价之和,则意味着以该16×16的目标变换单元进行编码的效果优于以其所包含的4个8×8的变换单元进行编码的编码效果,因而此时可将该16×16的目标变换单元标记为最优变换单元。并可以删除该16×16的目标变换单元所包含的各8×8的变换单元的最优变换单元标记,从而更新最优变换单元,以便于下一轮比对。反之,若该16×16的目标变换单元的编码代价大于该目标变换单元所包含的4个8×8的第二变换单元的编码代价之和,则意味着以该16×16的目标变换单元进行编码的效果劣于以其所包含的4个8×8的变换单元进行编码的编码效果,因而此时可仍使这4个8×8的变换单元持有最优变换单元编辑,即不进行任何操作。
在第二轮比对中,第二目标尺度为32,因而以第二目标尺度32划分的32×32的变换单元作为目标变换单元。可分别确定每一个32×32的目标变换单元的编码代价和该32×32的目标变换 单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和。
对于每一个32×32的目标变换单元,若该32×32的目标变换单元的编码代价小于或等于该目标变换单元所包含的带有最优变换单元标记的各变换单元的编码代价总和,则意味着以该32×32的目标变换单元进行编码的效果优于以其所包含的带有最优变换单元标记的变换单元整体的编码效果,因而此时可将该32×32的目标变换单元标记为最优变换单元。并可以删除该32×32的目标变换单元所包含的各带有最优变换单元标记的变换单元的最优变换单元标记,从而更新最优变换单元,以便于下一轮比对。反之,若该32×32的目标变换单元的编码代价大于该目标变换单元所包含的带有最优变换单元标记的变换单元的编码代价总和,则意味着以该32×32的目标变换单元进行编码的效果劣于以其所包含的带有最优变换单元标记的变换单元的整体编码效果,因而此时可不进行任何操作。
下面以一具体示例进行说明第二轮的比对过程。若某一个32×32的目标变换单元(可记为TU 32)所在区域,可容纳4个16×16的变换单元,可分别记为TU 16-1、TU 16-2、TU 16-3、TU 16-4。其中,TU 16-1可容纳4个8×8的变换单元,分别记为TU 8-1-1、TU 8-1-2、TU 8-1-3、TU 8-1-4。TU 16-2可容纳4个8×8的变换单元,分别记为TU 8-2-1、TU 8-2-2、TU 8-2-3、TU 8-2-4。TU 16-3可容纳4个8×8的变换单元,分别记为TU 8-3-1、TU 8-3-2、TU 8-3-3、TU 8-3-4。TU 16-4可容纳4个8×8的变换单元,分别记为TU 8-4-1、TU 8-4-2、TU 8-4-3、TU 8-4-4
若在上一轮比对中,TU 16-1的编码代价大于TU 8-1-1、TU 8-1-2、TU 8-1-3、TU 8-1-4的编码代价之和,TU 16-2的编码代价小于或等于TU 8-2-1、TU 8-2-2、TU 8-2-3、TU 8-2-4的编码代价之和,TU 16-3的编码代价小于或等于TU 8-3-1、TU 8-3-2、TU 8-3-3、TU 8-3-4的编码代价之和,且TU 16-4的编码代价小于或等于TU 8-4-1、TU 8-4-2、TU 8-4-3、TU 8-4-4的编码代价之和,则TU 8-1-1、TU 8-1-2、TU 8-1-3、TU 8-1-4、TU 16-2、TU 16-3、TU 16-4均被标记为最优变换单元。此时,32×32的目标变换单元TU 32所在区域中包括上一轮确定出的三个带有最优变换单元标记的16×16的变换单元(分别为TU 16-2、TU 16-3、TU 16-4)和4个带有最优变换单元标记的8×8的变换单元(分别为TU 8-1-1、TU 8-1-2、TU 8-1-3、TU 8-1-4)。在第二轮比对中,可将32×32的目标变换单元TU 32的编码代价与TU 16-2、TU 16-3、TU 16-4、TU 8-1-1、TU 8-1-2、TU 8-1-3、TU 8-1-4的编码代价之和进行比较。若32×32的目标变换单元TU 32的编码代价小于或等于TU 16-2、TU 16-3、TU 16-4、TU 8-1-1、TU 8-1-2、TU 8-1-3、TU 8-1-4的编码代价之和,则意味着以该32×32的目标变换单元TU 32的编码效果优于上一轮确定出的该区域的最优变换单元的编码效果,因而此时可将该32×32的目标变换单元TU 32标记为最优变换单元,并删除TU 16-2、TU 16-3、TU 16-4、TU 8-1-1、TU 8-1-2、TU 8-1-3、TU 8-1-4的最优变换单元标记。反之,若32×32的目标变换单元TU 32的编码代价大于TU 16-2、TU 16-3、TU 16-4、TU 8-1-1、TU 8-1-2、TU 8-1-3、TU 8-1-4的编码代价之和,则意味着以该32×32的目标变换单元TU 32的编码效果劣于上一轮确定出的该区域的最优变换单元的编码效果,因而此时可不进行任何操作,即维持该区域内当前最优变换单元。其他的32×32的目标变换单元与上述过程类似,此处不再赘述。
按照尺度由小到大的次序进行变换单元的比对,可避免变换单元的重复比对,从而方便快捷地决策出最优变换单元。为便于理解,下面以一示例进行说明。若第一轮决策出16个16×16的变换单元均为最优变换单元,各个16×16的变换单元中的8×8的变换单元均不为最优变换单元,则在第二轮比对时,仅需对将32×32的变换单元与其中所包含的4个16×16的变换单元进行比对,无需将该32×32的变换单元与其中的16个8×8的变换单元进行比对,也无需将该32×32的变换单元与其中的16×16的变换单元及8×8的变换单元的组合(如3个16×16的变换单元与4个8×8的变换单元的组合、2个16×16的变换单元与8个8×8的变换单元的组合、1个16×16的变换单元与12个8×8的变换单元的组合)进行对比。由此,可避免变换单元的重复比对,从而方便快捷地决策出最优变换单元。
在本实施例的一些可选的实现方式中,如图9所示,可按照如下子步骤S41至子步骤S43确定最优编码树的最优变换单元:
子步骤S41,分别按照不同尺度对最优编码单元进行变换单元划分,得到变换单元集合。
此处,按照不同尺度对最优编码单元进行变换单元划分可参见子步骤S31。在划分后得到变换单元后,可将各变换单元进行汇总,即可得到变换单元集合。
子步骤S42,从变换单元集合中选取部分变换单元,并采用率失真优化方式确定所选取的各变换单元的编码代价。
此处,可从变换单元集合中选取部分变换单元进行编码代价计算。通过对部分变换单元而非全部变换进行编码代价计算,能够降低编码代价计算量,从而提高最优变换单元的决策效率。
子步骤S43,基于确定出的各变换单元的编码代价,选取最优编码单元的最优变换单元。
由于编码代价越小,最终的编码效果越优,因而可以选取编码代价总和最小的划分方式对应的变换单元,作为最优编码单元的最优变换单元。此步骤与上述步骤S33基本相似,可参见上述S33中的过程,此处不再赘述。
步骤303,基于最优变换单元对最优编码单元进行编码。
在本实施例中,由于在整像素搜索过程中已确定出最优编码过程的预测图像块,因而,可确定该预测图像块与最优编码单元的残差块。从而,以该最优编码单元的最优变换单元为单位,对上述残差块依次进行变换、量化和熵编码,对各个最优变换单元进行编码,从而汇总得到该最优编码单元的编码结果。
在本实施例的一些可选的实现方式中,上述执行主体可以首先对最优编码单元进行预测(如在整像素搜索的基础上进一步进行分像素搜索),得到上述最优编码单元的预测图像块。而后确定上述最优编码单元与上述预测图像块的残差块。之后,基于上述最优变换单元,对上述残差块依次进行变换、量化和熵编码,从而汇总得到该最优编码单元的编码结果。由此,加入了分像素搜索过程,可提升编码质量。
本申请的上述实施例提供的编码方法,首先通过整像素搜索确定编码树单元的最优编码单元;而后确定上述最优编码单元的最优变换单元;最后基于上述最优变换单元对上述最优编码单元进行编码,由于无需考虑非最优编码单元的变换单元划分,且无需对各个编码单元和变换单元进行组合,因而降低了决策最优编码单元和最优变换单元过程中的计算复杂度,提高了决策效率。
进一步参考图10,作为对上述各图所示方法的实现,本申请提供了一种编码装置的一个实施例,该装置实施例与上述方法实施例相对应。该电子设备可以各种电子设备中。
如图10所示,本实施例所述的编码装置1000包括:第一确定单元1001,被配置成通过运动搜索确定编码树单元的最优编码单元;第二确定单元,1002被配置成确定所述最优编码单元的最优变换单元;编码单元1003,被配置成基于所述最优变换单元对所述最优编码单元进行编码。
根据本申请的一实施方式,所述第一确定单元,进一步被配置成:分别按照不同尺度对编码树单元进行编码单元划分,得到编码单元集合;从所述编码单元集合中选取部分编码单元,并通过所述运动搜索确定所选取的各编码单元的编码代价;基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。所述第一确定单元,进一步被配置成:分别按照不同尺度对编码树单元进行编码单元划分;通过所述运动搜索确定划分后的各编码单元的编码代价;基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。其中,运动搜索包括整像素搜索和/或分像素搜索。在本实施例的一些可选的实现方式中,所述第一确定单元1001,进一步被配置成:分别按照不同尺度对编码树单元进行编码单元划分,得到编码单元集合;从所述编码单元集合中选取部分编码单元,并通过整像素搜索确定所选取的各编码单元的编码代价;基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
然而,本申请并非限于此。在本实施例的一些可选的实现方式中,可以通过分像素搜索确 定编码树单元的最优编码单元。所述第一确定单元1001,进一步被配置成:分别按照不同尺度对编码树单元进行编码单元划分,得到编码单元集合;从所述编码单元集合中选取部分编码单元,并通过分像素搜索确定所选取的各编码单元(或各子编码单元)的编码代价;基于确定出的各编码单元(或各子编码单元)的编码代价,选取所述编码树单元的最优编码单元。
在一个实施方式中,所述第一确定单元1001,进一步被配置成:在执行完整像素搜索之后,执行分像素搜索。需要说明的是,在本实施例中,可以在执行整像素搜索时依据上述提到的方法确定关于编码树单元的较优编码单元;也可以在执行整像素搜索时暂时不确定关于编码树单元的最优编码单元。
若在整像素搜索阶段确定了关于编码树单元的较优编码单元,则在分像素搜索阶段,上述执行主体可以首先按照不同尺度将较优编码单元做进一步划分,而将较优编码单元划分为关于较优编码单元的子编码单元。进一步地,对部分子编码单元或全部子编码单元进行分像素搜索,之后基于分像素搜索结果所得到的预测图像块,即可确定出相应的编码单元的编码代价。编码代价可用于评价子编码单元的优劣,编码代价越小,则子编码单元越优,使用此子编码单元进行编码的编码效果越优。由此可选取使编码代价最小的子编码单元划分方式。此时的子编码单元划分方式即为最优的编码单元划分方式。通过在整像素搜索阶段得到较优编码单元,并且在分像素搜索阶段得到最优编码单元的方案,可以提高编码性能。
此外,若在整像素搜索阶段没有确定关于编码树单元的较优编码单元,而仅是在所有尺寸或部分尺寸的编码单元的基础上进行整像素搜索。然后,在对应这些尺寸的编码单元在分像素搜索阶段进一步进行分像素搜索。之后,基于分像素搜索结果所得到的预测图像块,即可确定出相应的编码单元的编码代价。编码代价可用于评价编码单元的优劣,编码代价越小,则编码单元越优,使用此编码单元进行编码的编码效果越优。由此可选取使编码代价最小的编码单元划分方式。此时的编码单元划分方式即为最优的编码单元划分方式。按照此划分方式进行编码树单元划分,即可得到最优编码单元。通过在分像素搜索阶段得到最优编码单元的方案,也可以提高编码性能。
在本实施例的一些可选的实现方式中,所述第一确定单元1001为运动搜索模块,并且所述第二确定单元1002为率失真决策模块;其中,所述运动搜索模块1001和所述率失真决策模块1002位于不同的流水级中。
在本实施例的一些可选的实现方式中,所述第一确定单元1001,进一步被配置成:分别按照不同尺度对编码树单元进行编码单元划分;通过整像素搜索确定划分后的各编码单元的编码代价;基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
在本实施例的一些可选的实现方式中,所述第二确定单元1002,进一步被配置成:分别按照不同尺度对所述最优编码单元进行变换单元划分,得到变换单元集合;从所述变换单元集合中选取部分变换单元,并采用率失真优化方式确定所选取的各变换单元的编码代价;基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
在本实施例的一些可选的实现方式中,所述第二确定单元1002,进一步被配置成:分别按照不同尺度对所述最优编码单元进行变换单元划分;采用率失真优化方式确定划分后的各变换单元的编码代价;基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
在本实施例的一些可选的实现方式中,所述编码单元1003,进一步被配置成:对所述最优编码单元进行预测,得到所述最优编码单元的预测图像块;确定所述最优编码单元与所述预测图像块的残差块;基于所述最优变换单元,对所述残差块依次进行变换、量化和熵编码。
在本实施例的一些可选的实现方式中,所述第一确定单元1001,进一步被配置成:以所述编码树单元的尺度作为第一最大尺度,以预设数值的N次方作为除数,将所述第一最大尺度与所述除数的商作为第一候选尺度,分别对所述编码树单元按照至少一个第一候选尺度进行编码 单元划分;其中,N为非负整数。
在本实施例的一些可选的实现方式中,编码单元的编码代价包括以下至少一项:绝对误差和、哈达玛积变换后的绝对值之和。
在本实施例的一些可选的实现方式中,所述第一确定单元1001,进一步被配置成:按照从小到大的次序,对已确定出编码代价的编码单元的尺度进行排序,得到第一排序结果;将以所述第一排序结果中的最小尺度划分的编码单元标记为最优编码单元,从所述第一排序结果中选择一个尺度作为第一目标尺度;将以所述第一目标尺度划分的编码单元作为目标编码单元,分别确定所述目标编码单元的编码代价和所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和;以及若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则将所述目标编码单元标记为最优编码单元。
在本实施例的一些可选的实现方式中,所述第一确定单元1001,进一步被配置成:从所述第一排序结果中的第二个尺度开始,依次选择所述第一排序结果中的一个尺度作为所述第一目标尺度,以用于选取所述编码树单元的最优编码单元,直到将所述第一排序结果中的最后一个尺寸作为第一目标尺寸为止。
在本实施例的一些可选的实现方式中,所述第一确定单元1001,进一步被配置成:若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则删除所述目标编码单元所包含的各编码单元的最优编码单元标记。
在本实施例的一些可选的实现方式中,所述第二确定单元1002,进一步被配置成:以所述最优编码单元的尺度作为第二最大尺度,以预设数值的M次方作为除数,将所述第二最大尺度与所述除数的商作为第二候选尺度,对所述最优编码单元按照至少一个第二候选尺度进行变换单元划分;其中,M为非负整数。
在本实施例的一些可选的实现方式中,所述第二确定单元1002,进一步被配置成:对于每一个最优编码单元,基于该最优编码单元的尺度,确定该最优编码单元的至少一个划分比例,并分别采用该最优编码单元的各划分比例,对该最优编码单元进行变换单元划分。
在本实施例的一些可选的实现方式中,所述第二确定单元1002,进一步被配置成:按照从小到大的次序,对已确定出编码代价的变换单元的尺度进行排序,得到第二排序结果;将以所述第二排序结果中的最小尺度划分的变换单元标记为最优变换单元,从所述第二排序结果中选择一个尺度作为第二目标尺度;将以所述第二目标尺度划分的变换单元作为目标变换单元,分别确定所述目标变换单元的编码代价和所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和;以及若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则将所述目标变换单元标记为最优变换单元。
在本实施例的一些可选的实现方式中,所述第二确定单元1002,进一步被配置成:从所述第二排序结果中的第二个尺度开始,依次选择所述第二排序结果中的一个尺度作为所述第二目标尺度,以用于选取所述编码树单元的最优变换单元,直到将所述第二排序结果中的最后一个尺寸作为第二目标尺寸为止。
在本实施例的一些可选的实现方式中,所述第二确定单元1002,进一步被配置成:若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则删除所述目标变换单元所包含的各变换单元的最优变换单元标记。
在本实施例的一些可选的实现方式中,上述装置还包括:获取单元,被配置成获取待编码的视频帧;划分单元,被配置成按照预设尺寸对所述视频帧进行编码树单元划分。
本申请的上述实施例提供的编码装置,首先通过整像素搜索确定编码树单元的最优编码单元;而后确定所述最优编码单元的最优变换单元;最后基于所述最优变换单元对所述最优编码 单元进行编码,由于无需考虑非最优编码单元的变换单元划分,且无需对各个编码单元和变换单元进行组合,因而降低了决策最优编码单元和最优变换单元过程中的计算复杂度,提高了决策效率。
请参见图11,作为对上述图1所示方法的实现,本申请提供了一种电子设备的一个实施例,该实施例与上述方法实施例相对应。该电子设备具体可以包括:处理器1101和存储器1102。
上述存储器1101,可以用于存储程序指令。
上述处理器1102,可以用于执行上述存储器存储的程序指令,当程序指令被执行时,上述处理器可以用于执行如下步骤:通过运动搜索确定编码树单元的最优编码单元;确定所述最优编码单元的最优变换单元;基于所述最优变换单元对所述最优编码单元进行编码。
可选的,所述通过运动搜索确定编码树单元的最优编码单元,包括:分别按照不同尺度对编码树单元进行编码单元划分,得到编码单元集合;从所述编码单元集合中选取部分编码单元,并通过运动搜索确定所选取的各编码单元的编码代价;基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
可选的,所述通过运动搜索确定编码树单元的最优编码单元,包括:分别按照不同尺度对编码树单元进行编码单元划分;通过运动搜索确定划分后的各编码单元的编码代价;基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
可选的,所述确定所述最优编码单元的最优变换单元,包括:分别按照不同尺度对所述最优编码单元进行变换单元划分,得到变换单元集合;从所述变换单元集合中选取部分变换单元,并采用率失真优化方式确定所选取的各变换单元的编码代价;基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
可选的,所述确定所述最优编码单元的最优变换单元,包括:分别按照不同尺度对所述最优编码单元进行变换单元划分;采用率失真优化方式确定划分后的各变换单元的编码代价;基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
可选的,所述基于所述最优变换单元对所述最优编码单元进行编码,包括:对所述最优编码单元进行预测,得到所述最优编码单元的预测图像块;确定所述最优编码单元与所述预测图像块的残差块;基于所述最优变换单元,对所述残差块依次进行变换、量化和熵编码。
可选的,所述分别按照不同尺度对编码树单元进行编码单元划分,包括:以所述编码树单元的尺度作为第一最大尺度,以预设数值的N次方作为除数,将所述第一最大尺度与所述除数的商作为第一候选尺度,分别对所述编码树单元按照至少一个第一候选尺度进行编码单元划分;其中,N为非负整数。
可选的,编码单元的编码代价包括以下至少一项:绝对误差和、哈达玛积变换后的绝对值之和。
可选的,所述基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元,包括:按照从小到大的次序,对已确定出编码代价的编码单元的尺度进行排序,得到第一排序结果;将以所述第一排序结果中的最小尺度划分的编码单元标记为最优编码单元,从所述第一排序结果中选择一个尺度作为第一目标尺度;将以所述第一目标尺度划分的编码单元作为目标编码单元,分别确定所述目标编码单元的编码代价和所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和;以及若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则将所述目标编码单元标记为最优编码单元。
可选的,所述从所述第一排序结果中选择一个尺度作为第一目标尺度,包括:从所述第一排序结果中的第二个尺度开始,依次选择所述第一排序结果中的一个尺度作为所述第一目标尺度,以用于选取所述编码树单元的最优编码单元,直到将所述第一排序结果中的最后一个尺寸 作为第一目标尺寸为止。
可选的,所述基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元,还包括:若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则删除所述目标编码单元所包含的各编码单元的最优编码单元标记。
可选的,所述分别按照不同尺度对所述最优编码单元进行变换单元划分,包括:以所述最优编码单元的尺度作为第二最大尺度,以预设数值的M次方作为除数,将所述第二最大尺度与所述除数的商作为第二候选尺度,分别对所述最优编码单元按照至少一个第二候选尺度进行变换单元划分;其中,M为非负整数。
可选的,所述分别按照不同尺度对所述最优编码单元进行变换单元划分,包括:对于每一个最优编码单元,基于该最优编码单元的尺度,确定该最优编码单元的至少一个划分比例,并分别采用该最优编码单元的各划分比例,对该最优编码单元进行变换单元划分。
可选的,所述基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元,包括:按照从小到大的次序,对已确定出编码代价的变换单元的尺度进行排序,得到第二排序结果;将以所述第二排序结果中的最小尺度划分的变换单元标记为最优变换单元,从所述第二排序结果中选择一个尺度作为第二目标尺度;将以所述第二目标尺度划分的变换单元作为目标变换单元,分别确定所述目标变换单元的编码代价和所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和;以及若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则将所述目标变换单元标记为最优变换单元。
可选的,所述从所述第二排序结果中选择一个尺度作为第二目标尺度,包括:从所述第二排序结果中的第二个尺度开始,依次选择所述第二排序结果中的一个尺度作为所述第二目标尺度,以用于选取所述编码树单元的最优变换单元,直到将所述第二排序结果中的最后一个尺寸作为第二目标尺寸为止。
可选的,所述基于确定出的各变换单元的编码代价,选取所述编码树单元的最优变换单元,还包括:若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则删除所述目标变换单元所包含的各变换单元的最优变换单元标记。
可选的,所述处理器还用于执行如下步骤:获取待编码的视频帧;按照预设尺寸对所述视频帧进行编码树单元划分。
可选的,所述通过运动搜索确定编码树单元的最优编码单元的步骤是由运动搜索模块来执行的,并且所述确定所述最优编码单元的最优变换单元的步骤是由率失真决策模块来执行的;其中,所述运动搜索模块和所述率失真决策模块分别属于不同的流水级。运动搜索包括整像素搜索和/或分像素搜索。
本申请的上述实施例所提供的电子设备,首先通过整像素搜索确定编码树单元的最优编码单元;而后确定所述最优编码单元的最优变换单元;最后基于所述最优变换单元对所述最优编码单元进行编码,由于无需考虑非最优编码单元的变换单元划分,且无需对各个编码单元和变换单元进行组合,因而降低了决策最优编码单元和最优变换单元过程中的计算复杂度,提高了决策效率。
对于电子设备实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。
本申请实施例还提供一种计算机可读介质,计算机可读介质上存储有计算机程序,该计算机程序被处理器执行时实现上述编码方法的实施例的各个过程,且能达到相同的技术效果。为 避免重复,该计算机程序被处理器执行时实现上述各方法的实施例的各个过程,这里不再赘述。
本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。
本领域内的技术人员应明白,本申请的实施例可提供为方法、装置、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可读介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请的方法、终端设备(***)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理终端设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理终端设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理终端设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理终端设备上,使得在计算机或其他可编程终端设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程终端设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
尽管已描述了本申请的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例做出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本申请范围的所有变更和修改。
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者终端设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者终端设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、物品或者终端设备中还存在另外的相同要素。
以上对本申请所提供的…方法、装置、电子设备和计算机可读介质,进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本申请的限制。

Claims (58)

  1. 一种编码方法,其特征在于,所述方法包括:
    通过运动搜索确定编码树单元的最优编码单元;
    确定所述最优编码单元的最优变换单元;
    基于所述最优变换单元对所述最优编码单元进行编码。
  2. 根据权利要求1所述的方法,其特征在于,所述通过所述运动搜索确定编码树单元的最优编码单元,包括:
    分别按照不同尺度对编码树单元进行编码单元划分,得到编码单元集合;
    从所述编码单元集合中选取部分编码单元,并通过所述运动搜索确定所选取的各编码单元的编码代价;
    基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
  3. 根据权利要求1所述的方法,其特征在于,所述通过所述运动搜索确定编码树单元的最优编码单元,包括:
    分别按照不同尺度对编码树单元进行编码单元划分;
    通过所述运动搜索确定划分后的各编码单元的编码代价;
    基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
  4. 根据权利要求1所述的方法,其特征在于,所述确定所述最优编码单元的最优变换单元,包括:
    分别按照不同尺度对所述最优编码单元进行变换单元划分,得到变换单元集合;
    从所述变换单元集合中选取部分变换单元,并采用率失真优化方式确定所选取的各变换单元的编码代价;
    基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
  5. 根据权利要求1所述的方法,其特征在于,所述确定所述最优编码单元的最优变换单元,包括:
    分别按照不同尺度对所述最优编码单元进行变换单元划分;
    采用率失真优化方式确定划分后的各变换单元的编码代价;
    基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
  6. 根据权利要求1所述的方法,其特征在于,所述基于所述最优变换单元对所述最优编码单元进行编码,包括:
    对所述最优编码单元进行预测,得到所述最优编码单元的预测图像块;
    确定所述最优编码单元与所述预测图像块的残差块;
    基于所述最优变换单元,对所述残差块依次进行变换、量化和熵编码。
  7. 根据权利要求2或3所述的方法,其特征在于,所述分别按照不同尺度对编码树单元进行编码单元划分,包括:
    以所述编码树单元的尺度作为第一最大尺度,以预设数值的N次方作为除数,将所述第一最大尺度与所述除数的商作为第一候选尺度,分别对所述编码树单元按照至少一个第一候选尺度进行编码单元划分;
    其中,N为非负整数。
  8. 根据权利要求2或3所述的方法,其特征在于,编码单元的编码代价包括以下至少一项:绝对误差和、哈达玛积变换后的绝对值之和。
  9. 根据权利要求2或3所述的方法,其特征在于,所述基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元,包括:
    按照从小到大的次序,对已确定出编码代价的编码单元的尺度进行排序,得到第一排序结果;
    将以所述第一排序结果中的最小尺度划分的编码单元标记为最优编码单元,从所述第一排序结果中选择一个尺度作为第一目标尺度;
    将以所述第一目标尺度划分的编码单元作为目标编码单元,分别确定所述目标编码单元的编码代价和所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和;以及
    若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则将所述目标编码单元标记为最优编码单元。
  10. 根据权利要求9所述的方法,其特征在于,所述从所述第一排序结果中选择一个尺度作为第一目标尺度,包括:
    从所述第一排序结果中的第二个尺度开始,依次选择所述第一排序结果中的一个尺度作为所述第一目标尺度,以用于选取所述编码树单元的最优编码单元,直到将所述第一排序结果中的最后一个尺寸作为第一目标尺寸为止。
  11. 根据权利要求9所述的方法,其特征在于,所述基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元,还包括:
    若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则删除所述目标编码单元所包含的各编码单元的最优编码单元标记。
  12. 根据权利要求4或5所述的方法,其特征在于,所述分别按照不同尺度对所述最优编码单元进行变换单元划分,包括:
    以所述最优编码单元的尺度作为第二最大尺度,以预设数值的M次方作为除数,将所述第二最大尺度与所述除数的商作为第二候选尺度,分别对所述最优编码单元按照至少一个第二候选尺度进行变换单元划分;
    其中,M为非负整数。
  13. 根据权利要求4或5所述的方法,其特征在于,所述分别按照不同尺度对所述最优编码单元进行变换单元划分,包括:
    对于每一个最优编码单元,基于该最优编码单元的尺度,确定该最优编码单元的至少一个划分比例,并分别采用该最优编码单元的各划分比例,对该最优编码单元进行变换单元划分。
  14. 根据权利要求4或5所述的方法,其特征在于,所述基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元,包括:
    按照从小到大的次序,对已确定出编码代价的变换单元的尺度进行排序,得到第二排序结 果;
    将以所述第二排序结果中的最小尺度划分的变换单元标记为最优变换单元,从所述第二排序结果中选择一个尺度作为第二目标尺度;
    将以所述第二目标尺度划分的变换单元作为目标变换单元,分别确定所述目标变换单元的编码代价和所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和;以及
    若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则将所述目标变换单元标记为最优变换单元。
  15. 根据权利要求14所述的方法,其特征在于,所述从所述第二排序结果中选择一个尺度作为第二目标尺度,包括:
    从所述第二排序结果中的第二个尺度开始,依次选择所述第二排序结果中的一个尺度作为所述第二目标尺度,以用于选取所述编码树单元的最优变换单元,直到将所述第二排序结果中的最后一个尺寸作为第二目标尺寸为止。
  16. 根据权利要求14所述的方法,其特征在于,所述基于确定出的各变换单元的编码代价,选取所述编码树单元的最优变换单元,还包括:
    若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则删除所述目标变换单元所包含的各变换单元的最优变换单元标记。
  17. 根据权利要求1所述的方法,其特征在于,在所述通过所述运动搜索确定编码树单元的最优编码单元之前,所述方法还包括:
    获取待编码的视频帧;
    按照预设尺寸对所述视频帧进行编码树单元划分。
  18. 根据权利要求1所述的方法,其特征在于,所述运动搜索包括整像素搜索和/或分像素搜索。
  19. 根据权利要求1所述的方法,其特征在于,所述通过运动搜索确定编码树单元的最优编码单元的步骤是由运动搜索模块来执行的,并且所述确定所述最优编码单元的最优变换单元的步骤是由率失真决策模块来执行的;
    其中,所述运动搜索模块和所述率失真决策模块分别属于不同的流水级。
  20. 一种编码装置,其特征在于,所述装置包括:
    第一确定单元,被配置成通过运动搜索确定编码树单元的最优编码单元;
    第二确定单元,被配置成确定所述最优编码单元的最优变换单元;
    编码单元,被配置成基于所述最优变换单元对所述最优编码单元进行编码。
  21. 根据权利要求20所述的装置,其特征在于,所述第一确定单元,进一步被配置成:
    分别按照不同尺度对编码树单元进行编码单元划分,得到编码单元集合;
    从所述编码单元集合中选取部分编码单元,并通过所述运动搜索确定所选取的各编码单元的编码代价;
    基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
  22. 根据权利要求20所述的装置,其特征在于,所述第一确定单元,进一步被配置成:
    分别按照不同尺度对编码树单元进行编码单元划分;
    通过所述运动搜索确定划分后的各编码单元的编码代价;
    基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
  23. 根据权利要求20所述的装置,其特征在于,所述第二确定单元,进一步被配置成:
    分别按照不同尺度对所述最优编码单元进行变换单元划分,得到变换单元集合;
    从所述变换单元集合中选取部分变换单元,并采用率失真优化方式确定所选取的各变换单元的编码代价;
    基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
  24. 根据权利要求20所述的装置,其特征在于,所述第二确定单元,进一步被配置成:
    分别按照不同尺度对所述最优编码单元进行变换单元划分;
    采用率失真优化方式确定划分后的各变换单元的编码代价;
    基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
  25. 根据权利要求20所述的装置,其特征在于,所述编码单元,进一步被配置成:
    对所述最优编码单元进行预测,得到所述最优编码单元的预测图像块;
    确定所述最优编码单元与所述预测图像块的残差块;
    基于所述最优变换单元,对所述残差块依次进行变换、量化和熵编码。
  26. 根据权利要求21或22所述的装置,其特征在于,所述第一确定单元,进一步被配置成:
    以所述编码树单元的尺度作为第一最大尺度,以预设数值的N次方作为除数,将所述第一最大尺度与所述除数的商作为第一候选尺度,分别对所述编码树单元按照至少一个第一候选尺度进行编码单元划分;
    其中,N为非负整数。
  27. 根据权利要求21或22所述的装置,其特征在于,编码单元的编码代价包括以下至少一项:绝对误差和、哈达玛积变换后的绝对值之和。
  28. 根据权利要求21或22所述的装置,其特征在于,所述第一确定单元,进一步被配置成:
    按照从小到大的次序,对已确定出编码代价的编码单元的尺度进行排序,得到第一排序结果;
    将以所述第一排序结果中的最小尺度划分的编码单元标记为最优编码单元,从所述第一排序结果中选择一个尺度作为第一目标尺度;
    将以所述第一目标尺度划分的编码单元作为目标编码单元,分别确定所述目标编码单元的编码代价和所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和;以及
    若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则将所述目标编码单元标记为最优编码单元。
  29. 根据权利要求28所述的装置,其特征在于,所述第一确定单元,进一步被配置成:
    从所述第一排序结果中的第二个尺度开始,依次选择所述第一排序结果中的一个尺度作为所述第一目标尺度,以用于选取所述编码树单元的最优编码单元,直到将所述第一排序结果中的最后一个尺寸作为第一目标尺寸为止。
  30. 根据权利要求28所述的装置,其特征在于,所述第一确定单元,进一步被配置成:
    若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则删除所述目标编码单元所包含的各编码单元的最优编码单元标记。
  31. 根据权利要求23或24所述的装置,其特征在于,所述第二确定单元,进一步被配置成:
    以所述最优编码单元的尺度作为第二最大尺度,以预设数值的M次方作为除数,将所述第二最大尺度与所述除数的商作为第二候选尺度,对所述最优编码单元按照至少一个第二候选尺度进行变换单元划分;
    其中,M为非负整数。
  32. 根据权利要求23或24所述的装置,其特征在于,所述第二确定单元,进一步被配置成:
    对于每一个最优编码单元,基于该最优编码单元的尺度,确定该最优编码单元的至少一个划分比例,并分别采用该最优编码单元的各划分比例,对该最优编码单元进行变换单元划分。
  33. 根据权利要求23或24所述的装置,其特征在于,所述第二确定单元,进一步被配置成:
    按照从小到大的次序,对已确定出编码代价的变换单元的尺度进行排序,得到第二排序结果;
    将以所述第二排序结果中的最小尺度划分的变换单元标记为最优变换单元,从所述第二排序结果中选择一个尺度作为第二目标尺度;
    将以所述第二目标尺度划分的变换单元作为目标变换单元,分别确定所述目标变换单元的编码代价和所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和;以及
    若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则将所述目标变换单元标记为最优变换单元。
  34. 根据权利要求33所述的装置,其特征在于,所述第二确定单元,进一步被配置成:
    从所述第二排序结果中的第二个尺度开始,依次选择所述第二排序结果中的一个尺度作为所述第二目标尺度,以用于选取所述编码树单元的最优变换单元,直到将所述第二排序结果中的最后一个尺寸作为第二目标尺寸为止。
  35. 根据权利要求33所述的装置,其特征在于,所述第二确定单元,进一步被配置成:
    若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则删除所述目标变换单元所包含的各变换单元的最优变换单元标记。
  36. 根据权利要求20所述的装置,其特征在于,所述装置还包括:
    获取单元,被配置成获取待编码的视频帧;
    划分单元,被配置成按照预设尺寸对所述视频帧进行编码树单元划分。
  37. 根据权利要求20所述的装置,其特征在于,所述运动搜索包括整像素搜索和/或分像素搜索。
  38. 根据权利要求20所述的装置,其特征在于,所述第一确定单元为运动搜索模块,并且所述第二确定单元为率失真决策模块;其中,所述运动搜索模块和所述率失真决策模块位于不同的流水级中。
  39. 一种电子设备,其特征在于,包括:处理器和存储器;
    所述存储器,用于存储程序指令;
    所述处理器,执行所述存储器存储的程序指令,当程序指令被执行时,所述处理器用于执行如下步骤:
    通过运动搜索确定编码树单元的最优编码单元;
    确定所述最优编码单元的最优变换单元;
    基于所述最优变换单元对所述最优编码单元进行编码。
  40. 根据权利要求39所述的电子设备,其特征在于,所述通过运动搜索确定编码树单元的最优编码单元,包括:
    分别按照不同尺度对编码树单元进行编码单元划分,得到编码单元集合;
    从所述编码单元集合中选取部分编码单元,并通过运动搜索确定所选取的各编码单元的编码代价;
    基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
  41. 根据权利要求39所述的电子设备,其特征在于,所述通过运动搜索确定编码树单元的最优编码单元,包括:
    分别按照不同尺度对编码树单元进行编码单元划分;
    通过运动搜索确定划分后的各编码单元的编码代价;
    基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元。
  42. 根据权利要求39所述的电子设备,其特征在于,所述确定所述最优编码单元的最优变换单元,包括:
    分别按照不同尺度对所述最优编码单元进行变换单元划分,得到变换单元集合;
    从所述变换单元集合中选取部分变换单元,并采用率失真优化方式确定所选取的各变换单元的编码代价;
    基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
  43. 根据权利要求39所述的电子设备,其特征在于,所述确定所述最优编码单元的最优变换单元,包括:
    分别按照不同尺度对所述最优编码单元进行变换单元划分;
    采用率失真优化方式确定划分后的各变换单元的编码代价;
    基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元。
  44. 根据权利要求39所述的电子设备,其特征在于,所述基于所述最优变换单元对所述最优编码单元进行编码,包括:
    对所述最优编码单元进行预测,得到所述最优编码单元的预测图像块;
    确定所述最优编码单元与所述预测图像块的残差块;
    基于所述最优变换单元,对所述残差块依次进行变换、量化和熵编码。
  45. 根据权利要求40或41所述的电子设备,其特征在于,所述分别按照不同尺度对编码树单元进行编码单元划分,包括:
    以所述编码树单元的尺度作为第一最大尺度,以预设数值的N次方作为除数,将所述第一最大尺度与所述除数的商作为第一候选尺度,分别对所述编码树单元按照至少一个第一候选尺度进行编码单元划分;
    其中,N为非负整数。
  46. 根据权利要求40或41所述的电子设备,其特征在于,编码单元的编码代价包括以下至少一项:绝对误差和、哈达玛积变换后的绝对值之和。
  47. 根据权利要求40或41所述的电子设备,其特征在于,所述基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元,包括:
    按照从小到大的次序,对已确定出编码代价的编码单元的尺度进行排序,得到第一排序结果;
    将以所述第一排序结果中的最小尺度划分的编码单元标记为最优编码单元,从所述第一排序结果中选择一个尺度作为第一目标尺度;
    将以所述第一目标尺度划分的编码单元作为目标编码单元,分别确定所述目标编码单元的编码代价和所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和;以及
    若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则将所述目标编码单元标记为最优编码单元。
  48. 根据权利要求47所述的电子设备,其特征在于,所述从所述第一排序结果中选择一个尺度作为第一目标尺度,包括:
    从所述第一排序结果中的第二个尺度开始,依次选择所述第一排序结果中的一个尺度作为所述第一目标尺度,以用于选取所述编码树单元的最优编码单元,直到将所述第一排序结果中的最后一个尺寸作为第一目标尺寸为止。
  49. 根据权利要求47所述的电子设备,其特征在于,所述基于确定出的各编码单元的编码代价,选取所述编码树单元的最优编码单元,还包括:
    若所述目标编码单元的编码代价小于或等于所述目标编码单元中所包含的带有最优编码单元标记的各编码单元的编码代价总和,则删除所述目标编码单元所包含的各编码单元的最优编码单元标记。
  50. 根据权利要求42或43所述的电子设备,其特征在于,所述分别按照不同尺度对所述最优编码单元进行变换单元划分,包括:
    以所述最优编码单元的尺度作为第二最大尺度,以预设数值的M次方作为除数,将所述第二最大尺度与所述除数的商作为第二候选尺度,对所述最优编码单元按照至少一个第二候选尺 度进行变换单元划分;
    其中,M为非负整数。
  51. 根据权利要求42或43所述的电子设备,其特征在于,所述分别按照不同尺度对所述最优编码单元进行变换单元划分,包括:
    对于每一个最优编码单元,基于该最优编码单元的尺度,确定该最优编码单元的至少一个划分比例,并分别采用该最优编码单元的各划分比例,对该最优编码单元进行变换单元划分。
  52. 根据权利要求42或43所述的电子设备,其特征在于,所述基于确定出的各变换单元的编码代价,选取所述最优编码单元的最优变换单元,包括:
    按照从小到大的次序,对已确定出编码代价的变换单元的尺度进行排序,得到第二排序结果;
    将以所述第二排序结果中的最小尺度划分的变换单元标记为最优变换单元,从所述第二排序结果中选择一个尺度作为第二目标尺度;
    将以所述第二目标尺度划分的变换单元作为目标变换单元,分别确定所述目标变换单元的编码代价和所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和;以及
    若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则将所述目标变换单元标记为最优变换单元。
  53. 根据权利要求52所述的电子设备,其特征在于,所述从所述第二排序结果中选择一个尺度作为第二目标尺度,包括:
    从所述第二排序结果中的第二个尺度开始,依次选择所述第二排序结果中的一个尺度作为所述第二目标尺度,以用于选取所述编码树单元的最优变换单元,直到将所述第二排序结果中的最后一个尺寸作为第二目标尺寸为止。
  54. 根据权利要求52所述的电子设备,其特征在于,所述基于确定出的各变换单元的编码代价,选取所述编码树单元的最优变换单元,还包括:
    若所述目标变换单元的编码代价小于或等于所述目标变换单元中所包含的带有最优变换单元标记的各变换单元的编码代价总和,则删除所述目标变换单元所包含的各变换单元的最优变换单元标记。
  55. 根据权利要求39所述的电子设备,其特征在于,所述处理器还用于执行如下步骤:
    获取待编码的视频帧;
    按照预设尺寸对所述视频帧进行编码树单元划分。
  56. 根据权利要求39所述的电子设备,其特征在于,所述运动搜索包括整像素搜索和/或分像素搜索。
  57. 根据权利要求39所述的电子设备,其特征在于,所述通过运动搜索确定编码树单元的最优编码单元的步骤是由运动搜索模块来执行的,并且所述确定所述最优编码单元的最优变换单元的步骤是由率失真决策模块来执行的;
    其中,所述运动搜索模块和所述率失真决策模块分别属于不同的流水级。
  58. 一种计算机可读介质,其特征在于,所述计算机可读介质中存储有计算机程序,所述计算机程序被处理器执行时实现如权利要求1-17中任一所述的方法。
PCT/CN2021/126836 2021-10-27 2021-10-27 编码方法、装置、电子设备和计算机可读介质 WO2023070403A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2021/126836 WO2023070403A1 (zh) 2021-10-27 2021-10-27 编码方法、装置、电子设备和计算机可读介质
CN202180102578.6A CN117981304A (zh) 2021-10-27 2021-10-27 编码方法、装置、电子设备和计算机可读介质

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2021/126836 WO2023070403A1 (zh) 2021-10-27 2021-10-27 编码方法、装置、电子设备和计算机可读介质

Publications (1)

Publication Number Publication Date
WO2023070403A1 true WO2023070403A1 (zh) 2023-05-04

Family

ID=86158760

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/126836 WO2023070403A1 (zh) 2021-10-27 2021-10-27 编码方法、装置、电子设备和计算机可读介质

Country Status (2)

Country Link
CN (1) CN117981304A (zh)
WO (1) WO2023070403A1 (zh)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102932642A (zh) * 2012-11-13 2013-02-13 北京大学 一种帧间编码快速模式选择方法
US20150055697A1 (en) * 2013-08-20 2015-02-26 Media Tek Inc. Method and Apparatus of Transform Process for Video Coding
CN104954787A (zh) * 2014-03-27 2015-09-30 浙江大华技术股份有限公司 Hevc帧间预测模式选择方法及装置
CN105516719A (zh) * 2014-09-26 2016-04-20 浙江大华技术股份有限公司 一种视频编码方法及装置
CN112954365A (zh) * 2021-04-11 2021-06-11 荆门汇易佳信息科技有限公司 Hevc帧间运动估算像素搜索改进方法
WO2021185022A1 (zh) * 2020-03-18 2021-09-23 百果园技术(新加坡)有限公司 编码模式的确定方法、装置、设备和存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102932642A (zh) * 2012-11-13 2013-02-13 北京大学 一种帧间编码快速模式选择方法
US20150055697A1 (en) * 2013-08-20 2015-02-26 Media Tek Inc. Method and Apparatus of Transform Process for Video Coding
CN104954787A (zh) * 2014-03-27 2015-09-30 浙江大华技术股份有限公司 Hevc帧间预测模式选择方法及装置
CN105516719A (zh) * 2014-09-26 2016-04-20 浙江大华技术股份有限公司 一种视频编码方法及装置
WO2021185022A1 (zh) * 2020-03-18 2021-09-23 百果园技术(新加坡)有限公司 编码模式的确定方法、装置、设备和存储介质
CN112954365A (zh) * 2021-04-11 2021-06-11 荆门汇易佳信息科技有限公司 Hevc帧间运动估算像素搜索改进方法

Also Published As

Publication number Publication date
CN117981304A (zh) 2024-05-03

Similar Documents

Publication Publication Date Title
TWI826519B (zh) 用於係數寫碼之規則寫碼位元子之減少
JP2023059946A (ja) 複数の参照線を用いたイントラ予測
JP4841101B2 (ja) 動き予測補償方法及び動き予測補償装置
TW202106019A (zh) 視訊寫碼中之矩陣內部預測參數之發信
JP5409909B2 (ja) ビットストリームを復号する方法
US11539952B2 (en) Implicit transform selection in video coding
CN103782597A (zh) 伴随有算术编码的对视频编码的方法和设备以及对视频解码的方法和设备
CN104994383A (zh) 用于视频解码的设备
CN103765893A (zh) 使用用于定点变换的比特深度调整的视频编码方法及其设备,以及视频解码方法及其设备
US11284105B2 (en) Data encoding and decoding
CN110383331A (zh) 非局部适应性环路滤波器处理
US20180199058A1 (en) Video encoding and decoding method and device
CN111316642A (zh) 信令图像编码和解码划分信息的方法和装置
TW202019173A (zh) 用於視訊寫碼中之適應性運動向量差解析度及增加的運動向量儲存精確度的運動向量捨位
TW202031049A (zh) 用於係數寫碼之規則寫碼位元子之減少
TW202032993A (zh) 用於係數位準之逃逸寫碼
US20200186835A1 (en) Computation of asymmetric transform pairs for video coding using adjustment stages and dct-2
JP6951324B2 (ja) 画像の符号化及び復号方法、画像の符号化及び復号デバイス、及びこれに対応するコンピュータプログラム
TW202002654A (zh) 具有群組分流位元子之係數寫碼
WO2023070403A1 (zh) 编码方法、装置、电子设备和计算机可读介质
JP6564315B2 (ja) 符号化装置、復号装置、及びプログラム
CN1848960A (zh) 使用非标准化矢量量化编码器的符合视频标准的残差编码
CN113115041A (zh) 支持alpha通道的无损图片压缩方法、装置及介质
US20240137524A1 (en) Bit-length control for linear regression-based affine merge candidate derivation
WO2022133664A1 (zh) 像素插值方法、装置、电子设备和计算机可读介质

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: 21961771

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 202180102578.6

Country of ref document: CN

NENP Non-entry into the national phase

Ref country code: DE