Method and device for determining intra-frame prediction mode of panoramic video H264 encoding
Through offline plotting and Kirsch operator edge direction analysis of panoramic video images, the H.264 intra prediction mode is quickly selected, which solves the problem of high complexity of intra prediction mode selection and achieves significant reduction in encoding time and efficiency. promote.
Patent Information
- Application Number
- CN202111128793.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-26
- Publication Date
- 2024-10-08
- Estimated Expiration
- 2041-09-26
AI Technical Summary
The existing H.264 intra-frame prediction technology requires a large amount of calculations in video encoding, resulting in a gap between encoding time and video real-time requirements. How to optimize it has become an important issue.
Through offline plotting of panoramic video images, non-key areas are identified, calibration areas are divided, polygon point sets are used to determine macroblock positions, edge directions are calculated based on image smoothness and the Kirsch operator, intra-frame prediction modes are quickly selected, and coding is reduced time.
While ensuring the encoding quality, the encoding time is significantly reduced. Multiple on-site verifications have shown that the encoding time can be reduced by 38.92%, improving encoding efficiency.
Smart Images

Figure CN113992911B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method and device for determining an intra-frame prediction mode of panoramic video H264 encoding. Background Art
[0002] With the development of video coding and streaming media technology, performance indicators such as video image resolution and video real-time have put forward higher requirements on image processing algorithms. Airport panoramic video coding is a typical example of such applications.
[0003] The H.264 coding standard proposes an intra-frame prediction method, which uses the decoded and reconstructed neighboring blocks to predict the current block, and performs corresponding subsequent processing on the residual between the predicted block and the actual block. According to "Thomas Wiegand, Heiko Schwarz, Anthony Joch, Faouzi Kossentini, and Gary J. Sullivan Rate-Constrained Coder Contral and Comparison of Video Coding Standards. 2005.", H.264 intra-frame coding has two cost function models, namely the Sum of Absolute Difference (SAD) cost model and the Rate-Distortion Optimization (RDO) model. The RDO model is more accurate for module selection than the SAD model. The basic principle of the RDO model for intra-frame mode selection is: in the optional macroblock type, traverse each available coding mode, calculate the number of coding bits and the corresponding reconstructed image distortion in each mode, and select the mode with the smallest distortion as the best mode. However, this intra-frame prediction technology has to deal with a huge amount of computation, and its encoding time is still far from the real-time requirements of the video. How to optimize it has become an important issue. Summary of the invention
[0004] Purpose of the invention: In view of the deficiencies in the prior art, the present invention proposes a method for determining an intra-frame prediction mode for panoramic video H264 encoding, which can quickly select an intra-frame prediction mode and improve the video encoding speed.
[0005] The present invention also provides a computer device and a computer-readable storage medium for implementing the above-mentioned method for determining the intra-frame prediction mode of panoramic video H264 encoding.
[0006] Technical solution: According to a first aspect of the present invention, a method for determining an intra-frame prediction mode for panoramic video H264 encoding is provided, comprising the following steps:
[0007] Mark the offline panoramic image, identify the designated observation area as the calibration area, and save the polygon point set of the calibration area;
[0008] The input panoramic video image to be encoded is divided into macroblocks, and whether the macroblock to be encoded is within the calibration area is determined according to the polygon point set;
[0009] For the macroblocks to be encoded within the calibration area, the intra16×16 mode is used, corresponding to 4 encoding alternative modes;
[0010] For the macroblocks to be encoded in the non-calibrated area, the image smoothness is calculated, and the intra16×16 mode or intra4×4 mode is determined based on the smoothness; for the macroblocks determined to use the intra4×4 mode, the edge direction is calculated using the Kirsch operator, and the encoding alternative mode is determined based on the edge direction;
[0011] According to the selected candidate modes, by calculating the cost function, the mode with the minimum cost is selected as the final intra-frame prediction mode.
[0012] According to certain embodiments of the first aspect, the designated observation area is a non-moving area in the airport panoramic image.
[0013] According to certain implementations of the first aspect, macroblock division is performed on the input panoramic video image to be encoded, and judging whether the macroblock to be encoded is within the calibration area according to the polygon point set includes:
[0014] The input airport panoramic image is divided into 16×16 macroblocks, and the attribute value of the current macroblock to be encoded with respect to the calibration area is calculated in combination with the polygon point set. When the calculated attribute value is greater than or equal to the specified threshold th1, the macroblock is considered to be within the calibration area, otherwise it is not within the calibration area.
[0015] According to certain implementations of the first aspect, the property value of the current macroblock to be encoded with respect to the marked area is calculated according to the following formula:
[0016]
[0017] Among them, Sum in It indicates the number of pixels in the current macroblock in the calibration area, and partion indicates the proportion of the current macroblock in the calibration area.
[0018] According to certain implementations of the first aspect, for the macroblock to be encoded in the non-calibrated area, when the image smoothness is greater than a set threshold th2, the intra4×4 mode is used, otherwise the intra16×16 mode is used.
[0019] According to certain embodiments of the first aspect, the image smoothness calculation formula is:
[0020]
[0021] Among them, f(x,y) is the pixel value of the macroblock at (x,y), and m is the mean value of all pixels in the macroblock.
[0022] According to certain embodiments of the first aspect, the edge direction is calculated using the Kirsch operator, and the encoding alternative mode is determined based on the edge direction, including: the 8 directions in the Kirsch operator are 0°, 45°, 90°, 135°, 180°, 225°, 270°, and 315°, respectively corresponding to direction numbers 1, 8, 7, 6, 5, 4, 3, and 2, and compared with the 8 modes except the DC prediction mode in the intra4×4 mode, there is no corresponding prediction mode for directions 5, 6, 7, and 8. Therefore, the directional derivative of each pixel in the image is calculated based on the templates in the four directions of 1, 2, 3, and 4, and then the inverse of the partial derivatives in the four directions is calculated. The largest template corresponds to the edge direction of the pixel, and the alternative mode is selected according to the corresponding rules.
[0023] According to certain embodiments of the first aspect, the rules for selecting the alternative mode are as follows:
[0024] If the direction of the Kirsch edge is direction 1, prediction modes 1, 6, and 8 are selected as alternative modes;
[0025] If the direction of the Kirsch edge is direction 2, prediction modes 4, 5, and 6 are selected as alternative modes;
[0026] If the direction of the Kirsch edge is direction 3, prediction modes 0, 5, and 7 are selected as alternative modes;
[0027] If the direction of the Kirsch edge is direction 4, prediction modes 3 and 7 are selected as alternative modes.
[0028] According to certain implementations of the first aspect, for a macroblock in intra4×4 mode, the DC mode is added as the alternative mode based on the obtained alternative mode.
[0029] According to a second aspect of the present invention, there is provided a computer device, the device comprising:
[0030] one or more processors;
[0031] Memory; and
[0032] One or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the one or more programs are executed by the one or more processors, the method for determining the intra-frame prediction mode of the panoramic video H264 encoding as described in the first aspect of the present invention is implemented.
[0033] According to a third aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. The computer program can be executed by one or more processors to implement the method for determining the intra-frame prediction mode of the panoramic video H264 encoding.
[0034] Beneficial effects: The present invention discloses a method for determining an intra-frame prediction mode for panoramic video H264 encoding, which can quickly select the H.264 intra-frame prediction mode for panoramic encoding. First, an offline panoramic marking method is used to mark the non-key focus area of the panorama, and the macroblocks to be encoded in the marked area can be quickly separated to use the intra16×16 mode; for the macroblocks to be encoded in the non-marked area, the image smoothness is used to determine the appropriate intra-frame coding mode; in order to solve the problem of too many prediction modes of the intra4×4 mode of intra-frame brightness, the improved Kirsch operator is used to obtain the edge direction, and the intra-frame prediction candidate mode is selected; finally, the final prediction mode is determined according to the cost function. The present invention solves the problem of selecting the intra-frame prediction mode of H.264 encoding of ultra-high-resolution panoramic video, reduces the encoding time while ensuring the encoding quality of the panoramic core area, and improves the encoding efficiency. Field verification and performance testing have been carried out in multiple airport environments, and the encoding time can be reduced by 38.92%, which has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is a schematic flow chart of a method for determining an intra-frame prediction mode for panoramic video H264 encoding according to an embodiment of the present invention;
[0036] Figure 2 is a schematic diagram of offline plotting of non-key focus areas of a panoramic image according to an embodiment of the present invention;
[0037] Figure 3 is a schematic diagram of eight directions of Kirsch operator and eight prediction modes of intra4×4 mode according to an embodiment of the present invention;
[0038] Figure 4 4 is a schematic diagram of the macroblock coding of a panoramic image according to an embodiment of the present invention. DETAILED DESCRIPTION
[0039] The technical solution of the present invention is further described below in conjunction with the accompanying drawings.
[0040] In order to solve the problem of high algorithm complexity in the process of intra-frame prediction mode selection during ultra-high resolution panoramic video encoding, the present invention proposes a method for fast selection of intra-frame prediction mode for panoramic video image encoding. The overall idea of the method is: through image prior information, non-key areas of concern are stripped out, and intra4×4 and intra16×16 modes are quickly separated. At the same time, the Kirsch algorithm is used to reduce the alternative modes in the intra4×4 mode. In the embodiment, the method is described using an airport panoramic video image. Figure 1 As shown, the following steps are included:
[0041] Step 1: Mark the offline panoramic image.
[0042] The airport panorama has the important characteristics of high image resolution and large field of view, and the key observation areas are running areas such as runways and aprons. Therefore, it is completely acceptable to start from narrowing the range of prediction mode selection and lose some image details in non-key observation areas to improve the real-time performance of the algorithm. By marking the stitched panoramic images offline in advance, using marking software to delineate the marking area polygons on the panorama, and recording the polygon point set, the extraction of non-key observation areas can be achieved. Here, the non-key observation area is used as the calibration area, and the calibration information is called prior information, which is used for subsequent judgment of the position of the macroblock to be encoded. Figure 2 This is a schematic diagram of offline marking of non-key focus areas of a panoramic image in this embodiment.
[0043] Step 2: determine the location of the macroblock to be encoded and preliminarily select the prediction mode.
[0044] The size of H.264 macroblock is 16×16, which is also the basic processing unit. When intra-coding, the current luminance macroblock must be predicted by both intra 4×4 and intra 16×16. H.264 luminance block intra-coding must traverse all intra16×16 and intra4×4 modes. The intra4×4 mode has 9 prediction directions, which is more accurate and suitable for macroblocks with large changes and more details. The intra 16×16 mode has only 4 prediction directions, which is more suitable for flat macroblocks. According to the technology disclosed in "T.Wiegand and B.Girod Lagrange multiplier selection in hybrid Video codercontrol, Processdings.2001International Conference on Image Processing, Vol.3Oct, 2001, pp.542-545.", the best mode can be selected by the distortion of the two modes. The H.264 intra-frame coding selection mode can be combined with the video image content. For areas with flat image texture changes, the intra16×16 mode can be selected, and for areas with drastic changes in image details, the intra4×4 mode can be selected. Since the airport panorama focuses on moving areas such as runways and aprons, the intra16×16 mode is directly used in non-moving areas. First, the intra16×16 mode blocks to be coded in the calibration area are stripped.
[0045] Input the airport panoramic video image to be encoded, divide it into macroblocks, and judge whether the pixels in the macroblock are within the polygons of the calibration area according to the polygon point set obtained by calibrating the panoramic image. Calculate the proportion of the macroblock in the calibration area. If it is greater than the specified threshold, it is considered to be within the calibration area. The calculation formula for the proportion of the macroblock in the calibration area is as follows;
[0046]
[0047] Among them, Sum in It indicates the number of pixels in the current macroblock in the calibration area. Partion is the proportion of the macroblock in the calibration area. If partion is greater than the threshold th1, it is considered to be in the calibration area and is identified as a non-focus area. The current macroblock uses the intra16×16 mode, and there are 4 alternative prediction modes.
[0048] If the macroblock to be encoded is not within the calibration area, select the appropriate macroblock intra-frame coding mode based on the image smoothness. Define the image smoothness Thr as:
[0049]
[0050] Among them, f(x, y) is the pixel value of the macroblock at (x, y), m is the average value of all pixels in the macroblock, and x and y are the horizontal and vertical coordinates representing the pixel value position. The larger the Thr, the more剧烈 the image change; conversely, the flatter the image. The image smoothness is also called flatness. According to the statistical characteristics of the video image sequence, the threshold th2 is set. The smaller this value, the clearer the image. When Thr < th2, the intra 16×16 mode is adopted; otherwise, the intra 4×4 mode is selected. In this mode, it is called a detail macroblock.
[0051] Step 3: Obtain the macroblock texture direction according to the Kirsch operator, so as to preferably select the intra-coding alternative mode.
[0052] For the macroblocks in the intra4×4 intra-coding mode selected in Step 2, the Kirsch operator uses 8 template directions to determine the gradient magnitude and direction, and calculates the difference values in different directions respectively. The direction corresponding to the maximum value is regarded as the edge direction. For a detailed introduction to the Kirsch operator, please refer to "Gong Shengrong, Digital Image Processing and Analysis, Beijing: Tsinghua University Press, 2006."
[0053] Step 3 specifically includes the following steps:
[0054] Step 3-1: Calculate the directional derivative of each pixel point in the image according to the templates in eight directions, referring to Figure 3 , these 8 directions are 0°, 45°, 90°, 135°, 180°, 225°, 270°, 315° respectively, corresponding to the direction numbers 1, 8, 7, 6, 5, 4, 3, 2 respectively. Compared with the 8 modes in H.264 intra prediction except the DC prediction mode, there are no corresponding prediction modes in the 5, 6, 7, 8 directions of the Kirsch operator. Therefore, the 8 directions of Kirsch can be reduced to 4 directions, and the corresponding partial derivative calculation methods are as follows:
[0055] (1) The calculation method of the partial derivative in the 0° direction is as follows:
[0056]
[0057] (2) The calculation method of the partial derivative in the 315° direction is as follows:
[0058]
[0059] (3) The calculation method of the partial derivative in the 270° direction is as follows:
[0060]
[0061] (4) The calculation method of the partial derivative in the 225° direction is as follows:
[0062]
[0063]
[0064] Based on the solved G0(i,j), the partial derivative values in the remaining directions can be iterated by the following formula to reduce the amount of calculation:
[0065] G 315 (i,j)=G0(i,j)+8(f(i-1,j+1)-f(i+1,j))
[0066] G 270 (i,j)=G 315 (i,j)+8(f(i+1,j-1)-f(i,j+1))
[0067] G 225 (i,j)=G 270 (i,j)+8(f(i,j-1)-f(i+1,j+1))
[0068] Where (i, j) represents the x and y coordinates of the pixel.
[0069] Step 3-2, find the inverse of the partial derivatives in the above four directions, and the direction corresponding to the largest template is identified as the edge direction of the pixel. Select the alternative mode according to the following rules:
[0070] If the direction of the Kirsch edge is direction 1, prediction modes 1, 6, and 8 are selected as alternative modes;
[0071] If the direction of the Kirsch edge is direction 2, prediction modes 4, 5, and 6 are selected as alternative modes;
[0072] If the direction of the Kirsch edge is direction 3, prediction modes 0, 5, and 7 are selected as alternative modes;
[0073] If the direction of the Kirsch edge is direction 4, prediction modes 3 and 7 are selected as alternative modes.
[0074] Step 4: Calculate the cost function RD_cost according to the alternative modes, and select the one with the smallest cost as the best coding mode.
[0075] If it is intra16×16 mode, the four 16×16 prediction modes of vertical, horizontal, DC, and planar are used as candidate modes, and the cost function RD_cost is calculated, and the smallest one is used as the final mode.
[0076] If it is a brightness 4×4 mode, add the DC mode to the obtained alternative mode as the alternative mode, and calculate RD_cost, and the smallest one is used as the final mode. The formula for RD_cost calculation to select the mode with the smallest distortion as the best mode is:
[0077] RD_cost=SSD(s,c,MODE|QP)+λ MODE R(s,c,MODE|QP)
[0078] λ MoDE is the current Lagrangian coefficient, MODE is an optional coding mode for the current macroblock, QP is the macroblock quantization parameter, s, c, respectively represent the pixel values of the original image and the reconstructed image in the corresponding mode, R(s, c, MODE|QP) represents the number of coded output bits of the current macroblock under a specific QP and MODE, SSD(s, c, MODE|QP) represents the image distortion, and the formula is:
[0079]
[0080] The schematic diagram of the panoramic image macroblock coding according to this embodiment is as follows: Figure 4 shown.
[0081] The method for fast selection of H264 intra-frame prediction mode for airport panoramic coding described in the embodiment of the present invention solves the problem of fast selection of intra-frame prediction mode for airport ultra-high resolution panoramic H264 coding. Field verification and performance testing were carried out in multiple airport environments, and the coding time can be reduced by 38.92%, which has broad application prospects.
[0082] Based on the same technical concept as the method embodiment, according to another embodiment of the present invention, a computer device is provided, the device comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs implement the steps in the method embodiment when executed by the one or more processors.
[0083] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0084] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0085] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0086] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0087] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for determining an intra-frame prediction mode for panoramic video H264 encoding, characterized in that: The following steps are involved: Plotting the offline panoramic image, identifying a designated observation area as a calibration area, and saving a polygon point set of the calibration area, wherein the designated observation area is a non-moving area in the airport panoramic image; The input panoramic video image to be encoded is divided into macroblocks, and whether the macroblock to be encoded is within the calibration area is determined according to the polygon point set, including: dividing the input airport panoramic image into 16×16 macroblocks, combining the polygon point set, calculating the attribute value of the current macroblock to be encoded with respect to the calibration area, when the calculated attribute value is greater than or equal to the specified threshold th1, the macroblock is considered to be within the calibration area, otherwise it is not within the calibration area, wherein the attribute value calculation formula is as follows: In the formula, Sum in Indicates the number of pixels in the current macroblock in the calibration area, and partion indicates the proportion of the current macroblock in the calibration area; For the macroblocks to be encoded within the calibration area, the intra16×16 mode is used, corresponding to 4 encoding alternative modes; For the macroblocks to be encoded in the non-calibrated area, the image smoothness is calculated, and the intra16×16 mode or intra4×4 mode is determined based on the smoothness; for the macroblocks determined to use the intra4×4 mode, the edge direction is calculated using the Kirsch operator, and the encoding alternative mode is determined based on the edge direction; According to the selected candidate modes, by calculating the cost function, the mode with the minimum cost is selected as the final intra-frame prediction mode.
2. The method for determining intra-frame prediction mode of panoramic video H264 encoding according to claim 1, characterized in that: For the macroblocks to be encoded in the non-calibrated area, when the image smoothness is greater than the set threshold th2, the intra4×4 mode is used, otherwise the intra16×16 mode is used.
3. The method for determining intra-frame prediction mode of panoramic video H264 encoding according to claim 2, characterized in that: The image smoothness calculation formula is: Among them, f(x,y) is the pixel value of the macroblock at (x,y), and m is the mean value of all pixels in the macroblock.
4. The method for determining intra-frame prediction mode of panoramic video H264 encoding according to claim 1, characterized in that: The edge direction is calculated using the Kirsch operator, and the encoding alternative modes are determined based on the edge direction: the 8 directions in the Kirsch operator are 0°, 45°, 90°, 135°, 180°, 225°, 270°, and 315°, corresponding to the direction numbers 1, 8, 7, 6, 5, 4, 3, and 2, respectively. Compared with the 8 modes in the intra4×4 mode except the DC prediction mode, there is no corresponding prediction mode for the directions 5, 6, 7, and 8. Therefore, the directional derivative of each pixel in the image is calculated based on the templates in the four directions of 1, 2, 3, and 4, and then the inverse of the partial derivatives in the four directions is calculated. The largest template corresponds to the edge direction of the pixel, and the alternative mode is selected according to the corresponding rules.
5. The method for determining intra-frame prediction mode of panoramic video H264 encoding according to claim 4, characterized in that: The rules for selecting an alternative mode are as follows: If the direction of the Kirsch edge is direction 1, prediction modes 1, 6, and 8 are selected as alternative modes; If the direction of the Kirsch edge is direction 2, prediction modes 4, 5, and 6 are selected as alternative modes; If the direction of the Kirsch edge is direction 3, prediction modes 0, 5, and 7 are selected as alternative modes; If the direction of the Kirsch edge is direction 4, prediction modes 3 and 7 are selected as alternative modes.
6. The method for determining intra-frame prediction mode of panoramic video H264 encoding according to claim 5, characterized in that: For the macroblock in intra4×4 mode, the candidate modes obtained according to the corresponding rules plus the DC mode are used as the candidate modes.
7. A computer device, characterized in that: The device comprises: one or more processors; Memory; and One or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the one or more programs are executed by the one or more processors, the method for determining the intra-frame prediction mode of the panoramic video H264 encoding as described in any one of claims 1-6 is implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which can be executed by one or more processors to implement the method for determining the intra-frame prediction mode of panoramic video H264 encoding as described in any one of claims 1-6.
