Data coding method and device, computer equipment, medium and product
By obtaining the distortion values under the intra and inter-frame encoding strategies of video frames, determining the category label and distortion cost parameters, and adjusting the encoding parameters, the problem of inaccurate selection of encoding parameters in the prior art is solved, improving the video encoding effect and reducing the The bit rate consumption.
Patent Information
- Application Number
- CN202310777076.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-28
- Publication Date
- 2024-12-31
AI Technical Summary
It is difficult for existing video encoding technologies to accurately select appropriate encoding parameters, resulting in poor encoding effects.
By obtaining the distortion values under the intra and inter-frame encoding strategies of the video frame, determining the category label and distortion cost parameters of the video frame, and adjusting the encoding parameters to improve the encoding effect.
It realizes more accurate encoding parameters selection for video frames, improves encoding effect, and reduces code rate consumption while ensuring video quality.
Smart Images

Figure CN119232924A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video coding or image coding, and in particular to a data coding method, device, computer equipment, medium and product. Background Art
[0002] With the continuous development of computer technology, digital multimedia technology and coding and decoding technology, videos and images are becoming more and more popular in various fields and people's daily lives, and people's requirements for high-quality data (such as video data or image data) are getting higher and higher. Among them, when encoding data, the encoder usually needs to compare all possible encoding parameters and determine the optimal encoding parameters as the encoding parameters in the actual encoding process. Therefore, how to select appropriate encoding parameters to achieve data encoding and improve the encoding effect has become a current research hotspot. Summary of the invention
[0003] The embodiments of the present application provide a data encoding method, apparatus, computer equipment, medium and product, which can determine more accurate encoding parameters for video frames in a video, so as to improve the encoding effect of the video based on the encoding parameters.
[0004] In a first aspect, an embodiment of the present application provides a data encoding method, including:
[0005] Obtaining a first video distortion value of each video frame in a coded image group of a target video under an intra-frame coding strategy, and determining a category label of each video frame based on the first video distortion value of each video frame; the coded image group includes a plurality of continuous video frames in the target video; the category label is used to indicate the content complexity of the video frame;
[0006] Obtaining a second video distortion value of each video frame in the coded image group under an inter-frame coding strategy, and determining a distortion cost parameter of each video frame in a coding bit rate dimension based on the second video distortion value of each video frame in the coded image group;
[0007] Adjusting the distortion cost parameter of each video frame in the coded image group based on the category label of each video frame to obtain the adjusted distortion cost parameter of each video frame in the coded image group;
[0008] The coding parameters of the corresponding video frame are determined based on the adjusted distortion cost parameters of each video frame in the coded image group, and the coding parameters of each video frame are used to perform coding processing on the corresponding video frame.
[0009] In a second aspect, an embodiment of the present application provides a data encoding device, including:
[0010] A determination unit, configured to obtain a first video distortion value of each video frame in a coded image group of a target video under an intra-frame coding strategy, and determine a category label of each video frame based on the first video distortion value of each video frame; the coded image group includes a plurality of continuous video frames in the target video; the category label is used to indicate the content complexity of the video frame;
[0011] The determining unit is further configured to obtain a second video distortion value of each video frame in the coded image group under the inter-frame coding strategy, and determine a distortion cost parameter of each video frame in the coding bit rate dimension based on the second video distortion value of each video frame in the coded image group;
[0012] an adjusting unit, configured to adjust the distortion cost parameter of each video frame in the coded image group based on the category label of each video frame, so as to obtain the adjusted distortion cost parameter of each video frame in the coded image group;
[0013] The determining unit is further used to determine the encoding parameters of the corresponding video frame based on the adjusted distortion cost parameters of each video frame in the encoded image group, and the encoding parameters of each video frame are used to perform encoding processing on the corresponding video frame.
[0014] In a third aspect, an embodiment of the present application provides a computer device, which includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute some or all of the steps in the above method.
[0015] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and the computer program includes program instructions, which, when executed by a processor, are used to execute some or all of the steps in the above method.
[0016] In a fifth aspect, an embodiment of the present application further provides a computer program product or a computer program, which includes program instructions, and when the program instructions are executed by a processor, some or all of the steps in the above method can be implemented.
[0017] In the embodiment of the present application, the first video distortion value of each video frame in the coded image group of the target video under the intra-frame coding strategy can be obtained first, and the category label of each video frame can be determined based on the first video distortion value of each video frame; the coded image group contains multiple continuous video frames in the target video; the category label is used to indicate the content complexity of the video frame. The second video distortion value of each video frame in the coded image group under the inter-frame coding strategy can also be obtained, and the distortion cost parameter of each video frame in the coding bit rate dimension can be determined based on the second video distortion value of each video frame in the coded image group. Further, the distortion cost parameter of each video frame in the coded image group can be adjusted based on the category label of each video frame to obtain the adjusted distortion cost parameter of each video frame in the coded image group; the coding parameter of the corresponding video frame is determined based on the adjusted distortion cost parameter of each video frame in the coded image group, and the coding parameter of each video frame is used to encode the corresponding video frame. By implementing the above method, more accurate coding parameters can be determined for the video frames in the video, so as to improve the coding effect of the video based on the coding parameters. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application 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, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 It is a schematic diagram of the architecture of a data encoding system provided in an embodiment of the present application;
[0020] Figure 2 It is a flowchart of a data encoding method provided in an embodiment of the present application;
[0021] Figure 3 is a curve diagram of video distortion changing with encoding bit rate provided in an embodiment of the present application;
[0022] Figure 4 It is a flowchart of another data encoding method provided in an embodiment of the present application;
[0023] Figure 5 It is a flowchart of another data encoding method provided in an embodiment of the present application;
[0024] Figure 6 is a structural schematic diagram of a data encoding device provided in an embodiment of the present application;
[0025] Figure 7 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions 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 are within the scope of protection of this application.
[0027] Cloud Technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.
[0028] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, image websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.
[0029] Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called "cloud". The resources in the "cloud" are infinitely expandable in the eyes of users, and can be obtained at any time, used on demand, expanded at any time, and paid for by use.
[0030] The present application can store data related to data encoding in the "cloud", and the data in the cloud can be obtained and expanded at any time according to needs. For example, video frames can be associated with corresponding category labels and stored in the "cloud". If video frames with different category labels are needed, the required video frames can be obtained from the "cloud".
[0031] An embodiment of the present application proposes a data encoding scheme; specifically, the principle of the scheme is as follows: for any coded image group in one or more coded image groups contained in a target video, the distortion cost parameters of the corresponding video frame in the coding bit rate dimension can be adjusted based on the content complexity of each video frame in the coded image group to obtain the adjusted distortion cost parameters of each video frame; and then the encoding parameters of the corresponding video frame are determined based on the distortion cost parameters of each video frame, and the encoding parameters of each video frame can be used to encode the corresponding video frame.
[0032] The content complexity of the video frame can be indicated by a category label. In one embodiment, the category label of each video frame can be pre-added to each video frame; for example, the content complexity of each video frame can be predicted by a neural network model, so as to add a category label for the content complexity to each video frame based on the prediction result. In another embodiment, the category label of each video frame can be determined based on the distortion value of the video frame; for example, the first video distortion value of each video frame in the encoded image group under the intra-frame coding strategy (intra-frame prediction) can be obtained to determine the category label of each video frame based on the first video distortion value of each video frame.
[0033] In one embodiment, the distortion cost parameter of each video frame in the encoding bit rate dimension may also be determined based on the distortion value of the video frame. For example, the second video distortion value of each video frame in the encoded image group under the inter-frame coding strategy (inter-frame prediction) may be obtained to determine the distortion cost parameter of each video frame in the encoding bit rate dimension based on the second video distortion value of each video frame in the encoded image group.
[0034] In a specific implementation, the execution subject of the above-mentioned data encoding scheme may be a computer device, which may be a terminal or a server. The terminal mentioned here may be a smart phone, tablet computer, laptop computer, desktop computer and other devices; the server may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms, etc.
[0035] It should be noted that when the computer device is a server, the embodiment of the present application provides a data encoding system, such as Figure 1As shown, the data encoding system includes at least one terminal and at least one server; the terminal can obtain the target video and upload the obtained target video to the server (i.e., a computer device), so that the computer device can obtain a coded image group of the target video, and encode the coded image group based on a data encoding scheme to obtain encoding parameters of each video frame in the coded image group.
[0036] By implementing the above scheme, the complexity of each video frame can be further subdivided to design a unique distortion cost parameter under the encoding bit rate dimension for each video frame, and then the corresponding encoding parameters can be determined based on the distortion cost parameter of each video frame; thus, the video content can be classified to adaptively adjust the bit rate of the video frame based on the classification result to achieve a more fine-grained bit rate allocation, thereby effectively improving the accuracy of bit rate allocation, and then improving the encoding efficiency and encoding effect. Practice has shown that under the premise of the same video quality, this scheme can bring certain bit rate savings, that is, while ensuring video quality, it can effectively reduce bit rate consumption.
[0037] Based on the above description of the data encoding scheme, the present application embodiment proposes a data encoding method. The present application embodiment is mainly described with a computer device as the execution subject; see Figure 2 , the data encoding method may include the following steps S201-S204:
[0038] S201, obtaining a first video distortion value of each video frame in a coded image group of a target video under an intra-frame coding strategy, and determining a category label of each video frame based on the first video distortion value of each video frame.
[0039] The target video may refer to a video to be encoded, and the target video may be a video of any type or length, and is not limited thereto.
[0040] It should be understood that in video encoding, the video frame sequence corresponding to the video can be divided into several GOPs (Group Of Pictures), and each video frame in each GOP is encoded in units of GOP, thereby realizing the encoding of the video. Among them, GOP refers to a group of encoded images starting with an I frame and ending with the next I frame. A GOP can contain I frames, P frames, and B frames. A GOP is a set of pictures in a video frame sequence. A GOP is a group of continuous video frames. The number of video frames in a GOP is not limited.
[0041] It should be noted that the coding parameters of the video frames involved in the data coding method proposed in the embodiment of the present application may refer to each video frame in the coded image group, or may only be the P frame in the coded image group, or may only be the B frame in the coded image group, without limitation. Considering that the coding rate of the P frame can be adjusted in a larger range, it is preferred to determine the coding parameters of the P frame in the coded image group using the data coding method proposed in the embodiment of the present application.
[0042] The coded picture group in the present application can be understood as the above-mentioned GOP. Based on this, it can be known that when encoding the target video, it can be encoded in units of coded picture groups. A target video can be divided into one or more coded picture groups, and a coded picture group contains multiple consecutive video frames in the target video.
[0043] It is understandable that the content included in each video frame in the target video is usually different, and the content included in a video frame may be relatively simple or relatively complex. In the present application, the video frames are classified based on the complexity of the content of the video frames, and the encoding bit rate of the video frames is adaptively adjusted based on the classification results, so as to achieve the subdivision of content of different complexity and better adjust the encoding bit rate of the video frames.
[0044] The video frames in the coded image group may be marked with a category label, and the category label may be used to indicate the complexity of the content of the video frame.
[0045] In one implementation, the category label of the video frame can be determined based on the video distortion value of the video frame under the intra-frame coding strategy (intra-frame prediction); for the convenience of description, the video distortion value here can be referred to as the first video distortion value, and the first video distortion value can also be referred to as the intra-frame complexity (intra_compelx). Considering that the principle of determining the first video distortion value of each video frame is the same, the following specifically describes the determination of the first video distortion value by taking any video frame in the coded picture group as an example.
[0046] Optionally, for any video frame in the coded image group, the distortion value of each coding block in any video frame under the intra-frame coding strategy can be determined first. For the convenience of description, the distortion value for the coding block can be determined as a block distortion value. Among them, the block distortion value can refer to the sum of absolute difference (SAD), the sum of absolute difference after transformation (SATD), and other parameters that can be used to characterize the distortion value. As mentioned above, the distortion value calculated here is the distortion value under the intra-frame coding strategy, then SAD can refer to intra_SAD, and SATD refers to intra_SATD.
[0047] After obtaining the block distortion value of each coding block, the first video distortion value of any video frame can be determined based on the block distortion value of each coding block. For example, the block distortion values of the coding blocks contained in any video frame can be averaged, and the result obtained by the average operation is used as the first video distortion value of the video frame under the intra-frame coding strategy; in other words, the intra-frame complexity (i.e., block distortion value) of each frame video will be calculated in the encoder, and then the average intra-frame complexity (i.e., first video distortion value) of each frame video will be solved based on the intra-frame complexity. For another example, the target coding block can be determined from the coding blocks contained in any video frame, and the first video distortion value of any video frame can be determined based on the block distortion value of the target coding block. Among them, the number of the target coding blocks can be one or more, and the method of determining the target coding block from the coding blocks contained in any video frame can be a random selection method, or it can be a method of using a preset selection rule, which is not limited.
[0048] In one implementation, considering that the original determination of the category label of the video frame based on the first video distortion value is consistent, the determination of the category label is specifically described below by taking any video frame in the coded image group as an example. For any video frame in the coded image group, the first video distortion value of the any video frame can be compared with a threshold value to determine the category label of the any video frame based on the comparison result. The threshold value can include a first threshold value and a second threshold value, and the first threshold value is less than the second threshold value.
[0049] Optionally, the specific implementation of determining the category label of any video frame may be: if the first video distortion value of any video frame is less than the first threshold, the category label corresponding to any video frame may be determined as the first category label; if the first video distortion value of any video frame is greater than the second threshold, the category label corresponding to any video frame may be determined as the second category label. And if the first video distortion value of any video frame is greater than the first threshold and less than the second threshold, the category label corresponding to any video frame may be determined as the third category label.
[0050] Among them, the first category label can be used to indicate that the content complexity of the video frame is low, the second category label can be used to indicate that the content complexity of the video frame is high, and the third category label can be used to indicate that the content complexity of the video frame is medium. Based on this, if the category label of a video frame is the first category label, the scene of the video frame in the video content dimension is a simple scene, if the category label of a video frame is the second category label, then the scene of the video frame in the video content dimension is a complex scene, and if the category label of a video frame is the third category label, then the scene of the video frame in the video content dimension is a medium scene.
[0051] For example, the first threshold value can be set to 1.5, and the second threshold value can be set to 6. If the first video distortion value of a video frame is less than 1.5, the category label of the video frame is the first category label, that is, the video frame is a video frame in a simple scene. If the first video distortion value of a video frame is greater than 6, the category label of the video frame is the second category label, that is, the video frame is a video frame in a complex scene. For video frames corresponding to the first video distortion values between 1.5 and 6, it can be determined that the scene setting of such video frames is a medium scene.
[0052] In summary, the embodiments of the present application can classify video content according to the degree of complexity (complexity), and the classification rule is to calculate the size of the distortion value of the intra-frame prediction of the video frame (that is, the first video distortion value), and according to the size of the distortion value of the intra-frame prediction, divide the video content of the video frame into simple, medium and complex scenes, so that the bit rate of the video frame can be allocated based on the scene classification later.
[0053] S202, obtaining a second video distortion value of each video frame in the coded image group under the inter-frame coding strategy, and determining a distortion cost parameter of each video frame in the coding bit rate dimension based on the second video distortion value of each video frame in the coded image group.
[0054] The second video distortion value of a video frame under the inter-frame coding strategy may refer to: the video distortion value of the video frame under the inter-frame coding strategy (inter-frame prediction).
[0055] Among them, obtaining the second video distortion value of each video frame in the coded image group under the inter-frame coding strategy is similar to the principle of obtaining the first video distortion value mentioned above, the difference is that here it is for the distortion value under the inter-frame coding strategy. In one implementation, for any video frame in the coded image group, the block distortion value of each coding block in any video frame under the inter-frame coding strategy can be determined first; and then based on the block distortion value of each coding block under the inter-frame coding strategy, the second video distortion value of any video frame under the inter-frame coding strategy is determined. Among them, determining the second video distortion value based on the block distortion value under the inter-frame coding strategy is similar to the principle of determining the first video distortion value based on the block distortion value under the intra-frame coding strategy described above, which will not be repeated here.
[0056] In one implementation, based on the second video distortion value of each video frame in the encoded picture group, a specific implementation of determining the distortion cost parameter of each video frame in the encoding bit rate dimension may be described as follows.
[0057] Optionally, a mapping relationship between a preset reference video distortion value and a reference distortion cost parameter of a video frame may be obtained, wherein the mapping relationship includes a large number of corresponding relationships between reference video distortion values and reference distortion cost parameters. After obtaining the mapping relationship, for any video frame in the coded image group, a reference video distortion value consistent with the second video distortion value of any video frame may be searched from the mapping relationship, and the reference distortion cost parameter of the reference video distortion value found may be used as the distortion cost parameter of any video frame in the coding bit rate dimension.
[0058] Optionally, the reference encoding bit rate of each video frame in the coded image group may be obtained first, so as to determine the rate-distortion cost for the coded image group based on the second video distortion value of each video frame in the coded image group and the reference encoding bit rate; further, the distortion cost parameter of each video frame in the coded image group may be determined based on the rate-distortion cost of the coded image group. The reference encoding bit rate of the video frame is the encoding bit rate assigned to the video frame by the encoder when selecting encoding parameters.
[0059] The following first explains the rate-distortion cost of encoding a group of pictures.
[0060] It should be understood that when the encoder encodes data (such as video data or image data), different coding parameter combinations (quantization parameters, coding strategies (inter-frame coding strategy or intra-frame coding strategy), distortion, coding bit rate, etc.) are used for the same video or the same image during the encoding process, and the encoding performance corresponding to each coding parameter combination is calculated respectively, such as the rate-distortion cost, and then the coding parameter combination to be used for the video frame is determined according to the rate-distortion cost. When encoding using different coding parameter combinations, the information of the bit rate R and distortion D corresponding to the current coding parameter combination P can be obtained, which is recorded as (R, D) P , because there are multiple quantization parameters, multiple coding strategies, etc. in the coding parameter set, the coding parameter combination is any combination of quantization parameters, coding strategies, etc. The combinations of different coding parameters are limited. Therefore, if all possible coding parameter combinations are traversed, a large number of R-D point pairs will be obtained, that is, under each coding parameter combination, there is a corresponding bit rate R and distortion D. Mathematically prove that the boundaries of all R-D point pairs can be formed as follows Figure 3 The convex hull line shown in Figure 1 can be understood as the rate-distortion curve of the encoder for a certain video or image. The rate-distortion curve represents the minimum distortion that can be achieved for the video or image at each bit rate point. The rate-distortion curve also reflects the performance limit of the current encoder at different bit rates.
[0061] For example, taking the P frame in the coded picture group as an example, in the encoder, the P frame adopts a unified RDO algorithm, such as Figure 3As shown in the rate-distortion curve, assuming that the given encoding bit rate of the P frame is Rt, the corresponding point O of the encoding bit rate of the P frame and the video distortion (which can be understood as the video distortion value under the inter-frame coding strategy) can be found in the rate-distortion curve. This point is the optimal point of compromise between the encoding bit rate and the video distortion. The slope of point O corresponds to the -lambda value in the encoder.
[0062] When the encoder encodes video data or image data, the encoding goal can be expressed as selecting a coding parameter combination P from the coding parameter set S to minimize the distortion D (i.e., closest to the rate-distortion curve). In practical application scenarios, the optimal point can be found through rate-distortion optimization (RDO): For example, the Lagrange multiplier method can be used to construct a rate-distortion optimization objective function, as shown in formula (1):
[0063] J = lambda * R + D (1)
[0064] Where J is the rate distortion cost, R is the coding bit rate consumed under the coding parameter combination, and D is the distortion, which can be the sum of absolute difference (SAD) or the sum of absolute difference after transformation (SATD). The D(R) curve is as follows: Figure 3 As shown, the point where the slope of the curve is -lambda is the optimal point. For the encoder, the evaluation of the coding parameter combination is to calculate the rate-distortion cost J of different coding parameter combinations and find a combination with the smallest J. It should be noted that the above (1) is only an exemplary representation of the rate-distortion cost, and the rate-distortion cost can be represented by other functional relationships, which is not limited to this.
[0065] Based on the understanding of the above formula (1), it can be known that, optionally, the computer device can determine the rate-distortion cost of the coded image group through a rate-distortion optimization objective function. For example, the rate-distortion cost of the coded image group can be expressed by the following formula (2):
[0066] J=(D1+…+Dk)+lambda(R1+…+Rk)(2)
[0067] Wherein, J represents the rate-distortion cost of the entire coded picture group, k represents the number of video frames in the coded picture group, Dk represents the distortion of the k-th video frame in the coded picture group (i.e., the second video distortion), and Rk represents the reference encoding bit rate of the k-th video frame in the coded picture group. That is, the rate-distortion cost of the coded picture group can be obtained by combining the second video distortion of the video frames included in the coded picture group and the reference encoding bit rate.
[0068] For example, a coded picture group may include a P frame and a B frame, and the rate-distortion cost of the coded picture group may be determined based on the distortion and encoding bit rate of the P frame, and the distortion and encoding bit rate of the B frame. In this embodiment, the computer device may determine the rate-distortion cost of the coded picture group by the following formula (3):
[0069] J=(DP1+…+DPn+DB1+…+DBm)+lambda(RP1+…+RPn+RB1+…+RBm)(3)
[0070] Among them, formula (2) can be understood as a rate-distortion function, J represents the rate-distortion cost of the entire GOP; n represents the number of P frames in the GOP, and m represents the number of B frames in the GOP, that is, there are n P frames and m B frames in the GOP. DP1 represents the distortion of the first P frame in the GOP, DP2 represents the distortion of the second P frame in the GOP, and so on, DPn represents the distortion of the nth P frame in the GOP. DB1 represents the distortion of the first B frame in the GOP, DB2 represents the distortion of the second B frame in the GOP, and so on, DBm represents the distortion of the mth B frame in the GOP. RP1 represents the encoding bit rate of the first P frame in GOP, RP2 represents the encoding bit rate of the second P frame in GOP, and so on. RPn represents the encoding bit rate of the nth P frame in GOP; RB1 represents the encoding bit rate of the first B frame in GOP, RB2 represents the encoding bit rate of the second B frame in GOP, and so on. RBm represents the encoding bit rate of the mth B frame in GOP.
[0071] Considering that the principle of determining the distortion cost parameter of each video frame based on the rate-distortion cost is consistent, the following takes any video frame in the coded image group as an example to explain the determination of the distortion cost parameter of any video frame based on the rate-distortion cost of the coded image group. The specific implementation can be as follows: steps s1-s2:
[0072] s1, for any video frame in the coded image group, the cost change of the rate-distortion cost under any video frame can be determined based on the rate-distortion cost of the coded image group, and the distortion cost parameter for the coded image group in the encoding bit rate dimension can be determined based on the cost change.
[0073] Optionally, a specific implementation method for determining the cost change of the rate-distortion cost in any video frame may be: performing a derivation processing on the encoding bit rate in any video frame based on the rate-distortion cost, that is, the derivation result may be used as the cost change of the rate-distortion cost in any video frame.
[0074] For example, taking the above formula (2) as an example, for the first video frame in the coded image group, the coding bit rate of the first video frame can be derived based on formula (2) to obtain the following formula (4), where formula (4) represents the cost change of the rate-distortion cost for the first video frame.
[0075] dJ / dR1=(dD1+…+dDk) / dR1+lambda(4)
[0076] Wherein, dR1 represents the code rate change of the encoding code rate allocated to the first video frame, and dD1+…+dDk represents the distortion change of the encoded picture group. Wherein, dD1 represents the distortion change value of the first video frame in the GOP, and so on.
[0077] For another example, taking the above formula (3) as an example, assuming that any video frame is the first P frame in the coded image group, RP1 can be derived based on formula (3) to obtain the following formula (5), which represents the cost change of the rate-distortion cost under the first P frame.
[0078] dJ / dRP1=(dDP1+…+dDPn+dDB1+…+dDBm) / dRP1+lambda(5)
[0079] Among them, dRP1 represents the code rate change of the encoding code rate allocated to the first P frame, and dDP1+…+dDPn+dDB1+…+dDBm represents the distortion change of the coded picture group. Among them, dDP1 represents the distortion change value of the first P frame in the GOP, dDP2 represents the distortion change value of the second P frame in the GOP, and so on; dDB1 represents the distortion change value of the first B frame in the GOP, and dDB2 represents the distortion change value of the second B frame in the GOP.
[0080] The distortion cost parameter of the coded image group in the coding bit rate dimension is the lambda mentioned above, such as the lambda in formula (4) or formula (5). To determine lambda, the cost change can be set to 0, so that lambda can be determined by mathematical conversion rules.
[0081] For example, taking the above formula (4) as an example, dJ / dR1 in formula (4) can be set to 0 to determine the distortion cost parameter for the coded image group in the coding bit rate dimension based on the equation after being set to 0. The distortion cost parameter for the coded image group in the coding bit rate dimension is lambda.
[0082] Exemplarily, when dJ / dR1=0, the calculation formula of lambda of the coded picture group is shown in (6):
[0083] lambda=—(dD1+…+dDk) / dR1(6)
[0084] For another example, taking the above formula (5) as an example, dJ / dRP1 in formula (5) can be set to 0, so as to determine the distortion cost parameter for the coded image group in the coding bit rate dimension based on the equation after being set to 0. The distortion cost parameter for the coded image group in the coding bit rate dimension is lambda.
[0085] Exemplarily, when dJ / dRP1=0, the calculation formula of lambda of the coded picture group is shown in (7):
[0086] lambda=—(dDP1+…+dDPn+dDB1+…+dDBm) / dRP1(7)
[0087] s2, determining a distortion cost parameter of any video frame based on a distortion cost parameter of the coded picture group in a coding bit rate dimension and a reference distortion cost parameter of any video frame in a coding bit rate dimension.
[0088] Optionally, the association relationship between any video frame and the coded image group in the distortion cost parameter dimension can be determined based on the distortion cost parameter of the coded image group in the coding bit rate dimension and the reference distortion cost parameter of any video frame in the coding bit rate dimension; and then the distortion cost parameter of any video frame can be determined based on the association relationship and the distortion cost parameter of the coded image group.
[0089] It can be understood that the rate-distortion cost of a video frame can satisfy the above formula (1). For example, for any video frame in the coded picture group, the rate-distortion cost of any video frame can be expressed by the following formula (8):
[0090] Ji=Di+lambda_i*Ri(8)
[0091] Among them, Ji represents the rate-distortion cost of the i-th video frame in the coded image group, Di represents the distortion of the i-th video frame, Ri represents the encoding bit rate of the i-th video frame, and lambda_i represents the distortion cost parameter of the i-th video frame.
[0092] For any video frame, the principle of determining the reference distortion cost parameter of the video frame in the encoding bit rate dimension is similar to the principle of determining the reference distortion cost parameter of the video frame of the encoded image group in the encoding bit rate dimension. Determining the reference distortion cost parameter of the video frame in the encoding bit rate dimension is to solve lambda_i in the above formula (8). For example, a specific implementation method may be: based on the rate-distortion cost of the video frame, the encoding bit rate of the video frame is derived, and the derivative result is set to 0, and the reference distortion cost parameter of the video frame in the encoding bit rate dimension is further determined based on the mathematical conversion rule.
[0093] For example, the reference distortion cost parameter of a video frame in the encoding bit rate dimension can be expressed as the following formula (9):
[0094] lambda_i=—dDi / dRi(9)
[0095] Wherein, dDi represents the change value of the distortion of the i-th video frame, and dRi represents the change value of the bit rate of the i-th video frame.
[0096] For another example, taking the video frame as a P frame, the reference distortion cost parameter of the P frame in the encoding bit rate dimension can be expressed as the following formula (10):
[0097] lambda_Pi = -dDPi / dRPi (10)
[0098] Wherein, lambda_Pi represents the lambda of the ith P frame, dDPi represents the change value of the distortion of the ith P frame, and dRPi represents the change value of the bit rate of the ith P frame.
[0099] Among them, the correlation between any video frame and the coded image group in the distortion cost parameter dimension can be derived based on the above formula. For example, through the above formula (6) and formula (9), it can be concluded that the correlation between lambda_i of the i-th video frame and lambda of GOP is as shown in formula (11). Based on the correlation, the distortion cost parameter of the i-th video frame can be further determined, such as the distortion cost parameter of the i-th video frame can be as shown in formula (12).
[0100] wi=dDi / (dD1+…+dDk)(11)
[0101] lambda_i=lambda*wi(12)
[0102] Among them, wi represents the ratio of the distortion change of the i-th video frame to the distortion change of the entire coded image group. wi can be used to represent the correlation between the i-th video frame and the coded image group in the dimension of distortion cost parameters. It can be seen that lambda_i can effectively represent the size of the correlation between frames. For video frames with different category labels, the weight value of wi is different, so different wi values can be provided for video frames of different complexity.
[0103] For another example, taking the P frame in the coded picture group as an example, the correlation between the P frame and the coded picture group in the distortion cost parameter dimension can be obtained based on the above formulas (7) and (10). The correlation between lambda_Pi of the i-th P frame and lambda of the GOP is shown in formula (13). Based on the correlation, the distortion cost parameter of the i-th P frame can be further determined, such as the distortion cost parameter of the i-th P frame can be shown in formula (14).
[0104] wi=dDPi / (dDP1+…+dDPn+dDB1+…+dDBm)(13)
[0105] lambda_Pi=lambda*wi(14)
[0106] S203 , adjusting the distortion cost parameter of each video frame in the coded image group based on the category label of each video frame to obtain the adjusted distortion cost parameter of each video frame in the coded image group.
[0107] In one implementation, a target video frame whose category label is a target category label can be first determined from each video frame, and then the distortion cost parameter of the target video frame can be adjusted according to a first adjustment method to obtain the adjusted distortion cost parameter of the target video frame; and for a non-target video frame in a coded image group, the distortion cost parameter of the non-target video frame can be adjusted according to a second adjustment method to obtain the adjusted distortion cost parameter of the non-target video frame. The second adjustment method can be understood as a weighting coefficient of 1 for the distortion cost parameter, that is, keeping the original distortion cost parameter unchanged.
[0108] Among them, the target category label can be one or more of a first category label and a second category label, the target video frame corresponding to the first category label is a video frame whose first video distortion value is less than a first threshold, and the target video frame corresponding to the second category label is a video frame whose first video distortion value is greater than a second threshold. As mentioned above, the target video frame corresponding to the first category label is a video frame with relatively simple video content, and the target video frame corresponding to the second category label is a video frame with relatively complex video content. In an embodiment of the present application, the distortion cost parameters of video frames with relatively simple or complex video content can be adjusted to be adjusted to more appropriate distortion cost parameters.
[0109] S204: Determine encoding parameters of corresponding video frames based on the adjusted distortion cost parameters of each video frame in the encoded picture group.
[0110] The encoding parameters of any video frame may include an encoding bit rate.
[0111] In one implementation, a mapping relationship between a preset reference distortion cost parameter and a reference coding parameter can be obtained, and the mapping relationship can include a large number of corresponding relationships between reference distortion cost parameters and reference coding parameters; after obtaining the mapping relationship, for any video frame in the encoded image group, a reference video distortion value consistent with the adjusted distortion cost parameter of any video frame can be searched from the mapping relationship, and the reference coding parameters of the reference video distortion value found can be used as the coding parameters of any video frame.
[0112] In another implementation, the quantization parameter of each video frame can be determined based on the distortion cost parameter of each video frame, that is, the quantization parameter of a video frame can be determined using the distortion cost parameter of the video frame. The quantization parameter can be determined using the parameter relationship between the preset quantization parameter and the distortion cost parameter. For example, the parameter relationship can be shown in the following formula (15):
[0113] QP_i=C1+C2*(double)log2(lambda_i / C3)(15)
[0114] Wherein, QP_i represents the quantization parameter of the i-th video frame in the coded picture group, lambda_i represents the distortion cost parameter of the i-th video frame in the coded picture group; C1, C2, C3 are hyperparameters, such as C1=12, C2=6, C3=0.85. That is, the quantization parameter of the video frame can be determined based on the distortion cost parameter of the video frame by formula (15).
[0115] After determining the quantization parameter of each video frame, the encoding bit rate of each video frame can be determined based on the quantization parameter of each video frame. It should be understood that the relationship between the encoding bit rate and the distortion and the quantization parameter in the encoding process is: the higher the quantization parameter, the lower the encoding bit rate of the encoding and the greater the distortion; the lower the quantization parameter, the higher the encoding bit rate of the encoding and the smaller the distortion. Based on this, it can be known that the encoding bit rate of each video frame can be determined based on the quantization parameter of each video frame according to the bit rate allocation rule that the quantization parameter and the encoding bit rate are negatively correlated, that is, the encoding bit rate of the video frame is negatively correlated with the quantization parameter. That is, if the quantization parameter of a video frame is higher, the encoding bit rate of the video frame is lower, and when the bit rate is allocated, a less encoding bit rate can be allocated to the video frame; and the lower the quantization parameter of the video frame, the higher the encoding bit rate of the video frame, and when the bit rate is allocated, a more encoding bit rate can be allocated to the video frame.
[0116] In the embodiment of the present application, the complexity of each video frame can be further subdivided to design a unique distortion cost parameter under the encoding bit rate dimension for each video frame, and then the corresponding encoding parameter can be determined based on the distortion cost parameter of each video frame; thus, the video content can be classified to adaptively adjust the bit rate of the video frame based on the classification result to achieve a more fine-grained bit rate allocation, thereby effectively improving the accuracy of bit rate allocation, and then improving the encoding efficiency and encoding effect. Practice has shown that under the premise of the same video quality, this solution can bring certain bit rate savings, that is, while ensuring video quality, it can effectively reduce bit rate consumption.
[0117] See also Figure 4 , is a flow chart of another data encoding method provided in an embodiment of the present application. The present application embodiment is mainly described with a computer device as the execution subject; see Figure 4 , the data encoding method may include the following steps S401-S406:
[0118] S401, obtaining a first video distortion value of each video frame in a coded image group of a target video under an intra-frame coding strategy, and determining a category label of each video frame based on the first video distortion value of each video frame.
[0119] S402, obtaining a second video distortion value of each video frame in the coded picture group under the inter-frame coding strategy, and determining a distortion cost parameter of each video frame in the coding bit rate dimension based on the second video distortion value of each video frame in the coded picture group.
[0120] The specific implementation of steps S401-S402 may refer to the specific implementation of steps S201-S202 above, which will not be repeated here.
[0121] S403: Determine a target video frame whose category label is a target category label from each video frame.
[0122] Among them, the target category label can be one or more of a first category label and a second category label, the target video frame corresponding to the first category label is a video frame whose first video distortion value is less than a first threshold, and the target video frame corresponding to the second category label is a video frame whose first video distortion value is greater than a second threshold. As mentioned above, the target video frame corresponding to the first category label is a video frame with a relatively simple video content, and the target video frame corresponding to the second category label is a video frame with a relatively complex video content. In an embodiment of the present application, the distortion cost parameters of video frames with relatively simple or complex video contents can be adjusted so that the adjusted distortion cost parameters can be used to determine a coding bit rate that better matches the corresponding video frame, thereby achieving the effect of improving coding efficiency.
[0123] S404: Adjust the distortion cost parameters of the target video frame in the coded picture group according to the first adjustment method to obtain the adjusted distortion cost parameters of the target video frame.
[0124] In one implementation, a target weight for adjusting the distortion cost parameter of the target video frame may be obtained, so as to determine the adjusted distortion cost parameter of the target video frame based on the target weight and the distortion cost parameter. For example, the distortion cost parameter of the target video frame may be weighted using the target weight, and the weighted distortion cost parameter may be used as the adjusted distortion cost parameter of the target video frame. In this implementation, the computer device may determine the adjusted distortion cost parameter of the target video frame using the following formula (16):
[0125] lambda_i_new=lambda_i*weight_c(16)
[0126] Among them, lambda_i_new represents the adjusted distortion cost parameter of the i-th video frame, lambda_i represents the distortion cost parameter of the i-th video frame, and weight_c represents the target weight.
[0127] The following specifically describes how to obtain the target weight of the target video frame. The target weight can be determined based on the complexity of the video content of the target video frame. When the complexity of the video content of the target video frame is lower, the numerical value corresponding to the target weight can be larger. The larger the target weight, the larger the numerical value corresponding to the adjusted distortion cost parameter of the target video frame, and the larger the quantization parameter determined based on the adjusted distortion cost parameter, and the smaller the corresponding allocated encoding bit rate can be. When the complexity of the video content of the target video frame is higher, the numerical value corresponding to the target weight can be smaller. The smaller the target weight, the smaller the numerical value corresponding to the adjusted distortion cost parameter of the target video frame, and the smaller the quantization parameter determined based on the adjusted distortion cost parameter, and the larger the corresponding allocated encoding bit rate can be.
[0128] Optionally, a corresponding target weight may be set for the first category label and a corresponding target weight may be set for the second category label in advance, wherein the target weight corresponding to the first category label is greater than the target weight corresponding to the second category label; and the specific value corresponding to the target weight is not limited.
[0129] In another implementation, the target weight of the target video frame can be determined by controlling the variable. Optionally, a preset weight range for the target video frame can be obtained first to determine the target weight corresponding to the target video frame within the weight range. The weight range can include multiple reference weights, and the weight range can be understood as a compensation value interval for adjusting the target video frame, such as the interval can be [—5, +5].
[0130] In one embodiment, each reference weight within the weight range can be traversed in turn to determine the index data generated by encoding the target video frame under each reference weight. In a specific implementation, for any reference weight within the weight range, the distortion cost parameter of the target video frame can be weighted using any reference weight, and the reference quantization parameter of the target video frame can be determined using the weighted distortion cost parameter; then the target video frame is encoded under the reference quantization parameter, and the index data generated by the encoding process here is obtained. For example, the reference encoding parameter of the target video frame can be determined based on the reference quantization parameter of the target video frame; then the index data generated by encoding the target video frame under the reference encoding parameter is obtained. Among them, the index data can be used to measure the similarity of the video frames before and after encoding, that is, the index data can be data under the image similarity evaluation index. In other words, the index data can be used to measure the encoding effect of the encoding process; for example, the index can refer to one or more of the SSIM (Structural Similarity) index, the PSNR (Peak Signal-to-Noise Ratio) index, etc.
[0131] After determining the indicator data under each reference weight, the target weight can be selected from the weight range based on the indicator data under each reference weight. It can be understood that each reference weight corresponds to an indicator data. In order to determine the target weight, the optimal indicator data can be selected from the indicator data corresponding to each reference weight in multiple reference weights, and the reference weight corresponding to the optimal indicator data can be determined as the target weight. Among them, the optimal indicator data can refer to the indicator data with the best encoding effect. For example, assuming that the indicator is SSIM, the indicator data corresponding to the highest degree of similarity between video frames before and after encoding under the SSIM indicator can be used as the optimal indicator data.
[0132] It should also be noted that, in order to verify the feasibility of adjusting the distortion cost parameter proposed in the embodiment of the present application, when the target video frame is encoded by the reference weight within the traversal weight range, the distortion of the target video frame (the distortion here may refer to the video distortion under the inter-frame coding strategy) and the distortion change of the subsequent video frame can be counted in sequence, and then, a linear function between the distortions is fitted based on the distortion of the target video frame and the distortion of the subsequent video frame. The slope of the linear function indicates the influence of the distortion on the distortion of the subsequent frame, and the slope can characterize the dependence of the distortion. Through the slope, it can be found that for simple scenes (i.e., video frames of the first category label), the distortion change of subsequent video frames caused by adjusting the quantization parameter of a single frame is relatively small, so the importance of the target video frame needs to be weakened, that is, a smaller encoding bit rate can be allocated; similarly, in complex scenes (i.e., video frames of the second category label): the distortion change of subsequent video frames caused by adjusting the quantization parameter of a single frame is relatively large, so the importance of the target video frame needs to be strengthened, that is, a larger encoding bit rate can be allocated.
[0133] By adjusting the distortion cost parameter using the target weight as proposed in the embodiment of the present application, the distortion cost parameter of the target video frame belonging to the first category label can be adjusted upward, that is, the distortion cost parameter of the target video frame after adjustment will become larger, and the distortion cost parameter is positively correlated with the quantization parameter, then the quantization parameter of the target video frame will become larger, and the quantization parameter is negatively correlated with the encoding bit rate, then the encoding bit rate of the target video frame can be reduced.
[0134] Similarly, by adjusting the distortion cost parameter using the target weight as proposed in the embodiment of the present application, the distortion cost parameter of the target video frame belonging to the second category label can be adjusted downward, that is, the distortion cost parameter of the target video frame after adjustment will become smaller, and further it can be known that the quantization parameter of the target video frame will become smaller, and the quantization parameter is negatively correlated with the encoding bit rate, and the encoding bit rate of the target video frame can be increased.
[0135] In summary, by adjusting the distortion cost parameters of the target video frame through the target weight, the quantization parameters of the target video frame can be adjusted, and then the encoding bit rate of the target video frame can be allocated using more reasonable quantization parameters. Through this allocation method, compared with the case where the distortion cost parameters of the target video frame are not adjusted, while ensuring the same video quality, the embodiment of the present application can effectively reduce bit rate consumption.
[0136] As mentioned above, in an embodiment of the present application, for video frames of simple scenes or complex scenes, the distortion cost parameter (such as the above-mentioned lambda_i) obtained by the above derivation can be corrected, and a target weight is added to the distortion cost parameter to obtain the latest distortion cost parameter. The latest distortion cost parameter is the adjusted distortion cost parameter, and the corresponding quantization parameter and encoding bit rate can be further determined by the adjusted distortion cost parameter.
[0137] S405 , adjusting the distortion cost parameters of the non-target video frames in the coded picture group according to the second adjustment method to obtain the adjusted distortion cost parameters of the non-target video frames.
[0138] The second adjustment method can be understood as that for non-target video frames in the coded picture group, the target weight is 1, and the above weight_c = 1. That is, under the second adjustment method, the adjusted distortion cost parameter of the non-target video frame is consistent with the original distortion cost parameter.
[0139] S406: Determine encoding parameters of corresponding video frames based on the adjusted distortion cost parameters of each video frame in the encoded picture group.
[0140] The encoding parameters of each video frame in the encoded picture group may be used to perform encoding processing on the corresponding video frame.
[0141] In one implementation, the corresponding video frames can be encoded based on the encoding parameters of each video frame in the encoded image group to generate encoding data for each video frame in the encoded image group, and then the encoding data of each video frame in the encoded image group can be determined as the encoding data of the encoded image group.
[0142] It is understandable that a target video may include one or more coded picture groups. In order to obtain complete coded data of the target video, the coded data of each coded picture group in the one or more coded picture groups included in the target video may be obtained, so as to generate the coded data of the target video from the coded data of all coded picture groups. For example, the coded data of each coded picture group may be combined and processed to generate the coded data of the target video. The principle for determining the coded data of each coded picture group is the same.
[0143] In a specific application scenario, after generating the coded data of the target video, the coded data of the target video can also be decoded so that the decoded target video can be played. Based on this, it can be seen that in one implementation, the coded data of the target video can be sent to a video client, so that the video client decodes the coded data of the target video to obtain the target video. Optionally, after obtaining the target video, the video client can also play the target video.
[0144] It should be noted that the target video obtained by the decoding process here may be consistent with or different from the target video before the encoding process. In one embodiment, in the scenario of lossless compression, since lossless compression can achieve the purpose of complete restoration, the target video obtained by the decoding process is consistent with the target video before the encoding process. In the scenario of lossy compression, since some information will be lost in the compression process, the original data cannot be completely restored during the decoding process, that is, the target video obtained by the decoding process cannot be completely restored to the target video before the encoding process; then, there are usually some differences between the target video obtained by the decoding process and the target video before the encoding process. These differences may be differences in video clarity or video color, such as the video clarity of the target video obtained by the decoding process is worse than the video clarity of the target video before the encoding process.
[0145] In another implementation, after determining the coding parameters of each video frame in the coded picture group, the video frame and the corresponding coding parameters may be associated and stored for use in a subsequent coding parameter prediction model. For example, the video frame and the coding parameters may be used as training samples to train a coding parameter prediction model that can automatically predict the coding parameters of the video frame.
[0146] To better understand the data encoding method proposed in the embodiment of the present application, the following combination Figure 5 For further explanation, for example, the following is described by taking the example of determining the encoding bit rate of a video frame of a P frame type (eg, P frame for short) in a coded picture group.
[0147] See also Figure 5 As shown, first, the P frames of the target video can be classified according to the complexity of the video content. The classification rule can be by calculating the size of the first video distortion value (such as intra_satd) predicted by the P frame within the frame, and according to the size of the first video distortion value, the P frame is classified into scene categories. For example, the P frame can be divided into one of simple (static), medium and complex (dynamic) scenes. The optimization target of the embodiment of the present application can be simple and complex scenes, that is, when the distortion cost parameters are adjusted as described below, only the video frames in simple and complex scenes are adjusted.
[0148] After determining the scene of the P frame, a reasonable encoding bit rate can be allocated to the P frame of each content complexity. In a specific implementation, the second video distortion value of each video frame in the encoded image group can be calculated, and then based on the second video distortion value of each video frame, the distortion cost parameter of the P frame in the encoded image group can be estimated, and then the distortion cost parameter of the P frame can be fine-tuned based on the scene classification. Here, the distortion cost parameters of the P frame in simple scenes and complex scenes can be adjusted. Finally, the quantization parameter of the P frame can be estimated based on the distortion cost parameter of the P frame, and after determining the quantization parameter of the P frame, the encoding bit rate of the P frame can be determined based on the quantization parameter of the P frame according to the bit rate allocation rule that the quantization parameter and the encoding bit rate are negatively correlated.
[0149] In the embodiment of the present application, the complexity of each video frame can be further subdivided to design a unique distortion cost parameter under the encoding bit rate dimension for each video frame, and then the corresponding encoding parameter can be determined based on the distortion cost parameter of each video frame; thus, the video content can be classified to adaptively adjust the bit rate of the video frame based on the classification result to achieve a more fine-grained bit rate allocation, thereby effectively improving the accuracy of bit rate allocation, and then improving the encoding efficiency and encoding effect. Practice has shown that under the premise of the same video quality, this solution can bring certain bit rate savings, that is, while ensuring video quality, it can effectively reduce bit rate consumption.
[0150] The method of the embodiment of the present application is described in detail above. In order to facilitate better implementation of the above scheme of the embodiment of the present application, the device of the embodiment of the present application is provided below accordingly.
[0151] Figure 6 A schematic diagram of the structure of a data encoding device provided by an exemplary embodiment of the present application is shown; the data encoding device can be used as a computer program (including program code) running in a computer device, for example, the data encoding device can be an application program in the computer device; the data encoding device can be used to execute Figure 2 and Figure 4 Some or all of the steps in the method embodiment shown. Figure 6 , the data encoding device comprises the following units:
[0152] The determining unit 601 is used to obtain a first video distortion value of each video frame in a coded image group of a target video under an intra-frame coding strategy, and determine a category label of each video frame based on the first video distortion value of each video frame; the coded image group includes a plurality of continuous video frames in the target video; the category label is used to indicate the content complexity of the video frame;
[0153] The determining unit 601 is further configured to obtain a second video distortion value of each video frame in the coded image group under the inter-frame coding strategy, and determine a distortion cost parameter of each video frame in the coding bit rate dimension based on the second video distortion value of each video frame in the coded image group;
[0154] An adjusting unit 602 is configured to adjust the distortion cost parameter of each video frame in the coded image group based on the category label of each video frame to obtain the adjusted distortion cost parameter of each video frame in the coded image group;
[0155] The determining unit 601 is further configured to determine encoding parameters of corresponding video frames based on the adjusted distortion cost parameters of each video frame in the encoded image group, wherein the encoding parameters of each video frame are used to perform encoding processing on the corresponding video frame.
[0156] In one implementation, the determining unit 601 is specifically configured to:
[0157] For any video frame in the encoded image group, if a first video distortion value of any video frame is less than a first threshold, determining the category label corresponding to the any video frame as a first category label;
[0158] If the first video distortion value of any video frame is greater than a second threshold, determining the category label corresponding to the any video frame as a second category label;
[0159] The first threshold is smaller than the second threshold.
[0160] In one implementation, the determining unit 601 is specifically configured to:
[0161] Obtaining a reference encoding bit rate of each video frame in the coded picture group, and determining a rate-distortion cost for the coded picture group based on a second video distortion value of each video frame in the coded picture group and the reference encoding bit rate;
[0162] For any video frame in the coded image group, determine a cost change of the rate-distortion cost under the any video frame based on the rate-distortion cost of the coded image group, and determine a distortion cost parameter for the coded image group in the encoding bit rate dimension based on the cost change;
[0163] Determine, based on the distortion cost parameter of the coded image group in the coding bit rate dimension and the reference distortion cost parameter of any video frame in the coding bit rate dimension, an association relationship between any video frame and the coded image group in the distortion cost parameter dimension;
[0164] Based on the association relationship and the distortion cost parameter of the coded picture group, a distortion cost parameter of any one of the video frames is determined.
[0165] In one implementation, the adjusting unit 602 is specifically configured to:
[0166] Determine a target video frame whose category label is a target category label from each video frame; the target category label is one or more of a first category label and a second category label, the target video frame corresponding to the first category label is a video frame whose first video distortion value is less than a first threshold, and the target video frame corresponding to the second category label is a video frame whose first video distortion value is greater than a second threshold;
[0167] Adjusting the distortion cost parameter of the target video frame in the coded image group according to the first adjustment method to obtain the adjusted distortion cost parameter of the target video frame;
[0168] The distortion cost parameters of the non-target video frames in the coded image group are adjusted according to the second adjustment method to obtain the adjusted distortion cost parameters of the non-target video frames.
[0169] In one implementation, the adjusting unit 602 is specifically configured to:
[0170] Acquire a preset weight range for the target video frame; the weight range includes a plurality of reference weights;
[0171] Traversing each reference weight within the weight range in turn, and determining index data generated by encoding the target video frame under each reference weight;
[0172] Based on the indicator data under each reference weight, selecting a target weight from the weight range;
[0173] The distortion cost parameter of the target video frame is weighted by using the target weight, and the weighted distortion cost parameter is used as the adjusted distortion cost parameter of the target video frame.
[0174] In one implementation, the adjusting unit 602 is specifically configured to:
[0175] For any reference weight within the weight range, weighting the distortion cost parameter of the target video frame using the any reference weight, and determining a reference quantization parameter of the target video frame using the weighted distortion cost parameter;
[0176] Determining a reference encoding parameter of the target video frame based on a reference quantization parameter of the target video frame;
[0177] Obtain index data generated by encoding the target video frame under reference encoding parameters.
[0178] In one implementation, the encoding parameters of any video frame include an encoding bit rate, and the determining unit 601 is specifically configured to:
[0179] Determining a quantization parameter of each video frame based on the adjusted distortion cost parameter of each video frame;
[0180] According to a rate allocation rule that a quantization parameter and an encoding rate are negatively correlated, the encoding rate of each video frame is determined based on the quantization parameter of each video frame.
[0181] In one implementation, the determining unit 601 is specifically configured to:
[0182] For any video frame in the coded picture group, determining a block distortion value of each coding block in the any video frame under an intra-frame coding strategy;
[0183] A mean operation is performed on the block distortion values of the coding blocks included in any one of the video frames to obtain a first video distortion value of the video frame under the intra-frame coding strategy.
[0184] In one implementation, the target video includes one or more coded picture groups; the determining unit 601 is further configured to:
[0185] Based on the encoding parameters of each video frame in the encoded picture group, encoding each video frame in the encoded picture group is performed to obtain encoded data of the encoded picture group;
[0186] Obtaining the encoding data of the target video based on the encoding data of each encoding picture group in one or more encoding picture groups included in the target video;
[0187] The encoded data of the target video is sent to a video client, so that the video client decodes the encoded data of the target video to obtain the target video.
[0188] It is understood that the division of units in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. The functional units in the embodiments of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware or in the form of software functional units.
[0189] See also Figure 7 , Figure 7This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 7 As shown, the computer device includes: at least one processor 701 and a memory 702. Optionally, the computer device may further include a network interface 703. The processor 701, the memory 702 and the network interface 703 may exchange data, the network interface 703 is controlled by the processor 701 to send and receive messages, the memory 702 is used to store a computer program, the computer program includes program instructions, and the processor 701 is used to execute the program instructions stored in the memory 702. The processor 701 is configured to call the program instructions to execute the above method.
[0190] Among them, the memory 702 may include a volatile memory (volatile memory), such as a random access memory (Random Access Memory, RAM); the memory 702 may also include a non-volatile memory (non volatile memory), such as a flash memory (flash memory), a solid state drive (SSD), etc.; the memory 702 may also include a combination of two or more of the above types of memory.
[0191] The processor 701 may be a central processing unit (CPU). In one embodiment, the processor 701 may also be a graphics processing unit (GPU). The processor 701 may also be a combination of a CPU and a GPU.
[0192] In a possible implementation, the memory 702 is used to store program instructions, and the processor 701 may call the program instructions to perform the following steps:
[0193] Obtaining a first video distortion value of each video frame in a coded image group of a target video under an intra-frame coding strategy, and determining a category label of each video frame based on the first video distortion value of each video frame; the coded image group includes a plurality of continuous video frames in the target video; the category label is used to indicate the content complexity of the video frame;
[0194] Obtaining a second video distortion value of each video frame in the coded image group under an inter-frame coding strategy, and determining a distortion cost parameter of each video frame in a coding bit rate dimension based on the second video distortion value of each video frame in the coded image group;
[0195] Adjusting the distortion cost parameter of each video frame in the coded image group based on the category label of each video frame to obtain the adjusted distortion cost parameter of each video frame in the coded image group;
[0196] The coding parameters of the corresponding video frame are determined based on the adjusted distortion cost parameters of each video frame in the coded image group, and the coding parameters of each video frame are used to perform coding processing on the corresponding video frame.
[0197] In one implementation, the processor 701 is specifically configured to:
[0198] For any video frame in the encoded image group, if a first video distortion value of any video frame is less than a first threshold, determining the category label corresponding to the any video frame as a first category label;
[0199] If the first video distortion value of any video frame is greater than a second threshold, determining the category label corresponding to the any video frame as a second category label;
[0200] The first threshold is smaller than the second threshold.
[0201] In one implementation, the processor 701 is specifically configured to:
[0202] Obtaining a reference encoding bit rate of each video frame in the coded picture group, and determining a rate-distortion cost for the coded picture group based on a second video distortion value of each video frame in the coded picture group and the reference encoding bit rate;
[0203] For any video frame in the coded image group, determine a cost change of the rate-distortion cost under the any video frame based on the rate-distortion cost of the coded image group, and determine a distortion cost parameter for the coded image group in the encoding bit rate dimension based on the cost change;
[0204] Determine, based on the distortion cost parameter of the coded image group in the coding bit rate dimension and the reference distortion cost parameter of any video frame in the coding bit rate dimension, an association relationship between any video frame and the coded image group in the distortion cost parameter dimension;
[0205] Based on the association relationship and the distortion cost parameter of the coded picture group, a distortion cost parameter of any one of the video frames is determined.
[0206] In one implementation, the processor 701 is specifically configured to:
[0207] Determine a target video frame whose category label is a target category label from each video frame; the target category label is one or more of a first category label and a second category label, the target video frame corresponding to the first category label is a video frame whose first video distortion value is less than a first threshold, and the target video frame corresponding to the second category label is a video frame whose first video distortion value is greater than a second threshold;
[0208] Adjusting the distortion cost parameter of the target video frame in the coded image group according to the first adjustment method to obtain the adjusted distortion cost parameter of the target video frame;
[0209] The distortion cost parameters of the non-target video frames in the coded image group are adjusted according to the second adjustment method to obtain the adjusted distortion cost parameters of the non-target video frames.
[0210] In one implementation, the processor 701 is specifically configured to:
[0211] Acquire a preset weight range for the target video frame; the weight range includes a plurality of reference weights;
[0212] Traversing each reference weight within the weight range in turn, and determining index data generated by encoding the target video frame under each reference weight;
[0213] Based on the indicator data under each reference weight, a target weight is selected from the weight range; the distortion cost parameter of the target video frame is weighted using the target weight, and the weighted distortion cost parameter is used as the adjusted distortion cost parameter of the target video frame.
[0214] In one implementation, the processor 701 is specifically configured to:
[0215] For any reference weight within the weight range, weighting the distortion cost parameter of the target video frame using the any reference weight, and determining a reference quantization parameter of the target video frame using the weighted distortion cost parameter;
[0216] Determining a reference encoding parameter of the target video frame based on a reference quantization parameter of the target video frame;
[0217] Obtain index data generated by encoding the target video frame under reference encoding parameters.
[0218] In one implementation, the encoding parameters of any video frame include an encoding bit rate, and the determining unit 601 is specifically configured to:
[0219] Determining a quantization parameter of each video frame based on the adjusted distortion cost parameter of each video frame;
[0220] According to a rate allocation rule that a quantization parameter and an encoding rate are negatively correlated, the encoding rate of each video frame is determined based on the quantization parameter of each video frame.
[0221] In one implementation, the processor 701 is specifically configured to:
[0222] For any video frame in the coded picture group, determining a block distortion value of each coding block in the any video frame under an intra-frame coding strategy;
[0223] A mean operation is performed on the block distortion values of the coding blocks included in any one of the video frames to obtain a first video distortion value of the video frame under the intra-frame coding strategy.
[0224] In one implementation, the target video includes one or more coded picture groups; the processor 701 is further configured to:
[0225] Based on the encoding parameters of each video frame in the encoded picture group, encoding each video frame in the encoded picture group is performed to obtain encoded data of the encoded picture group;
[0226] Obtaining the encoding data of the target video based on the encoding data of each encoding picture group in one or more encoding picture groups included in the target video;
[0227] The encoded data of the target video is sent to a video client, so that the video client decodes the encoded data of the target video to obtain the target video.
[0228] In a specific implementation, the above-described device, processor, memory, etc. can execute the implementation described in the above-mentioned method embodiment, and can also execute the implementation described in the embodiment of the present application, which will not be repeated here.
[0229] A computer (readable) storage medium is also provided in an embodiment of the present application, and the computer storage medium stores a computer program, and the computer program includes program instructions. When the program instructions are executed by the processor, the processor can execute some or all of the steps performed in the above method embodiment. Optionally, the computer storage medium can be volatile or non-volatile. The computer-readable storage medium can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function, etc.; the data storage area can store data created according to the use of the blockchain node, etc.
[0230] The embodiment of the present application also provides a computer program product, which includes program instructions, and when the program instructions are executed by a processor, some or all of the steps in the above-mentioned data encoding method can be implemented. Optionally, the program instructions can be stored in a computer-readable storage medium, and a computer device such as a processor of a computer device reads the program instructions from the computer-readable storage medium, and the processor executes the program instructions, so that the computer device performs the above-mentioned data encoding method.
[0231] The present application also involves blockchain-related technologies. Among them, blockchain is a new application model of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. The blockchain may include a blockchain underlying platform, a platform product service layer, and an application service layer. The blockchain includes a series of blocks that are connected to each other in the order of their generation. Once a new block is added to the blockchain, it will not be removed. The block records the record data submitted by the nodes in the blockchain system. In this application, the category recognition results of the determined text to be identified can be added to the blockchain for storage to ensure the immutability of the data.
[0232] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0233] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more program instructions. When loading and executing the computer program instructions on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The program instructions can be stored in a computer-readable storage medium or transmitted by a computer-readable storage medium.
[0234] Program instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. Computer-readable storage media can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. Available media can be magnetic media (e.g., floppy disks, hard disks, tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)), etc.
[0235] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data encoding method, characterized in that: The method comprises: Obtaining a first video distortion value of each video frame in a coded image group of a target video under an intra-frame coding strategy, and determining a category label of each video frame based on the first video distortion value of each video frame; the coded image group includes a plurality of continuous video frames in the target video; the category label is used to indicate the content complexity of the video frame; Obtaining a second video distortion value of each video frame in the coded image group under an inter-frame coding strategy, and determining a distortion cost parameter of each video frame in a coding bit rate dimension based on the second video distortion value of each video frame in the coded image group; Adjusting the distortion cost parameter of each video frame in the coded image group based on the category label of each video frame to obtain the adjusted distortion cost parameter of each video frame in the coded image group; The coding parameters of the corresponding video frame are determined based on the adjusted distortion cost parameters of each video frame in the coded image group, and the coding parameters of each video frame are used to perform coding processing on the corresponding video frame.
2. The method according to claim 1, characterized in that The determining the category label of each video frame based on the first video distortion value of each video frame respectively includes: For any video frame in the encoded image group, if a first video distortion value of any video frame is less than a first threshold, determining the category label corresponding to the any video frame as a first category label; If the first video distortion value of any video frame is greater than a second threshold, determining the category label corresponding to any video frame as a second category label; The first threshold is smaller than the second threshold.
3. The method according to claim 1, characterized in that The determining, based on the second video distortion value of each video frame in the coded picture group, a distortion cost parameter of each video frame comprises: Obtaining a reference encoding bit rate of each video frame in the coded picture group, and determining a rate-distortion cost for the coded picture group based on a second video distortion value of each video frame in the coded picture group and the reference encoding bit rate; For any video frame in the coded image group, determine a cost change of the rate-distortion cost under the any video frame based on the rate-distortion cost of the coded image group, and determine a distortion cost parameter for the coded image group in the encoding bit rate dimension based on the cost change; Determine, based on the distortion cost parameter of the coded image group in the coding bit rate dimension and the reference distortion cost parameter of any video frame in the coding bit rate dimension, an association relationship between any video frame and the coded image group in the distortion cost parameter dimension; Based on the association relationship and the distortion cost parameter of the coded picture group, a distortion cost parameter of any one of the video frames is determined.
4. The method according to claim 1, characterized in that: The step of adjusting the distortion cost parameter of each video frame in the coded image group based on the category label of each video frame to obtain the adjusted distortion cost parameter of each video frame in the coded image group includes: Determine a target video frame whose category label is a target category label from each video frame; the target category label is one or more of a first category label and a second category label, the target video frame corresponding to the first category label is a video frame whose first video distortion value is less than a first threshold, and the target video frame corresponding to the second category label is a video frame whose first video distortion value is greater than a second threshold; Adjusting the distortion cost parameter of the target video frame in the coded image group according to the first adjustment method to obtain the adjusted distortion cost parameter of the target video frame; The distortion cost parameters of the non-target video frames in the coded image group are adjusted according to the second adjustment method to obtain the adjusted distortion cost parameters of the non-target video frames.
5. The method according to claim 4, characterized in that The step of adjusting the distortion cost parameter of the target video frame in the coded image group according to the first adjustment mode to obtain the adjusted distortion cost parameter of the target video frame includes: Acquire a preset weight range for the target video frame; the weight range includes a plurality of reference weights; Traversing each reference weight within the weight range in turn, and determining index data generated by encoding the target video frame under each reference weight; Based on the indicator data under each reference weight, selecting a target weight from the weight range; The distortion cost parameter of the target video frame is weighted by using the target weight, and the weighted distortion cost parameter is used as the adjusted distortion cost parameter of the target video frame.
6. The method according to claim 5, characterized in that The determining of the index data generated by encoding the target video frame under each reference weight includes: For any reference weight within the weight range, weighting the distortion cost parameter of the target video frame using the any reference weight, and determining a reference quantization parameter of the target video frame using the weighted distortion cost parameter; Determining a reference encoding parameter of the target video frame based on a reference quantization parameter of the target video frame; Obtain index data generated by encoding the target video frame under reference encoding parameters.
7. The method according to claim 1, characterized in that The encoding parameters of any video frame include an encoding bit rate, and the determining the encoding parameters of the corresponding video frame based on the adjusted distortion cost parameters of each video frame in the encoded picture group includes: Determining a quantization parameter of each video frame based on the adjusted distortion cost parameter of each video frame; According to a rate allocation rule that a quantization parameter and an encoding rate are negatively correlated, the encoding rate of each video frame is determined based on the quantization parameter of each video frame.
8. The method according to claim 1, characterized in that: The step of obtaining a first video distortion value of each video frame in a coded image group of a target video under an intra-frame coding strategy includes: For any video frame in the coded picture group, determining a block distortion value of each coding block in the any video frame under an intra-frame coding strategy; A mean operation is performed on the block distortion values of the coding blocks included in any one of the video frames to obtain a first video distortion value of the video frame under the intra-frame coding strategy.
9. The method according to any one of claims 1 to 8, characterized in that: The target video includes one or more coded picture groups; the method further includes: Based on the encoding parameters of each video frame in the encoded picture group, encoding each video frame in the encoded picture group is performed to obtain encoded data of the encoded picture group; Obtaining the encoding data of the target video based on the encoding data of each encoding picture group in one or more encoding picture groups included in the target video; The encoded data of the target video is sent to a video client, so that the video client decodes the encoded data of the target video to obtain the target video.
10. A data encoding device, characterized in that: include: A determination unit, configured to obtain a first video distortion value of each video frame in a coded image group of a target video under an intra-frame coding strategy, and determine a category label of each video frame based on the first video distortion value of each video frame; the coded image group includes a plurality of continuous video frames in the target video; the category label is used to indicate the content complexity of the video frame; The determining unit is further configured to obtain a second video distortion value of each video frame in the coded image group under the inter-frame coding strategy, and determine a distortion cost parameter of each video frame in the coding bit rate dimension based on the second video distortion value of each video frame in the coded image group; an adjusting unit, configured to adjust the distortion cost parameter of each video frame in the coded image group based on the category label of each video frame, so as to obtain the adjusted distortion cost parameter of each video frame in the coded image group; The determining unit is further used to determine the encoding parameters of the corresponding video frame based on the adjusted distortion cost parameters of each video frame in the encoded image group, and the encoding parameters of each video frame are used to perform encoding processing on the corresponding video frame.
11. A computer device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store a computer program, the computer program comprises program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program instructions, and when the program instructions are executed, they are used to implement the method according to any one of claims 1 to 9.
13. A computer program product, comprising program instructions, wherein when the program instructions are executed by a processor, the program instructions are used to implement the method according to any one of claims 1 to 9.
