Video compression method and video device
By using the RLE compression algorithm and pixel value compensation technology in ultrasonic videos, the display distortion problem caused by lossy compression is solved, and lossless compression and efficient storage are achieved.
Patent Information
- Application Number
- CN202211324290.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-27
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2042-10-27
AI Technical Summary
The lossy compression algorithm of ultrasonic video in the prior art has the problem of display distortion after decompression.
The run-length encoding (RLE) compression algorithm is used to losslessly compress the pixel values in the ultrasonic video, and pixel value compensation is performed in adjacent video frames to reduce the compression rate of the video.
It effectively avoids display distortion after decompression, reduces storage space requirements, and improves the acquisition and compression efficiency of video equipment.
Smart Images

Figure CN115695816B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data compression, and in particular to a video compression method and video device. Background Art
[0002] The ultrasonic device includes an ultrasonic probe, and the ultrasonic device can continuously collect ultrasonic images through the ultrasonic probe to obtain ultrasonic videos.
[0003] Since the ultrasound video usually includes a large number of ultrasound images, the storage space occupied by the ultrasound video is relatively large. Summary of the Invention
[0004] This application provides a video compression method and video device that can solve the problem of ultrasound video compressed using a lossy compression algorithm in the related art, which suffers from display distortion after decompression. The technical solution is as follows:
[0005] In one aspect, a video compression method is provided, which is applied to a video device, and the method includes: receiving a video capture instruction;
[0006] Capturing a video in response to the video capture instruction, the video comprising a plurality of video frames, each of the video frames comprising a plurality of pixels;
[0007] For each pixel in the plurality of pixels, a run-length encoding (RLE) compression algorithm is used to compress the pixel value of the pixel in the plurality of video frames to obtain a compressed video.
[0008] In another aspect, a video device is provided, comprising: a processor; the processor being configured to:
[0009] Receive video capture instructions;
[0010] Capturing a video in response to the video capture instruction, the video comprising a plurality of video frames, each of the video frames comprising a plurality of pixels;
[0011] For each pixel in the plurality of pixels, a run-length encoding (RLE) compression algorithm is used to compress the pixel value of the pixel in the plurality of video frames to obtain a compressed video.
[0012] On the other hand, a video device is provided, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the video compression method described in the above aspects when executing the computer program.
[0013] On the other hand, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is loaded and executed by a processor to implement the video compression method as described in the above aspects.
[0014] On the other hand, a computer program product comprising instructions is provided. When the computer program product is run on the computer, the computer is enabled to perform the video compression method described in the above aspects.
[0015] The beneficial effects of the technical solution provided by this application include at least:
[0016] The present application provides a video compression method and a video device. The video device is capable of capturing a video, the video comprising multiple video frames. Subsequently, for each of the multiple pixels included in each video frame, the video device is capable of compressing the pixel value of the pixel across the multiple video frames using an RLE compression algorithm to compress the video. Because the RLE compression algorithm is a lossless compression algorithm, the video compressed using the RLE compression algorithm can effectively avoid display distortion after decompression. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0018] Figure 1 This is a flow chart of a video compression method provided by an embodiment of the present application;
[0019] Figure 2 is a flowchart of another video compression method provided by an embodiment of the present application;
[0020] Figure 3 This is a schematic diagram of pixel values of a target pixel partition in two adjacent video frames provided by an embodiment of the present application;
[0021] Figure 4 is a schematic diagram of pixel values of a target pixel partition before and after compensation provided by an embodiment of the present application;
[0022] Figure 5 This is a schematic diagram of video compression provided by an embodiment of the present application;
[0023] Figure 6 Schematic diagram of an index memory table of multiple pixels provided in an embodiment of the present application;
[0024] Figure 7This is a schematic diagram of compressed data of one pixel provided by an embodiment of the present application;
[0025] Figure 8 Yes Figure 7 Schematic diagram of updating the index memory table of a pixel during the decompression process of the compressed data of the pixel shown;
[0026] Figure 9 This is a flowchart of another video compression method provided by an embodiment of the present application;
[0027] Figure 10 is a schematic diagram of a first array, a second array, and a third array provided in an embodiment of the present application;
[0028] Figure 11 is a schematic diagram of multiple video frames included in a video provided in an embodiment of the present application;
[0029] Figure 12 yes Figure 11 Compression results of multiple video frames shown;
[0030] Figure 13 This is a schematic diagram of the structure of a mobile terminal provided in an embodiment of the present application;
[0031] Figure 14 This is a software structure block diagram of a mobile terminal provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0033] In related technologies, to reduce the storage space required for ultrasound video, ultrasound equipment can use a lossy compression algorithm to process the captured ultrasound video after video acquisition. However, ultrasound videos compressed using lossy compression algorithms can suffer from display distortion after decompression.
[0034] The embodiment of the present application provides a video compression method, which is applied to a video device. Optionally, the video device can be an ultrasound device, a desktop computer, or a mobile terminal, and the mobile terminal can be a mobile phone, a tablet computer, a laptop computer, or a camera. For example, the video device can be an ultrasound device (such as a medical ultrasound device). Figure 1 , the method comprising:
[0035] Step 101: Receive a video capture instruction.
[0036] In an embodiment of the present application, the video device may include a video capture button, and the video capture instruction may be triggered by a touch operation on the video capture button.
[0037] Optionally, the video capture button may be a physical button of the video device. Alternatively, the video device may further include a display screen, and the video capture button may be a virtual button displayed on the display screen.
[0038] Step 102: Capture video in response to the video capture instruction.
[0039] The video includes a plurality of video frames, each of which includes a plurality of pixels, and for each pixel in the plurality of pixels, when the plurality of video frames overlap, the pixel in the plurality of video frames overlaps.
[0040] In an embodiment of the present application, the video device may include an image acquisition component. The video device may acquire video through the image acquisition component in response to a video acquisition instruction.
[0041] It is understandable that if the video device is an ultrasonic device, the image acquisition component may be an ultrasonic probe. If the video device is a desktop computer or a mobile terminal, the image acquisition component may be a camera.
[0042] Step 103: For each pixel in the plurality of pixels, a run-length coding compression algorithm is used to compress the pixel value of the pixel in the plurality of video frames to obtain a compressed video.
[0043] Therefore, the video device can use the run length encoding (RLE) compression algorithm to compress multiple pixel values of pixels located at the same position in multiple video frames, thereby obtaining a compressed video.
[0044] It's understood that the RLE compression algorithm is a lossless compression algorithm that compresses data based on recurring characters. For example, if the data is "aaaaaaaa", then after using the RLE compression algorithm to process this data, the resulting compression result is "a8". This shows that the compression result can reflect the recurring characters in the data and the number of times each character appears.
[0045] In summary, embodiments of the present application provide a video compression method. A video device can capture a video, the video comprising multiple video frames. Subsequently, for each of the multiple pixels included in each video frame, the video device can compress the pixel value of the pixel across the multiple video frames using the RLE compression algorithm to compress the video. Because the RLE compression algorithm is a lossless compression algorithm, the video compressed using the RLE compression algorithm can effectively avoid display distortion after decompression.
[0046] Figure 2 This is a flowchart of another video compression method provided by an embodiment of the present application, which can be applied to video equipment. Figure 2 , the method may include:
[0047] Step 201: Receive a video capture instruction.
[0048] In an embodiment of the present application, the video device may include a video capture button, and the video capture instruction may be triggered by a touch operation on the video capture button.
[0049] Optionally, the video capture button may be a physical button of the video device. Alternatively, the video device may further include a display screen, and the video capture button may be a virtual button displayed on the display screen.
[0050] Step 202: Capture video in response to the video capture instruction.
[0051] The video includes multiple video frames, and each video frame includes multiple pixels.
[0052] In an embodiment of the present application, the video device may include an image acquisition component. The video device may acquire video through the image acquisition component in response to a video acquisition instruction.
[0053] It is understood that if the video device is an ultrasonic device, the image acquisition component can be an ultrasonic probe, and each video frame is an ultrasonic image. If the video device is a desktop computer or a mobile terminal, the image acquisition component can be a camera.
[0054] Step 203: For each target pixel partition in the multiple pixel partitions of the video frame, if the similarity between the target pixel partition in two adjacent video frames is greater than a first threshold, the pixel value of the target pixel partition in the second video frame is compensated based on the pixel value of the target pixel partition in the first video frame so that the similarity is greater than a second threshold.
[0055] The first video frame is the video frame captured earlier of the two adjacent video frames, i.e., the video frame captured earlier. Correspondingly, the second video frame is the video frame captured later of the two adjacent video frames, i.e., the video frame captured later. Both the first threshold and the second threshold may be pre-stored by the video device, and the second threshold may be greater than the first threshold.
[0056] In an embodiment of the present application, the video may be obtained by capturing a target object by a video device, and the state of the target area of the target object may remain unchanged for a period of time. However, during the capture process, the target area may be affected by the capture parameters, which may cause a slight difference in the pixel values of the target area in two adjacent video frames. In this case, the video device may execute step 203, so that the pixel values of the target pixel partition in the two adjacent video frames are closer, thereby reducing the compression rate of the video and thus reducing the size of the storage space occupied by the compressed video.
[0057] If the video device is an ultrasonic device, the acquisition parameter may include ultrasonic intensity. If the video device is a mobile terminal or a desktop computer, the acquisition parameter may include acquisition brightness.
[0058] In the embodiment of the present application, the target region of the target object may be the entire region of the target object. In this case, the target pixel region among the multiple pixel regions of the video frame may be any pixel region among the multiple pixel regions.
[0059] Alternatively, the target area of the target object may be a partial area of the target object (such as a peripheral area of the target object). For example, the target object may include the human heart and the surrounding tissues of the heart, and the corresponding video is an ultrasonic video of the human heart movement captured by ultrasound. Since the state of the heart continues to change over a period of time, and the state of the surrounding tissue remains unchanged over a period of time, the target area of the target object is the area where the surrounding tissue is located. In this case, each target pixel partition in the multiple pixel partitions of the video frame may be any pixel partition in the multiple pixel partitions.
[0060] Alternatively, in a scenario where the target area is the peripheral area of the target object, the images of the edge portions of the various video frames included in the collected video (such as an ultrasound video) are roughly the same. Based on this, each target pixel partition in the multiple pixel partitions can be close to the edge of the video frame relative to the other pixel partitions. That is, each target pixel partition can be a pixel partition located in the edge area of the video frame among the multiple pixel partitions. In this way, the compression speed of the video can be increased, that is, the compression efficiency of the video can be improved.
[0061] It is understandable that the arrangement and number of the plurality of pixel partitions depends on a division method, which may be pre-stored by the video device and may be determined based on the position of the target area of the target object.
[0062] In an embodiment of the present application, for each target pixel partition in the plurality of pixel partitions, the video device may employ a similarity algorithm to process the pixel values of the target pixel partition in two adjacent video frames to obtain the similarity between the target pixel partition in the two adjacent video frames. Optionally, the similarity algorithm may include one of the following algorithms: a cosine similarity algorithm, a Euclidean distance calculation algorithm, and a Pearson correlation coefficient calculation algorithm.
[0063] Alternatively, for two adjacent video frames, the video device may obtain the first pixel value of each pixel included in the target pixel partition in the first video frame and the second pixel value in the second video frame. The video device may then determine the difference between the first pixel value and the second pixel value of each pixel in the target pixel partition, and determine the number of pixels with the same difference as the similarity between the two adjacent video frames.
[0064] It is understandable that the first threshold and the second threshold are different in different similarity determination methods.
[0065] In an embodiment of the present application, a process in which a video device compensates a pixel value of a target pixel partition in a second video frame based on the pixel value of the target pixel partition in a first video frame may include: the video device first determines a compensation value based on the pixel value of the target pixel partition in the first video frame (i.e., the first pixel value described above) and the pixel value of the target pixel partition in the second video frame (i.e., the second pixel value described above). Thereafter, the video device uses the compensation value to compensate the pixel value of each pixel in the target pixel partition in the second video frame.
[0066] Optionally, the compensation value may be the difference value that appears the most times among the multiple difference values. Each of the multiple difference values may be a difference between a first pixel value and a second pixel value of a pixel in the target pixel partition. In this case, the video device may add the compensation value to each pixel value of the target pixel partition in the second video frame to compensate for the pixel value of the target pixel partition in the second video frame.
[0067] Alternatively, each of the plurality of difference values may be a difference obtained by subtracting a first pixel value from a second pixel value of a pixel in the target pixel partition. In this case, the video device may subtract the compensation value from each pixel value of the target pixel partition in the second video frame to compensate for the pixel value of the target pixel partition in the second video frame.
[0068] For example, see Figure 3 , assuming that each video frame includes twelve pixel partitions arranged in four rows and three columns, and one target pixel partition among the twelve pixel partitions is the pixel partition located in the second row and third column. Figure 3It can be seen that in two adjacent video frames, the first pixel values of the target pixel partition in the first video frame are 6, 6, 6, 6, 6, 4, 6, and 6. The second pixel values of the target pixel partition in the second video frame are 7, 7, 7, 7, 7, 5, 6, and 7.
[0069] Assuming that the difference is the difference between the first pixel value and the second pixel value, the difference value that appears most frequently among the differences of multiple pixels in the target pixel partition is -1. Therefore, see Figure 4 , the video device may add -1 to each second pixel value in the second video frame to compensate the second video frame. Figure 4 It can be seen that the compensated pixel values of the pixels in the target pixel partition in the second video frame are 6, 6, 6, 6, 6, 6, 4, 5 and 6 in sequence.
[0070] And, compared Figure 3 and Figure 4 It can be seen that compared with before compensation, the pixel value of the target pixel partition in the second video frame after compensation is substantially the same as the pixel value in the first video frame.
[0071] It can be seen that through the above step 203, the compensated pixel values of the pixels in multiple consecutive video frames can be made the same, thereby reducing the compression rate of the video and ensuring that the storage space required for the video is small.
[0072] Step 204 : For each pixel in the plurality of pixels, compress the pixel value of the pixel in the plurality of video frames using a run-length coding compression algorithm to obtain a compressed video.
[0073] Therefore, the video device can use the run length encoding (RLE) compression algorithm to compress multiple pixel values of pixels located at the same position in multiple video frames, thereby obtaining a compressed video.
[0074] It's understood that the RLE compression algorithm is a lossless compression algorithm that compresses data based on recurring characters. For example, if the data is "aaaaaaaa", then after using the RLE compression algorithm to process this data, the resulting compression result is "a8". This shows that the compression result can reflect the recurring characters in the data and the number of times each character appears.
[0075] In an optional implementation, after video capture is completed, the video device may compress the pixel value of each of the multiple pixels in multiple video frames using an RLE compression algorithm to obtain a compressed video. For example, after video capture is completed, the video device may obtain the pixel value of each of the multiple pixels from the first video frame to the last video frame, and compress the obtained pixel value using the RLE compression algorithm to obtain a compressed video.
[0076] For example, assuming the total number of video frames is 5, see Figure 5 After completing video capture, the video device can first obtain the pixel values of the first pixel (i.e., pix1) across multiple video frames, where the capture times are different. The video device then uses the RLE compression algorithm to process the pixel values of the first pixel across the multiple video frames, obtaining compressed data for the first pixel (also known as the compression result). Similarly, the video device can obtain the compression result for each pixel except the first pixel, thereby obtaining a compressed video. Figure 5 In the example, the nth frame represents the nth video frame. n is an integer greater than or equal to 1.
[0077] In another optional implementation, during the video capture process, the video device can compress the pixel values of each of the multiple pixels across multiple video frames using an RLE compression algorithm to obtain a compressed video. For example, the video device can compress the pixel values of each of the multiple pixels across multiple video frames using an RLE compression algorithm each time it captures a video frame. In other words, the video device can compress the captured video frames in real time until capture is complete, thereby obtaining a compressed video.
[0078] When capturing video, a video device typically stores the captured video frames in its cache. However, this cache is typically small, and if insufficient, the video device cannot continue capturing video. Because the video device provided in embodiments of the present application can compress video in real time, this can reduce the amount of cache space required for captured video frames, allowing the video device to capture more video frames. Furthermore, it can improve the efficiency of the video device in acquiring compressed video.
[0079] According to the above description, the video device provided in the embodiment of the present application can use the RLE compression algorithm in the time dimension to compress the collected video frames, thereby obtaining a compressed video.
[0080] In an embodiment of the present application, a compressed video includes compressed data for each of a plurality of pixels. The compressed data for each pixel includes at least one pixel value for the pixel, the at least one pixel value including a compressed pixel value and / or an uncompressed pixel value, a compression position identifier corresponding to each compressed pixel value, and a compressed frame number corresponding to each compressed pixel value. Thus, each compression position identifier for each pixel corresponds to a compressed frame number.
[0081] The compressed pixel value may be the pixel value of the pixel in at least three consecutive video frames, and the pixel value of the pixel in the at least three consecutive video frames is the same. The compressed position identifier may be used to indicate the frame identifier of the first video frame in the at least three video frames to which the corresponding compressed pixel value belongs. The compressed frame number may be used to indicate the total number of the at least three video frames to which the corresponding compressed pixel value belongs.
[0082] The frame identifier of each video frame may be the number of the video frame. Optionally, the number may be the sequence number of the video frame in a plurality of video frames.
[0083] In an embodiment of the present application, a video device may use a table to record the compressed data of each pixel in a plurality of pixels. Alternatively, the video device may use an array to record the compressed data of each pixel in a plurality of pixels. For example, the video device may use an array to record the compressed data of each pixel in a plurality of pixels. In this case, the compressed video may include: a first array, a second array, and a third array. The first array may record at least one pixel value of each pixel in a plurality of pixels. The second array may record a compressed position identifier corresponding to the compressed pixel value of each pixel in a plurality of pixels. The third array may record the number of compressed frames corresponding to the compressed pixel value of each pixel in a plurality of pixels. The number of compressed frames corresponding to the compressed pixel value of each pixel may be greater than or equal to 3.
[0084] It is understandable that each of the first array, the second array, and the third array can be a two-dimensional array, and the two-dimensional array can be an array of N rows and M columns. N is the total number of pixels in each video frame, and M is an integer greater than or equal to 1. The N data rows included in each array correspond one-to-one to the N pixels, and each data row is used to record part of the compressed data of a corresponding pixel (i.e., at least one pixel value as described above, or a compressed position identifier corresponding to a compressed pixel value, or a compressed frame number corresponding to a compressed pixel value). The data type of the elements recorded in each data row is an integer, i.e., int. That is, the data type of the elements in each array is int.
[0085] It is also understood that in scenarios where a video device compensates for a second frame captured later than two adjacent frames, the compressed video may further include: a frame identifier for the video frame whose pixel values have been compensated, and the compensation values for the compensated pixel partitions within that video frame. This ensures that the decompressed video is more accurate after decompression.
[0086] Step 205: In response to the video play instruction, decompress the compressed video based on the RLE compression algorithm.
[0087] In an embodiment of the present application, after receiving a video playback instruction, the video device may decompress the compressed video based on the RLE compression algorithm in response to the video playback instruction. For example, for each of a plurality of pixels, the video device may process the compressed data of the pixel based on the RLE compression algorithm to determine the pixel value of the pixel in at least one video frame to be played, thereby restoring the at least one video frame from the compressed video and subsequently decompressing the compressed video.
[0088] The video play instruction is triggered by a video play button on the video device, which may be a physical button on the video device or a virtual button displayed on a display screen of the video device.
[0089] The video play instruction can be used to instruct to start playing the video from a target video frame. Optionally, the target video frame can be the first video frame of the video (i.e., the first video frame), or it can be an intermediate video frame of the video. The capture time of the intermediate video frame is later than the capture time of the first video frame.
[0090] If the target video frame is the first video frame of the video, the at least one video frame to be played is all the video frames of the video. If the target video frame is an intermediate video frame of the video, the at least one video frame is part of the video frames of the video.
[0091] It is understood that in scenarios where at least one video frame is a partial video frame of a video, the video device can restore all video frames of the video based on the compressed video, and then select the at least one video frame from all video frames. Alternatively, the video device can restore only the at least one video frame based on the compressed video. In this way, the decompression efficiency of the video can be improved, thereby improving the playback efficiency of the decompressed video.
[0092] Optionally, the process of restoring all video frames of a video based on a compressed video by a video device may include: for each pixel among a plurality of pixels, the video device first determines the pixel value of the pixel in the first video frame (or the last video frame) based on the first pixel value (or the last pixel value) recorded in the data row corresponding to the pixel in the first array. Then, based on the compressed data of the pixel, starting from the first video frame (or the last video frame), the video device determines the pixel value of the pixel in each video frame after the first video frame (or before the last video frame) in order from early to late (or from late to early) in terms of the acquisition time, thereby decompressing and obtaining all video frames. That is, the video device can obtain all video frames sequentially or in reverse order.
[0093] This embodiment of the application is described by taking as an example that a video device determines, starting from the first video frame of a video, the pixel value of any pixel among a plurality of pixels in each video frame after the first video frame in the order of acquisition time from earliest to latest.
[0094] After the video device obtains the pixel value of the pixel in the first video frame from the compressed data of the pixel, it can create an index memory table for the any pixel. The index memory table can record: the pixel value index, the position identifier index of the compressed pixel value, and the decompressed frame number of the compressed pixel value. The pixel value index refers to: the pixel value of the any pixel in the currently decompressed video frame (i.e., the restored video frame with the latest acquisition time), and the position of the pixel in at least one pixel value (i.e., the pixel value recorded in the first array). If the pixel value is a compressed pixel value, the position identifier index is the compressed position identifier corresponding to the compressed pixel value, and the position in at least one compressed position identifier (i.e., the compressed position identifier recorded in the second array) of the pixel. If the pixel value is an uncompressed pixel value, the position identifier index is the compressed position identifier corresponding to the next compressed pixel value of the uncompressed pixel value, and the position in the at least one compressed position identifier. The decompressed frame number is less than or equal to the compressed frame number corresponding to the compressed pixel value.
[0095] After the video device creates the index memory table, it can repeat the decompression process until the pixel value of the pixel in the last video frame is obtained. The decompression process includes: determining the pixel value of the pixel in the next video frame based on the index memory table and the compressed data of the pixel, and updating the index memory table.
[0096] For example, if the pixel value indicated by the pixel value index in the index memory table is a compressed pixel value, and the compressed frame number corresponding to the compressed position identifier indicated by the position identifier index in the index memory table is greater than the decompressed frame number in the index memory table, the video device can determine that the pixel value of the pixel in the next video frame is the pixel value indicated by the pixel value index. The video device can then keep the pixel value index and position identifier index in the index memory table unchanged and add 1 to the decompressed frame number to update the index memory table.
[0097] If the pixel value indicated by the pixel value index in the index memory table is a compressed pixel value, and the compressed frame number corresponding to the compressed position identifier indicated by the position identifier index in the index memory table is equal to the decompressed frame number in the index memory table, then the video device can determine that the pixel value of any pixel in the next video frame is: the next pixel value of the pixel value indicated by the pixel value index in at least one pixel value of the pixel. Afterwards, the video device can add 1 to the pixel value index, add 1 to the position identifier index, and update the decompressed frame number to 0 or 1 to update the index memory table. If the next pixel value is a compressed pixel value, the updated decompressed frame number is 1, and if the next pixel value is a non-compressed pixel value, the updated decompressed frame number is 0.
[0098] If the pixel value indicated by the pixel value index in the index memory table is an uncompressed pixel value, the video device can determine that the pixel value of any pixel in the next video frame is: the next pixel value of the pixel value indicated by the pixel value index among the at least one pixel value of the pixel. Afterwards, the video device can add 1 to the pixel value index, keep the position identifier index unchanged, and keep the decompressed frame number unchanged or update the decompressed frame number to 1 to update the index memory table. If the next pixel value is an uncompressed pixel value, the video device can keep the decompressed frame number unchanged; if the next pixel value is a compressed pixel value, the video device can update the decompressed frame number to 1.
[0099] The above is an exemplary description of how a video device obtains all video frames, using the method of restoring all video frames of a video starting from the first video frame as an example. It is understood that the video device can also restore all video frames of a video starting from the last video frame, and the process of restoring all video frames of a video starting from the last video frame can refer to the implementation process of restoring all video frames starting from the first video frame, and the present embodiment will not be repeated here.
[0100] Furthermore, during the above process of restoring all video frames, the video device determines the pixel value in the next video frame by reading the index memory table and performing comparison operations (for example, comparing the decompressed frame number with the compressed frame number), and updates the index memory table by performing addition operations. Therefore, the process of restoring all video frames by the video device is relatively simple, with a time complexity of O(n).
[0101] For example, the video device, in response to the video play instruction, obtains the pixel value of each pixel in the first video frame of the plurality of pixels and can create Figure 6 The table shown has N rows and three columns. This table can be considered as consisting of an index memory table of multiple pixels, with each row being an index memory table for one pixel. Accordingly, the first column of the table can be used to record the pixel value index of each pixel, the second column can be used to record the position identification index of the compressed pixel value of each pixel, and the third column can be used to record the decompressed frame number of the compressed pixel value of each pixel.
[0102] Alternatively, after obtaining the pixel value of each of the plurality of pixels in the first video frame, the video device may create a table with three rows and N columns. Each column in the table may be an index memory table for a pixel. Accordingly, the first row of the table may be used to record the pixel value index of each pixel, the second row may be used to record the position identification index of the compressed pixel value of each pixel, and the third row may be used to record the decompressed frame number of the compressed pixel value of each pixel.
[0103] Assume that the frame identifier of the first video frame in N video frames is 0, the frame identifier of the nth video frame is n-1, and the frame identifier of the Nth video frame is N-1. n is an integer greater than or equal to 1 and less than or equal to N. 0 in the pixel value index and position identifier index represents the first position. Assume that the total number of multiple video frames is 9, and the compressed data of the pixel value of a pixel in nine video frames is as follows: Figure 7 As shown. Figure 7 It can be seen that the pixel values of the pixel in the nine video frames may include: 1, 5, 3 and 8.
[0104] Pixel values 5 and 8 are uncompressed pixel values, while pixel values 1 and 3 are compressed pixel values. The compressed position identifier corresponding to pixel value 1 is the frame identifier of the first video frame, and the corresponding compressed frame number is 3. The compressed position identifier corresponding to pixel value 3 is the frame identifier of the fifth video frame, and the corresponding compressed frame number is 4.
[0105] The video device can read the first pixel value 1 in the compressed data of the pixel and use the first pixel value 1 as the pixel value of the pixel in the first video frame. Then, the video device can read the first compression position identifier in the compressed data of the pixel. Since the video frame indicated by the first compression position identifier 0 is the first video frame, the video device can determine that the first pixel value 1 is the compressed pixel value. And since the video device decompressed the pixel value 1 once, the video device can create Figure 8 The index memory table shown. Figure 8 It can be seen that the pixel value index recorded in the index memory table is 0, the position identifier index is 0, and the decompressed frame number is 1.
[0106] When determining the pixel value of the pixel in the second video frame, the video device first reads the position identifier index 0 in the index memory table, and reads the compressed frame number 3 corresponding to the compressed position identifier indicated by the position identifier index 0 from the compressed frame number of the pixel. The decompressed frame number in the index memory table is 1, so the video device can determine that the pixel value of the pixel in the second video frame is still the first pixel value 1. Afterwards, the video device can keep the pixel value index and position identifier index in the index memory table unchanged, and update the decompressed frame number to 2 to obtain an updated index memory table. Similarly, the video device can obtain the pixel value of the pixel in the third video frame as 1, and update the decompressed frame number in the index memory table. The updated decompressed frame number is 3.
[0107] When determining the pixel value of the pixel in the fourth video frame, the video device uses the location identifier index and the decompressed frame number in the index memory table to determine that the first compressed pixel value has been decompressed. It can then read the second compressed location identifier 4 for the pixel. Since the video frame indicated by the second compressed location identifier is the fifth video frame, the video device can directly read the second pixel value 5 of the pixel and determine this second pixel value 5 as the pixel value of the pixel in the fourth video frame. It also updates the pixel value index in the index memory table to 2, the location identifier index to 2, and the decompressed frame number to 0. It is understandable that the decompressed frame number is meaningless at this point.
[0108] When determining the pixel value of the pixel in the fifth video frame, the decompressed frame number in the index memory table is 0, so the video device can determine the third pixel value 3 of the pixel as the pixel value of the pixel in the fifth video frame. Because the compressed position identifier indicated by the position identifier index 2 is the frame identifier of the fifth video frame, the video device can determine that the third pixel value is a compressed pixel value, and then update the pixel value index in the index memory table to 2, update the decompressed frame number to 1, and keep the position identifier index unchanged.
[0109] Referring to the process of the above-mentioned video device obtaining the second video frame and the third video frame, the video device can determine that the pixel value of the pixel in the sixth video frame to the eighth video frame is 3, and after obtaining the pixel value of each video frame in the sixth video frame to the eighth video frame, update the decompressed frame number in the index memory table.
[0110] When determining the pixel value of the pixel in the ninth video frame, the video device uses the location identifier index and the decompressed frame number in the index memory table to determine that the third compressed pixel value has been decompressed and can then read the third compressed location identifier for the pixel. Since the compressed data for the pixel does not contain the third compressed location identifier, the video device directly determines the fourth pixel value as the pixel value of the pixel in the ninth video frame, updates the pixel value index in the index memory table to 3, updates the location identifier index to 2, and updates the decompressed frame number to 0.
[0111] Afterwards, if the video device determines that the fourth pixel value is the last pixel value, the decompression can be determined to be complete. If the video device determines that the fourth pixel value is not the last pixel value, the pixel values after the fourth pixel value can be sequentially determined as the pixel values of the pixel in the video frame after the ninth video frame.
[0112] Optionally, the compressed video may also include: an index memory table of multiple intermediate video frames. The index memory table of each intermediate video frame is: a set of index memory tables of each pixel in the multiple pixels of the intermediate video frame. For a scene in which the target video frame is an intermediate video frame and the video device sequentially restores at least one video frame to be played, the video device may first determine a reference video frame whose acquisition time is closest to the acquisition time of the target video frame from the multiple video frames. Then, the video device may restore at least one video frame based on the index memory table of the reference video and the data recorded in the first to third arrays. The process of the video device restoring at least one video frame based on the index memory table of the reference video and the data recorded in the first to third arrays may refer to the process of the video device restoring from the first video frame to all video frames, and the embodiments of the present application will not be repeated here.
[0113] Since it is not necessary to restore all video frames one by one starting from the first video frame to obtain the at least one video frame, the restoration efficiency of the at least one video frame is effectively improved, that is, the decompression efficiency of the compressed video is improved.
[0114] It's understandable that the decompression efficiency of compressed video is positively correlated with the number of index memory tables for the intermediate video frames stored by the video device. That is, the greater the number of intermediate video frames, the higher the decompression efficiency. However, index memory tables also consume a certain amount of memory, and having too many index memory tables can actually increase the video compression rate. Therefore, the number of index memory tables needs to strike a balance between decompression speed and compression rate.
[0115] In an embodiment of the present application, for scenarios where pixel values are compensated, the video device may first obtain the initial pixel value of each pixel in at least one video frame based on the compressed video. Then, for each pixel, the video device may perform inverse compensation on the initial pixel value based on the recorded compensation value of the pixel partition to which the pixel belongs, thereby obtaining the actual pixel value of the pixel in the at least one video frame.
[0116] If the compensation value is the difference between the first pixel value and the second pixel value, then inverse compensation of the initial pixel value of the pixel means: subtracting the compensation value from the initial pixel value of the pixel to obtain the actual pixel value of the pixel.
[0117] If the compensation value is the difference between the second pixel value and the first pixel value, then inversely compensating the initial pixel value of the pixel means adding the compensation value to the initial pixel value of the pixel to obtain the actual pixel value of the pixel.
[0118] Step 206: Play at least one video frame included in the video.
[0119] After obtaining the decompressed video, the video device can play at least one video frame included in the video.
[0120] It can be understood that, for a scenario in which at least one video frame is a partial video frame of a video, and in the process of obtaining the at least one video frame, the video device needs to restore all video frames of the video based on the compressed video, the video device can first select at least one video frame from all the restored video frames, and then play the at least one video frame.
[0121] See also Figure 9 In the embodiment of the present application, a video device is used to compress a video in real time as an example to exemplify the video compression method provided in the embodiment of the present application:
[0122] Step 301: Receive a video capture instruction.
[0123] The implementation process of step 301 can refer to the implementation process of the above-mentioned step 101 or step 201, and will not be repeated here in the embodiment of the present application.
[0124] Step 302: Capture video frames.
[0125] In the embodiment of the present application, after receiving the video capture instruction, the video device can respond to the video capture instruction and capture a video frame. The video frame includes a plurality of pixels.
[0126] It is understood that, in response to the video capture instruction, the video device may further create a first array, a second array, and a third array to record the compressed data of the plurality of pixels. In this case, each of the first array, the second array, and the third array is an empty array, that is, the number of elements included in each array is 0.
[0127] The first array is used to record at least one pixel value of each of the plurality of pixels. The second array is used to record a compressed position identifier corresponding to the compressed pixel value of each of the plurality of pixels. The third array is used to record a compressed frame number corresponding to the compressed pixel value of each of the plurality of pixels.
[0128] For example, in response to a video capture instruction, the video device may create a data structure, which may include: Figure 10 The first array, the second array and the third array shown. Figure 10 It can be seen that each array may include: N rows of elements corresponding one-to-one to pixel 1 (ie, pix1 in the figure) to pixel N (ie, pixN in the figure).
[0129] Step 303: During the video capture process, it is detected whether the currently captured video frame belongs to the target video frame group.
[0130] If the video device determines that the currently captured video frame belongs to the target video frame group, step 304 is executed. If the video device determines that the currently captured video frame does not belong to the target video frame group, step 305 is executed. The target video frame group includes: the first video frame and the second video frame of the video.
[0131] Optionally, during the video capture process, the video device may count the captured video frames. If the video device determines that the total number of captured video frames is less than or equal to 2, the currently captured video frame may be determined to belong to the target video frame group. If the video device determines that the total number of captured video frames is greater than 2, the currently captured video frame may be determined not to belong to the target video frame group.
[0132] Step 304: For each pixel in the plurality of pixels, record the pixel value of the pixel in a first array.
[0133] If the video device determines that the currently captured video frame belongs to the target video frame group, that is, the captured video frame is the first video frame or the second video frame of the video, then for each pixel in the plurality of pixels, the video device may record the pixel value of each of the N pixels in each row of the first array. Furthermore, the video device may keep the second array and the third array unchanged.
[0134] For example, the video device may record the pixel value of the first pixel in the first row of the first array, and record the pixel value of the second pixel in the third row of the first array, until the recording of each pixel value in the video frame is completed.
[0135] Step 305: For each pixel among the multiple pixels, detect whether the pixel value of the pixel in the currently acquired video frame is the same as the pixel value in the previous video frame.
[0136] If the video device determines that the currently captured video frame does not belong to the target video group, the video device may detect, for each of the plurality of pixels, whether a pixel value of the pixel in the currently captured video frame is the same as a pixel value of the pixel in a previous video frame, where the previous video frame is a video frame immediately preceding the currently captured video frame.
[0137] If the video device determines that the pixel value of the pixel in the currently captured video frame is different from the pixel value in the previous video frame, step 306 is executed. If the video device determines that the pixel value of the pixel in the currently captured video frame is the same as the pixel value in the previous video frame, step 307 is executed.
[0138] Optionally, the video device can detect whether the pixel value of the pixel in the currently acquired video frame is the same as the last pixel value of the pixel recorded in the first array. If the video device determines that the pixel value of the pixel in the currently acquired video frame is the same as the last pixel value, it can be determined that the pixel value of the pixel in the currently acquired video frame is the same as the pixel value in the previous video frame. If the video device determines that the pixel value of the pixel in the currently acquired video frame is different from the last pixel value, it can be determined that the pixel value of the pixel in the currently acquired video frame is different from the pixel value in the previous video frame.
[0139] Step 306: Record the pixel value of the pixel in the currently acquired video frame in the first array.
[0140] For each pixel among the plurality of pixels, if the video device determines that the pixel value of the pixel in the currently captured video frame is different from the pixel value in the previous video frame, the pixel value of the pixel in the currently captured video frame may be directly recorded in the first array. Furthermore, the video device may keep the second array and the third array unchanged.
[0141] For example, the video device may record the pixel value of the pixel in the currently captured video frame in a data row corresponding to the pixel in the first array.
[0142] Step 307: Detect whether the pixel value of the pixel in the previous video frame is compressed.
[0143] For each pixel among the multiple pixels, if the video device determines that the pixel value of the pixel in the currently captured video frame is the same as the pixel value in the previous video frame, it can detect whether the pixel value of the pixel in the previous video frame is compressed.
[0144] If the video device determines that the pixel value of the pixel in the previous video frame has been compressed, step 308 may be executed. If the video device determines that the pixel value of the pixel in the previous video frame has not been compressed, step 309 may be executed.
[0145] In an embodiment of the present application, the video device can determine whether the pixel value in the previous video frame is compressed based on the position identifier recorded in the second array and the corresponding compressed frame number.
[0146] Step 308: Determine the pixel value of the pixel in the current video frame as the compressed pixel value of the pixel, and update the compressed frame number corresponding to the compressed pixel value recorded in the third array.
[0147] For each pixel in the plurality of pixels, if the video device determines that the pixel value of the pixel in the previous video frame has been compressed, the pixel value of the pixel in the current video frame may be determined to be a compressed pixel value, and the compressed frame number corresponding to the compressed pixel value recorded in the third array may be updated. The updated compressed frame number may be one greater than the compressed frame number before the update.
[0148] Step 309: Detect whether the pixel value of the pixel in the currently acquired video frame is the same as the pixel value in the auxiliary video frame.
[0149] The auxiliary video frame is the video frame before the previous video frame. That is, the auxiliary video frame is the second video frame before the currently captured video frame. It is understandable that the pixel values in the auxiliary video frame are not compressed.
[0150] For each pixel in the plurality of pixels, if the video device determines that the pixel value of the pixel in the previous video is uncompressed, the video device may detect whether the pixel value of the pixel in the currently acquired video frame is the same as the pixel value in the auxiliary video frame. If the video device determines that the pixel value of the pixel in the currently acquired video frame is different from the pixel value in the auxiliary video frame, step 306 may be executed. If the video device determines that the pixel value of the pixel in the currently acquired video frame is the same as the pixel value in the auxiliary video frame, step 310 may be executed.
[0151] Step 310: Determine the pixel value of the pixel in the currently acquired video frame as the compressed pixel value of the pixel, delete the pixel value of the pixel in the previous video frame recorded in the first array, record the frame identifier of the auxiliary video frame in the second array, and record the compressed frame number in the third array.
[0152] For each of the multiple pixels, if the video device determines that the pixel value of the pixel in the currently acquired video frame is the same as the pixel value in the auxiliary video frame, the pixel value of the pixel in the currently acquired video frame can be determined as the compressed pixel value, and the frame identifier of the auxiliary video frame can be determined as the compressed position identifier corresponding to the compressed pixel value. The video device can then delete the pixel value of the pixel in the previous video frame recorded in the first array, record the frame identifier of the auxiliary video frame in the second array, and record the number of compressed frames in the third array. The number of compressed frames is 3.
[0153] Step 311: Detect whether the currently captured video frame is the last video frame of the video.
[0154] In the embodiment of the present application, after the video device executes step 304, step 306, step 308, or step 310, it can detect whether the currently captured video frame is the last video frame of the video. If the video device determines that the video frame is not the last video frame of the video, it continues to execute step 302. If the video device determines that the video frame is the last video frame of the video, it can terminate the operation and use the first array, the second array, and the third array as the compressed video.
[0155] Optionally, if the video device receives an instruction to end capturing after capturing the first video frame, it may be determined that the first video frame is the last video frame of the video.
[0156] For example, assuming that the video capture device captures five video frames in total, the five video frames can be Figure 11 As shown. Figure 11As can be seen, each video frame includes nine pixels. The pixel values of the nine pixels in the first video frame are: 1, 1, 0, 1, 2, 1, 4, 1, and 1. The pixel values of the nine pixels in the fifth video frame are: 1, 1, 0, 1, 6, 2, 3, 2, and 3.
[0157] Then the video device can obtain the following information through the above steps 303 to 311: Figure 11 The compressed video shown. Figure 12 It can be seen that the compressed data of the first pixel includes: a pixel value 1, a compressed position identifier 0, and a compressed frame number 5. The compressed data of the ninth pixel includes: two pixel values 1 and 3, a compressed position identifier 1, and a compressed frame number 4.
[0158] It should be noted that the order of the steps of the video compression method provided in the embodiments of the present application can be adjusted appropriately, and the steps can be increased or decreased accordingly. For example, step 203 can be deleted according to the circumstances. Any method that can be easily conceived by a person skilled in the art within the scope of the technology disclosed in this application should be included in the scope of protection of this application, and therefore will not be described in detail.
[0159] In summary, embodiments of the present application provide a video compression method. A video device can capture a video, the video comprising multiple video frames. Subsequently, for each of the multiple pixels included in each video frame, the video device can compress the pixel value of the pixel across the multiple video frames using the RLE compression algorithm to compress the video. Because the RLE compression algorithm is a lossless compression algorithm, the video compressed using the RLE compression algorithm can effectively avoid display distortion after decompression.
[0160] An embodiment of the present application provides a video device, which may include: a processor. The processor is configured to:
[0161] Receive video capture instructions;
[0162] Capturing a video in response to a video capture instruction, the video comprising a plurality of video frames, each of the video frames comprising a plurality of pixels;
[0163] For each pixel in the multiple pixels, a run-length encoding (RLE) compression algorithm is used to compress the pixel value of the pixel in the multiple video frames to obtain a compressed video.
[0164] Optionally, the compressed video includes: compressed data for each pixel of the plurality of pixels, the compressed data including: at least one pixel value of the pixel, the at least one pixel value including: a compressed pixel value and / or an uncompressed pixel value, a compression position identifier corresponding to each compressed pixel value, and a compressed frame number corresponding to each compressed pixel value;
[0165] Among them, the compressed pixel value is the pixel value of the pixel in at least three consecutive video frames, the compressed position identifier is used to indicate the frame identifier of the first video frame in the at least three video frames to which the corresponding compressed pixel value belongs, and the compressed frame number is used to indicate the total number of at least three video frames to which the corresponding compressed pixel value belongs.
[0166] Optionally, the compressed video includes: a first array, a second array, and a third array;
[0167] The first array records at least one pixel value of each pixel in the plurality of pixels;
[0168] The second array records a compressed position identifier corresponding to a compressed pixel value of each pixel in the plurality of pixels;
[0169] The third array records the compressed frame number corresponding to the compressed pixel value of each pixel in the plurality of pixels.
[0170] Optionally, the number of each compressed frame is greater than or equal to 3.
[0171] Optionally, the processor can be used to:
[0172] During the video acquisition process, the RLE compression algorithm is used to compress the pixel values in multiple video frames to obtain the compressed video;
[0173] Alternatively, after video acquisition is completed, the pixel values of the pixels in multiple video frames are compressed using an RLE compression algorithm to obtain a compressed video.
[0174] Optionally, each of the multiple video frames includes: multiple pixel partitions. The processor may also be configured to:
[0175] For each target pixel partition among the multiple pixel partitions, if a similarity between the target pixel partition in two adjacent video frames is greater than a first threshold, compensate a pixel value of the target pixel partition in the second video frame based on a pixel value of the target pixel partition in the first video frame so that the similarity is greater than a second threshold;
[0176] The second threshold is greater than the first threshold, and the first video frame is a video frame captured earlier in time than in two adjacent video frames.
[0177] Optionally, each target pixel partition among the multiple pixel partitions is closer to an edge of the video frame than other pixel partitions.
[0178] Optionally, after obtaining the compressed video, the method further includes:
[0179] In response to a video playback instruction, decompressing the compressed video based on an RLE compression algorithm;
[0180] At least one video frame included in the video is played.
[0181] Optionally, the compressed video includes: compressed data for each pixel of the plurality of pixels, the compressed data including: at least one pixel value of the pixel, the at least one pixel value including: a compressed pixel value and / or an uncompressed pixel value, a compression position identifier corresponding to each compressed pixel value, and a compressed frame number corresponding to each compressed pixel value; decompressing the compressed video based on the RLE compression algorithm includes:
[0182] For each pixel in the plurality of pixels, compressed data of the pixel is processed based on an RLE compression algorithm to determine a pixel value of the pixel in at least one video frame to be played.
[0183] In summary, embodiments of the present application provide a video device capable of capturing a video comprising multiple video frames. Subsequently, for each of the multiple pixels included in each video frame, the video device can compress the pixel value of the pixel across the multiple video frames using the RLE compression algorithm to compress the video. Because the RLE compression algorithm is a lossless compression algorithm, the video compressed using the RLE compression algorithm can effectively avoid display distortion after decompression.
[0184] like Figure 13 As shown, the video device 110 provided in the embodiment of the present application may further include: a display unit 130, a radio frequency (RF) circuit 150, an audio circuit 160, a wireless fidelity (Wi-Fi) module 170, a Bluetooth module 180, a power supply 190 and a camera 121 and other components.
[0185] The camera 121 can be used to capture still images or videos. The object is projected through the lens into a photosensitive element, which can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, which is then transmitted to the processor 1101 for conversion into a digital image signal.
[0186] The processor 1101 is the control center of the video device 110. It uses various interfaces and lines to connect various parts of the entire terminal. By running or executing software programs stored in the memory 140 and calling data stored in the memory 140, it performs various functions of the video device 110 and processes data. In some embodiments, the processor 1101 may include one or more processing units; the processor 1101 may also integrate an application processor and a baseband processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the baseband processor mainly processes wireless communications. It is understandable that the above-mentioned baseband processor may not be integrated into the processor 1101. In the present application, the processor 1101 can run the operating system and application programs, can control the user interface display, and can implement the video compression method provided in the embodiment of the present application. In addition, the processor 1101 is coupled to the input unit and the display unit 130.
[0187] The display unit 130 can be used to receive input digital or character information and generate signal input related to user settings and function control of the video device 110. Optionally, the display unit 130 can also be used to display information input by the user or information provided to the user, as well as a graphical user interface (GUI) of various menus of the video device 110. The display unit 130 may include a display screen 131 disposed on the front of the video device 110. The display screen 131 can be configured in the form of a liquid crystal display, a light-emitting diode, etc. The display unit 130 can be used to display the various graphical user interfaces described in this application.
[0188] Display unit 130 includes a display screen 131 and a touch screen 132 located on the front of video device 110. Display screen 131 can be used to display preview images. Touch screen 132 can detect user touch operations on or near it, such as clicking a button or dragging a scroll bar. Touch screen 132 can be overlaid on display screen 131 or integrated with display screen 131 to implement the input and output functions of video device 110. The integrated display screen can be simply referred to as a touch screen display.
[0189] The memory 140 can be used to store software programs and data. The processor 1101 executes various functions and data processing of the video device 110 by running the software programs or data stored in the memory 140. The memory 140 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. The memory 140 stores an operating system that enables the video device 110 to run. In the present application, the memory 140 can store an operating system and various application programs, and can also store code for executing the video compression method provided in the embodiments of the present application.
[0190] RF circuit 150 can be used to receive and transmit signals during information transmission or calls. It can receive downlink data from the base station and pass it to processor 1101 for processing; it can also send uplink data to the base station. Typically, RF circuits include but are not limited to antennas, at least one amplifier, a transceiver, a coupler, a low-noise amplifier, a duplexer, and other components.
[0191] The audio circuit 160, the speaker 161, and the microphone 162 can provide an audio interface between the user and the video device 110. The audio circuit 160 can transmit the electrical signal converted from the received audio data to the speaker 161, which is converted into a sound signal for output. The video device 110 can also be configured with a volume button for adjusting the volume of the sound signal. On the other hand, the microphone 162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 160 and converted into audio data, and then outputs the audio data to the RF circuit 150 to be sent to, for example, another terminal, or outputs the audio data to the memory 140 for further processing. In this application, the microphone 162 can capture the user's voice.
[0192] Wi-Fi is a short-range wireless transmission technology. The video device 110 can help users send and receive emails, browse web pages, and access streaming media through the Wi-Fi module 170, providing users with wireless broadband Internet access.
[0193] The Bluetooth module 180 is used to exchange information with other Bluetooth devices having a Bluetooth module through the Bluetooth protocol. For example, the video device 110 can establish a Bluetooth connection with a wearable electronic device (such as a smart watch) that also has a Bluetooth module through the Bluetooth module 180 to exchange data.
[0194] The video device 110 also includes a power supply 190 (e.g., a battery) that supplies power to various components. The power supply can be logically connected to the processor 1101 via a power management system, thereby enabling the power management system to manage functions such as charging, discharging, and power consumption. The video device 110 can also be configured with a power button for turning the terminal on and off, as well as locking the screen.
[0195] The video device 110 may include at least one sensor 1110, such as a motion sensor 11101, a distance sensor 11102, and a temperature sensor 11103. The video device 110 may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor.
[0196] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the mobile terminal and each device described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0197] Figure 14 This is a block diagram of the software structure of the video device provided in an embodiment of the present application. A layered architecture divides software into several layers, each with distinct roles and divisions of labor. Layers communicate with each other via software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime (ART) and system libraries, and the kernel layer.
[0198] The application layer can include a series of application packages. Figure 14 As shown, the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message. The application framework layer provides the application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0199] like Figure 14 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0200] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.
[0201] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, pictures, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0202] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.
[0203] The call manager is used to provide communication functions for the video device 110, such as management of call status (including answering, hanging up, etc.).
[0204] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0205] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically, without requiring user interaction. For example, the Notification Manager can be used to announce the completion of downloads, message reminders, and so on. The Notification Manager can also display notifications in the form of icons or scrolling text in the top status bar, such as notifications from background applications, or in the form of dialog windows on the screen. Examples include displaying text messages in the status bar, emitting alert sounds, vibrating the communication terminal, and flashing indicator lights.
[0206] The Android runtime includes the core library and the virtual machine. The Android runtime is responsible for scheduling and management of the Android system.
[0207] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.
[0208] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.
[0209] The system library can include multiple functional modules, such as surface manager, media libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0210] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.
[0211] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0212] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0213] A 2D graphics engine is a drawing engine for 2D drawings.
[0214] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver.
[0215] An embodiment of the present application provides a video device, which may include a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the video compression method provided in the above embodiment is implemented, for example Figure 1 、 Figure 2 or Figure 9 The method shown.
[0216] The embodiment of the present application provides a computer-readable storage medium, in which a computer program is stored. The computer program is loaded by a processor and executes the video compression method provided in the above embodiment, for example Figure 1 、 Figure 2 or Figure 9 The method shown.
[0217] The present application also provides a computer program product including instructions. When the computer program product is run on a computer, the computer is caused to execute the video compression method provided by the above method embodiment, for example: Figure 1 、 Figure 2 or Figure 9 The method shown.
[0218] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.
[0219] It should be understood that the term "and / or" used herein indicates that three relationships can exist. For example, "A and / or B" can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following objects are in an "or" relationship. Furthermore, the term "at least one" in this application means one or more, and the term "plurality" in this application means two or more.
[0220] In this application, the terms "first," "second," and the like are used to distinguish between identical or similar items with substantially the same purpose or function. It should be understood that "first," "second," and "nth" do not have a logical or temporal dependency, nor do they limit the quantity or execution order. For example, without departing from the scope of the various examples described, a first video frame may be referred to as a second video frame, and similarly, a second video frame may be referred to as a first video frame.
[0221] The above description is merely an exemplary embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A video compression method, characterized in that: Applied to a video device, the method includes: Receive video capture instructions; Capturing a video in response to the video capture instruction, the video comprising a plurality of video frames, each of the video frames comprising a plurality of pixel partitions; For each target pixel partition among the multiple pixel partitions, if the similarity between the target pixel partition in two adjacent video frames is greater than a first threshold, compensating the pixel value of the target pixel partition in the second video frame based on the pixel value of the target pixel partition in the first video frame so that the similarity is greater than a second threshold; wherein the second threshold is greater than the first threshold, the first video frame is a video frame captured earlier than the two adjacent video frames, and the second video frame is a video frame captured later than the two adjacent video frames; For each pixel in the plurality of pixels included in each of the video frames, a run-length encoding (RLE) compression algorithm is used to compress the pixel value of the pixel in the plurality of video frames to obtain a compressed video.
2. The method according to claim 1, characterized in that The compressed video includes: compressed data of each pixel of the plurality of pixels, the compressed data including: at least one pixel value of the pixel, the at least one pixel value including: a compressed pixel value and / or an uncompressed pixel value, a compression position identifier corresponding to each compressed pixel value, and a compressed frame number corresponding to each compressed pixel value; In which, the compressed pixel value is the pixel value of the pixel in at least three consecutive video frames, the compressed position identifier is used to indicate the frame identifier of the first video frame in the at least three video frames to which a corresponding compressed pixel value belongs, and the compressed frame number is used to indicate the total number of at least three video frames to which a corresponding compressed pixel value belongs.
3. The method according to claim 2, characterized in that The compressed video includes: a first array, a second array, and a third array; Wherein, the first array records at least one pixel value of each pixel in the plurality of pixels; The second array records a compressed position identifier corresponding to the compressed pixel value of each pixel in the plurality of pixels; The third array records the number of compressed frames corresponding to the compressed pixel value of each pixel in the multiple pixels.
4. The method according to any one of claims 1 to 3, characterized in that: The step of compressing the pixel values of the pixels in the plurality of video frames using a run-length encoding (RLE) compression algorithm to obtain a compressed video includes: During the video acquisition process, an RLE compression algorithm is used to compress the pixel values of the pixels in the plurality of video frames to obtain a compressed video; Alternatively, after the video acquisition is completed, the pixel values of the pixels in the multiple video frames are compressed using an RLE compression algorithm to obtain a compressed video.
5. The method according to any one of claims 1 to 3, characterized in that: The video device is an ultrasonic device, and each of the video frames is an ultrasonic image; Each target pixel partition among the plurality of pixel partitions is closer to an edge of the video frame than other pixel partitions.
6. The method according to any one of claims 1 to 3, characterized in that: After obtaining the compressed video, the method further includes: In response to a video playback instruction, decompressing the compressed video based on the RLE compression algorithm; At least one video frame included in the video is played.
7. The method according to claim 6, characterized in that The compressed video includes: compressed data of each pixel of the plurality of pixels, the compressed data includes: at least one pixel value of the pixel, the at least one pixel value includes: a compressed pixel value and / or an uncompressed pixel value, a compression position identifier corresponding to each compressed pixel value, and a compressed frame number corresponding to each compressed pixel value; decompressing the compressed video based on the RLE compression algorithm includes: For each pixel of the plurality of pixels, compressed data of the pixel is processed based on the RLE compression algorithm to determine a pixel value of the pixel in at least one video frame to be played.
8. A video device, characterized in that: The video device includes: a processor; the processor is configured to: Receive video capture instructions; Capturing a video in response to the video capture instruction, the video comprising a plurality of video frames, each of the video frames comprising a plurality of pixel partitions; For each target pixel partition among the multiple pixel partitions, if the similarity between the target pixel partition in two adjacent video frames is greater than a first threshold, compensating the pixel value of the target pixel partition in the second video frame based on the pixel value of the target pixel partition in the first video frame so that the similarity is greater than a second threshold; wherein the second threshold is greater than the first threshold, the first video frame is a video frame captured earlier than the two adjacent video frames, and the second video frame is a video frame captured later than the two adjacent video frames; For each pixel in the plurality of pixels included in each of the video frames, a run-length encoding (RLE) compression algorithm is used to compress the pixel value of the pixel in the plurality of video frames to obtain a compressed video.
9. The video device according to claim 8, wherein The compressed video includes: compressed data of each pixel of the plurality of pixels, the compressed data including: at least one pixel value of the pixel, the at least one pixel value including: a compressed pixel value and / or an uncompressed pixel value, a compression position identifier corresponding to each compressed pixel value, and a compressed frame number corresponding to each compressed pixel value; In which, the compressed pixel value is the pixel value of the pixel in at least three consecutive video frames, the compressed position identifier is used to indicate the frame identifier of the first video frame in the at least three video frames to which a corresponding compressed pixel value belongs, and the compressed frame number is used to indicate the total number of at least three video frames to which a corresponding compressed pixel value belongs.
Citation Information
Patent Citations
Image lossless compression and image decompressing method
CN101039374A
Data-modifying run length encoder to avoid data expansion
CN101197578A