A method, device and electronic device for processing audio and video code streams

By using ring buffering and interrupt notification signals in audio and video stream processing, the problems of reduced system performance and low frame formation speed are solved, and more efficient audio and video frame processing and reduced frame drop lag are achieved.

CN114339378BActive Publication Date: 2025-05-02SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111587352.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-23
Publication Date
2025-05-02
Estimated Expiration
2041-12-23

AI Technical Summary

Technical Problem

In the prior art, the system performance, low frame stuttering caused by copying compressed audio and video frames, resulting in frame loss and lag caused by long delay.

Method used

By generating a transmission stream, filtering out the audio and video code stream, writing PES data into multiple ring buffers in memory, identifying the start code position to obtain the physical address, recording the start code buffer, and parsing the PES data in response to the interrupt notification signal to generate compressed audio and video frames, and writing it to the frame buffer.

Benefits of technology

This reduces the system performance degradation caused by copying compressed audio and video frames, improves frame formation speed, and reduces frame loss and lag caused by long delays.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114339378B_ABST
    Figure CN114339378B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method, device and electronic device for processing audio and video code streams. The method includes: generating a transport stream according to a received signal, filtering out audio and video code streams from the transport stream, wherein the audio and video code streams include packaged basic code stream PES data, writing the PES data into multiple circular buffers in a memory, wherein the PES data includes at least one start code, identifying the position of the at least one start code in the multiple circular buffers, obtaining a physical address corresponding to the position, recording the physical address into the start code buffer of the memory, and in response to a generated interrupt notification signal, parsing the PES data according to the physical address to generate a compressed audio and video frame, and writing the compressed audio and video frame into at least one frame buffer in the memory. The embodiment of the present invention reduces frame loss and jamming caused by long delays.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present invention relates to the field of television, and in particular to a method, a device and an electronic device for processing audio and video code streams. [Background technology]

[0002] At present, the mainstream method for processing audio and video code streams in live TV is to process the received signal and output the transport stream. The demultiplexer (Demux) hardware filters out the packetized elementary code stream (PES) data in the transport stream according to the packet identifier (PID) value set by the driver software, and writes the PES data into the buffer allocated by the driver software for the hardware. The driver software reads the data in the buffer, parses it byte by byte, and performs framing operations, and copies the compressed audio and video frames that have been framed to the upper user space.

[0003] The driver software is privately owned and implemented by each manufacturer. According to the Google DTV Hal layer reference code of the Android S platform, multiple copy operations will occur during the parsing of compressed audio and video frames. Data will be frequently transmitted between the kernel and the upper user space, and a large amount of memory will be consumed.

[0004] However, when parsing PES data, byte-by-byte parsing and framing operations will cause the player to freeze when playing high-resolution bitstreams due to low framing efficiency, and cannot guarantee smooth playback of TV programs. Copying the compressed audio and video frames that have been framed to the upper user space through the driver software will reduce system performance. [Summary of the invention]

[0005] In view of this, the embodiments of the present invention provide a method, device, electronic device and storage medium for processing audio and video code streams, so as to solve the problems of reduced system performance, low framing speed and long delay caused by copying and compressing audio and video frames in the prior art.

[0006] On the one hand, the present invention provides a method for processing an audio and video code stream, the method comprising:

[0007] Generate a transport stream based on the received signal;

[0008] Filtering out an audio and video code stream from a transport stream, wherein the audio and video code stream includes packaged elementary code stream PES data;

[0009] Writing the PES data into a plurality of ring buffers in a memory, the PES data including at least one start code;

[0010] Identify the at least one start code at a position of the plurality of ring buffers to obtain a physical address corresponding to the position;

[0011] Recording the physical address into a start code buffer of the memory;

[0012] In response to the generated interrupt notification signal, the PES data is parsed according to the physical address to generate compressed audio and video frames, and the compressed audio and video frames are written into at least one frame buffer in the memory.

[0013] Optionally, filtering out the audio and video code streams from the transport stream includes:

[0014] The transport stream is filtered by using the set packet identifier PID to generate the audio and video code stream.

[0015] Optionally, before the method of parsing the PES data according to the physical address to generate a compressed audio and video frame in response to the generated interrupt notification signal, further includes:

[0016] Identify the number of the at least one start code in the plurality of ring buffers, and generate the number of the start code corresponding to each ring buffer;

[0017] The number of the start codes is recorded in the corresponding ring buffer.

[0018] Optionally, before recording the physical address into the start code buffer of the memory, the method further includes:

[0019] A buffer of a specified size is allocated, and the buffer of the specified size is used as the start code buffer.

[0020] Optionally, writing the compressed audio and video frames into at least one frame buffer in a memory includes:

[0021] Determine whether to use an independent buffering mode or a non-independent buffering mode for buffering;

[0022] If it is determined that the independent buffering method is used for buffering, each compressed audio and video frame is written into the corresponding frame buffer;

[0023] If it is determined that a non-independent buffering method is used for buffering, all of the compressed audio and video frames are written into a frame buffer.

[0024] Optionally, before identifying the positions of the plurality of ring buffers for the at least one start code, the step further includes:

[0025] At least one start code is set according to the encoding specification of the code stream.

[0026] Optionally, obtaining the number of the start codes in the ring buffer;

[0027] Reading in the start code buffer the physical addresses of the start codes in the ring buffer in a number corresponding to the number of the start codes;

[0028] Finding a start code corresponding to the physical address in a ring buffer according to the physical address;

[0029] In the PES data, a portion conforming to the frame boundary coding rule is detected starting from the start code corresponding to the physical address, and the portion conforming to the frame boundary coding rule is determined as a frame boundary;

[0030] Frames are grouped according to the identified frame boundaries to generate the compressed audio and video frames.

[0031] On the other hand, an embodiment of the present invention provides a device for processing an audio and video code stream, including:

[0032] A generation module, used for generating a transmission stream according to a received signal;

[0033] A filtering module, used for filtering out audio and video code streams from a transport stream, wherein the audio and video code streams include PES data;

[0034] A first writing module, used for writing the PES data into a plurality of ring buffers in a memory, wherein the PES data includes at least one start code;

[0035] A first identification module, configured to identify the position of the at least one start code in the plurality of ring buffers to obtain a physical address corresponding to the position;

[0036] A first recording module, used for recording the physical address into a start code buffer of the memory;

[0037] A parsing module, for parsing the PES data according to the physical address to generate a compressed audio and video frame in response to the generated interrupt notification signal;

[0038] The second writing module is used to write the compressed audio and video frames into at least one frame buffer in the memory.

[0039] On the other hand, an embodiment of the present invention provides a storage medium, characterized in that the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the above-mentioned audio and video code stream processing method.

[0040] On the other hand, an embodiment of the present invention provides a first electronic device, characterized in that it includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, it implements the method for processing audio and video code streams as described above.

[0041] In the technical solution provided by the embodiment of the present invention, a transport stream is generated according to a received signal, and an audio and video code stream is filtered out from the transport stream, wherein the audio and video code stream includes packaged basic code stream PES data, and the PES data is written into multiple circular buffers in a memory, wherein the PES data includes at least one start code, and the position of the at least one start code in the multiple circular buffers is identified to obtain a physical address corresponding to the position, and the physical address is recorded in a start code buffer of the memory, and in response to a generated interrupt notification signal, the PES data is parsed according to the physical address to generate a compressed audio and video frame, and the compressed audio and video frame is written into at least one frame buffer in the memory, thereby reducing the degradation of system performance caused by copying compressed audio and video frames, improving the frame assembly speed, and reducing frame loss and jamming caused by long delays.

Brief Description of the Drawings

[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0043] Figure 1 A flowchart of a method for processing an audio and video code stream provided by an embodiment of the present invention;

[0044] Figure 2 A schematic diagram of data transmission provided by an embodiment of the present invention;

[0045] Figure 3 A schematic diagram of an internal identification provided by an embodiment of the present invention;

[0046] Figure 4 A schematic diagram of a buffer zone search principle provided by an embodiment of the present invention;

[0047] Figure 5 A schematic diagram of a device for processing an audio and video code stream provided by an embodiment of the present invention;

[0048] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present invention. [Specific implementation method]

[0049] In order to better understand the technical solution of the present invention, the embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0050] It should be clear that the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0051] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0052] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0053] It should be understood that, although the terms first, second, third, etc. may be used to describe numbers, etc. in embodiments of the present invention, these numbers should not be limited to these terms. These terms are only used to distinguish numbers from each other. For example, without departing from the scope of embodiments of the present invention, a first number may also be referred to as a second number, and similarly, a second number may also be referred to as a first number.

[0054] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0055] Figure 1 A flowchart of a method for processing an audio and video code stream provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method includes:

[0056] Step 101: Generate a transport stream according to a received signal.

[0057] Each step in the embodiment of the present invention may be executed by an electronic device, which includes but is not limited to a smart TV, a mobile phone, a tablet computer, a personal computer, etc. For example, the electronic device may also include other electronic devices capable of watching mobile TV programs.

[0058] In the embodiment of the present invention, the signal may be a radio frequency signal.

[0059] In an embodiment of the present invention, the electronic device includes a chip, and Demux hardware is integrated in the chip. For example, the chip is a TV chip.

[0060] In the embodiment of the present invention, the electronic device includes a tuner, a demodulator, a register and Demux hardware.

[0061] In the embodiment of the present invention, the received signal may be processed by a tuner and a demodulator to generate a transport stream.

[0062] Step 102: Filter out the audio and video code stream from the transport stream, where the audio and video code stream includes PES data.

[0063] In the embodiment of the present invention, steps 102 to 105 can be performed by Demux hardware. In the embodiment of the present invention, the transport stream is filtered by the set PID to generate the audio and video stream, for example, the audio and video stream is a digital television (DTV) audio and video stream.

[0064] In the embodiment of the present invention, the transport stream may include code stream data in various formats such as audio and video code streams, subtitles, and service information. Demux hardware can separate code stream data in various formats such as audio and video code streams, subtitles, and service information tables.

[0065] In the embodiment of the present invention, after the transport stream is generated, the transport stream is filtered according to the set PID to filter out the bitstream corresponding to the PID. The PID is a numerical value, and each data type in the same transport stream corresponds to a unique PID value. Therefore, by setting the PID, the audio and video bitstream corresponding to the PID can be filtered out from the transport stream.

[0066] In the embodiment of the present invention, after the transport stream is generated, the transport stream is filtered according to the PID set by the driver software to filter out the code stream corresponding to the PID.

[0067] In the embodiment of the present invention, a transport stream refers to a single data stream composed of one or more PES data with a common time reference or an independent time reference. The basic code stream is divided into multiple sub-basic code streams, each sub-basic code stream is packaged with a corresponding header to form PES data, and the PES data is carried by the transport stream packet as the effective load of the transport stream. When the sub-basic code streams are packaged to form multiple PES data, the data volume of each PES data can be different or the same.

[0068] Step 103: write the PES data into a plurality of ring buffers in the memory, wherein the PES data includes at least one start code.

[0069] In the embodiment of the present invention, memory can be dynamically allocated and organized into a circular linked list, which includes the physical address of the circular buffer. The memory corresponding to the physical address is obtained according to the physical address of the circular buffer in the circular linked list, and the PES data is written into the circular buffer corresponding to the physical address.

[0070] In the embodiment of the present invention, memory can be dynamically allocated by the driver software, and the allocated memory is organized into a circular linked list, which includes the physical address of the circular buffer. PES data is written into the circular buffer corresponding to the physical address according to the physical address stored in the linked list.

[0071] Figure 2 A schematic diagram of data transmission provided by an embodiment of the present invention, such as Figure 2 As shown, the memory includes multiple ring buffers, each of which has the same size. Multiple PES data are written into multiple ring buffers (dscr) in sequence. One PES data can occupy multiple ring buffers. If one PES data has been written into the ring buffer in full, but the last written ring buffer has not been filled, when writing new PES data, the new PES data is written into a new ring buffer. For example, when two PES packets are written into the ring buffer, the first PES data (PES data1) is first written into the first ring buffer. After the first ring buffer is filled, the remaining data of the first PES is written into the subsequent ring buffer until the first PES data is written. After the first PES data is written into the ring buffer in full, the first ring buffer and the second ring buffer are filled, and the third ring buffer is only partially filled. When writing the second PES data, the second PES data (PES data2) is written into the ring buffer starting from the fourth ring buffer. If the fourth ring buffer is full, it continues to be written into the subsequent ring buffer until the second PES data is written into the ring buffer in full.

[0072] Step 104: Identify the position of at least one start code in multiple ring buffers to obtain a physical address corresponding to the position.

[0073] In the embodiment of the present invention, before identifying the positions of the plurality of ring buffers, the step further includes: setting the at least one start code according to a coding specification of a code stream.

[0074] In the embodiment of the present invention, the start code is set according to the encoding specifications of different code streams. For example, for an H264 code stream, the start code may be set to 0x00000148 or the like.

[0075] In the embodiment of the present invention, the start code is set according to the encoding specifications of different code streams through the driving software.

[0076] In the embodiment of the present invention, the start code can be set to one or more, and the start code itself is also a part of the PES encoding. The same start code can be identified multiple times in a ring buffer. For example, the start code is set to 0x00000148. If three 0x00000148 codes are identified in a ring buffer, the three identified 0x00000148 codes are all confirmed as start codes. According to the identified start code, the physical address corresponding to each start code in the ring buffer is obtained.

[0077] In the embodiment of the present invention, the register includes a set start code, and the Demux hardware obtains the start code in the register, identifies the position of the start code, identifies the position of the start code in each ring buffer, and obtains the physical address corresponding to the position, each physical address includes 4 bytes.

[0078] Step 105: Record the physical address into the start code buffer of the memory.

[0079] In the embodiment of the present invention, before step 105, the method further includes: allocating a buffer of a specified size, and using the buffer of the specified size as the start code buffer.

[0080] In the embodiment of the present invention, the start code buffer is used to store the addresses of different start codes in the ring buffer. A buffer of a specified size is dynamically allocated, and the buffer of the specified size is used as the start code buffer. For example, the specified size is 1k. The start code buffer is called, and the physical address corresponding to each start code in the ring buffer is sequentially written into the start code buffer.

[0081] In the embodiment of the present invention, a buffer of a specified size is dynamically allocated through driver software, and the buffer of the specified size is used as a start code buffer.

[0082] Step 106 , in response to the generated interrupt notification signal, parse the PES data according to the physical address to generate compressed audio and video frames, and write the compressed audio and video frames into at least one frame buffer in the memory.

[0083] In the embodiment of the present invention, before step 106, the steps include: identifying the number of the at least one start code in the multiple ring buffers, generating the number of the start code corresponding to each ring buffer, and recording the number of the start code in the corresponding ring buffer.

[0084] Figure 3 A schematic diagram of an internal identification provided by an embodiment of the present invention, such as Figure 3As shown, the number of start codes in each ring buffer is identified according to the start code set by the driver software, an internal identifier scode_cnt is generated inside each ring buffer, and the number of start codes existing in each ring buffer is recorded through the internal identifier scode_cnt. For example, if a ring buffer includes the internal identifier scode_cnt: 2, it means that the ring buffer contains 2 start codes.

[0085] In the embodiment of the present invention, after all PES data are written into the ring buffer, the Demux hardware is interrupted, and the interrupt service routine (ISR) in the driver software is notified through the interrupt to parse the PES data in the ring buffer.

[0086] In the embodiment of the present invention, the step of parsing the PES data to generate compressed audio and video frames includes:

[0087] Step 1061: Obtain the number of the start codes in the ring buffer.

[0088] In an embodiment of the present invention, parsing PES data to generate compressed audio and video frames includes parsing data in multiple ring buffers in sequence, and obtaining the number of start codes recorded by the internal identifier in the ring buffer currently being parsed. For example, the internal identifier of the first ring buffer is scode_cnt:2, and when parsing the data in the first ring buffer, the number of start codes in the current ring buffer is obtained according to the internal identifier scode_cnt:2, which is 2.

[0089] Step 1062: Read in the start code buffer a number of physical addresses of the start codes in the ring buffer corresponding to the number of the start codes.

[0090] Figure 4 A schematic diagram of a buffer zone search principle provided by an embodiment of the present invention, such as Figure 4As shown, according to the number of start codes in the obtained ring buffer, the number of physical addresses obtained in the start code buffer is determined, and the physical addresses corresponding to the number of start codes in the ring buffer currently being parsed are found in the start code buffer. When parsing data in a new ring buffer, the physical addresses corresponding to the number of start codes in the current ring buffer are obtained starting from the position where the physical address was last obtained in the start code buffer. For example, the first ring buffer has an internal identifier scode_cnt: 2, and the second ring buffer has an internal identifier scode_cnt: 3. When parsing the PES data in the first ring buffer, according to the internal identifier scode_cnt: 2, the first physical address (Address 1) and the second physical address (Address 2) are obtained in the start code buffer, and the first physical address and the second physical address are used as the physical addresses corresponding to the two start codes in the first ring buffer. When parsing the PES data in the second ring buffer, according to the internal identifier scode_cnt: 3, the third physical address (Address 3), the fourth physical address (Address 4) and the fifth physical address (Address 5) are obtained in the start code buffer, and the third physical address, the fourth physical address and the fifth physical address are used as the physical addresses corresponding to the three start codes in the second ring buffer.

[0091] Step 1063: Find the start code corresponding to the physical address in the ring buffer according to the physical address.

[0092] Step 1064: In the PES data, detect the portion that complies with the frame boundary coding rule starting from the start code corresponding to the physical address, and determine the portion that complies with the frame boundary coding rule as the frame boundary.

[0093] In the embodiment of the present invention, the position of the start code in the ring buffer is searched, and the start code is found according to the position, and the data after the start code is detected. Due to different encoding methods, the encoding rules are also different. According to the encoding rules of the currently used encoding, the part of the data in the PES data that meets the frame boundary rules is detected, and the part of the data that meets the frame boundary rules is determined as the frame boundary.

[0094] Step 1065: Group frames according to the identified frame boundaries to generate the compressed audio and video frames.

[0095] In the embodiment of the present invention, the start code in the ring buffer is found through the physical address in the start code buffer, and the frame boundary is identified based on the start code, so that the frame boundary can be quickly identified. Therefore, the framing operation can be completed without parsing the entire code stream word by word.

[0096] In the embodiment of the present invention, writing the compressed audio and video frames into at least one frame buffer in the memory includes:

[0097] Step 1066: Determine whether to use independent buffering mode or non-independent buffering mode for buffering. If it is determined that independent buffering mode is used for buffering, execute step 1067; if it is determined that non-independent buffering mode is used for buffering, execute step 1068.

[0098] In the embodiment of the present invention, the frame buffer is allocated in the upper user space, and the handle of the frame buffer is passed to the driver software, and the frame buffer is mapped to convert the address of the frame buffer into a kernel virtual address, so that the upper user space and the driver software can share the frame buffer. The compressed audio and video frames after PES data parsing are directly written into the frame buffer. Since the upper user space and the driver software can share the compressed audio and video frames in the frame buffer, the copy operation between the kernel and the user space is avoided.

[0099] In the embodiment of the present invention, the address of the frame buffer is converted into a kernel virtual address by the driver software, so that the upper user space and the driver software can share the frame buffer.

[0100] In an embodiment of the present invention, the buffering mode to be adopted can be pre-set. If it is detected that the pre-set buffering mode is an independent buffering mode, it is determined to adopt the independent buffering mode for buffering; if it is detected that the pre-set buffering mode is a non-independent buffering mode, it is determined to adopt the non-independent buffering mode for buffering.

[0101] Step 1067: Write each compressed audio and video frame into the corresponding frame buffer.

[0102] In the embodiment of the present invention, when an independent buffering method is used for buffering, multiple frame buffers are generated, and a compressed audio and video frame is written into each frame buffer, that is, a frame buffer includes only one compressed audio and video frame.

[0103] In the embodiment of the present invention, when an independent buffering method is used for buffering, multiple frame buffers are generated, and a compressed audio and video frame is written into each frame buffer through the driving software.

[0104] Step 1068: Write all of the compressed audio and video frames into a frame buffer.

[0105] In an embodiment of the present invention, when a non-independent buffering method is used for buffering, only one frame buffer is generated, and all compressed audio and video frames are written into this frame buffer. A corresponding offset position is recorded according to the position where the written compressed audio and video frame is written. The offset position is recorded once each time a compressed audio and video frame is written, and the offset position is determined as the position where the next compressed audio and video frame is written.

[0106] In the embodiment of the present invention, when the non-independent buffering mode is adopted for buffering, only one frame buffer is generated, and all compressed audio and video frames are written into the frame buffer through the driving software.

[0107] In the technical solution provided by the embodiment of the present invention, a transport stream is generated according to a received signal, and an audio and video code stream is filtered out from the transport stream, wherein the audio and video code stream includes packaged basic code stream PES data, and the PES data is written into multiple circular buffers in a memory, wherein the PES data includes at least one start code, and the position of the at least one start code in the multiple circular buffers is identified to obtain a physical address corresponding to the position, and the physical address is recorded in a start code buffer of the memory, and in response to a generated interrupt notification signal, the PES data is parsed according to the physical address to generate a compressed audio and video frame, and the compressed audio and video frame is written into at least one frame buffer in the memory, thereby reducing the degradation of system performance caused by copying compressed audio and video frames, improving the frame assembly speed, and reducing frame loss and jamming caused by long delays.

[0108] Figure 5 A structural diagram of a device for processing an audio and video code stream provided by an embodiment of the present invention, such as Figure 5 As shown, the device includes: a generating module 1, a filtering module 2, a first writing module 3, a first identifying module 4, a first recording module 5, a parsing module 6 and a second writing module 7.

[0109] In an embodiment of the present invention, a generation module 1 is used to generate a transport stream according to a received signal. A filtering module 2 is used to filter out an audio and video code stream from the transport stream, wherein the audio and video code stream includes PES data. A first writing module 3 is used to write the PES data into multiple circular buffers of a memory, wherein the PES data includes at least one start code. A first identification module 4 is used to identify the position of the at least one start code in the multiple circular buffers to obtain a physical address corresponding to the position. A first recording module 5 is used to record the physical address into a start code buffer of the memory. A parsing module 6 is used to parse the PES data according to the physical address to generate a compressed audio and video frame in response to a generated interrupt notification signal. A second writing module 7 is used to write the compressed audio and video frame into at least one frame buffer in the memory.

[0110] In the embodiment of the present invention, the filtering module 2 is specifically used to filter the transport stream through the set PID to generate the audio and video code stream.

[0111] In the embodiment of the present invention, the device further includes: a second identification module 8 and a second recording module 9. The second identification module 8 is used to identify the number of the at least one start code in the multiple ring buffers and generate the number of the start code corresponding to each ring buffer. The second recording module 9 is used to record the number of the start code in the corresponding ring buffer.

[0112] In the embodiment of the present invention, the device further includes: an allocation module 10. The allocation module 10 is used to allocate a buffer of a specified size, and use the buffer of the specified size as the start code buffer.

[0113] In the embodiment of the present invention, the second writing module 7 includes a judgment submodule 71 and a writing submodule 72. The judgment submodule 71 is used to judge whether to use an independent buffering mode or a non-independent buffering mode for buffering. The writing submodule 72 is used to write each compressed audio and video frame into a corresponding frame buffer if the judgment submodule 71 judges that the independent buffering mode is used for buffering; if the judgment submodule 71 judges that the non-independent buffering mode is used for buffering, all the compressed audio and video frames are written into one frame buffer.

[0114] In the embodiment of the present invention, the device further comprises a setting module 11. The setting module 11 is used to set at least one start code according to a coding specification of a code stream.

[0115] In the embodiment of the present invention, the parsing module 6 includes an acquisition submodule 61, a reading submodule 62, a search submodule 63, a detection submodule 64 and a framing submodule 65. The acquisition submodule 61 is used to acquire the number of the start codes in the ring buffer. The reading submodule 62 is used to read the physical addresses of the start codes in the ring buffer corresponding to the number of the start codes in the start code buffer. The search submodule 63 is used to find the start code corresponding to the physical address in the ring buffer according to the physical address. The detection submodule 64 is used to detect the part that meets the frame boundary coding rule from the start code corresponding to the physical address in the PES data, and determine the part that meets the frame boundary coding rule as the frame boundary. The framing submodule 65 is used to perform framing according to the identified frame boundary to generate the compressed audio and video frame.

[0116] In the technical solution provided by the embodiment of the present invention, a transport stream is generated according to a received signal, and an audio and video code stream is filtered out from the transport stream, wherein the audio and video code stream includes packaged basic code stream PES data, and the PES data is written into multiple circular buffers in a memory, wherein the PES data includes at least one start code, and the position of the at least one start code in the multiple circular buffers is identified to obtain a physical address corresponding to the position, and the physical address is recorded in a start code buffer of the memory, and in response to a generated interrupt notification signal, the PES data is parsed according to the physical address to generate a compressed audio and video frame, and the compressed audio and video frame is written into at least one frame buffer in the memory, thereby reducing the degradation of system performance caused by copying compressed audio and video frames, improving the frame assembly speed, and reducing frame loss and jamming caused by long delays.

[0117] An embodiment of the present invention provides a storage medium, which includes a stored program, wherein when the program is run, the device where the storage medium is located is controlled to execute an embodiment of the above-mentioned audio and video code stream processing method.

[0118] An embodiment of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements an embodiment of the above-mentioned method for processing audio and video code streams when executing the computer program.

[0119] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present invention, such as Figure 6 As shown, the electronic device 20 of this embodiment includes: a processor 21, a memory 22, and a computer program 23 stored in the memory 22 and executable on the processor 21. When the computer program 23 is executed by the processor 21, the processing method applied to the audio and video code stream in the embodiment is implemented. To avoid repetition, it is not described one by one here. Alternatively, when the computer program is executed by the processor 21, the functions of each model / unit in the processing device applied to the audio and video code stream in the embodiment are implemented. To avoid repetition, it is not described one by one here.

[0120] The electronic device 20 includes, but is not limited to, a processor 21 and a memory 22. Those skilled in the art will appreciate that Figure 6 It is only an example of the electronic device 20 and does not constitute a limitation of the electronic device 20. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0121] The processor 21 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or 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, etc.

[0122] The memory 22 may be an internal storage unit of the electronic device 20, such as a hard disk or memory of the electronic device 20. The memory 22 may also be an external storage device of the electronic device 20, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 20. Further, the memory 22 may also include both an internal storage unit of the electronic device 20 and an external storage device. The memory 22 is used to store computer programs and other programs and data required by the electronic device. The memory 22 may also be used to temporarily store data that has been output or is to be output.

[0123] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0124] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0125] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0126] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0127] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (Processor) to perform some steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0128] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. A method for processing an audio and video code stream, characterized in that: The method comprises: Generate a transport stream based on the received signal; Filtering out an audio and video code stream from a transport stream, wherein the audio and video code stream includes packaged elementary code stream PES data; Writing the PES data into a plurality of ring buffers in a memory, the PES data including at least one start code; Identify the at least one start code at a position of the plurality of ring buffers to obtain a physical address corresponding to the position; Recording the physical address into a start code buffer of the memory; In response to the generated interrupt notification signal, the PES data is parsed according to the physical address to generate a compressed audio and video frame, and the compressed audio and video frame is written into at least one frame buffer in the memory, wherein the address of the frame buffer is a kernel virtual address; The step of parsing the PES data to generate compressed audio and video frames includes: Obtaining the number of the start codes in the ring buffer; Reading in the start code buffer the physical addresses of the start codes in the ring buffer in a number corresponding to the number of the start codes; Finding a start code corresponding to the physical address in a ring buffer according to the physical address; In the PES data, a portion conforming to the frame boundary coding rule is detected starting from the start code corresponding to the physical address, and the portion conforming to the frame boundary coding rule is determined as a frame boundary; Frames are grouped according to the identified frame boundaries to generate the compressed audio and video frames.

2. The method according to claim 1, characterized in that The filtering out the audio and video code stream from the transport stream includes: The transport stream is filtered by using the set packet identifier PID to generate the audio and video code stream.

3. The method according to claim 1, characterized in that Before the PES data is parsed according to the physical address to generate a compressed audio and video frame in response to the generated interrupt notification signal, the method further includes: Identify the number of the at least one start code in the plurality of ring buffers, and generate the number of the start code corresponding to each ring buffer; The number of the start codes is recorded in the corresponding ring buffer.

4. The method according to claim 1, characterized in that: Before recording the physical address into the start code buffer of the memory, the method further includes: A buffer of a specified size is allocated, and the buffer of the specified size is used as the start code buffer.

5. The method according to claim 1, characterized in that Writing the compressed audio and video frames into at least one frame buffer in a memory includes: Determine whether to use an independent buffering mode or a non-independent buffering mode for buffering; If it is determined that the independent buffering method is used for buffering, each compressed audio and video frame is written into the corresponding frame buffer; If it is determined that a non-independent buffering method is used for buffering, all of the compressed audio and video frames are written into a frame buffer.

6. The method according to claim 1, characterized in that Before identifying the positions of the plurality of ring buffers of the at least one start code, the method further comprises: At least one start code is set according to the encoding specification of the code stream.

7. A device for processing audio and video code streams, characterized in that: include: A generation module, used for generating a transmission stream according to a received signal; A filtering module, used for filtering out audio and video code streams from a transport stream, wherein the audio and video code streams include PES data; A first writing module, used for writing the PES data into a plurality of ring buffers in a memory, wherein the PES data includes at least one start code; A first identification module, configured to identify the position of the at least one start code in the plurality of ring buffers to obtain a physical address corresponding to the position; A first recording module, used for recording the physical address into a start code buffer of the memory; A parsing module, for parsing the PES data according to the physical address to generate a compressed audio and video frame in response to the generated interrupt notification signal; A second writing module, used for writing the compressed audio and video frame into at least one frame buffer in the memory, wherein the address of the frame buffer is a kernel virtual address; The step of parsing the PES data to generate compressed audio and video frames includes: Obtaining the number of the start codes in the ring buffer; Reading in the start code buffer the physical addresses of the start codes in the ring buffer in a number corresponding to the number of the start codes; Finding a start code corresponding to the physical address in a ring buffer according to the physical address; In the PES data, a portion conforming to the frame boundary coding rule is detected starting from the start code corresponding to the physical address, and the portion conforming to the frame boundary coding rule is determined as a frame boundary; Frames are grouped according to the identified frame boundaries to generate the compressed audio and video frames.

8. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the method for processing audio and video code streams according to any one of claims 1 to 6.

9. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for processing the audio and video code stream as claimed in any one of claims 1 to 6 when executing the computer program.

Citation Information

Patent Citations

  • A real time conversion method from MPEG-4 transmission code stream to Internet stream media alliance stream

    CN101193289A

  • Internal memory management method in audio / video decoding course

    CN101404764A

  • Date receiving method based on CPU able to receive basic data stream

    CN1368681A

  • Stream data processor

    CN1960335A