A video encoding method and device
By dynamically adjusting the quantization parameters during the video encoding process and using the distortion information of the encoded picture groups, the problem of low adaptability of quantization parameters in the prior art is solved, and the encoding quality is improved.
Patent Information
- Application Number
- CN202010900351.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-31
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2040-08-31
AI Technical Summary
In the existing video encoding technology, the adaptability of quantization parameters is low, resulting in the inability to fully utilize the distorted information during the encoding process, affecting the encoding quality.
By obtaining the distortion information of the encoded picture group, dynamically adjusting the quantization parameters in the picture group to be encoded, and calculate the influencing factor based on the distortion information of each layer of video frame and the distortion information of the reference layer, and determining the target quantization parameters.
The adaptability of quantization parameters during video encoding is improved, making the quantization parameters more suitable for each layer in the currently coded picture group, thereby improving the encoding quality.
Smart Images

Figure CN114125459B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computers, and in particular to a video encoding method and device. Background Art
[0002] In current video coding technology, the entire video sequence is usually encoded in units of GOP (Group of Pictures). In each GOP, video frames are divided into different levels according to reference relationships. Each level is assigned a different frame-level QP (Quantizier Parameter) based on empirical values. The more references in a GOP, the lower the level, and the lower the assigned QP. The existing technical solutions ignore the impact of each layer on other layers, resulting in low adaptability of the assigned quantization parameters.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The present application provides a video encoding method and device to at least solve the technical problem of low adaptability of quantization parameters used in the video encoding process in the related art.
[0005] According to one aspect of an embodiment of the present application, a video encoding method is provided, including:
[0006] Obtaining distortion information of each layer of video frames in multiple layers of a first picture group that has been encoded, wherein the first picture group is a picture group that has been encoded before a second picture group to be encoded in a target video;
[0007] Determining a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to distortion information of each layer of video frames in the first picture group and distortion information of a reference layer video frame of each layer of video frames in the first picture group, wherein the reference layer video frame of each layer of video frames in the first picture group is a video frame referenced when encoding each layer of video frames in the first picture group;
[0008] Each layer of video frames in the second picture group is encoded using the target quantization parameter of each layer of video frames in the second picture group.
[0009] Optionally, determining, according to distortion information of each layer of video frames in the first picture group and distortion information of reference layer video frames of each layer of video frames in the first picture group, a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group includes:
[0010] Calculate, according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, an influence factor of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group, wherein the influence factor is used to indicate the influence degree of each layer of video frames in the second picture group as a reference layer on the coding layer that refers to each layer of video frames in the second picture group;
[0011] The target quantization parameter of each layer of video frames in the second picture group is determined according to the influencing factor of each layer of video frames in the second picture group.
[0012] Optionally, calculating, according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, the influence factor of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group includes:
[0013] Calculating, according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frame of each layer of video frames in the first picture group, an average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frame, wherein the average dependency coefficient is used to indicate the dependency of each layer of video frames in the second picture group on the reference layer video frame, and the reference layer video frame is a video frame referenced by each layer of video frames in the second picture group during encoding;
[0014] An influence factor of each layer of video frames in the second picture group is determined according to an average dependency coefficient corresponding to each layer of video frames in the second picture group when the video frames are used as reference layer video frames.
[0015] Optionally, calculating the average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frame according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frame of each layer of video frames in the first picture group includes:
[0016] Calculating the variance of each video frame in the second picture group during motion estimation;
[0017] Calculating a dependency coefficient corresponding to each reference relationship included in the second picture group according to the variance of each video frame, the average coding distortion of the layer where each video frame is located, and the average reference distortion of the layer where the reference frame referenced by each video frame is located, wherein the dependency coefficient is used to indicate the dependency of the coding frame on the reference frame in each reference relationship, and the distortion information includes the average coding distortion and the average reference distortion;
[0018] According to the dependency coefficient of the reference relationship between each layer of video frames in the second picture group and the reference layer video frames and the number of reference relationships, the average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frames is calculated.
[0019] Optionally, determining the influence factor of each layer of video frames in the second picture group according to the average dependency coefficient corresponding to each layer of video frames in the second picture group as the reference layer video frames includes:
[0020] For a target layer that is not referenced in the second picture group, determining that an impact factor corresponding to the target layer is a preset impact factor;
[0021] For a target layer referenced in the second picture group, an influence factor of the target layer is determined according to an average dependency coefficient and an influence factor corresponding to a coding layer that references the target layer.
[0022] Optionally, determining the target quantization parameter of each layer of video frames in the second picture group according to the influencing factor of each layer of video frames in the second picture group includes:
[0023] Finding a preset Lambda parameter corresponding to the preset quantization parameter from Lambda parameters and quantization parameters having a corresponding relationship;
[0024] For a target layer that is not referenced in the second picture group, determining that a target quantization parameter corresponding to the target layer is the preset quantization parameter;
[0025] For the target layer referenced in the second picture group, the ratio between the preset Lambda parameter and the influencing factor of the target layer is determined as the target Lambda parameter corresponding to the target layer; and the quantization parameter corresponding to the target Lambda parameter is searched from the Lambda parameters and quantization parameters having a corresponding relationship as the target quantization parameter of the target layer.
[0026] According to another aspect of the embodiment of the present application, there is also provided a video encoding device, including:
[0027] An acquisition module, configured to acquire distortion information of each layer of video frames in multiple layers of a first picture group that has been encoded, wherein the first picture group is a picture group in a target video that has been encoded before a second picture group to be encoded;
[0028] a determination module, configured to determine a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to distortion information of each layer of video frames in the first picture group and distortion information of a reference layer video frame of each layer of video frames in the first picture group, wherein the reference layer video frame of each layer of video frames in the first picture group is a video frame referenced when encoding each layer of video frames in the first picture group;
[0029] An encoding module is used to encode each layer of video frames in the second picture group using a target quantization parameter of each layer of video frames in the second picture group.
[0030] Optionally, the determining module includes:
[0031] a calculation unit, configured to calculate, according to distortion information of each layer of video frames in the first picture group and distortion information of reference layer video frames of each layer of video frames in the first picture group, an influence factor of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group, wherein the influence factor is used to indicate the influence degree of each layer of video frames in the second picture group as a reference layer on the coding layer that refers to each layer of video frames in the second picture group;
[0032] A determination unit is used to determine the target quantization parameter of each layer of video frames in the second picture group according to the influencing factor of each layer of video frames in the second picture group.
[0033] According to another aspect of an embodiment of the present application, a storage medium is further provided, which includes a stored program, and the above method is executed when the program is run.
[0034] According to another aspect of an embodiment of the present application, an electronic device is further provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above method through the computer program.
[0035] In an embodiment of the present application, the method adopts a method of obtaining distortion information of each layer of video frames in multiple layers of a first picture group that has been encoded, wherein the first picture group is a picture group in a target video that has been encoded before a second picture group that is currently to be encoded; according to the distortion information of each layer of video frames in the first picture group and the distortion information of reference layer video frames of each layer of video frames in the first picture group, determining a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group, wherein the reference layer video frames of each layer of video frames in the first picture group are video frames referenced when encoding each layer of video frames in the first picture group; using the target quantization parameter of each layer of video frames in the second picture group to encode each layer of video frames in the second picture group, when encoding the second picture group that is currently to be encoded, obtaining the target quantization parameter of each layer of video frames in the second picture group. The distortion information of each layer of video frames in multiple layers of the first picture group that completes encoding between picture groups is obtained, and the target quantization parameters of each layer of video frames in the second picture group are determined according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, so as to achieve the purpose of dynamically adjusting the quantization parameters of the current picture group to be encoded according to the distortion information of the encoded picture group, so that the quantization parameters of each layer of the current picture group to be encoded can fully reflect the reference relationship between the pictures, and the adjusted quantization parameters can be more suitable for each layer in the current picture group to be encoded, thereby achieving the technical effect of improving the adaptability of the quantization parameters used in the video encoding process, and then solving the technical problem of low adaptability of the quantization parameters used in the video encoding process in the related technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0038] Figure 1 is a schematic diagram of a hardware environment of a video encoding method according to an embodiment of the present application;
[0039] Figure 2 is a flowchart of an optional video encoding method according to an embodiment of the present application;
[0040] Figure 3 is a schematic diagram of a hierarchical structure of a picture group according to an embodiment of the present application;
[0041] Figure 4 is a schematic diagram of an optional video encoding device according to an embodiment of the present application;
[0042] Figure 5 It is a structural block diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0044] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0045] According to one aspect of the embodiments of the present application, a method embodiment of video encoding is provided.
[0046] Optionally, in this embodiment, the above video encoding method can be applied to Figure 1 In the hardware environment composed of the terminal 101 and the server 103 shown in FIG. Figure 1 As shown, the server 103 is connected to the terminal 101 through a network, and can be used to provide services (such as game services, application services, etc.) for the terminal or the client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 103. The above network includes but is not limited to: a wide area network, a metropolitan area network or a local area network, and the terminal 101 is not limited to a PC, a mobile phone, a tablet computer, etc. The encoding method of the video of the embodiment of the present application can be executed by the server 103, or by the terminal 101, or by the server 103 and the terminal 101. Among them, the terminal 101 executes the encoding method of the video of the embodiment of the present application, which can also be executed by the client installed thereon.
[0047] Figure 2 is a flowchart of an optional video encoding method according to an embodiment of the present application, such as Figure 2 As shown, the method may include the following steps:
[0048] Step S202, obtaining distortion information of each layer of video frames in multiple layers of a first picture group that has been encoded, wherein the first picture group is a picture group in the target video that has been encoded before a second picture group to be encoded;
[0049] Step S204, determining a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, wherein the reference layer video frames of each layer of video frames in the first picture group are video frames referenced when encoding each layer of video frames in the first picture group;
[0050] Step S206: Encode each layer of video frames in the second picture group using the target quantization parameter of each layer of video frames in the second picture group.
[0051] Through the above steps S202 to S206, when encoding the second picture group to be encoded, the distortion information of each layer of video frames in multiple layers of the first picture group that has been encoded between the second picture groups is obtained, and the target quantization parameter of each layer of video frames in the second picture group is determined according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frame of each layer of video frames in the first picture group, so as to achieve the purpose of dynamically adjusting the quantization parameter of the current picture group to be encoded according to the distortion information of the encoded picture group, so that the quantization parameter of each layer of the current picture group to be encoded can fully reflect the reference relationship between pictures, and the adjusted quantization parameter can be more suitable for each layer in the current picture group to be encoded, thereby achieving the technical effect of improving the adaptability of the quantization parameter used in the video encoding process, and then solving the technical problem of low adaptability of the quantization parameter used in the video encoding process in the related technology.
[0052] Optionally, in this embodiment, the video encoding method may be, but is not limited to, applied to various encoding methods that use quantization parameters to encode picture groups in a video, such as AV1 encoding.
[0053] In the technical solution provided in step S202, a group of pictures (Group of Pictures, GOP) refers to a set of continuous pictures in a video. Usually, the first picture in a GOP is an I frame, which is intra-coded and does not need to refer to other frames. Other frames in a GOP can be B frames or P frames, where P frames are coded with forward reference and B frames are coded with bidirectional reference.
[0054] Optionally, in this embodiment, the first picture group is a picture group in the target video that has been encoded before the second picture group currently to be encoded, for example: the first picture group can be a picture group in the target video that has been encoded before the second picture group currently to be encoded, or the first picture group can be a picture group in the target video that has been encoded M times before the second picture group currently to be encoded.
[0055] Optionally, in this embodiment, the GOP can be layered, and the pictures in the upper layer are usually encoded with reference to the pictures in the lower layer, and the pictures in the highest layer will not be referenced by other pictures. For example: Figure 3 is a schematic diagram of a hierarchical structure of a picture group according to an embodiment of the present application, such as Figure 3 As shown in the figure, the video frames in the picture group are divided into 5 layers. The 0th frame is an I frame, which can be encoded without referring to other frames. It can be used as a reference frame for other frames and is located in the 0th layer. The 1st, 2nd, 4th, 8th, and 16th frames all require the 0th frame as a reference frame for encoding. In addition, the high-level (4th layer) pictures are not referenced by other frames, while the low-level (1st, 2nd, 3rd, and 0th layers) pictures are all referenced by other frames.
[0056] Optionally, in this embodiment, the frame to be encoded can be called an encoded frame, and the frame referenced when the encoded frame is encoded can be called a reference frame. Similarly, the layer to be encoded in the picture group can be called an encoded layer, and the layer referenced when the encoded layer is encoded can be called a reference layer. Figure 3 In the hierarchical structure shown, when the second frame needs to be encoded, the second frame can be called a coded frame, and the reference frames of the second frame are the 0th frame and the 4th frame. When the first frame needs to be encoded, the first frame can be called a coded frame, and the reference frames of the first frame are the 0th frame and the 2nd frame. When the video frame of the second layer needs to be encoded, the second layer can be called a coding layer, and the reference layers of the second layer are the 0th layer and the 1st layer.
[0057] Optionally, in this embodiment, when the coded frame refers to other frames (reference frames), the reference frame has already been coded. And in actual coding, the coded frame refers to the reconstructed frame of the reference frame, rather than the reference frame itself (original frame). Therefore, the quality of the reconstructed frame of the reference frame directly affects the quality of the coded frame, and further affects the coding quality of the entire video. For example, Figure 3As shown in the figure, frame 7 needs to refer to frame 6, frame 6 needs to refer to frame 4, and frame 4 needs to refer to frame 0. If the encoding quality of frame 0 is not good, it will directly affect the encoding quality of frame 4, and the encoding quality of frame 7 will be affected layer by layer. Since these frames are also referenced by other frames, the quality of other frames will also be affected.
[0058] Optionally, in this embodiment, if the above-mentioned first picture group is the first picture group in the target video, it can be encoded using the default method in the encoding standard; if the first picture group is not the first picture group in the target video, it can be encoded using the encoding method provided in this embodiment.
[0059] Optionally, in this embodiment, the distortion information of each layer of video frames in multiple layers of the encoded first picture group obtained may include, but is not limited to: the average coding distortion of each layer (denoted as Dpre_i, where i represents the i-th layer) and the average reference distortion (Dref_j, where j represents the j-th layer). The average coding distortion of each layer is equal to the sum of the coding distortions of all frames in the layer divided by the number of all frames in the layer. The average reference distortion is equal to the sum of the coding distortions of all reference frames in the layer divided by the number of all reference frames in the layer. If the above-mentioned first picture group is the first picture group in the target video, since the reference frame uses a reconstructed frame, its distortion is also the coding distortion of other frames in the GOP, so the average reference distortion is equal to the average coding distortion.
[0060] In the technical solution provided in step S204, the quantization parameter (QP) has a QP range of [0,51] in AV1, which affects the relationship between the actual encoding process distortion and the file size. Simply put, the larger the value, the larger the quantization step size in the quantization process, the smaller the bit rate (bit value) required for encoding (corresponding to the smaller the encoded file size), but the distortion caused by the encoding process will also be greater.
[0061] Optionally, in this embodiment, by calculating the dependency between the coded frame and the reference frame and then calculating the impact factor of each layer, the Lambda value and QP value of each layer are dynamically adjusted according to the impact factor, thereby achieving the purpose of adjusting the QP value of each layer according to the change of video content.
[0062] Optionally, in this embodiment, the dependency coefficients between the layers of the current GOP are calculated by calculating the actual coding distortion size of each frame of the previous GOP, the coding distortion size of the corresponding reference frame, and the distortion size of the current GOP motion estimation pre-analysis, and then the influencing factors of each layer are obtained. Through the relationship between the influencing factors and the top layer, the Lambda values and QP values of the lower layers are adjusted.
[0063] In the above step S204, the target quantization parameter of each layer of the video frame in the second picture group may be determined in the following manner, but is not limited to:
[0064] S11, calculating, according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, an influence factor of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group, wherein the influence factor is used to indicate the influence degree of each layer of video frames in the second picture group as a reference layer on the coding layer that refers to each layer of video frames in the second picture group;
[0065] S12: Determine the target quantization parameter of each layer of video frames in the second picture group according to the influencing factor of each layer of video frames in the second picture group.
[0066] Optionally, in this embodiment, the influence factor is used to indicate the influence of each layer of video frames in the second picture group as a reference layer on the coding layer that refers to each layer of video frames in the second picture group, that is, the influence factor reflects the degree to which each layer in the picture group is relied on by other layers. It can also be said that the influence factor represents the influence of the current layer on its upper layer.
[0067] Optionally, in this embodiment, the target quantization parameter corresponding to each layer is determined according to the influence factor of the layer, that is, the determination of the target quantization parameter fully considers the reference dependency relationship between layers.
[0068] In the above step S11, the influence factor of each layer of video frames in the second picture group may be calculated in the following manner, but is not limited to:
[0069] S21, calculating an average dependency coefficient of each layer of video frames in the second picture group relative to a reference layer video frame according to distortion information of each layer of video frames in the first picture group and distortion information of a reference layer video frame of each layer of video frames in the first picture group, wherein the average dependency coefficient is used to indicate the degree of dependency of each layer of video frames in the second picture group on the reference layer video frame, and the reference layer video frame is a video frame to which each layer of video frames in the second picture group refers when encoding;
[0070] S22: Determine an influence factor of each layer of video frames in the second picture group according to an average dependency coefficient corresponding to each layer of video frames in the second picture group when the video frames are used as reference layer video frames.
[0071] Optionally, in this embodiment, firstly, an average dependency coefficient of each layer relative to its reference layer is calculated based on the distortion information of each layer in the first picture group and the distortion information of its reference layer, and the average dependency coefficient is used to indicate the dependency of each layer video frame in the second picture group on its reference layer video frame. Then, the influence factor is determined based on the average dependency coefficient.
[0072] In the above step S21, the average dependency coefficient of each layer of video frames in the second picture group may be calculated in the following manner, but is not limited to:
[0073] S31, calculating the variance of each video frame in the second picture group during motion estimation;
[0074] S32, calculating a dependency coefficient corresponding to each reference relationship included in the second picture group according to the variance of each video frame, the average coding distortion of the layer where each video frame is located, and the average reference distortion of the layer where the reference frame referenced by each video frame is located, wherein the dependency coefficient is used to indicate the dependency of the coding frame on the reference frame in each reference relationship, and the distortion information includes the average coding distortion and the average reference distortion;
[0075] S33, calculating the average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frames according to the dependency coefficient of the reference relationship between each layer of video frames in the second picture group and the reference layer video frames and the number of reference relationships.
[0076] Optionally, in this embodiment, the motion estimation process of all frames of the current GOP (ie, the second picture group) is first performed, and the variance variance_ori of each frame in the current GOP during motion estimation can be calculated.
[0077] Optionally, in this embodiment, according to the variance (variance_ori) of each video frame, the average coding distortion (Dpre_i) of the layer where each video frame is located, and the average reference distortion (Dref_j) of the layer where the reference frame referenced by each video frame is located, the dependency coefficient dep[Li,Lj] corresponding to each reference relationship included in the second picture group can be calculated by, but not limited to, the following formula: dep[Li,Lj]=Dpre_i / (Dref_j+variance_ori). That is, Figure 3 In the GOP hierarchy structure shown, each connection line represents a reference relationship, and a dependency coefficient can be calculated for each connection line.
[0078] Optionally, in this embodiment, since the I frame is an intra-frame coding mode frame and does not need to rely on other frames, and the B frame and P frame are inter-frame coding mode frames and need to refer to other frames for encoding, the dependency coefficients of the B frame and the P frame can be calculated here.
[0079] Optionally, in this embodiment, the average dependency coefficient may be calculated by, but is not limited to, dividing the sum of all dep[Li,Lj] by<Li,Lj> The total number of reference relationships. For example, Figure 3 In the GOP hierarchy structure shown in , the average dependency coefficient between the two layers can be calculated by dividing the dependency coefficient between each two layers by the total number of reference relationships between the two layers.
[0080] In the above step S22, the influence factor of each layer of video frames in the second picture group may be determined in the following manner but is not limited to:
[0081] S41, for a target layer that is not referenced in the second picture group, determining that an impact factor corresponding to the target layer is a preset impact factor;
[0082] S42: For a target layer referenced in the second picture group, determine an influence factor of the target layer according to an average dependency coefficient and an influence factor corresponding to a coding layer that references the target layer.
[0083] Optionally, in this embodiment, the target layer that is not referenced may be, but is not limited to, the topmost layer, and an influence factor may be preset for it. For example, the preset influence factor may be, but is not limited to, 1.
[0084] Optionally, in this embodiment, for the target layer referenced in the second picture group, its corresponding influence factor may be determined according to, but not limited to, the average dependency coefficient and influence factor corresponding to the coding layer of the reference target layer.
[0085] For example: Figure 3 Taking the GOP hierarchical structure shown in FIG. 1 as an example, the top layer (referred to as layer 4) will not be referenced by other layers, and its influence on other layers is 0, and its influence factor is recorded as: D4=1;
[0086] Layer 3 is referenced by the top layer 4, and the impact factor is calculated as: D3 = 1 + ave_dep[L4,L3];
[0087] Layer 2 is referenced by layers 4 and 3, and the impact factor is calculated as: D2 = 1 + ave_dep[L4,L2]*D4 + ave_dep[L3,L3]*D3;
[0088] Layer 1 is referenced by layers 4, 3, and 2, and the impact factor is calculated as: D1 = 1 + ave_dep[L4,L1]*D4 + ave_dep[L3,L1]*D3 + ave_dep[L2,L1]*D2;
[0089] The bottom layer, layer 0, is referenced by all the layers above it, and the impact factor is calculated as: D0=1+ave_dep[L4,L0]*D4+ave_dep[L3,L0]*D3+ave_dep[L2,L0]*D2+ave_dep[L1,L0]*D1.
[0090] In the above step S12, the target quantization parameter may be determined in the following manner, but is not limited to:
[0091] S51, searching for a preset Lambda parameter corresponding to a preset quantization parameter from Lambda parameters and quantization parameters having a corresponding relationship;
[0092] S52, for a target layer that is not referenced in the second picture group, determining that a target quantization parameter corresponding to the target layer is the preset quantization parameter;
[0093] S53, for the target layer referenced in the second picture group, determine the ratio between the preset Lambda parameter and the influencing factor of the target layer as the target Lambda parameter corresponding to the target layer; and search the quantization parameter corresponding to the target Lambda parameter from the Lambda parameters and quantization parameters with corresponding relationships as the target quantization parameter of the target layer.
[0094] Optionally, in this embodiment, the Lambda parameter and the quantization parameter required in the encoding process have a corresponding relationship. For the target layer (such as the top layer) that is not referenced in the second picture group, since other layers will be referenced by it, its corresponding target quantization parameter can be determined as the initial value, that is, the preset quantization parameter. The target quantization parameters of other layers are then determined according to the preset quantization parameter.
[0095] For example: Taking the above GOP hierarchy structure as an example, because all the bottom layers will be referenced by the top 4th layer, the Lambda of the top frame is the preset Lambda parameter, and QP is the initial QP value. The preset Lambda parameter can be found in the table based on the initial QP value (AV1 already has a Hash Table of the correspondence between Lambda and QP). The Lambda calculation method of the lower layer is: Lambda_i = Lambda / Di. According to the updated Lambda_i, the table is looked up to obtain the updated QP value corresponding to each layer. This QP value is the QP value required for encoding all frames of the corresponding layer.
[0096] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for an electronic device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0098] According to another aspect of an embodiment of the present application, a video encoding device for implementing the above-mentioned video encoding method is also provided. Figure 4 is a schematic diagram of an optional video encoding device according to an embodiment of the present application, such as Figure 4 As shown, the device may include:
[0099] An acquisition module 42 is used to acquire distortion information of each layer of video frames in multiple layers of a first picture group that has been encoded, wherein the first picture group is a picture group in the target video that has been encoded before a second picture group to be encoded;
[0100] a determination module 44, configured to determine a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to distortion information of each layer of video frames in the first picture group and distortion information of a reference layer video frame of each layer of video frames in the first picture group, wherein the reference layer video frame of each layer of video frames in the first picture group is a video frame referenced when encoding each layer of video frames in the first picture group;
[0101] The encoding module 46 is configured to encode each layer of the video frames in the second picture group using the target quantization parameter of each layer of the video frames in the second picture group.
[0102] It should be noted that the acquisition module 42 in this embodiment can be used to execute step S202 in the embodiment of the present application, the determination module 44 in this embodiment can be used to execute step S204 in the embodiment of the present application, and the encoding module 46 in this embodiment can be used to execute step S206 in the embodiment of the present application.
[0103] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1 In the hardware environment shown, it can be implemented by software or by hardware.
[0104] Through the above module, when encoding the second picture group to be encoded, the distortion information of each layer of video frames in multiple layers of the first picture group that has been encoded between the second picture groups is obtained, and the target quantization parameter of each layer of video frames in the second picture group is determined according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frame of each layer of video frames in the first picture group, so as to achieve the purpose of dynamically adjusting the quantization parameter of the current picture group to be encoded according to the distortion information of the encoded picture group, so that the quantization parameter of each layer of the current picture group to be encoded can fully reflect the reference relationship between the pictures, and the adjusted quantization parameter can be more suitable for each layer in the current picture group to be encoded, thereby achieving the technical effect of improving the adaptability of the quantization parameter used in the video encoding process, and then solving the technical problem of low adaptability of the quantization parameter used in the video encoding process in the related technology.
[0105] As an optional embodiment, the determining module includes:
[0106] a calculation unit, configured to calculate, according to distortion information of each layer of video frames in the first picture group and distortion information of reference layer video frames of each layer of video frames in the first picture group, an influence factor of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group, wherein the influence factor is used to indicate the influence degree of each layer of video frames in the second picture group as a reference layer on the coding layer that refers to each layer of video frames in the second picture group;
[0107] A determination unit is used to determine the target quantization parameter of each layer of video frames in the second picture group according to the influencing factor of each layer of video frames in the second picture group.
[0108] As an optional embodiment, the computing unit is used for:
[0109] Calculating, according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frame of each layer of video frames in the first picture group, an average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frame, wherein the average dependency coefficient is used to indicate the dependency of each layer of video frames in the second picture group on the reference layer video frame, and the reference layer video frame is a video frame referenced by each layer of video frames in the second picture group during encoding;
[0110] An influence factor of each layer of video frames in the second picture group is determined according to an average dependency coefficient corresponding to each layer of video frames in the second picture group when the video frames are used as reference layer video frames.
[0111] As an optional embodiment, the computing unit is used for:
[0112] Calculating the variance of each video frame in the second picture group during motion estimation;
[0113] Calculating a dependency coefficient corresponding to each reference relationship included in the second picture group according to the variance of each video frame, the average coding distortion of the layer where each video frame is located, and the average reference distortion of the layer where the reference frame referenced by each video frame is located, wherein the dependency coefficient is used to indicate the dependency of the coding frame on the reference frame in each reference relationship, and the distortion information includes the average coding distortion and the average reference distortion;
[0114] According to the dependency coefficient of the reference relationship between each layer of video frames in the second picture group and the reference layer video frames and the number of reference relationships, the average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frames is calculated.
[0115] As an optional embodiment, the computing unit is used for:
[0116] For a target layer that is not referenced in the second picture group, determining that an impact factor corresponding to the target layer is a preset impact factor;
[0117] For a target layer referenced in the second picture group, an influence factor of the target layer is determined according to an average dependency coefficient and an influence factor corresponding to a coding layer that references the target layer.
[0118] As an optional embodiment, the determining unit is used to:
[0119] Finding a preset Lambda parameter corresponding to the preset quantization parameter from Lambda parameters and quantization parameters having a corresponding relationship;
[0120] For a target layer that is not referenced in the second picture group, determining that a target quantization parameter corresponding to the target layer is the preset quantization parameter;
[0121] For the target layer referenced in the second picture group, the ratio between the preset Lambda parameter and the influencing factor of the target layer is determined as the target Lambda parameter corresponding to the target layer; and the quantization parameter corresponding to the target Lambda parameter is searched from the Lambda parameters and quantization parameters having a corresponding relationship as the target quantization parameter of the target layer.
[0122] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. It should be noted that the above modules as part of the device can be run in Figure 1 In the hardware environment shown, it can be implemented by software or by hardware, wherein the hardware environment includes a network environment.
[0123] According to another aspect of the embodiments of the present invention, an electronic device for implementing the above-mentioned video encoding method is also provided. Figure 5 As shown, the electronic device includes a memory 502 and a processor 504. The memory 502 stores a computer program, and the processor 504 is configured to execute the steps in any of the above method embodiments through the computer program.
[0124] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0125] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:
[0126] Obtaining distortion information of each layer of video frames in multiple layers of a first picture group that has been encoded, wherein the first picture group is a picture group that has been encoded before a second picture group to be encoded in a target video;
[0127] Determining a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to distortion information of each layer of video frames in the first picture group and distortion information of a reference layer video frame of each layer of video frames in the first picture group, wherein the reference layer video frame of each layer of video frames in the first picture group is a video frame referenced when encoding each layer of video frames in the first picture group;
[0128] Each layer of video frames in the second picture group is encoded using the target quantization parameter of each layer of video frames in the second picture group.
[0129] Alternatively, a person skilled in the art may understand that: Figure 5The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, or other terminal devices. Figure 5 The structure of the electronic device is not limited. Figure 5 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 5 Different configurations are shown.
[0130] Among them, the memory 502 can be used to store software programs and modules, such as the program instructions / modules corresponding to the method and device for displaying data forms in the embodiments of the present invention. The processor 504 executes various functional applications and data processing by running the software programs and modules stored in the memory 502, that is, realizing the above-mentioned method for displaying data forms. The memory 502 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 502 may further include a memory remotely located relative to the processor 504, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Among them, the memory 502 may specifically be used, but is not limited to, to store information such as feature information and probability results of the account to be processed. As an example, if Figure 5 As shown, the memory 502 may include but is not limited to the acquisition module 5022, the determination module 5024 and the encoding module 5026 in the video image processing device. In addition, it may also include but is not limited to other module units in the video encoding device, which will not be repeated in this example.
[0131] Optionally, the transmission device 506 is used to receive or send data via a network. Specific examples of the network may include wired networks and wireless networks. In one example, the transmission device 506 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices and routers via a network cable so as to communicate with the Internet or a local area network. In one example, the transmission device 506 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0132] In addition, the electronic device further comprises: a display 508 for displaying the characteristic information and probability result of the account to be processed; and a connection bus 510 for connecting the various module components in the electronic device.
[0133] The embodiment of the present application further provides a storage medium. Optionally, in this embodiment, the storage medium can be used to execute the program code of the video encoding method.
[0134] Optionally, in this embodiment, the storage medium may be located on at least one network device among a plurality of network devices in the network shown in the above embodiment.
[0135] Optionally, in this embodiment, the storage medium is configured to store program codes for executing the following steps:
[0136] Obtaining distortion information of each layer of video frames in multiple layers of a first picture group that has been encoded, wherein the first picture group is a picture group that has been encoded before a second picture group to be encoded in a target video;
[0137] Determining a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to distortion information of each layer of video frames in the first picture group and distortion information of a reference layer video frame of each layer of video frames in the first picture group, wherein the reference layer video frame of each layer of video frames in the first picture group is a video frame referenced when encoding each layer of video frames in the first picture group;
[0138] Each layer of video frames in the second picture group is encoded using the target quantization parameter of each layer of video frames in the second picture group.
[0139] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0140] Optionally, in this embodiment, the above-mentioned storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store program codes.
[0141] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0142] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
[0143] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0144] In the several embodiments provided in the present application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0145] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0146] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0147] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A video encoding method, characterized in that: include: Obtaining distortion information of each layer of video frames in multiple layers of a first picture group that has been encoded, wherein the first picture group is a picture group that has been encoded before a second picture group to be encoded in a target video; Determining a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to distortion information of each layer of video frames in the first picture group and distortion information of a reference layer video frame of each layer of video frames in the first picture group, wherein the reference layer video frame of each layer of video frames in the first picture group is a video frame referenced when encoding each layer of video frames in the first picture group; encoding each layer of video frames in the second group of pictures using a target quantization parameter of each layer of video frames in the second group of pictures; Wherein, determining the target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group includes: calculating the influence factor of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, wherein the influence factor is used to indicate the influence degree of each layer of video frames in the second picture group as a reference layer on the coding layer that refers to each layer of video frames in the second picture group; determining the target quantization parameter of each layer of video frames in the second picture group according to the influence factor of each layer of video frames in the second picture group; Wherein, according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, calculating the influence factor of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group includes: according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, calculating the average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frame, wherein the average dependency coefficient is used to indicate the dependency of each layer of video frames in the second picture group on the reference layer video frame, and the reference layer video frame is the video frame to which each layer of video frames in the second picture group refers when encoding; according to the average dependency coefficient corresponding to each layer of video frames in the second picture group when serving as reference layer video frames, determining the influence factor of each layer of video frames in the second picture group; Among them, according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, calculating the average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frames includes: calculating the variance of each video frame in the second picture group during motion estimation; calculating the dependency coefficient corresponding to each reference relationship included in the second picture group according to the variance of each video frame, the average coding distortion of the layer where each video frame is located, and the average reference distortion of the layer where the reference frame referenced by each video frame is located, wherein the dependency coefficient is used to indicate the dependence of the coded frame on the reference frame in each reference relationship, and the distortion information includes the average coding distortion and the average reference distortion; calculating the average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frames according to the dependency coefficient of the reference relationship included between each layer of video frames in the second picture group and the reference layer video frames and the number of reference relationships.
2. The method according to claim 1, characterized in that Determining, according to an average dependency coefficient corresponding to each layer of video frames in the second picture group as a reference layer video frame, an influencing factor of each layer of video frames in the second picture group includes: For a target layer that is not referenced in the second picture group, determining that an impact factor corresponding to the target layer is a preset impact factor; For a target layer referenced in the second picture group, an influence factor of the target layer is determined according to an average dependency coefficient and an influence factor corresponding to a coding layer that references the target layer.
3. The method according to claim 1, characterized in that Determining the target quantization parameter of each layer of video frames in the second picture group according to the influencing factor of each layer of video frames in the second picture group includes: Finding a preset Lambda parameter corresponding to the preset quantization parameter from Lambda parameters and quantization parameters having a corresponding relationship; For a target layer that is not referenced in the second picture group, determining that a target quantization parameter corresponding to the target layer is the preset quantization parameter; For the target layer referenced in the second picture group, the ratio between the preset Lambda parameter and the influencing factor of the target layer is determined as the target Lambda parameter corresponding to the target layer; and the quantization parameter corresponding to the target Lambda parameter is searched from the Lambda parameters and quantization parameters having a corresponding relationship as the target quantization parameter of the target layer.
4. A video encoding device, characterized in that: include: An acquisition module, configured to acquire distortion information of each layer of video frames in multiple layers of a first picture group that has been encoded, wherein the first picture group is a picture group in a target video that has been encoded before a second picture group to be encoded; a determination module, configured to determine a target quantization parameter of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to distortion information of each layer of video frames in the first picture group and distortion information of a reference layer video frame of each layer of video frames in the first picture group, wherein the reference layer video frame of each layer of video frames in the first picture group is a video frame referenced when encoding each layer of video frames in the first picture group; an encoding module, configured to encode each layer of video frames in the second picture group using a target quantization parameter of each layer of video frames in the second picture group; The determination module includes: a calculation unit, used to calculate the influence factor of each layer of video frames in the second picture group corresponding to each layer of video frames in the first picture group according to the distortion information of each layer of video frames in the first picture group and the distortion information of the reference layer video frames of each layer of video frames in the first picture group, wherein the influence factor is used to indicate the influence degree of each layer of video frames in the second picture group as a reference layer on the coding layer that refers to each layer of video frames in the second picture group; a determination unit, used to determine the target quantization parameter of each layer of video frames in the second picture group according to the influence factor of each layer of video frames in the second picture group; The calculation unit is further used for: calculating an average dependency coefficient of each layer of video frames in the second picture group relative to a reference layer video frame according to distortion information of each layer of video frames in the first picture group and distortion information of a reference layer video frame of each layer of video frames in the first picture group, wherein the average dependency coefficient is used to indicate the degree of dependency of each layer of video frames in the second picture group on the reference layer video frame, and the reference layer video frame is a video frame to which each layer of video frames in the second picture group refers when encoding; determining an influence factor of each layer of video frames in the second picture group according to the average dependency coefficient corresponding to each layer of video frames in the second picture group when used as a reference layer video frame; The calculation unit is further used to: calculate the variance of each video frame in the second picture group during motion estimation; calculate the dependency coefficient corresponding to each reference relationship included in the second picture group according to the variance of each video frame, the average coding distortion of the layer where each video frame is located, and the average reference distortion of the layer where each video frame refers to. The dependency coefficient is used to indicate the dependence of the coded frame on the reference frame in each reference relationship, and the distortion information includes the average coding distortion and the average reference distortion; calculate the average dependency coefficient of each layer of video frames in the second picture group relative to the reference layer video frames according to the dependency coefficient of the reference relationship included between each layer of video frames in the second picture group and the reference layer video frames and the number of reference relationships.
5. A storage medium, characterized in that: The storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 3 when executed.
6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: The processor executes the method according to any one of claims 1 to 3 through the computer program.
Citation Information
Patent Citations
Extension-type video encoding quantization parameter determination method and device
CN103096048A
Method for optimizing time domain rate-distortion in low-delay video coding
CN105872544A