A Linux lighting master control synchronous playback method and device
By generating encapsulated signals, recording timestamps and their intervals under the Linux system, performing timing processing and frame sequence management, and combining a multi-frame buffer pipeline strategy, the delay problem of synchronous playback of the lighting master controller was solved, high-precision synchronous playback was achieved, and the stability and reliability of the system were improved.
Patent Information
- Application Number
- CN202411599759.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2044-11-11
AI Technical Summary
Under the Linux system, the synchronous playback of the lighting controller has uncontrollable thread scheduling delays, which may cause frame errors that are discernible to the human eye during the performance, affecting the performance effect.
By generating encapsulated signals, recording timestamps and their intervals, performing timing processing and frame sequence management, calculating compensation time, and using multi-frame buffer pipeline strategies and frame sequence numbers for synchronous playback, the playback synchronization of all lighting controllers is ensured.
It achieves high-precision synchronous playback of multiple lighting controllers, improves the stability and reliability of the playback system, reduces dependence on external high-precision clock sources, reduces system hardware costs, and supports lighting control systems of different scales and complexities.
Smart Images

Figure CN119562419B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of audio control, and in particular to a Linux lighting master control synchronous playback method and device. Background Art
[0002] In floodlighting control systems, multiple lighting controllers are often required to achieve integrated control of lights in a larger area, and the lighting controllers must be synchronized when playing lighting effects. Limited by physical wiring and costs, GPS satellite timing is often used for synchronization. At the same time, the functions of lighting controllers are becoming increasingly diverse, requiring them to perform complex tasks including operational interaction, network communication, video decoding, image processing, wiring mapping, data construction and transmission. Based on stability and software development environment requirements, applications are generally developed based on the Linux system. Although Linux excels in performance, it is not a hard real-time system and has uncontrollable delays in thread scheduling. When faced with high real-time requirements such as synchronous playback, if certain measures are not taken to ensure real-time synchronization, the performance may show frame errors that are discernible to the human eye (a frame of image from different controllers is displayed at different times), which will seriously affect the performance effect. Summary of the Invention
[0003] The embodiments of the present invention provide a Linux lighting master controller synchronous playback method and device, which realize high-precision synchronous playback of multiple Linux lighting master controllers, thereby improving the quality and reliability of the overall lighting effect.
[0004] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application provides a Linux lighting master control synchronous playback, comprising:
[0005] Generate several groups of packaged signals according to NMEA information and pulse signals;
[0006] receiving a plurality of groups of packaged signals, and recording a group of timestamps in each group of packaged signals and a plurality of groups of timestamp intervals between adjacent groups of packaged signals;
[0007] If the intervals of a number of consecutive timestamps that are not less than a preset number are all within a preset range, the timestamp corresponding to the last timestamp interval is taken as the playback timestamp;
[0008] Performing timing processing and frame sequence management on the playback timestamp in sequence, and obtaining compensation time according to the start time of the timing processing and the start time of the frame sequence management;
[0009] Generate a frame number of a Linux light master control frame according to the playback timestamp and the compensation time;
[0010] According to the multi-frame buffer pipeline strategy and the frame sequence number, the Linux lighting master frame is selected for synchronous playback.
[0011] In a possible implementation of the first aspect, generating several groups of packaged signals according to the NMEA information and the pulse signal specifically includes:
[0012] Extract the timestamp and signal quality information from the NMEA information;
[0013] Recording the initial time when the pulse signal is received and the offset timing is started, and obtaining the offset delay based on the time difference between the preselected sending time and the initial time;
[0014] The timestamp, signal quality information and offset delay are encapsulated to generate several groups of encapsulated signals and the several groups of encapsulated signals are sent to the Linux lighting master at the sending time.
[0015] In a possible implementation manner of the first aspect, encapsulating the timestamp, the signal quality information, and the offset value to generate several groups of encapsulated signals specifically includes:
[0016] A preset identification field, a year field extracted from the timestamp, a month field extracted from the timestamp, a day field extracted from the timestamp, an hour field extracted from the timestamp, a minute field extracted from the timestamp, a second field extracted from the timestamp, the offset value, the number of satellites, and a check value are encapsulated to generate a set of encapsulated signals; the check value is the accumulated byte size of the other fields except the identification field and the check value field.
[0017] In a possible implementation of the first aspect, if no less than a preset number of consecutive groups of timestamp intervals are within a preset range, taking the timestamp corresponding to the last group of timestamp intervals as the playback timestamp, the method further includes:
[0018] Obtain several groups of timestamps sent from the MCU to the Linux lighting master controller in the historical data as a historical timestamp set;
[0019] A normal distribution analysis is performed on the historical timestamp set, and a preset range is determined according to the analysis result.
[0020] In a possible implementation of the first aspect, performing a normal distribution analysis on the historical timestamp set and determining a preset range based on the analysis result specifically includes:
[0021] Counting the value range of the historical timestamp set, and dividing the value range into a plurality of value intervals according to a preset interval interval;
[0022] Counting the number and proportion of timestamps corresponding to several value intervals, performing normal distribution analysis based on the average value of the historical timestamp set, and determining two value intervals according to the preset sample concentration ratio;
[0023] The preset range is determined according to the two value intervals.
[0024] In a possible implementation of the first aspect, sequentially performing timing processing and frame sequence management on the playback timestamp, and obtaining the compensation time according to the start time of the timing processing and the start time of the frame sequence management, specifically includes:
[0025] The playback timestamp is sequentially subjected to timing processing and frame sequence management, and the time difference between the start time of the frame sequence management and the start time of the timing processing is used as the compensation time.
[0026] In a possible implementation of the first aspect, generating a frame number of a Linux light master control frame according to the playback timestamp and the compensation time specifically includes:
[0027] The time difference between the playback timestamp and the preset comparison time is used as an offset value;
[0028] Perform division and remainder operations on the sum of the offset value, the offset delay, and the compensation time to obtain a frame number of the Linux lighting master control frame.
[0029] In a possible implementation of the first aspect, before receiving the plurality of groups of encapsulated signals and recording a group of timestamps in each group of the encapsulated signals and a plurality of groups of timestamp intervals between adjacent groups of the encapsulated signals, the method further includes:
[0030] Allocate CPU cores, set scheduling strategies and priorities for timing processing thread, frame sequence management thread, video decoding thread, image processing thread, mapping processing thread, data transmission thread, logic control thread and other threads respectively; there are several CPU cores; the scheduling strategies include first-in-first-out strategy, polling scheduling strategy and other strategies;
[0031] The priority of the timing processing thread, the frame sequence management thread and the number transmission thread is the highest priority; the priority of the video decoding thread, the image processing thread and the mapping processing thread is the second highest priority; the priority of the logic control thread is the lowest priority; the priority of the other threads is a custom priority.
[0032] In a possible implementation of the first aspect, the multi-frame buffer pipeline strategy specifically includes:
[0033] Set the number of buffered frames;
[0034] According to the number of thread types involved in selecting the Linux light master frame for synchronous playback, several levels of pipelines are set; a level of pipeline is set between every two threads of different types.
[0035] A second aspect of the embodiments of the present application provides a Linux lighting master control synchronous playback device, comprising:
[0036] MCU packaging module, used to generate several groups of packaged signals based on NMEA information and pulse signals;
[0037] a main control recording module, configured to receive a plurality of groups of packaged signals, and record a group of timestamps in each group of packaged signals and a plurality of groups of timestamp intervals between adjacent groups of packaged signals;
[0038] A master timestamp control module is configured to take the timestamp corresponding to the last set of timestamp intervals as the playback timestamp if the intervals of a number of consecutive timestamp intervals (not less than a preset number) are all within a preset range;
[0039] A main control compensation module is used to perform timing processing and frame sequence management on the playback timestamp in sequence, and obtain compensation time according to the start time of the timing processing and the start time of the frame sequence management;
[0040] A master frame sequence number module is used to generate a frame sequence number of the Linux lighting master frame according to the playback timestamp and the compensation time;
[0041] The master control playback module is used to select the Linux lighting master control frame for synchronous playback according to the multi-frame buffer pipeline strategy and the frame sequence number.
[0042] Compared with the prior art, the embodiments of the present invention provide a Linux lighting master controller synchronous playback method and device, which generates an encapsulated signal based on NMEA information and pulse signals for subsequent time synchronization and data transmission; receives the encapsulated signal and records the timestamp and its interval for subsequent time synchronization analysis; screens the appropriate playback timestamp by the timestamp interval to ensure the accuracy of time synchronization; performs timing processing and frame sequence management on the playback timestamp, calculates the compensation time, and ensures high-precision synchronization of playback; generates a frame number based on the playback timestamp and compensation time for subsequent frame selection and playback; finally, selects a frame for playback based on the multi-frame buffer pipeline strategy and the frame number to ensure playback synchronization of all lighting master controllers.
[0043] By using the above steps and technical means, high-precision synchronized playback of multiple lighting controllers can be achieved on a Linux system. This method not only improves the stability and reliability of the playback system, but also enables the synchronized control of complex lighting effects within the constraints of cost and physical wiring. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 This is a flowchart of a Linux lighting master control synchronous playback method provided by an embodiment of the present invention;
[0045] Figure 2 1 is a schematic diagram of a confirmation process for a preset range provided by an embodiment of the present invention;
[0046] Figure 3 1 is a schematic diagram of a compensation time calculation method provided by an embodiment of the present invention;
[0047] Figure 4 is a schematic diagram of a multi-frame buffer pipeline strategy provided by one embodiment of the present invention;
[0048] Figure 5 The present invention is a schematic diagram of a Linux lighting master control synchronous playback device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0050] To solve the above problem, see Figure 1 An embodiment of the present invention provides a Linux lighting master control synchronous playback, including:
[0051] S10. Generate several groups of packaged signals according to the NMEA information and the pulse signal.
[0052] S11. Receive several groups of packaged signals, and record a group of timestamps in each group of packaged signals and several groups of timestamp intervals between adjacent groups of packaged signals.
[0053] S12: If the intervals of a number of consecutive timestamps that are not less than a preset number are all within a preset range, take the timestamp corresponding to the last timestamp interval as the playback timestamp.
[0054] S13, performing timing processing and frame sequence management on the playback timestamp in sequence, and obtaining compensation time according to the start time of the timing processing and the start time of the frame sequence management.
[0055] S14. Generate a frame number of a Linux lighting master control frame according to the play timestamp and the compensation time.
[0056] S15. Select the Linux lighting master frame for synchronous playback according to the multi-frame buffer pipeline strategy and the frame sequence number.
[0057] S10 generates a packaged signal containing a timestamp and related data for subsequent time synchronization and data transmission; S11 receives the packaged signal and records the timestamp and its interval for subsequent time synchronization and playback; S13 performs timing processing and frame sequence management on the playback timestamp, calculates the compensation time, and ensures high-precision synchronization of the master playback; S14 generates a frame number based on the playback timestamp and compensation time for subsequent frame selection and playback; S15 selects frames for synchronous playback based on the multi-frame buffer pipeline strategy and frame number to ensure playback synchronization of all lighting master controllers.
[0058] In practical applications, an MCU (microcontroller with excellent real-time performance) can be placed between the GPS module and the SoC (Linux lighting control unit, equivalent to running Linux). This MCU captures the PPS (high-precision pulse per second) signal, generates an interrupt on its rising edge, and initiates offset timing with an accuracy of 1ms. When the MCU receives the NMEA message, it extracts the timestamp and satellite number (signal quality) information. It also obtains the offset of the NMEA message's timestamp relative to the initial moment (the initial moment is when the MCU receives the pulse signal and starts offset timing). These three pieces of information are packaged into a fixed-byte packet and sent to the SoC via the UART serial port. This approach eliminates the need to modify the Linux kernel. The R1 deviation between different devices is due to the MCU processing error, as the MCU has no other processing tasks. Generally, the deviation can be controlled to less than 1µs. It should be noted that R1 refers to the time offset of the timestamp sent by the source GPS module.
[0059] This solution improves the time synchronization accuracy between multiple lighting controllers, which is particularly important for highly coordinated light shows. Furthermore, by optimizing the time synchronization mechanism and thread management strategy, the overall stability and reliability of the playback system are enhanced. Furthermore, software algorithms are used to achieve high-precision time synchronization, reducing reliance on external high-precision clock sources and lowering system hardware costs. Support for a multi-frame buffer pipeline strategy provides the system with excellent flexibility and scalability, adapting to the needs of lighting control systems of varying scale and complexity.
[0060] Exemplarily, the generating of several groups of packaged signals according to the NMEA information and the pulse signal specifically includes:
[0061] Extract the timestamp and signal quality information from the NMEA information;
[0062] Recording the initial time when the pulse signal is received and the offset timing is started, and obtaining the offset delay based on the time difference between the preselected sending time and the initial time;
[0063] The timestamp, signal quality information and offset delay are encapsulated to generate several groups of encapsulated signals and the several groups of encapsulated signals are sent to the Linux lighting master at the sending time.
[0064] The above steps can be executed by the MCU, which then sends the encapsulated data packet to the SoC (Linux lighting controller) via the UART serial port. The detailed structure of the encapsulated signal is shown in Table 1. The checksum calculates the byte sum of multiple fields in the encapsulated signal to ensure that the data is not lost or corrupted during transmission. If the checksum calculated by the receiver does not match the checksum sent by the sender, it indicates that an error occurred during data transmission. This ensures that the generated data packet maintains its integrity and correctness during transmission. The use of the checksum significantly improves data transmission reliability.
[0065] Through the above steps, you can generate several sets of packaged signals based on NMEA information and pulse signals, and send these signals to the Linux lighting master at the pre-selected sending time. This ensures the accuracy of time synchronization and the reliability of the system.
[0066] Table 1 Composition of package signals
[0067]
[0068] Exemplarily, encapsulating the timestamp, signal quality information, and offset value to generate several groups of encapsulated signals specifically includes:
[0069] A preset identification field, a year field extracted from the timestamp, a month field extracted from the timestamp, a day field extracted from the timestamp, an hour field extracted from the timestamp, a minute field extracted from the timestamp, a second field extracted from the timestamp, the offset value, the number of satellites, and a check value are encapsulated to generate a set of encapsulated signals; the check value is the accumulated byte size of the other fields except the identification field and the check value field.
[0070] The encapsulated signal generation process can be summarized as follows: Extract the year, month, day, hour, minute, and second fields from the timestamp. Calculate the time difference between the timestamp and the initial time and convert it to milliseconds. Calculate the byte sum of all fields except the identifier and checksum, and use the result as the checksum. Finally, encapsulate all fields into a binary data packet according to the format shown in Table 1.
[0071] These steps enable high-precision time synchronization, ensuring that time deviations between devices are kept to the microsecond level. This approach requires no modifications to the Linux kernel and leverages the real-time capabilities of the MCU to achieve efficient synchronization control.
[0072] Exemplarily, if the intervals of a plurality of consecutive timestamps that are not less than a preset number are all within a preset range, before taking the timestamp corresponding to the last timestamp interval as the playback timestamp, the method further includes:
[0073] Obtain several groups of timestamps sent from the MCU to the Linux lighting master controller in the historical data as a historical timestamp set;
[0074] A normal distribution analysis is performed on the historical timestamp set, and a preset range is determined according to the analysis result.
[0075] Ideally, the interval between each group should be 1000ms (milliseconds). In reality, due to the response of the playback system, there is a fluctuation of -8ms to 10ms, and the average value may be 1000.28ms. In order to eliminate the impact of this fluctuation, according to Figure 2 The normal distribution analysis results use a preset range of ±4ms to determine the sample size. Samples are then filtered based on this range. If the intervals between five consecutive timestamps are within the preset range of 1000 ± 4ms, the most recent set is used. The calculated sample average is 1000.28ms, which deviates only 0.28ms from the ideal value of 1000ms, demonstrating good complementarity between the intervals.
[0076] These steps ensure the accuracy and stability of timestamps and improve the reliability of time synchronization. This method utilizes the statistical characteristics of historical data and effectively filters out abnormal timestamp intervals.
[0077] Exemplarily, performing normal distribution analysis on the historical timestamp set and determining the preset range according to the analysis result specifically includes:
[0078] Counting the value range of the historical timestamp set, and dividing the value range into a plurality of value intervals according to a preset interval interval;
[0079] Counting the number and proportion of timestamps corresponding to several value intervals, performing normal distribution analysis based on the average value of the historical timestamp set, and determining two value intervals according to the preset sample concentration ratio;
[0080] The preset range is determined according to the two value intervals.
[0081] When performing normal distribution analysis, you can obtain the minimum and maximum values of the timestamp interval. Divide the range into several intervals based on the preset interval interval. Count the number of timestamps in each interval and calculate its proportion of the total number of timestamps. Calculate the mean and standard deviation of the timestamp intervals. Finally, determine two intervals based on the confidence level as the boundaries of the preset range.
[0082] In practical applications, Figure 2 For example, we can use a collection of historical timestamps as samples. The sample range is then divided into 20 equal intervals of 1ms. The number of samples in each of these 20 intervals and their percentages are calculated, revealing that 99.5% of the samples are concentrated in the 996-1004ms range (within the 1000±4ms range, which allows for the persistence of vision effect and does not affect inter-device lighting synchronization). A small number of larger fluctuations fall outside this range and are discretely distributed. From the samples, we can observe that sudden changes (exceeding 4ms) typically occur within 2 to 4 adjacent samples and are not continuous. Therefore, we can select five groups of samples for filtering (all five groups are stable data, and the last group is used because it is closest to the timestamp in the program).
[0083] See also Figure 3 Exemplarily, the performing timing processing and frame sequence management on the playback timestamp in sequence, and obtaining the compensation time according to the start time of the timing processing and the start time of the frame sequence management, specifically includes:
[0084] The playback timestamp is sequentially subjected to timing processing and frame sequence management, and the time difference between the start time of the frame sequence management and the start time of the timing processing is used as the compensation time.
[0085] A software response compensation strategy is further implemented for the transmission of timestamps between system threads. From the moment the system receives an external timestamp, a compensation timer accurate to 1ms is started. Compensation is applied when the timestamp is finally applied to eliminate this delay difference. After being processed by the timing processing thread, the timestamp is passed to the frame sequence management thread for application. The frame sequence management thread converts the timestamp into an offset time relative to January 1, 2000, 00:00:00 (or any other preset reference time), adds the compensation time Td, and uses it to calculate the frame number of the final output lighting effect.
[0086] These steps ensure the accuracy and stability of timestamps and improve the reliability of time synchronization. This method leverages the statistical properties of historical data to effectively filter out abnormal timestamp intervals and further improves system accuracy by calculating compensation time through timing processing and frame sequence management.
[0087] Exemplarily, generating a frame number of a Linux light master control frame according to the playback timestamp and the compensation time specifically includes:
[0088] The time difference between the playback timestamp and the preset comparison time is used as an offset value;
[0089] Perform division and remainder operations on the sum of the offset value, the offset delay, and the compensation time to obtain a frame number of the Linux lighting master control frame.
[0090] When a pulse signal is received and offset timing starts, the initial time is recorded. This initial time can be a fixed time point when the MCU is started, or a time point recorded each time the MCU receives a pulse signal.
[0091] When the Linux lighting control (SOC) receives the playback timestamp, it records the current time (the sending time). It then calculates the difference between the sending time and the initial time, which is the offset delay. It then adds the offset value To, the offset delay Tc, and the compensation time Td to obtain the total offset time. This total offset time is then divided and modulo-calculated to obtain the frame number of the Linux lighting control frame.
[0092] For a more specific calculation process, please refer to the following example:
[0093] 1. Get the playback timestamp (consisting of year, month, day, hour, minute, and second, output once every second) Ti;
[0094] 2. Convert the playback timestamp to the offset value To relative to 00:00:00 on January 1, 2000, in milliseconds;
[0095] 3. Get the current playback frame rate Fs (representing how long it takes to send a frame, in milliseconds / frame) and the total number of frames of the lighting effect Fq;
[0096] 4. Calculate the frame number Fn currently being played using "Fn = ((To + Tc + Td) / Fs) % Fq" ( / is the division sign, % is the remainder); (Tc is the offset delay from the GPS sending the playback timestamp to the software capturing it, in milliseconds; Td is the compensation time from capturing the playback timestamp to starting frame sequence calculation, in milliseconds).
[0097] 5. Read the lighting effect frame with frame number Fn for playback. (When the master controller selects the effect frame for playback, it needs to go through steps such as video decoding, image processing, wiring mapping, and data packet transmission, resulting in an uncertain delay Ts (in milliseconds)).
[0098] Through the above steps, the frame number of the Linux lighting master frame can be generated based on the playback timestamp and compensation time. This method ensures the accuracy of time synchronization and can effectively manage the frame number, thereby improving the stability and reliability of the system.
[0099] Exemplarily, before receiving several groups of the encapsulated signals and recording a group of timestamps in each group of the encapsulated signals and several groups of timestamp intervals between adjacent groups of the encapsulated signals, the method further includes:
[0100] Allocate CPU cores, set scheduling strategies and priorities for timing processing thread, frame sequence management thread, video decoding thread, image processing thread, mapping processing thread, data transmission thread, logic control thread and other threads respectively; there are several CPU cores; the scheduling strategies include first-in-first-out strategy, polling scheduling strategy and other strategies;
[0101] The priority of the timing processing thread, the frame sequence management thread and the number transmission thread is the highest priority; the priority of the video decoding thread, the image processing thread and the mapping processing thread is the second highest priority; the priority of the logic control thread is the lowest priority; the priority of the other threads is a custom priority.
[0102] Current SOC solutions (Linux lighting controllers or those running Linux systems) often use multi-core CPUs. Binding key threads to CPU cores and setting thread scheduling strategies and priorities can effectively reduce the uncertainty of thread response delays. For example, in this lighting controller, the SOC can use the RK3328 (a quad-core CPU). The playback software primarily consists of a timing processing thread, a frame sequence management thread, a video decoding thread, an image processing thread, a data transmission thread, a logic control thread, and other threads. Using the priority strategy shown in Table 2, combined with other strategies in this method, can achieve excellent synchronized playback results.
[0103] In Table 2, a larger priority value represents a higher priority, with 99 being the highest. SCHED_FIFO is the first-in-first-out (FIFO) scheduling strategy, SCHED_RR is the round-robin scheduling strategy, and SCHED_OTHER is other scheduling strategies (usually the default scheduling strategy).
[0104] Table 2 Critical thread priority strategy
[0105]
[0106] The above steps, on the one hand, appropriately set thread priorities and scheduling policies to ensure timely execution of critical threads: use the SCHED_FIFO or SCHED_RR scheduling policies with a higher priority; use the SCHED_OTHER scheduling policy with a lower priority. Furthermore, these steps bind critical threads to specific CPU cores, reducing latency caused by thread switching between cores and response time variations in the Linux lighting control application layer, resulting in a more accurate compensation time Td and improving the system's real-time performance and stability.
[0107] In other words, the above steps ensure that different threads run efficiently on a multi-core CPU, with critical threads receiving the highest priority, thereby improving system performance and stability and achieving excellent synchronized playback. This method is particularly suitable for applications requiring high real-time performance and low latency, such as playback systems composed of Linux lighting controllers.
[0108] See also Figure 4 , exemplarily, the multi-frame buffer pipeline strategy specifically includes:
[0109] Set the number of buffered frames;
[0110] According to the number of thread types involved in selecting the Linux light master frame for synchronous playback, several levels of pipelines are set; a level of pipeline is set between every two threads of different types.
[0111] Different Linux lighting masters in the playback system can generate consistent frame numbers at relatively consistent times. However, from the generation of the frame number to the display of the lighting effect, they still need to go through processes that require a lot of calculations, such as video decoding, image processing, mapping processing, and data transmission. If single-frame sequential processing is used, the time occupied by each process will fluctuate due to the uncertainty of system task scheduling, which may result in uneven playback (that is, fluctuations in frame intervals lead to uneven effects). When multi-frame buffer pipeline processing is used, the uncertainty of the time taken by each process can be controlled, so that the reserved time for the number-generating process is more sufficient, which can effectively suppress uneven playback. In the Linux lighting master control involved in this case, 10-frame buffer processing and 3-level pipeline processing can be used.
[0112] 10 frames is an empirical value and can be changed in different playback systems based on resources and performance. In this example, buffering 10 frames is based on actual measurements and can offset fluctuations caused by thread scheduling and resource preemption. Furthermore, the time required to buffer 10 frames during pre-playback is acceptable to the system application (200-600ms).
[0113] 3-stage pipeline such as Figure 4As shown, video decoding to image processing is the first stage, image processing to mapping is the second stage, and mapping to data transmission is the third stage. These four processing steps have a certain sequence and each takes up a certain amount of CPU usage (in this example, a single step takes up approximately 20-90% of a single-core CPU). The CPU in this example has four cores, divided into a three-stage pipeline. Each core can execute four processing steps concurrently, forming a pipeline to avoid instability caused by resource congestion.
[0114] Through the above steps, a multi-frame buffer pipeline strategy can be implemented, which can reduce the response time deviation of the Linux lighting master application layer program and improve the real-time performance and stability of the system.
[0115] Compared with the prior art, the embodiment of the present invention provides a Linux lighting master controller synchronous playback method, which generates an encapsulated signal based on NMEA information and pulse signals for subsequent time synchronization and data transmission; receives the encapsulated signal and records the timestamp and its interval for subsequent time synchronization analysis; screens the appropriate playback timestamp by the timestamp interval to ensure the accuracy of time synchronization; performs timing processing and frame sequence management on the playback timestamp, calculates the compensation time, and ensures high-precision synchronization of playback; generates a frame number based on the playback timestamp and compensation time for subsequent frame selection and playback; finally, selects a frame for playback based on the multi-frame buffer pipeline strategy and the frame number to ensure playback synchronization of all lighting master controllers.
[0116] By using the above steps and technical means, high-precision synchronized playback of multiple lighting controllers can be achieved on a Linux system. This method not only improves the stability and reliability of the playback system, but also enables the synchronized control of complex lighting effects within the constraints of cost and physical wiring.
[0117] The embodiment of the present application provides a Linux lighting master synchronization playback device, including an MCU packaging module, a master recording module, a master timestamp module, a master compensation module, a master frame sequence number module, and a master playback module. Figure 5 In actual applications, you can choose to place the MCU encapsulation module in the MCU, and place the master recording module, master timestamp module, master compensation module, master frame number module and master playback module in the SOC (which can run Linux). The SOC here is a Linux lighting master control.
[0118] The MCU encapsulation module is used to generate several groups of encapsulated signals based on NMEA information and pulse signals.
[0119] The main control recording module is used to receive several groups of packaged signals, record a group of timestamps in each group of packaged signals and several groups of timestamp intervals between adjacent groups of packaged signals.
[0120] The master timestamp module is configured to take the timestamp corresponding to the last group of timestamp intervals as the playback timestamp if the intervals of a number of consecutive timestamp intervals that are not less than a preset number are all within a preset range.
[0121] The main control compensation module is used to perform timing processing and frame sequence management on the playback timestamp in sequence, and obtain the compensation time according to the start time of the timing processing and the start time of the frame sequence management.
[0122] The master frame sequence number module is used to generate the frame sequence number of the Linux lighting master frame according to the playback timestamp and the compensation time.
[0123] The master control playback module is used to select the Linux lighting master control frame for synchronous playback according to the multi-frame buffer pipeline strategy and the frame sequence number.
[0124] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment and will not be described again here.
[0125] Compared with the prior art, the embodiment of the present invention provides a Linux lighting master synchronous playback device, which generates an encapsulated signal based on NMEA information and pulse signals for subsequent time synchronization and data transmission; receives the encapsulated signal and records the timestamp and its interval for subsequent time synchronization analysis; screens the appropriate playback timestamp by the timestamp interval to ensure the accuracy of time synchronization; performs timing processing and frame sequence management on the playback timestamp, calculates the compensation time, and ensures high-precision synchronization of playback; generates a frame number based on the playback timestamp and compensation time for subsequent frame selection and playback; finally, selects a frame for playback based on the multi-frame buffer pipeline strategy and the frame number to ensure playback synchronization of all lighting master controllers.
[0126] By using the above steps and technical means, high-precision synchronized playback of multiple lighting controllers can be achieved on a Linux system. This method not only improves the stability and reliability of the playback system, but also enables the synchronized control of complex lighting effects within the constraints of cost and physical wiring.
[0127] An embodiment of the present application provides a computer-readable storage medium, which includes a stored computer program. When the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned Linux lighting master control synchronous playback method.
[0128] The computer device may be a computing device such as a smartphone, tablet computer, desktop computer, or cloud server. The computer device may include, but is not limited to, a processor and memory. Those skilled in the art will appreciate that the diagrams are merely examples of computer devices and do not limit the computer device. The computer device may include more or fewer components than shown, or a combination of certain components, or different components. For example, the computer device may also include input / output devices, network access devices, etc.
[0129] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0130] In some embodiments, the memory may be an internal storage unit of the computer device, such as a hard disk or memory of the computer device. In other embodiments, the memory may also be an external storage device of the computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card, etc. Furthermore, the memory may also include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of the computer program. The memory may also be used to temporarily store data that has been output or is to be output.
[0131] An embodiment of the present application provides a computer program product. When the computer program product is run on a computer device, the computer device implements the steps in the above-mentioned various method embodiments when executing the computer program product.
[0132] In several embodiments provided in the present application, it is understood that each box in the flow chart or block diagram can represent a part of a module, program segment or code, and the part of the module, program segment or code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which depends on the functions involved.
[0133] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0134] The above is a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A Linux lighting master control synchronous playback method, characterized in that: include: Generate several groups of packaged signals according to NMEA information and pulse signals; receiving a plurality of groups of packaged signals, and recording a group of timestamps in each group of packaged signals and a plurality of groups of timestamp intervals between adjacent groups of packaged signals; If the intervals of a plurality of consecutive timestamp groups, not less than a preset number, are all within a preset range, the timestamp corresponding to the interval of the last timestamp group is taken as the playback timestamp; wherein, when the intervals of the timestamp groups are all within the preset range, the latest timestamp group from the consecutive timestamp groups is taken as the playback timestamp; performing timing processing and frame sequence management on the playback timestamp in sequence, and obtaining a compensation time based on the start time of the timing processing and the start time of the frame sequence management; wherein the frame sequence management is a thread for converting the timestamp into an offset time relative to a preset reference time, and adding the compensation time to calculate the frame sequence number; Generate a frame number of the Linux lighting master frame based on the playback timestamp and the compensation time; wherein the time difference between the playback timestamp and the preset comparison time is used as the offset value; perform a division operation and a remainder operation on the sum of the offset value, the offset delay and the compensation time to obtain the frame number of the Linux lighting master frame; wherein the initial time when the pulse signal is received and the offset timing is started is recorded; obtain the sending time when the Linux lighting master receives the playback timestamp; and use the time difference between the sending time and the initial time as the offset delay; According to the multi-frame buffer pipeline strategy and the frame sequence number, the Linux lighting master frame is selected for synchronous playback; wherein the multi-frame buffer pipeline strategy includes setting the number of buffered frames; setting a number of pipeline stages according to the number of thread types involved in selecting the Linux lighting master frame for synchronous playback; and setting a pipeline stage between every two threads of different types.
2. A Linux lighting master control synchronous playback method as claimed in claim 1, characterized in that: The method of generating several groups of packaged signals according to the NMEA information and the pulse signal specifically includes: Extract the timestamp and signal quality information from the NMEA information; Recording the initial time when the pulse signal is received and the offset timing is started, and obtaining the offset delay based on the time difference between the preselected sending time and the initial time; The timestamp, signal quality information and offset delay are encapsulated to generate several groups of encapsulated signals and the several groups of encapsulated signals are sent to the Linux lighting master at the sending time.
3. A Linux lighting master control synchronous playback method as described in claim 2, characterized in that: Encapsulating the timestamp, signal quality information, and offset value to generate a plurality of groups of encapsulated signals specifically includes: A preset identification field, a year field extracted from the timestamp, a month field extracted from the timestamp, a day field extracted from the timestamp, an hour field extracted from the timestamp, a minute field extracted from the timestamp, a second field extracted from the timestamp, an offset value, the number of satellites, and a check value are encapsulated to generate a set of encapsulated signals; the check value is the accumulated byte size of the other fields except the identification field and the check value field; wherein the time difference between the playback timestamp and the preset comparison time is used as the offset value.
4. A Linux lighting master control synchronous playback method as claimed in claim 1, characterized in that: Before taking the timestamp corresponding to the last set of timestamp intervals as the playback timestamp if the intervals of the consecutive timestamp intervals of not less than the preset number are all within the preset range, the method further includes: Obtain several groups of timestamps sent from the MCU to the Linux lighting master controller in the historical data as a historical timestamp set; A normal distribution analysis is performed on the historical timestamp set, and a preset range is determined according to the analysis result.
5. A Linux lighting master control synchronous playback method as claimed in claim 4, characterized in that: The performing normal distribution analysis on the historical timestamp set and determining the preset range according to the analysis result specifically includes: Counting the value range of the historical timestamp set, and dividing the value range into a plurality of value intervals according to a preset interval interval; Counting the number and proportion of timestamps corresponding to several value intervals, performing normal distribution analysis based on the average value of the historical timestamp set, and determining two value intervals according to the preset sample concentration ratio; The preset range is determined according to the two value intervals.
6. A Linux lighting master control synchronous playback method as claimed in claim 1, characterized in that: The timing processing and frame sequence management are sequentially performed on the playback timestamp, and the compensation time is obtained according to the start time of the timing processing and the start time of the frame sequence management, specifically including: The playback timestamp is sequentially subjected to timing processing and frame sequence management, and the time difference between the start time of the frame sequence management and the start time of the timing processing is used as the compensation time.
7. A Linux lighting master control synchronous playback method as claimed in claim 1, characterized in that: Before receiving the plurality of groups of packaged signals and recording a group of timestamps in each group of packaged signals and a plurality of groups of timestamp intervals between adjacent groups of packaged signals, the method further includes: Allocate CPU cores, set scheduling strategies and priorities for timing processing thread, frame sequence management thread, video decoding thread, image processing thread, mapping processing thread, data transmission thread, logic control thread and other threads respectively; there are several CPU cores; the scheduling strategies include first-in-first-out strategy, polling scheduling strategy and other strategies; The priority of the timing processing thread, the frame sequence management thread and the number transmission thread is the highest priority; the priority of the video decoding thread, the image processing thread and the mapping processing thread is the second highest priority; the priority of the logic control thread is the lowest priority; the priority of the other threads is a custom priority.
8. A Linux lighting master control synchronous playback device, characterized in that: include: MCU packaging module, used to generate several groups of packaged signals based on NMEA information and pulse signals; a main control recording module, configured to receive a plurality of groups of packaged signals, and record a group of timestamps in each group of packaged signals and a plurality of groups of timestamp intervals between adjacent groups of packaged signals; A master timestamp control module is configured to, if the intervals of a plurality of consecutive timestamp groups (not less than a preset number) are all within a preset range, take the timestamp corresponding to the last interval of the timestamp group as the playback timestamp; wherein, when the intervals of the plurality of timestamp groups are all within the preset range, take the latest one of the plurality of consecutive timestamp groups as the playback timestamp; A main control compensation module is used to sequentially perform timing processing and frame sequence management on the playback timestamp, and obtain a compensation time based on the start time of the timing processing and the start time of the frame sequence management; wherein the frame sequence management is a thread for converting the timestamp into an offset time relative to a preset reference time and adding the compensation time to calculate the frame sequence number; The master frame number module is used to generate a frame number of the Linux lighting master frame according to the playback timestamp and the compensation time; wherein the time difference between the playback timestamp and the preset comparison time is used as the offset value; the sum of the offset value, the offset delay and the compensation time is divided and modulo operations are performed to obtain the frame number of the Linux lighting master frame; wherein the initial time when the pulse signal is received and the offset timing is started is recorded; the sending time when the Linux lighting master receives the playback timestamp is obtained; and the time difference between the sending time and the initial time is used as the offset delay; A master playback module is used to select the Linux lighting master frame for synchronous playback according to a multi-frame buffer pipeline strategy and the frame sequence number; wherein the multi-frame buffer pipeline strategy includes setting the number of buffered frames; According to the number of thread types involved in selecting the Linux light master frame for synchronous playback, several levels of pipelines are set; a level of pipeline is set between every two threads of different types.
Citation Information
Patent Citations
Method and system for remotely and real-time playing and synchronously controlling light emitting diode (LED) lamp light
CN102186275A
Automobile electronic control unit signal synchronous acquisition method, electronic equipment, server and storage medium
CN111130674A