Dual-channel single-serial-number real-time merging algorithm based on longest incremental subsequence

By using the longest increasing subsequence algorithm and pseudo-pipeline processing in dual-channel data transmission, the problem of discontinuous serial numbers is solved, processing efficiency and resource utilization are improved, and memory requirements are reduced.

CN118708357APending Publication Date: 2024-09-27CHANGGUANG SATELLITE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410883321.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-03
Publication Date
2024-09-27

AI Technical Summary

Technical Problem

During the dual-channel data transmission process, serial numbers are discontinuous, resulting in complex reorganization and fault tolerance processing required for subsequent processing, resulting in high memory capacity requirements, waste of CPU resources, and long processing time.

Method used

Adopts a dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence, and implements simulated pipeline processing through the block memory pool management module, thread-safe queue module, code stream data reading module, data frame verification module and dual-channel merging module. , perform reading, verification, merging and output simultaneously, reducing memory operations and CPU waiting.

Benefits of technology

Improved CPU resource utilization, reduced processing time, reduced memory usage, and optimized memory operation efficiency through fixed-size block transfer and memory pool management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118708357A
    Figure CN118708357A
Patent Text Reader

Abstract

The invention relates to a dual-channel single-serial-number real-time merging algorithm based on a longest incremental subsequence. The algorithm comprises the following steps: initializing a memory pool; initializing a thread security queue; initializing control parameters; reading an input parameter order; starting double processes to respectively read data of the two code stream files and press the data into corresponding code stream input queues, dequeuing memory blocks from the two code stream input queues, performing format check on single-channel data and searching for a longest incremental subsequence, and combining and outputting the double-channel data to a combination barrier according to serial number incremental in a merge sorting mode; and dequeuing the merging result data from the merging queue, and outputting the data. According to the invention, satellite data is processed by adopting an imitated assembly line mode, and is processed while being read and written out, so that the resource utilization rate of a CPU (Central Processing Unit) is improved; the memory is pooled, and the operation time is short; data transmission on the assembly line can control the total memory usage amount by controlling the size of the buffer area of the assembly line, and the requirement for the memory capacity is lowered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of information technology, and in particular to a dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence. Background Art

[0002] The digital data transmitted from the satellite to the ground and received by the ground receiving station is called a code stream. The code stream is transmitted in frames. The length of each frame is fixed, including the frame protocol header and data. The frame protocol header mainly includes the frame header and the serial number. The adjacent frame headers ensure the integrity of the frame, and the serial number is incremented to ensure the orderly transmission of the data. In order to receive as much data as possible within a limited time, a dual-channel method is usually used for data transmission. This brings a new problem. Before dual-channel data transmission, the data serial number is orderly. After dual-channel transmission, it becomes two files. The serial number of each file is not continuous, and the serial numbers of the two files intersect with each other. For example, the serial number of file 1 is 1, 3, 5, 6..., and the serial number of file 2 is 2, 4, 7... In subsequent processing, the two files need to be reassembled into one file according to the increment of the serial number, and then continue processing.

[0003] During the satellite-to-ground signal transmission process, due to the influence of the environment, the received data may have errors or losses, resulting in serial number mutation or loss. This requires fault tolerance when the two files are reassembled.

[0004] The previous processing method is to merge the two files first, first read the two files into the memory as a whole, then traverse the files and find all the frame data with the correct format, sort them again by serial number and delete the same serial number, reassemble them into a new file in the sorted order, and finally write them to the external memory. This processing method is step-by-step, and the next step needs to wait for the previous step to be completed before it can start. Due to the large amount of data to be transmitted, the memory capacity requirement is also large, generally requiring 2 to 3 times the amount of data to be transmitted; the time to read and write files is relatively long; when reading and writing files, the CPU is idle, wasting resources; in the process of transferring each processing step, it is necessary to apply for and release continuous large-capacity memory several times, and each memory operation takes too long. Summary of the invention

[0005] The present invention aims to solve the technical problems in the prior art and provides a dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence.

[0006] In order to solve the above technical problems, the technical solutions of the present invention are as follows:

[0007] A dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence is proposed. The system applicable to the algorithm includes: block memory pool management module, thread safety queue module, code stream data reading module, data frame verification module, dual-channel merging module and data output module.

[0008] The algorithm consists of the following steps:

[0009] Step 1: The block memory pool management module initializes the memory pool;

[0010] Step 2: The thread-safe queue module initializes the thread-safe queue;

[0011] Step 3: The main program initializes the control parameters;

[0012] Step 4: Read the input parameter order to obtain the dual-channel code stream path and output directory parameters;

[0013] Step 5: The code stream data reading module starts a dual process, reads the code stream data of each channel respectively, and puts the data read into the memory block into the code stream input queue;

[0014] Step 6: The data frame verification module starts a dual process, dequeues memory blocks from the corresponding code stream input queue, performs format verification, and enters the results into the format verification queue;

[0015] Step 7: The dual-channel merging module dequeues memory blocks from the two bitstream input queues, searches for the longest increasing subsequence for the single-channel data and deletes the obviously abnormal (too small or too large) serial number data, then merges the dual-channel data in increasing order of serial number, and enters the result into the merging queue;

[0016] Step 8: The data output module dequeues the merged result data from the merge queue and outputs the data;

[0017] Step 9: The main program loop detects whether the output is completed and outputs the amount of data currently processed by each module until the output is completed.

[0018] In step 2 of the above technical solution, the thread-safe queue includes: a code stream input queue*2, a format check queue*2, and a merge queue*1.

[0019] In step 3 of the above technical solution, the control parameters include: whether the code stream input is completed*2, whether the format check is completed*2, whether the merge is completed*1, whether the output is completed*1, the code stream reading data volume*2, the format check data volume*2, the merge data volume*1, and the output data volume*1.

[0020] In the above technical solution, the block memory pool management module is used to:

[0021] Initialize the initialization parameters such as the capacity of a single memory block, the maximum number of idle blocks, and the maximum usage;

[0022] When the code stream data reading module and the dual-channel merging module apply for memory blocks, they determine whether there are free memory blocks. If there are free memory blocks, they are allocated directly. If not, they determine whether the total amount allocated is less than the maximum usage. If the total amount allocated is less than the maximum usage, they apply for new memory allocation and update the total amount allocated. Otherwise, they wait until the total amount allocated is less than the maximum usage before applying for allocation.

[0023] When the dual-channel merging module and the data output module release memory blocks, they determine whether the number of free blocks in the block memory pool exceeds the maximum idle number. If not, they are added to the block memory pool; otherwise, half of the space in the block memory pool is released and the total amount of allocated memory is updated.

[0024] In the above technical solution, the thread-safe queue module is used to:

[0025] Set the queue capacity;

[0026] When the code stream data reading module, data frame verification module and dual-channel merging module enter the queue, it is determined whether the queue has reached the maximum capacity. If not, it is directly added to the end of the queue, otherwise it waits until it can be added;

[0027] When the data frame verification module, the dual-channel merging module and the data output module are dequeued, it is determined whether the queue is empty. If it is empty, it waits, and if it is not empty, it pops out the first element.

[0028] In the above technical solution, the working process of the code stream data reading module is as follows:

[0029] Step 31: Initialize the code stream path parameters;

[0030] Step 32: Open the code stream file; if it cannot be opened, go to step 38;

[0031] Step 33: Apply for block memory from the block memory pool management module;

[0032] Step 34: Read the code stream data into the block memory;

[0033] Step 35: Update the amount of read data;

[0034] Step 36: Add the block memory to the stream input queue;

[0035] Step 37: Repeat steps 33 to 36 until the file reading is completed;

[0036] Step 38: Set the status of whether the corresponding code stream input is completed to completed, and output the amount of data read.

[0037] In the above technical solution, the workflow of the data frame verification module is:

[0038] Step 41: Initialize the stream input queue and format check queue initialization parameters;

[0039] Step 42: Apply for residual frame memory block;

[0040] Step 43: cyclically checking whether the code stream input is completed and whether the code stream input queue is empty. If both conditions are met, the processing ends, otherwise it indicates that the code stream reading is in progress; if the queue is not empty, the first memory block is popped out;

[0041] Step 44: writing the first memory block into the residual frame memory block in an appending manner;

[0042] Step 45: Perform format check on the data of the residual frame memory block, that is, determine whether the length between two adjacent frame headers is in compliance with the standard, and write the correct format data into the first memory block;

[0043] Step 46: Update the format verification data volume;

[0044] Step 47: Update the residual frame data and move the residual frame data to the beginning of the residual frame memory block;

[0045] Step 48: Put the first memory block into the format inspection queue;

[0046] Step 49: Loop through steps 43 to 48 until both conditions in step 43 are met and the format verification is complete; set the corresponding format verification completion status to completed, output the amount of qualified data, and release the residual frame memory block.

[0047] In the above technical solution, the workflow of the dual-channel merging module is:

[0048] Step 51: Initialize parameters;

[0049] Step 52: Apply for temporary cache 1, temporary cache 2 and output cache;

[0050] Step 53: Initialize two-channel frame data list1, list2, and store the frame data;

[0051] Step 54: Loop to check whether the two lists are empty, check whether the format is complete and whether the format check queue is empty. If all three conditions are met, the data processing of a certain channel is completed;

[0052] Step 55: Check whether the list is empty. If it is empty, it means that the data of this channel has been processed and the next piece of data can be processed;

[0053] Step 56: according to whether the format check is completed and whether the format check queue is empty, the first memory block is dequeued, the data is appended to the temporary cache and the first memory block is released at the same time;

[0054] Step 57: Determine whether the amount of data in the temporary cache meets the minimum amount of data that can be processed. If not, return to step 56 until the condition is met.

[0055] Step 58: extract the frame data and add them to the list, extract the longest increasing subsequence from the list, and then perform a serial number mutation check to delete the frame data with obviously too large or too small serial numbers in the increasing serial numbers;

[0056] Step 59: Execute steps 55 to 58 for another channel;

[0057] Step 510: Compare the data in the two lists, remove the data with smaller serial numbers first, and put them into the output buffer until one of the lists is empty;

[0058] Step 511: determine whether the amount of data in the output buffer can be output, if yes, apply for block memory from the block memory pool management module, remove the data frame header from the output buffer data, and write the newly applied memory block; after the output is completed, put the memory block into the output queue;

[0059] Step 512: Update the merged data volume;

[0060] Step 513: When the three judgment conditions of a channel in step 54 are satisfied at the same time, it means that the processing of this channel is completed;

[0061] Step 514: perform single channel merging, write the data in the list into the output buffer, and execute step 56 at the same time, dequeue the remaining data, and directly remove the frame header and write it into the output buffer, and execute step 511;

[0062] Step 515: the single-channel data processing is completed, the merge completion status is set to completed, the merged data volume is output, and the temporary buffer 1, temporary buffer 2 and output buffer are released.

[0063] In the above technical solution, the workflow of the data output module is:

[0064] Step 61: Initialize output queue parameters;

[0065] Step 62: Loop to determine whether the merge is complete and whether the output queue is empty. If both conditions are met, the output ends.

[0066] Step 63: Otherwise, if the output queue is not empty, the first memory block is dequeued, the first memory block is written into the external memory, and the block memory pool management module is called to release the first memory block;

[0067] Step 64: Update the output data volume;

[0068] Step 65: until both conditions in step 62 are met, the output ends;

[0069] Step 66: Update the output completion status to complete and output the data volume.

[0070] The present invention has the following beneficial effects:

[0071] The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence of the present invention processes satellite data in an imitation pipeline manner, organizes reading, checking, merging and outputting in a pipeline manner, and the data can be processed simultaneously in the above processing steps, and I / O reading and writing are synchronized with processing, and processing can be performed while reading and writing, thereby improving the resource utilization of the CPU and reducing the processing time; at the same time, data is transmitted between various processing modules in blocks of fixed size, the size of the data block is much smaller than the size of the code stream data, the memory operation time is short, and the memory pool is used to manage the block memory, thereby further reducing the memory operation time; data transmission on the pipeline can control the total memory usage by controlling the buffer size of the pipeline, thereby reducing the requirement for the memory capacity. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0073] Figure 1 The figure is a schematic diagram of the overall flow of the dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence of the present invention.

[0074] Figure 2 This is a schematic diagram of the block memory management module workflow.

[0075] Figure 3 This is a diagram of the thread-safe queue module workflow.

[0076] Figure 4 This is a schematic diagram of the working process of the code stream data reading module.

[0077] Figure 5 This is a schematic diagram of the workflow of the data frame verification module.

[0078] Figure 6-1 Schematic diagram of the dual-channel merging module workflow.

[0079] Figure 6-2 This is a schematic diagram of the process of popping up the format inspection queue.

[0080] Figure 6-3 Schematic diagram of the incremental processing flow.

[0081] Figure 6-4 Schematic diagram of the data merging process.

[0082] Figure 6-5 This is a schematic diagram of the single-channel processing flow.

[0083] Figure 6-6 Schematic diagram of the output cache enqueue process.

[0084] Figure 7 This is a schematic diagram of the data output module workflow.

[0085] Figure 8 The figure is a signal flow diagram of the longest increasing subsequence-based dual-channel single serial number real-time merging algorithm of the present invention. DETAILED DESCRIPTION

[0086] The present invention is described in detail below with reference to the accompanying drawings.

[0087] The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence of the present invention is applicable to a system mainly composed of the following six modules that are interconnected, namely: a block memory pool management module, a thread safety queue module, a code stream data reading module, a data frame checking module, a dual-channel merging module and a data output module.

[0088] The modules use a producer-consumer model similar to that in the operating system to process data. The code stream data reading module is the first producer, the data output module is the last consumer, the data frame verification module is both the consumer of the code stream data reading module and the producer of the dual-channel merging module, and the dual-channel merging module is both the consumer of the data frame verification module and the producer of the data output module. The producer-consumer model uses a buffer to exchange products. The algorithm uses a thread-safe queue to simulate the buffer to achieve product exchange. By setting the capacity of the thread-safe queue, the total amount of memory used can be controlled. Products are fixed-size memory blocks. A block memory pool management module is designed to uniformly manage the application and release of block memory, reduce high-frequency memory application and release operations, and save time.

[0089] The code stream data reading module is responsible for reading data from the external storage into the internal memory in the form of blocks in real time. The data frame verification module is responsible for checking the data frame format in real time and passing the qualified data frames to the next module. The dual-channel merging module is responsible for sorting the correctly formatted data frames of the two channels according to the serial numbers, eliminating errors, and merging the dual-channel data. The data output module is responsible for writing the data out of the external storage.

[0090] like Figure 1-5 , Figure 7 , Figure 8 ,as well as Figure 6-1 to Figure 6-6As shown, the overall process of the dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence of the present invention is as follows:

[0091] Step 1: The block memory pool management module initializes the memory pool;

[0092] Step 2: The thread-safe queue module initializes the thread-safe queue (including 2 bitstream input queues, 2 format check queues, and 1 merge queue);

[0093] Step 3: The main program initializes the control parameters, including whether the code stream input is completed*2, whether the format check is completed*2, whether the merge is completed*1, whether the output is completed*1, the code stream read data volume*2, the format check data volume*2, the merge data volume*1, and the output data volume*1.

[0094] Step 4: Read the input parameter order to obtain parameters such as dual-channel code stream path and output directory;

[0095] Step 5: The code stream data reading module starts a dual process, reads the code stream data of each channel respectively, and puts the data read into the memory block into the code stream input queue;

[0096] Step 6: The data frame verification module starts a dual process, dequeues memory blocks from the corresponding code stream input queue, performs format verification, and enters the results into the format verification queue;

[0097] Step 7: The dual-channel merging module dequeues memory blocks from the two bitstream input queues, searches for the longest increasing subsequence for the single-channel data, verifies and deletes the obviously abnormal (too small or too large) serial number data, then merges the dual-channel data in increasing order of serial number, and enters the result into the merging queue;

[0098] Step 8: The data output module dequeues the merged result data from the merge queue and outputs the data;

[0099] Step 9: The main program loop detects whether the output is completed and outputs the amount of data currently processed by each module (i.e., progress display) until the output is completed.

[0100] The following is a detailed description of the workflow of each module in the dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence of the present invention.

[0101] 1. The block memory pool management module workflow is as follows:

[0102] Step 11: Initialize the initialization parameters such as the capacity of a single memory block, the maximum number of idle blocks, and the maximum usage;

[0103] Step 12: When the code stream data reading module and the dual-channel merging module apply for memory blocks, they determine whether there are free memory blocks. If there are free memory blocks, they are allocated directly. If not, they determine whether the total amount allocated is less than the maximum usage. If the total amount allocated is less than the maximum usage, they apply for new memory allocation and update the total amount allocated. Otherwise, they wait until the total amount allocated is less than the maximum usage before applying for allocation.

[0104] Step 13: When the dual-channel merging module and the data output module release memory blocks, it is determined whether the number of free blocks in the block memory pool exceeds the maximum idle number. If not, they are added to the block memory pool; otherwise, half of the space in the block memory pool is released and the total amount of allocated memory is updated.

[0105] 2. The workflow of the thread-safe queue module is as follows:

[0106] Step 21: Set the queue capacity;

[0107] Step 22: When the code stream data reading module, the data frame verification module and the dual-channel merging module enter the queue, it is determined whether the queue has reached the maximum capacity. If not, they are directly added to the end of the queue, otherwise they wait until they can be added;

[0108] Step 23: When the data frame verification module, the dual-channel merging module and the data output module are dequeued, it is determined whether the queue is empty. If it is empty, it waits. If it is not empty, it pops out the first element.

[0109] 3. The working process of the code stream data reading module is as follows:

[0110] Step 31: Initialize the stream path and other parameters;

[0111] Step 32: Open the code stream file; if it cannot be opened, go to step 38;

[0112] Step 33: Apply for block memory from the block memory pool management module;

[0113] Step 34: Read the code stream data into the block memory;

[0114] Step 35: Update the amount of read data;

[0115] Step 36: Add the block memory to the stream input queue;

[0116] Step 37: Repeat steps 33 to 36 until the file reading is completed;

[0117] Step 38: Set the status of whether the corresponding code stream input is completed to completed, and output the amount of data read.

[0118] 4. The workflow of the data frame verification module is as follows:

[0119] Step 41: Initialize the initialization parameters such as the code stream input queue and the format check queue;

[0120] Step 42: Apply for residual frame memory block;

[0121] Step 43: cyclically checking whether the code stream input is completed and whether the code stream input queue is empty. If both conditions are met, the processing ends, otherwise it indicates that the code stream reading is in progress; if the queue is not empty, the first memory block is popped out;

[0122] Step 44: writing the first memory block into the residual frame memory block in an appending manner;

[0123] Step 45: Perform format check on the data of the residual frame memory block, that is, determine whether the length between two adjacent frame headers is compliant, and write the correct format data into the first memory block;

[0124] Step 46: Update the format verification data volume.

[0125] Step 47: Update the residual frame data (the residual frame data is the data where the end of the residual frame data block is less than one frame and needs to be combined with the next input data for further judgment), and move the residual frame data to the beginning of the residual frame memory block;

[0126] Step 48: Put the first memory block into the format inspection queue;

[0127] Step 49: Loop through steps 43 to 48 until both conditions in step 43 are met and the format verification is complete; set the corresponding format verification completion status to completed, output the amount of qualified data, and release the incomplete frame memory block.

[0128] 5. Dual-channel merging module workflow:

[0129] Step 51: Initialize parameters;

[0130] Step 52: Apply for temporary cache 1, temporary cache 2 and output cache;

[0131] Step 53: Initialize two-channel frame data list1, list2, and store the frame data;

[0132] Step 54: Loop to check whether the two lists are empty, check whether the format is complete and whether the format check queue is empty. If all three conditions are met, the data processing of a certain channel is completed.

[0133] Step 55: Check whether the list is empty. If it is empty, it means that the data of this channel has been processed and the next piece of data can be processed;

[0134] Step 56: according to whether the format check is completed and whether the format check queue is empty, the first memory block is dequeued, the data is appended to the temporary cache and the first memory block is released at the same time;

[0135] Step 57: Determine whether the amount of data in the temporary cache meets the minimum amount of data that can be processed. If not, return to step 56 until the condition is met.

[0136] Step 58: extract frame data (mainly serial numbers) and add them to the list, extract the longest increasing subsequence from the list, and then perform a serial number mutation check to delete frame data that is obviously too large or too small in the increasing serial number;

[0137] Step 59: Execute steps 55 to 58 for another channel;

[0138] Step 510: Compare the data in the two lists, remove the data with smaller serial numbers first, and put them into the output buffer until one of the lists is empty;

[0139] Step 511: determine whether the amount of data in the output buffer can be output, if yes, apply for block memory from the block memory pool management module, remove the data frame header from the output buffer data, and write the newly applied memory block; after the output is completed, put the memory block into the output queue;

[0140] Step 512: Update the merged data volume;

[0141] Step 513: When the three judgment conditions of a channel in step 54 are satisfied at the same time, it means that the processing of this channel is completed;

[0142] Step 514: perform single channel merging, write the data in the list into the output buffer, and execute step 56 at the same time, dequeue the remaining data, and directly remove the frame header and write it into the output buffer, and execute step 511;

[0143] Step 515: the single-channel data processing is completed, the merge completion status is set to completed, the merged data volume is output, and the temporary buffer 1, temporary buffer 2 and output buffer are released.

[0144] 6. Data output module workflow

[0145] Step 61: Initialize the output queue and other parameters;

[0146] Step 62: Loop to determine whether the merge is complete and whether the output queue is empty. If both conditions are met, the output ends.

[0147] Step 63: Otherwise, if the output queue is not empty, the first memory block is dequeued, the first memory block is written into the external memory, and the block memory pool management module is called to release the first memory block;

[0148] Step 64: Update the output data volume;

[0149] Step 65: until both conditions in step 62 are met, the output ends;

[0150] Step 66: Update the output completion status to complete and output the data volume.

[0151] In the dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence of the present invention, there are three implementation schemes for obtaining the maximum increasing subsequence:

[0152] (I) Sorting and using the longest common subsequence, time complexity O(n 2 )

[0153] Assume two sequences S1 and S2, S1 is not sorted, and S2 is obtained after S1 is sorted:

[0154] (1) If the last elements of S1 and S2 are equal, then the longest common subsequence of S1 and S2 is equal to the longest common subsequence of {S1 minus the last element} and {S2 minus the last element} plus the last element of S1 and S2 that is equal.

[0155] (2) If the last elements of S1 and S2 are not equal, then the longest common subsequence of S1 and S2 is equal to the longest common subsequence of {S1 minus the last element} and S2 and the longest common subsequence of S1 and {S2 minus the last element}, whichever is larger.

[0156] (3) Assume that C[i, j] represents X i With Y j The longest common subsequence length, then the recursive formula is as follows:

[0157]

[0158] (II) Dynamic programming method is used to solve the problem, with a time complexity of O(n 2 )

[0159] L i Indicates that X i The length of the longest increasing subsequence at the end, then L i The value is equal to

[0160] L i ={max(L j +1)j j <X i

[0161] The final length is equal to L i The maximum value of .

[0162] ​(III) Dynamic programming plus binary search solution, time complexity O(nlog2n)

[0163] Combined with binary search based on dynamic programming.

[0164] d i Represents the minimum value of the last element of the longest increasing subsequence of length i.

[0165] When traversing the original sequence, for each element, if it is larger than the last element in d, add it to the end of d; otherwise, binary search for the first element larger than it in d and replace it with the current element. Finally, the length of d is the longest increasing subsequence.

[0166] The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence of the present invention processes satellite data in an imitation pipeline manner, organizes reading, checking, merging and outputting in a pipeline manner, and the data can be processed simultaneously in the above processing steps, and I / O reading and writing are synchronized with processing, and processing can be performed while reading and writing, thereby improving the resource utilization of the CPU and reducing the processing time; at the same time, data is transmitted between various processing modules in blocks of fixed size, the size of the data block is much smaller than the size of the code stream data, the memory operation time is short, and the memory pool is used to manage the block memory, thereby further reducing the memory operation time; data transmission on the pipeline can control the total memory usage by controlling the buffer size of the pipeline, thereby reducing the requirement for the memory capacity.

[0167] Obviously, the above embodiments are merely examples for the purpose of clear explanation, and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the invention.

Claims

1. A real-time merging algorithm of dual-channel single serial number based on the longest increasing subsequence, It is characterized in that The system to which the algorithm is applicable includes: a block memory pool management module, a thread-safe queue module, a code stream data reading module, a data frame verification module, a dual-channel merging module and a data output module that are interconnected; The algorithm consists of the following steps: Step 1: The block memory pool management module initializes the memory pool; Step 2: The thread-safe queue module initializes the thread-safe queue; Step 3: The main program initializes the control parameters; Step 4: Read the input parameter order to obtain the dual-channel code stream path and output directory parameters; Step 5: The code stream data reading module starts a dual process to read the code stream data of each channel respectively, and puts the data read into the memory block into the code stream input queue; Step 6: The data frame verification module starts a dual process, dequeues memory blocks from the corresponding code stream input queue, performs format verification, and enters the results into the format verification queue; Step 7: The dual-channel merging module dequeues memory blocks from the two bitstream input queues, finds the longest increasing subsequence for the single-channel data, verifies and deletes the obviously abnormal serial number data, then merges the dual-channel data in increasing order of serial number, and enters the result into the merging queue; Step 8: The data output module dequeues the merged result data from the merge queue and outputs the data; Step 9: The main program loop detects whether the output is completed and outputs the amount of data currently processed by each module until the output is completed.

2. According to claim 1, the dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence, It is characterized in that In step 2, the thread-safe queue includes: 2 bitstream input queues, 2 format check queues, and 1 merge queue.

3. The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence according to claim 1, It is characterized in that In step 3, the control parameters include: whether the code stream input is completed*2, whether the format check is completed*2, whether the merge is completed*1, whether the output is completed*1, the code stream read data volume*2, the format check data volume*2, the merge data volume*1, and the output data volume*1.

4. The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence according to any one of claims 1 to 3, It is characterized in that The block memory pool management module is used to: Initialize the capacity of a single memory block, the maximum number of idle blocks, and the maximum usage initialization parameters; When the code stream data reading module and the dual-channel merging module apply for memory blocks, they determine whether there are free memory blocks. If there are free memory blocks, they are directly allocated. If not, they determine whether the total amount allocated is less than the maximum usage. If the total amount allocated is less than the maximum usage, they apply for new memory allocation and update the total amount allocated. Otherwise, wait until the total amount allocated is less than the maximum usage before applying for allocation; When the dual-channel merging module and the data output module release memory blocks, they determine whether the number of free blocks in the block memory pool exceeds the maximum idle number. If not, they are added to the block memory pool; otherwise, half of the space in the block memory pool is released and the total amount of allocated memory is updated.

5. The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence according to any one of claims 1 to 3, It is characterized in that The thread-safe queue module is used to: Set the queue capacity; When the code stream data reading module, data frame verification module and dual-channel merging module enter the queue, it is determined whether the queue has reached the maximum capacity. If not, it is directly added to the end of the queue, otherwise it waits until it can be added; When the data frame verification module, the dual-channel merging module and the data output module are dequeued, it is determined whether the queue is empty. If it is empty, it waits, and if it is not empty, it pops out the first element.

6. The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence according to any one of claims 1 to 3, It is characterized in that The workflow of the code stream data reading module is as follows: Step 31: Initialize the code stream path parameters; Step 32: Open the code stream file; if it cannot be opened, go to step 38; Step 33: Apply for block memory from the block memory pool management module; Step 34: Read the code stream data into the block memory; Step 35: Update the amount of read data; Step 36: Add the block memory to the stream input queue; Step 37: Repeat steps 33 to 36 until the file reading is completed; Step 38: Set the status of whether the corresponding code stream input is completed to completed, and output the amount of data read.

7. The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence according to any one of claims 1 to 3, It is characterized in that The workflow of the data frame verification module is: Step 41: Initialize the stream input queue and format check queue initialization parameters; Step 42: Apply for residual frame memory block; Step 43: cyclically checking whether the code stream input is completed and whether the code stream input queue is empty. If both conditions are met, the processing ends, otherwise it indicates that the code stream reading is in progress; if the queue is not empty, the first memory block is popped out; Step 44: writing the first memory block into the residual frame memory block in an appending manner; Step 45: Perform format check on the data of the residual frame memory block, that is, determine whether the length between two adjacent frame headers is in compliance with the standard, and write the correct format data into the first memory block; Step 46: Update the format verification data volume; Step 47: Update the residual frame data and move the residual frame data to the beginning of the residual frame memory block; Step 48: Put the first memory block into the format inspection queue; Step 49: Loop through steps 43 to 48 until both conditions in step 43 are met and the format verification is complete; set the corresponding format verification completion status to completed, output the amount of qualified data, and release the residual frame memory block.

8. The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence according to any one of claims 1 to 3, It is characterized in that The workflow of the dual-channel merging module is: Step 51: Initialize parameters; Step 52: Apply for temporary cache 1, temporary cache 2 and output cache; Step 53: Initialize two-channel frame data list1, list2, and store the frame data; Step 54: Loop to check whether the two lists are empty, check whether the format is complete and whether the format check queue is empty. If all three conditions are met, the data processing of a certain channel is completed; Step 55: Check whether the list is empty. If it is empty, it means that the data of this channel has been processed and the next piece of data can be processed; Step 56: according to whether the format check is completed and whether the format check queue is empty, the first memory block is dequeued, the data is appended to the temporary cache and the first memory block is released at the same time; Step 57: Determine whether the amount of data in the temporary cache meets the minimum amount of data that can be processed. If not, return to step 56 until the condition is met. Step 58: extract the frame data and add them to the list, extract the longest increasing subsequence from the list, and then perform a serial number mutation check to delete the frame data with obviously too large or too small serial numbers in the increasing serial numbers; Step 59: Execute steps 55 to 58 for another channel; Step 510: Compare the data in the two lists, remove the data with smaller serial numbers first, and put them into the output buffer until one of the lists is empty; Step 511: determine whether the amount of data in the output buffer can be output, if yes, apply for block memory from the block memory pool management module, remove the data frame header from the output buffer data, and write the newly applied memory block; after the output is completed, put the memory block into the output queue; Step 512: Update the merged data volume; Step 513: When the three judgment conditions of a channel in step 54 are satisfied at the same time, it means that the processing of this channel is completed; Step 514: perform single channel merging, write the data in the list into the output buffer, and execute step 56 at the same time, dequeue the remaining data, and directly remove the frame header and write it into the output buffer, and execute step 511; Step 515: the single-channel data processing is completed, the merge completion status is set to completed, the merged data volume is output, and the temporary buffer 1, temporary buffer 2 and output buffer are released.

9. The dual-channel single serial number real-time merging algorithm based on the longest increasing subsequence according to any one of claims 1 to 3, It is characterized in that The workflow of the data output module is: Step 61: Initialize output queue parameters; Step 62: Loop to determine whether the merge is complete and whether the output queue is empty. If both conditions are met, the output ends. Step 63: Otherwise, if the output queue is not empty, the first memory block is dequeued, the first memory block is written into the external memory, and the block memory pool management module is called to release the first memory block; Step 64: Update the output data volume; Step 65: until both conditions in step 62 are met, the output ends; Step 66: Update the output completion status to complete and output the data volume.