Coding method, encoder, device and storage medium based on inter-frame prediction
By combining inter prediction methods of small-range and large-range search templates, the motion vector search area is optimized, and the inter prediction accuracy and bit rate problems in the prior art are solved, and the coding efficiency and bit rate savings are achieved without increasing coding complexity.
Patent Information
- Application Number
- CN202110974191.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-24
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2041-08-24
AI Technical Summary
The existing digital video compression technology is difficult to improve the accuracy of inter-frame prediction and save code rate without increasing the coding complexity, especially in large-scale scrolling screen scenarios such as screen sharing.
Combining the first search template with a small search range and a cross search template with a large search range, search for the best matching block of the current block in the reference frame. By determining whether the inter-frame prediction cost is greater than the loss threshold, decide whether to use the cross search template for verification, and optimize the motion vector to narrow the search area.
Without increasing the encoding complexity, the accuracy of inter-frame prediction is improved and the bit rate is saved, especially in large-scale scrolling screen scenarios to improve encoding efficiency, and ensure encoding speed without scrolling content.
Smart Images

Figure CN115720267B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of coding in image processing technology, and more specifically, to a coding method, encoder, device and storage medium based on inter-frame prediction. Background Art
[0002] Digital video compression technology primarily compresses large amounts of digital video data for easier transmission and storage. With the surge in internet video usage and increasing demand for higher-quality video, while existing digital video compression standards are capable of achieving video decompression, there is a continued need for better digital video compression technologies to improve inter-frame prediction accuracy and save bitrate without increasing encoding complexity. Summary of the Invention
[0003] The embodiments of the present application provide an encoding method, encoder, device, and storage medium based on inter-frame prediction, which can improve the accuracy of inter-frame prediction and save bit rate without increasing the encoding complexity as much as possible.
[0004] In a first aspect, a coding method based on inter-frame prediction is provided, characterized by comprising:
[0005] Get the current block to be encoded in the target video frame;
[0006] Using a first search template, searching for a first matching block having the minimum inter-frame prediction cost with the current block in a reference frame of the current block; the search range of the first search template is smaller than the search range of the cross search template;
[0007] If the inter-frame prediction cost of the first matching block is greater than or equal to the loss threshold, verifying the first matching block with a matching block searched in the reference frame using the cross search template based on the motion vector of the first matching block to obtain a best matching block;
[0008] The current block is inter-frame predicted and encoded based on the best matching block.
[0009] In a second aspect, an encoder is provided, comprising: a device for executing the method in the first aspect or its respective implementations. Specifically, the encoder comprises a functional unit for executing the method in the first aspect or its respective implementations.
[0010] In a third aspect, an encoder is provided, comprising a processor and a memory, wherein the memory is configured to store a computer program, and the processor is configured to call and execute the computer program stored in the memory to execute the method of the first aspect or its respective implementations.
[0011] In a fourth aspect, an electronic device is provided, including:
[0012] a processor adapted to execute a computer program;
[0013] A computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, the method of the first aspect or its various implementation modes is implemented.
[0014] In a fifth aspect, a computer-readable storage medium is provided, which stores computer instructions. When the computer instructions are read and executed by a processor of a computer device, the computer device executes the method of the first party or its various implementations.
[0015] Based on the above technical solution, the encoding end can first use the first search template to determine the first matching block with the lowest inter-frame prediction cost with the current block in the reference frame; then, by judging whether the inter-frame prediction cost of the first matching block is greater than or equal to the loss threshold, determine whether it is necessary to use a cross-search template with a search range larger than the search range of the first search template, and re-search the matching block of the current block in the reference frame to verify the first matching block. This is equivalent to, considering that the requirements of the motion search range for inter-frame prediction in different scenarios are different, if only the first search template with a small search range is used, then for scenes with large-scale scrolling images such as browsing web pages and tables that often appear in screen sharing, due to the limitation of the motion search range, it is impossible to accurately determine the best matching block, which limits the encoding efficiency. If the cross-search template with a large search range is directly used, for some scenes that do not contain scrolling content, it will not only increase the complexity of encoding, but also reduce the encoding efficiency.
[0016] In addition, verifying the first matching block based on the motion vector of the first matching block is equivalent to considering using the motion vector of the first matching block to limit the search area of the cross search template, which can improve the accuracy of inter-frame prediction while reducing the number of motion estimation searches and increasing the encoding speed.
[0017] In short, the method provided in the present application aims to combine a first search template with a small search range and a cross search template with a large search range, and optimize the search range of the cross search template to search for the best matching block of the current block in the reference frame. It can not only quickly and effectively improve the coding efficiency in scenarios with large-scale scrolling pictures, but also can ensure the accuracy of inter-frame prediction in scenarios without large-scale scrolling pictures while basically not increasing the coding complexity. That is, the method provided in the present application can ensure that the accuracy of inter-frame prediction is improved and the bit rate is saved without increasing the coding complexity as much as possible. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0019] Figure 1 It is a schematic block diagram of the coding framework provided in an embodiment of the present application.
[0020] Figure 2 It is a schematic block diagram of the decoding framework provided in an embodiment of the present application.
[0021] Figures 3 to 5 This is a schematic flowchart of the encoding method based on inter-frame prediction provided in an embodiment of the present application.
[0022] Figure 6 This is a schematic block diagram of an encoder provided in an embodiment of the present application.
[0023] Figure 7 It is a schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments of this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0025] The present application can be applied to the field of image coding and decoding, the field of video coding and decoding, the field of hardware video coding and decoding, the field of dedicated circuit video coding and decoding, and the field of real-time video coding and decoding. For example, the solution of the present application can be combined with the Audio Video Coding Standard (AVS). For example, the H.264 / Audio Video Coding (AVC) standard, the H.265 / High Efficiency Video Coding (HEVC) standard, and the H.266 / Versatile Video Coding (VVC) standard.
[0026] To facilitate understanding, the coding framework provided in this application is briefly introduced first.
[0027] Figure 11 is a schematic block diagram of a coding framework 100 provided in an embodiment of the present application. It should be understood that the coding framework can be used to perform lossy compression on an image, or it can be used to perform lossless compression on an image. The lossless compression can be visually lossless compression or mathematically lossless compression.
[0028] For example, after the coding framework 100 reads the target image frame, it divides the target image frame into block data and performs encoding based on the block data. For example, after the coding framework 100 reads the target image frame, it can divide the target image frame into several coding tree units (CTUs), and a coding tree unit can be further divided into several coding unit blocks (CUs). The CU can be a rectangular block or a square block. That is, the coding framework 100 can perform encoding based on CTUs or CUs.
[0029] like Figure 1 As shown, the coding framework 100 may include an intra-frame estimation unit 111, an intra-frame prediction unit 112, a motion compensation unit 113, a motion estimation unit 114, a residual unit 121, a transform and quantization unit 122, and a header information encoding unit or an entropy encoding unit 140. The coding framework 100 may also be referred to as a hybrid framework coding mode.
[0030] In other words, in the coding framework 100, the intra-frame estimation unit 111 and the intra-frame prediction unit 112 can predict the target image block with reference to the adjacent image blocks of the image frame to be encoded to output a prediction block. Alternatively, the motion compensation unit 113 and the motion estimation unit 114 can predict the target image block with reference to the adjacent image blocks of the image frame to be encoded to output a prediction block. The residual unit 121 can calculate a residual block based on the prediction block and the target image block to be encoded, that is, the difference between the prediction block and the target image block to be encoded. This residual block can also be referred to as residual information. This residual block is transformed and quantized by the transform and quantization unit 122, which can remove information that is not sensitive to the human eye to eliminate visual redundancy. Optionally, the residual block before transformation and quantization by the transform and quantization unit 122 can be referred to as a time-domain residual block, and the time-domain residual block after transformation and quantization by the transform and quantization unit 122 can be referred to as a frequency residual block or a frequency-domain residual block. After receiving the quantized change coefficient output by the change quantization unit 122, the header information encoding unit or entropy encoding unit 140 may output a target bitstream based on the quantized change coefficient and the intra-frame prediction data output by the intra-frame estimation unit 111 and the intra-frame prediction unit 112, or the motion data output by the motion compensation unit 113 and the motion estimation unit 114. For example, the header information encoding unit or entropy encoding unit 140 may eliminate character redundancy based on the target context model and the probability information of the binary bitstream. For example, the header information encoding unit or entropy encoding unit 140 may be used for context-based adaptive binary arithmetic entropy coding (CABAC).
[0031] After the decoding end receives and parses the bitstream, it obtains the time domain residual block through steps such as inverse transformation and inverse quantization. After superimposing the predicted block obtained by the decoding end on the time domain residual block, the reconstructed block can be obtained. Optionally, in this application, the current block can also be referred to as the original image block or the image block to be encoded, and the matching block can also be referred to as the predicted image block or the image prediction block. In addition, for the encoding end, the current block can also be referred to as the target encoding block or the target encoding image block, and for the decoding end, the current block can also be referred to as the target decoding block or the target decoding image block.
[0032] Optionally, the current block may be a macroblock.
[0033] The intra-frame estimation unit 111 and intra-frame prediction unit 112 can be used for intra-frame prediction. Intra-frame prediction only refers to information from the same frame image and predicts pixel information within the target image block to eliminate spatial redundancy. The frame used for intra-frame prediction can be an I-frame. The motion compensation unit 113 and motion estimation unit 114 can be used for inter-frame prediction. Inter-frame prediction can refer to image information from different frames and use motion estimation to search for motion vector information that best matches the target image block to eliminate temporal redundancy. If the input digital video is in color format, such as YUV 4:2:0 format, each four pixels in each image frame of the digital video are composed of four Y components and two UV components. The encoding framework 100 can encode the Y components (i.e., luminance blocks) and UV components (i.e., chrominance blocks) separately. Similarly, the decoding end can also perform decoding accordingly based on the format. It should be noted that the frames used for inter-frame prediction can be P frames and / or B frames. P frames refer to forward-predicted frames, and B frames refer to bidirectionally predicted frames.
[0034] It should be understood that Figure 1 This is only an example of the present application and should not be considered as limiting the present application.
[0035] For example, the coding framework 100 may further include an inverse transform and inverse quantization unit 131, a filter control and analysis unit 132, a neural network-based filtering unit 133, and a cache unit 134. This is equivalent to providing a decoder within the coding framework 100. Thus, the prediction unit 100 can perform intra-frame or inter-frame prediction on the target frame based on an existing reference frame, thereby ensuring that the encoding and decoding ends have consistent understandings of the reference frame.
[0036] In other words, the encoder replicates the decoder's processing loop, producing the same predictions as the decoder. Specifically, the quantized transform coefficients are de-expanded and de-transformed by the inverse transform and dequantization unit 131 to replicate the approximate residual signal from the decoder. This approximate residual signal, after adding the prediction block, is passed through a neural network-based filtering unit 133 to smooth out blocking artifacts caused by block-based processing and quantization. The image blocks output by the neural network-based filtering unit 133 are stored in the decoded image cache unit 134 for use in predicting subsequent images.
[0037] Figure 2 It is a schematic block diagram of the decoding framework 200 provided in an embodiment of the present application.
[0038] like Figure 2 As shown, the decoding framework 200 may include a header information decoding unit or entropy decoding unit 210, an inverse transform and inverse quantization unit 220, a residual unit 230, a motion compensation unit 240, an intra-frame prediction unit 250, a loop filtering unit 260, and a decoded image cache unit 270.
[0039] For example, after receiving and parsing the bitstream, the header information decoding unit or entropy decoding unit 210 obtains a prediction block and a frequency domain residual block. The frequency domain residual block is subjected to inverse transformation and inverse quantization by the inverse transform and inverse quantization unit 220 to obtain a time domain residual block. The residual unit 230 superimposes the prediction block predicted by the motion compensation unit 240 or the intra-frame prediction unit 250 onto the time domain residual block that has been inverse transformed and inverse quantized by the inverse transform and inverse quantization unit 220 to obtain a reconstructed block. For example, the motion compensation unit 240 or the intra-frame prediction unit 250 can obtain the prediction block by decoding the header information of the bitstream.
[0040] For example, loop filtering unit 260 may perform a deblocking filtering operation to reduce blocking artifacts of pixel blocks associated with a CU.
[0041] For example, the decoded image cache unit 270 may store the reconstructed image of the CU, wherein the reconstructed image may be used as a reference image for subsequent prediction, or the reconstructed image may be transmitted to a display device for presentation.
[0042] It should be noted that, for the decoding end, the current block may also be referred to as a target decoding block or a target decoding image block; and the matching block may also be referred to as a reconstructed image block or a target decoding block.
[0043] To facilitate understanding of the present application, the following describes the relevant terms used in this application.
[0044] 1. Rate-Distortion Cost (RDCost): A method for measuring bit rate and distortion in video coding.
[0045] 2. Inter-frame prediction (Inter): Referencing image information from different frames, motion estimation is used to search for the motion vector information of the matching block with the minimum inter-frame prediction cost to eliminate temporal redundancy.
[0046] 3. Motion Vector (MV): The offset in the reference frame relative to the current frame.
[0047] 4. Macroblock (MB): A coded image is usually divided into several macroblocks. A macroblock consists of a luminance pixel and two additional chrominance pixel blocks.
[0048] 5. Bit rate: also known as bit rate, refers to the number of bits transmitted or decoded per unit time.
[0049] 6. Quantization Parameter (QP): This parameter reflects the compression of spatial details. A small QP value indicates that more details are retained and the bit rate increases. A large QP value indicates that details are lost and the bit rate decreases, but at the same time, image distortion increases and quality decreases.
[0050] For example, in scenarios such as browsing web pages or tables, which often occur in screen sharing and involve large-scale scrolling, the same content may scroll up and down or slide left and right over a large area. The inter-frame prediction encoding methods for video frames or image frames in such scenarios include the following schemes:
[0051] When encoding, the encoder uses a small diamond or hexagonal search template based on the open source x264 video encoding function library to perform integer pixel motion search within a motion search range with a radius of 16 pixels to obtain the best matching block for the current block, and then performs inter-frame prediction encoding on the current block based on the best matching block.
[0052] However, because the above scheme is limited by the size of the motion search range when performing inter-frame prediction, it cannot accurately predict motion information and find the best matching block in scenes with large scrolling areas, such as web browsing and spreadsheets, which are common in screen sharing. Therefore, the compression efficiency achieved by using the above scheme in such scenes is limited. Simply expanding the motion search range would significantly increase the encoding complexity of the encoder, especially for scenes without large scrolling content. This would not only greatly increase the encoding complexity but also fail to achieve any coding benefits.
[0053] Based on this, the present application provides an encoding method based on inter-frame prediction, which aims to search for the best matching block of the current block in the reference frame by combining a first search template with a small search range and a cross search template with a search range larger than that of the first search template. It can not only quickly and effectively improve the encoding efficiency in scenarios with large-scale scrolling pictures, but also can ensure the accuracy of inter-frame prediction while basically not increasing the encoding complexity in scenarios without large-scale scrolling pictures. That is, the method provided by the present application can ensure that the accuracy of inter-frame prediction is improved and the bit rate is saved without increasing the encoding complexity as much as possible.
[0054] The solution provided by this application will be described in detail below.
[0055] Figure 3 3 is a schematic flow chart of an inter-frame prediction-based encoding method 300 provided in an embodiment of the present application. It should be understood that the encoding method 300 can be executed by an encoding end. For example, Figure 1 The coding framework 100 is shown; for ease of description, the following description is given by taking the coding end as an example.
[0056] like Figure 3 As shown, the encoding method 300 may include:
[0057] S301: Obtain a current block to be encoded in a target video frame.
[0058] S302 , using a first search template, searching for a first matching block having the minimum inter-frame prediction cost with the current block in a reference frame of the current block; the search range of the first search template is smaller than the search range of the cross search template.
[0059] S303: If the inter-frame prediction cost of the first matching block is greater than or equal to the loss threshold, based on the motion vector of the first matching block, the first matching block is verified using the matching block searched in the reference frame using the cross search template to obtain the best matching block.
[0060] For example, if the inter-frame prediction cost of the first matching block is greater than or equal to the loss threshold and the size of the current block is 16*16, the first matching block is verified based on the motion vector of the first matching block using the matching block searched in the reference frame using the cross search template to obtain the best matching block.
[0061] S304: Perform inter-frame prediction coding on the current block based on the best matching block.
[0062] In short, first, the encoder searches for a matching block of the current block within a first search range in the reference frame by using a first search template; second, it calculates the rate-distortion loss of the current block and the searched matching block using a block matching criterion, and finally determines the first matching block with the smallest rate-distortion loss of the current block within the first search range; finally, by judging whether the rate-distortion loss of the first matching block is greater than or equal to a loss threshold, it determines whether it is necessary to use a cross search template to search for a matching block of the current block to verify the first matching block, so as to determine the best matching block of the current block.
[0063] For example, the first search template may be a diamond search template or a hexagonal search template; of course, in other alternative embodiments, the first search template may also be a quadrilateral search template or an octagonal search template whose search range is smaller than that of the cross search template, and this application does not impose any specific restrictions on this.
[0064] Exemplarily, the first search range may be a preset search range; for example, it may be a motion search range with a radius of 16 pixels; for another example, it may be a motion search range with a radius of 8 pixels, and this application does not impose any specific restrictions on this.
[0065] For example, the block matching criterion can be any one of the sum of absolute difference (SAD) matching criterion, the mean square error (MSE) matching criterion or the sum of absolute values after hadamard transformation (SATD) matching criterion. Of course, it can also be other matching criteria, and this application does not impose specific restrictions on this. For example, the size of the current block can be 16*16. Of course, in other alternative embodiments, the size of the current block can also be 8*8, and this application does not impose specific restrictions on this.
[0066] It should be noted that the motion vector is the offset of the matching block in the reference frame relative to the current block in the current frame. It should be noted that the loss threshold may be a preset threshold.
[0067] It can be seen that the encoding end determines whether the inter-frame prediction cost of the first matching block is greater than or equal to the loss threshold, which is equivalent to taking into account the different requirements of the motion search range for inter-frame prediction in different scenarios; if the inter-frame prediction cost of the first matching block is greater than or equal to the loss threshold, the first matching block is verified by the matching block searched in the reference frame using the cross search template to obtain the best matching block, which is equivalent to taking into account the scenes of browsing web pages, tables and other large-scale scrolling images that often appear in screen sharing, and the need to use a cross search template with a search range larger than the search range of the first search template to improve the accuracy of inter-frame prediction, thereby improving the encoding efficiency; otherwise, the first matching block is determined as the best matching block, that is, for some scenes that do not contain scrolling content, the best matching block can be determined directly by using the first search template with a small search range, thereby avoiding increasing the complexity of encoding and ensuring the encoding speed.
[0068] In addition, verifying the first matching block based on the motion vector of the first matching block is equivalent to considering using the motion vector of the first matching block to limit the search area of the cross search template, which can improve the accuracy of inter-frame prediction while reducing the number of motion estimation searches and increasing the encoding speed.
[0069] In short, the method provided in the present application aims to combine a first search template with a small search range and a cross search template with a large search range, and optimize the search range of the cross search template to search for the best matching block of the current block in the reference frame. It can not only quickly and effectively improve the coding efficiency in scenarios with large-scale scrolling pictures, but also can ensure the accuracy of inter-frame prediction in scenarios without large-scale scrolling pictures while basically not increasing the coding complexity. That is, the method provided in the present application can ensure that the accuracy of inter-frame prediction is improved and the bit rate is saved without increasing the coding complexity as much as possible.
[0070] The following examples illustrate the effect of improving encoding speed and encoding benefits by combining the experimental data in Table 1 and Table 2.
[0071] Table 1
[0072]
[0073] Table 2
[0074]
[0075] Among them, Table 1 shows the experimental data of the bit rate, Y component, U component, V component and frame rate of the first search template alone, and the experimental data of the bit rate, Y component, U component, V component and frame rate after combining the first search template and the cross search template when using different quantization parameters for the scrolling web page scenario. Table 2 shows the improvement effect of encoding speed and encoding benefits obtained based on the experimental data in Table 1.
[0076] Based on Tables 1 and 2, it can be seen that for the test sequence of the screen content scrolling scene, the encoding speed is increased by 39.2% while obtaining a 57.5% BD-rate benefit, which means that the encoding efficiency can be improved quickly and effectively.
[0077] It should be noted that the "-" represents a decrease in BD-rate, which means an increase in encoding revenue. It should be noted that the method provided in this application is not limited to the aforementioned scrolling webpage scenario. It can also achieve varying degrees of encoding speed improvements and encoding revenue in scenarios such as scrolling tables, scrolling PDFs, PPT playback, iOS gaming, and scrolling the screen left and right on iOS.
[0078] In some embodiments of the present application, before S303, the method may further include:
[0079] Determine whether the motion vector of the first matching block satisfies any one of the following conditions:
[0080] The motion vector of the first matching block is used as the search starting point of the first search template;
[0081] The direction of the motion vector of the first matching block in the reference frame is a vertical direction;
[0082] The direction of the motion vector of the first matching block in the reference frame is horizontal.
[0083] In other words, if the inter-frame prediction cost of the first matching block is greater than or equal to the loss threshold, the encoding end further determines whether it is necessary to use the cross search template to search for the matching block of the current block in the reference frame based on the motion vector of the first matching block. This can further narrow the conditions for entering the cross search and the search range after entering the cross search, thereby achieving effective search and improving search efficiency.
[0084] The following will be combined Figure 4 The preferred process of the inter-frame prediction encoding method provided by this application is described in detail. It should be understood that the encoding method 400 can be executed by the encoding end. For example, the framework of the encoding end can be Figure 1 Coding frame 100 is shown.
[0085] Figure 4 This is another schematic flowchart of the inter-frame prediction encoding method provided in an embodiment of the present application.
[0086] like Figure 4 As shown, the encoding method 400 may include:
[0087] S401: The encoder uses a first search template to search for a matching block of the current block in a reference frame.
[0088] S402: The encoder determines a first matching block with a minimum inter-frame prediction cost with the current block.
[0089] S403, the encoding end determines whether the inter-frame prediction cost of the first matching block is greater than or equal to the loss threshold and whether the size of the current block is 16*16. If the inter-frame prediction cost of the first matching block is greater than or equal to the loss threshold and the size of the current block is 16*16, execute S404; if the inter-frame prediction cost of the first matching block is less than the loss threshold or the size of the current block is not 16*16, execute S406.
[0090] In step S404, the encoder determines whether the direction of the motion vector of the first matching block in the reference frame is vertical or whether the motion vector of the first matching block is the search starting point of the first search template. If the direction of the motion vector of the first matching block in the reference frame is vertical or the motion vector of the first matching block is the search starting point of the first search template, step S405 is executed; if the direction of the motion vector of the first matching block in the reference frame is not vertical, step S407 is executed.
[0091] S405 : The encoder determines that the search direction of the cross search template is a vertical direction, and searches for a matching block of the current block in the reference frame based on the current search point on the cross search template.
[0092] S409, the encoding end determines whether the inter-frame prediction cost between the current block and the matching block searched based on the current search point on the cross search template is less than the loss threshold. If the inter-frame prediction cost between the current block and the matching block searched based on the current search point on the cross search template is less than the loss threshold, execute S406, otherwise execute S407.
[0093] In step S407, the encoder determines whether the motion vector of the first matching block is horizontal in the reference frame or the motion vector of the first matching block is the search starting point of the first search template. If the motion vector of the first matching block is horizontal in the reference frame or the motion vector of the first matching block is the search starting point of the first search template, step S408 is executed; otherwise, step S406 is executed.
[0094] S408: The encoder determines that the search direction of the cross search template is the horizontal direction, and uses the current search point on the cross search template to search for a matching block of the current block in the reference frame.
[0095] S406: The encoding end determines the best matching block.
[0096] In other words, in step S403 , if the inter-frame prediction cost of the first matching block is less than the loss threshold, step S406 is executed to determine the first matching block as the best matching block.
[0097] In other words, in step S409, if the search direction of the cross search template is the vertical direction, and the inter-frame prediction cost between the current block and the matching block searched based on the current search point on the cross search template is less than the loss threshold, then S406 is executed, that is, the matching block searched based on the current search point is determined as the best matching block.
[0098] In other words, in step S408, the search direction of the cross search template is determined to be the horizontal direction, and the cross search template is used to search for a matching block of the current block in the reference frame to verify the first matching block to determine the best matching block; for example, if the rate-distortion loss between the current block and the matching block searched using the cross search template is less than the loss threshold, then S406 is executed, i.e., the matching block searched using the cross search template is determined as the best matching block; for another example, if no matching block with a rate-distortion loss less than the loss threshold is found within the preset search range using the cross search template, then S406 is executed, and the first matching block is determined as the best matching block.
[0099] In other words, in step S407, if the direction of the motion vector of the first matching block in the reference frame is not horizontal or the motion vector of the first matching block is not the search starting point of the first search template, then S406 is executed to determine the first matching block as the best matching block.
[0100] The following takes the case where the first search template is a diamond or hexagonal search template as an example to illustrate the encoding process based on the above inter-frame prediction.
[0101] First, using a diamond or hexagonal search template, a matching block for the current block is searched for integer pixels within a motion search range with a radius of 16 pixels. The first matching block within the motion search range that has the smallest rate-distortion loss with the current block is determined. If the rate-distortion loss of the first matching block is less than a loss threshold, or if the motion vector of the first matching block is not at the search starting point of the first search template and is not oriented vertically or horizontally within the reference frame, the integer-pixel motion search ends and the first matching block is determined as the best matching block.
[0102] If the rate-distortion loss of the first matching block is greater than or equal to the loss threshold and the size of the current block is 16*16, whether to enter the cross search is determined based on the motion vector of the first matching block. If the motion vector of the first matching block is the search starting point of the first search template, or the direction of the motion vector of the first matching block in the reference frame is vertical, or the direction of the motion vector of the first matching block in the reference frame is horizontal, then within the motion search range with a radius of 256 pixels, a cross search template is used to further search on the first video frame with a resolution smaller than that of the reference frame to correctly estimate the motion information of the target scene to improve coding efficiency.
[0103] It should be understood that Figure 4 This is only an example of the present application and should not be considered as limiting the present application.
[0104] In some embodiments of the present application, S303 may include:
[0105] Based on the motion vector, determining a search direction of the cross search template;
[0106] Determine whether the current search point is a search point along the search direction within the search range of the cross search template;
[0107] If the current search point is a search point along the search direction within the search range, the first matching block is verified based on the matching block searched for at the current search point to obtain the best matching block.
[0108] The encoding end determines the search direction of the cross search template based on the motion vector of the first matching block, which is equivalent to using the motion vector of the first matching block to limit the search area of the cross search template. This can improve the accuracy of inter-frame prediction while reducing the number of motion estimation searches and increasing the encoding speed.
[0109] It should be noted that the search range may be a preset search range; for example, the search range may be a motion search range with a radius of 256 pixels. Of course, in other alternative embodiments, the search range may also be the boundary of the reference frame, and this application does not impose any specific limitation on this.
[0110] In some embodiments of the present application, if the motion vector of the first matching block is the search starting point of the first search template, the search direction of the cross search template is determined to be the vertical direction or the horizontal direction; if the direction of the motion vector of the first matching block within the reference frame is the vertical direction, the search direction of the cross search template is determined to be the vertical direction; if the direction of the motion vector of the first matching block within the reference frame is the horizontal direction, the search direction of the cross search template is determined to be the horizontal direction.
[0111] It should be noted that the search starting point can directly select the center position of the corresponding block mapped to the current block in the reference frame, or the prediction point can be determined as the search starting point; wherein, the prediction point can be the median of the motion vectors of the encoded macroblocks to the left, above, and above right of the current block. It should be noted that the search starting point of the cross search template can be the same as the search starting point of the first search template. Of course, the search starting point of the cross search template can also be different from the search starting point of the first search template. This application does not impose any specific restrictions on this.
[0112] In some embodiments of the present application, S303 may include:
[0113] If there is a first video frame having a resolution smaller than that of the reference frame, searching for a matching block of the current block based on the current search point in the first video frame based on the motion vector of the first matching block to obtain a second matching block;
[0114] The first matching block is verified based on the inter-frame prediction cost of the second matching block to obtain the best matching block.
[0115] In other words, if there is a first video frame whose resolution is smaller than that of the reference frame, the encoding end searches for a matching block of the current block based on the current search point in the first video frame, which improves the encoding speed compared to searching for a matching block of the current block based on the current search point in the reference frame.
[0116] It should be noted that the reference frame is a video frame directly obtained after the video is extracted without upsampling or downsampling; it should be noted that the reference frame is an original video frame that has not been downsampled.
[0117] In some embodiments of the present application, if the product of the inter-frame prediction cost of the second matching block and the preset coefficient is greater than or equal to the loss threshold, the first matching block is determined as the best matching block; if the product of the inter-frame prediction cost of the second matching block and the preset coefficient is less than the loss threshold, the second matching block is determined as the best matching block.
[0118] In other words, considering that the second coding block is searched in the first video frame, the encoding end compares the product of the inter-frame prediction cost of the second matching block and the preset coefficient with the loss threshold, which is equivalent to converting the inter-frame prediction cost of the second matching block to the inter-frame prediction cost of the matching block under the reference frame through the preset coefficient, thereby improving the verification effect of the first matching block using the second matching block.
[0119] It should be noted that the preset coefficient can be a multiple of the resolution of the first video frame reduced compared to the resolution of the reference frame. The preset coefficient can be 4 or 5. This application does not impose any specific restrictions on the specific value of the preset coefficient.
[0120] In some embodiments of the present application, if the product of the inter-frame prediction cost of the second matching block and the preset coefficient is greater than or equal to the loss threshold, the first matching block is determined as the best matching block; if the product of the inter-frame prediction cost of the second matching block and the preset coefficient is less than the loss threshold, the matching blocks of the current block are searched respectively based on two search points adjacent to the current search point on the reference frame in the direction determined by the motion vector of the first matching block to obtain two matching blocks corresponding to the two search points respectively; the matching block with the smallest inter-frame prediction cost among the two matching blocks and the second matching block is determined as the best matching block.
[0121] For example, if there is a matching block among the two matching blocks whose inter-frame prediction cost is less than the product of the inter-frame prediction cost in the second matching block and the preset coefficient, then the matching block is determined as the best matching block; if there is no matching block among the two matching blocks whose inter-frame prediction cost is less than the product of the inter-frame prediction cost in the second matching block and the preset coefficient, then the second matching block is determined as the best matching block.
[0122] In other words, if the inter-frame prediction cost between the matching block obtained based on the current search point and the current block is less than the loss threshold, the encoder calculates the inter-frame prediction cost of the current block and the matching blocks searched based on two search points adjacent to the current search point on the reference frame along the search direction of the cross search template, and determines the matching block with the smallest inter-frame prediction cost among the matching blocks searched based on the current search point and the two adjacent search points as the best matching block.
[0123] By separately calculating the inter-frame prediction costs of the current block and the matching blocks found based on two search points adjacent to the current search point, on the one hand, when performing a cross search, the second matching block is searched on the first video frame with a lower resolution to improve the encoding speed; on the other hand, since there are more search points on the reference frame than search points on the first video frame along the direction determined by the motion vector of the first matching block, there may be a matching block on the reference frame with an inter-frame prediction cost lower than the inter-frame prediction cost of the second matching block. At this time, based on the two search points adjacent to the current search point on the reference frame with a higher resolution, it is possible to further verify whether the second matching block is the best matching block, thereby improving the accuracy of inter-frame prediction while ensuring the encoding speed.
[0124] In some embodiments of the present application, the first video frame is a video frame that is downsampled with respect to the reference frame, and the preset coefficient is a coefficient determined based on the downsampling coefficient of the first video frame.
[0125] For example, for the reference frame I, the size is M*N, and it is downsampled by a factor of s, that is, the first video frame with a resolution of (M / s)*(N / s) is obtained; where s is the downsampling coefficient of the first video frame. If the reference frame is considered to be a video frame in matrix form, the image of the s*s window size in the reference frame is regarded as a pixel point, and the value of the pixel point is the mean value of all pixels in the window.
[0126] It should be noted that downsampling the reference frame can, on the one hand, make the downsampled first video frame conform to the size of the display area; on the other hand, it can generate a thumbnail of the reference frame, which can reduce the number of motion searches and improve search efficiency when searching for the best matching block.
[0127] In some embodiments of the present application, S303 may include:
[0128] Based on the motion vector of the first matching block, searching for a matching block of the current block based on the current search point in the reference frame to obtain a third matching block;
[0129] If the inter-frame prediction cost of the third matching block is greater than or equal to the loss threshold, determining the first matching block as the best matching block;
[0130] If the inter-frame prediction cost of the third matching block is less than the loss threshold, the third matching block is determined as the best matching block.
[0131] In other words, the encoder searches for a third matching block of the current block in the reference frame based on the current search point using a matching criterion. If the inter-frame prediction cost of the third matching block obtained by the search is greater than or equal to the loss threshold, the first matching block is temporarily determined as the best matching block, and the search is continued using the cross search template until the current search point is no longer within the search range of the cross search template. If the current search point is no longer within the search range, and the inter-frame prediction cost of the third matching block obtained based on the previous search point of the current search point is still greater than or equal to the loss threshold, the first matching block is determined as the best matching block. Otherwise, if the inter-frame prediction cost of a matching block obtained based on a certain search point during the search process is less than the loss threshold, the third matching block obtained based on the search point is determined as the best matching block.
[0132] The following will be combined Figure 5 The process of the coding method based on inter-frame prediction after entering the cross search template provided by the present application is described in detail. It should be understood that the coding method 500 can be executed by the coding end. For example, the framework of the coding end can be Figure 1 Coding frame 100 is shown.
[0133] Figure 5 This is another schematic flowchart of the inter-frame prediction encoding method provided in an embodiment of the present application.
[0134] like Figure 5 As shown, the encoding method 500 may include:
[0135] S501: The encoding end determines the search direction of the cross search template.
[0136] For example, the encoder determines the direction indicated by the motion vector of the first matching block as the search direction of the cross search template.
[0137] S502, the encoder determines whether the current search point is a search point along the search direction within the search range of the cross search template; if the current search point is a search point along the search direction within the search range of the cross search template, execute S503; otherwise, execute S509.
[0138] S503: The encoder determines whether there is a first video frame having a resolution smaller than that of the reference frame. If there is a first video frame, execute S504; otherwise, execute S507.
[0139] S504 : The encoder searches for a matching block of the current block based on the current search point in the first video frame based on the motion vector of the first matching block to obtain a second matching block.
[0140] In step S505, the encoding end determines whether the product of the inter-frame prediction cost of the second matching block and the preset coefficient is less than the loss threshold; if the product of the inter-frame prediction cost of the second matching block and the preset coefficient is less than the loss threshold, execute S506; otherwise, determine a new current search point and execute S502.
[0141] S506: The encoder searches for matching blocks of the current block based on two search points adjacent to the current search point on the reference frame in the direction indicated by the motion vector of the first matching block, and obtains two matching blocks corresponding to the two search points.
[0142] S507 : The encoder searches for a matching block of the current block based on the current search point in the first video frame based on the motion vector of the first matching block to obtain a third matching block.
[0143] In step S508, the encoder determines whether the inter-frame prediction cost between the current block and the third matching block is less than the loss threshold. If the inter-frame prediction cost between the current block and the third matching block is less than the loss threshold, step S509 is executed. Otherwise, a new current search point is determined on the cross search template, and step S502 is executed.
[0144] S509: The encoding end determines the best matching block.
[0145] In other words, the two matching blocks obtained in S506 that are searched based on two search points adjacent to the current search point on the reference frame, and the matching block with the smallest inter-frame prediction cost with the current block among the matching blocks searched based on the current search point, are determined as the best matching block.
[0146] In other words, the third matching block whose inter-frame prediction cost with the current block in step S508 is less than the loss threshold is determined as the best matching block.
[0147] In other words, if the current search point in step S502 is not a search point along the search direction within the search range of the cross search template, the first matching block is determined as the best matching block.
[0148] It should be understood that Figure 5 This is only an example of the present application and should not be considered as limiting the present application.
[0149] In some embodiments of the present application, method 300 may further include:
[0150] If the inter-frame prediction cost of the first matching block is less than the loss threshold, the direction of the motion vector of the first matching block in the reference frame is not vertical, the motion vector of the first matching block is not the search starting point of the first search template, and the direction of the motion vector of the first matching block in the reference frame is not horizontal, then the first matching block is determined as the best matching block.
[0151] If the direction of the motion vector of the first matching block in the reference frame is not vertical, the direction of the motion vector of the first matching block in the reference frame is not horizontal, or the motion vector of the first matching block is not the search starting point of the first search template, the first matching block is directly determined as the best matching block. This is equivalent to, considering the screen content encoding for some non-scrolling scenes, without the need to combine with the cross search template, the first matching block is already the best matching block with relatively high inter-frame prediction accuracy.
[0152] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, a variety of simple modifications can be made to the technical solution of the present application, and these simple modifications all fall within the scope of protection of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner unless there is any contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different embodiments of the present application can also be arbitrarily combined, and as long as they do not violate the ideas of the present application, they should also be regarded as the contents disclosed in the present application.
[0153] It should also be understood that in the various method embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0154] The above describes the method embodiment of the present application in detail. Figure 6 , describe in detail the device embodiments of the present application.
[0155] Figure 6 It is a schematic block diagram of the encoder 600 according to an embodiment of the present application.
[0156] like Figure 6 As shown, the encoder 600 may include:
[0157] The acquisition unit 610 is configured to acquire a current block to be encoded in a target video frame.
[0158] The search unit 620 is configured to search the reference frame of the current block for a first matching block having the minimum inter-frame prediction cost with the current block using a first search template; the search range of the first search template is smaller than the search range of the cross search template.
[0159] The verification unit 630 is configured to verify the first matching block using a matching block searched in the reference frame using the cross search template based on the motion vector of the first matching block to obtain a best matching block if the inter-frame prediction cost of the first matching block is greater than or equal to a loss threshold.
[0160] The encoding unit 640 is configured to perform inter-frame prediction encoding on the current block based on the best matching block.
[0161] In some embodiments of the present application, before verifying the first matching block using the matching block searched for in the reference frame using the cross search template, the verification unit 630 may further be configured to:
[0162] Determine whether the motion vector of the first matching block satisfies any one of the following conditions:
[0163] The motion vector of the first matching block is used as the search starting point of the first search template;
[0164] The direction of the motion vector of the first matching block in the reference frame is a vertical direction;
[0165] The direction of the motion vector of the first matching block in the reference frame is horizontal.
[0166] In some embodiments of the present application, the verification unit 630 may be specifically configured to:
[0167] Based on the motion vector, determining a search direction of the cross search template;
[0168] Determine whether the current search point is a search point along the search direction within the search range of the cross search template;
[0169] If the current search point is a search point within the search range and along the search direction, the first matching block is verified based on the matching block searched for at the current search point to obtain the best matching block.
[0170] In some embodiments of the present application, if the motion vector of the first matching block is the search starting point of the first search template, the search direction of the cross search template is determined to be the vertical direction or the horizontal direction; if the direction of the motion vector of the first matching block within the reference frame is the vertical direction, the search direction of the cross search template is determined to be the vertical direction; if the direction of the motion vector of the first matching block within the reference frame is the horizontal direction, the search direction of the cross search template is determined to be the horizontal direction.
[0171] In some embodiments of the present application, the verification unit 630 may be specifically configured to:
[0172] If there is a first video frame having a resolution smaller than that of the reference frame, searching for a matching block of the current block based on the current search point in the first video frame based on the motion vector of the first matching block to obtain a second matching block;
[0173] The first matching block is verified based on the inter-frame prediction cost of the second matching block to obtain the best matching block.
[0174] In some embodiments of the present application, if the product of the inter-frame prediction cost of the second matching block and the preset coefficient is greater than or equal to the loss threshold, the first matching block is determined as the best matching block; if the product of the inter-frame prediction cost of the second matching block and the preset coefficient is less than the loss threshold, the second matching block is determined as the best matching block.
[0175] In some embodiments of the present application, the verification unit 630 may be specifically configured to:
[0176] If the product of the inter-frame prediction cost of the second matching block and the preset coefficient is greater than or equal to the loss threshold, determining the first matching block as the best matching block;
[0177] If the product of the inter-frame prediction cost of the second matching block and the preset coefficient is less than the loss threshold, searching for matching blocks of the current block based on two search points adjacent to the current search point on the reference frame in the direction determined by the motion vector of the first matching block to obtain two matching blocks corresponding to the two search points respectively; and determining the matching block with the smallest inter-frame prediction cost among the two matching blocks and the second matching block as the best matching block.
[0178] In some embodiments of the present application, the first video frame is a video frame that is downsampled with respect to the reference frame, and the preset coefficient is a coefficient determined based on the downsampling coefficient of the first video frame.
[0179] In some embodiments of the present application, the verification unit 630 may be specifically configured to:
[0180] Based on the motion vector of the first matching block, searching for a matching block of the current block based on the current search point in the reference frame to obtain a third matching block;
[0181] If the inter-frame prediction cost of the third matching block is greater than or equal to the loss threshold, determining the first matching block as the best matching block;
[0182] If the inter-frame prediction cost of the third matching block is less than the loss threshold, the third matching block is determined as the best matching block.
[0183] In some embodiments of the present application, if the inter-frame prediction cost of the first matching block is less than the loss threshold, the direction of the motion vector of the first matching block in the reference frame is not vertical, the motion vector of the first matching block is not the search starting point of the first search template, and the direction of the motion vector of the first matching block in the reference frame is not horizontal, then the first matching block is determined as the best matching block.
[0184] It should also be understood that the various units in the embodiment of the present application related to the encoder 600 can be separately or all merged into one or several other units to constitute, or some (some) units therein can also be further split into multiple smaller units in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be implemented by multiple units, or the function of multiple units is implemented by one unit. In other embodiments of the present application, the encoder 600 can also include other units. In practical applications, these functions can also be implemented with the assistance of other units and can be implemented by the collaboration of multiple units. According to another embodiment of the present application, the encoder 600 involved in the embodiment of the present application can be constructed by running a computer program (including program code) that can execute the various steps involved in the corresponding method on a general-purpose computing device including processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), a read-only storage medium (ROM), etc., to construct the encoding method based on inter-frame prediction provided in the embodiment of the present application. The computer program can be recorded on, for example, a computer-readable storage medium, loaded into an electronic device via the computer-readable storage medium, and run therein to implement the corresponding method of the embodiment of the present application.
[0185] In other words, the units mentioned above can be implemented in the form of hardware, can be implemented by instructions in the form of software, or can be implemented in the form of a combination of hardware and software. Specifically, the steps of the method embodiments in the embodiments of the present application can be completed by the hardware integrated logic circuit and / or software instructions in the processor, and the steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or being executed by a combination of hardware and software in a decoding processor. Optionally, the software can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory and completes the steps in the above method embodiments in combination with its hardware.
[0186] Figure 7 It is a schematic structural diagram of an electronic device 700 provided in an embodiment of the present application.
[0187] like Figure 7 As shown, the electronic device 700 includes at least a processor 710 and a computer-readable storage medium 720. The processor 710 and the computer-readable storage medium 720 may be connected via a bus or other means. The computer-readable storage medium 720 is used to store a computer program 721, which includes computer instructions. The processor 710 is used to execute the computer instructions stored in the computer-readable storage medium 720. The processor 710 is the computing core and control core of the electronic device 700. It is suitable for implementing one or more computer instructions, and is specifically suitable for loading and executing one or more computer instructions to implement the corresponding method flow or corresponding function.
[0188] As an example, the processor 710 may also be referred to as a central processing unit (CPU). The processor 710 may include, but is not limited to, a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, and the like.
[0189] As an example, the computer-readable storage medium 720 may be a high-speed RAM memory, or a non-volatile memory (Non-Volatile Memory), such as at least one disk storage; optionally, it may also be at least one computer-readable storage medium located away from the aforementioned processor 710. Specifically, the computer-readable storage medium 720 includes, but is not limited to: volatile memory and / or non-volatile memory. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0190] like Figure 7 As shown, the electronic device 700 may further include a transceiver 730 .
[0191] The processor 710 may control the transceiver 730 to communicate with other devices. Specifically, the processor 710 may send information or data to other devices or receive information or data sent by other devices. The transceiver 730 may include a transmitter and a receiver. The transceiver 730 may further include one or more antennas.
[0192] In one implementation, the electronic device 700 may be the encoding end, encoder, or encoding framework involved in the embodiment of the present application; the computer-readable storage medium 720 stores a first computer instruction; the processor 710 loads and executes the first computer instruction stored in the computer-readable storage medium 720 to implement the corresponding steps in the inter-frame prediction-based encoding method provided in the embodiment of the present application; in other words, the first computer instruction in the computer-readable storage medium 720 is loaded by the processor 710 and the corresponding steps are executed. To avoid repetition, they are not repeated here.
[0193] In one implementation, the electronic device 700 may be the encoding end, encoder, or encoding framework involved in the embodiment of the present application; the computer-readable storage medium 720 stores a second computer instruction; the processor 710 loads and executes the second computer instruction stored in the computer-readable storage medium 720 to implement the corresponding steps in the inter-frame prediction-based encoding method provided in the embodiment of the present application; in other words, the second computer instruction in the computer-readable storage medium 720 is loaded by the processor 710 and the corresponding steps are executed. To avoid repetition, they are not repeated here.
[0194] According to another aspect of the present application, an embodiment of the present application further provides a computer-readable storage medium (Memory), which is a memory device in the electronic device 700 for storing programs and data. For example, a computer-readable storage medium 720. It can be understood that the computer-readable storage medium 720 here can include both the built-in storage medium in the electronic device 700 and, of course, the extended storage medium supported by the electronic device 700. The computer-readable storage medium provides a storage space, which stores the operating system of the electronic device 700. In addition, one or more computer instructions suitable for being loaded and executed by the processor 710 are also stored in the storage space. These computer instructions can be one or more computer programs 721 (including program codes).
[0195] According to another aspect of the present application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. For example, computer program 721 is provided. In this case, data processing device 700 may be a computer, processor 710 reads the computer instructions from computer-readable storage medium 720, and processor 710 executes the computer instructions, causing the computer to perform the inter-frame prediction-based encoding method provided in the various optional embodiments described above.
[0196] According to another aspect of the present application, a coding system is provided, including the encoder mentioned above, such as the encoder 600 .
[0197] In other words, when implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process of the embodiment of the present application is run in whole or in part or the functions of the embodiment of the present application are implemented. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode.
[0198] Those skilled in the art will appreciate that the units and process steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0199] Finally, it should be noted that the above content is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A coding method based on inter-frame prediction, characterized in that: include: Get the current block to be encoded in the target video frame; Using a first search template, searching for a first matching block having a minimum inter-frame prediction cost with the current block in a reference frame of the current block; The search range of the first search template is smaller than the search range of the cross search template; If the inter-frame prediction cost of the first matching block is greater than or equal to a loss threshold, verifying the first matching block with a matching block searched in the reference frame using the cross search template based on a motion vector of the first matching block to obtain a best matching block; The current block is inter-frame predicted and encoded based on the best matching block.
2. The method according to claim 1, characterized in that Before verifying the first matching block using the matching block searched for in the reference frame using the cross search template, the method further includes: Determine whether the motion vector of the first matching block satisfies any one of the following conditions: The motion vector of the first matching block is used as a search starting point of the first search template; The direction of the motion vector of the first matching block in the reference frame is a vertical direction; The direction of the motion vector of the first matching block in the reference frame is horizontal.
3. The method according to claim 1, characterized in that The checking of the first matching block by using the matching block searched in the reference frame by using the cross search template based on the motion vector of the first matching block to obtain the best matching block includes: determining a search direction of the cross search template based on the motion vector; determining whether the current search point is a search point along the search direction within the search range of the cross search template; If the current search point is a search point within the search range and along the search direction, the first matching block is verified based on the matching block searched for at the current search point to obtain a best matching block.
4. The method according to claim 3, characterized in that The determining the search direction of the cross search template based on the motion vector includes: If the motion vector of the first matching block is the search starting point of the first search template, determining that the search direction of the cross search template is a vertical direction or a horizontal direction; If the direction of the motion vector of the first matching block in the reference frame is a vertical direction, determining the search direction of the cross search template to be a vertical direction; If the direction of the motion vector of the first matching block in the reference frame is horizontal, the search direction of the cross search template is determined to be horizontal.
5. The method according to claim 1, wherein The checking of the first matching block by using the matching block searched in the reference frame by using the cross search template based on the motion vector of the first matching block to obtain the best matching block includes: If there is a first video frame having a resolution smaller than that of the reference frame, searching for a matching block of the current block based on the motion vector of the first matching block in the first video frame based on the current search point to obtain a second matching block; The first matching block is verified based on the inter-frame prediction cost of the second matching block to obtain the best matching block.
6. The method according to claim 5, characterized in that The verifying the first matching block based on the inter-frame prediction cost of the second matching block to obtain the best matching block includes: If the product of the inter-frame prediction cost of the second matching block and the preset coefficient is greater than or equal to the loss threshold, determining the first matching block as the best matching block; If the product of the inter-frame prediction cost of the second matching block and the preset coefficient is smaller than the loss threshold, the second matching block is determined as the best matching block.
7. The method according to claim 5, characterized in that The verifying the first matching block based on the inter-frame prediction cost of the second matching block to obtain the best matching block includes: If the product of the inter-frame prediction cost of the second matching block and the preset coefficient is greater than or equal to the loss threshold, determining the first matching block as the best matching block; If the product of the inter-frame prediction cost of the second matching block and the preset coefficient is less than the loss threshold, searching for matching blocks of the current block based on two search points adjacent to the current search point on the reference frame in the direction determined by the motion vector of the first matching block to obtain two matching blocks corresponding to the two search points respectively; and determining the matching block with the smallest inter-frame prediction cost among the two matching blocks and the second matching block as the best matching block.
8. The method according to claim 6 or 7, characterized in that The first video frame is a video frame that is downsampled with respect to the reference frame, and the preset coefficient is a coefficient determined based on the downsampling coefficient of the first video frame.
9. The method according to any one of claims 1 to 7, characterized in that The checking of the first matching block by using the matching block searched in the reference frame by using the cross search template based on the motion vector of the first matching block to obtain the best matching block includes: Searching for a matching block of the current block based on a current search point in the reference frame based on the motion vector of the first matching block to obtain a third matching block; If the inter-frame prediction cost of the third matching block is greater than or equal to the loss threshold, determining the first matching block as the best matching block; If the inter-frame prediction cost of the third matching block is less than the loss threshold, the third matching block is determined as the best matching block.
10. The method according to any one of claims 1 to 7, characterized in that The method further comprises: If the inter-frame prediction cost of the first matching block is less than the loss threshold, the direction of the motion vector of the first matching block in the reference frame is not vertical, the motion vector of the first matching block is not the search starting point of the first search template, and the direction of the motion vector of the first matching block in the reference frame is not horizontal, the first matching block is determined as the best matching block.
11. The method according to any one of claims 1 to 7, characterized in that The first search template is a diamond search template or a hexagonal search template.
12. An encoder, characterized in that include: An acquisition unit, configured to acquire a current block to be encoded in a target video frame; A searching unit, configured to search, using a first search template, in a reference frame of the current block for a first matching block having a minimum inter-frame prediction cost with the current block; The search range of the first search template is smaller than the search range of the cross search template; a verification unit, configured to verify the first matching block using a matching block searched in the reference frame by using the cross search template based on a motion vector of the first matching block to obtain a best matching block if the inter-frame prediction cost of the first matching block is greater than or equal to a loss threshold; The encoding unit is configured to perform inter-frame prediction encoding on the current block based on the best matching block.
13. An electronic device, characterized in that: include: a processor adapted to execute a computer program; A computer-readable storage medium having a computer program stored therein, wherein the computer program, when executed by the processor, implements the method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that Used to store a computer program, wherein the computer program causes a computer to execute the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Video intra-frame encoding method based on space domain decomposition
CN101389028A
Method for searching for motion estimation
CN103763563A