CN112929668A - Video coding method, device, equipment and storage medium - Google Patents

Video coding method, device, equipment and storage medium Download PDF

Info

Publication number
CN112929668A
CN112929668A CN202110372888.1A CN202110372888A CN112929668A CN 112929668 A CN112929668 A CN 112929668A CN 202110372888 A CN202110372888 A CN 202110372888A CN 112929668 A CN112929668 A CN 112929668A
Authority
CN
China
Prior art keywords
target
coding
macro block
offset
macroblock
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.)
Granted
Application number
CN202110372888.1A
Other languages
Chinese (zh)
Other versions
CN112929668B (en
Inventor
张文忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bigo Technology Pte Ltd
Original Assignee
Bigo Technology Pte Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bigo Technology Pte Ltd filed Critical Bigo Technology Pte Ltd
Priority to CN202110372888.1A priority Critical patent/CN112929668B/en
Publication of CN112929668A publication Critical patent/CN112929668A/en
Priority to PCT/CN2022/082675 priority patent/WO2022213809A1/en
Application granted granted Critical
Publication of CN112929668B publication Critical patent/CN112929668B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/169Methods 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/17Methods 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/176Methods 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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/102Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding characterised by the element, parameter or selection affected or controlled by the adaptive coding
    • H04N19/124Quantisation
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/10Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using adaptive coding
    • H04N19/134Methods 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/146Data rate or code amount at the encoder output
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/42Methods 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 adaptive coding quality based on the ratio of the target macro block in the current video frame; calculating the non-target coding offset of a non-target macro block in the current video frame based on a frame-level coding stabilization principle and a target coding offset; and 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 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 overhead of video coding and ensures the high efficiency of the video coding; meanwhile, the coding quality of the video is further improved on the basis of ensuring the high efficiency of video coding.

Description

Video coding method, device, equipment and storage medium
Technical Field
The present invention relates to the field of video coding technologies, and in particular, to a method, an apparatus, a device, and a storage medium for video coding.
Background
With the rapid development of internet technology, the functions of social entertainment products are more and more abundant, and video coding plays an important role as a basic function in the fields of video call, short video recording, video live broadcast and the like. Moreover, for some regions of Interest (ROI) with high definition display requirements in a video frame, adaptive coding needs to be specially performed on the regions of Interest, so as to improve the playing image quality of the regions of Interest.
At present, a third-party ROI detection device is usually adopted to identify an interested region and a non-interested region in a video frame, and then rate distortion cost of each coding unit in the interested region and the non-interested region under each prediction coding mode at a corresponding recursive depth and rate distortion cost of each transformation unit divided by the coding unit under each prediction coding mode are calculated in a traversal manner, so that an optimal coding mode with the minimum cost is respectively selected for each coding unit in the interested region and the non-interested region, and coding quality of the interested region and the non-interested region is ensured.
However, the conventional ROI coding algorithm is too complex, and has a 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 video coding device, video coding 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 coding, where the method includes:
calculating a target coding offset when a target macro block reaches adaptive coding quality based on the ratio of the target macro block in the current video frame;
calculating the non-target coding offset of the non-target macro block in the current video frame based on a frame-level coding stabilization principle and the target coding offset;
and 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 second aspect, an embodiment of the present invention provides an apparatus for video encoding, where the apparatus includes:
the target offset calculation module is used for calculating the target coding offset when the target macro block reaches the adaptive coding quality based on the proportion of the target macro block in the current video frame;
the non-target offset calculation module is used for calculating the non-target coding offset of a non-target macro block in the current video frame based on a frame-level coding stabilization principle and the target coding offset;
and the coding parameter adjusting 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 device, where the computer device includes:
one or more processors;
storage means for storing 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 according to any of the embodiments of the present invention.
In a fourth aspect, the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the method for video encoding according to any embodiment of the present invention.
The method, the device, the equipment and the storage medium for video coding provided by the embodiment of the invention can analyze the adaptive coding quality of the target macro block through the proportion of the target macro block in the current video frame, further calculate the target coding offset when the target macro block reaches the adaptive coding quality, then, based on the frame-level coding stabilization principle, the target coding offset can be used to calculate the non-target coding offset of the non-target macro block in the current video frame, and then the target coding offset and the non-target coding offset are used, correspondingly adjusting the macro block coding parameters of the target macro block and the non-target macro block to realize the coding optimization of the target macro block and the non-target macro block of the current video frame, without calculating the coding cost under an unnecessary coding division mode, greatly reducing the complexity and the coding cost of video coding and ensuring the high efficiency of the video coding; meanwhile, after the target coding offset and the non-target coding offset are adopted and the 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 ensuring the high efficiency of video coding.
Drawings
Other features, objects and advantages of the invention will become more apparent upon reading of the detailed description of non-limiting embodiments made with reference to the following drawings:
fig. 1A is a flowchart of a video encoding method according to an embodiment of the present invention;
fig. 1B is a schematic diagram of a video encoding process according to an embodiment of the present invention;
fig. 2A is a flowchart of a video encoding method 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 video encoding method according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an apparatus for video encoding 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 present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures. In addition, the embodiments and features of the embodiments in the present invention may be combined with each other without conflict.
Example one
Fig. 1A is a flowchart of a video encoding method according to an embodiment of the present invention, which can be applied to any scene with an encoding requirement. The method for video coding provided by this embodiment may be performed by an apparatus for video coding provided by the embodiment of the present invention, where the apparatus may be implemented by software and/or hardware, and is integrated in a computer device that executes the method, where the computer device may be a background server or the like that participates in video data interaction.
Specifically, referring to fig. 1A, the method may include the steps of:
and S110, calculating the target coding offset when the target macro block reaches the adaptive coding quality based on the occupation ratio of the target macro block in the current video frame.
Specifically, different areas in each frame of each type of video respectively display different video pictures, and a user is interested in certain specific picture areas, so that the video pictures of each interested area in the video frame can be required to adopt a high-quality coding mode as far as possible, the high definition of the pictures of the interested area is ensured, and the video quality of the interested area is improved. The region of interest in this embodiment may be a local region in which a uniform specific picture feature is provided in a video frame, so as to be used for accurate identification of the region of interest, for example, a face region that can be detected through skin color in a scene such as a video call or live video.
At this time, when video encoding is performed on the current video frame, as shown in fig. 1B, since the current video frame is usually divided into a plurality of macro blocks, the macro blocks may be pixel blocks with a size of 16 × 16, and then the current video frame is encoded by using the macro blocks as encoding units, the present embodiment may further improve the video quality of the regions of interest by optimizing the encoding manner of the macro blocks where the regions of interest are located. The current video frame is 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 that whether the picture of each macroblock in the current video frame is the picture of the region of interest can be analyzed, the macroblock in the current video frame is further divided into a target macroblock and a non-target macroblock, and meanwhile, the proportion of the target macroblock in the current video frame can be determined. All pictures in the target macro block are the interested areas, and the video pictures in the non-target macro block contain pictures except the interested areas.
At this time, if the target macro block in the current video frame is higher in ratio, it is indicated that more target macro blocks exist in the current video frame and the coding quality needs to be further optimized on the basis of the current coding quality, and it is considered that the higher the coding quality is, the more detail features of the video picture are required to be reserved, so that the coding rate of the target macro blocks is larger, and at this time, if each target macro block adopts a 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 the video coding is congested. Therefore, in order to maintain stable encoding of the current video frame and avoid generation of encoding congestion or excessive encoding, the present embodiment inversely sets different adaptive encoding qualities according to different ratios of the target macroblock 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 ratio is, the larger the total amount of encoding of the target macroblock in the current video frame is, the lower the optimal range of the adaptive encoding quality relative to the current encoding quality is set, whereas the lower the ratio is, the smaller the total amount of encoding of the target macroblock in the current video frame is, the higher the optimal range of the adaptive encoding quality relative to the current encoding quality is set. Then, a target coding offset when the target macro block reaches the adaptive coding quality is calculated, wherein the target coding offset can accurately represent the optimized amplitude between the adaptive coding quality and the current coding quality, that is, the larger the occupation ratio of the target macro block in the current video frame is, the smaller the target coding offset is, and the smaller the occupation ratio of the target macro block in the current video frame is, the larger the target coding offset is.
And 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 means that, in order to avoid a phenomenon that video coding is congested due to a coding rate exceeding a requirement of a current network bandwidth, it is required that after a target macroblock and a non-target macroblock are optimally coded, an overall coding parameter of a current video frame can be kept approximately unchanged. 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 macro block can be calculated by using the target coding offset and the number of the target macro blocks, and then the non-target coding offset of the non-target macro block can be calculated according to the number of the non-target macro blocks in the current video frame.
And S130, 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.
Optionally, after obtaining a target coding offset of a target macroblock in a current video frame and a non-target coding offset of a non-target macroblock, a video macroblock-level coding control algorithm is used to calculate macroblock coding parameters of each target macroblock and each non-target macroblock when the target macroblock and each non-target macroblock meet a current network bandwidth requirement, and then in order to further optimize the coding quality of the target macroblock to ensure high-definition display of an area of interest in the current video frame, the present embodiment may adjust the macroblock coding parameters of each target macroblock in the current video frame by using the target coding offset, so that the target macroblock can perform video coding by using more picture detail features, and the coding quality of a video can be further improved on the basis of ensuring the high efficiency of video coding. Meanwhile, in order to ensure the overall stability of video frame-level coding, the macroblock coding parameters of each non-target macroblock in the current video frame are also adjusted by adopting a 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 proportion 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 using the target coding offset based on a 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 using 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 under an unnecessary coding partition mode does not need to be calculated, the complexity and the coding cost of video coding are greatly reduced, and the high efficiency of video coding; meanwhile, after the target coding offset and the non-target coding offset are adopted and the 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 ensuring 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 the second embodiment of the present invention. The embodiment is optimized on the basis of the 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 matched with the ratio of the target macro block, which is set under the adaptive coding quality.
Optionally, in order to ensure an accurate match between the target macroblock ratio and the adaptive coding quality, the present embodiment may pre-divide the target macroblock ratio into ratio stages with different adaptive coding qualities, for example, in four stages of (0,0.15], (0.15,0.35], (0.35,0.5] and (0.5,1) of the target macroblock ratio, the adaptive coding quality required in each stage is different, where the smaller the ratio of the target macroblock is, the higher the adaptive coding quality in the ratio stage is.
In order to accurately represent the adaptive coding quality at different ratio stages, the present embodiment sets a matched coding offset base value under each adaptive coding quality, where the coding offset base value can ensure that the target macroblock can still reach the adaptive coding quality to the maximum extent after the coding parameter adjustment is performed on the basis of the current network bandwidth.
Specifically, the encoding Parameter in this embodiment may be a Quantization Parameter (QP), and before the current video frame is encoded, the present embodiment may use a frame-level coding control algorithm to calculate a frame-level encoding Parameter (QP _ base) meeting the current network bandwidth requirement, while the maximum coding parameter (QP _ max) for the current video frame to meet the coding requirements is externally specified, the maximum coding parameter is used for ensuring the video coding quality, representing the coding upper limit when the current network bandwidth requirement is not exceeded to avoid the problems of coding congestion or coding surplus, if the adjusted encoding parameter of the frame-level encoding parameter exceeds the maximum encoding parameter, the encoding rate will underflow, and the preset code rate is not reached, so that the encoding quality of the video frame is poorer than expected, that is, the frame-level encoding adjustable value (QP _ diff) of the current video frame is the difference between the frame-level encoding parameter and the maximum encoding parameter. Meanwhile, in order to ensure adaptive bitrate adjustment of the target macroblock, the present embodiment further sets a corresponding macroblock reference offset value (ROI _ QP _ OFF) for the target macroblock in the current video frame.
At this time, the occupation ratio of the target macroblock is less than the occupation ratio specified by the highest coding quality, that is, when the occupation ratio of the target macroblock is in the (0, 0.15) stage, the matched coding offset base value may be set to be the frame-level coding adjustable value (QP _ diff) of the current video frame, otherwise, the matched coding offset base value may be set to be 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 is min (QP _ diff, QP _ OFF).
And S220, calculating the target coding offset of the target macro block based on the coding offset base value and the inverse influence parameter of the ratio of the target macro block to the adaptive coding quality.
In this embodiment, after the code offset base value matching the ratio of the target macro block is calculated, since the smaller the ratio of the target macro block is, the higher the coding quality achieved by the target macro block is, the ratio of the target macro block has a reverse influence on the adaptive coding quality, and at this time, the calculated code offset base value is adjusted by using the reverse influence parameter of the ratio of the target macro block on the adaptive coding quality, so that the target code offset of the target macro block can be calculated.
For example, the target coding offset of the target macroblock may be calculated as follows:
1) when the occupation ratio of the target macro block is (0, 0.15)]At stage, the target coding offset of the target macro block is QP1=QP_diff*(1-ROI_ratio2) (ii) a Where ROI _ ratio is the fraction of the target macroblock.
2) When the occupation ratio of the target macro block is (0.15, 0.35)]At stage, the target coding offset of the target macro block is QP1=QP_diff_limit*(1-ROI_ratio2)。
3) When the occupation ratio of the target macro block is (0.35, 0.5)]At stage, the target coding offset of the target macro block is QP1=QP_diff_limit*(1-ROI_ratio2)-QP_diff_limit/6。
4) When the occupation ratio of the target macro block is in the (0.5,1) stage, the target coding offset of the target macro block is QP1=QP_diff_limit*(1-ROI_ratio)。
As can be seen from the above calculation formula, as the ratio of the target macroblock increases, the target coding offset of the target macroblock is smaller, that is, the coding quality optimization amplitude of each target macroblock is smaller.
And 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 frame-level coding adjustable 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, when the coding parameter of the current video frame is adjusted within the range corresponding to the frame-level coding adjustable value, the coding rate can be regulated and controlled to keep stable, and the problem of coding congestion or coding surplus is avoided, that is, the integral offset of the frame-level coding parameter is allowed to be within the range of the frame-level coding adjustable value, at this time, the integral offset of the target macro block in the current video frame can be calculated by using the target coding offset and the number of the target macro blocks of the target macro block in the current video frame, then the integral offset of the non-target macro block can be estimated within the range corresponding to the frame-level coding adjustable value of the current video frame by using the integral offset of the target macro block, and then the non-target coding offset of the non-target macro block is calculated according to the number of the non-target macro blocks in the current.
S240, the macro block coding parameter of each target macro block is adjusted up by adopting the target coding offset, and the actual coding parameter of the target macro block is obtained.
Optionally, in order to ensure that the coding quality of a target macroblock in a current video frame is higher, and thus high-definition display of an area of interest in the current video frame is achieved, more detailed picture features may be required to be adopted when the target macroblock is coded, so that a target coding offset may be adopted to correspondingly adjust up a macroblock coding parameter calculated by each target macroblock through a macroblock-level code control algorithm, so as to obtain an actual coding parameter of the target macroblock, and when the target macroblock is subsequently coded by adopting the actual coding parameter, more detailed picture features may be obtained, thereby further improving the coding quality of the target macroblock.
And S250, adjusting the macro block coding parameters of each non-target macro block downward by adopting the non-target coding offset to obtain the actual coding parameters of the non-target macro block.
Optionally, in order to ensure that frame-level coding of the current video frame is stable, in this embodiment, after the macroblock coding parameters of the target macroblock in the current video frame are adjusted upwards, the macroblock coding parameters calculated by using a macroblock-level code control algorithm for each non-target macroblock are also adjusted correspondingly under the non-target coding offset to obtain actual coding parameters of the non-target macroblock, and then the actual coding parameters are used to code the non-target macroblock, so that frame-level coding stability of the current video frame is achieved, and coding congestion or excessive phenomenon is avoided.
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 ratio of the target macro block and the inverse influence parameter of the ratio of the target macro block on the adaptive coding quality, so that the accuracy of the coding optimization of the target macro block is ensured, meanwhile, in the range corresponding to the frame-level coding adjustable value of the current video frame, the non-target coding offset of the non-target macro block is calculated by utilizing the target coding offset of the target macro block and the number of the target macro block and the non-target macro block in the current video frame, so that the stability of the 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 video encoding method according to a third embodiment of the present invention. The embodiment is optimized on the basis of the embodiment. Specifically, since the regions of interest in the current video frame are not uniformly distributed, and therefore there exists a non-target macroblock that is composed of both the video picture of the region of interest and the video picture of the region of non-interest, the non-target macroblock in this embodiment may include both a local non-target macroblock and a complete non-target macroblock, where the local non-target macroblock is composed of both the video picture of the region of interest and the video picture of the region of non-interest, and the complete non-target macroblock is only the video picture of the region of non-interest. In this embodiment, the detailed explanation is mainly given to the specific calculation procedure of the non-target coding offset of the local non-target macroblock and the complete 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 to calculate the 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 uniform specific picture features of the region 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 the regions of interest, and if yes, the macro block is determined to be the target macro block; if part of the video pictures in the macro block are interested areas and part of the video pictures are non-interested areas, determining that the macro block is a local non-target macro block; if all the video pictures in the macro block are non-interesting areas, determining that the macro block is a complete non-target macro block; and meanwhile, counting the number of target macro blocks in the current video frame, local non-target macro blocks and complete non-target macro blocks in the non-target macro blocks so as to calculate the ratio of the target macro blocks in the current video frame.
For example, if the region of interest is a skin color region, the present embodiment may nest a VPx skin color detection model in the VPx open source encoder, where the VPx skin color detection model has higher detection efficiency for the skin color region in the video frame.
At this time, obtaining corresponding width and height information for the current video frame, namely width and height respectively; then, the current video frame is traversed by taking the macro block with the size of 16 × 16 as a coding unit to divide the current video frame into all the macro blocks (x, y), wherein x takes the value of [0, width/16 ]]And y is [0, height/16 ]]And then completing the 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 occupation ratio of the target macro block in the current video frame can be equal to that of the target macro block in the current video frame
Figure BDA0003010041420000121
And S320, calculating the target coding offset when the target macro block reaches the adaptive coding quality based on the occupation 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.
Specifically, in order to satisfy the frame-level coding stabilization principle, the overall coding offset of the target macroblock and the non-target macroblock in the current video frame is approximately 0, and then the overall coding offset of the target macroblock can be calculated by using the target coding offset and the number of the target macroblocks, and then the non-target coding offset reference quantity of the non-target macroblock can be calculated according to the number of the non-target macroblocks in the current video frame.
Wherein the non-target coding offset reference amount of the non-target macro block may be
Figure BDA0003010041420000122
Wherein, QP1And the target coding offset of the target macro block is obtained, and the accuracy of the non-target coding offset of the local non-target macro block and the accuracy of the non-target coding offset of the complete non-target macro block are ensured by further adjusting the non-target coding offset reference quantity.
S340, based on the frame-level coding adjustable value of the current video frame, the non-target coding offset reference quantity is adjusted downwards to obtain the non-target coding offset of the local non-target macro block; and adjusting the non-target coding offset reference quantity up to obtain the non-target coding offset of the complete non-target macro block.
Optionally, since the local non-target macroblock is composed of the video picture of the region of interest and the video picture of the region of non-interest together, and the complete non-target macroblock is composed of the video picture of the region of non-interest only, the coding of the local non-target macroblock is required to be able to make a coding buffer between the target macroblock and the complete non-target macroblock. That is, based on the frame-level coding adjustable value of the current video frame, a variation meeting the requirement of the frame-level coding adjustable value is set, so that the current video frame can meet the requirement of current coding control, and the calculated non-target coding offset reference quantity is adjusted downwards by adopting the variation 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 adjusted up by the variable quantity to serve as the non-target coding offset of the complete non-target macro block, so that when the frame-level coding of the current video frame is guaranteed to be stable, the non-target coding offset of the local non-target macro block can be lower than that of the complete non-target macro block, and the coding quality of the local non-target macro block can be better than that of the complete non-target macro block. Then, the corresponding coding offset is respectively adopted to correspondingly adjust the macro block coding parameters of each macro block, and the actual coding parameters of each macro block are obtained.
For example, if the set variance is δ based on the frame-level coding adjustable value of the current video frame, the non-target coding offset of the local non-target macroblock may be δ
Figure BDA0003010041420000131
The non-targeted coding offset for a completely non-targeted macroblock may be
Figure BDA0003010041420000132
S350, adjusting the macro block coding parameters of each target macro block by adopting the target coding offset to obtain the 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 parameters of each complete non-target macro block by adopting the non-target coding offset of the complete non-target macro block to obtain the actual coding parameters of the complete non-target macro block.
And S360, aiming at each macro block in the current video frame, adopting the macro block coding parameters adjusted by the macro block to code the macro block.
Optionally, after calculating the actual coding parameter of each macroblock in the current video frame, the actual coding parameter of each macroblock adjusted according to the corresponding coding offset may be sequentially used to code the macroblock.
According to the technical scheme provided by the embodiment, the adaptive coding quality of the target macro block can be analyzed through the proportion 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 using the target coding offset based on a 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 using 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 under an unnecessary coding partition mode does not need to be calculated, the complexity and the coding cost of video coding are greatly reduced, and the high efficiency of video coding; meanwhile, after the target coding offset and the non-target coding offset are adopted and the 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 ensuring the high efficiency of video coding.
Example four
Fig. 4 is a schematic structural diagram of an apparatus for video encoding according to a fourth embodiment of the present invention, specifically, as shown in fig. 4, the apparatus may include:
a target offset calculation module 410, configured to calculate a target coding offset when a target macroblock reaches adaptive coding quality based on a 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;
and an encoding parameter adjusting module 430, 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 proportion 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 using the target coding offset based on a 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 using 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 under an unnecessary coding partition mode does not need to be calculated, the complexity and the coding cost of video coding are greatly reduced, and the high efficiency of video coding; meanwhile, after the target coding offset and the non-target coding offset are adopted and the 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 ensuring the high efficiency of video coding.
The video coding apparatus provided in this embodiment is applicable to the video coding method provided in any of the above embodiments, and has corresponding functions and advantages.
EXAMPLE five
Fig. 5 is a schematic structural diagram of a computer device according to a fifth embodiment of the present invention, 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, and one processor 50 is 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, as exemplified by the bus connection in fig. 5.
The computer device provided by the embodiment can be used for executing the video coding method provided by any embodiment, and has corresponding functions and beneficial effects.
EXAMPLE six
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, can implement the method for video encoding in any of the above embodiments.
Of course, the storage medium provided by the embodiments of the present invention contains computer-executable instructions, and the computer-executable instructions are not limited to the method operations described above, and may also perform related operations in the method for video encoding provided by any embodiment of the present invention.
From the above description of the embodiments, it is obvious for those skilled in the art that the present invention can be implemented by software and necessary general hardware, and certainly, can also be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
It should be noted that, in the embodiment of the video encoding apparatus, the included units and modules are only divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present invention.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (13)

1. A method of video encoding, comprising:
calculating a target coding offset when a target macro block reaches adaptive coding quality based on the ratio of the target macro block in the current video frame;
calculating the non-target coding offset of the non-target macro block in the current video frame based on a frame-level coding stabilization principle and the target coding offset;
and 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.
2. The method of claim 1, wherein calculating the target coding offset at which the target macroblock reaches the adaptive coding quality based on the fraction of the target macroblock in the current video frame comprises:
determining a preset coding offset base value matched with the proportion of the target macro block under the adaptive coding quality;
and calculating the target coding offset of the target macro block based on the coding offset base value and the inverse influence parameter of the occupation ratio of the target macro block on the adaptive coding quality.
3. The method of claim 2, wherein the coding offset base value is a frame-level coding adjustable value of the current video frame when the duty ratio of the target macroblock is less than a duty ratio specified by a highest coding quality, and wherein the coding offset base value is a minimum value of the frame-level coding adjustable value and a macroblock reference offset value of the target macroblock otherwise.
4. The method of claim 1, wherein calculating the non-target coding offset for the non-target macroblock in the current video frame based on the frame-level coding stabilization rule 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 frame-level coding adjustable 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.
5. The method of claim 1, wherein the correspondingly adjusting the macroblock coding parameters of the target macroblock and the non-target macroblock using the target coding offset and the non-target coding offset comprises:
adopting the target coding offset to adjust up the macro block coding parameter of each target macro block to obtain the actual coding parameter of the target macro block;
and adjusting the macro block coding parameters of each non-target macro block downwards by adopting the non-target coding offset to obtain the actual coding parameters of the non-target macro block.
6. The method according to any of claims 1-5, wherein the non-target macroblocks comprise local non-target macroblocks and full non-target macroblocks.
7. The method of claim 6, wherein calculating the non-target coding offset for the non-target macroblock in the current video frame based on the frame-level coding stabilization rule and the target coding offset comprises:
calculating a non-target coding offset reference quantity of the non-target macro block based on a frame level coding stabilization principle and the target coding offset;
based on the frame-level coding adjustable value of the current video frame, the non-target coding offset reference quantity is adjusted downwards to obtain the non-target coding offset of the local non-target macro block; and adjusting the non-target coding offset reference quantity up to obtain the non-target coding offset of the complete non-target macro block.
8. The method of claim 7, wherein the correspondingly adjusting the macroblock coding parameters of the target macroblock and the non-target macroblock using the target coding offset and the non-target coding offset comprises:
adjusting the macro block coding parameter of each target macro block by adopting the target coding offset to obtain the actual coding parameter 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 parameters of each complete non-target macro block by adopting the non-target coding offset of the complete non-target macro block to obtain the actual coding parameters of the complete non-target macro block.
9. The method according to any of claims 1-5, further comprising, before calculating a target coding offset at which a target macroblock in a current video frame reaches an adaptive coding quality based on a fraction of the target macroblock,:
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 to calculate the ratio of the target macro blocks in the current video frame.
10. The method according to any one of claims 1-5, further comprising, after correspondingly adjusting macroblock coding parameters of the target macroblock and the non-target macroblock using the target coding offset and the non-target coding offset:
and aiming at each macro block in the current video frame, adopting the macro block coding parameters adjusted by the macro block to code the macro block.
11. An apparatus for video encoding, comprising:
the target offset calculation module is used for calculating the target coding offset when the target macro block reaches the adaptive coding quality based on the proportion of the target macro block in the current video frame;
the non-target offset calculation module is used for calculating the non-target coding offset of a non-target macro block in the current video frame based on a frame-level coding stabilization principle and the target coding offset;
and the coding parameter adjusting 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.
12. A computer device, characterized in that the computer device comprises:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement a method of video encoding as claimed in any one of claims 1-10.
13. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method of video encoding according to any one of claims 1 to 10.
CN202110372888.1A 2021-04-07 2021-04-07 Video coding method, device, equipment and storage medium Active CN112929668B (en)

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 true CN112929668A (en) 2021-06-08
CN112929668B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022213809A1 (en) * 2021-04-07 2022-10-13 百果园技术(新加坡)有限公司 Video coding method, apparatus and device, and storage medium
WO2024066701A1 (en) * 2022-09-29 2024-04-04 上海哔哩哔哩科技有限公司 Roi detection-based video coding method and apparatus, and computing device

Citations (11)

* Cited by examiner, † Cited by third party
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
US20170214915A1 (en) * 2016-01-22 2017-07-27 Oki Electric Industry Co., Ltd. Image encoding device and image encoding method
US20190007690A1 (en) * 2017-06-30 2019-01-03 Intel Corporation Encoding video frames using generated region of interest maps
US20190068968A1 (en) * 2017-08-29 2019-02-28 Samsung Electronics Co., Ltd. Video encoding apparatus
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 (7)

* Cited by examiner, † Cited by third party
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
US8363720B2 (en) * 2009-01-26 2013-01-29 Panasonic Corporation Moving image processing device, 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
CN106791856A (en) * 2016-12-28 2017-05-31 天津天地伟业生产力促进有限公司 A kind of method for video coding based on self adaptation area-of-interest
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

Patent Citations (11)

* Cited by examiner, † Cited by third party
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
US20170214915A1 (en) * 2016-01-22 2017-07-27 Oki Electric Industry Co., Ltd. Image encoding device and image encoding method
US20190007690A1 (en) * 2017-06-30 2019-01-03 Intel Corporation Encoding video frames using generated region of interest maps
US20190068968A1 (en) * 2017-08-29 2019-02-28 Samsung Electronics Co., Ltd. Video encoding apparatus
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)

* Cited by examiner, † Cited by third party
Title
张立保;余先川;: "基于分级位平面偏移的多感兴趣区图像编码", 光电工程, no. 02 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022213809A1 (en) * 2021-04-07 2022-10-13 百果园技术(新加坡)有限公司 Video coding method, apparatus and device, and storage medium
WO2024066701A1 (en) * 2022-09-29 2024-04-04 上海哔哩哔哩科技有限公司 Roi detection-based video coding method and apparatus, and computing device

Also Published As

Publication number Publication date
WO2022213809A1 (en) 2022-10-13
CN112929668B (en) 2024-04-26

Similar Documents

Publication Publication Date Title
CN110876060B (en) Code rate adjusting method and device in coding process
CN110620924B (en) Method and device for processing coded data, computer equipment and storage medium
CN113766226A (en) Image encoding method, apparatus, device and storage medium
CN108322747B (en) Coding unit division optimization method for ultra-high definition video
WO2022213809A1 (en) Video coding method, apparatus and device, and storage medium
US11259029B2 (en) Method, device, apparatus for predicting video coding complexity and storage medium
CN112672149B (en) Video processing method and device, storage medium and server
CN110766637B (en) Video processing method, processing device, electronic equipment and storage medium
CN107454413B (en) Video coding method with reserved characteristics
WO2021012965A1 (en) Image processing method and apparatus, mobile terminal video processing method and apparatus, device and medium
WO2020248715A1 (en) Coding management method and apparatus based on high efficiency video coding
CN107820095B (en) Long-term reference image selection method and device
CN113473131A (en) Video coding code rate dynamic adjustment method and device, electronic equipment and storage medium
CN113068034A (en) Video encoding method and device, encoder, equipment and storage medium
CN109218722B (en) Video coding method, device and equipment
CN111726656A (en) Transcoding method, device, server and storage medium for live video
US20230045884A1 (en) Rio-based video coding method and deivice
CN112655212B (en) Video coding optimization method and device and computer storage medium
CN110956594A (en) Image filtering method and device, electronic equipment and storage medium
CN110858388A (en) Method and device for enhancing video image quality
De Praeter et al. Simultaneous encoder for high-dynamic-range and low-dynamic-range video
CN111669602A (en) Method and device for dividing coding unit, coder and storage medium
CN115567712A (en) Screen content video coding perception code rate control method and device based on just noticeable distortion by human eyes
CN113038135B (en) CRF self-adaptive method based on block effect detection
CN111541898B (en) Method, device, server and storage medium for determining coding mode

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