Frame header positioning and decoding method suitable for SPDIF interface
By setting the maximum and minimum pulse width thresholds in the SPDIF interface and combining the dual threshold method, the problem of frame head positioning and decoding errors is solved, and the robustness and accuracy of signal resolution are improved.
Patent Information
- Application Number
- CN202510603365.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-12
- Publication Date
- 2025-08-12
AI Technical Summary
The prior art in the frame head positioning and BMC decoding process in the SPDIF interface, the positioning and decoding error rates are high due to the change in the signal duty cycle.
The maximum pulse width threshold and minimum pulse width threshold are set in the information flow, and the level pulse width sampling point is recorded through the high-frequency clock, the maximum pulse width buffer and minimum pulse width buffer are updated in real time, the pulse width threshold is calculated dynamically, and the frame head is identified and audio data is decoded in combination with the dual threshold method.
It improves the robustness of signal resolution, reduces the probability of decoding errors, and realizes flexible frame head positioning and audio data decoding.
Smart Images

Figure CN120472914A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of audio processing, and in particular to a frame header positioning and decoding method applicable to an SPDIF interface. Background Art
[0002] SPDIF is a digital audio interface protocol jointly launched by Sony and Philips. Its frame header uses special encoding and the data uses Bi-Phase Mark Coding (BMC). Bi-Phase Mark Coding is a self-synchronizing serial data transmission encoding method that embeds clock information through level jumps.
[0003] The frame structure of SPDIF audio transmission includes a header, audio data, ancillary data, status information, and more. During the decoding process, the header pattern must be compared. When a matching pattern is detected, it is identified as the header and subsequent parsing of the audio data and ancillary information begins. Existing technology uses a separate header detection algorithm to identify the header, generate a positioning signal, and then begin parsing the BMC stream data. The BMC stream uses a level register to obtain the minimum pulse width sample point. At each SPDIF edge change, the level count value is compared with a threshold value obtained from the minimum pulse width point to decode the data.
[0004] In actual applications, the following reasons can cause the SPDIF duty cycle to vary: first, the SPDIF signal is affected by the transmission medium's inherent load and noise interference; second, the input SPDIF signal is processed by filters and some pre-processing circuits, resulting in inconsistent level conversion rates. That is, the signal switches from low to high and from high to low at different rates or at different rates; third, the decoding system requires high-frequency clock synchronization to filter out glitches and metastable information. These factors cause the duty cycle of the bitstream signal to vary, affecting the positioning and judgment of the frame header and the accuracy of BMC decoding. Summary of the Invention
[0005] In view of the above problems, the present invention provides a frame header positioning and decoding method suitable for the SPDIF interface, which locates the frame header position and parses the data by setting the maximum pulse width threshold and the minimum pulse width threshold in the information stream, and dynamically calculates and determines the pulse width threshold as the sampling rate changes, thereby reducing the probability of decoding errors caused by duty cycle changes and improving the robustness of signal analysis.
[0006] In a first aspect, the present invention provides a frame header positioning and decoding method suitable for an SPDIF interface, comprising the following steps: obtaining a signal stream and using a high-frequency clock to record sampling points of a level pulse width in each time window, and updating a maximum pulse width buffer and a minimum pulse width buffer in real time to obtain a maximum pulse width value and a minimum pulse width value; setting a maximum pulse width threshold and a minimum pulse width threshold for the maximum pulse width value and the minimum pulse width value based on a threshold algorithm; identifying a frame header in the signal stream and decoding audio data based on the maximum pulse width threshold and the minimum pulse width threshold.
[0007] Furthermore, the threshold algorithm is expressed as follows: the minimum pulse width threshold is set to the sum of M*maximum pulse width value and N*minimum pulse width value plus / minus constant L, and the maximum pulse width threshold is set to the sum of X*maximum pulse width value and Y*minimum pulse width value plus / minus constant Z.
[0008] Furthermore, when the sampling point of the level pulse width is greater than the maximum pulse width threshold, the frame header position is located in the information stream.
[0009] Furthermore, if the number of sampling points of the level pulse width is between the maximum pulse width threshold and the minimum pulse width threshold, it is decoded as 0; if two high and low levels smaller than the minimum pulse width threshold are detected consecutively, it is decoded as 1.
[0010] Furthermore, the time window is defined by the number of flips of the SPDIF signal, and the number is configurable.
[0011] The above embodiment has the following advantages or beneficial effects:
[0012] (1) Using the flexibly configured number of signal flips as a time window to search for the maximum and minimum pulse widths, this avoids the impact of sampling rate changes and allows for faster and more flexible positioning of the code stream's frame header and decoded data.
[0013] (2) Dynamically determine and parse the frame header and audio data within each time window to improve the robustness of signal analysis;
[0014] (3) The frame header determination algorithm and the BCM decoding algorithm are combined to use a dual-threshold method to determine the frame header and parse the data;
[0015] (4) Based on the known maximum and minimum pulse widths, and considering the threshold judgment conditions under the influence of the duty cycle, different parameters M, N, L, X, Y, and Z can be selected to support more severe duty cycle changes. Alternatively, when the duty cycle deviation is not large, parameters with simple implementation logic can be selected to optimize the area.
[0016] Other features and advantages of the present application will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present application. The purposes and other advantages of the present application can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0018] Figure 1 A flow chart of a frame header positioning and decoding method applicable to an SPDIF interface provided by the present invention;
[0019] Figure 2 Schematic diagram of the frame header encoding format of the information stream in an embodiment of the present invention;
[0020] Figure 3 Schematic diagram of the encoding format of audio data in an embodiment of the present invention;
[0021] Figure 4 This is a schematic diagram of the frame header and data pulse width provided in an embodiment of the present invention with duty cycle taken into consideration. DETAILED DESCRIPTION
[0022] To make the objectives, technical solutions, and advantages of this application more clearly understood, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0023] like Figure 1 A frame header positioning and decoding method suitable for SPDIF interface is shown.
[0024] The signal stream is acquired and the sampling points of the level pulse width are recorded using a high-frequency clock in each time window. The maximum pulse width buffer and the minimum pulse width buffer are updated in real time to obtain the maximum pulse width value and the minimum pulse width value.
[0025] In a specific implementation, the time window length is defined by the number of SPDIF signal flips. The number can be configured, but the maximum and minimum pulse widths must be obtained within the time window to avoid incorrect maximum and minimum pulse widths when the sampling rate changes.
[0026] SPDIF input data consists of 192 frames, each of which consists of two subframes, divided into two channels: Channel A and Channel B. The subframe data length is 32 bits, including the frame header (Preamble), auxiliary data (Aux Data), audio data (Audio Data), and four bits of information and checksum.
[0027] In specific implementation, Figure 2 As shown, the frame header encoding format; Figure 3 As shown in the figure, the encoding format of the audio data stream is set. Within the time window, a level pulse width counter pulse_cnt, a maximum pulse width buffer max_pulse_cnt, and an initial value of 0 are set; a minimum pulse width buffer min_pulse_cnt is set, and the initial value is set to the maximum value. When the SPDIF input stream is valid, the number of sampling points of each level pulse width is recorded using a high-frequency clock, and the last_pulse_num buffer is set. Each time the level changes, the pulse_cnt value is updated to last_pulse_num to obtain the pulse width sample of each level. When the level changes, the maximum pulse width buffer and the minimum pulse width buffer are updated. If the value of the level pulse width counter is greater than the value of the maximum pulse width buffer, the maximum pulse width buffer is updated; otherwise, it remains unchanged. If the value of the level pulse width counter is less than the value of the minimum pulse width buffer, the minimum pulse width buffer is updated; otherwise, it remains unchanged.
[0028] After obtaining the maximum pulse width value and the minimum pulse width value within the time window, a maximum pulse width threshold value max_pulse_thres and a minimum pulse width threshold value min_pulse_thres are set for the maximum pulse width value and the minimum pulse width value according to a threshold algorithm;
[0029] The threshold algorithm is constructed based on the maximum pulse width value and the minimum pulse width value. The algorithm is expressed as follows: the minimum pulse width threshold is set to the sum of M*maximum pulse width value and N*minimum pulse width value plus / minus constant L, and the maximum pulse width threshold is set to the sum of X*maximum pulse width value and Y*minimum pulse width value plus / minus constant Z; that is, min_pulse_thres=M*max_pulse_cnt+N*min_pulse_cnt+ / -L;
[0030] max_pulse_thres=X*max_pulse_cnt+Y*min_pulse_cnt+ / -Z.
[0031] In some implementations, the SPDIF signal code duty cycle is not 50%. Figure 4In the signal code shown, the original frame header length of 3 units is redefined as 3max and 3min respectively. The minimum pulse width of 1 unit is also redefined as 1max and 1min in the frame header and BMC code. The data 0 code 00 / 11 is also divided into 2max and 2min from 2 units.
[0032] When the sampling point of the level pulse width is greater than the maximum pulse width threshold, the frame header position is located in the information stream; when the number of sampling points of the level pulse width is between the maximum pulse width threshold and the minimum pulse width threshold, the decoding is 0; when two high and low levels less than the minimum pulse width threshold are detected continuously, the decoding is 1, and the following formula is obtained:
[0033]
[0034] 3max and 1min are the known values we obtained, which correspond to max_pulse_cnt and min_pulse_cnt respectively.
[0035] For different duty cycle conditions, the threshold algorithm settings based on the maximum and minimum pulse width values are also different, but all rely on the maximum and minimum pulse width thresholds for signal decoding. By selecting different parameters M, N, L, X, Y, and Z values, a trade-off is made between logic complexity and duty cycle bias while satisfying Equations 1 and 2. Based on the relationship between the maximum and minimum pulse width thresholds and the level pulse sampling points, frame headers and audio data in the signal stream are identified and decoded.
[0036] Find the maximum pulse width and minimum pulse width count values within the time window defined by the number of SPDIF signal flips, obtain the maximum pulse width threshold and minimum pulse width threshold according to the threshold algorithm shown, and judge the frame header and decoded data based on the relationship between the sampling point and threshold of the level pulse width. Through the above solution, the following advantages or
[0037] Beneficial effects:
[0038] (1) Using the flexibly configured number of signal flips as a time window to search for the maximum / minimum pulse width, this avoids the impact of sampling rate changes and allows for faster and more flexible positioning of the code stream frame header and decoded data.
[0039] (2) Dynamically determine and parse the frame header and audio data within each time window to improve the robustness of signal analysis;
[0040] (3) The frame header determination algorithm and the BCM decoding algorithm are combined to use a dual-threshold method to determine the frame header and parse the data;
[0041] (4) Based on the known maximum and minimum pulse widths, and considering the threshold judgment conditions under the influence of the duty cycle, different parameters M, N, L, X, Y, and Z can be selected to support more severe duty cycle changes; or parameters with simple implementation logic can be selected to optimize the area when the duty cycle deviation is not large.
[0042] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A frame header positioning and decoding method applicable to an SPDIF interface, characterized in that: These include: Acquire the signal stream and use a high-frequency clock to record the sampling points of the level pulse width in each time window, and update the maximum pulse width buffer and the minimum pulse width buffer in real time to obtain the maximum pulse width value and the minimum pulse width value; A maximum pulse width threshold and a minimum pulse width threshold are set for the maximum pulse width value and the minimum pulse width value according to a threshold algorithm; and a frame header in a signal stream is identified and audio data is decoded according to the maximum pulse width threshold and the minimum pulse width threshold.
2. The frame header positioning and decoding method applicable to the SPDIF interface according to claim 1, wherein: The threshold algorithm is expressed as follows: the minimum pulse width threshold is set to the sum of M*maximum pulse width value and N*minimum pulse width value plus / minus constant L, and the maximum pulse width threshold is set to the sum of X*maximum pulse width value and Y*minimum pulse width value plus / minus constant Z.
3. The frame header positioning and decoding method applicable to the SPDIF interface as claimed in claim 1, characterized in that: When the sampling point of the level pulse width is greater than the maximum pulse width threshold, the frame header position is located in the information stream.
4. The frame header positioning and decoding method applicable to the SPDIF interface as claimed in claim 1, characterized in that: If the number of sampling points of the level pulse width is between the maximum pulse width threshold and the minimum pulse width threshold, the decoding is 0; if two high and low levels smaller than the minimum pulse width threshold are detected continuously, the decoding is 1.
5. The frame header positioning and decoding method applicable to the SPDIF interface according to claim 1, characterized in that: The time window is defined by the number of flips of the SPDIF signal, and the number is configurable.