Voice coding and decoding method and system
By compressing and encrypting voice data in satellite communication, the problems of voice distortion and insufficient bandwidth utilization are solved, and high-quality voice transmission in narrowband communication is achieved.
Patent Information
- Application Number
- CN202511669457.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-14
- Publication Date
- 2026-02-27
AI Technical Summary
In existing technologies, voice communication in satellite communication suffers from severe voice distortion and cannot maximize bandwidth utilization.
The 320-byte voice data is compressed into 5 bytes using a compression algorithm. A protocol field is added to the header of the data frame. The data is then encrypted and scrambled by a digital signal processor before being sent. The receiving end descrambles and decrypts the data to decompress it into 320 bytes of voice data.
It improves voice quality with limited bandwidth and maximizes the use of bandwidth resources.
Smart Images

Figure CN121583267A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of speech coding, in particular to a speech coding method and system. BACKGROUND
[0002] In a communication system, voice service is a very important service, because satellite communication is mostly narrowband communication, and most communication devices use 600 rate voice service. Although the compression ratio is large, the voice distortion is serious. If the wcdma communication protocol is used, the bandwidth cannot be maximized. SUMMARY
[0003] The purpose of the present application is to provide a speech coding method and system, which solves the problem of serious voice distortion and cannot maximize the use of bandwidth in the prior art.
[0004] Technical scheme: The speech coding method provided by the present application comprises the following steps: The sending end comprises the following steps: (1) Collecting voice data, the voice data being in pulse code modulation (PCM) format, single channel, 16 bits, and a sampling rate of 8 kHz, collecting 320 bytes of voice data every 20 ms; compressing each 320 bytes of voice data into 5 bytes of compressed data; and assembling multiple groups of compressed data into a data frame, wherein 18 groups of compressed data form a data frame, and a protocol field is added to the header of the data frame; (2) Encrypting and scrambling the data frame; and sending the processed data frame to a satellite communication channel through a digital signal processor (DSP); The receiving end comprises the following steps: (3) Receiving data frames from the satellite communication channel, one frame every 60 ms; and splicing multiple data frames into a complete voice data frame; (4) Decrypting and descrambling the voice data frame; decompressing each 5 bytes of decrypted data into 320 bytes of voice data; and playing the decompressed voice data.
[0005] Further, assembling multiple groups of compressed data into a data frame specifically comprises: adding a 14-byte encryption synchronization header as a protocol field to the header of the data frame.
[0006] Further, splicing multiple data frames into a complete voice data frame specifically comprises: four frames of data form a group, and the frames are spliced according to the serial numbers in the frames.
[0007] Further, the compression algorithm is used to realize the compression from 320 bytes to 5 bytes, and the decompression algorithm is used to realize the decompression from 5 bytes to 320 bytes.
[0008] The voice coding and decoding system comprises a sending end and a receiving end; the sending end comprises: a first ARM core for collecting voice data, the voice data being in a pulse code modulation (PCM) format, single channel, 16 bits, and a sampling rate of 8 kHz, 320 bytes of voice data being collected every 20 ms; a second ARM core connected with the first ARM core, for compressing each 320 bytes of voice data into 5 bytes of compressed data, assembling multiple groups of compressed data into a data frame, wherein each 18 groups of compressed data form a data frame, adding a protocol field in the header of the data frame, and performing encryption and scrambling processing on the data frame; a first DSP module connected with the second ARM core, for sending the processed data frame to a satellite communication channel; The receiving end comprises: a second DSP module for receiving data frames from the satellite communication channel, one frame being received every 60 ms; A third ARM core connected with the second DSP module, for splicing multiple data frames into a complete voice data frame, and performing descrambling and decryption processing on the voice data frame; a fourth ARM core connected with the third ARM core, for decompressing each 5 bytes of decrypted data into 320 bytes of voice data, and playing the voice data.
[0009] Further, the second ARM core adds a 14-byte encryption synchronization header as a protocol field in the header of the data frame when assembling the data frame.
[0010] Further, the third ARM core splices each four frames of data as a group, and splices according to the serial number in the frame when splicing the data frame.
[0011] Further, the second ARM core uses a compression module to realize compression from 320 bytes to 5 bytes, and the fourth ARM core uses a decompression module to realize decompression from 5 bytes to 320 bytes.
[0012] Further, the first ARM core collects voice data through a dedicated voice chip CODEC, and the fourth ARM core plays voice data through a dedicated voice chip CODEC.
[0013] Advantages: Compared with the prior art, the present application has the following remarkable advantages: the present application realizes voice compression and decompression in a first rate bandwidth communication scenario, greatly improves the quality of voice on the basis of maximizing the use of bandwidth. BRIEF DESCRIPTION OF DRAWINGS
[0014] Figure 1 is a method flowchart of the present application; Figure 2 is a sending end flowchart of the present application; Figure 3 is a receiving end flowchart of the present application; Figure 4is a packet of received data of the application; Figure 5 is a system structure diagram of the application. DETAILED DESCRIPTION
[0015] The technical solutions of the application are further described below with reference to the drawings.
[0016] As Figure 1 shown, the embodiment of the application provides a voice coding and decoding method, comprising the following steps: The sending end: (1) collecting voice data, the voice data being in pulse code modulation (PCM) format, single channel, 16 bits, and a sampling rate of 8 kHz, collecting 320 bytes of voice data every 20 ms; compressing each 320 bytes of voice data into 5 bytes of compressed data; assembling multiple groups of compressed data into a data frame, wherein each 18 groups of compressed data form a data frame, and adding a protocol field in the header of the data frame; (2) encrypting and scrambling the data frame; sending the processed data frame to a satellite communication channel through a digital signal processor (DSP); The receiving end: (3) receiving the data frame from the satellite communication channel, one frame every 60 ms; splicing multiple data frames into a complete voice data frame; (4) descrambling and decrypting the voice data frame; decompressing the decrypted data every 5 bytes into 320 bytes of voice data; playing the decompressed voice data.
[0017] Among them, assembling multiple groups of compressed data into a data frame specifically comprises: adding a 14-byte encryption synchronization header as a protocol field in the header of the data frame. Splicing multiple data frames into a complete voice data frame specifically comprises: four frames of data as a group, splicing according to the serial number in the frame. The compression algorithm is used to realize the compression from 320 bytes to 5 bytes, and the decompression algorithm is used to realize the decompression from 5 bytes to 320 bytes.
[0018] The voice sending processing flow is as shown in Figure 2 , and specifically comprises: 1. calling the function tp_dd_open() to open the device Lim5 in the thread UHF_voice_send_thread_2400; 2. once the ptt button is pressed, the AP side collects voice data at a rate of 8k from the pcm and sends it to the CP-ARM, the CP-ARM calls the function tp_dd_read() to read voice data from the AP side in a loop, 320 bytes (equivalent to 20 ms) each time; 3. Compress the 320 bytes of data read into 5 bytes using the compression function u2k_enc(), and then send it to the voice packet assembly function EnCode_2400() for packet assembly.
[0019] 4. In the function EnCode_2400(), the compressed voice data is cached in the buffer voiceEncdBuff. The first 14 bytes of data in this buffer are used as the encrypted synchronization header. The end of the buffer is recorded through the global variable voice_enc_pos. 5 bytes of data are cached every 20ms, and 18 groups are packed into one packet (i.e., 90 bytes). 5. After the buffer is full of 90 bytes of compressed data, along with 14 bytes of encrypted synchronization header data, it is sent to the uplink data transfer thread UHF_ALOHA_send_process_thread through the function tp_os_queue_send() in the function SendVoiceDataToDSP().
[0020] 6. The thread UHF_ALOHA_send_process_thread sets the inverse frequency point according to the type of frame to be sent, and then sends it to the DSP.
[0021] Some of the variables involved are as follows: a. `first_send_flag`: The `first_send_flag` determines whether it is the first frame (1: first frame; 0: not the first frame). If it is the first frame, RF needs to be enabled, and the function `SendVoiceDataToDSP()` needs to be called to send data. b. isfirst: Indicates whether a voice frame is at the beginning or end (first frame: FIRST_VOICE_FRM; middle voice frames: FOLLOWING_VOICE_FRM; last frame: LAST_VOICE_FRM). The DSP uses this flag to decide whether to open or close the channel.
[0022] c. voice_end_flag: Indicates whether the voice has ended (0: voice has not ended; 1: voice has ended).
[0023] d. _VOICE_FRM_TALKING: Whether the PTT button is pressed (0: Release the PTT button to end sending; 1: Press the PTT button to start sending voice).
[0024] e. cmd_pack_num: Used to tell the DSP the voice frame status. The DSP uses this variable to determine whether the voice transmission has ended (when it is LAST_VOICE_FRM, the voice has ended; when it is FIRST_VOICE_FRM and FOLLOWING_VOICE_FRM, the voice has not ended).
[0025] f. next_ram_send: The DSP side notifies the CP-ARM side whether to pause transmission (0: the DSP notifies the CP-ARM side to pause transmission; 1: the DSP notifies the CP-ARM side to continue transmission).
[0026] The voice reception and processing flow is as follows Figure 3 As shown, the specific details are as follows: Every 60ms, the DSP receives a set of voice data from the physical channel and sends the voice data, along with information such as data type, CRC check result, and signal-to-noise ratio, to the CP-ARM. The CP-ARM obtains this data information through the function x1643_mcu_mc1_data_proc() and sends it to the message queue g_uhf_test_queue_id. The thread UHF_TDM_recv_thread is responsible for reading all data information from this message queue in a loop and parsing out the valid voice data.
[0027] Each parsed valid voice data is 21 bytes. The signaling is in the lower four bits of the 19th byte, and the signaling occupies 4 bits. The signaling bit values of the received voice data cycle in the order of 0, 1, 2, 3. The first 14 bytes of the data packet with a signaling value of 0 are the encrypted synchronization header. The data packets with signaling values of 1, 2, 3 do not have an encrypted synchronization header. The 20th and 21st bytes of each voice data packet are CRC data, and the rest are voice data.
[0028] The decrypted voice data is buffered. Each voice data frame is converted into binary data and sequentially buffered into the array `voice_buf_bit` (one bit occupies one byte), starting from the signaling bit of the previous data packet. When the signaling bit value is 0, the first 112 bits of data are taken from the array `voice_buf_bit` as an encrypted synchronization header. When the received signaling bit values are 1, 2, and 3, 160 bits (20 bytes) of data are sequentially taken from the buffer `voice_buf_bit` and passed through to the queue `g_uhf_voice_fwd_queue_id` via the functions `ParseUserSig_2400()` and `voice_2_fwd_thread()`.
[0029] The thread UHF_voice_fwd_thread reads the voice data from the message queue in a loop, and calls the decompression function u2k_dec() in the function de_voice_2_ap() to decompress the 5 bytes of data into 320 bytes of data, which is then sent to the AP via LMI5.
[0030] like Figure 4As shown, the function x1643_mcu_mc1_data_proc() reads data from the DSP and stores it in the queue g_uhf_test_queue_id. In the function UHF_TDM_recv_thread(), the data from the DSP is first checked for CRC. Correct data from the DSP has a CRC of 0x01, while incorrect data has a CRC of 0x88. Correct data is then packetized, and the packetized data is sent to the queue g_uhf_voice_fwd_queue_id. The function de_voice_2_ap() receives 20 bytes, and every 5 bytes are decompressed into 320 bytes using the decompression function u2k_dec(). The decompressed data is then written to device lmi5 via tp_dd_write() and sent to the AP.
Claims
1. A speech encoding and decoding method, characterized in that, Includes the following steps: Sender: (1) Acquire speech data. The speech data is in Pulse Code Modulation (PCM) format, single channel, 16 bits, sampling rate of 8kHz, and 320 bytes of speech data are acquired every 20ms; each 320 bytes of speech data is compressed into 5 bytes of compressed data. Multiple sets of compressed data are assembled into a data frame, with each 18 sets of compressed data forming a data frame, and a protocol field is added to the header of the data frame. (2) Encrypt and scramble the data frames; The processed data frames are sent to the satellite communication channel via a digital signal processor (DSP). Receiver: (3) Receive data frames from the satellite communication channel, one frame every 60ms; splice multiple data frames into a complete voice data frame; (4) Descramble and decrypt the voice data frames; Decompress the decrypted data into 320-byte groups of 5-byte audio data; play the decompressed audio data.
2. The speech encoding and decoding method according to claim 1, characterized in that, The process of assembling multiple sets of compressed data into a data frame is as follows: a 14-byte encrypted synchronization header is added to the data frame header as a protocol field.
3. The speech encoding and decoding method according to claim 1, characterized in that, The process of concatenating multiple data frames into a complete voice data frame is as follows: each group consists of four data frames, which are then concatenated according to their sequence numbers.
4. The speech encoding and decoding method according to claim 1, characterized in that, Compression algorithms are used to compress data from 320 bytes to 5 bytes, and decompression algorithms are used to decompress data from 5 bytes to 320 bytes.
5. A voice encoding and decoding system, characterized in that, It includes a transmitter and a receiver. The transmitter includes: a first ARM core for acquiring voice data in Pulse Code Modulation (PCM) format, single-channel, 16-bit, with a sampling rate of 8kHz, acquiring 320 bytes of voice data every 20ms; a second ARM core connected to the first ARM core for compressing each 320 bytes of voice data into 5 bytes of compressed data, assembling multiple sets of compressed data into data frames, wherein each set of 18 sets of compressed data forms a data frame, adding a protocol field to the header of the data frame, and encrypting and scrambling the data frame; and a first DSP module connected to the second ARM core for sending the processed data frames to the satellite communication channel. The receiver includes: a second DSP module for receiving data frames from the satellite communication channel, receiving one frame every 60ms; The third ARM core is connected to the second DSP module to splice multiple data frames into a complete voice data frame, and to descramble and decrypt the voice data frame; the fourth ARM core is connected to the third ARM core to decompress the decrypted data into 320-byte voice data in groups of 5 bytes, and to play the voice data.
6. A speech encoding and decoding system according to claim 5, characterized in that, When assembling data frames, the second ARM core adds a 14-byte encrypted synchronization header as a protocol field to the data frame header.
7. A speech encoding and decoding system according to claim 5, characterized in that, When splicing data frames, the third ARM core splices the data in groups of four frames according to the sequence number within each frame.
8. A speech encoding and decoding system according to claim 5, characterized in that, The second ARM core uses a compression module to compress data from 320 bytes to 5 bytes, while the fourth ARM core uses a decompression module to decompress data from 5 bytes to 320 bytes.
9. A speech encoding and decoding system according to claim 5, characterized in that, The first ARM core collects voice data through a dedicated voice chip CODEC, and the fourth ARM core plays the voice data through the same dedicated voice chip CODEC.