CN112929668B - Video coding method, device, equipment and storage medium - Google Patents
Video coding method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN112929668B CN112929668B CN202110372888.1A CN202110372888A CN112929668B CN 112929668 B CN112929668 B CN 112929668B CN 202110372888 A CN202110372888 A CN 202110372888A CN 112929668 B CN112929668 B CN 112929668B
- Authority
- CN
- China
- Prior art keywords
- target
- coding
- macro block
- offset
- video frame
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 40
- 230000003044 adaptive effect Effects 0.000 claims abstract description 41
- 230000006641 stabilisation Effects 0.000 claims abstract description 18
- 238000011105 stabilization Methods 0.000 claims abstract description 18
- 238000001514 detection method Methods 0.000 claims description 10
- 238000004364 calculation method Methods 0.000 claims description 7
- 230000001105 regulatory effect Effects 0.000 claims description 4
- 238000004590 computer program Methods 0.000 claims description 3
- 238000005457 optimization Methods 0.000 abstract description 8
- 238000010586 diagram Methods 0.000 description 7
- 238000004422 calculation algorithm Methods 0.000 description 5
- 230000006870 function Effects 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 238000013139 quantization Methods 0.000 description 2
- 230000008859 change Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/169—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding
- H04N19/17—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object
- H04N19/176—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the coding unit, i.e. the structural portion or semantic portion of the video signal being the object or the subject of the adaptive coding the unit being an image region, e.g. an object the region being a block, e.g. a macroblock
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/102—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
- H04N19/124—Quantisation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/10—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
- H04N19/134—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or criterion affecting or controlling the adaptive coding
- H04N19/146—Data rate or code amount at the encoder output
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N19/00—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
- H04N19/42—Methods or arrangements for coding, decoding, compressing or decompressing digital video signals characterised by implementation details or hardware specially adapted for video compression or decompression, e.g. dedicated software implementation
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
The embodiment of the invention discloses a method, a device, equipment and a storage medium for video coding. Wherein the method comprises the following steps: calculating a target coding offset when the target macro block reaches the adaptive coding quality based on the duty ratio of the target macro block in the current video frame; calculating non-target coding offset of non-target macro blocks in the current video frame based on a frame-level coding stabilization principle and a target coding offset; and correspondingly adjusting macro block coding parameters of the target macro block and the non-target macro block by adopting the target coding offset and the non-target coding offset. The technical scheme provided by the embodiment of the invention realizes the coding optimization of the target macro block and the non-target macro block of the current video frame, greatly reduces the complexity and the coding cost of video coding and ensures the high efficiency of video coding; meanwhile, on the basis of guaranteeing the high efficiency of video coding, the coding quality of the video is further improved.
Description
Technical Field
The embodiment of the invention relates to the technical field of video coding, in particular to a method, a device, equipment and a storage medium for video coding.
Background
With the rapid development of internet technology, the more and more the functions of the social entertainment product are made, wherein video coding is used as a basic function, and plays an important role in the fields of video call, short video recording, video live broadcasting and the like. In addition, for some regions of interest (Region of Interest, ROI) in the video frame, where there is a high-definition display requirement, adaptive coding is required to be performed on the regions of interest specifically, so as to improve the playing image quality of the regions of interest.
At present, a third party ROI detection device is generally adopted to identify an interested region and a non-interested region in a video frame, then the rate distortion cost of each coding unit in the interested region and the non-interested region in each prediction coding mode under the corresponding recursion depth is calculated through traversal, and the rate distortion cost of each transformation unit divided by the coding units in each prediction coding mode is further used for screening out the optimal coding mode with the minimum cost for each coding unit in the interested region and the non-interested region, so that the coding quality of the interested region and the non-interested region is ensured.
However, the existing ROI coding algorithm is too complex, and has large coding overhead, which greatly affects the efficiency of video coding.
Disclosure of Invention
The embodiment of the invention provides a video coding method, a device, equipment and a storage medium, which can reduce the complexity and the calculation cost of video coding and improve the coding quality of video on the basis of ensuring the high efficiency of video coding.
In a first aspect, an embodiment of the present invention provides a method for video encoding, including:
calculating a target coding offset when the target macro block reaches the adaptive coding quality based on the duty ratio of the target macro block in the current video frame;
calculating non-target coding offset of non-target macro blocks in the current video frame based on a frame-level coding stabilization principle and the target coding offset;
and correspondingly adjusting macro block coding parameters of the target macro block and the non-target macro block by adopting the target coding offset and the non-target coding offset.
In a second aspect, an embodiment of the present invention provides an apparatus for video encoding, including:
the target offset calculating module is used for calculating the target coding offset when the target macro block reaches the adaptive coding quality based on the duty ratio of the target macro block in the current video frame;
The non-target offset calculating module is used for calculating the non-target coding offset of the non-target macro block in the current video frame based on the frame-level coding stabilization principle and the target coding offset;
And the coding parameter adjustment module is used for correspondingly adjusting the macro block coding parameters of the target macro block and the non-target macro block by adopting the target coding offset and the non-target coding offset.
In a third aspect, an embodiment of the present invention provides a computer apparatus, including:
One or more processors;
A storage means for storing one or more programs;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the methods of video encoding as described in any of the embodiments of the present invention.
In a fourth aspect, embodiments of the present invention provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of video encoding according to any embodiment of the present invention.
According to the video coding method, device, equipment and storage medium provided by the embodiment of the invention, the adaptive coding quality of the target macro block can be analyzed through the duty ratio of the target macro block in the current video frame, so that the target coding offset when the target macro block reaches the adaptive coding quality is calculated, then the non-target coding offset of the non-target macro block in the current video frame can be calculated by utilizing the target coding offset based on the frame-level coding stabilization principle, then the macro block coding parameters of the target macro block and the non-target macro block are correspondingly adjusted by adopting the target coding offset and the non-target coding offset, so that the coding optimization of the target macro block and the non-target macro block of the current video frame is realized, the coding cost in an unnecessary coding division mode is not required to be calculated, the complexity and the coding cost of video coding are greatly reduced, and the high efficiency of video coding is ensured; meanwhile, the target coding offset and the non-target coding offset are adopted, and after macro block coding parameters of the target macro block and the non-target macro block are correspondingly adjusted, the coding quality of the video can be further improved on the basis of guaranteeing the high efficiency of video coding.
Drawings
Other features, objects and advantages of the present invention will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the accompanying drawings in which:
Fig. 1A is a flowchart of a method for video encoding according to a first embodiment of the present invention;
fig. 1B is a schematic diagram of a video encoding process according to a first embodiment of the present invention;
fig. 2A is a flowchart of a method for video encoding according to a second embodiment of the present invention;
fig. 2B is a schematic diagram of a video encoding process according to a second embodiment of the present invention;
Fig. 3 is a flowchart of a method for video encoding according to a third embodiment of the present invention;
Fig. 4 is a schematic structural diagram of a video encoding apparatus according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of a computer device according to a fifth embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings. Furthermore, embodiments of the invention and features of the embodiments may be combined with each other without conflict.
Example 1
Fig. 1A is a flowchart of a video encoding method according to an embodiment of the present invention, which is applicable to a scenario where encoding requirements exist for any video. The video coding method provided in the present embodiment may be performed by the video coding apparatus provided in the present embodiment, where the apparatus may be implemented by software and/or hardware, and integrated in a computer device that performs the method, where the device may be a background server that participates in video data interaction, etc.
Specifically, referring to fig. 1A, the method may include the steps of:
S110, calculating a target coding offset when the target macro block reaches the adaptive coding quality based on the duty ratio of the target macro block in the current video frame.
Specifically, because different areas in each frame of various videos can respectively display different video pictures, and users can be interested in certain specific picture areas, the video pictures of each region of interest in the video frames can be required to adopt a high-quality coding mode as far as possible, so that the picture high definition of the region of interest is ensured, and the video quality of the region of interest is improved. The region of interest in this embodiment may be a local region having uniform specific picture characteristics in a video frame for accurately identifying the region of interest, for example, a face region that can be detected by skin color in a scene such as a video call or a video live broadcast.
At this time, when the current video frame is video-encoded, as shown in fig. 1B, since the current video frame is generally divided into a plurality of macro blocks, the macro blocks may be 16×16 pixel blocks, and then the macro blocks are used as encoding units to encode the current video frame, the embodiment may further improve the video quality of the region of interest by optimizing the encoding mode of the macro block where each region of interest is located. Wherein the current video frame is the original video data which is not subjected to data processing.
In this embodiment, the same specific picture feature of the region of interest is adopted, so as to analyze whether the picture of each macro block in the current video frame is the picture of the region of interest, further divide the macro block in the current video frame into a target macro block and a non-target macro block, and determine the duty ratio of the target macro block in the current video frame. Wherein all pictures within the target macroblock are regions of interest, and video pictures within the non-target macroblock will contain pictures other than the regions of interest.
At this time, if the target macro block in the current video frame occupies a relatively high area, it is indicated that more target macro blocks exist in the current video frame and further optimizing the coding quality based on the current coding quality, and considering that the more the detail features of the video picture are required to be preserved when the coding quality is higher, the greater the coding rate of the target macro block is, at this time, if each target macro block adopts the coding mode under the highest coding quality, the coding rate of the current video frame is too high and exceeds the requirement of the current network bandwidth, so that video coding congestion is generated. Therefore, in order to keep the stable encoding of the current video frame, the embodiment will reversely set different adaptive encoding quality according to different duty ratios of the target macro block in the current video frame, and each adaptive encoding quality is required to be better than the current encoding quality, for example, the higher the duty ratio is, the larger the total amount of encoding of the target macro block in the current video frame is, the lower the optimized amplitude of the adaptive encoding quality relative to the current encoding quality is set, and the lower the duty ratio is, the smaller the total amount of encoding of the target macro block in the current video frame is, and the higher the optimized amplitude of the adaptive encoding quality relative to the current encoding quality is. Then, a target coding offset is calculated when the target macroblock reaches the adaptive coding quality, the target coding offset can accurately represent an optimized amplitude between the adaptive coding quality and the current coding quality, that is, the larger the duty ratio of the target macroblock in the current video frame is, the smaller the target coding offset is, and the smaller the duty ratio of the target macroblock in the current video frame is, the larger the target coding offset is.
S120, calculating the non-target coding offset of the non-target macro block in the current video frame based on the frame-level coding stabilization principle and the target coding offset.
Optionally, the frame-level coding stabilization principle in this embodiment refers to that in order to avoid congestion phenomenon caused by the fact that the coding rate exceeds the current network bandwidth, it is required that the overall coding parameters of the current video frame can remain approximately unchanged after the target macroblock and the non-target macroblock are optimally coded. That is, to satisfy the frame-level coding stabilization principle, the overall coding offset of the target macroblock and the non-target macroblock within the current video frame is approximately 0. Therefore, the overall coding offset of the target macroblock can be calculated by using the target coding offset and the target macroblock number of the target macroblock, and then the non-target coding offset of the non-target macroblock can be calculated according to the non-target macroblock number in the current video frame.
S130, adopting the target coding offset and the non-target coding offset to correspondingly adjust the macro block coding parameters of the target macro block and the non-target macro block.
Optionally, after the target coding offset of the target macroblock and the non-target coding offset of the non-target macroblock in the current video frame are obtained, a video macroblock-level code control algorithm is adopted, macroblock coding parameters of each target macroblock and each non-target macroblock when meeting the current network bandwidth requirement can be calculated respectively, and then in order to further optimize the coding quality of the target macroblock, the embodiment can adjust the macroblock coding parameters of each target macroblock in the current video frame by adopting the target coding offset, so that the target macroblock can adopt more picture detail features to perform video coding, and the coding quality of video can be further improved on the basis of guaranteeing the video coding efficiency. Meanwhile, in order to ensure the overall stability of video frame level coding, the macro block coding parameters of each non-target macro block in the current video frame are adjusted by adopting non-target coding offset so as to realize the coding optimization of the current video frame.
According to the technical scheme provided by the embodiment, the adaptive coding quality of the target macro block can be analyzed through the duty ratio of the target macro block in the current video frame, so that the target coding offset when the target macro block reaches the adaptive coding quality is calculated, then the non-target coding offset of the non-target macro block in the current video frame can be calculated by utilizing the target coding offset based on the frame-level coding stabilization principle, then the macro block coding parameters of the target macro block and the non-target macro block are correspondingly adjusted by adopting the target coding offset and the non-target coding offset, so that the coding optimization of the target macro block and the non-target macro block of the current video frame is realized, the coding cost in an unnecessary coding division mode is not required to be calculated, the complexity and the coding cost of video coding are greatly reduced, and the high efficiency of video coding is ensured; meanwhile, the target coding offset and the non-target coding offset are adopted, and after macro block coding parameters of the target macro block and the non-target macro block are correspondingly adjusted, the coding quality of the video can be further improved on the basis of guaranteeing the high efficiency of video coding.
Example two
Fig. 2A is a flowchart of a video encoding method according to a second embodiment of the present invention, and fig. 2B is a schematic diagram of a video encoding process according to a second embodiment of the present invention. This embodiment is optimized based on the above embodiment. Specifically, as shown in fig. 2B, the present embodiment mainly explains the specific calculation process of the target coding offset of the target macroblock and the non-target coding offset of the non-target macroblock in the current video frame in detail.
Optionally, as shown in fig. 2A, the present embodiment may include the following steps:
S210, determining a coding offset base value which is set under the adaptive coding quality and matched with the duty ratio of the target macro block.
Optionally, in order to ensure accurate matching between the target macroblock duty ratio and the adaptive coding quality, the present embodiment may divide the duty ratio stages suitable for different adaptive coding quality for the target macroblock duty ratio in advance, for example, in the four stages (0,0.15), (0.15,0.35), (0.35,0.5) and (0.5, 1) of the target macroblock duty ratio, the adaptive coding quality required in each stage is different, where the smaller the duty ratio of the target macroblock, the higher the adaptive coding quality in the duty ratio stage.
In order to accurately represent the adaptive coding quality of different duty ratio stages, the embodiment sets a matched coding offset base value under each adaptive coding quality, and the coding offset base value can ensure that the adaptive coding quality can be maximally achieved after the target macro block performs coding parameter adjustment on the basis of the current network bandwidth.
Specifically, the coding parameters in this embodiment may be coding quantization parameters (Quantization Parameter, QP), before the current video frame is coded, a frame-level coding algorithm may be used in this embodiment to calculate a frame-level coding parameter (qp_base) that meets the current network bandwidth requirement, and meanwhile, a maximum coding parameter (qp_max) that is specified by the outside and meets the coding requirement for the current video frame, where the maximum coding parameter is used to ensure video coding quality, and represents an upper limit of coding when the current network bandwidth requirement is not exceeded to avoid the problem of coding congestion or excessive coding, and if the coding parameter after the frame-level coding parameter is adjusted exceeds the maximum coding parameter, the coding rate is caused to underflow, but the preset code rate is not reached, so that the coding quality of the video frame is worse than expected, that is, the frame-level coding adjustable value (qp_diff) of the current video frame is the difference between the frame-level coding parameter and the maximum coding parameter. Meanwhile, in order to ensure adaptive code rate adjustment of the target macroblock, the present embodiment also sets a corresponding macroblock reference offset value (roi_qp_off) for the target macroblock in the current video frame.
At this time, the duty ratio of the target macroblock is smaller than the duty ratio specified by the highest coding quality, that is, the duty ratio of the target macroblock is in the (0,0.15) stage, the matched coding offset base value may be set to the frame-level coding adjustable value (qp_diff) of the current video frame, otherwise, the matched coding offset base value may be set to the minimum value of the frame-level coding adjustable value (qp_diff) and the macroblock reference offset value (roi_qp_off) of the target macroblock, that is, qp_diff_limit=min (qp_diff, roi_qp_off).
S220, calculating the target coding offset of the target macro block based on the coding offset base value and the reverse influence parameter of the duty ratio of the target macro block on the adaptive coding quality.
In this embodiment, after the coding offset base value matched with the duty ratio of the target macroblock is calculated, the smaller the duty ratio of the target macroblock is, the higher the coding quality achieved by the target macroblock is, so that the duty ratio of the target macroblock has a negative influence on the adaptive coding quality, and at this time, the calculated coding offset base value is adjusted by the negative influence parameter of the duty ratio of the target macroblock on the adaptive coding quality, so that the target coding offset of the calculated target macroblock can be calculated.
For example, the target coding offset of the target macroblock may be calculated as follows:
1) When the duty cycle of the target macroblock is in stage (0,0.15), the target encoding offset for the target macroblock is QP 1=QP_diff*(1-ROI_ratio2); where roi_ratio is the duty cycle of the target macroblock.
2) When the duty cycle of the target macroblock is in stage (0.15,0.35), the target coding offset for the target macroblock is QP 1=QP_diff_limit*(1-ROI_ratio2.
3) When the duty cycle of the target macroblock is in stage (0.35,0.5), the target encoding offset for the target macroblock is QP 1=QP_diff_limit*(1-ROI_ratio2) -qp_diff_limit/6.
4) When the duty cycle of the target macroblock is in the (0.5, 1) phase, the target coding offset of the target macroblock is QP 1 =qp_diff_limit (1-roi_ratio).
As can be seen from the above calculation formula, as the duty ratio of the target macroblock increases, the smaller the target encoding offset of the target macroblock, that is, the smaller the encoding quality optimization amplitude of each target macroblock.
S230, calculating the non-target coding offset of the non-target macro block in the current video frame based on the target coding offset, the adjustable frame-level coding value of the current video frame and the number of the target macro block and the non-target macro block in the current video frame.
Optionally, considering that when the encoding parameter adjustment is performed in the range corresponding to the frame-level encoding adjustable value of the current video frame, the encoding code rate can be regulated and controlled to be stable, so that the problem of encoding congestion or excessive encoding is avoided, namely, the problem that the overall offset of the frame-level encoding parameter is allowed to be within the range of the frame-level encoding adjustable value is solved, at the moment, the overall offset of the target macroblock in the current video frame can be calculated by utilizing the target encoding offset of the target macroblock and the number of the target macroblock in the current video frame, then the overall offset of the non-target macroblock can be estimated by utilizing the overall offset of the target macroblock in the range corresponding to the frame-level encoding adjustable value of the current video frame, and further, the non-target encoding offset of the non-target macroblock is calculated according to the number of the non-target macroblock in the current video frame.
S240, the macro block coding parameter of each target macro block is up-regulated by the target coding offset to obtain the actual coding parameter of the target macro block.
Optionally, in order to ensure that the encoding quality of the target macro block in the current video frame is higher, and realize high definition display of the region of interest in the current video frame, more detail picture features can be adopted when the target macro block is encoded, so that the target encoding offset can be adopted to correspondingly up-regulate macro block encoding parameters calculated by a macro block level code control algorithm of each target macro block to obtain actual encoding parameters of the target macro block, and when the actual encoding parameters are adopted to encode the target macro block, more detail picture features can be obtained, thereby further improving the encoding quality of the target macro block.
S250, adopting the non-target coding offset to downwards adjust the macro block coding parameter of each non-target macro block to obtain the actual coding parameter of the non-target macro block.
Optionally, in order to ensure stable frame-level coding of the current video frame, after up-regulating macro-block coding parameters of a target macro-block in the current video frame, the embodiment further adopts a non-target coding offset to correspondingly regulate macro-block coding parameters calculated by a macro-block-level code control algorithm of each non-target macro-block to obtain actual coding parameters of the non-target macro-block, and then adopts the actual coding parameters to code the non-target macro-block, thereby realizing stable frame-level coding of the current video frame and avoiding the phenomenon of coding congestion or excessive coding.
According to the technical scheme provided by the embodiment, the target coding offset of the target macro block is calculated by adopting the coding offset base value matched with the duty ratio of the target macro block and the reverse influence parameter of the duty ratio of the target macro block on the adaptive coding quality, so that the accuracy of the target macro block coding optimization is ensured, and meanwhile, the target coding offset of the target macro block and the number of target macro blocks and non-target macro blocks in the current video frame are utilized in the range corresponding to the frame-level coding adjustable value of the current video frame, so that the non-target coding offset of the non-target macro block is calculated, the stability of video frame-level coding is ensured, and the phenomenon of coding congestion or excessive coding is avoided.
Example III
Fig. 3 is a flowchart of a method for video encoding according to a third embodiment of the present invention. This embodiment is optimized based on the above embodiment. Specifically, since the region of interest in the current video frame is not uniformly distributed, there is a non-target macroblock that is composed of the video picture of the region of interest and the video picture of the non-region of interest together, so in this embodiment, the non-target macroblock may include two types of local non-target macroblocks and complete non-target macroblocks, where the local non-target macroblock is composed of the video picture of the region of interest and the video picture of the non-region of interest together, and the complete non-target macroblock is only the video picture of the non-region of interest. In this embodiment, a detailed explanation will be mainly made on a specific calculation process of the non-target encoding offset of the local non-target macroblock and the total non-target macroblock under the non-target macroblock.
Optionally, as shown in fig. 3, the present embodiment may include the following steps:
s310, detecting the type of each macro block in the current video frame by adopting a target area detection model, and counting the number of target macro blocks and non-target macro blocks in the current video frame so as to calculate the duty ratio of the target macro blocks in the current video frame.
Optionally, in this embodiment, for different regions of interest, a target region detection model for accurately identifying unified specific picture features of the regions of interest is preset, and each macro block in the current video frame is traversed through the target region detection model to determine whether all video pictures in the macro block are regions of interest, and if so, the macro block is determined to be a target macro block; if part of video pictures in the macro block are interested areas and part of video pictures are non-interested areas, determining the macro block as a local non-target macro block; if all video pictures in the macro block are non-interested areas, determining the macro block as a completely non-target macro block; and simultaneously counting the number of target macro blocks in the current video frame and the number of local non-target macro blocks and total non-target macro blocks in the non-target macro blocks, so as to calculate the duty ratio of the target macro blocks in the current video frame.
For example, if the region of interest is a skin tone region, the embodiment may nest a VPx skin tone detection model in a VPx open source encoder, where the VPx skin tone detection model has a higher detection efficiency for the skin tone region within the video frame.
At this time, corresponding width and height information is acquired for the current video frame, which are width and height respectively; then, traversing the current video frame by taking macro blocks with the size of 16 x 16 as a coding unit to divide the current video frame into macro blocks (x, y), wherein x takes a value of [0, width/16], y takes a value of [0, height/16], further finishing skin color detection of each macro block by means of a VPx skin color detection model, outputting three macro block types of a target macro block, a local non-target macro block and a complete non-target macro block, and counting proficiency of the target macro block, the local non-target macro block and the complete non-target macro block as n1, n2 and n3 respectively, wherein the duty ratio of the target macro block in the current video frame can be
S320, calculating a target coding offset when the target macro block reaches the adaptive coding quality based on the duty ratio of the target macro block in the current video frame.
S330, calculating the non-target coding offset reference quantity of the non-target macro block based on the frame-level coding stabilization principle and the target coding offset quantity.
Specifically, in order to meet the frame-level coding stabilization principle, the overall coding offset of the target macro block and the non-target macro block in the current video frame is approximately 0, and then the overall coding offset of the target macro block can be calculated by using the target coding offset of the target macro block and the number of the target macro blocks, and then the non-target coding offset reference of the non-target macro block can be calculated according to the number of the non-target macro blocks in the current video frame.
Wherein the non-target coding offset reference amount of the non-target macro block can be as followsThe QP 1 is a target coding offset of the target macroblock, and then, by further adjusting the non-target coding offset reference, the accuracy of the non-target coding offsets of the local non-target macroblock and the complete non-target macroblock is ensured.
S340, based on the adjustable frame-level coding value of the current video frame, the non-target coding offset reference quantity is adjusted downwards, and the non-target coding offset quantity of the local non-target macro block is obtained; and up-regulating the non-target coding offset reference quantity to obtain the non-target coding offset quantity of the completely non-target macro block.
Alternatively, since the local non-target macro block is composed of the video picture of the region of interest and the video picture of the non-region of interest together, and the completely non-target macro block is composed of only the video picture of the non-region of interest, the encoding of the local non-target macro block requires that an encoding buffer be made between the target macro block and the completely non-target macro block. That is, based on the adjustable value of the frame level coding of the current video frame, a variable quantity meeting the requirement of the adjustable value of the frame level coding is set, so that the current video frame can meet the requirement of the current code control, and the calculated non-target coding offset reference quantity is downwards adjusted by adopting the variable quantity to serve as the non-target coding offset of the local non-target macro block; meanwhile, the calculated non-target coding offset reference quantity is up-regulated by the variable quantity to be used as the non-target coding offset quantity of the completely non-target macro block, so that the non-target coding offset quantity of the local non-target macro block can be lower than the non-target coding offset quantity of the completely non-target macro block when the frame-level coding stability of the current video frame is ensured, and the coding quality of the local non-target macro block can be better than that of the completely non-target macro block. And then, correspondingly adjusting the macro block coding parameters of each macro block by adopting corresponding coding offset to obtain the actual coding parameters of each macro block.
For example, if the set change amount is delta based on the frame-level encoding adjustable value of the current video frame, the non-target encoding offset of the local non-target macroblock may beThe non-target coding offset of a completely non-target macroblock may be/>
S350, adjusting macro block coding parameters of each target macro block by using the target coding offset to obtain actual coding parameters of the target macro block; adjusting macro block coding parameters of each local non-target macro block by adopting non-target coding offset of the local non-target macro block to obtain actual coding parameters of the local non-target macro block; and adjusting the macro block coding parameter of each completely non-target macro block by adopting the non-target coding offset of the completely non-target macro block to obtain the actual coding parameter of the completely non-target macro block.
S360, for each macro block in the current video frame, the macro block is encoded by adopting macro block encoding parameters adjusted by the macro block.
Optionally, after calculating the actual coding parameter of each macroblock in the current video frame, each macroblock may be sequentially encoded by adopting the actual coding parameter of each macroblock after being adjusted according to the corresponding coding offset.
According to the technical scheme provided by the embodiment, the adaptive coding quality of the target macro block can be analyzed through the duty ratio of the target macro block in the current video frame, so that the target coding offset when the target macro block reaches the adaptive coding quality is calculated, then the non-target coding offset of the non-target macro block in the current video frame can be calculated by utilizing the target coding offset based on the frame-level coding stabilization principle, then the macro block coding parameters of the target macro block and the non-target macro block are correspondingly adjusted by adopting the target coding offset and the non-target coding offset, so that the coding optimization of the target macro block and the non-target macro block of the current video frame is realized, the coding cost in an unnecessary coding division mode is not required to be calculated, the complexity and the coding cost of video coding are greatly reduced, and the high efficiency of video coding is ensured; meanwhile, the target coding offset and the non-target coding offset are adopted, and after macro block coding parameters of the target macro block and the non-target macro block are correspondingly adjusted, the coding quality of the video can be further improved on the basis of guaranteeing the high efficiency of video coding.
Example IV
Fig. 4 is a schematic structural diagram of a video encoding apparatus according to a fourth embodiment of the present invention, and specifically, as shown in fig. 4, the apparatus may include:
a target offset calculation module 410, configured to calculate a target coding offset when the target macroblock reaches an adaptive coding quality based on a duty ratio of the target macroblock in a current video frame;
A non-target offset calculation module 420, configured to calculate a non-target coding offset of a non-target macroblock in a current video frame based on a frame-level coding stabilization principle and the target coding offset;
The encoding parameter adjustment module 430 is configured to correspondingly adjust macroblock encoding parameters of the target macroblock and the non-target macroblock by using the target encoding offset and the non-target encoding offset.
According to the technical scheme provided by the embodiment, the adaptive coding quality of the target macro block can be analyzed through the duty ratio of the target macro block in the current video frame, so that the target coding offset when the target macro block reaches the adaptive coding quality is calculated, then the non-target coding offset of the non-target macro block in the current video frame can be calculated by utilizing the target coding offset based on the frame-level coding stabilization principle, then the macro block coding parameters of the target macro block and the non-target macro block are correspondingly adjusted by adopting the target coding offset and the non-target coding offset, so that the coding optimization of the target macro block and the non-target macro block of the current video frame is realized, the coding cost in an unnecessary coding division mode is not required to be calculated, the complexity and the coding cost of video coding are greatly reduced, and the high efficiency of video coding is ensured; meanwhile, the target coding offset and the non-target coding offset are adopted, and after macro block coding parameters of the target macro block and the non-target macro block are correspondingly adjusted, the coding quality of the video can be further improved on the basis of guaranteeing the high efficiency of video coding.
The video coding device provided by the embodiment is applicable to the video coding method provided by any embodiment, and has corresponding functions and beneficial effects.
Example five
Fig. 5 is a schematic structural diagram of a computer device according to a fifth embodiment of the present invention, and as shown in fig. 5, the computer device includes a processor 50, a storage device 51 and a communication device 52; the number of processors 50 in the computer device may be one or more, one processor 50 being taken as an example in fig. 5; the processor 50, the storage means 51 and the communication means 52 in the computer device may be connected by a bus or other means, in fig. 5 by way of example.
The computer device provided in this embodiment may be used to execute the video encoding method provided in any of the foregoing embodiments, and has corresponding functions and beneficial effects.
Example six
The sixth embodiment of the present invention also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of video encoding in any of the above embodiments.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present invention is not limited to the above-described method operations, and may also perform the related operations in the video encoding method provided in any embodiment of the present invention.
From the above description of embodiments, it will be clear to a person skilled in the art that the present invention may be implemented by means of software and necessary general purpose hardware, but of course also by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk, or an optical disk of a computer, etc., and include several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments of the present invention.
It should be noted that, in the embodiment of the video encoding apparatus, each unit and module included are only divided according to the functional logic, but not limited to the above-mentioned division, so long as the corresponding functions can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, and various modifications and variations may be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (11)
1. A method of video encoding, comprising:
calculating a target coding offset when the target macro block reaches the adaptive coding quality based on the duty ratio of the target macro block in the current video frame;
calculating non-target coding offset of non-target macro blocks in the current video frame based on a frame-level coding stabilization principle and the target coding offset;
correspondingly adjusting macro block coding parameters of the target macro block and the non-target macro block by adopting the target coding offset and the non-target coding offset;
The calculating, based on the duty ratio of the target macroblock in the current video frame, the target coding offset when the target macroblock reaches the adaptive coding quality includes:
Determining a coding offset base value which is set under the adaptive coding quality and matched with the duty ratio of the target macro block;
Calculating a target coding offset of the target macro block based on the coding offset base value and a reverse influence parameter of the duty ratio of the target macro block on the adaptive coding quality;
and when the duty ratio of the target macro block is smaller than the duty ratio appointed by the highest coding quality, the coding offset base value is a frame-level coding adjustable value of the current video frame, otherwise, the coding offset base value is the minimum value of the frame-level coding adjustable value and the macro block reference offset value of the target macro block.
2. The method of claim 1, wherein the calculating a non-target coding offset for non-target macroblocks in the current video frame based on the frame-level coding stabilization principle and the target coding offset comprises:
And calculating the non-target coding offset of the non-target macro block in the current video frame based on the target coding offset, the adjustable frame-level coding value of the current video frame and the number of the target macro block and the non-target macro block in the current video frame.
3. The method of claim 1, wherein said adapting macroblock coding parameters of said target macroblock and said non-target macroblock using said target coding offset and said non-target coding offset comprises:
the macro block coding parameter of each target macro block is up-regulated by adopting the target coding offset to obtain the actual coding parameter of the target macro block;
And adopting the non-target coding offset to downwards adjust the macro block coding parameters of each non-target macro block to obtain the actual coding parameters of the non-target macro block.
4. A method according to any of claims 1-3, wherein the non-target macro blocks comprise local non-target macro blocks and complete non-target macro blocks.
5. The method of claim 4, wherein calculating the non-target coding offset for the non-target macroblock within the current video frame based on the frame-level coding stabilization principle and the target coding offset comprises:
Calculating a non-target coding offset reference amount of the non-target macro block based on a frame-level coding stabilization principle and the target coding offset;
based on the adjustable frame-level coding value of the current video frame, the non-target coding offset reference quantity is adjusted downwards, and the non-target coding offset quantity of the local non-target macro block is obtained; and up-regulating the non-target coding offset reference quantity to obtain the non-target coding offset quantity of the completely non-target macro block.
6. The method of claim 5, wherein said adapting macroblock coding parameters of said target macroblock and said non-target macroblock using said target coding offset and said non-target coding offset comprises:
adjusting macro block coding parameters of each target macro block by adopting the target coding offset to obtain actual coding parameters of the target macro block;
Adjusting the macro block coding parameter of each local non-target macro block by adopting the non-target coding offset of the local non-target macro block to obtain the actual coding parameter of the local non-target macro block;
and adjusting the macro block coding parameter of each completely non-target macro block by adopting the non-target coding offset of the completely non-target macro block to obtain the actual coding parameter of the completely non-target macro block.
7. A method according to any of claims 1-3, characterized in that before calculating the target coding offset at which the target macroblock reaches the adapted coding quality based on the duty cycle of the target macroblock within the current video frame, further comprising:
and detecting the type of each macro block in the current video frame by adopting a target area detection model, and counting the number of target macro blocks and non-target macro blocks in the current video frame so as to calculate the duty ratio of the target macro blocks in the current video frame.
8. A method according to any one of claims 1-3, further comprising, after adapting the macroblock coding parameters of the target macroblock and the non-target macroblock using the target coding offset and the non-target coding offset, correspondingly:
and aiming at each macro block in the current video frame, adopting macro block coding parameters adjusted by the macro block to code the macro block.
9. An apparatus for video encoding, comprising:
the target offset calculating module is used for calculating the target coding offset when the target macro block reaches the adaptive coding quality based on the duty ratio of the target macro block in the current video frame;
The non-target offset calculating module is used for calculating the non-target coding offset of the non-target macro block in the current video frame based on the frame-level coding stabilization principle and the target coding offset;
The coding parameter adjustment module is used for correspondingly adjusting the macro block coding parameters of the target macro block and the non-target macro block by adopting the target coding offset and the non-target coding offset;
the target offset calculation module is specifically configured to:
Determining a coding offset base value which is set under the adaptive coding quality and matched with the duty ratio of the target macro block;
Calculating a target coding offset of the target macro block based on the coding offset base value and a reverse influence parameter of the duty ratio of the target macro block on the adaptive coding quality;
and when the duty ratio of the target macro block is smaller than the duty ratio appointed by the highest coding quality, the coding offset base value is a frame-level coding adjustable value of the current video frame, otherwise, the coding offset base value is the minimum value of the frame-level coding adjustable value and the macro block reference offset value of the target macro block.
10. A computer device, the computer device comprising:
One or more processors;
A storage means for storing one or more programs;
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of video encoding of any of claims 1-8.
11. A computer readable storage medium having stored thereon a computer program, which when executed by a processor implements a method of video encoding according to any of claims 1-8.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110372888.1A CN112929668B (en) | 2021-04-07 | 2021-04-07 | Video coding method, device, equipment and storage medium |
PCT/CN2022/082675 WO2022213809A1 (en) | 2021-04-07 | 2022-03-24 | Video coding method, apparatus and device, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110372888.1A CN112929668B (en) | 2021-04-07 | 2021-04-07 | Video coding method, device, equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112929668A CN112929668A (en) | 2021-06-08 |
CN112929668B true CN112929668B (en) | 2024-04-26 |
Family
ID=76173619
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110372888.1A Active CN112929668B (en) | 2021-04-07 | 2021-04-07 | Video coding method, device, equipment and storage medium |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN112929668B (en) |
WO (1) | WO2022213809A1 (en) |
Families Citing this family (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112929668B (en) * | 2021-04-07 | 2024-04-26 | 百果园技术(新加坡)有限公司 | Video coding method, device, equipment and storage medium |
CN115643405A (en) * | 2022-09-29 | 2023-01-24 | 上海哔哩哔哩科技有限公司 | ROI (region of interest) detection-based video coding method and device and computing equipment |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1212526A (en) * | 1997-08-07 | 1999-03-31 | 松下电器产业株式会社 | Device and method for detecting action vector |
CN101867799A (en) * | 2009-04-17 | 2010-10-20 | 北京大学 | Video frame processing method and video encoder |
EP2680581A1 (en) * | 2012-06-28 | 2014-01-01 | Alcatel-Lucent | Method and apparatus for dynamic adaptation of video encoder parameters |
WO2016054307A1 (en) * | 2014-10-03 | 2016-04-07 | Microsoft Technology Licensing, Llc | Adapting quantization within regions-of-interest |
CN110267037A (en) * | 2019-06-21 | 2019-09-20 | 腾讯科技(深圳)有限公司 | Method for video coding, device, electronic equipment and computer readable storage medium |
WO2020117781A1 (en) * | 2018-12-04 | 2020-06-11 | Interdigital Vc Holdings, Inc. | Method and apparatus for video encoding and decoding with adjusting the quantization parameter to block size |
CN111918066A (en) * | 2020-09-08 | 2020-11-10 | 北京字节跳动网络技术有限公司 | Video encoding method, device, equipment and storage medium |
WO2020256522A1 (en) * | 2019-06-20 | 2020-12-24 | 한국전자통신연구원 | Method and apparatus for image encoding and image decoding using area segmentation |
Family Cites Families (10)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6256423B1 (en) * | 1998-09-18 | 2001-07-03 | Sarnoff Corporation | Intra-frame quantizer selection for video compression |
US8406297B2 (en) * | 2008-10-17 | 2013-03-26 | Futurewei Technologies, Inc. | System and method for bit-allocation in video coding |
JP5285632B2 (en) * | 2009-01-26 | 2013-09-11 | パナソニック株式会社 | Moving image processing apparatus, moving image processing method, and imaging apparatus |
CN103974071A (en) * | 2013-01-29 | 2014-08-06 | 富士通株式会社 | Video coding method and equipment on basis of regions of interest |
JP6690254B2 (en) * | 2016-01-22 | 2020-04-28 | 沖電気工業株式会社 | Image coding apparatus, method and program |
CN106791856A (en) * | 2016-12-28 | 2017-05-31 | 天津天地伟业生产力促进有限公司 | A kind of method for video coding based on self adaptation area-of-interest |
US10349060B2 (en) * | 2017-06-30 | 2019-07-09 | Intel Corporation | Encoding video frames using generated region of interest maps |
KR102543444B1 (en) * | 2017-08-29 | 2023-06-13 | 삼성전자주식회사 | Video encoding apparatus |
CN112188208B (en) * | 2020-09-18 | 2022-08-09 | 浙江大华技术股份有限公司 | Macro block level code rate control method and related device |
CN112929668B (en) * | 2021-04-07 | 2024-04-26 | 百果园技术(新加坡)有限公司 | Video coding method, device, equipment and storage medium |
-
2021
- 2021-04-07 CN CN202110372888.1A patent/CN112929668B/en active Active
-
2022
- 2022-03-24 WO PCT/CN2022/082675 patent/WO2022213809A1/en active Application Filing
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN1212526A (en) * | 1997-08-07 | 1999-03-31 | 松下电器产业株式会社 | Device and method for detecting action vector |
CN101867799A (en) * | 2009-04-17 | 2010-10-20 | 北京大学 | Video frame processing method and video encoder |
EP2680581A1 (en) * | 2012-06-28 | 2014-01-01 | Alcatel-Lucent | Method and apparatus for dynamic adaptation of video encoder parameters |
WO2016054307A1 (en) * | 2014-10-03 | 2016-04-07 | Microsoft Technology Licensing, Llc | Adapting quantization within regions-of-interest |
WO2020117781A1 (en) * | 2018-12-04 | 2020-06-11 | Interdigital Vc Holdings, Inc. | Method and apparatus for video encoding and decoding with adjusting the quantization parameter to block size |
WO2020256522A1 (en) * | 2019-06-20 | 2020-12-24 | 한국전자통신연구원 | Method and apparatus for image encoding and image decoding using area segmentation |
CN110267037A (en) * | 2019-06-21 | 2019-09-20 | 腾讯科技(深圳)有限公司 | Method for video coding, device, electronic equipment and computer readable storage medium |
CN111918066A (en) * | 2020-09-08 | 2020-11-10 | 北京字节跳动网络技术有限公司 | Video encoding method, device, equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
基于分级位平面偏移的多感兴趣区图像编码;张立保;余先川;;光电工程(第02期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
WO2022213809A1 (en) | 2022-10-13 |
CN112929668A (en) | 2021-06-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110876060B (en) | Code rate adjusting method and device in coding process | |
CN112929668B (en) | Video coding method, device, equipment and storage medium | |
KR101350853B1 (en) | Apparatus and method for reducing artifacts in images | |
CN110620924B (en) | Method and device for processing coded data, computer equipment and storage medium | |
TWI677239B (en) | Non-local adaptive loop filter combining multiple denoising technologies and grouping image patches in parallel | |
CN105472205B (en) | Real-time video noise reduction method and device in encoding process | |
WO2021012965A1 (en) | Image processing method and apparatus, mobile terminal video processing method and apparatus, device and medium | |
CN109978774B (en) | Denoising fusion method and device for multi-frame continuous equal exposure images | |
CN102158699B (en) | Embedded video compression coding system with image enhancement function | |
CN110766637B (en) | Video processing method, processing device, electronic equipment and storage medium | |
US20200374526A1 (en) | Method, device, apparatus for predicting video coding complexity and storage medium | |
CN113068034B (en) | Video encoding method and device, encoder, equipment and storage medium | |
WO2020248715A1 (en) | Coding management method and apparatus based on high efficiency video coding | |
CN112672149A (en) | Video processing method and device, storage medium and server | |
CN112752106B (en) | Video image frame coding control method and device and computer storage medium | |
WO2024114432A1 (en) | Sample adaptive offset method and device in video coding | |
CN110956594A (en) | Image filtering method and device, electronic equipment and storage medium | |
He et al. | Fast Inter-Mode Decision Algorithm for High-Efficiency Video Coding Based on Textural Features. | |
CN116363018B (en) | Adaptive NLM noise reduction method | |
CN116962701A (en) | Video coding processing method, device, equipment, storage medium and product | |
De Praeter et al. | Simultaneous encoder for high-dynamic-range and low-dynamic-range video | |
CN116320446A (en) | Video encoding method and device, electronic equipment and computer medium | |
CN113038135B (en) | CRF self-adaptive method based on block effect detection | |
CN113891081A (en) | Video processing method, device and equipment | |
WO2020042268A1 (en) | Method and device for determining video frame complexity measure |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |