A video coding method and device based on residual gating, equipment and medium
Patent Information
- Application Number
- CN202611334170.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]现有方案的问题,依赖虚拟背景帧、混合高斯背景建模、帧差+决策树等额外场景模型,管线重、难与轻量实时编码器热路径耦合;把背景直接判为跳过或停止向下划分,过于绝对,易损伤人物边缘、字幕、手势所需的小块与矩形分区;未系统利用编码过程中Merge/Skip阶段已出现的零运动、近零残差信息,把它转成“同层裁剪、递归仍保留”;通用Skip/Merge代价提前终止方案不区分会议/监控内容结构,常把模式裁剪与递归终止耦合;缺少按“静态程度”启停的闭环,镜头晃动、切景时易误触发
[0015]综上可知,本申请获取目标视频的当前编码单元,基于目标视频所处的场景触发门控编码加速操作,并判断所述当前编码单元所属区域是否为静态背景场景;当所述当前编码单元所属区域为静态背景场景时,基于预设模式集合对所述当前编码单元进行模式搜索,得到所述当前编码单元的目标候选模式,基于所述目标候选模式判断所述当前编码单元是否满足预设门控命中条件;所述预设模式集合包括各个候选编码模式;若所述当前编码单元满足预设门控命中条件,则将所述目标候选模式确定为所述当前编码单元的本层候选模式,并对所述当前编码单元进行向下递归划分搜索得到递归搜索结果,根据所述目标候选模式确定所述本层候选模式与所述递归搜索结果对应的第一率失真代价,并根据所述第一率失真代价确定所述当前编码单元的目标编码模式;若所述当前编码单元未满足所述预设门控命中条件,则基于所述目标候选模式对所述当前编码单元进行预测,得到对应的预测残差,基于所述预测残差的分布情况对所述当前编码单元执行向下递归划分搜索或矩形分区剪枝,得到对应的候选搜索结果,确定所述候选搜索结果中各所述候选编码模式对应的第二率失真代价,根据各所述第二率失真代价确定所述当前编码单元的目标编码模式;基于所述目标编码模式对所述当前编码单元完成编码。
Smart Images

Figure CN123020787A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of video coding technology, and in particular to a video coding method, apparatus, device and medium based on residual gating. Background Technology
[0002] Currently, video conferencing, live streaming, and fixed camera monitoring services have high real-time requirements. The statistical characteristics of the footage are: fixed camera positions or extremely weak motion; most areas can be accurately predicted between frames using references at the same location and frequently fall into zero-motion skip mode; motion and texture details are concentrated in localized areas such as faces, upper bodies, gestures, and subtitles. It is necessary to significantly reduce complexity in real-time settings without completely eliminating the need for subdivision of character outlines.
[0003] The existing solutions suffer from several problems: they rely on additional scene models such as virtual background frames, Gaussian mixture background modeling, frame difference + decision trees, etc., resulting in a heavy and complex pipeline coupled with the hot path of the lightweight real-time encoder; directly judging the background as skip or stop the downward segmentation is too absolute and easily damages the small blocks and rectangular partitions required for character edges, subtitles, and gestures; they do not systematically utilize the zero motion and near-zero residual information that has already appeared in the Merge / Skip stage during the encoding process to convert it into "same-layer clipping, recursion still retained"; the general Skip / Merge cost early termination scheme does not distinguish between meeting / monitoring content structure and often couples mode clipping with recursive termination; and they lack a closed loop for starting and stopping based on "static degree", which is easy to trigger accidentally when the camera shakes or cuts.
[0004] In conclusion, reducing the workload of video encoding is an urgent problem to be solved. Summary of the Invention
[0005] In view of this, the purpose of this invention is to provide a video coding method, apparatus, device, and medium based on residual gating, which can reduce the workload of video coding. The specific solution is as follows: Firstly, this application provides a video coding method based on residual gating, applied to a video encoder, including: Obtain the current encoding unit of the target video, trigger gated encoding acceleration operation based on the scene in which the target video is located, and determine whether the area to which the current encoding unit belongs is a static background scene; When the region to which the current coding unit belongs is a static background scene, a pattern search is performed on the current coding unit based on a preset pattern set to obtain the target candidate pattern of the current coding unit. Based on the target candidate pattern, it is determined whether the current coding unit meets the preset gating hit condition. The preset pattern set includes each candidate coding pattern. If the current coding unit meets the preset gating hit condition, the target candidate mode is determined as the candidate mode of the current layer of the current coding unit, and the current coding unit is recursively partitioned downward to obtain the recursive search result. The first rate distortion cost corresponding to the candidate mode of the current layer and the recursive search result is determined according to the target candidate mode, and the target coding mode of the current coding unit is determined according to the first rate distortion cost. If the current coding unit does not meet the preset gating hit condition, then the current coding unit is predicted based on the target candidate pattern to obtain the corresponding prediction residual. Based on the distribution of the prediction residual, the current coding unit is subjected to forced splitting or rectangular partition pruning, and the search is recursively divided downward to obtain the corresponding candidate search results. The second rate-distortion cost corresponding to each candidate coding pattern is determined according to the candidate search results. The target coding pattern of the current coding unit is selected from the preset pattern set according to each second rate-distortion cost. The current coding unit is encoded based on the target coding pattern.
[0006] Optionally, the gating encoding acceleration operation triggered based on the scene in which the target video is located includes: The gating trigger ratio is obtained by comparing the number of coding units that meet the preset gating hit conditions within the scene window with the total number of analyzed coding units within the scene window. If the gating trigger ratio is greater than or equal to the preset enable threshold, or if the gating trigger ratio is greater than or equal to the preset disable threshold and the previous scene window of the scene window is in the gating enable state, then the scene where the target video is located is determined to be a static background dominant scene, and the gating encoding acceleration operation is triggered; wherein, the preset disable threshold is less than the preset enable threshold.
[0007] Optionally, determining whether the region to which the current encoding unit belongs is a static background scene includes: Determine the protected region in the current frame of the target video; the protected region includes any one or more of the following: face region, body region, subtitle region, graphical interface region, and region of interest. If the current coding unit does not intersect with the protected area, then the area to which the current coding unit belongs is determined to be a static background scene; If the current coding unit intersects with the protected area, the area to which the current coding unit belongs is determined to be a non-static background scene, and a preset normal mode search operation is performed on the current coding unit.
[0008] Optionally, determining whether the current coding unit meets the preset gating hit condition based on the target candidate pattern includes: Based on the target candidate pattern, determine the motion vector of each preset effective prediction direction of the current coding unit; Determine whether the target candidate mode is a skip mode, and whether the amplitude of the motion vector is less than or equal to a preset motion threshold; If so, the current encoding unit is determined to meet the preset gating hit condition.
[0009] Optionally, based on the distribution of the predicted residuals, a forced split is performed on the current coding unit, and a downward recursive partition search is conducted, including: The brightness residual in the prediction residual is divided into four quadrants according to the current coding unit, and the mean square error corresponding to each quadrant and the mean value of each mean square error are determined respectively. The high residual threshold is determined based on the quantization parameters of the current coding unit, and the residual heterogeneity is determined based on the maximum value, minimum value and mean value of each mean square error; If there is a single quadrant or a diagonal quadrant in the mean square error of each quadrant that is greater than the high residual threshold, and the residual heterogeneity is greater than or equal to the preset heterogeneity threshold, then the distribution of the predicted residual is determined to be the first residual distribution. If the mean square error of each quadrant is greater than the high residual threshold, then the distribution of the predicted residual is determined to be the second residual distribution. If the distribution of the predicted residual is either the first residual distribution or the second residual distribution, and the depth of the reference co-position coding unit in each preset effective prediction direction is greater than the depth of the current coding unit, then the current coding unit is forcibly split, and a downward recursive partitioning search is performed to prune candidate coding modes at the current depth other than the target candidate mode.
[0010] Optionally, rectangular partitioning pruning is performed on the current coding unit based on the distribution of the predicted residuals, including: Based on the mean square errors described above, determine the first sum of the mean square errors of the two left quadrants and the second sum of the mean square errors of the two right quadrants, as well as the third sum of the mean square errors of the two upper quadrants and the fourth sum of the mean square errors of the two lower quadrants. If the relative deviation between the first sum and the second sum is less than or equal to the preset similarity tolerance, then it is determined that the prediction residual is consistent in the left and right directions, and the vertical rectangular partitioning pattern in the preset pattern set is removed from the candidate search results; If the relative deviation between the third sum and the fourth sum is less than or equal to the preset similarity tolerance, then it is determined that the prediction residuals are consistent in the vertical direction, and the horizontal rectangular partitioning patterns in the preset pattern set are removed from the candidate search results.
[0011] Optionally, after performing forced splitting or rectangular partitioning pruning on the current coding unit based on the distribution of the predicted residuals, the method further includes: When performing forced splitting or rectangular partitioning pruning on the current coding unit, the sub-coding units obtained by recursively dividing the current coding unit downwards are determined; the sub-coding units include non-square prediction units; Identify square prediction cells at the same depth as the non-square prediction cells, and determine the sub-regions within the square prediction cells that correspond to the positions of the non-square prediction cells; If the brightness residual of the sub-region is zero, the motion vector, reference frame index and prediction direction of the square prediction unit are reused as the motion information of the non-square prediction unit, and the motion estimation of the non-square prediction unit is skipped. Based on the motion information obtained through reuse, motion compensation and rate-distortion cost calculation operations are performed on the non-square prediction unit to obtain the candidate search results corresponding to the non-square prediction unit.
[0012] Secondly, this application provides a residual-gated video encoding device for use in a video encoder, comprising: The scene judgment module is used to obtain the current encoding unit of the target video, trigger gated encoding acceleration operation based on the scene in which the target video is located, and determine whether the area to which the current encoding unit belongs is a static background scene. The gating hit determination module is used to perform a pattern search on the current coding unit based on a preset pattern set when the area to which the current coding unit belongs is a static background scene, to obtain the target candidate pattern of the current coding unit, and to determine whether the current coding unit meets the preset gating hit condition based on the target candidate pattern; the preset pattern set includes each candidate coding pattern; The first encoding mode determination module is used to determine the target candidate mode as the current layer candidate mode of the current encoding unit if the current encoding unit meets the preset gating hit condition, and to perform a downward recursive partition search on the current encoding unit to obtain a recursive search result, determine the first rate distortion cost corresponding to the current layer candidate mode and the recursive search result based on the target candidate mode, and determine the target encoding mode of the current encoding unit based on the first rate distortion cost. The second coding mode determination module is used to predict the current coding unit based on the target candidate mode if the current coding unit does not meet the preset gating hit condition, obtain the corresponding prediction residual, perform forced splitting or rectangular partition pruning on the current coding unit based on the distribution of the prediction residual, and recursively divide and search downward to obtain the corresponding candidate search results, determine the second rate-distortion cost corresponding to each candidate coding mode according to the candidate search results, and select the target coding mode of the current coding unit from the preset mode set according to each second rate-distortion cost; The encoding completion module is used to complete the encoding of the current encoding unit based on the target encoding mode.
[0013] Thirdly, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor is used to execute the computer program to implement the residual gating-based video coding method as described above.
[0014] Fourthly, this application provides a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the video coding method based on residual gating as described above.
[0015] In summary, this application obtains the current encoding unit of the target video, triggers gated encoding acceleration based on the scene in which the target video is located, and determines whether the area to which the current encoding unit belongs is a static background scene. When the area to which the current encoding unit belongs is a static background scene, a pattern search is performed on the current encoding unit based on a preset pattern set to obtain the target candidate pattern of the current encoding unit. Based on the target candidate pattern, it is determined whether the current encoding unit meets the preset gated hit condition. The preset pattern set includes various candidate encoding patterns. If the current encoding unit meets the preset gated hit condition, the target candidate pattern is determined as the candidate pattern of the current layer of the current encoding unit, and a downward recursive partition search is performed on the current encoding unit to obtain the recursive search result. The first rate-distortion cost corresponding to the current candidate pattern and the recursive search result is determined according to the target candidate pattern, and the target encoding pattern of the current encoding unit is determined according to the first rate-distortion cost; if the current encoding unit does not meet the preset gating hit condition, the current encoding unit is predicted based on the target candidate pattern to obtain the corresponding prediction residual, and the current encoding unit is subjected to downward recursive partitioning search or rectangular partitioning pruning based on the distribution of the prediction residual to obtain the corresponding candidate search result, the second rate-distortion cost corresponding to each candidate encoding pattern in the candidate search result is determined, and the target encoding pattern of the current encoding unit is determined according to each second rate-distortion cost; the current encoding unit is encoded based on the target encoding pattern.
[0016] As can be seen from the above, when encoding the current coding unit of the target video, this application first triggers gating coding acceleration based on the scene in which the video is located, and determines whether the current coding unit is located in a static background area. If it is a static background, a target candidate mode is searched from a preset candidate mode set, and it is determined whether the preset gating hit condition is met. If the condition is met, the target candidate mode is used as the candidate mode of this layer, and a downward recursive partitioning search is performed on the current coding unit. The rate-distortion cost of the current candidate mode and the recursive search result is combined to determine the target coding mode. If the condition is not met, the target candidate mode is used to make a prediction to obtain the prediction residual. Then, based on the residual distribution, a downward recursive partitioning search or rectangular partitioning pruning is selected. The rate-distortion cost of each candidate coding mode is compared from the candidate search results, the target coding mode is selected, and finally the encoding of the current coding unit is completed according to the target coding mode. This method determines whether the current scene belongs to this type of static background scene. If it does, large areas of background are skipped and quickly cropped with zero motion. For local high residual areas such as lip movements and gestures, the method determines whether to force subdivision or cut unreasonable rectangular divisions based on the geometric relationship of the four quadrants of the residual. Motion information is then reused on the precisely matched sub-regions. This significantly improves the encoding frame rate, reduces latency, and keeps the image quality loss within an acceptable range, without altering the bitstream syntax or decoder. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0018] Figure 1 This is a flowchart of a video coding method based on residual gating disclosed in this application; Figure 2 This is a schematic diagram of a specific four-quadrant division disclosed in this application; Figure 3 This application discloses a specific flowchart of a hierarchical residual gating coding acceleration process; Figure 4 This is a schematic diagram of the structure of a video encoding device based on residual gating disclosed in this application; Figure 5 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Currently, video conferencing, live streaming, and fixed camera monitoring have high real-time requirements. Existing solutions suffer from several problems: reliance on virtual background frames, Gaussian mixture background modeling, frame difference + decision trees, and other additional scene models, resulting in a heavy and complex pipeline coupled with hot-path coupling to lightweight real-time encoders; directly classifying the background as skipped or stopped for further segmentation is too absolute, easily damaging the small blocks and rectangular partitions needed for human edges, subtitles, and gestures; failure to systematically utilize the zero-motion and near-zero residual information already present in the Merge / Skip stage of encoding, converting it into "same-layer clipping, recursive retention"; the general Skip / Merge cost-based early termination scheme does not distinguish between meeting / monitoring content structure, often coupling mode clipping with recursive termination; and the lack of a closed loop for starting and stopping based on "static level," making it prone to accidental triggering during camera shake or scene transitions. To address these technical issues, this application discloses a video encoding method, apparatus, device, and medium based on residual gating, which can reduce the workload of video encoding.
[0021] See Figure 1 As shown, this embodiment of the invention discloses a video coding method based on residual gating, applied to a video encoder, including: Step S11: Obtain the current encoding unit of the target video, trigger gated encoding acceleration operation based on the scene where the target video is located, and determine whether the area to which the current encoding unit belongs is a static background scene.
[0022] It should be noted that in the inter-frame coding unit analysis path of the real-time mode of the video encoder, CU (Coding Unit) is the current coding block in the quadtree partition; CTU (Coding Tree Unit) is the root block of the largest partition; PU (Prediction Unit) is the inter-frame prediction partition block, which includes squares and rectangles; Skip mode is a candidate skip mode with zero or near-zero residuals; Merge mode is a candidate motion merge mode; MV (Motion Vector) is the inter-frame displacement vector; RDO (Rate Distortion Optimization) refers to selecting the best among the candidate coding modes according to the rate distortion cost; QP (Quantization Parameter) is the parameter that controls the quantization step size.
[0023] In this embodiment, during video encoding, the ratio of the number of encoding units within the scene window that meet the preset gating hit conditions to the total number of analyzed encoding units within the scene window is used to obtain the gating trigger ratio. If the gating trigger ratio is greater than or equal to a preset enable threshold, or if the gating trigger ratio is greater than or equal to a preset disable threshold and the previous scene window of the scene window is in a gating enabled state, then the scene in which the target video is located is determined to be a static background-dominated scene, and the gating encoding acceleration operation is triggered; wherein, the preset disable threshold is less than the preset enable threshold. Specifically, it can be set by frame, by encoding tree unit, or by sliding window, for example, taking the most recent several frames or the most recent several encoding tree units. Let the gating trigger ratio be r, and the preset enable threshold be r on The preset disabling threshold is r. off The gating enabled status of the previous scene window is E. prev The gating enable state E of the current scene window can be determined by the following formula: ; Where ∨ represents logical OR; ∧ represents logical AND; and E represents yes or no. The gating trigger ratio r is activated once it is greater than or equal to the preset activation threshold r. on This means enabling gating; and in the enabled state, as long as r is not lower than the preset deactivation threshold r off It will remain enabled. Because r off Less than r on A hysteresis interval is formed between the two, which can prevent the enabled state from fluctuating back and forth around the threshold. For example, r on r off It can take values in the range of 0.2 to 0.5.
[0024] if If yes, then the protected region in the current frame of the target video is determined. The protected region includes any one or more of the following: face region, body region, subtitle region, graphical interface region, and region of interest (ROI). If the current encoding unit does not intersect with the protected region, then the region to which the current encoding unit belongs is determined to be a static background scene. If the current encoding unit intersects with the protected region, then the region to which the current encoding unit belongs is determined to be a non-static background scene, and a preset normal mode search operation is performed on the current encoding unit. Specifically, the "protected region" in the current frame is first determined, which refers to those visually more critical and easily noticed areas, such as faces, bodies, subtitles, graphical interfaces, or areas of particular interest to the user. Because viewers will immediately notice if the image quality of these areas deteriorates. Next, it is determined whether the currently encoded unit overlaps with these protected regions. If there is no intersection, it means that this encoding unit belongs to an unimportant static background scene, such as a solid-color wall or sky, where the human eye is not sensitive to changes, and the encoder can adopt a faster strategy to prioritize efficiency. Conversely, if the encoding unit intersects with the protected area, it indicates that important content is contained and will be classified as a non-static background scene. In this case, a more refined and computationally intensive preset conventional mode search operation needs to be performed to carefully find the optimal encoding method to better preserve details and avoid blurry faces or fuzzy subtitles.
[0025] if If not, the preset normal mode search operation will be performed on this encoding unit, without entering gate one / two / three.
[0026] Step S12: When the area to which the current coding unit belongs is a static background scene, perform a pattern search on the current coding unit based on a preset pattern set to obtain the target candidate pattern of the current coding unit, and determine whether the current coding unit meets the preset gating hit condition based on the target candidate pattern; the preset pattern set includes each candidate coding pattern.
[0027] In this embodiment, if the region to which the current coding unit belongs is a static background scene, when analyzing the current coding unit, preset analyses such as merging / skipping modes and same-layer square prediction can be completed first, and the optimal candidate at the current depth can be used as the target candidate mode.
[0028] Then, based on the target candidate pattern, the motion vectors of each preset effective prediction direction of the current coding unit are determined; it is determined whether the target candidate pattern is a skip mode and whether the amplitude of the motion vector is less than or equal to a preset motion threshold; if so, the current coding unit is determined to meet the preset gating hit condition. Specifically, the motion vectors of the current coding unit in each preset effective prediction direction are determined based on the target candidate pattern, and it is determined whether the target candidate pattern is a skip mode and whether the amplitude of the motion vectors in all effective prediction directions is zero, i.e., all motion vectors are zero. If the target candidate pattern is a Skip mode and the motion vectors in each effective prediction direction are zero, the current coding unit is determined to meet the preset gating hit condition, i.e., the background hit is gated by gate one.
[0029] Step S13: If the current coding unit satisfies the preset gating hit condition, the target candidate mode is determined as the candidate mode of the current layer of the current coding unit, and the current coding unit is recursively partitioned downward to obtain the recursive search result. The first rate-distortion cost corresponding to the candidate mode of the current layer and the recursive search result is determined according to the target candidate mode, and the target coding mode of the current coding unit is determined according to the first rate-distortion cost.
[0030] In this embodiment, when the current coding unit meets the preset gating hit condition, a decoupled operation of same-layer pruning and recursive retention is performed. On the one hand, same-layer pruning is performed, that is, the analysis of other candidate coding modes at the current depth is stopped, including inter-frame re-estimation (such as square re-search), rectangular partitioning, asymmetric partitioning, and intra-frame modes, etc., and only the skipped / merged candidates obtained are retained as candidate modes of this layer, thereby eliminating redundant search of static background regions on the same layer; on the other hand, recursive retention is forced, and quadrant division is performed downwards to obtain, such as Figure 2 The four quadrants shown do not prematurely terminate the downward partitioning of the quadtree due to a gating hit, but instead continue to analyze the four sub-encoding units to obtain the recursive search result.
[0031] Based on this, the rate-distortion cost corresponding to the candidate mode in this layer is determined according to the target candidate mode, as well as the rate-distortion cost of the four-part combination candidate corresponding to the recursive search results, i.e., the first rate-distortion cost. Then, rate-distortion optimization is performed between the skipped candidate in this layer and the four-part combination candidate, and the one with the smaller cost is determined as the target encoding mode of the current encoding unit. In this way, even if the current encoding unit hits zero motion skips as a whole, if there are a few details inside, they can still be preserved through the division of sub-encoding units, reducing the risk of accidental blocking of small blocks required for character edges, subtitles, gestures, etc.
[0032] Step S14: If the current coding unit does not meet the preset gating hit condition, then the current coding unit is predicted based on the target candidate mode to obtain the corresponding prediction residual. Based on the distribution of the prediction residual, the current coding unit is subjected to forced splitting or rectangular partition pruning, and the search is recursively divided downward to obtain the corresponding candidate search results. The second rate-distortion cost corresponding to each candidate coding mode is determined according to the candidate search results. The target coding mode of the current coding unit is selected from the preset mode set according to each second rate-distortion cost.
[0033] In this embodiment, if the current coding unit does not meet the preset gating hit condition, the brightness residual in the prediction residual is divided into four quadrants according to the current coding unit, and the mean square error corresponding to each quadrant and the mean value of each mean square error are determined respectively; a high residual threshold is determined according to the quantization parameters of the current coding unit, and the residual variability is determined according to the maximum value, minimum value and mean value of each mean square error; if there is a single quadrant or a diagonal quadrant in the mean square error of each quadrant that is greater than the high residual threshold, and the residual variability is greater than or equal to the preset variability... If a qualitative threshold is set, the distribution of the predicted residuals is determined to be a first residual distribution. If the mean square error of each quadrant is greater than the high residual threshold, the distribution of the predicted residuals is determined to be a second residual distribution. If the distribution of the predicted residuals is either the first or the second residual distribution, and the depth of the reference co-position coding unit in each preset effective prediction direction is greater than the depth of the current coding unit, then the current coding unit is forcibly split, and a downward recursive partitioning search is performed to prune candidate coding modes at the current depth other than the target candidate mode. Specifically, the current optimal predicted brightness residual is divided into four quadrants. Calculate the mean square error , and the threshold that varies with the quantization parameter Heterogeneity and tolerance Comparison. Heterogeneity Determination: ; in, for The maximum value in; for The minimum value in; To obtain The maximum value in.
[0034] If the mean square error in a single quadrant or two diagonal quadrants is greater than the high residual threshold T(q), and the residual heterogeneity H is greater than or equal to the preset heterogeneity threshold H... thThis indicates that high residuals are concentrated locally, which is the first residual distribution, i.e., the case of locally high residuals. If the mean square error in all four quadrants is greater than the high residual threshold T(q), it is the second residual distribution, i.e., the case of all high residuals.
[0035] After confirming the residual distribution, temporal depth confirmation is also required, which means that the depth d of the coding unit at the same position in the reference frame in each preset effective prediction direction is required. ref If the depth d is greater than the current coding unit's depth, it indicates that the region was already subdivided more finely in the reference frame and is more likely to require further subdivision now. The temporal depth confirmation result is recorded as T. emp The confirmation result of locally high residuals is L. ok The confirmation result of the full-height residual is A. ok The forced splitting flag F can be determined according to the following formula: ; When the forced split flag F is set, the current coding unit is forced to split, the candidate coding modes at the current depth except for the target candidate mode are pruned, and a downward recursive partition search is performed to concentrate computing power on the sub-block partitions that are more likely to bring benefits.
[0036] Then, based on the mean squared errors, a first sum of the mean squared errors of the two left quadrants and a second sum of the mean squared errors of the two right quadrants are determined, as well as a third sum of the mean squared errors of the two upper quadrants and a fourth sum of the mean squared errors of the two lower quadrants. If the relative deviation between the first sum and the second sum is less than or equal to a preset similarity tolerance, it is determined that the prediction residuals are consistent in the left-right direction, and the vertical rectangular partitioning patterns in the preset pattern set are removed from the candidate search results. If the relative deviation between the third sum and the fourth sum is less than or equal to the preset similarity tolerance, it is determined that the prediction residuals are consistent in the up-down direction, and the horizontal rectangular partitioning patterns in the preset pattern set are removed from the candidate search results. Specifically, the first sum is the sum of the mean squared errors of the upper left and lower left quadrants, the second sum is the sum of the mean squared errors of the upper right and lower right quadrants, the third sum is the sum of the mean squared errors of the upper left and upper right quadrants, and the fourth sum is the sum of the mean squared errors of the lower left and lower right quadrants. For example, the relative deviation between two sums can be taken as the ratio of the absolute value of their difference to the larger of the two values, and the preset similarity tolerance α can be taken as approximately 0.10. If the residuals in the left and right directions are approximately the same, it indicates that there is no obvious vertical boundary in the current coding unit, and continuing to try vertical rectangular partitioning is not very meaningful, so the vertical rectangular partitioning pattern is pruned; similarly, when the residuals in the up and down directions are approximately the same, the horizontal rectangular partitioning pattern is pruned. It should be noted that rectangular partitioning pruning does not depend on temporal depth confirmation, that is, regardless of whether forced splitting is valid, the rectangular partitioning pattern can be pruned according to the above-mentioned directional consistency.
[0037] It should be noted that after performing forced splitting or rectangular partitioning pruning on the current coding unit based on the distribution of the prediction residual, the process further includes determining the sub-coding units obtained by recursively dividing the current coding unit downwards when performing forced splitting or rectangular partitioning on the current coding unit; the sub-coding units include non-square prediction units; determining square prediction units at the same depth as the non-square prediction units, and determining the sub-regions in the square prediction units corresponding to the positions of the non-square prediction units; if the brightness residual of the sub-region is zero, then the motion vector, reference frame index, and prediction direction of the square prediction unit are reused as the motion information of the non-square prediction unit, and the motion estimation of the non-square prediction unit is skipped; based on the reused motion information, motion compensation and rate-distortion cost calculation operations are performed on the non-square prediction unit to obtain the candidate search results corresponding to the non-square prediction unit. Specifically, at the same depth, if a square prediction unit already covers the entire region of the current coding unit, and its luminance and chrominance residuals are zero in the sub-region corresponding to a non-square prediction unit, it means that the sub-region has been accurately matched by the square prediction. Performing motion estimation separately on the non-square prediction unit would only lead to redundant calculations. Therefore, the actual motion vector, reference frame index, and prediction direction of the square prediction unit are directly reused as the motion information for the non-square prediction unit, skipping its motion estimation, but still completing the calculation of motion compensation and rate-distortion costs to ensure the fairness of candidate comparison. Regions with uneven residual spatial distribution, such as lip movements, gestures, and shoulder edges, are mainly covered by the aforementioned forced splitting, rectangular partition pruning, and zero-residual motion multiplexing.
[0038] It should be noted that zero-motion skipping and forced splitting based on residual distribution are mutually exclusive: once the current coding unit meets the preset gating hit condition, it will no longer be classified according to the four-quadrant residual distribution. Rectangular partition pruning and zero-residual motion reuse will only be implemented when the preset gating hit condition is not met. The overall processing priority is: scene and protected area bypass judgment, preset gating hit judgment, forced splitting or rectangular partition pruning based on residual distribution, zero-residual motion reuse, and rate-distortion optimization.
[0039] Furthermore, after the current coding unit analysis is completed, whether it meets the preset gating hit conditions, as well as the optional forced splitting and motion multiplexing hit conditions, can be written into the scene statistics window to update the gating trigger ratio r; the next frame or the next coding tree unit refreshes the gating enable status E accordingly, thereby forming a closed loop of statistics, start and stop, gating, and re-statistics, avoiding the forced application of acceleration paths to content with violent motion or scene cuts.
[0040] Step S15: Encode the current coding unit based on the target coding mode.
[0041] In this embodiment, after the current coding unit is encoded based on the target coding mode determined by rate-distortion optimization, the output bitstream still conforms to the standard syntax. That is to say, this embodiment only modifies the mode search process at the encoding end, without changing the bitstream syntax, and does not require any modification to the decoder, thus exhibiting good standard compatibility.
[0042] In one specific implementation, the gating parameters can be configured as follows: a preset activation threshold r on With preset disable threshold r off The similarity is set to a value between 0.2 and 0.5 to form a hysteresis loop, used to identify static dominant scenarios such as meetings and monitoring; the preset similarity tolerance α is set to around 0.10 for geometric verification and rectangular partitioning pruning; and the preset heterogeneity threshold H is used. th A value of approximately 0.20 is used to suppress erroneous forced splitting. At the same time, a gating mask can be set as a switch to enable all zero-motion skip judgment, residual distribution judgment and zero-residual motion multiplexing according to the computing power configuration, or only enable zero-motion skip judgment facing the background. For protected areas, the strategy of disabling gating or raising the threshold is implemented to ensure subjective quality.
[0043] In one specific implementation, the encoder is set to the real-time position and all the aforementioned gate controls are opened, α is 0.10, H th Using a value of 0.20, the scene window takes the most recent frames or several coding tree units, and disables same-layer pruning for coding units within the face detection box or only allows zero-residual motion multiplexing. On a subset of static background sequences of conference types, compared to anchor points with the above gating disabled, the encoded frame rate can be improved by more than 60%, for example, about 62%, and the degradation of the average peak signal-to-noise ratio (BD-rate) is controlled within about 1%, for example, about 0.7%. On a multi-category set including natural motion videos and conference content, the frame rate improvement is statistically analyzed by category and then the arithmetic average is taken, with an overall improvement of about 23%, of which conference content contributes the main acceleration benefits.
[0044] Additionally, information such as gimbal status, inertial measurement unit data, or conference mode switching can be integrated to assist in scene judgment. Differentiated gating strengths are applied to areas of interest for beautification effects and subtitles. During nighttime monitoring scenarios, the gating aggression is increased to achieve a higher speedup ratio. The zero-motion condition is relaxed to a small-amplitude motion vector threshold to cover cases of slight jitter.
[0045] As can be seen from the above, in the embodiments of this application, when encoding the current encoding unit of the target video, gating encoding acceleration is first triggered based on the scene in which the video is located, and it is determined whether the current encoding unit is located in a static background area. If it is a static background, a target candidate mode is searched from a preset candidate mode set, and it is determined whether the preset gating hit condition is met. If the condition is met, the target candidate mode is used as the candidate mode of this layer, and a downward recursive partitioning search is performed on the current encoding unit. The rate-distortion cost of the current candidate mode and the recursive search result is combined to determine the target encoding mode. If the condition is not met, the target candidate mode is used to make a prediction to obtain the prediction residual. Then, based on the residual distribution, a downward recursive partitioning search or rectangular partitioning pruning is selected. The rate-distortion cost of each candidate encoding mode is compared from the candidate search results, the target encoding mode is selected, and finally the encoding of the current encoding unit is completed according to the target encoding mode. This method determines whether the current scene belongs to this type of static background scene. If it does, large areas of background are skipped and quickly cropped with zero motion. For local high residual areas such as lip movements and gestures, the method determines whether to force subdivision or cut unreasonable rectangular divisions based on the geometric relationship of the four quadrants of the residual. Motion information is then reused on the precisely matched sub-regions. This significantly improves the encoding frame rate, reduces latency, and keeps the image quality loss within an acceptable range, without altering the bitstream syntax or decoder.
[0046] As can be seen from the previous embodiment, this application discloses a video coding method based on residual gating, which can reduce the workload of video coding for scenarios where static backgrounds dominate. Next, we will address... Figure 3 The residual-gated video encoding device shown is described in detail.
[0047] Example 1, Background Block: Take the encoding unit (CU) located on the blurred background wall. B The size is 32×32, and it does not intersect with the protected area, entering the acceleration path. After completing the preset analysis such as merging / skipping, its target candidate mode is the skip mode, and the motion vectors of the effective prediction directions of L0 and L1 are both (0,0), satisfying the hit condition of gate one. Therefore, same-layer pruning is performed, and inter-frame re-search, rectangular and asymmetric partitioning and intra-frame search of this layer are no longer performed, while still performing quartic recursion; the four sub-coding units are also mostly zero-motion skips, and after rate-distortion optimization, CU B Ultimately, the skip mode for this layer is still adopted, and this layer will no longer enter the residual distribution determination and motion reuse. Then, the hit is written into the scene statistics.
[0048] Example 2, Local Block: The coding unit (CU) located at the boundary between the speaker's shoulder and the background is selected. LThe size is 32×32, and it does not intersect with the face protection frame. The high residual threshold T(q) corresponding to the current quantization parameter is 66. Its optimal candidate for merging / skipping analysis is the merging mode, which does not meet the hit condition of gate one, and enters the residual distribution judgment of gate two. The brightness residual of the current best prediction is statistically analyzed in four quadrants, and the results are e0 is 120 (higher on the side closer to the person), e1 is 18, e2 is 22, e3 is 20, and the mean is e avg The residual heterogeneity is approximately 45. The residual heterogeneity H = (120-18) / max(1, 45) ≈ 2.27, which is greater than or equal to the preset heterogeneity threshold of 0.20. It belongs to the case of high heterogeneity in a single quadrant, and the local high residual is confirmed. Since the depth of the reference frame at the same position in each effective prediction direction is greater than the current depth, the temporal depth is confirmed, and a forced split is performed to prune the remaining candidate coding modes in this layer and retain the recursion. If the forced split is not triggered and only rectangular partition pruning is performed, the vertical rectangular partition mode can be pruned when the residuals of the left and right quadrants are approximately the same, and the horizontal rectangular partition mode can be pruned when the residuals of the top and bottom are approximately the same. After recursion to the sub-coding unit, when a certain sub-coding unit analyzes the non-square prediction unit, it finds that the brightness and chromaticity residuals of the square prediction at the same depth in the corresponding sub-region are zero. Therefore, gate 3 is triggered, the actual motion vector, reference frame and prediction direction of the square prediction are reused, the motion estimation of the prediction unit is skipped, and the motion compensation and rate distortion cost calculation are still completed. Finally, the best candidate is selected from the candidates retained in this layer and its sub-layers, and the gating hit status of this block is written back to the scene statistics.
[0049] See Figure 4 As shown, this embodiment of the invention discloses a video encoding device based on residual gating, applied to a video encoder, comprising: The scene judgment module 11 is used to obtain the current encoding unit of the target video, trigger gated encoding acceleration operation based on the scene in which the target video is located, and determine whether the area to which the current encoding unit belongs is a static background scene. The gating hit determination module 12 is used to perform a pattern search on the current coding unit based on a preset pattern set when the area to which the current coding unit belongs is a static background scene, to obtain the target candidate pattern of the current coding unit, and to determine whether the current coding unit meets the preset gating hit condition based on the target candidate pattern; the preset pattern set includes each candidate coding pattern; The first encoding mode determination module 13 is used to determine the target candidate mode as the current layer candidate mode of the current encoding unit if the current encoding unit meets the preset gating hit condition, and to perform a downward recursive partition search on the current encoding unit to obtain a recursive search result, determine the first rate distortion cost corresponding to the current layer candidate mode and the recursive search result based on the target candidate mode, and determine the target encoding mode of the current encoding unit based on the first rate distortion cost. The second coding mode determination module 14 is used to predict the current coding unit based on the target candidate mode if the current coding unit does not meet the preset gating hit condition, obtain the corresponding prediction residual, perform forced splitting or rectangular partition pruning on the current coding unit based on the distribution of the prediction residual, and recursively divide and search downward to obtain the corresponding candidate search results, determine the second rate-distortion cost corresponding to each candidate coding mode according to the candidate search results, and select the target coding mode of the current coding unit from the preset mode set according to each second rate-distortion cost. The encoding completion module 15 is used to complete the encoding of the current encoding unit based on the target encoding mode.
[0050] As can be seen from the above, when encoding the current coding unit of the target video, this application first triggers gating coding acceleration based on the scene in which the video is located, and determines whether the current coding unit is located in a static background area. If it is a static background, a target candidate mode is searched from a preset candidate mode set, and it is determined whether the preset gating hit condition is met. If the condition is met, the target candidate mode is used as the candidate mode of this layer, and a downward recursive partitioning search is performed on the current coding unit. The rate-distortion cost of the current candidate mode and the recursive search result is combined to determine the target coding mode. If the condition is not met, the target candidate mode is used to make a prediction to obtain the prediction residual. Then, based on the residual distribution, a downward recursive partitioning search or rectangular partitioning pruning is selected. The rate-distortion cost of each candidate coding mode is compared from the candidate search results, the target coding mode is selected, and finally the encoding of the current coding unit is completed according to the target coding mode. This method determines whether the current scene belongs to this type of static background scene. If it does, large areas of background are skipped and quickly cropped with zero motion. For local high residual areas such as lip movements and gestures, the method determines whether to force subdivision or cut unreasonable rectangular divisions based on the geometric relationship of the four quadrants of the residual. Motion information is then reused on the precisely matched sub-regions. This significantly improves the encoding frame rate, reduces latency, and keeps the image quality loss within an acceptable range, without altering the bitstream syntax or decoder.
[0051] In some specific implementations, the gating encoding acceleration operation triggered based on the scene in which the target video is located may specifically include: The trigger ratio acquisition unit is used to calculate the ratio of the number of encoding units that meet the preset gating hit conditions in the scene window to the total number of analyzed encoding units in the scene window, and obtain the gating trigger ratio. An acceleration operation triggering unit is configured to determine that the scene in which the target video is located is a static background-dominated scene and trigger the gating encoding acceleration operation if the gating trigger ratio is greater than or equal to a preset enable threshold, or the gating trigger ratio is greater than or equal to a preset disable threshold and the previous scene window of the scene window is in a gating enabled state; wherein, the preset disable threshold is less than the preset enable threshold.
[0052] In some specific implementations, determining whether the region to which the current coding unit belongs is a static background scene may specifically include: The protected area determination unit is used to determine the protected area in the current frame of the target video; the protected area includes any one or more of the following: face area, body area, subtitle area, graphical interface area, and user interest area; A static background determination unit is used to determine that the area to which the current coding unit belongs is a static background scene if the current coding unit does not intersect with the protected area. A non-static background processing unit is used to determine that the area to which the current coding unit belongs is a non-static background scene if the current coding unit intersects with the protected area, and to perform a preset conventional mode search operation on the current coding unit.
[0053] In some specific implementations, determining whether the current coding unit meets the preset gating hit condition based on the target candidate pattern may specifically include: A motion vector determination unit is used to determine the motion vectors of each preset effective prediction direction of the current encoding unit based on the target candidate pattern; A gated hit determination unit is used to determine whether the target candidate mode is a skip mode and whether the magnitude of the motion vector is less than or equal to a preset motion threshold. A gating hit determination unit is used to determine if the current encoding unit meets the preset gating hit condition.
[0054] In some specific implementations, a forced split is performed on the current coding unit based on the distribution of the predicted residuals, and a downward recursive partitioning search is performed. Specifically, this may include: The quadrant residual statistics unit is used to divide the brightness residual in the prediction residual according to the four quadrants of the current coding unit, and determine the mean square error corresponding to each quadrant and the mean value of each mean square error. The threshold and heterogeneity determination unit is used to determine a high residual threshold based on the quantization parameters of the current encoding unit, and to determine residual heterogeneity based on the maximum value, minimum value and mean value of each mean square error; The first residual distribution determination unit is used to determine the distribution of the predicted residual as the first residual distribution if there is a single quadrant or a diagonal quadrant in the mean square error of each quadrant that is greater than the high residual threshold, and the residual heterogeneity is greater than or equal to a preset heterogeneity threshold. The second residual distribution determination unit is used to determine the distribution of the predicted residual as the second residual distribution if the mean square error of each quadrant is greater than the high residual threshold. A forced splitting unit is used to perform a forced split on the current coding unit if the distribution of the predicted residual is either the first residual distribution or the second residual distribution, and the depth of the reference coding unit at the same position in each preset effective prediction direction is greater than the depth of the current coding unit. Then, a downward recursive partitioning search is performed to prune the candidate coding modes at the current depth except for the target candidate mode.
[0055] In some specific implementations, rectangular partitioning pruning is performed on the current coding unit based on the distribution of the predicted residuals, which may specifically include: The quadrant sum determination unit is used to determine, based on the mean square errors of each quadrant, a first sum of the mean square errors of the two left quadrants and a second sum of the mean square errors of the two right quadrants, as well as a third sum of the mean square errors of the two upper quadrants and a fourth sum of the mean square errors of the two lower quadrants. A vertical rectangular partitioning pruning unit is used to determine that the prediction residuals are consistent in the left and right directions if the relative deviation between the first sum and the second sum is less than or equal to a preset similarity tolerance, and to prune the vertical rectangular partitioning patterns in the preset pattern set from the candidate search results. The horizontal rectangular partitioning pruning unit is used to determine that the prediction residuals are consistent in the vertical direction if the relative deviation between the third sum and the fourth sum is less than or equal to the preset similarity tolerance, and to prune the horizontal rectangular partitioning patterns in the preset pattern set from the candidate search results.
[0056] In some specific implementations, after performing forced splitting or rectangular partitioning pruning on the current coding unit based on the distribution of the predicted residuals, the method further includes: A sub-coding unit is used to determine the sub-coding units obtained by recursively dividing the current coding unit downwards when performing forced splitting or rectangular partitioning pruning on the current coding unit; the sub-coding unit includes non-square prediction units. A reference sub-region determination unit is used to determine a square prediction unit at the same depth as the non-square prediction unit, and to determine a sub-region within the square prediction unit that corresponds to the position of the non-square prediction unit. The motion information multiplexing unit is used to multiplex the motion vector, reference frame index and prediction direction of the square prediction unit into the motion information of the non-square prediction unit if the brightness residual of the sub-region is zero, and to skip the motion estimation of the non-square prediction unit. The candidate search calculation unit is used to perform motion compensation and rate distortion cost calculation operations on the non-square prediction unit based on the reused motion information, so as to obtain the candidate search results corresponding to the non-square prediction unit.
[0057] Furthermore, embodiments of this application also disclose an electronic device, Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the residual gating-based video coding method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0058] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0059] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0060] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the residual gating-based video coding method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0061] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned residual gating-based video coding method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0062] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0063] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art 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.
[0064] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0065] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0066] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A video coding method based on residual gating, characterized in that, Applied to video encoders, including: Obtain the current encoding unit of the target video, trigger gated encoding acceleration operation based on the scene in which the target video is located, and determine whether the area to which the current encoding unit belongs is a static background scene; When the region to which the current coding unit belongs is a static background scene, a pattern search is performed on the current coding unit based on a preset pattern set to obtain the target candidate pattern of the current coding unit. Based on the target candidate pattern, it is determined whether the current coding unit meets the preset gating hit condition. The preset pattern set includes each candidate coding pattern. If the current coding unit meets the preset gating hit condition, the target candidate mode is determined as the candidate mode of the current layer of the current coding unit, and the current coding unit is recursively partitioned downward to obtain the recursive search result. The first rate distortion cost corresponding to the candidate mode of the current layer and the recursive search result is determined according to the target candidate mode, and the target coding mode of the current coding unit is determined according to the first rate distortion cost. If the current coding unit does not meet the preset gating hit condition, then the current coding unit is predicted based on the target candidate pattern to obtain the corresponding prediction residual. Based on the distribution of the prediction residual, the current coding unit is subjected to forced splitting or rectangular partition pruning, and the search is recursively divided downward to obtain the corresponding candidate search results. The second rate-distortion cost corresponding to each candidate coding pattern is determined according to the candidate search results. The target coding pattern of the current coding unit is selected from the preset pattern set according to each second rate-distortion cost. The current coding unit is encoded based on the target coding pattern.
2. The video coding method based on residual gating according to claim 1, characterized in that, The scene-based gating encoding acceleration operation triggered by the target video includes: The gating trigger ratio is obtained by comparing the number of coding units that meet the preset gating hit conditions within the scene window with the total number of analyzed coding units within the scene window. If the gating trigger ratio is greater than or equal to the preset enable threshold, or if the gating trigger ratio is greater than or equal to the preset disable threshold and the previous scene window of the scene window is in the gating enable state, then the scene where the target video is located is determined to be a static background dominant scene, and the gating encoding acceleration operation is triggered; wherein, the preset disable threshold is less than the preset enable threshold.
3. The video coding method based on residual gating according to claim 1, characterized in that, The step of determining whether the region to which the current coding unit belongs is a static background scene includes: Determine the protected region in the current frame of the target video; the protected region includes any one or more of the following: face region, body region, subtitle region, graphical interface region, and region of interest. If the current coding unit does not intersect with the protected area, then the area to which the current coding unit belongs is determined to be a static background scene; If the current coding unit intersects with the protected area, the area to which the current coding unit belongs is determined to be a non-static background scene, and a preset normal mode search operation is performed on the current coding unit.
4. The video coding method based on residual gating according to claim 1, characterized in that, The step of determining whether the current coding unit meets the preset gating hit condition based on the target candidate pattern includes: Based on the target candidate pattern, determine the motion vectors of each preset effective prediction direction of the current coding unit; Determine whether the target candidate mode is a skip mode, and whether the amplitude of the motion vector is less than or equal to a preset motion threshold; If so, the current encoding unit is determined to meet the preset gating hit condition.
5. The video coding method based on residual gating according to claim 4, characterized in that, Based on the distribution of the predicted residuals, a forced split is performed on the current coding unit, and a downward recursive partitioning search is conducted, including: The brightness residual in the prediction residual is divided into four quadrants according to the current coding unit, and the mean square error corresponding to each quadrant and the mean value of each mean square error are determined respectively. A high residual threshold is determined based on the quantization parameters of the current coding unit, and residual heterogeneity is determined based on the maximum value, minimum value and mean value of each mean square error; If there is a single quadrant or a diagonal quadrant in the mean square error of each quadrant that is greater than the high residual threshold, and the residual heterogeneity is greater than or equal to the preset heterogeneity threshold, then the distribution of the predicted residual is determined to be the first residual distribution. If the mean square error of each quadrant is greater than the high residual threshold, then the distribution of the predicted residual is determined to be the second residual distribution. If the distribution of the predicted residual is either the first residual distribution or the second residual distribution, and the depth of the reference co-position coding unit in each preset effective prediction direction is greater than the depth of the current coding unit, then the current coding unit is forcibly split, and a downward recursive partitioning search is performed to prune candidate coding modes at the current depth other than the target candidate mode.
6. The video coding method based on residual gating according to claim 5, characterized in that, Based on the distribution of the predicted residuals, rectangular partitioning pruning is performed on the current coding unit, including: Based on the mean square errors described above, determine the first sum of the mean square errors of the two left quadrants and the second sum of the mean square errors of the two right quadrants, as well as the third sum of the mean square errors of the two upper quadrants and the fourth sum of the mean square errors of the two lower quadrants. If the relative deviation between the first sum and the second sum is less than or equal to the preset similarity tolerance, then it is determined that the prediction residual is consistent in the left and right directions, and the vertical rectangular partitioning pattern in the preset pattern set is removed from the candidate search results; If the relative deviation between the third sum and the fourth sum is less than or equal to the preset similarity tolerance, then it is determined that the prediction residuals are consistent in the vertical direction, and the horizontal rectangular partitioning patterns in the preset pattern set are removed from the candidate search results.
7. The video coding method based on residual gating according to claim 1, characterized in that, After performing forced splitting or rectangular partitioning pruning on the current coding unit based on the distribution of the predicted residuals, the method further includes: When performing forced splitting or rectangular partitioning pruning on the current coding unit, the sub-coding units obtained by recursively dividing the current coding unit downwards are determined; the sub-coding units include non-square prediction units; Identify square prediction cells at the same depth as the non-square prediction cells, and determine the sub-regions within the square prediction cells that correspond to the positions of the non-square prediction cells; If the brightness residual of the sub-region is zero, the motion vector, reference frame index and prediction direction of the square prediction unit are reused as the motion information of the non-square prediction unit, and the motion estimation of the non-square prediction unit is skipped. Based on the motion information obtained through reuse, motion compensation and rate-distortion cost calculation operations are performed on the non-square prediction unit to obtain the candidate search results corresponding to the non-square prediction unit.
8. A video encoding device based on residual gating, characterized in that, Applied to video encoders, including: The scene judgment module is used to obtain the current encoding unit of the target video, trigger gated encoding acceleration operation based on the scene in which the target video is located, and determine whether the area to which the current encoding unit belongs is a static background scene. The gating hit determination module is used to perform a pattern search on the current coding unit based on a preset pattern set when the area to which the current coding unit belongs is a static background scene, to obtain the target candidate pattern of the current coding unit, and to determine whether the current coding unit meets the preset gating hit condition based on the target candidate pattern; the preset pattern set includes each candidate coding pattern; The first encoding mode determination module is used to determine the target candidate mode as the current layer candidate mode of the current encoding unit if the current encoding unit meets the preset gating hit condition, and to perform a downward recursive partition search on the current encoding unit to obtain a recursive search result, determine the first rate distortion cost corresponding to the current layer candidate mode and the recursive search result based on the target candidate mode, and determine the target encoding mode of the current encoding unit based on the first rate distortion cost. The second coding mode determination module is used to predict the current coding unit based on the target candidate mode if the current coding unit does not meet the preset gating hit condition, obtain the corresponding prediction residual, perform forced splitting or rectangular partition pruning on the current coding unit based on the distribution of the prediction residual, and recursively divide and search downward to obtain the corresponding candidate search results, determine the second rate-distortion cost corresponding to each candidate coding mode according to the candidate search results, and select the target coding mode of the current coding unit from the preset mode set according to each second rate-distortion cost; The encoding completion module is used to complete the encoding of the current encoding unit based on the target encoding mode.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the residual gating-based video coding method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein, when the computer programs are executed by a processor, they implement the video coding method based on residual gating as described in any one of claims 1 to 7.
