Compression mode switching method, electronic device, and storage medium

CN122269025BActive Publication Date: 2026-08-21BEIJING ZHIXIANG INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202610740277.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-05-27
Publication Date
2026-08-21
Estimated Expiration
2046-05-27

AI Technical Summary

Technical Problem

[0006]本申请提供一种压缩方式切换方法、电子设备和存储介质,用以解决现有技术中的场景识别算法产生的计算延迟与 CPU 开销难以满足云桌面实时交互的使用需求的缺陷

Benefits of technology

[0021] The compression method switching method provided in this application can accurately identify the applicable scenarios of video compression methods by statistically analyzing the area information of the encoding region under hybrid compression mode and combining the color complexity measured by the number of colors and color density for scene judgment. This enables stable switching between hybrid compression methods and video compression methods, avoiding problems such as abnormal images and transmission stuttering caused by frequent and irregular switching of compression methods, and improving the smoothness and reliability of cloud desktop image transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122269025B_ABST
    Figure CN122269025B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of image coding, and provides a compression mode switching method, an electronic device and a storage medium. The method comprises the following steps: in the case that a cloud desktop image is encoded by using a hybrid compression mode, determining a first area, a second area and a third area of a first encoding region in the cloud desktop image; in the case that the first area is greater than the second area, and the ratio of the first area and the third area is greater than a first ratio threshold, switching the hybrid compression mode to a video compression mode. The first area is used for representing the area of a region with color complexity greater than a complexity threshold in the first encoding region; the second area is used for representing the area of a region with color complexity less than the complexity threshold in the first encoding region; and the color complexity is measured by the color quantity and the color density. The compression mode switching method provided by the application can realize scene discrimination with light weight and high efficiency, and is more suitable for the application environment of cloud desktop real-time interaction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image coding technology, and in particular to a compression mode switching method, an electronic device, and a storage medium. Background Technology

[0002] Cloud desktop image encoding typically includes lossless compression methods, lossy compression methods, and video compression methods based on common video coding standards, such as Advanced Video Coding (AVC, or H.264) in the Moving Picture Experts Group-4 (MPEG-4) series.

[0003] Video compression methods can achieve considerable compression results in most common office scenarios such as file browsing and text editing. However, these methods suffer from high algorithm complexity and high CPU resource consumption, making them unsuitable for lightweight scenarios. Therefore, for scenarios like text editing and code editing, where the area of ​​visual change is small, the content structure is simple, and the compressed data size is relatively small, the computational overhead of high-complexity video compression methods does not match the bandwidth gains, resulting in low cost-effectiveness and uneconomical encoding. For line-intensive scenarios such as chip wiring diagrams, printed circuit board diagrams, waveform diagrams, and computer-aided design (CAD) engineering drawings, video compression methods not only achieve lower compression rates than lossless compression methods but also cause loss of image details and line distortion, failing to meet the requirements of high-precision display and transmission.

[0004] Therefore, video compression methods cannot meet the full-scenario usage needs of cloud desktops. A reliable scene recognition algorithm is needed to distinguish between line editing scenarios where video compression methods are not applicable and text editing scenarios where they are uneconomical. In the corresponding scenarios, a hybrid compression method combining lossless and lossy compression should be used for image encoding.

[0005] To meet the high real-time requirements of cloud desktop encoding, scene recognition algorithms need to have low computational complexity to avoid introducing a large amount of additional computational overhead. Existing scene recognition algorithms mostly use complex algorithms such as target recognition, convolution operations, and image variance analysis, and usually need to perform traversal and feature calculations on the entire frame or a large area of ​​image. The resulting computational latency and CPU overhead are difficult to meet the real-time interactive needs of cloud desktops. Summary of the Invention

[0006] This application provides a compression mode switching method, an electronic device, and a storage medium to address the shortcomings of existing scene recognition algorithms, where the computational latency and CPU overhead are insufficient to meet the real-time interactive needs of cloud desktops.

[0007] This application provides a method for switching compression modes, including the following steps: When encoding cloud desktop images using a hybrid compression method, the first area, second area, and third area of ​​the first encoded region in the cloud desktop image are determined. If the first area is greater than the second area and the ratio of the first area to the third area is greater than a first ratio threshold, the hybrid compression method is switched to video compression.

[0008] The first coding region refers to the region in which the cloud desktop image is encoded using a hybrid compression method within the first time period; the first area is used to characterize the area of ​​the region in the first coding region where the color complexity is greater than the complexity threshold; the second area is used to characterize the area of ​​the region in the first coding region where the color complexity is less than the complexity threshold; the third area is used to characterize the area of ​​the first coding region; color complexity is measured by the number of colors and color density.

[0009] According to the compression method provided in this application, the hybrid compression method includes lossy compression and lossless compression. Regions in the first encoding region with color complexity greater than a complexity threshold are encoded using lossy compression. Regions in the first encoding region with color complexity less than a complexity threshold are encoded using lossless compression.

[0010] According to a compression mode switching method provided in this application, determining the first area and the second area of ​​a first encoded region in a cloud desktop image may specifically include: The area of ​​the region encoded using lossy compression within the first encoding region is defined as the first area; the area of ​​the region encoded using lossless compression within the first encoding region is defined as the second area.

[0011] According to the compression mode switching method provided in this application, when the first area is larger than the second area and the ratio of the first area to the third area is greater than a first ratio threshold, the hybrid compression mode is switched to a video compression mode. Specifically, it may include: If the first area is larger than the second area, determine the ratio between the difference between the first and second areas and the third area; if the ratio between the difference between the first and second areas and the third area is greater than a first ratio threshold, switch the hybrid compression method to video compression.

[0012] According to the compression mode switching method provided in this application, the method may further include: When encoding cloud desktop images using video compression, determine the actual and theoretical data lengths after encoding the second encoding region using video compression. The second encoding region refers to the area of ​​the cloud desktop image encoded using video compression within the second time period. If the actual data length exceeds the theoretical data length, switch the video compression method to a hybrid compression method.

[0013] According to the compression mode switching method provided in this application, the theoretical data length after encoding the second coding region using video compression mode is determined, which may specifically include: Obtain the image data length of the second encoding region, the compression ratio corresponding to the preset image quality, and the image quality adjustment coefficient. The image quality adjustment coefficient is used to characterize the degree of difference between the image quality corresponding to the current compression parameters and the preset image quality; based on the image data length, compression ratio, and image quality adjustment coefficient, determine the theoretical data length.

[0014] According to the compression method provided in this application, when the actual data length is greater than the theoretical data length, the video compression method is switched to a hybrid compression method, which may specifically include: If the ratio between the actual data length and the theoretical data length is greater than the second ratio threshold, the video compression method will be switched to hybrid compression.

[0015] According to the compression method provided in this application, the hybrid compression method includes lossy compression and lossless compression. Switching the video compression method to a hybrid compression method includes: The number of colors in the third encoding region is determined. The third encoding region refers to the area to be encoded in the cloud desktop image. If the number of colors is less than a preset threshold, the video compression method is switched to lossless compression. If the number of colors is greater than the threshold, the color density of the third encoding region is determined. If the color density is greater than a density threshold, the video compression method is switched to lossy compression.

[0016] This application also provides a compression mode switching device, including the following modules: The determination module is used to determine the first area, second area, and third area of ​​the first encoded region in the cloud desktop image when encoding the cloud desktop image using a hybrid compression method. The first encoded region refers to the region in the cloud desktop image encoded using a hybrid compression method within a first time period. The first area is used to characterize the area of ​​the region in the first encoded region where the color complexity is greater than the complexity threshold. The second area is used to characterize the area of ​​the region in the first encoded region where the color complexity is less than the complexity threshold. The third area is used to characterize the area of ​​the first encoded region. Color complexity is measured by the number of colors and the color density.

[0017] The switching module is used to switch the hybrid compression method to video compression method when the first area is greater than the second area and the ratio of the first area to the third area is greater than the first ratio threshold.

[0018] This application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the compression mode switching method as described above.

[0019] This application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the compression mode switching method as described above.

[0020] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the compression mode switching method as described above.

[0021] The compression method switching method provided in this application can accurately identify the applicable scenarios of video compression methods by statistically analyzing the area information of the encoding region under hybrid compression mode and combining the color complexity measured by the number of colors and color density for scene judgment. This enables stable switching between hybrid compression methods and video compression methods, avoiding problems such as abnormal images and transmission stuttering caused by frequent and irregular switching of compression methods, and improving the smoothness and reliability of cloud desktop image transmission.

[0022] Meanwhile, this solution achieves scene recognition based on area statistics and color complexity judgment, without the need for complex algorithms such as target recognition, convolution operation, and variance analysis, nor the need for traversing large-area images and calculating complex features. This significantly reduces the computational latency and CPU overhead of the scene recognition process, meets the requirements of strong real-time encoding in cloud desktops, and achieves lightweight and efficient scene discrimination while ensuring the accuracy of compression decisions. It is also more suitable for the application environment of real-time interaction on cloud desktops. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a flowchart illustrating a compression mode switching method provided in this application.

[0025] Figure 2This is a schematic diagram illustrating the correspondence between JPEG image quality level and the reciprocal of density threshold, as provided in this application.

[0026] Figure 3 This is a flowchart illustrating another compression mode switching method provided in this application.

[0027] Figure 4 This is a flowchart illustrating another compression mode switching method provided in this application.

[0028] Figure 5 This is a schematic diagram of a compression mode switching device provided in this application.

[0029] Figure 6 This is a schematic diagram of the structure of an electronic device provided in this application. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0031] In the description of this application, it should be understood that the terms "center," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of this application. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined with "first," "second," or "third" may explicitly or implicitly include one or more of the stated features. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.

[0032] Cloud desktop image encoding typically includes lossless compression methods, lossy compression methods, and video compression methods based on common video coding standards. In actual encoding, a single encoding method can be used for a period of time, or a single frame image can be divided into multiple regions and different encoding strategies can be used for different regions.

[0033] Video compression methods can achieve considerable compression results in most common office scenarios such as file browsing and text editing. However, these methods suffer from high algorithm complexity and high CPU resource consumption, making them unsuitable for lightweight scenarios. Therefore, for scenarios like text editing and code editing, where the area of ​​visual change is small, the content structure is simple, and the compressed data size is relatively small, the computational overhead of using highly complex video compression methods does not match the bandwidth gains, resulting in low cost-effectiveness and uneconomical encoding. For line-dense scenarios such as chip wiring diagrams, printed circuit board diagrams, waveform diagrams, and CAD engineering drawings, video compression methods not only achieve lower compression rates than lossless compression methods but also cause loss of image details and line distortion, failing to meet the requirements of high-precision display and transmission.

[0034] This demonstrates that video compression methods cannot fully meet the needs of cloud desktop usage across all scenarios, requiring the switching of different compression methods to encode images in different situations. Since switching between different compression methods is difficult to achieve seamlessly for users, and video compression algorithms are complex, containing a large amount of contextual states and encoding reference information, frequent starts and stops or dynamic switching of encoding regions can easily lead to problems such as image anomalies and transmission stuttering. Therefore, a stable and accurate scene recognition algorithm is needed to support the switching of encoding methods, accurately distinguishing between line editing scenarios where video compression methods are unsuitable and text editing scenarios where they are uneconomical, and employing a hybrid compression method combining lossless and lossy compression for image encoding in the corresponding scenarios.

[0035] To meet the high real-time requirements of cloud desktop encoding, scene recognition algorithms need to have low computational complexity to avoid introducing a large amount of additional computational overhead. Existing scene recognition algorithms mostly use complex algorithms such as target recognition, convolution operations, and image variance analysis, and usually need to perform traversal and feature calculations on the entire frame or a large area of ​​image. The resulting computational latency and CPU overhead are difficult to meet the real-time interactive needs of cloud desktops.

[0036] To address the aforementioned technical issues, this application provides a compression mode switching method. When encoding a cloud desktop image using a hybrid compression method, a first area, a second area, and a third area of ​​a first encoded region in the cloud desktop image are determined. The first encoded region refers to the area in the cloud desktop image encoded using the hybrid compression method within a first time period. The first area represents the area within the first encoded region where the color complexity is greater than a complexity threshold. The second area represents the area within the first encoded region where the color complexity is less than the complexity threshold. The third area represents the area of ​​the first encoded region. Color complexity can be measured by the number of colors and color density. When the first area is greater than the second area, and the ratio of the first area to the third area is greater than a first ratio threshold, the hybrid compression method is switched to video compression.

[0037] The compression method switching method provided in this application can accurately identify the applicable scenarios of video compression methods by statistically analyzing the area information of the encoding region under hybrid compression mode and combining the color complexity measured by the number of colors and color density for scene judgment. This enables stable switching between hybrid compression methods and video compression methods, avoiding problems such as abnormal images and transmission stuttering caused by frequent and irregular switching of compression methods, and improving the smoothness and reliability of cloud desktop image transmission.

[0038] Meanwhile, this solution achieves scene recognition based on area statistics and color complexity judgment, without the need for complex algorithms such as target recognition, convolution operation, and variance analysis, nor the need for traversing large-area images and calculating complex features. This significantly reduces the computational latency and CPU overhead of the scene recognition process, meets the requirements of strong real-time encoding in cloud desktops, and achieves lightweight and efficient scene discrimination while ensuring the accuracy of compression decisions. It is also more suitable for the application environment of real-time interaction on cloud desktops.

[0039] The compression method switching method provided in this application embodiment will be described in detail below with reference to Figures 1-6. It should be noted that the hybrid compression method consumes less computing resources, has a fast compression speed, and low transmission latency, making it suitable for scenarios with single colors and fragmented area updates, such as line editing, text editing, and CAD drawing. Video compression methods have high compression efficiency and low bandwidth consumption, but their algorithm complexity is high, CPU usage is large, and they are prone to poor compression effects and image distortion for densely lined images, making them unsuitable for all cloud desktop scenarios. Therefore, the compression method switching method in this application embodiment mainly includes switching between the hybrid compression method and the video compression method.

[0040] Figure 1 This is a flowchart illustrating a compression mode switching method provided in this application. This method can be executed by an electronic device; in one example, the electronic device can be a cloud server. (See reference...) Figure 1 As shown, the method includes the following steps S101-S102.

[0041] S101, when encoding the cloud desktop image using a hybrid compression method, determine the first area, second area, and third area of ​​the first encoded region in the cloud desktop image.

[0042] Cloud desktop images refer to desktop displays that are rendered by a cloud server and sent to the client via cloud desktop protocols. These include, but are not limited to, text editing interfaces, file browsing interfaces, line drawings, video playback screens, and graphical interactive interfaces.

[0043] The first encoding region refers to the area within a first time period where the cloud desktop image is encoded using a hybrid compression method. The encoding process of the cloud desktop image can be divided into multiple sequentially executed encoding cycles. Correspondingly, the aforementioned first time period can be the time interval from the start of the current encoding cycle to the current moment. Thus, the first encoding region refers to the area within the current encoding cycle where the cloud desktop image is encoded using a hybrid compression method.

[0044] The first area is used to characterize the area of ​​the region in the first encoding region where the color complexity is greater than a complexity threshold. Color complexity is measured by the number of colors and the color density. Accordingly, color complexity greater than the complexity threshold can be replaced by: the number of colors is greater than a preset number threshold, and the color density is greater than a preset density threshold. Accordingly, the aforementioned first area refers to the area of ​​the region in the first encoding region where the number of colors is greater than the preset number threshold, and the color density is greater than the preset density threshold.

[0045] The second area is used to characterize the area in the first encoding region where the color complexity is less than a complexity threshold. Specifically, the second area refers to the area in the first encoding region where the number of colors is less than a preset quantity threshold, or the color density is less than a preset density threshold.

[0046] The third area is used to characterize the area of ​​the first encoded region. The third area can also be called the cumulative area (or the cumulative total screen area).

[0047] In one optional implementation, the hybrid compression method described above may include lossy compression and lossless compression. Accordingly, regions in the first encoding region with color complexity greater than the complexity threshold may be encoded using lossy compression, while regions in the first encoding region with color complexity less than the complexity threshold may be encoded using lossless compression.

[0048] Based on this, the determination of the first and second areas of the first encoded region in the cloud desktop image can be specifically implemented as follows: the area of ​​the region encoded using lossy compression within the first encoded region is determined as the first area, and the area of ​​the region encoded using lossless compression within the first encoded region is determined as the second area. Thus, the first area can also be called the lossy compression area (or cumulative lossy compression area), and the second area can also be called the lossless compression area (or cumulative lossless compression area).

[0049] S102, if the first area is greater than the second area and the ratio of the first area to the third area is greater than the first ratio threshold, switch the hybrid compression method to the video compression method.

[0050] The embodiments of this application do not specifically limit the first proportional threshold. For example, the first proportional threshold can be 10%, 15%, or a larger or smaller value.

[0051] In one example, S102 can be specifically implemented as follows: if the first area is greater than the second area, determine the ratio between the difference between the first area and the second area and the third area; if the ratio between the difference between the first area and the second area and the third area is greater than a first ratio threshold, switch the hybrid compression method to the video compression method.

[0052] Specifically, taking a first ratio threshold of 10% as an example, when the first area is greater than the second area, the ratio A between the difference between the first and second areas and the third area can be determined using the following formula based on the first area, the second area, and the third area.

[0053] Ratio A = (First area - Second area) / Third area After determining the ratio A, it can be compared with a first ratio threshold of 10%. If ratio A is greater than the first ratio threshold of 10%, the hybrid compression method can be switched to video compression, and video compression can be used to encode the unencoded areas in the cloud desktop image. If ratio A is less than the first ratio threshold of 10%, the hybrid compression method can continue to be used to encode the unencoded areas in the cloud desktop image.

[0054] Setting the first threshold to 10% means that if the area encoded using lossy compression exceeds the area encoded using lossless compression by 10%, it can be converted to video compression. This setting exceeds the interface change ratio in most text editing scenarios, while it can be easily achieved in scenarios involving web browsing, PPT editing, and photo browsing with images. To ensure that video compression is not used in line editing scenarios, any target scenarios such as wiring diagrams, board diagrams, and waveform diagrams will occupy a large area of ​​the screen, causing the metric to become a very small negative number, far below the threshold.

[0055] The aforementioned scheme, which comprehensively determines whether to switch to video compression by considering the area encoded using lossy compression, the area encoded using lossless compression, and the total area of ​​the first encoded area, can effectively differentiate between different cloud desktop application scenarios, accurately identify image content areas suitable for video compression, and prevent video compression from being mistakenly triggered in inapplicable scenarios. Specifically, in scenarios with single colors and dense details, such as line editing, circuit design, and CAD drawing, this scheme can significantly reduce or even negatively reduce the judgment index (i.e., ratio A) by leveraging the high proportion of lossless compression areas, thereby strictly avoiding entering video compression mode and ensuring clear and undistorted image lines.

[0056] Meanwhile, for scenarios with small screen update areas and low overall change amplitude, such as text editing and code modification, the above method can keep the ratio A at a low value, keeping the system in a hybrid compression mode. This avoids the problems of increased CPU encoding load and insignificant bandwidth optimization benefits caused by enabling video compression, thus improving encoding economy. Only in scenarios with rich colors and a high proportion of lossy compression areas, such as web browsing, PPT editing, and image and video playback, will the system automatically switch to video compression mode. This fully leverages the high compression ratio of video compression, effectively reducing the transmission bitrate while maintaining image quality, balancing encoding efficiency, system resource consumption, and user visual experience.

[0057] Furthermore, when a large portion of the encoded area is using lossy compression, video compression methods often still yield good compression results. This is because, as described above, converting to video compression methods typically results in better compression performance when the area encoded using lossy compression methods is predominantly large.

[0058] The aforementioned hybrid compression method can include lossy compression and lossless compression. Therefore, when encoding cloud desktop images using hybrid compression, the specific choice between lossy and lossless compression can be determined by referring to the following content.

[0059] In one optional implementation, the electronic device can determine the number of colors in the region to be encoded (hereinafter referred to as encoding region A) of the cloud desktop image. If the number of colors in encoding region A is less than a preset threshold, the electronic device can encode encoding region A using lossless compression. If the number of colors in encoding region A is greater than the threshold, the electronic device can determine the color density of encoding region A. If the color density of encoding region A is greater than a density threshold, the electronic device can encode encoding region A using lossy compression.

[0060] This application does not impose a specific limitation on the quantity threshold. For example, the quantity threshold can be 100, 90, or a larger or smaller value.

[0061] The cloud desktop image can be divided into multiple regions, each of which can be used as encoding region A in turn. The above steps are then performed to determine the encoding method for each region.

[0062] In one example, an electronic device can determine the color density of encoding region A based on the number of pixels encountered when scanning a color with a quantity threshold in encoding region A. For instance, if the quantity threshold is 100 and the number of colors in encoding region A is greater than 100, when the electronic device scans the 100th color in the encoding region, it can obtain the number of pixels contained in the scanned area and determine the color density of encoding region A based on the formula described above.

[0063] Specifically, the electronic device can first determine the number of colors in encoding region A. If the number of colors in encoding region A is less than a threshold, the electronic device can encode encoding region A using lossless compression. If the number of colors in encoding region A is greater than the threshold, the electronic device can determine the number of pixels encountered when scanning a color that meets the threshold. Based on the preset threshold and the number of pixels encountered when scanning a color that meets the threshold, the electronic device can determine the color density of encoding region A using the formula: Color Density = Threshold / Number of Pixels Involved When Scanning a Color That Meets the Threshold. If the color density of encoding region A is less than a density threshold, the electronic device can encode encoding region A using lossless compression. If the color density of encoding region A is greater than the density threshold, the electronic device can encode encoding region A using lossy compression.

[0064] In one example, the electronic device can determine a density threshold based on the current compression parameters.

[0065] Specifically, electronic devices can store the correspondence between compression parameters and density thresholds. Accordingly, based on the current compression parameters, the electronic device can determine the corresponding density threshold from its stored correspondence.

[0066] Compression parameters can include quantization parameters, image quality levels, compression ratio coefficients, and other parameters that characterize the compression intensity. Taking the Joint Photographic Experts Group (JPEG) image quality level as an example, Figure 2 shows a correspondence between the JPEG image quality level and the reciprocal of the density threshold. Referring to Figure 2, it can be seen that there is a clear negative linear correlation between the JPEG image quality level and the reciprocal of the density threshold; as the JPEG image quality level increases, the reciprocal of the density threshold decreases accordingly.

[0067] The correspondence between compression parameters and density thresholds can be determined based on experimental data from real-world application scenarios. Specifically, for a given image region, if lossless compression and lossy compression with set parameters can achieve similar compression ratios, then the density threshold corresponding to the set parameters of the lossy compression method can be considered consistent with the actual color density of that image region. Based on the above rules, users can obtain the correspondence between density thresholds and compression parameters by statistically and averaging a large number of real-world scene images, and store this correspondence in the electronic device.

[0068] The above-described scheme, which selects between lossless and lossy compression methods based on the number and density of colors, has extremely low computational overhead and requires no additional complex calculations. For areas with rich colors, such as images and videos, only a small number of pixels at the beginning of the area need to be scanned to make the number of colors exceed the preset threshold, and the scanning time is extremely short. For areas with fewer colors, color count itself is a necessary prerequisite for subsequent lossless compression. The calculation process of color count and color density is an inherent step in the original processing flow. Although the count takes relatively long, the additional computational overhead introduced by the threshold determination for switching compression methods in this method is almost zero.

[0069] The compression mode switching method provided in this application will be described in detail below with reference to the above-described embodiments. Figure 3 A flowchart illustrating another compression mode switching method provided in this application embodiment is shown below. Figure 3 As shown, the method includes the following steps S301-S310.

[0070] S301, Determine the number of colors in the encoding region A of the cloud desktop image.

[0071] S302, Is the number of colors in encoding region A less than a preset threshold? If yes, proceed to S303. If no, proceed to S304.

[0072] S303 uses lossless compression to encode region A.

[0073] S304, determine the color density of the encoding region A.

[0074] S305. Is the color density of the encoding region A less than the preset density threshold? If yes, proceed to S303. If no, proceed to S306.

[0075] S306 uses a lossy compression method to encode the coding region A.

[0076] S307, the area of ​​the region encoded using lossy compression in the first encoding region of the cloud desktop image is determined as the first area.

[0077] S308, the area of ​​the region encoded using lossless compression within the first encoded region of the cloud desktop image is determined as the second area.

[0078] S309, the area of ​​the first coding region is determined as the third area.

[0079] S310, if the first area is greater than the second area, and the ratio between the difference between the first area and the second area and the third area is greater than the first ratio threshold, the hybrid compression method is switched to video compression method.

[0080] In one optional implementation, when the electronic device encodes the cloud desktop image using video compression, it can determine the actual data length and the theoretical data length after encoding the second encoding region using video compression. If the actual data length is greater than the theoretical data length, the electronic device can switch the video compression method to a hybrid compression method.

[0081] The second encoding region refers to the area where the cloud desktop image is encoded using video compression within a second time period. The second time period can be the time interval from the start of the current encoding cycle to the current time. Therefore, the second encoding region refers to the area where the cloud desktop image is encoded using video compression within the current encoding cycle.

[0082] In one example, after the electronic device encodes the second encoding region using video compression, it can obtain the actual data length of the encoded second encoding region. The electronic device can obtain the image data length of the second encoding region, the compression ratio corresponding to the preset image quality, and the current image quality adjustment coefficient. Based on the image data length, compression ratio, and image quality adjustment coefficient, it determines the theoretical data length. If the actual data length is greater than the theoretical data length, it indicates that the video compression method has achieved the expected effect, and the electronic device can exit the video encoding method, that is, switch the video compression method to a hybrid compression method.

[0083] In one example, when the actual data length is greater than the theoretical data length, the electronic device can switch the video compression method to a hybrid compression method. Specifically, this can be achieved by switching the video compression method to a hybrid compression method when the ratio between the actual data length and the theoretical data length is greater than a second ratio threshold.

[0084] For specific electronic devices, the formula can be used to determine the ratio B: ratio B = actual data length / theoretical data length. When the ratio B is greater than the second ratio threshold, the electronic device can switch the video compression method to a hybrid compression method.

[0085] In one example, the aforementioned electronic device determines the theoretical data length based on the image data length, compression ratio, and image quality adjustment coefficient. Specifically, this can be achieved by using the formula: Theoretical data length = Image data length / Compression ratio * Image quality adjustment coefficient to determine the theoretical data length.

[0086] The image data length refers to the original data length of the image region (i.e., the second encoding region) to be processed using video compression. The image data length can be determined based on the number of pixels contained in the second encoding region and the number of bytes occupied by a single pixel. Therefore, the image data length can also be referred to as the number of bytes of original pixel data.

[0087] The compression rate corresponding to the preset image quality refers to the compression rate of the video compression method under the preset image quality (or the preset basic image quality), which is used to characterize the compression capability when a better display effect is achieved.

[0088] The image quality adjustment factor is used to characterize the difference between the image quality corresponding to the current compression parameters and the preset image quality. Specifically, the image quality adjustment factor is an adjustment coefficient that matches the compression parameters of the currently used video compression method. When the compression parameters of the actually used video compression method are consistent with the compression parameters corresponding to the preset image quality, it indicates that the current compression ratio is consistent with the compression ratio corresponding to the preset image quality, and the image quality adjustment factor is 1. When the compression parameters of the actually used video compression method correspond to a lower image quality, that is, when the image quality corresponding to the compression parameters of the actually used video compression method is lower than the preset image quality, it indicates that the current compression ratio is greater than the compression ratio corresponding to the preset image quality, and the image quality adjustment factor also increases accordingly. In other words, the image quality adjustment factor is used to calibrate the theoretical data length under different compression parameters to ensure that a reasonable estimate that conforms to the actual video compression capability can be obtained when using different image quality levels.

[0089] When using H.264 as the actual encoding protocol for video compression, the available video compression quality levels range from 0 to 51, with 18 to 30 being the most common. Different quality levels correspond to different compression ratios; for example, a quality level of 18 corresponds to a compression ratio of 30. According to the protocol, ideally, when compressing the same image, the ratio of the output data length between adjacent quality levels is approximately 2^(1 / 6). Therefore, in one example, when using H.264 as the actual video compression encoding protocol, the preset quality level can be 18, and correspondingly, the preset compression ratio can be 30. When the quality level used in the actual video compression changes, the corresponding quality adjustment factor can be determined using the formula: Quality Adjustment Factor = 2 / 2^[(Quality Level - 12) / 6].

[0090] Thus, when the actual video compression method uses a quality level of 18, the quality adjustment factor is 1. When the actual video compression method uses a higher quality level, the compression ratio increases, and the quality adjustment factor also increases accordingly.

[0091] In one example, the second ratio threshold mentioned above can be set to 5, and the compression ratio corresponding to the preset base image quality can be set to 30. In other words, when the compression ratio actually obtained by using video compression is lower than 1 / 5 of the compression ratio of the preset image quality (i.e., the compression factor is less than 6 times), it can be considered that the current scene is not suitable for using video compression. In actual tests, for scenes with rich colors such as videos and photos, the calculated index value is much less than 1, and can even be as low as below 0.1, indicating that the actual compression effect of video compression in such scenes is significantly better than expected. Even in text editing scenes, although the index value rises slightly, it rarely exceeds 1. However, in scenes with single colors and dense details, such as line editing, the index rises rapidly and far exceeds the threshold range of 5 to 10, fully demonstrating the effectiveness and sensitivity of this judgment index.

[0092] In one example, the hybrid compression method may include lossy compression and lossless compression. Switching the video compression method to hybrid compression as described above can be implemented as follows: determining the number of colors in the third encoding region; the third encoding region refers to the area to be encoded in the cloud desktop image; if the number of colors is less than a preset threshold, switching the video compression method to lossless compression; if the number of colors is greater than the threshold, determining the color density of the third encoding region; if the color density is greater than the density threshold, switching the video compression method to lossy compression. The specific implementation can be referred to the description of encoding region A above, and will not be repeated here.

[0093] The above technical solution enables accurate identification of suitable video compression methods and reliable rollback control based on a comparison between actual and expected compression results. This solution effectively differentiates between typical cloud desktop scenarios such as line editing and text editing. In line editing scenarios, due to the predominantly high-frequency lines and low pixel correlation, video compression not only results in significantly lower-than-expected compression efficiency and difficulty in achieving effective compression, but also causes noticeable image quality degradation. This solution can quickly switch from video compression to hybrid compression using the aforementioned method, avoiding encoding distortion and insufficient compression performance. In text editing scenarios, although video compression suffers from header overhead and other issues that limit overall compression gains, the overall compression rate is not significantly different from hybrid compression. Furthermore, the area of ​​image change is small, and the increase in latency is not significant. Therefore, the indicator will not trigger a switch, thus avoiding system overhead and stability degradation caused by frequent switching of compression methods, ensuring a continuous and stable encoding process.

[0094] Meanwhile, the complexity of the aforementioned calculation formula is independent of image size, boasts high calculation speed and low resource consumption, and exhibits extremely high responsiveness to unsuitable scenarios such as line editing. This resolves potential issues of misjudgment and response lag, and experiments demonstrate its accurate and effective discrimination. The overall solution ensures high efficiency in video compression for richly colored scenes such as videos and photos, while avoiding the quality and efficiency deficiencies of video compression in line editing scenarios. It also balances economy and system stability in text editing scenarios, achieving overall optimization in terms of encoding quality, compression efficiency, computational overhead, and scenario adaptability.

[0095] The process of switching from a video compression method to a hybrid compression method, as provided in the embodiments of this application, will be described in detail below with reference to the above-described embodiments. Figure 4 A flowchart illustrating another compression mode switching method provided in this application embodiment is shown below. Figure 4 As shown, the method includes the following steps S401-S407.

[0096] S401, when the cloud desktop image is encoded using the video compression method, the actual data length after encoding the second encoding region using the video compression method is determined.

[0097] S402, obtain the image data length of the second encoding region, the compression rate corresponding to the preset image quality, and the image quality adjustment coefficient.

[0098] S403 determines the theoretical data length based on the image data length, compression ratio, and image quality adjustment coefficient.

[0099] S404, determine the ratio between the actual data length and the theoretical data length.

[0100] S405. Is the ratio between the actual data length and the theoretical data length greater than the second ratio threshold? If yes, proceed to S406 below; otherwise, proceed to S407 below.

[0101] S406, switch the video compression method to hybrid compression method.

[0102] S407 continues to use video compression methods.

[0103] The compression mode switching device provided in this application is described below. The compression mode switching device described below and the compression mode switching method described above can be referred to in correspondence.

[0104] Figure 5 An example is a schematic diagram of a compression mode switching device, which includes: The determination module 501 is used to determine the first area, second area, and third area of ​​the first encoded region in the cloud desktop image when encoding the cloud desktop image using a hybrid compression method; the first encoded region refers to the region in the cloud desktop image encoded using a hybrid compression method within a first time period; the first area is used to characterize the area of ​​the region in the first encoded region where the color complexity is greater than the complexity threshold; the second area is used to characterize the area of ​​the region in the first encoded region where the color complexity is less than the complexity threshold; the third area is used to characterize the area of ​​the first encoded region; color complexity is measured by the number of colors and color density; The switching module 502 is used to switch the hybrid compression method to video compression method when the first area is greater than the second area and the ratio of the first area to the third area is greater than the first ratio threshold.

[0105] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include: a processor 601, a communications interface 602, a memory 603, and a communication bus 604, wherein the processor 601, the communications interface 602, and the memory 603 communicate with each other via the communication bus 604. The processor 601 can call logical instructions in the memory 603 to execute a compression mode switching method, which includes: When encoding cloud desktop images using a hybrid compression method, the first area, second area, and third area of ​​the first encoded region in the cloud desktop image are determined. If the first area is greater than the second area and the ratio of the first area to the third area is greater than a first ratio threshold, the hybrid compression method is switched to video compression.

[0106] The first coding region refers to the region in which the cloud desktop image is encoded using a hybrid compression method within the first time period; the first area is used to characterize the area of ​​the region in the first coding region where the color complexity is greater than the complexity threshold; the second area is used to characterize the area of ​​the region in the first coding region where the color complexity is less than the complexity threshold; the third area is used to characterize the area of ​​the first coding region; color complexity is measured by the number of colors and color density.

[0107] Furthermore, the logical instructions in the aforementioned memory 603 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0108] On the other hand, this application also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the compression mode switching method provided by the above methods, the method including: When encoding cloud desktop images using a hybrid compression method, the first area, second area, and third area of ​​the first encoded region in the cloud desktop image are determined. If the first area is greater than the second area and the ratio of the first area to the third area is greater than a first ratio threshold, the hybrid compression method is switched to video compression.

[0109] The first coding region refers to the region in which the cloud desktop image is encoded using a hybrid compression method within the first time period; the first area is used to characterize the area of ​​the region in the first coding region where the color complexity is greater than the complexity threshold; the second area is used to characterize the area of ​​the region in the first coding region where the color complexity is less than the complexity threshold; the third area is used to characterize the area of ​​the first coding region; color complexity is measured by the number of colors and color density.

[0110] Furthermore, this application also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a compression mode switching method provided by the methods described above, the method comprising: When encoding cloud desktop images using a hybrid compression method, the first area, second area, and third area of ​​the first encoded region in the cloud desktop image are determined. If the first area is greater than the second area and the ratio of the first area to the third area is greater than a first ratio threshold, the hybrid compression method is switched to video compression.

[0111] The first coding region refers to the region in which the cloud desktop image is encoded using a hybrid compression method within the first time period; the first area is used to characterize the area of ​​the region in the first coding region where the color complexity is greater than the complexity threshold; the second area is used to characterize the area of ​​the region in the first coding region where the color complexity is less than the complexity threshold; the third area is used to characterize the area of ​​the first coding region; color complexity is measured by the number of colors and color density.

[0112] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0113] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A method for switching compression modes, characterized in that, The method includes: When encoding a cloud desktop image using a hybrid compression method, a first area, a second area, and a third area of ​​a first encoded region in the cloud desktop image are determined. The first encoded region refers to the region in the cloud desktop image encoded using the hybrid compression method within a first time period. The first area is used to characterize the area of ​​the region in the first encoded region where the color complexity is greater than a complexity threshold. The second area is used to characterize the area of ​​the region in the first encoded region where the color complexity is less than the complexity threshold. The third area is used to characterize the area of ​​the first encoded region. The color complexity is measured by the number of colors and the color density. If the first area is larger than the second area, and the ratio of the first area to the third area is greater than the first ratio threshold, the hybrid compression method will be switched to video compression. When encoding the cloud desktop image using the aforementioned video compression method, the actual data length and theoretical data length after encoding the second encoding region using the aforementioned video compression method are determined; the second encoding region refers to the region of the cloud desktop image encoded using the aforementioned video compression method within a second time period; If the actual data length is greater than the theoretical data length, the video compression method will be switched to the hybrid compression method.

2. The compression mode switching method according to claim 1, characterized in that, The hybrid compression method includes lossy compression and lossless compression; Regions in the first encoding region with color complexity greater than the complexity threshold are encoded using the lossy compression method; regions in the first encoding region with color complexity less than the complexity threshold are encoded using the lossless compression method.

3. The compression mode switching method according to claim 2, characterized in that, Determining the first area and the second area of ​​the first coded region in the cloud desktop image includes: The area of ​​the region encoded using the lossy compression method within the first encoded region is defined as the first area; The area of ​​the region encoded using the lossless compression method within the first encoded region is determined as the second area.

4. The compression mode switching method according to claim 1, characterized in that, The step of switching the hybrid compression method to a video compression method when the first area is larger than the second area and the ratio of the first area to the third area is greater than a first ratio threshold includes: If the first area is greater than the second area, determine the ratio between the difference between the first area and the second area and the third area; If the ratio between the difference between the first area and the second area and the third area is greater than the first ratio threshold, the hybrid compression method is switched to the video compression method.

5. The compression mode switching method according to claim 1, characterized in that, Determining the theoretical data length after encoding the second coding region using the aforementioned video compression method includes: The image data length of the second encoding region, the compression ratio corresponding to the preset image quality, and the image quality adjustment coefficient are obtained; the image quality adjustment coefficient is used to characterize the degree of difference between the image quality corresponding to the current compression parameters and the preset image quality. The theoretical data length is determined based on the image data length, the compression ratio, and the image quality adjustment coefficient.

6. The compression mode switching method according to claim 1, characterized in that, When the actual data length is greater than the theoretical data length, switching the video compression method to the hybrid compression method includes: If the ratio between the actual data length and the theoretical data length is greater than the second ratio threshold, the video compression method will be switched to the hybrid compression method.

7. The compression mode switching method according to claim 1, characterized in that, The hybrid compression method includes lossy compression and lossless compression; Switching the video compression method to the hybrid compression method includes: Determine the number of colors in the third encoding region; the third encoding region refers to the region to be encoded in the cloud desktop image. If the number of colors is less than a preset threshold, the video compression method will be switched to the lossless compression method. When the number of colors is greater than the number threshold, the color density of the third encoding region is determined; If the color density is greater than the density threshold, the video compression method is switched to the lossy compression method.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the compression mode switching method as described in any one of claims 1 to 7.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the compression mode switching method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Cloud desktop system, image sequence compression code method and medium thereof

    CN108989811A

  • Cloud desktop image processing method, image processing method, equipment and storage medium

    CN115908165A