Video stream encoding and decoding acceleration method and system based on microcomputer host
Through the consistent hashing algorithm and hash ring allocation under preset allocation scale, combined with the adaptive adjustment of DPCM sampling rate, the problem of video stream encoding duration caused by unreasonable CPU core encoding arrangement in the prior art is solved, and efficient and coherent video stream encoding is achieved.
Patent Information
- Application Number
- CN202510206652.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2045-02-25
AI Technical Summary
In the prior art, the CPU core encoding arrangement is unreasonable, resulting in a long video stream encoding time and cannot meet the needs of efficient encoding.
The streaming packets are mapped to the hash ring to be allocated through a consistent hash algorithm, and allocated according to the proximity of the distribution between adjacent streaming packets. The initial allocation hash ring under different preset allocation scales are selected, and the final allocation hash ring is determined based on the similarity and quantity distribution of the streaming packets allocated by the CPU core nodes. At the same time, the DPCM sampling rate is adjusted according to the prediction error of the streaming data packet.
By optimizing the video stream packet allocation and DPCM sampling rate adjustment of the CPU core, the efficiency of video stream encoding is significantly improved, the encoding time is reduced, and the video coherence after decoding is ensured.
Smart Images

Figure CN119697369B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of video stream coding, and in particular to a video stream coding and decoding acceleration method and system based on a microcomputer host. Background Art
[0002] The main purpose of video stream encoding and decoding is to store and transmit video content more efficiently. The encoding process converts the original video file into a smaller file through compression technology, thereby reducing the storage space and transmission bandwidth requirements. Decoding is the reverse process of encoding, which restores the compressed video data to the original video signal so that it can be played on various devices and players.
[0003] In the encoding stage, the original video file is processed by a compression algorithm to remove redundant information and compress the video data into a smaller file by using similarities between images. Video stream encoding involves multiple steps and technologies, mainly including intra-frame coding, inter-frame coding, transform coding, quantization coding, and entropy coding. When the commonly used DPCM method is used to encode the video stream through inter-frame prediction, the streaming data packets corresponding to a period of video stream are often randomly and evenly arranged for CPU core encoding. When the arrangement is unreasonable, the required encoding time will be longer and cannot meet the requirements of efficient encoding. Summary of the invention
[0004] In order to solve the technical problem that the encoding time required is long when the CPU core encoding arrangement and allocation are unreasonable in the prior art, the purpose of the present invention is to provide a video stream encoding and decoding acceleration method and system based on a microcomputer host, and the technical solution adopted is as follows:
[0005] The present invention provides a video stream encoding and decoding acceleration method based on a microcomputer host, the method comprising:
[0006] Obtain a video stream to be encoded; split the video stream according to the inter-frame differences of video frames in the video stream to obtain streaming data packets;
[0007] A consistent hashing algorithm is used to map streaming data packets to a hash ring to be allocated, where the nodes in the hash ring to be allocated are CPU cores; an allocation rationality index of each adjacent two streaming data packets is obtained according to the distribution proximity of the distance between each two adjacent streaming data packets on the hash ring to be allocated; at least two preset allocation scales are selected, and under each preset allocation scale, the streaming data packets are allocated to the CPU core nodes based on the size of the allocation rationality index of the adjacent streaming data packets in the hash ring to be allocated, so as to obtain the initial allocation hash ring under different preset allocation scales;
[0008] In each initial allocation hash ring, according to the similarity between the streaming data packets allocated to each CPU core node and the quantity distribution of the streaming data packets allocated between the CPU core nodes, the allocation ideal index of each initial allocation hash ring is obtained; based on the allocation ideal index, a final allocation hash ring is determined from all the initial allocation hash rings;
[0009] Under the final distribution hash ring, DPCM is used to obtain the prediction error index of each streaming data packet; according to the distribution of the prediction error index of each streaming data packet in the local range of the CPU core node where it is located, and the DPCM sampling rate of the previous streaming data packet, the DPCM sampling rate of each streaming data packet is obtained;
[0010] Video stream encoding is performed by finally assigning a hash ring and a DPCM sampling rate to each streaming packet.
[0011] Furthermore, the method for obtaining the allocation rationality index includes:
[0012] Every two adjacent streaming data packets on the hash ring to be allocated are regarded as a data packet group;
[0013] Calculate the hash value difference between two adjacent streaming data packets in each data packet group to obtain the distribution approximation index of each data packet group;
[0014] The minimum distribution approximation index is taken as the closest value;
[0015] The difference between the distribution mean index and the nearest maximum value of each data packet group is calculated and negative correlation mapping is performed to obtain the distribution rationality index of each data packet group.
[0016] Furthermore, the method for obtaining the initially allocated hash ring includes:
[0017] For any preset allocation scale, when there is an allocation rationality index greater than the preset allocation scale, two streaming data packets corresponding to the allocation rationality index are regarded as one same processing class, otherwise the two streaming data packets are regarded as different same processing classes;
[0018] When the number of the same processing class is less than or equal to the CPU core node, the same processing class is assigned to the same CPU core node to obtain an initial allocation hash ring under the preset allocation scale.
[0019] Furthermore, the method for obtaining the ideal allocation index includes:
[0020] For any initial allocated hash ring, each CPU core node in the initial allocated hash ring is used as an analysis node in turn;
[0021] The sum of the distribution rationality indexes of each two adjacent streaming data packets in the analysis node is calculated as the distribution similarity of the analysis node; the average of the distribution similarities of all CPU core nodes in the initial allocation hash ring is used as the similarity index of the initial allocation hash ring;
[0022] Obtain the number of streaming data packets allocated to each CPU core node in the initial allocation hash ring as the allocation number of each CPU core node; obtain the number distribution index of the initial allocation hash ring according to the size distribution and disorder of the allocation numbers in the initial allocation hash ring;
[0023] The product of the similarity index and the quantity distribution index of the initial allocation hash ring is used as the allocation ideal index of the initial allocation hash ring.
[0024] Furthermore, the method for obtaining the quantity distribution index includes:
[0025] The maximum allocated quantity is taken as the maximum value of the numerical distribution of the initial allocated hash ring;
[0026] Calculate the difference between the number of allocations of each CPU core node and the average of all allocations as the number deviation of each CPU core node; take the sum of the number deviations of all CPU core nodes in the initial allocation hash ring as the numerical disorder of the initial allocation hash ring;
[0027] A negative correlation mapping is performed on the product of the maximum value of the value distribution of the initial allocated hash ring and the value disorder degree to obtain the quantity distribution index of the initial allocated hash ring.
[0028] Further, the determining of the final allocation hash ring from all the initial allocation hash rings based on the allocation ideal index includes:
[0029] The initial allocation hash ring corresponding to the maximum value of the ideal allocation index is used as the final allocation hash ring.
[0030] Furthermore, the method for obtaining the prediction error index includes:
[0031] For any video frame, when there is a temporally previous video frame for the video frame, the pixel value difference between the video frame and the temporally previous video frame at each pixel point is accumulated to obtain the error value of the video frame;
[0032] The mean of all error values in each streaming data packet is taken as the prediction error indicator of each streaming data packet.
[0033] Furthermore, the method for obtaining the DPCM sampling rate of each streaming data packet includes:
[0034] Under the final allocation hash ring, for any streaming data packet, a preset number of streaming data packets in the timing sequence in the allocated CPU core node where the streaming data packet is located are used as local data packets of the streaming data packet;
[0035] The sum of all prediction error indicators of the streaming data packet and all local data packets is used as the local error sum value of the streaming data packet; the ratio between the local error sum value of the streaming data packet and the maximum local error sum value is subjected to normalized range mapping processing to obtain an adjustment coefficient of the streaming data packet;
[0036] Obtain the DPCM sampling rate of the previous streaming data packet in the timing sequence in the assigned CPU core node where the streaming data packet is located; use the product of the DPCM sampling rate of the previous streaming data packet and the adjustment coefficient as the adjustment value of the streaming data packet; use the sum of the DPCM sampling rate of the previous streaming data packet and the adjustment value as the DPCM sampling rate of the streaming data packet.
[0037] Furthermore, the method for acquiring the streaming data packet includes:
[0038] The video stream to be encoded is divided into two frames whose difference is greater than a preset difference threshold by using an inter-frame difference method to obtain different video frame segments of the video stream to be encoded;
[0039] A half length of a minimum length video frame segment is used as a split packet size; within each video frame segment, a start video frame is split using the split packet size as a fixed packet size to obtain a streaming data packet.
[0040] The present invention also provides a video stream encoding and decoding acceleration system based on a microcomputer host, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above methods when executing the computer program.
[0041] The present invention has the following beneficial effects:
[0042] The present invention performs hash analysis on the split streaming data packets, and performs node allocation on the hash ring based on the distribution similarity between adjacent streaming data packets at different scales, so as to obtain the initial allocation hash ring at different scales. The allocation through the hash ring can stabilize the load while managing the allocation more flexibly, thereby improving the processing performance. Further, according to the similarity and quantity distribution of the streaming data packets allocated to the CPU core nodes in the initial allocation hash ring at different scales, the overall time of parallel processing is considered, and the final allocation hash ring is screened out as the optimal allocation situation, so that the CPU core parallel processing is more efficient. At the same time, considering that the DPCM sampling rate can reduce the encoding operation time, but excessive compression can also cause the decoded video to be incoherent, the DPCM sampling rate is adjusted according to the prediction error of each frame in the streaming data packet under the optimal allocation situation, and finally the video stream encoding is performed by the final allocation hash ring and the more suitable DPCM sampling rate of different streaming data packets. The present invention selects the optimal allocation situation according to the CPU parallel situation under different allocation situations of the data packet, and adaptively adjusts the DPCM sampling rate of the data packet, accelerates the encoding speed under the condition of better overall processing time, and makes the video stream encoding processing more efficient. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 A flow chart of a video stream encoding and decoding acceleration method based on a microcomputer host provided by an embodiment of the present invention;
[0045] Figure 2 A schematic diagram of a hash ring to be allocated provided by an embodiment of the present invention;
[0046] Figure 3 A schematic diagram of an initial allocation hash ring provided for an embodiment of the present invention. DETAILED DESCRIPTION
[0047] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the video stream encoding and decoding acceleration method and system based on a microcomputer host proposed by the present invention, its specific implementation method, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0048] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0049] The following is a detailed description of a video stream encoding and decoding acceleration method and system based on a microcomputer host provided by the present invention in conjunction with the accompanying drawings.
[0050] See also Figure 1 , which shows a flow chart of a video stream encoding and decoding acceleration method based on a microcomputer host provided by an embodiment of the present invention, the method comprising the following steps:
[0051] S1: Obtain a video stream to be encoded; split the video stream according to the inter-frame differences of video frames in the video stream to obtain streaming data packets.
[0052] First, the video stream to be encoded is split into packets for analysis. However, direct splitting of fixed packet sizes usually results in poor correlation between video frames contained in fixed packets, which are likely to contain multiple contents with large deviations, which has a significant impact on the subsequent analysis of allocation based on the similarity of streaming packets. Therefore, when splitting, it is considered that streaming packets only contain video frames with similar contents.
[0053] Preferably, in an embodiment of the present invention, splitting the video stream according to the inter-frame difference of video frames in the video stream to obtain streaming data packets includes:
[0054] Inter-frame Difference Method is a common video frame compression and frame selection technology used to analyze key frames in video streams. The basic idea is to calculate the differences between consecutive video frames and select those frames with large differences as key frames. The video stream can be divided according to the large differences between frames, so that it can be split into segments with high similarity later.
[0055] The frame difference method is used to divide the two frames greater than the preset difference threshold into segments of the video stream to be encoded, and different video frame segments of the video stream to be encoded are obtained. In an embodiment of the present invention, the video stream to be encoded is traversed to obtain the difference result between each two frames, and normalization is performed. The two frames with normalized values greater than 0.3 are divided to obtain video frame segments. At this time, the preset difference threshold is 0.4. It should be noted that the data size can be adjusted by the implementer according to the specific implementation scenario. The normalization process is a technical means well known to those skilled in the art. The normalization option can be linear normalization or standard normalization, etc. The specific normalization method is not limited here.
[0056] Further, half the length of the minimum length video frame segment is used as the split packet size, so that each video frame segment can obtain at least two similar streaming data packets for analysis. In each video frame segment, the starting video frame is split with the split packet size as the fixed packet size to obtain a streaming data packet. When the remaining video frames in the video frame segment cannot meet the split packet size, the steps are looped with the starting frames of the remaining video frames and marked to obtain multiple streaming data packets of the same size. For the cyclic supplementary data packet, the supplement is deleted by marking during decoding.
[0057] At this point, the initial split package analysis is completed.
[0058] S2: Use consistent hashing algorithm to map streaming data packets to the hash ring to be allocated, where the nodes in the hash ring to be allocated are CPU cores; obtain the allocation rationality index of each two adjacent streaming data packets based on the distribution proximity of the distance between each two adjacent streaming data packets on the hash ring to be allocated; select at least two preset allocation scales, and under each preset allocation scale, allocate the streaming data packets to the CPU core nodes based on the size of the allocation rationality index of adjacent streaming data packets in the hash ring to be allocated, so as to obtain the initial allocation hash ring under different preset allocation scales.
[0059] When DPCM is usually used for inter-frame prediction to encode video streams, the streaming data packets corresponding to a period of video streams are often randomly and evenly arranged for CPU core encoding. There may be large differences between the streaming data packets arranged in the same CPU core. When DPCM is used to compress the streaming data packets based on the inter-frame prediction of the streaming data packets in the same CPU core, the accuracy of the inter-frame prediction is low, the inter-frame error is large, and the encoding time is long. Therefore, in order to reduce the encoding time of the video stream, the streaming data packets with small differences should be put into the same CPU core for encoding processing.
[0060] Consistent Hashing is a distributed hashing algorithm used to solve the data migration problem caused by dynamic changes in nodes in a distributed system. In the consistent hashing algorithm, the range of hash values is a ring space. Each CPU core node occupies a position on the ring. The hash value of the streaming data packet is also mapped to the ring. Then, the first node is found in a clockwise direction and the streaming data packet is stored on the CPU core node. When the CPU core node changes dynamically, only the affected streaming data packets need to be rehashed and mapped to the new CPU core node without redistributing the entire data set. This method can effectively reduce the overhead of data migration and improve the scalability and stability of the system.
[0061] After the initial mapping is completed, the hash ring to be allocated is obtained. In order to ensure that the streaming data packets allocated in the same CPU core node have a high degree of similarity, the distribution of different streaming data packets on the hash ring is used as a reference. When the distance between two streaming data packets on the hash ring is closer, it proves that the hash values of the two streaming data packets are closer, and the video stream content contained in them is also closer. When they are put into the same CPU core for processing, it is more conducive to DPCM inter-frame prediction and can effectively reduce the encoding time. Please refer to Figure 2 , which shows a schematic diagram of a hash ring to be allocated provided by an embodiment of the present invention.
[0062] Preferably, in an embodiment of the present invention, the rationality of the consistent allocation between adjacent data packets is first analyzed, and the method for obtaining the allocation rationality index includes:
[0063] A hash algorithm, also called a hash algorithm, is a method of mapping a binary value of any length to a fixed-length binary value. This fixed-length binary value is the hash value. For different input data, the hash value is almost unique. Even if the input data changes slightly, the generated hash value will be completely different. Therefore, different streaming data packets on the hash ring have their own specific hash values for analysis, and the distance on the hash ring is reflected by the difference in hash values.
[0064] Every two adjacent streaming data packets on the to-be-allocated hash ring are regarded as a data packet group. In the embodiment of the present invention, two adjacent streaming data packets on the circular ring of the hash ring are regarded as a data packet group to analyze the distance distribution.
[0065] Calculate the hash value difference between two adjacent streaming data packets in each data packet group, and obtain the distribution approximation index of each data packet group. The closer the hash value is, the closer the distance distribution is on the hash ring. Therefore, the minimum distribution approximation index is used as the closest value, and the closest value is the closest distribution size. When the distribution of the data packet group is closer to the closest value, it means that the approximation is higher and the reasonableness of the same treatment is greater.
[0066] Therefore, the difference between the distribution mean index and the nearest maximum value of each data packet group is further calculated and negative correlation mapping is performed to obtain the allocation rationality index of each data packet group. The larger the allocation rationality index, the greater the similarity between two adjacent streaming data packets, and the higher the rationality of being placed in the same core for processing. It should be noted that negative correlation mapping is a technical means well known to those skilled in the art, such as inverse proportion or negative exponential power form, and is not limited here. As an example, the expression of the allocation rationality index is:
[0067] ; In the formula, It is expressed as the allocation rationality index of the i-th streaming data packet and the i+1-th streaming data packet, Represented as the hash value of the i-th streaming data packet, Represented as the hash value of the i+1th streaming data packet, It is expressed as the distribution approximation index of the i-th streaming data packet and the i+1-th streaming data packet, Represented as close to the maximum value. Expressed as an exponential function with a natural constant as base.
[0068] The greater the allocation rationality, the higher the possibility of consistent processing. The allocation can be further performed through the threshold. By setting the threshold, when the threshold is exceeded, two adjacent streaming data packets are divided into the same nearest CPU core for processing, otherwise they are divided into different CPU cores for processing. Finally, the multiple streaming data packets obtained by splitting the video stream are allocated to multiple CPU cores for processing. The relationship between the streaming data packets and the CPU core nodes is: the corresponding relationship between the streaming data packets and the CPU core nodes is one-to-one, and the relationship between the CPU core nodes and the streaming data packets is one-to-many.
[0069] Due to different threshold selections, the allocation situation will also be different. In order to find the optimal allocation situation, different threshold allocations are selected. The allocation under each threshold can be further analyzed. First, at least two preset allocation scales are selected. In the embodiment of the present invention, the range of the preset allocation scale is set to [0.1, 0.9], and different preset allocation scales are obtained by increasing the step size of 0.1.
[0070] Further, under each preset allocation scale, the streaming data packets are allocated to the CPU core nodes based on the allocation rationality index size of the adjacent streaming data packets in the hash ring to be allocated, and the initial allocation hash ring under each preset allocation scale is obtained, including:
[0071] For any preset allocation scale, when there is an allocation rationality index greater than the preset allocation scale, the two streaming data packets corresponding to the allocation rationality index will be treated as one of the same processing classes, otherwise the two streaming data packets will be treated as different same processing classes, and the streaming data packets that can be processed together will be screened out first for subsequent unified allocation.
[0072] When the scale is larger, the partitioning conditions are more stringent, and more processing classes are divided. Considering the number of CPU core nodes that can be allocated, when the number of processing classes is less than or equal to the CPU core nodes, the same processing classes are allocated to the same CPU core nodes to obtain the initial allocation hash ring under the preset allocation scale. If the number of processing classes is greater than the CPU core nodes, it means that the allocation at this time cannot meet the CPU core operation, the scale is too large, the initial allocation hash ring cannot be obtained, and there is no subsequent allocation.
[0073] See also Figure 3 , which shows a schematic diagram of an initial allocation hash ring provided by an embodiment of the present invention. So far, different allocations under multiple scales are completed.
[0074] S3: In each initial allocation hash ring, according to the similarity between the streaming data packets allocated to each CPU core node and the number distribution of the streaming data packets allocated between the CPU core nodes, the ideal allocation index of each initial allocation hash ring is obtained; based on the ideal allocation index, the final allocation hash ring is determined from all the initial allocation hash rings.
[0075] The CPU cores often process data packets in parallel. To ensure that the overall processing time for all streaming data packets corresponding to the current video stream is short, while ensuring that the contents of the streaming data packets processed by the same CPU core are similar, it should also be ensured that the number of streaming data packets processed by each CPU core is relatively uniform and that the number of streaming data packets contained in each CPU core is relatively small.
[0076] Therefore, the ideal allocation index is obtained by the similarity between the streaming data packets allocated to the nodes in the initial allocation hash ring and the distribution of the number of allocated packets between the CPU core nodes. Preferably, in an embodiment of the present invention, the method for obtaining the ideal allocation index includes:
[0077] For any initial allocation hash ring, each CPU core node in the initial allocation hash ring is taken as an analysis node in turn, and each CPU core node is analyzed.
[0078] The sum of the distribution rationality index of each two adjacent streaming data packets in the analysis node is calculated as the distribution similarity of the analysis node. Combined with the rationality of all streaming data packets in the analysis node, the larger the overall distribution rationality index is, the greater the similarity of the streaming data packets is. Therefore, the mean of the distribution similarity of all CPU core nodes in the initial allocation hash ring is used as the similarity index of the initial allocation hash ring. The larger the similarity index is, the more reasonable the streaming data packets allocated in the analysis node are.
[0079] Further considering the parallel processing situation, the number of streaming data packets allocated to each CPU core node in the initial allocation hash ring is obtained as the allocation number of each CPU core node, reflecting the number of streaming data packets that the node needs to process. According to the size distribution and disorder of the allocation number in the initial allocation hash ring, the number distribution index of the initial allocation hash ring is obtained. Through the analysis of the distribution of the number, when the number of nodes with the largest number of allocations is larger and the number distribution between different nodes is more uneven, it reflects that the parallel processing situation is more complicated and the overall processing time may be longer.
[0080] In an embodiment of the present invention, a method for obtaining a quantity distribution index includes:
[0081] First, the maximum allocation quantity is used as the maximum value of the numerical distribution of the initial allocation hash ring. When the maximum value of the quantity distribution is larger, the time waiting for the maximum number of streaming data packets to be processed may be longer, and the preferred situation of this allocation is lower.
[0082] The difference between the number of allocations of each CPU core node and the mean of all allocations is further calculated as the number deviation of each CPU core node, reflecting the degree of deviation between each node and the overall node in the number of processed data packets. The sum of the number deviations of all CPU core nodes in the initial allocation hash ring is further used as the numerical chaos of the initial allocation hash ring. All deviations are combined. The greater the overall deviation, that is, the greater the numerical chaos, the less conducive it is to reducing the overall encoding time, and the lower the preferred situation of this allocation.
[0083] Finally, the product of the numerical distribution maximum and numerical chaos of the initial allocated hash ring is negatively correlated to obtain the quantity distribution index of the initial allocated hash ring. The smaller the numerical distribution maximum and numerical chaos are, the better the response distribution is, so the quantity distribution index is obtained by negative correlation processing.
[0084] Finally, the product of the similarity index and the quantity distribution index of the initial allocation hash ring is used as the ideal allocation index of the initial allocation hash ring. When the similarity index and the quantity distribution index are both larger, it reflects that the allocation is better, and the overall CPU core processing time under this allocation is more reasonable and efficient.
[0085] Therefore, when determining the final allocation hash ring based on the allocation ideal index, in the embodiment of the present invention, the initial allocation hash ring corresponding to the maximum value of the allocation ideal index is used as the final allocation hash ring.
[0086] At this point, the optimal CPU core processing allocation result is obtained.
[0087] S4: Under the final distribution hash ring, DPCM is used to obtain the prediction error index of each streaming data packet; according to the distribution of the prediction error index of each streaming data packet in the local range of the CPU core node, and the DPCM sampling rate of the previous streaming data packet, the DPCM sampling rate of each streaming data packet is obtained.
[0088] By reducing the sampling rate of DPCM, the operation time for encoding the streaming data packet can be reduced, but the video stream in the streaming data packet may be over-compressed, resulting in discontinuity of the decoded video. Therefore, the prediction error of each frame in the streaming data packet that is preferentially encoded in each CPU core under the preferred allocation is used as a reference. When the prediction error of each frame in the preferentially encoded streaming data packet is larger, it proves that the current sampling rate may be smaller for this streaming data packet, the time span between the obtained sampled frames is larger, and the image difference of the video frame is larger, and the continuity of the video cannot be well expressed.
[0089] Therefore, we first analyze the prediction error of each streaming data packet. The DPCM prediction error is obtained by calculating the difference between the current sample value and the predicted value. In DPCM, the prediction value is calculated by the previous one or several previous sample values. For example, if the previous sample value of a sample is used as the prediction value, then the prediction value is the previous sample value. The difference between the predicted current sample value and the predicted value is the prediction error. For video streams, the sample value is the pixel value of each pixel in the video frame.
[0090] In an embodiment of the present invention, a method for obtaining a prediction error indicator includes:
[0091] For any video frame, when there is a previous video frame in time sequence, the pixel value difference between the video frame and the previous video frame in time sequence at each pixel point is accumulated to obtain the error value of the video frame. The previous video frame in time sequence is also the predicted value. For each video frame except the first video frame, the pixel value difference of each pixel point position between the video frames reflects the inter-frame deviation of a single pixel. Combined with all pixel points, the overall error degree between each video frame and the previous video frame is obtained.
[0092] The mean of all error values in each streaming data packet is further used as the prediction error indicator of each streaming data packet. By comprehensively considering all video frame errors in the streaming data packet, it reflects the deviation of the overall streaming data packet from the historical encoding during encoding.
[0093] Since the streaming data packets allocated to the same CPU core are relatively similar, in order to ensure that the encoding operation of the streaming data packets to be encoded later can ensure good video continuity, the DPCM sampling rate should be increased in time. When the prediction errors corresponding to the streaming data packets processed continuously in history are all small, the DPCM sampling rate can be appropriately reduced to speed up the encoding speed. Therefore, according to the distribution of the prediction error index of each streaming data packet in the local range of the CPU core node, the DPCM sampling rate of the previous streaming data packet is adjusted to obtain the DPCM sampling rate of each streaming data packet.
[0094] Preferably, in an embodiment of the present invention, the method for obtaining the DPCM sampling rate of each streaming data packet includes:
[0095] Under the final allocated hash ring, for any streaming data packet, a preset number of streaming data packets before the streaming data packet in timing in the allocated CPU core node are used as local data packets of the streaming data packet. In an embodiment of the present invention, the preset number is set to 4. When the preset number is not met, all the previous streaming data packets are used as local data packets. The specific value can be adjusted by the implementer.
[0096] The sum of all prediction error indices of the streaming data packet and all local data packets is used as the local error sum of the streaming data packet to reflect the overall error situation under continuous processing. The ratio between the local error sum of the streaming data packet and the maximum local error sum is normalized and mapped to obtain the adjustment coefficient of the streaming data packet. When the error degree under continuous processing is smaller, that is, the adjustment coefficient is smaller, it means that the sampling rate can be reduced to increase the encoding rate. Otherwise, it means that the error is high and the sampling rate needs to be increased to ensure video continuity. In an embodiment of the present invention, the normalized range of the ratio is mapped to the interval [-1,1] through the premnmx function. When it is smaller, the adjustment can be reduced, and when it is larger, the adjustment can be increased.
[0097] The DPCM sampling rate of the previous streaming data packet in the allocated CPU core node where the streaming data packet is located is obtained. When the streaming data packet is the starting streaming data packet, the sampling rate is the system initial setting sampling rate. The previous streaming data packet cannot be obtained and no adjustment is required. Therefore, the product of the DPCM sampling rate of the previous streaming data packet and the adjustment coefficient is used as the adjustment value of the streaming data packet, and the sum of the DPCM sampling rate of the previous streaming data packet and the adjustment value is used as the DPCM sampling rate of the streaming data packet.
[0098] At this point, the adaptive adjustment of the coding sampling is completed.
[0099] S5: Encode the video stream by finally allocating the hash ring and the DPCM sampling rate of each streaming data packet.
[0100] In the embodiment of the present invention, the main process of video stream encoding is: splitting the video stream into streaming data packets, allocating CPU cores to the streaming data packets, and adaptively adjusting the DPCM sampling rate during the encoding process to improve the encoding rate while ensuring the continuity of the decoded video. Encapsulate the encoded data into a specific video stream format, such as MP4, AVI, etc. The encapsulation process will include video metadata, timestamps and other information to facilitate synchronization and processing during playback.
[0101] In summary, the present invention performs hash analysis on the split streaming data packets, and performs node allocation on the hash ring based on the distribution similarity between adjacent streaming data packets at different scales, so as to obtain the initial allocation hash ring at different scales. The allocation through the hash ring can stabilize the load while managing the allocation more flexibly, thereby improving the processing performance. Further, according to the similarity and quantity distribution of the streaming data packets allocated to the CPU core nodes in the initial allocation hash ring at different scales, the overall time of parallel processing is considered, and the final allocation hash ring is screened out as the optimal allocation situation, so that the CPU core parallel processing is more efficient. At the same time, considering that the DPCM sampling rate can reduce the encoding operation time, but excessive compression can also cause the decoded video to be incoherent, the DPCM sampling rate is adjusted by the prediction error of each frame in the streaming data packet under the optimal allocation situation, and finally the video stream encoding is performed by the final allocation hash ring and the more suitable DPCM sampling rate of different streaming data packets. The present invention selects the optimal allocation situation by the CPU parallel situation under different allocation situations of the data packet, and adaptively adjusts the DPCM sampling rate of the data packet, speeds up the encoding speed under the condition of better overall processing time, and makes the video stream encoding processing more efficient.
[0102] The present invention also provides a video stream encoding and decoding acceleration system based on a microcomputer host, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of any of the above methods when executing the computer program.
[0103] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0104] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
Claims
1. A video stream encoding and decoding acceleration method based on a microcomputer host, characterized in that: The method comprises: Obtain a video stream to be encoded; split the video stream according to the inter-frame differences of video frames in the video stream to obtain a number of streaming data packets; A consistent hashing algorithm is used to map all the streaming data packets to a hash ring to be allocated, where the nodes in the hash ring to be allocated are CPU cores; an allocation rationality index of each adjacent two streaming data packets is obtained according to the distribution proximity of the distance between each two adjacent streaming data packets on the hash ring to be allocated; at least two preset allocation scales are selected, and under each preset allocation scale, all streaming data packets in the hash ring to be allocated are allocated to the CPU core nodes based on the size of the allocation rationality index of the adjacent streaming data packets in the hash ring to be allocated, so as to obtain the initial allocation hash ring under different preset allocation scales; In each initial allocation hash ring, according to the similarity between the streaming data packets allocated to each CPU core node and the distribution of the number of streaming data packets allocated between the CPU core nodes, the allocation ideal index of each initial allocation hash ring is obtained; based on the allocation ideal index, a final allocation hash ring is determined from all the initial allocation hash rings; Under the final distribution hash ring, DPCM is used to obtain the prediction error index of each streaming data packet; according to the distribution of the prediction error index of each streaming data packet in the local range of the CPU core node where it is located, and the DPCM sampling rate of the previous streaming data packet, the DPCM sampling rate of each streaming data packet is obtained; Video stream encoding is performed by finally assigning a hash ring and a DPCM sampling rate to each streaming packet.
2. According to claim 1, a video stream encoding and decoding acceleration method based on a microcomputer host is characterized in that: The method for obtaining the allocation rationality index includes: Every two adjacent streaming data packets on the hash ring to be allocated are regarded as a data packet group; Calculate the hash value difference between two adjacent streaming data packets in each data packet group to obtain the distribution approximation index of each data packet group; The minimum distribution approximation index is taken as the closest value; The difference between the distribution mean index and the nearest maximum value of each data packet group is calculated and negative correlation mapping is performed to obtain the distribution rationality index of each data packet group.
3. According to claim 1, a video stream encoding and decoding acceleration method based on a microcomputer host is characterized in that: The method for obtaining the initially allocated hash ring includes: For any preset allocation scale, when there is an allocation rationality index greater than the preset allocation scale, two streaming data packets corresponding to the allocation rationality index are regarded as one same processing class, otherwise the two streaming data packets are regarded as different same processing classes; When the number of the same processing class is less than or equal to the CPU core node, the same processing class is assigned to the same CPU core node to obtain an initial allocation hash ring under the preset allocation scale.
4. According to claim 1, a video stream encoding and decoding acceleration method based on a microcomputer host is characterized in that: The method for obtaining the ideal allocation index includes: For any initial allocated hash ring, each CPU core node in the initial allocated hash ring is used as an analysis node in turn; The sum of the distribution rationality indexes of each two adjacent streaming data packets in the analysis node is calculated as the distribution similarity of the analysis node; the average of the distribution similarities of all CPU core nodes in the initial allocation hash ring is used as the similarity index of the initial allocation hash ring; Obtain the number of streaming data packets allocated to each CPU core node in the initial allocation hash ring as the allocation number of each CPU core node; obtain the number distribution index of the initial allocation hash ring according to the size distribution and disorder of the allocation numbers in the initial allocation hash ring; The product of the similarity index and the quantity distribution index of the initial allocation hash ring is used as the allocation ideal index of the initial allocation hash ring.
5. According to claim 4, a video stream encoding and decoding acceleration method based on a microcomputer host is characterized in that: The method for obtaining the quantity distribution index includes: The maximum allocated quantity is used as the maximum value of the numerical distribution of the initial allocated hash ring; Calculate the difference between the number of allocations of each CPU core node and the average of all allocations as the number deviation of each CPU core node; take the sum of the number deviations of all CPU core nodes in the initial allocation hash ring as the numerical disorder of the initial allocation hash ring; A negative correlation mapping is performed on the product of the maximum value of the numerical distribution of the initial allocated hash ring and the numerical disorder degree to obtain the quantity distribution index of the initial allocated hash ring.
6. The video stream encoding and decoding acceleration method based on a microcomputer host according to claim 1, characterized in that: The method of determining the final allocation hash ring from all initial allocation hash rings based on the allocation ideal index includes: The initial allocation hash ring corresponding to the maximum value of the ideal allocation index is used as the final allocation hash ring.
7. The video stream encoding and decoding acceleration method based on a microcomputer host according to claim 1 is characterized in that: The method for obtaining the prediction error index includes: For any video frame, when there is a temporally previous video frame for the video frame, the pixel value difference between the video frame and the temporally previous video frame at each pixel point is accumulated to obtain the error value of the video frame; The mean of all error values in each streaming data packet is taken as the prediction error indicator of each streaming data packet.
8. The video stream encoding and decoding acceleration method based on a microcomputer host according to claim 1, characterized in that: The method for obtaining the DPCM sampling rate of each streaming data packet includes: Under the final allocation hash ring, for any streaming data packet, a preset number of streaming data packets in the timing sequence in the allocated CPU core node where the streaming data packet is located are used as local data packets of the streaming data packet; The sum of all prediction error indicators of the streaming data packet and all local data packets is used as the local error sum value of the streaming data packet; the ratio between the local error sum value of the streaming data packet and the maximum local error sum value is subjected to normalized range mapping processing to obtain an adjustment coefficient of the streaming data packet; Obtain the DPCM sampling rate of the previous streaming data packet in the timing sequence in the assigned CPU core node where the streaming data packet is located; use the product of the DPCM sampling rate of the previous streaming data packet and the adjustment coefficient as the adjustment value of the streaming data packet; use the sum of the DPCM sampling rate of the previous streaming data packet and the adjustment value as the DPCM sampling rate of the streaming data packet.
9. The video stream encoding and decoding acceleration method based on a microcomputer host according to claim 1, characterized in that: The method for acquiring the streaming data packet comprises: The video stream to be encoded is divided into two frames whose difference is greater than a preset difference threshold by using an inter-frame difference method to obtain different video frame segments of the video stream to be encoded; A half length of a minimum length video frame segment is used as a split packet size; within each video frame segment, a start video frame is split using the split packet size as a fixed packet size to obtain a streaming data packet.
10. A video stream encoding and decoding acceleration system based on a microcomputer host, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of a video stream encoding and decoding acceleration method based on a microcomputer host are implemented as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Coding and decoding plug-in distributed deployment method and device, equipment and medium
CN113923218A
Video coding method and device based on Hash search algorithm, and electronic equipment
CN116708798A