CN-121996565-A - Method for reading uncompressed YUV file and related equipment
Abstract
The invention discloses a method for reading uncompressed YUV files and related equipment, relating to the technical field of data transmission, wherein the method comprises the following steps of creating Memory YUV data blocks; parallel start-up And for each reading, reading data by acquiring Full semaphore of a target memory YUV data block, and releasing the Empty semaphore of the memory YUV data block after reading until all YUV frame data are output. The invention ensures that the working thread cannot write data into the memory YUV data block which is not read yet, and simultaneously ensures that the data processing module can only read the effective data which has been written, thereby realizing the reliability and safety of data read-write operation in a multi-thread concurrency environment and ensuring the continuity and accuracy of video signal output.
Inventors
- Shan Linwei
- WANG LIFANG
- MAO KE
- XU FUXING
Assignees
- 北京数字电视国家工程实验室有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20251229
Claims (10)
- 1. A method of reading an uncompressed YUV file, comprising: Creation of The method comprises the steps of storing YUV data blocks, and setting a Full semaphore and an Empty semaphore for each YUV data block, wherein the initial value of all Full semaphores is 0, and the initial value of all Empty semaphores is 1; Parallel start-up Each working thread is allocated with a unique sequence number, and based on the allocated sequence number, each working thread circularly reads corresponding YUV frame data in a hard disk file in a memory mapping mode and writes the corresponding YUV frame data into a corresponding memory YUV data block, and simultaneously realizes writing synchronization by acquiring the Empty semaphore and the release Full semaphore of the memory YUV data block, And Are all positive integers, the total number of the two is equal to the positive integer, Is that Integer multiples of (2); and circularly reading YUV frame data from the memory YUV data blocks in sequence and outputting the YUV frame data, for each reading, reading data by acquiring Full semaphore of the target memory YUV data block, and releasing the Empty semaphore of the memory YUV data block after reading until all YUV frame data are output.
- 2. The method for reading uncompressed YUV files by signal source device according to claim 1, wherein the sequence number is The data processing process of the working thread of (1) comprises the following steps: To be used for As the starting YUV frame number , wherein, Is that To the point of Is an integer of (2); According to the current YUV frame number Calculating the offset of the YUV frame corresponding to the serial number in the hard disk file; mapping a file area corresponding to YUV frame data in a hard disk file into a user space memory in a memory mapping mode based on the offset, and acquiring a mapped memory address; According to the current YUV frame number Calculating the sequence number of the YUV data block of the target memory , wherein, ; Obtain serial number of The Empty semaphore of the memory YUV data block; copying YUV frame data mapped into user space memory address to sequence number Is stored in the memory YUV data block; Release sequence number is The Full semaphore of the memory YUV data block; the current YUV frame number Updated to And repeatedly executing the steps from calculating the offset to releasing the Full signal quantity until all YUV frames are processed.
- 3. The method for reading uncompressed YUV files by a signal source device according to claim 2, wherein the process of circularly reading YUV frame data and outputting the YUV frame data comprises the steps of: initializing YUV frame sequence number to be read and output as ; According to the current YUV frame number Calculating the corresponding memory YUV data block sequence number , wherein, ; Obtain serial number of The Full semaphore of the memory YUV data block; Reading sequence number as The stored YUV frame data in the memory YUV data block is outputted; Release sequence number is The Empty semaphore of the memory YUV data block; YUV frame number And increasing, and repeatedly executing the steps from calculating the corresponding memory block sequence number to releasing the Empty semaphore until all YUV frame data are output.
- 4. A method of reading an uncompressed YUV file according to any one of claims 1 to 3, further comprising: And performing reading performance test on a plurality of groups of different k and N combined configurations, and selecting the k and N combined configuration with the highest reading rate as a final working parameter according to test results.
- 5. The system for reading the uncompressed YUV file is characterized by comprising a creation module, a writing module and an output module; The creation module is used for creating The method comprises the steps of storing YUV data blocks, and setting a Full semaphore and an Empty semaphore for each YUV data block, wherein the initial value of all Full semaphores is 0, and the initial value of all Empty semaphores is 1; The writing module is used for parallel starting Each working thread circularly reads corresponding YUV frame data in a hard disk file in a memory mapping mode and writes the corresponding YUV frame data into a corresponding memory YUV data block based on the allocated sequence number, and simultaneously realizes writing synchronization by acquiring the Empty semaphore and the release Full semaphore of the memory YUV data block And Are all positive integers, the total number of the two is equal to the positive integer, Is that Integer multiples of (2); The output module is used for circularly reading YUV frame data from the memory YUV data blocks in sequence and outputting the YUV frame data, for each reading, reading the data by acquiring the Full semaphore of the target memory YUV data block, and releasing the Empty semaphore of the memory YUV data block after reading until all YUV frame data are output.
- 6. The system for reading uncompressed YUV files by signal source equipment according to claim 5 wherein the sequence number is The data processing process of the working thread of (1) comprises the following steps: To be used for As the starting YUV frame number , wherein, Is that To the point of Is an integer of (2); According to the current YUV frame number Calculating the offset of the YUV frame corresponding to the serial number in the hard disk file; mapping a file area corresponding to YUV frame data in a hard disk file into a user space memory in a memory mapping mode based on the offset, and acquiring a mapped memory address; According to the current YUV frame number Calculating the sequence number of the YUV data block of the target memory , wherein, ; Obtain serial number of The Empty semaphore of the memory YUV data block; copying YUV frame data mapped into user space memory address to sequence number Is stored in the memory YUV data block; Release sequence number is The Full semaphore of the memory YUV data block; the current YUV frame number Updated to And repeatedly executing the steps from calculating the offset to releasing the Full signal quantity until all YUV frames are processed.
- 7. The system for reading uncompressed YUV files by a source device according to claim 6, wherein the process of circularly reading YUV frame data and outputting the same comprises: initializing YUV frame sequence number to be read and output as ; According to the current YUV frame number Calculating the corresponding memory YUV data block sequence number , wherein, ; Obtain serial number of The Full semaphore of the memory YUV data block; Reading sequence number as The stored YUV frame data in the memory YUV data block is outputted; Release sequence number is The Empty semaphore of the memory YUV data block; YUV frame number And increasing, and repeatedly executing the steps from calculating the corresponding memory block sequence number to releasing the Empty semaphore until all YUV frame data are output.
- 8. The system for reading uncompressed YUV files according to any one of claims 5-7 further comprising a testing module for performing a reading performance test on a plurality of groups of different k and N combined configurations, and selecting the k and N combined configuration with the highest reading rate as a final working parameter according to the test result.
- 9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing a method of reading an uncompressed YUV file according to any one of claims 1 to 4 when the computer program is executed.
- 10. A computer readable storage medium, characterized in that the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements a method of reading an uncompressed YUV file according to any one of claims 1 to 4.
Description
Method for reading uncompressed YUV file and related equipment Technical Field The invention relates to the technical field of data transmission, in particular to a method for reading uncompressed YUV files and related equipment. Background In the operation mode of a video signal source, a common way is to read a video signal file from a hard disk file, process the video signal file, and output the processed video signal file to a device under test. In a specific application scenario, for example, when a test signal is provided for a video encoder, a video signal source is required to output the most original uncompressed video signal so as to facilitate objective analysis and evaluation of the encoding capability of the video encoder, and meanwhile, the test standards of some countries and communities also clearly specify that the uncompressed video signal needs to be used as the test signal. However, non-compressed video signal files require extremely high sustained read rates from hard disk to memory under high resolution conditions, such as 8K or 10K resolution. Taking 8Kp60 YUV420 format file as an example, the required reading rate is more than 3GBps (24 Gbps). If the actual reading rate cannot meet the bandwidth requirement of the output signal, stable real-time output of the uncompressed video signal cannot be ensured. Therefore, how to realize fast real-time reading of the uncompressed video signal to meet the requirement of high bandwidth output becomes a technical problem to be solved. The prior art is generally optimized from two levels for the need to increase the hard disk file read rate. The first level is to employ a multi-line Cheng Bingfa read strategy. The whole reading throughput rate can be remarkably improved by carrying out multithreading reading on the hard disk file. This approach avoids the efficiency bottleneck that may exist with single-threaded sequential reads, allowing multiple threads to read different portions of a file in parallel, thus fully exploiting the potential bandwidth of the hard disk input and output. The second level relates to the specific input-output operation mode of file reading. In most of the existing video signal file reading schemes, a standard file reading input/output operation interface is commonly adopted for implementation. This method is applicable in the case of smaller data volume or low rate requirement. However, the above prior art has significant drawbacks in dealing with extremely high read rate requirements. The multi-wire Cheng Douqu strategy, while promoting concurrency, does not address the inherent overhead on the underlying data transfer path. Conventional file read i/o operations generate a large amount of i/o overhead when the data read rate is very high. Although these overheads are managed by the operating system floor, the impact on application performance is significant. The root cause is that standard file read input output operation needs to allocate a temporary memory in kernel space of the operating system, read data from the hard disk to the kernel space memory, and copy the data from the kernel space memory to the user space memory for application. This process involves at least two memory copy operations. When the data size is huge and the bandwidth requirement is extremely high, the additional memory copy operation consumes a large amount of CPU cycles and memory bandwidth, and becomes a key bottleneck for restricting the further improvement of the reading efficiency. Therefore, a new technical scheme is needed, so that the path cost of data transferred between storage and memory is fundamentally reduced while the concurrent advantage of multiple threads is maintained, and the accurate synchronization between read-write operations is ensured, thereby realizing the reliable real-time reading of the high-bandwidth uncompressed video file. Disclosure of Invention The invention aims to solve the technical problems of the prior art, and particularly provides a method for reading an uncompressed YUV file and related equipment, which comprises the following steps: 1) In a first aspect, the present invention provides a method for reading an uncompressed YUV file, which specifically adopts the following technical scheme: Creation of The method comprises the steps of storing YUV data blocks, and setting a Full semaphore and an Empty semaphore for each YUV data block, wherein the initial value of all Full semaphores is 0, and the initial value of all Empty semaphores is 1; Parallel start-up Each working thread is allocated with a unique sequence number, and based on the allocated sequence number, each working thread circularly reads corresponding YUV frame data in a hard disk file in a memory mapping mode and writes the corresponding YUV frame data into a corresponding memory YUV data block, and simultaneously realizes writing synchronization by acquiring the Empty semaphore of the memory YUV data block and releasing the Full semapho