An image code flow control method suitable for a low-speed synchronous interface
By adjusting the quantization Q value and frame length statistics to optimize image coding, the problems of delay and bit rate fluctuation in image data transmission in low-speed synchronous channels were solved, resulting in a more stable image display effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- THE 54TH RESEARCH INSTITUTE OF CHINA ELECTRONICS TECHNOLOGY GROUP CORPORATION
- Filing Date
- 2024-11-28
- Publication Date
- 2026-07-21
AI Technical Summary
Image data transmission in low-speed synchronous channels suffers from coding rate fluctuations, leading to buffering delays and unstable image quality, especially for static images, which cannot meet transmission requirements.
By adjusting the quantization Q value based on the average frame length of the most recent frames, combined with frame length statistics and caching mechanisms, the image encoding and transmission process is optimized, reducing latency and frame rate jitter, and improving display smoothness.
It effectively reduces the number of buffers in the synchronous sending interface, reduces encoding and sending latency, and improves the smoothness and quality of image display.
Smart Images

Figure CN119815019B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to an image stream control method suitable for low-speed synchronous interfaces in the field of image transmission, particularly applicable to low-speed image stream control using synchronous interface transmission. The invention adjusts the encoder quantization Q value based on the average frame length of the most recent frames of encoded data to adapt it to the transmission requirements of low-speed synchronous channels, reducing transmission latency and improving image display quality. Background Technology
[0002] Low-speed image data is acquired in standard definition (SD) format at a frame rate of 25 frames per second. During compression, it is encoded into intra-frame coded I-frames and inter-frame coded P-frames. Typically, the data size of an I-frame is much larger than that of a P-frame, leading to fluctuations in the received image encoding bitrate. The low-speed synchronization channel transmits data at a fixed rate. To meet the requirements of the synchronization channel, the encoded image data needs to be buffered, and the image quantization Q-value is adjusted according to the amount of buffered data. This ensures that the fluctuating encoded image data can be transmitted at a constant rate while minimizing the Q-value, reducing image distortion, and improving image quality.
[0003] Adjusting the image quantization Q-value by buffering data requires the encoder to buffer a certain amount of data, thus increasing additional time latency. When the image data is static, even with the minimum Q-value, the P-frame data size is insufficient for transmission. Summary of the Invention
[0004] To avoid the problems described in the background art, this invention proposes an image bitstream control method suitable for low-speed synchronization interfaces. This method uses the average frame length of the most recent frames as the basis for Q-value adjustment, reducing the number of buffers in the synchronization transmission interface and decreasing encoding and transmission latency. By uniformly padding data at the end of each image frame, image frame rate jitter is reduced, improving the smoothness of reception and display.
[0005] The technical solution adopted in this invention is as follows:
[0006] A method for controlling image bitstreams using a low-speed synchronization interface, comprising the following steps:
[0007] (1) The image encoding module encodes the original image frame output by the image acquisition module based on the quantization Q value, and generates an encoded image frame to be output to the frame length statistics module; wherein, during the first encoding process, the quantization Q value is the initial quantization value;
[0008] (2) The frame length statistics module calculates the actual average frame length of the recently set frame number encoded image frame based on the current frame length and the frame length in the historical records, and then outputs the actual average frame length to the Q value adjustment module, while outputting the encoded image frame to the inter-thread buffer module.
[0009] (3) The Q-value adjustment module adjusts the quantization Q-value of subsequent encoding processing according to the actual average frame length, returns to step (1), and executes step (4) at the same time.
[0010] (4) The inter-thread buffer module buffers the encoded image frames. After the sending frame module retrieves the encoded image frames from the inter-thread buffer module, it assembles them into synchronous data frames and outputs them through the synchronous data sending module under the control of the synchronous timer interrupt.
[0011] Complete image stream control suitable for low-speed synchronous interfaces.
[0012] Furthermore, the process of adjusting the quantized Q value in step (3) is as follows:
[0013] The actual average frame length of the encoded image frame is compared with the theoretical average frame length of the low-speed synchronization interface. When the actual average frame length is greater than the theoretical average frame length, the quantization Q value is increased. When the actual average frame length is between the theoretical average frame length and the adjustment threshold, the quantization Q value remains unchanged. When the actual average frame length is less than the adjustment threshold, the quantization Q value is decreased and the amount of subsequent encoded data is increased.
[0014] Furthermore, in step (2), when calculating the actual average frame length of the most recently set frame number encoded image frame, a frame length calculation structure is used. The frame length calculation structure includes five parameters: frame length array, number of records, record position, total frame length, and average frame length.
[0015] The frame length array contains multiple units, with n units. Each unit stores a frame length value in bytes. The number of records indicates the number of valid frame length values in the frame length array. The record position indicates the storage position of the next frame length value. The total frame length indicates the sum of valid frame length values in the frame length array. The average frame length indicates the average value of valid frame length values in the frame length array.
[0016] The average frame length calculation process includes:
[0017] During initialization, the frame length array, number of records, record position, total frame length, and average frame length are cleared to 0;
[0018] After receiving the encoded image frame from the image encoding module, the frame length statistics module extracts the frame length m bytes of the encoded image frame and records it in the corresponding position of the frame length array. The total frame length is increased by m; the frame length value of the current unit in the frame length array is decreased; the record position is increased by 1, and then it is determined that if the record position is greater than or equal to n, the record position is set to 0; if the number of records is less than n, the number of records is increased by 1; the total frame length is divided by the number of records to obtain the average frame length of the most recently set number of frames; where m is the set value.
[0019] Furthermore, the frame sending module in step (4) has a data filling mechanism. When there are not enough encoded image frames, the idle data area after the encoded image frames in the current synchronization data frame is filled. When there are no encoded image frames in the inter-thread buffer, the synchronization data frame is composed entirely of filling data.
[0020] Compared with the prior art, the present invention has the following advantages:
[0021] (1) The present invention uses the average frame length of the most recent frames as the basis for Q value adjustment, thereby reducing the number of synchronous transmission interface buffers and reducing the encoding transmission time delay.
[0022] (2) The filling data of the present invention is evenly distributed at the end of each frame of image data, which reduces frame rate jitter and improves the smoothness of image reception and display. Attached Figure Description
[0023] Figure 1 This is a block diagram illustrating the working principle of an image stream control method applicable to low-speed synchronization interfaces according to the present invention. Detailed Implementation
[0024] The invention will be further explained below with reference to the accompanying drawings.
[0025] like Figure 1 As shown, an image bitstream control method suitable for low-speed synchronization interfaces includes the following steps:
[0026] (1) The image encoding module encodes the original image frame output by the image acquisition module based on the quantization Q value and generates an encoded image frame to be output to the frame length statistics module; wherein, during the first encoding process, the quantization Q value is the initial quantization value.
[0027] (2) The frame length statistics module calculates the actual average frame length of the recently set frame number encoded image frame based on the current frame length and the frame length in the historical records, and then outputs the actual average frame length to the Q value adjustment module for Q value adjustment, while outputting the encoded image frame to the inter-thread buffer module.
[0028] In step (2), when calculating the actual average frame length of the most recently encoded image frames, a frame length calculation structure is used. The frame length calculation structure includes five parameters: frame length array, number of records, record position, total frame length, and average frame length, which are used to record and calculate the average frame length of the most recent frames.
[0029] The frame length statistics module's frame length array contains n units, each capable of storing a frame length value in one byte. The record count represents the number of valid frame length values in the array, with a valid value range of 0 to n. The record position indicates the storage location of the next frame length value, with a valid value range of 0 to n-1. The total frame length represents the sum of valid frame length values in the array. The average frame length represents the average value of the valid frame length values in the array.
[0030] The steps for calculating the average frame length include:
[0031] During initialization, the frame length array, number of records, record position, total frame length, and average frame length are cleared to 0.
[0032] Upon receiving the encoded image frame from the image encoding module, the frame length statistics module extracts the frame length (m bytes) of that encoded image frame and records it in the corresponding position of the frame length array, increasing the total frame length by m. The frame length value of the current cell in the frame length array is then decreased. The recording position is incremented by 1. If the recording position is greater than or equal to n, it is set to 0; otherwise, the number of records is increased by 1. The total frame length is divided by the number of records to obtain the average frame length of the most recent frames.
[0033] (3) The Q-value adjustment module adjusts the quantization Q-value of the subsequent encoded image according to the average frame length to ensure that the subsequently encoded data can meet the requirements of synchronous channel transmission; then it returns to step (1) and executes step (4).
[0034] The process of adjusting the quantized Q value in step (3) is as follows:
[0035] The actual average frame length of the encoded image frames is compared with the theoretical average frame length of the low-speed synchronization interface. When the actual average frame length is greater than the theoretical average frame length, the quantization Q value is increased to reduce the amount of subsequent encoded data. When the actual average frame length is between the theoretical average frame length and the adjustment threshold, the quantization Q value remains unchanged. When the actual average frame length is less than the adjustment threshold, the quantization Q value is decreased to improve the quality of subsequent images and increase the amount of subsequent encoded data.
[0036] The legal quantization Q-value range for an image encoder is 2 to 31. For a synchronous channel with a transmission rate of 384,000 bits per second, 25 frames of images need to be acquired and encoded per second, resulting in a theoretical average frame length of 1920 bytes. The adjustment threshold is set to 70% of the theoretical average frame length, i.e., 1344 bytes. When the actual average frame length is greater than 1920 bytes, the quantization Q-value increases by 1, with a maximum not exceeding 31; when the actual average frame length is less than or equal to 1920 bytes but greater than 1344 bytes, the quantization Q-value remains unchanged; when the actual average frame length is less than or equal to 1344 bytes, the quantization Q-value decreases by 1, with a minimum not lower than 2. The adjustment frequency is once per frame.
[0037] (4) The inter-thread caching module caches the encoded image frames. After the sending frame assembly module retrieves the encoded image frames from the inter-thread caching module, it assembles them into synchronous data frames and outputs them through the synchronous data sending module under the control of the synchronous timer interrupt.
[0038] In step (4), the encoded image frame is sent to the synchronous sending thread through the inter-thread buffer module. The sending frame module of the synchronous sending thread converts the encoded image frame into a synchronous data frame and outputs it to the synchronous data sending module. The synchronous data sending module outputs the synchronous data frame according to the timer interrupt.
[0039] The sending frame assembly module incorporates a data padding mechanism to ensure sufficient padding data is available to occupy the synchronization channel when encoded image data is insufficient. Padding data is applied only when the inter-thread buffer module lacks encoded image frames; it fills the idle data area after the encoded image data in the current synchronization data frame. When there are no encoded image frames in the inter-thread buffer module, the synchronization data frame consists entirely of padding data.
Claims
1. A method for controlling image bitstreams suitable for low-speed synchronization interfaces, characterized in that, Including the following steps: (1) The image encoding module encodes the original image frame output by the image acquisition module based on the quantization Q value, and generates an encoded image frame to be output to the frame length statistics module; wherein, during the first encoding process, the quantization Q value is the initial quantization value; (2) The frame length statistics module calculates the actual average frame length of the recently set frame number encoded image frame based on the current frame length and the frame length in the historical records, and then outputs the actual average frame length to the Q value adjustment module, while outputting the encoded image frame to the inter-thread buffer module. (3) The Q-value adjustment module adjusts the quantization Q-value of subsequent encoding processing according to the actual average frame length, returns to step (1), and executes step (4). (4) The inter-thread buffer module buffers the encoded image frames. After the sending frame module retrieves the encoded image frames from the inter-thread buffer module, it forms a synchronous data frame and outputs it through the synchronous data sending module under the control of the synchronous timer interrupt. In step (2), when calculating the actual average frame length of the most recently set frame number encoded image frame, a frame length calculation structure is used. The frame length calculation structure includes five parameters: frame length array, number of records, record position, total frame length, and average frame length. The frame length array contains multiple units, with n units. Each unit stores a frame length value in bytes. The number of records indicates the number of valid frame length values in the frame length array. The record position indicates the storage position of the next frame length value. The total frame length indicates the sum of valid frame length values in the frame length array. The average frame length indicates the average value of valid frame length values in the frame length array. The average frame length calculation process includes: During initialization, the frame length array, number of records, record position, total frame length, and average frame length are cleared to 0; After receiving the encoded image frame from the image encoding module, the frame length statistics module extracts the frame length m bytes of the encoded image frame. It subtracts the original frame length value of the cell pointed to by the recording position in the frame length array from the total frame length, then records the frame length m bytes in that cell, increasing the total frame length by m. The recording position is incremented by 1. Then, if the recording position is greater than or equal to n, the recording position is set to 0; if the number of records is less than n, the number of records is incremented by 1. The total frame length is divided by the number of records to obtain the average frame length of the most recently set number of frames; where m is the set value. Complete image stream control suitable for low-speed synchronous interfaces.
2. The image bitstream control method for low-speed synchronization interfaces according to claim 1, characterized in that, The process of adjusting the quantized Q value in step (3) is as follows: Compare the actual average frame length of the encoded image frames with the theoretical average frame length of the low-speed synchronization interface; when the actual average frame length is greater than the theoretical average frame length, increase the quantization Q value; When the actual average frame length is between the theoretical average frame length and the adjustment threshold, the quantization Q value remains unchanged; When the actual average frame length is less than the adjustment threshold, the quantization Q value is reduced and the amount of subsequent encoded data is increased.
3. The image bitstream control method for low-speed synchronization interfaces according to claim 1, characterized in that, In step (4), the frame sending module has a data filling mechanism. When there are not enough encoded image frames, the idle data area after the encoded image frames in the current synchronization data frame is filled. When there are no encoded image frames in the inter-thread buffer, the synchronization data frame is composed entirely of filling data.