A visual lossless compression method based on adaptive coding and quality check gating
Patent Information
- Application Number
- CN202611314118.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-27
- Publication Date
- 2026-10-30
AI Technical Summary
目前,现有技术无法消除双侧关键帧位置差异导致的采样错位,缺乏与用户压缩档位对应的差异化相似性基准,无法将相似性比对结果转化为带方向与幅度信息的偏离量,存在压缩产物画质无法稳定满足档位承诺、失真超标时缺乏有效兜底保护的问题,因此,提出一种基于自适应编码与质量校验门控的视觉无损压缩方法
本发明通过读取源文件媒体时长并采集双侧关键帧时间戳分布,基于源文件媒体时长生成采样时刻序列,结合双侧关键帧时间戳分布筛选出双侧就近关键帧锚点,依据双侧就近关键帧锚点定位解码起点,沿解码方向精确前进至采样时刻获取对齐采样帧对亮度像素矩阵,基于对齐采样帧对亮度像素矩阵计算最低采样结构相似性系数,调取用户选定的压缩档位确定档位化相似性基准,将最低采样结构相似性系数与档位化相似性基准比对分析相似性偏离量,通过相似性偏离量对首遍编码质量因子基线进行下调后触发压缩产物再次编码并计算复检相似性系数,根据复检相似性系数将交付路径分类切换为达标交付路径或原始文件回退路径,使压缩产物在最差采样点的结构相似性稳定满足用户所选档位的画质承诺,对首遍压缩失真超标情形形成自适应修正与兜底保护的闭环。
Smart Images

Figure CN123020786A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of visual lossless compression technology, and more specifically, to a visual lossless compression method based on adaptive coding and quality check gating. Background Technology
[0002] Video compression services are widely used in cloud-based media processing platforms. User-uploaded source video files are compressed by an encoder according to specified quality parameters and delivered as compressed outputs. During compression, the encoder controls the compression intensity based on a constant quality factor; a higher quality factor results in a higher compression ratio but also greater image quality loss. To ensure the delivered output meets the user's expected image quality level, the platform performs quality verification after compression to determine if the compression distortion is within acceptable limits. If distortion exceeds the acceptable range, adaptive recoding is initiated to correct the quality. Finally, based on the verification results, the platform selects the appropriate output for the user.
[0003] The existing technology has the following shortcomings: Currently, existing technologies cannot eliminate sampling misalignment caused by differences in the positions of keyframes on both sides, lack differentiated similarity benchmarks corresponding to the user's compression level, and cannot convert similarity comparison results into deviations with directional and amplitude information. This results in problems such as the compressed product image quality failing to consistently meet the level commitment and a lack of effective fallback protection when distortion exceeds the standard. Therefore, a visual lossless compression method based on adaptive coding and quality verification gating is proposed.
[0004] The information disclosed in the background section is only intended to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] To overcome the aforementioned deficiencies of the prior art, embodiments of the present invention provide a visual lossless compression method based on adaptive coding and quality verification gating. By employing bilateral proximity keyframe anchor point positioning and two-stage precise addressing to eliminate sampling misalignment, and combining graded similarity benchmarks and similarity deviation to drive adaptive recoding and delivery path splitting, the method solves the problems mentioned in the background art.
[0006] To achieve the above objectives, the present invention provides the following technical solution: a visual lossless compression method based on adaptive coding and quality verification gating, comprising the following steps: Step S1: Read the media duration of the source file, collect the timestamp distribution of keyframes on both sides, generate a sampling time sequence based on the media duration of the source file, and filter out the nearest keyframe anchor points on both sides by combining the timestamp distribution of keyframes on both sides. Step S2: Locate the decoding starting point based on the nearest keyframe anchor points on both sides, advance precisely along the decoding direction to the sampling time to obtain the luminance pixel matrix of the aligned sampling frame pair, and calculate the minimum sampling structure similarity coefficient based on the luminance pixel matrix of the aligned sampling frame pair. Step S3: Retrieve the compression level selected by the user, determine the level-based similarity benchmark based on the selected compression level, and compare the minimum sampling structure similarity coefficient with the level-based similarity benchmark to analyze the similarity deviation. Step S4: Obtain the baseline of the first-pass coding quality factor, adjust the baseline of the first-pass coding quality factor by the similarity deviation, trigger the compressed product to be encoded again and calculate the re-inspection similarity coefficient, and classify and switch the delivery path to the qualified delivery path or the original file rollback path according to the re-inspection similarity coefficient.
[0007] In a preferred embodiment, in step S1, the moment after the user-uploaded source video file is selected and the first compression is completed to obtain the compressed product is taken as the starting point of the reading cycle. The container parser is called to parse the header of the source video file, obtain the continuous playback time span from the start of playback of the first frame to the end of playback of the last frame, and obtain the media duration of the source file. On the same container parser, index scans are performed on the source video file and the compressed product respectively. The key frames with independent decoding capabilities in each bitstream are traversed, and their display timestamp fields are read frame by frame. The display timestamps of all key frames are merged in ascending order to obtain the source-side key frame timestamp dataset and the product-side key frame timestamp dataset. The two together constitute the dual-side key frame timestamp distribution.
[0008] In a preferred embodiment, in step S1, the number of sampling points is determined according to the step mapping relationship of the source file media duration, and a sampling time sequence uniformly distributed within the source file media duration interval is generated. For each sampling time in the sampling time sequence, the maximum value of all keyframe timestamps no later than the corresponding sampling time is taken from the source-side keyframe timestamp dataset and the product-side keyframe timestamp dataset, respectively, and used as the source-side nearest keyframe anchor point and the product-side nearest keyframe anchor point corresponding to the sampling time. The anchor points corresponding to all sampling times are combined to obtain the set of bilateral nearest keyframe anchor points.
[0009] In a preferred embodiment, in step S2, independent decoding contexts are enabled for the source video file and the compressed product, and the source-side nearest keyframe anchor point and the product-side nearest keyframe anchor point corresponding to each sampling moment in the set of nearby keyframe anchor points on both sides are used as the jump targets of their respective decoding contexts. The internal reference frame buffers of the two decoding contexts are reconstructed to their corresponding anchor positions to complete the decoding start point location.
[0010] In a preferred embodiment, in step S2, after the two decoding contexts have completed their respective positioning, they advance frame by frame along the decoding direction. Each time they advance a frame, they check the display timestamp of the current frame until the display timestamp is not earlier than the corresponding sampling time, and then determine it as the target sampling frame. Perform pixel-domain preprocessing on each pair of target sampling frames to obtain the luminance pixel matrix of the aligned sampling frame pairs; For the luminance pixel matrix of the aligned sampled frame at each sampling time, calculate the structural similarity coefficient of the sampling points at the sampling time. Traverse all sampling times in the sampling time sequence and take the minimum value among all sampling point structural similarity coefficients as the lowest sampling structural similarity coefficient.
[0011] In a preferred embodiment, in step S3, the compression level is the compression intensity level selected by the user through the front-end interface when initiating the compression task; Determine the gear similarity benchmark based on the compression gear selected by the user; The similarity deviation is obtained by subtracting the leveled similarity benchmark from the lowest sampling structural similarity coefficient.
[0012] In a preferred embodiment, in step S4, the first pass coding quality factor baseline refers to the coding quality used when performing the first compression coding on the source video file; The baseline of the first-pass coding quality factor is lowered by the similarity deviation, and the lowering action is triggered only when the similarity deviation is less than zero; The adjustment step size is obtained by smoothing the sigmoid mapping with the absolute value of the similarity deviation. The baseline of the first pass coding quality factor is then adjusted based on the adjustment step size to obtain the adjusted coding quality factor. The baseline of the first-pass coding quality factor is replaced with the adjusted coding quality factor, while keeping the other coding parameters unchanged. The source video file is then re-encoded to obtain the re-inspection compressed product.
[0013] In a preferred embodiment, in step S4, the key frame timestamp distribution of the re-inspection compressed product is re-acquired, and the nearest key frame anchor point on the re-inspection product side is selected by combining the generated sampling time sequence with the read source key frame timestamp dataset. The source side and the re-inspection product side are precisely advanced along the decoding direction to each sampling moment to obtain the luminance pixel matrix of the re-inspection aligned sampling frame pair. For each pair of luminance pixel matrices, the structural similarity coefficient of the re-inspection sampling point is calculated, and the minimum value among all the structural similarity coefficients of the re-inspection sampling points is taken as the re-inspection similarity coefficient.
[0014] In a preferred embodiment, in step S4, when the similarity deviation is not less than zero, i.e. the first pass meets the standard, the delivery path is switched to the qualified delivery path, and the delivery object is the first pass compression product. When the similarity deviation is less than zero but the re-inspection similarity coefficient is not lower than the graded similarity benchmark, the delivery path will be switched to the compliant delivery path, and the delivery object will be the re-inspection compressed product. When the similarity deviation is less than zero and the re-inspection similarity coefficient is still lower than the graded similarity benchmark, the delivery path will be switched to the original file rollback path, and the delivery object will be the source video file itself.
[0015] The technical effects and advantages of this invention are as follows: This invention reads the media duration of the source file and collects the timestamp distribution of keyframes on both sides. Based on the media duration of the source file, it generates a sampling time sequence and selects the nearest keyframe anchor points on both sides by combining the timestamp distribution of keyframes on both sides. Based on the nearest keyframe anchor points on both sides, it locates the decoding starting point and moves precisely along the decoding direction to the sampling time to obtain the luminance pixel matrix of the aligned sampling frame pair. Based on the luminance pixel matrix of the aligned sampling frame pair, it calculates the minimum sampling structural similarity coefficient, retrieves the compression level selected by the user to determine the level-based similarity benchmark, compares the minimum sampling structural similarity coefficient with the level-based similarity benchmark to analyze the similarity deviation, and then lowers the baseline of the first pass encoding quality factor based on the similarity deviation to trigger the compression product to be encoded again and calculate the re-inspection similarity coefficient. Based on the re-inspection similarity coefficient, it classifies and switches the delivery path to either the qualified delivery path or the original file rollback path, so that the structural similarity of the compression product at the worst sampling point stably meets the image quality commitment of the user-selected level. It forms a closed loop of adaptive correction and fallback protection for the case of excessive distortion in the first pass compression. Attached Figure Description
[0016] Figure 1 This is a flowchart illustrating the implementation of a visual lossless compression method based on adaptive coding and quality verification gating according to the present invention.
[0017] Figure 2 This is a schematic diagram illustrating the steps of a visual lossless compression method based on adaptive coding and quality check gating according to the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] This invention selects the nearest keyframe anchor points on both sides and uses them to accurately locate the decoding starting point. It drives the adaptive down-adjustment and re-examination of the encoding quality factor by comparing the lowest sampling structural similarity coefficient with the tiered similarity benchmark. Finally, it switches the delivery path according to the re-examination similarity coefficient, thereby achieving closed-loop gating delivery of compressed product image quality.
[0020] Example 1 Please see Figures 1 to 2 A visual lossless compression method based on adaptive coding and quality check gating is presented, with the specific operation process as follows: Step S1: Read the media duration of the source file, collect the timestamp distribution of keyframes on both sides, generate a sampling time sequence based on the media duration of the source file, and filter out the nearest keyframe anchor points on both sides by combining the timestamp distribution of keyframes on both sides. Step S2: Locate the decoding starting point based on the nearest keyframe anchor points on both sides, advance precisely along the decoding direction to the sampling time to obtain the luminance pixel matrix of the aligned sampling frame pair, and calculate the minimum sampling structure similarity coefficient based on the luminance pixel matrix of the aligned sampling frame pair. Step S3: Retrieve the compression level selected by the user, determine the level-based similarity benchmark based on the selected compression level, and compare the minimum sampling structure similarity coefficient with the level-based similarity benchmark to analyze the similarity deviation. Step S4: Obtain the baseline of the first-pass coding quality factor, adjust the baseline of the first-pass coding quality factor by the similarity deviation, trigger the compressed product to be encoded again and calculate the re-inspection similarity coefficient, and classify and switch the delivery path to the qualified delivery path or the original file rollback path according to the re-inspection similarity coefficient.
[0021] The specific implementation is as follows: In step S1, the moment after the cloud server receives the source video file uploaded by the user and completes the first compression to obtain the compressed product is selected as the starting point of the reading cycle, and a quality check gating process is used as the acquisition unit. First, the media information reading module calls the container parser to parse the header of the source video file and read the media duration. The media duration refers to the continuous playback time span of the source video file from the start of playback of the first frame to the end of playback of the last frame, measured in seconds. ; Subsequently, index scanning was performed on the source video file and the compressed product on the same container parser to collect the timestamp distribution of key frames on both sides. Taking the frame index table of each video stream read by the container parser as the unit, all frame nodes with independent decoding capabilities were traversed, and their display timestamp fields were read frame by frame. The display timestamps of all key frames were merged into a dataset in ascending order. The source-side keyframe timestamp dataset is denoted as ={ , ,…, The keyframe timestamp dataset on the product side is denoted as} ={ , ,…, }, where p and q are the number of keyframes on the source side and the product side, respectively, and the two datasets together constitute the two-sided keyframe timestamp distribution.
[0022] Keyframes are frames in a video stream that can be decoded independently without relying on other frames. They are typically inserted periodically by the encoder according to the image group structure. During the recoding process, the compressed output will automatically rearrange the keyframe positions based on the baseline of the coding quality factor and the coding speed preset. and The number of elements, their spacing, and their relative positions are all different.
[0023] A sampling time sequence is generated based on the media duration of the source file. This sampling time sequence refers to the set of relative time points used to simultaneously indicate the frames that need to be extracted from both the source and product sides, denoted as S={ , ,…, }, where n is the number of sampling points, This represents the i-th sampling time; the sampling time sequence is generated using the method of removing both ends and generating equal intervals.
[0024] In the formula, i ranges from 1 to n, and the number of sampling points n has a stepwise mapping relationship with the duration of the source file media. The longer the length, the larger n becomes.
[0025] It should be added that, in the above... The settings can be customized by professionals in the field according to the actual situation. For example, short segments, medium segments, and long segments can be set to 3, 5, and 7 respectively, which will not be elaborated here.
[0026] After obtaining the sampling time sequence, the nearest keyframe anchor points on both sides are selected based on the distribution of keyframe timestamps on both sides. The nearest keyframe anchor point on both sides refers to the closest keyframe position before each sampling time in both the source-side and product-side keyframe timestamp datasets, used as the decoding starting point for subsequent two-stage precise addressing; starting with the i-th sampling time... For example, the nearest keyframe anchor point on the source side Keyframe anchor points closest to the product side Determined by the following formula:
[0027]
[0028] That is, take all keyframe timestamps in the source-side keyframe timestamp dataset that are less than or equal to The maximum value among the elements is used as the nearest keyframe anchor point on the source side, and the same applies to the product side.
[0029] By combining the anchor points corresponding to all sampling times, we obtain the set of nearest keyframe anchor points on both sides. This is used to pass in subsequent steps.
[0030] In step S2, the decoding starting point is located based on the nearest keyframe anchor points on both sides, and an independent decoding context is enabled for the source video file and the compressed product respectively.
[0031] Taking the i-th sampling time as an example, the decoding context first performs a coarse localization operation, jumping the decoding position to the desired location. and At this point, the internal reference frame buffers of the two decoding contexts are completely reconstructed.
[0032] Then, a precise forward movement is executed, with the decoding context advancing frame by frame along the decoding direction. At each advance, the display timestamp of the current decoded frame is checked until the display timestamp is greater than or equal to... Up to this point, this frame is taken as the target sampling frame, and the source-side target sampling frame is denoted as... The target sampling frame on the product side is denoted as .
[0033] It should be noted that the two stages of coarse localization and precise forwarding are collectively referred to as two-stage precise addressing. Coarse localization is used to compress the decoding position to a small time window before the target time, avoiding the time overhead of sequential decoding from the beginning of the video. Precise forwarding is used to eliminate the image misalignment caused by the misalignment of keyframe positions between the source and output sides, ensuring... and Strict alignment to the same relative time point is required; if the precise forward phase is omitted and the keyframe to which the coarse positioning falls is directly used as the sampling frame, the source side and the product side will fall on different points in time. and On two different keyframes, the two frames are usually hundreds of milliseconds apart on the time axis. The main subject, camera position, and motion stage have all changed, and the structural similarity coefficient will be contaminated by sampling misalignment.
[0034] After obtaining the target sampled frame pairs at each sampling time, pixel-domain preprocessing is performed on each pair of target sampled frames to obtain the luminance pixel matrix of the aligned sampled frame pairs. The pixel-domain preprocessing specifically includes: The luminance channel is extracted from the original color space of the frame, and the luminance channel data is organized into a two-dimensional matrix. The source-side luminance pixel matrix at the i-th sampling time is denoted as... The brightness pixel matrix of the product side is denoted as Together, they form the luminance pixel matrix of the aligned sampling frame pair.
[0035] The least-sampled structural similarity coefficient is calculated based on the luminance pixel matrix of the aligned sampled frames. First, for each pair of luminance pixel matrices ( , Calculate the structural similarity coefficient of the sampling points. :
[0036] in , They are respectively and The average brightness The square of The squares of these values represent the variances of the brightness of the two values, respectively. Let the brightness covariance of the two be , , This is a constant for the stabilizing term used to avoid the denominator being zero; The value range is [-1, 1], and it usually varies in the range of [0, 1]. The closer the value is to 1, the higher the structural consistency of the two frames in terms of mean brightness, variance of brightness, and covariance of brightness.
[0037] After calculation, the worst-case scenario of the sampled points is taken as the representative value of the structural consistency of the entire video segment, i.e., the minimum sampled structural similarity coefficient, using the Chebyshev distance approach. :
[0038] The larger the value, the higher the structural consistency of the compressed product relative to the source file at the worst sampling point, reflecting less compression distortion. The smaller the value, the more severe the compression distortion.
[0039] It needs to be explained that the stability term constant , You can set it yourself according to your actual requirements. In this example, we take the following values respectively: 6.5 The value is 58.5, which will not be analyzed here.
[0040] In step S3, the compression level selected by the user is retrieved. The compression level is the compression intensity level selected by the user through the front-end interface when initiating the compression task. It is used to express the trade-off between image quality and compression ratio, and is denoted as L. The value range of L is { , , },in For mild cases For balanced mode, The higher the compression level, the greater the compression ratio and the lower the acceptable level of structural similarity for users.
[0041] The compression level is written to the task record by the front-end interface, and the task scheduling module reads it through the task record when starting the quality verification gating process.
[0042] The gear-based similarity benchmark is determined based on the compression gear selected by the user. This benchmark refers to a structural similarity reference value that corresponds one-to-one with each compression gear, used for comparison with the lowest sampled structural similarity coefficient, and is denoted as [reference value]. Establish similarity benchmark rules for different price levels: Rule 1: When L = That is, at the light setting, Take the mild level as the benchmark ; Rule 2: When L = That is, in balanced mode, Take the balanced mode as the benchmark ; Rule 3: When L = That is, in depth mode, Take depth range as reference .
[0043] The three benchmarks satisfy a monotonic relationship. > > In other words, the deeper the compression level, the lower the baseline. The specific method for determining the three-level baseline adopts the pre-experimental percentile statistical method. That is, before formal deployment, a batch of sample videos covering different resolutions and different content types, namely static scenes, moving scenes, and texture-dense scenes, are selected. Each sample video is encoded in the first pass at three compression levels, and the lowest sampling structure similarity coefficient of all products is collected. The distribution of the coefficients is statistically analyzed by level, and the lower percentile of the distribution of each level is taken as the baseline of that level. In this example, the low-level compression level is taken. 0.985, Balanced 0.970, depth profile It is 0.950.
[0044] After obtaining the minimum sampling structure similarity coefficient and the tiered similarity benchmark, the two are compared and analyzed to determine the similarity deviation. The similarity deviation is the directional difference between the minimum sampling structure similarity coefficient and the tiered similarity benchmark, used to simultaneously express the deviation direction and deviation magnitude, denoted as Δ.
[0045] It should be explained that Δ is the directionality difference. When Δ≥0, it means that the minimum sampling structure similarity coefficient is not lower than the level similarity benchmark, and the compressed product still meets the image quality commitment corresponding to the level at the worst sampling point. The direction is the qualified side. When Δ<0, it means that the minimum sampling structure similarity coefficient is lower than the level similarity benchmark, and the compressed product shows perceptible degradation. The direction is the degraded side, and the larger |Δ| is, the more severe the degradation.
[0046] In step S4, the first-pass coding quality factor baseline, i.e., the coding quality control amount used when performing the first compression coding of the source video file, adopts the constant quality factor (CRF) measurement method commonly used by encoders, and is denoted as... The higher the value, the higher the compression rate and the lower the image quality.
[0047] Before the first pass of encoding, the adaptive encoding module determines and writes the compression level and source video file size according to the preset mapping relationship. The task scheduling module reads the task record when starting the quality verification gating process.
[0048] The baseline of the first-pass coding quality factor is lowered by the similarity deviation. The lowering action is only triggered when Δ < 0; when Δ ≥ 0, the lowering is not triggered and the process directly enters the pass / fail delivery judgment branch.
[0049] The downgraded coding quality factor is denoted as :
[0050] Where g(|Δ|) is the down-adjustment step size function, using the Sigmoid smoothing mapping, the specific formula is as follows:
[0051] in That is, lower the upper limit of the step size, where γ is the steepness parameter and ε is the inflection point position parameter.
[0052] It should be added that the upper limit of the downward adjustment step size, steepness parameters, and inflection point position parameters mentioned above should be adjusted by professionals in the field according to the actual accuracy requirements of the character shape. For example, Δ can be taken respectively. The values are 6, γ is 15, and ε is 0.01, etc., which will not be analyzed in detail here.
[0053] Reduced coding quality factor The smaller the value, the weaker the compression intensity and the higher the image quality of the compressed product. Therefore, the larger the value, the greater the downward adjustment. The smaller the size, the more likely the image quality of the re-inspected product will return to the acceptable range. The relationship between |Δ| and |Δ| is a smooth decreasing one through the Sigmoid function.
[0054] Adjusted coding quality factor Triggering re-encoding of the compressed output, the adaptive encoding module uses... replace Keeping other encoding parameters such as encoding speed preset, audio track copy settings, and thread limit unchanged, the source video file is re-encoded once to obtain the re-inspected compressed product.
[0055] The two-stage precise addressing and structural similarity calculation are re-executed on the re-inspected compressed product using the same addressing method. Taking the source video file and the re-inspected compressed product as the two sides, the keyframe timestamp distribution on the re-inspected compressed product side is re-acquired. Following the method in step S1, the generated sampling time sequence S and the read source side keyframe timestamp dataset are combined. Select the nearest keyframe anchor point on the re-inspection product side. Following step S2, accurately advance along the decoding direction on both the source and re-inspection product sides to the sampling time to obtain the luminance pixel matrix of the re-inspection aligned sampling frame pairs. Calculate the structural similarity coefficient of the re-inspection sampling points for each pair of luminance pixel matrices. Finally, take the minimum value of the sampling points to obtain the re-inspection similarity coefficient. :
[0056] in, That is, the structural similarity coefficient of the re-inspection sampling points; and the delivery path is classified and switched according to the re-inspection similarity coefficient.
[0057] The delivery path refers to the final output channel for this compression task to the user. It is divided into two categories: the qualified delivery path and the original file rollback path. The qualified delivery path takes the compressed product that has met the requirements as the delivery object, while the original file rollback path takes the source video file itself as the delivery object. Rules for switching between delivery path categories are defined as follows: Rule 1: When the target is achieved on the first pass (Δ≥0), the delivery path is switched to the target delivery path, and the delivery object is the first pass compressed product; Rule 2: If the first pass fails but the second pass succeeds, i.e., Δ < 0 and ≥ When this happens, the delivery path will be switched to the compliance delivery path, and the delivery object will be the re-inspected compressed product. Rule 3: If the first pass fails to meet the standard and the re-examination also fails to meet the standard, i.e., Δ<0 and < When this happens, the delivery path is switched to the original file rollback path, and the delivery object is the source video file itself.
[0058] It should be noted that Rule 3 is designed based on the following fact: if the encoding quality factor of the same source video file is lowered twice in a row and still cannot be brought back to above the level similarity benchmark, it means that the content characteristics of the source file itself, such as extremely high motion complexity, extremely dense texture, and a large number of scene changes, do not match the compression expectations of the current level. Continuing to re-encode indefinitely not only wastes cloud computing resources, but also has a very high probability of still failing to converge. In this case, using the original file itself as the delivery object can ensure that the image quality of the file obtained by the user does not undergo any perceptible degradation, forming a fallback protection for compression failure.
[0059] After completing the delivery path switch, record the key intermediate quantities and final results involved in this quality verification gating process in the task log, specifically including: source file media duration. Sampling time sequence S, bilateral nearest keyframe anchor point set A, minimum sampling structural similarity coefficient Similarity baseline (BL), similarity deviation (Δ), and first-pass coding quality factor baseline. The reduced coding quality factor , re-examination of similarity coefficient Delivery path type and final delivery object identifier.
[0060] This method consists of four closed loops: sampling alignment, similarity measurement, tiered comparison, feedback adjustment, and traffic splitting. It establishes anchor points for the nearest keyframes on both sides, eliminates sampling misalignment caused by differences in the distribution of keyframes on both sides through two-stage precise addressing, obtains a strictly aligned sampled frame pair luminance pixel matrix, and compresses it into the lowest sampling structure similarity coefficient. The similarity deviation is used to replace the hard threshold comparison, retaining two-dimensional information of direction and amplitude. Finally, the similarity deviation is used as feedback to perform a sigmoid smoothing down adjustment on the baseline of the first-pass encoding quality factor, triggering re-encoding and re-inspection. Finally, the delivery path is split into a qualified delivery path or an original file rollback path according to the re-inspection similarity coefficient, forming a fallback protection for compression failure.
[0061] Finally, it should be noted that in this paper, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0062] Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0063] In this document, the singular forms “a,” “an,” and “the” may also include the plural forms unless the context clearly indicates otherwise. It should also be understood that terms such as “comprising / including” or “having” specify the presence of the stated features, integrals, steps, operations, components, parts, or combinations thereof, but do not preclude the possibility of the presence or addition of one or more other features, integrals, steps, operations, components, parts, or combinations thereof. Meanwhile, the term “and / or” as used in this specification includes any and all combinations of the associated listed items.
[0064] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0065] The above description of the disclosed embodiments will enable those skilled in the art to make or use various modifications to these embodiments. It will be readily apparent to those skilled in the art that the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A visual lossless compression method based on adaptive coding and quality check gating, characterized in that: Includes the following steps: Step S1: Read the media duration of the source file, collect the timestamp distribution of keyframes on both sides, generate a sampling time sequence based on the media duration of the source file, and filter out the nearest keyframe anchor points on both sides by combining the timestamp distribution of keyframes on both sides. Step S2: Locate the decoding starting point based on the nearest keyframe anchor points on both sides, advance precisely along the decoding direction to the sampling time to obtain the luminance pixel matrix of the aligned sampling frame pair, and calculate the minimum sampling structure similarity coefficient based on the luminance pixel matrix of the aligned sampling frame pair. Step S3: Retrieve the compression level selected by the user, determine the level-based similarity benchmark based on the selected compression level, and compare the minimum sampling structure similarity coefficient with the level-based similarity benchmark to analyze the similarity deviation. Step S4: Obtain the baseline of the first-pass coding quality factor, adjust the baseline of the first-pass coding quality factor by the similarity deviation, trigger the compressed product to be encoded again and calculate the re-inspection similarity coefficient, and classify and switch the delivery path to the qualified delivery path or the original file rollback path according to the re-inspection similarity coefficient.
2. The visual lossless compression method based on adaptive coding and quality check gating according to claim 1, characterized in that: In step S1, the time after the user-uploaded source video file is selected and the first compression is completed to obtain the compressed product is taken as the starting point of the reading cycle; The container parser is called to parse the header of the source video file, obtain the continuous playback time span from the start of playback of the first frame to the end of playback of the last frame, and obtain the media duration of the source file. On the same container parser, index scans are performed on the source video file and the compressed product respectively. The key frames with independent decoding capabilities in each bitstream are traversed, and their display timestamp fields are read frame by frame. The display timestamps of all key frames are merged in ascending order to obtain the source-side key frame timestamp dataset and the product-side key frame timestamp dataset. The two together constitute the dual-side key frame timestamp distribution.
3. The visual lossless compression method based on adaptive coding and quality check gating according to claim 2, characterized in that: In step S1, the number of sampling points is determined according to the step mapping relationship based on the duration of the source file media, and a sampling time sequence that is uniformly distributed within the duration interval of the source file media is generated; For each sampling time in the sampling time sequence, the maximum value of all keyframe timestamps no later than the corresponding sampling time is taken from the source-side keyframe timestamp dataset and the product-side keyframe timestamp dataset, respectively, and used as the source-side nearest keyframe anchor point and the product-side nearest keyframe anchor point corresponding to the sampling time. The anchor points corresponding to all sampling times are combined to obtain the set of bilateral nearest keyframe anchor points.
4. The visual lossless compression method based on adaptive coding and quality check gating according to claim 3, characterized in that: In step S2, independent decoding contexts are enabled for the source video file and the compressed product, and the source-side nearest keyframe anchor point and the product-side nearest keyframe anchor point corresponding to each sampling moment in the dual-side nearest keyframe anchor point set are used as the jump targets of their respective decoding contexts. The internal reference frame buffers of the two decoding contexts are reconstructed to their corresponding anchor positions to complete the decoding start point location.
5. The visual lossless compression method based on adaptive coding and quality check gating according to claim 4, characterized in that: In step S2, after each decoding context completes its localization, it advances frame by frame along the decoding direction. Each time it advances a frame, it checks the display timestamp of the current frame until the display timestamp is not earlier than the corresponding sampling time, and then determines it as the target sampling frame. Perform pixel-domain preprocessing on each pair of target sampling frames to obtain the luminance pixel matrix of the aligned sampling frame pairs; For the luminance pixel matrix of the aligned sampled frame at each sampling time, calculate the structural similarity coefficient of the sampling points at the sampling time. Traverse all sampling times in the sampling time sequence and take the minimum value among all sampling point structural similarity coefficients as the lowest sampling structural similarity coefficient.
6. The visual lossless compression method based on adaptive coding and quality check gating according to claim 1, characterized in that: In step S3, the compression level is the compression intensity level selected by the user through the front-end interface when initiating the compression task; Determine the gear similarity benchmark based on the compression gear selected by the user; The similarity deviation is obtained by subtracting the leveled similarity benchmark from the lowest sampling structural similarity coefficient.
7. The visual lossless compression method based on adaptive coding and quality check gating according to claim 1, characterized in that: In step S4, the first pass coding quality factor baseline refers to the coding quality used when performing the first compression coding on the source video file; The baseline of the first-pass coding quality factor is lowered by the similarity deviation, and the lowering action is triggered only when the similarity deviation is less than zero; The adjustment step size is obtained by smoothing the sigmoid mapping with the absolute value of the similarity deviation. The baseline of the first pass coding quality factor is then adjusted based on the adjustment step size to obtain the adjusted coding quality factor. The baseline of the first-pass coding quality factor is replaced with the adjusted coding quality factor, while keeping the other coding parameters unchanged. The source video file is then re-encoded to obtain the re-inspection compressed product.
8. The visual lossless compression method based on adaptive coding and quality check gating according to claim 7, characterized in that: In step S4, the key frame timestamp distribution of the re-inspection compressed product is re-acquired, and the nearest key frame anchor point on the re-inspection product side is selected by combining the generated sampling time sequence with the read source key frame timestamp dataset. The source side and the re-inspection product side are precisely advanced along the decoding direction to each sampling moment to obtain the luminance pixel matrix of the re-inspection aligned sampling frame pair. For each pair of luminance pixel matrices, the structural similarity coefficient of the re-inspection sampling point is calculated, and the minimum value among all the structural similarity coefficients of the re-inspection sampling points is taken as the re-inspection similarity coefficient.
9. The visual lossless compression method based on adaptive coding and quality check gating according to claim 8, characterized in that: In step S4, when the similarity deviation is not less than zero, i.e. the first pass meets the standard, the delivery path is switched to the qualified delivery path, and the delivery object is the first pass compression product. When the similarity deviation is less than zero but the re-inspection similarity coefficient is not lower than the graded similarity benchmark, the delivery path will be switched to the compliant delivery path, and the delivery object will be the re-inspection compressed product. When the similarity deviation is less than zero and the re-inspection similarity coefficient is still lower than the graded similarity benchmark, the delivery path will be switched to the original file rollback path, and the delivery object will be the source video file itself.
