CN114339378A - Audio and video code stream processing method and device and electronic equipment - Google Patents

Audio and video code stream processing method and device and electronic equipment Download PDF

Info

Publication number
CN114339378A
CN114339378A CN202111587352.8A CN202111587352A CN114339378A CN 114339378 A CN114339378 A CN 114339378A CN 202111587352 A CN202111587352 A CN 202111587352A CN 114339378 A CN114339378 A CN 114339378A
Authority
CN
China
Prior art keywords
audio
video
physical address
memory
frame
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111587352.8A
Other languages
Chinese (zh)
Inventor
陆子海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Spreadtrum Communications Shanghai Co Ltd
Original Assignee
Spreadtrum Communications Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Spreadtrum Communications Shanghai Co Ltd filed Critical Spreadtrum Communications Shanghai Co Ltd
Priority to CN202111587352.8A priority Critical patent/CN114339378A/en
Publication of CN114339378A publication Critical patent/CN114339378A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The embodiment of the invention provides a method and a device for processing an audio and video code stream and electronic equipment. The method comprises the following steps: generating a transport stream according to a received signal, filtering out an audio and video code stream from the transport stream, wherein the audio and video code stream comprises Packed Elementary Stream (PES) data, writing the PES data into a plurality of annular buffers of a memory, the PES data comprises at least one start code, identifying the position of the at least one start code in the plurality of annular buffers to obtain a physical address corresponding to the position, recording the physical address into a start code buffer area of the memory, responding to a generated interrupt notification signal, analyzing 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 area of the memory. The embodiment of the invention reduces the frame loss and the blocking caused by longer delay.

Description

Audio and video code stream processing method and device and electronic equipment
[ technical field ] A method for producing a semiconductor device
The invention relates to the field of televisions, in particular to a method and a device for processing an audio and video code stream and electronic equipment.
[ background of the invention ]
Currently, the mainstream of a method for processing an audio/video code Stream in a live television broadcast is to output a transport Stream after processing a received signal, demultiplex (Demux) hardware filters out Packetized Elementary Stream (PES) data in the transport Stream according to a Packet Identifier (PID) value set by driving software, write the PES data into a buffer area allocated to the hardware by the driving software, read the data in the buffer area by the driving software, parse the data byte by byte, perform framing operation, and copy a framed compressed audio/video frame to an upper-layer user space.
The driving software is proprietary to each manufacturer and is realized, according to the Android S platform google DTV Hal layer reference code, multiple copy operations can occur in the analysis process of compressed audio and video frames, data can be frequently transmitted in the space of a kernel and an upper layer user, and a large amount of memory can be consumed.
However, when PES data is parsed byte by byte and framing is performed, the problem of stuttering of a player when playing a high-resolution code stream due to too low framing efficiency is caused, and smooth playing of television programs cannot be guaranteed. Copying the framed compressed audio-video frames to the upper user space by the driver software may result in reduced system performance.
[ summary of the invention ]
In view of this, embodiments of the present invention provide a method and an apparatus for processing an audio/video code stream, an electronic device, and a storage medium, so as to solve the problem of a system performance reduction caused by copying a compressed audio/video frame, a frame dropping stuck caused by a low frame-forming speed and a long delay in the prior art.
In one aspect, the present invention provides a method for processing an audio/video code stream, where the method includes:
generating a transport stream according to the received signal;
filtering out an audio and video code stream from a transmission stream, wherein the audio and video code stream comprises packed elementary stream PES data;
writing the PES data into a plurality of ring buffers of a memory, wherein the PES data comprises at least one start code;
identifying the positions of the at least one start code in the plurality of ring buffers to obtain a physical address corresponding to the position;
recording the physical address into a start code buffer area of the memory;
and responding to the generated interrupt notification signal, analyzing the PES data according to the physical address to generate a compressed audio/video frame, and writing the compressed audio/video frame into at least one frame buffer area in the memory.
Optionally, the filtering out the audio and video code stream from the transport stream includes:
and filtering the transport stream through a set PID to generate the audio and video code stream.
Optionally, before analyzing the PES data according to the physical address to generate a compressed audio/video frame in response to the generated interrupt notification signal, the method further includes:
identifying the number of the at least one start code in the plurality of ring buffers, and generating the number of the start codes corresponding to each ring buffer;
and recording the number of the start codes into the corresponding ring buffer.
Optionally, before recording the physical address into a start code buffer of the memory, the method further includes:
and allocating a buffer area with a specified size, and taking the buffer area with the specified size as the starting code buffer area.
Optionally, the writing the compressed audio/video frame into at least one frame buffer in a memory includes:
judging whether an independent buffering mode is adopted for buffering or a non-independent buffering mode is adopted for buffering;
if the independent buffering mode is adopted for buffering, each compressed audio and video frame is written into a corresponding frame buffer area;
and if the compressed audio/video frames are judged to be buffered in a non-independent buffering mode, writing all the compressed audio/video frames into a frame buffer area.
Optionally, before identifying the location of the at least one start code in the plurality of circular buffers, the method further includes:
and setting at least one start code according to the coding specification of the code stream.
Optionally, obtaining the number of the start codes in the ring buffer;
reading the physical addresses of the start codes in the ring buffer, wherein the number of the physical addresses corresponds to the number of the start codes;
finding out a start code corresponding to the physical address in a ring buffer according to the physical address;
detecting a portion conforming to a frame boundary coding rule from a start code corresponding to the physical address in the PES data, and determining the portion conforming to the frame boundary coding rule as a frame boundary;
and framing according to the identified frame boundary to generate the compressed audio and video frame.
On the other hand, an embodiment of the present invention provides a device for processing an audio/video code stream, including:
the generating module is used for generating a transmission stream according to the received signal;
the filtering module is used for filtering out an audio and video code stream from the transmission stream, wherein the audio and video code stream comprises PES data;
a first writing module, configured to write the PES data into a plurality of ring buffers of a memory, where the PES data includes at least one start code;
the first identification module is used for identifying the positions 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, configured to record the physical address into a start code buffer of the memory;
the analysis module is used for responding to the generated interrupt notification signal and analyzing the PES data according to the physical address to generate a compressed audio/video frame;
and the second writing module is used for writing the compressed audio and video frames into at least one frame buffer area in the memory.
On the other hand, an embodiment of the present invention provides a storage medium, where the storage medium includes a stored program, and when the program runs, a device where the storage medium is located is controlled to execute the above processing method for an audio/video code stream.
In another aspect, an embodiment of the present invention provides a first electronic device, which is characterized by including a memory, a processor, and a computer program that is stored in the memory and is executable on the processor, where when the processor executes the computer program, the method for processing an audio/video code stream as described above is implemented.
In the technical scheme provided by the embodiment of the invention, a transport stream is generated according to a received signal, an audio and video code stream is filtered from the transport stream, the audio and video code stream comprises packetized elementary code stream (PES) data, the PES data is written into a plurality of annular buffers of a memory, the PES data comprises at least one start code, the position of the at least one start code in the annular buffers is identified to obtain a physical address corresponding to the position, the physical address is recorded into a start code buffer area of the memory, in response to a generated interrupt notification signal, the PES data is analyzed 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 area of the memory, so that the system performance reduction caused by copying the compressed audio and video frame is reduced, and the framing speed is improved, the frame loss caused by longer delay is reduced.
[ description of the drawings ]
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive labor.
Fig. 1 is a flowchart of a method for processing an audio/video code stream according to an embodiment of the present invention;
fig. 2 is a schematic diagram of data transmission according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an internal identifier according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating a buffer search principle according to an embodiment of the present invention;
fig. 5 is a schematic diagram of a device for processing an audio/video code stream according to an embodiment of the present invention;
fig. 6 is a schematic diagram of an electronic device according to an embodiment of the present invention.
[ detailed description ] embodiments
For better understanding of the technical solutions of the present invention, the following detailed descriptions of the embodiments of the present invention are provided with reference to the accompanying drawings.
It should be understood that the described embodiments are only some embodiments of the invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in the examples of the present invention and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
It should be understood that although the terms first, second, third, etc. may be used to describe numbers, etc. in embodiments of the invention, these numbers should not be limited to these terms. These terms are only used to distinguish one number from another. For example, 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, without departing from the scope of embodiments of the present invention.
The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
Fig. 1 is a flowchart of a method for processing an audio/video code stream according to an embodiment of the present invention, and as shown in fig. 1, the method includes:
step 101, generating a transport stream according to the received signal.
The steps in the embodiments of the present invention may be performed by an electronic device, which includes but is not limited to a smart television, a mobile phone, a tablet computer, a personal computer, and the like, for example, the electronic device may also include other electronic devices capable of watching mobile television programs.
In the embodiment of the present invention, the signal may be a radio frequency signal.
In the embodiment of the invention, the electronic equipment comprises a chip, and the inside of the chip is integrated with Demux hardware, for example, the chip is a television chip.
In an embodiment of the invention, an electronic device includes a tuner, a demodulator, a register, and Demux hardware.
In the embodiment of the invention, the received signal can be processed by the tuner and the demodulator to generate the transport stream.
And 102, filtering out an audio and video code stream from the transport stream, wherein the audio and video code stream comprises PES data.
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 a set PID to generate the audio/video code stream, for example, the audio/video code stream is a Digital Television (DTV) audio/video code stream.
In the embodiment of the invention, the transport stream can comprise code stream data in various formats such as audio and video code streams, subtitles, service information and the like. The Demux hardware can separate the code stream data of various formats such as audio and video code stream, caption, service information table, etc.
In the embodiment of the invention, after the transport stream is generated, the transport stream is filtered according to the set PID, and the code stream corresponding to the PID is filtered. PID is a numerical value, and each data type in the same transport stream corresponds to a unique PID value. Therefore, the audio and video code stream corresponding to the PID can be filtered from the transport stream through the set PID.
In the embodiment of the invention, after the transport stream is generated, the transport stream is filtered according to the PID set by the driving software, and the code stream corresponding to the PID is filtered.
In the embodiment of the present invention, a transport stream refers to a single data stream in which one or more PES data having a common time reference or independent time references are combined. The basic code stream is divided into a plurality of sub basic code streams, each sub basic code stream is added with a corresponding head to be packaged to form PES data, and the PES data is taken as an effective load of the transport stream and carried by the transport stream packet. When the sub elementary stream is packetized to form a plurality of PES data, the data amount of each PES data may be different or the same.
Step 103, writing PES data into a plurality of ring buffers of the memory, wherein the PES data includes at least one start code.
In the embodiment of the invention, the memory can be dynamically allocated, and the allocated memory is organized into the annular linked list which comprises the physical address of the annular buffer. And acquiring a memory corresponding to the physical address according to the physical address of the ring buffer in the ring linked list, and writing the PES data into the ring buffer corresponding to the physical address.
In the embodiment of the invention, the memory can be dynamically allocated through the driving software, and the allocated memory is organized into the annular linked list which comprises the physical address of the annular buffer. And writing PES data into the ring buffer corresponding to the physical address according to the physical address stored in the linked list.
Fig. 2 is a schematic diagram of data transmission according to an embodiment of the present invention, as shown in fig. 2, a memory includes a plurality of ring buffers, each ring buffer has the same size, a plurality of PES data are sequentially written into the plurality of ring buffers (dscr), one PES data may occupy the plurality of ring buffers, and if one PES data is completely written into the ring buffers but the last written ring buffer is not filled, when a new PES data is written, the new PES data is written into a new ring buffer. For example, two PES packets are written into the ring buffer, the first PES data (PES data1) is written into the first ring buffer, and after the first ring buffer is fully written, the remaining data of the first PES packet is written into the following ring buffer until the first PES packet is completely written. After the first PES data is completely written into the ring buffer, the first ring buffer and the second ring buffer are filled, and the third ring buffer is filled only partially. When writing the second PES data, the second PES data (PES data2) is written into the ring buffer from the fourth ring buffer, and if the fourth ring buffer is full, the subsequent ring buffer is continuously written until the second PES data is completely written into the ring buffer.
And 104, identifying the positions of at least one start code in the plurality of annular buffers to obtain a physical address corresponding to the position.
In this embodiment of the present invention, before identifying the location of the at least one start code in the plurality of circular buffers, the method further includes: and setting at least one start code according to the coding specification of the code stream.
In the embodiment of the present invention, the start code is set according to the coding specifications of different code streams, for example, for an H264 code stream, the start code may be set to 0x00000148, and the like.
In the embodiment of the invention, the start code is set by the driving software according to the coding specifications of different code streams.
In the embodiment of the present invention, the start code may be set to one or more, and the start code itself is also a part of the PES coding. Multiple ones of the same start code can be identified in a circular buffer. For example, if the start code is set to 0x00000148, and 3 codes of 0x00000148 are recognized in one ring buffer, all of the recognized 3 codes of 0x00000148 are confirmed as the start code. And acquiring the corresponding physical address of each start code in the ring buffer according to the identified start code.
In the embodiment of the invention, the register internally comprises a set start code, and the Demux hardware acquires the start code in the register. And identifying the position of the start code, identifying the position of the start code in each circular buffer, and acquiring a physical address corresponding to the position, wherein each physical address comprises 4 bytes.
And 105, recording the physical address into a start code buffer area of the memory.
In the embodiment of the present invention, before step 105, the method further includes: and allocating a buffer area with a specified size, and taking the buffer area with the specified size as the starting code buffer area.
In the embodiment of the invention, the start code buffer area is used for storing the addresses of different start codes in the ring buffer. A buffer of a specified size is dynamically allocated and used as a start code buffer. For example, the specified size is 1 k. And calling a start code buffer area, and sequentially writing the physical addresses of the start codes in the ring buffer area into the start code buffer area.
In the embodiment of the invention, a buffer area with a specified size is dynamically allocated through the driving software, and the buffer area with the specified size is used as a starting code buffer area.
And 106, responding to the generated interrupt notification signal, analyzing the PES data according to the physical address to generate a compressed audio/video frame, and writing the compressed audio/video frame into at least one frame buffer area in the memory.
In the embodiment of the present invention, step 106 includes: and identifying the number of the at least one start code in the plurality of annular buffers, generating the number of the start codes corresponding to each annular buffer, and recording the number of the start codes into the corresponding annular buffers.
Fig. 3 is a schematic diagram of an internal identifier according to an embodiment of the present invention, as shown in fig. 3, 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 an inner flag scode _ cnt is included in a ring buffer: 2, it means that the ring buffer contains 2 start codes.
In the embodiment of the invention, after all PES data are written into the ring buffer, the Demux hardware is interrupted, and an Interrupt Service Routine (ISR) in the driving software is informed through the interruption to analyze the PES data in the ring buffer.
In the embodiment of the present invention, the analyzing the PES data to generate a compressed audio/video frame includes:
step 1061, obtaining the number of the start codes in the ring buffer.
In the embodiment of the invention, the step of analyzing the PES data to generate the compressed audio/video frame comprises the step of sequentially analyzing the data in the plurality of annular buffers to obtain the number of the start codes of the internal identification records in the annular buffer which is currently analyzed. For example, the first ring buffer internal identification is scode _ cnt: 2, when the data in the first ring buffer is analyzed, according to the internal identifier scode _ cnt: 2 the number of start codes in the current ring buffer is 2.
Step 1062, reading the physical addresses of the start codes in the ring buffer, where the number of the physical addresses corresponds to the number of the start codes, in the start code buffer.
Fig. 4 is a schematic diagram of a buffer search principle according to an embodiment of the present invention, as shown in fig. 4, the number of physical addresses acquired in a start code buffer is determined according to the number of start codes in an acquired ring buffer, and a number of physical addresses corresponding to the number of start codes in a ring buffer currently being analyzed is found in the start code buffer. When analyzing the data in the new ring buffer, starting to acquire the physical addresses with the number corresponding to the number of the start codes in the current ring buffer from the position of the last acquired physical address ending in the start code buffer. For example, the first ring buffer internal identification scode _ cnt: 2, second ring buffer internal identification scode _ cnt: 3, when parsing the PES data in the first ring buffer, according to the internal identification scode _ cnt: acquiring a first physical Address (Address 1) and a second physical Address (Address 2) in a start code buffer area, taking the first physical Address and the second physical Address as physical addresses corresponding to two start codes in a first ring buffer, and when analyzing PES data in a second ring buffer, according to an internal identifier scode _ cnt: and 3, acquiring a third physical Address (Address 3), a fourth physical Address (Address 4) and a fifth physical Address (Address 5) in the start code buffer area, and taking the third physical Address, the fourth physical Address and the fifth physical Address as physical addresses corresponding to three start codes in the second ring buffer.
Step 1063, finding out the start code corresponding to the physical address in the ring buffer according to the physical address.
Step 1064, detecting a portion conforming to the frame boundary coding rule from the start code corresponding to the physical address in the PES data, and determining the portion conforming to the frame boundary coding rule as a frame boundary.
In the embodiment of the invention, the position of the start code in the annular buffer is searched, the start code found according to the position is detected, and the data behind the start code is detected. Because of different coding modes and different coding rules, partial data meeting the frame boundary rule in the PES data is detected according to the coding rule of the currently used coding, and the partial data meeting the frame boundary rule is determined as the frame boundary.
And 1065, framing according to the identified frame boundary to generate the compressed audio/video frame.
In the embodiment of the invention, the start code in the annular buffer is found through the physical address in the start code buffer area, and the frame boundary is identified according to the start code, so that the frame boundary can be identified quickly, and the framing operation can be finished without analyzing the whole code stream word by word.
In the embodiment of the present invention, the writing the compressed audio/video frame into at least one frame buffer in a memory includes:
and 1066, judging whether an independent buffering mode is adopted for buffering or a non-independent buffering mode is adopted for buffering. If the independent buffering mode is adopted for buffering, executing step 1067; if it is determined that the buffering is performed in the dependent buffering manner, step 1068 is performed.
In the embodiment of the invention, the frame buffer area is distributed in the upper layer user space, the handle of the frame buffer area is transmitted to the driving software, and the mapping operation is carried out on the frame buffer area so as to convert the address of the frame buffer area into the kernel virtual address, so that the upper layer user space and the driving software can share the frame buffer area. Compressed audio and video frames after PES data analysis are directly written into a frame buffer area, and because the upper layer user space and the driving software can share the compressed audio and video frames in the frame buffer area, the copying operation between a kernel and the user space is avoided.
In the embodiment of the invention, the address of the frame buffer area is converted into the kernel virtual address through the driving software, so that the upper layer user space and the driving software can share the frame buffer area.
In the embodiment of the invention, a buffering mode required to be adopted can be preset, and if the preset buffering mode is detected to be an independent buffering mode, the independent buffering mode is judged to be adopted for buffering; and if the preset buffering mode is detected to be the non-independent buffering mode, judging that the non-independent buffering mode is adopted for buffering.
And step 1067, writing each compressed audio/video frame into a corresponding frame buffer area.
In the embodiment of the invention, when the independent buffering mode is adopted for buffering, a plurality of frame buffer areas are generated, and one compressed audio/video frame is written into each frame buffer area, namely, one frame buffer area only comprises one compressed audio/video frame.
In the embodiment of the invention, when the buffer is performed in an independent buffer mode, a plurality of frame buffer areas are generated, and a compressed audio/video frame is written into each frame buffer area through the driving software.
And 1068, writing all the compressed audio and video frames into a frame buffer.
In the embodiment of the invention, when the buffering is carried out in a non-independent buffering mode, only one frame buffer area is generated, all compressed audio and video frames are written into the frame buffer area, a corresponding offset position is recorded according to the written position of the compressed audio and video frames, and the offset position is determined as the position of the next compressed audio and video frame written in once the offset position is recorded every time one compressed audio and video frame is written in.
In the embodiment of the invention, when the buffer is carried out in a non-independent buffer mode, only one frame buffer area is generated, and all compressed audio and video frames are written into the frame buffer area through the driving software.
In the technical scheme provided by the embodiment of the invention, a transport stream is generated according to a received signal, an audio and video code stream is filtered from the transport stream, the audio and video code stream comprises packetized elementary code stream (PES) data, the PES data is written into a plurality of annular buffers of a memory, the PES data comprises at least one start code, the position of the at least one start code in the annular buffers is identified to obtain a physical address corresponding to the position, the physical address is recorded into a start code buffer area of the memory, in response to a generated interrupt notification signal, the PES data is analyzed 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 area of the memory, so that the system performance reduction caused by copying the compressed audio and video frame is reduced, and the framing speed is improved, the frame loss caused by longer delay is reduced.
Fig. 5 is a schematic structural diagram of a device for processing an audio/video code stream according to an embodiment of the present invention, and as shown in fig. 5, the device includes: the device comprises a generating module 1, a filtering module 2, a first writing module 3, a first identifying module 4, a first recording module 5, an analyzing module 6 and a second writing module 7.
In the embodiment of the present invention, the generating module 1 is configured to generate a transport stream according to the received signal. The filtering module 2 is configured to filter out an audio/video code stream from the transport stream, where the audio/video code stream includes PES data. The first writing module 3 is configured to write the PES data into a plurality of ring buffers of the memory, where the PES data includes at least one start code. The first identifying module 4 is configured to identify the location of the at least one start code in the multiple circular buffers, so as to obtain a physical address corresponding to the location. The first recording module 5 is configured to record the physical address into a start code buffer of the memory. And the analysis module 6 is used for responding to the generated interrupt notification signal and analyzing the PES data according to the physical address to generate a compressed audio/video frame. The second writing module 7 is configured to write the compressed audio/video frame into at least one frame buffer in the memory.
In the embodiment of the present invention, the filtering module 2 is specifically configured to filter the transport stream through a set PID, so as to generate the audio/video code stream.
In the embodiment of the present invention, the apparatus further includes: a second recognition module 8 and a second recording module 9. The second identifying module 8 is configured to identify the number of the at least one start code in the plurality of circular buffers, and generate the number of the start codes corresponding to each circular buffer. The second recording module 9 is configured to record the number of the start codes into the corresponding ring buffer.
In the embodiment of the present invention, the apparatus further includes: a module 10 is assigned. The allocation module 10 is configured to allocate a buffer with a specified size as the start code buffer.
In this embodiment of the present invention, the second writing module 7 includes a determining submodule 71 and a writing submodule 72. The judgment submodule 71 is configured to judge whether buffering is performed in an independent buffering manner or buffering is performed in a non-independent buffering manner. The writing submodule 72 is configured to write each compressed audio/video frame into a corresponding frame buffer if the determining submodule 71 determines that the independent buffering mode is adopted for buffering; if the judgment sub-module 71 judges that the buffering is performed in the non-independent buffering manner, all the compressed audio/video frames are written into a frame buffer.
In the embodiment of the present invention, the apparatus further includes a setting module 11. The setting module 11 is configured to set at least one start code according to a coding specification of the codestream.
In the embodiment of the present invention, the parsing module 6 includes an obtaining sub-module 61, a reading sub-module 62, a searching sub-module 63, a detecting sub-module 64, and a framing sub-module 65. The obtaining submodule 61 is configured to obtain the number of the start codes in the ring buffer. The reading submodule 62 is configured to read, in the start code buffer, the physical addresses of the start codes in the ring buffer, where the number of the start codes corresponds to the number of the start codes. The lookup submodule 63 is configured to find out a start code corresponding to the physical address in the ring buffer according to the physical address. The detection submodule 64 is configured to detect a portion that meets a frame boundary coding rule from a start code corresponding to the physical address in the PES data, and determine the portion that meets the frame boundary coding rule as a frame boundary. The framing submodule 65 is configured to perform framing according to the identified frame boundary, and generate the compressed audio/video frame.
In the technical scheme provided by the embodiment of the invention, a transport stream is generated according to a received signal, an audio and video code stream is filtered from the transport stream, the audio and video code stream comprises packetized elementary code stream (PES) data, the PES data is written into a plurality of annular buffers of a memory, the PES data comprises at least one start code, the position of the at least one start code in the annular buffers is identified to obtain a physical address corresponding to the position, the physical address is recorded into a start code buffer area of the memory, in response to a generated interrupt notification signal, the PES data is analyzed 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 area of the memory, so that the system performance reduction caused by copying the compressed audio and video frame is reduced, and the framing speed is improved, the frame loss caused by longer delay is reduced.
The embodiment of the invention provides a storage medium, which comprises a stored program, wherein when the program runs, the device where the storage medium is located is controlled to execute the embodiment of the processing method of the audio and video code stream.
The embodiment of the invention provides electronic equipment which comprises a memory, a processor and a computer program which is stored in the memory and can run on the processor, wherein the processor realizes the embodiment of the processing method of the audio and video code stream when executing the computer program.
Fig. 6 is a schematic diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 6, an electronic device 20 of the embodiment includes: the processor 21, the memory 22, and the computer program 23 stored in the memory 22 and capable of running on the processor 21, where the computer program 23 is executed by the processor 21 to implement the processing method applied to the audio/video code stream in the embodiment, and in order to avoid repetition, details are not repeated here. Alternatively, the computer program is executed by the processor 21 to implement the functions of each model/unit in the processing apparatus applied to the audio/video code stream in the embodiment, and in order to avoid repetition, the description is not repeated here.
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 fig. 6 is merely an example of the electronic device 20 and does not constitute a limitation of the electronic device 20 and may include more or fewer components than shown, or combine certain components, or different components, e.g., the electronic device may also include input-output devices, network access devices, buses, etc.
The Processor 21 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 22 may be an internal storage unit of the electronic device 20, such as a hard disk or a 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 memory Card (Flash Card), and the like provided on the electronic device 20. Further, the memory 22 may also include both internal storage units and external storage devices of the electronic device 20. The memory 22 is used for storing 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.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the embodiments provided in the present invention, it should be understood that the disclosed system, apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions in actual implementation, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) or a Processor (Processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A processing method of audio and video code streams is characterized by comprising the following steps:
generating a transport stream according to the received signal;
filtering out an audio and video code stream from a transmission stream, wherein the audio and video code stream comprises packed elementary stream PES data;
writing the PES data into a plurality of ring buffers of a memory, wherein the PES data comprises at least one start code;
identifying the positions of the at least one start code in the plurality of ring buffers to obtain a physical address corresponding to the position;
recording the physical address into a start code buffer area of the memory;
and responding to the generated interrupt notification signal, analyzing the PES data according to the physical address to generate a compressed audio/video frame, and writing the compressed audio/video frame into at least one frame buffer area in the memory.
2. The method of claim 1, wherein filtering the audio-video bitstream from the transport stream comprises:
and filtering the transport stream through a set PID to generate the audio and video code stream.
3. The method according to claim 1, wherein before parsing the PES data according to the physical address to generate compressed audio/video frames in response to the generated interrupt notification signal, the method further comprises:
identifying the number of the at least one start code in the plurality of ring buffers, and generating the number of the start codes corresponding to each ring buffer;
and recording the number of the start codes into the corresponding ring buffer.
4. The method of claim 1, wherein before recording the physical address in a start code buffer of the memory, further comprising:
and allocating a buffer area with a specified size, and taking the buffer area with the specified size as the starting code buffer area.
5. The method of claim 1, wherein writing the compressed audio-video frames to at least one frame buffer in a memory comprises:
judging whether an independent buffering mode is adopted for buffering or a non-independent buffering mode is adopted for buffering;
if the independent buffering mode is adopted for buffering, each compressed audio and video frame is written into a corresponding frame buffer area;
and if the compressed audio/video frames are judged to be buffered in a non-independent buffering mode, writing all the compressed audio/video frames into a frame buffer area.
6. The method of claim 1, wherein prior to identifying the at least one start code at the locations of the plurality of circular buffers, further comprising:
and setting at least one start code according to the coding specification of the code stream.
7. The method of claim 3, wherein parsing the PES data to generate compressed audio-video frames comprises:
acquiring the number of the start codes in the ring buffer;
reading the physical addresses of the start codes in the ring buffer, wherein the number of the physical addresses corresponds to the number of the start codes;
finding out a start code corresponding to the physical address in a ring buffer according to the physical address;
detecting a portion conforming to a frame boundary coding rule from a start code corresponding to the physical address in the PES data, and determining the portion conforming to the frame boundary coding rule as a frame boundary;
and framing according to the identified frame boundary to generate the compressed audio and video frame.
8. A processing device of audio and video code stream is characterized by comprising:
the generating module is used for generating a transmission stream according to the received signal;
the filtering module is used for filtering out an audio and video code stream from the transmission stream, wherein the audio and video code stream comprises PES data;
a first writing module, configured to write the PES data into a plurality of ring buffers of a memory, where the PES data includes at least one start code;
the first identification module is used for identifying the positions 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, configured to record the physical address into a start code buffer of the memory;
the analysis module is used for responding to the generated interrupt notification signal and analyzing the PES data according to the physical address to generate a compressed audio/video frame;
and the second writing module is used for writing the compressed audio and video frames into at least one frame buffer area in the memory.
9. A storage medium, characterized in that the storage medium includes a stored program, wherein, when the program runs, a device where the storage medium is located is controlled to execute the processing method of audio/video code stream according to any one of claims 1 to 7.
10. An electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the processing method of the audio/video code stream according to any one of claims 1 to 7 when executing the computer program.
CN202111587352.8A 2021-12-23 2021-12-23 Audio and video code stream processing method and device and electronic equipment Pending CN114339378A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111587352.8A CN114339378A (en) 2021-12-23 2021-12-23 Audio and video code stream processing method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111587352.8A CN114339378A (en) 2021-12-23 2021-12-23 Audio and video code stream processing method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN114339378A true CN114339378A (en) 2022-04-12

Family

ID=81055389

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111587352.8A Pending CN114339378A (en) 2021-12-23 2021-12-23 Audio and video code stream processing method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN114339378A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115174969A (en) * 2022-07-01 2022-10-11 抖音视界(北京)有限公司 Video pushing method and device and storage medium
CN115714879A (en) * 2022-11-17 2023-02-24 展讯通信(上海)有限公司 Data decoding method, device, equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1368681A (en) * 2001-02-07 2002-09-11 北京算通数字技术研究中心有限公司 Date receiving method based on CPU able to receive basic data stream
CN1960335A (en) * 2005-10-31 2007-05-09 恩益禧电子股份有限公司 Stream data processor
CN101193289A (en) * 2006-11-22 2008-06-04 中兴通讯股份有限公司 A real time conversion method from MPEG-4 transmission code stream to Internet stream media alliance stream
CN101399993A (en) * 2007-09-29 2009-04-01 奇景光电股份有限公司 Device and method for video and audio synchronization
CN101404764A (en) * 2008-10-30 2009-04-08 宁波中科集成电路设计中心有限公司 Internal memory management method in audio/video decoding course
CN101540899A (en) * 2008-03-19 2009-09-23 上海贝尔阿尔卡特股份有限公司 I frame resolution method and I frame resolver in streaming media system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1368681A (en) * 2001-02-07 2002-09-11 北京算通数字技术研究中心有限公司 Date receiving method based on CPU able to receive basic data stream
CN1960335A (en) * 2005-10-31 2007-05-09 恩益禧电子股份有限公司 Stream data processor
CN101193289A (en) * 2006-11-22 2008-06-04 中兴通讯股份有限公司 A real time conversion method from MPEG-4 transmission code stream to Internet stream media alliance stream
CN101399993A (en) * 2007-09-29 2009-04-01 奇景光电股份有限公司 Device and method for video and audio synchronization
CN101540899A (en) * 2008-03-19 2009-09-23 上海贝尔阿尔卡特股份有限公司 I frame resolution method and I frame resolver in streaming media system
CN101404764A (en) * 2008-10-30 2009-04-08 宁波中科集成电路设计中心有限公司 Internal memory management method in audio/video decoding course

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115174969A (en) * 2022-07-01 2022-10-11 抖音视界(北京)有限公司 Video pushing method and device and storage medium
CN115714879A (en) * 2022-11-17 2023-02-24 展讯通信(上海)有限公司 Data decoding method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN114339378A (en) Audio and video code stream processing method and device and electronic equipment
US7707485B2 (en) System and method for dynamic transrating based on content
JP4689872B2 (en) Digital video stream decoding method and apparatus by pseudo header insertion in digital video system
US20140341538A1 (en) Recording medium, reproducing apparatus, and reproducing method
WO2001026375A1 (en) Trick play signal generation for a digital video recorder
US10509681B2 (en) Electronic apparatus for effective resource management and method thereof
KR102505973B1 (en) Image processing apparatus, control method thereof and computer readable medium having computer program recorded therefor
US20040258060A1 (en) System, method, and computer program product for parsing packetized, multi-program transport stream
US6687305B1 (en) Receiver, CPU and decoder for digital broadcast
US6366325B1 (en) Single port video capture circuit and method
CN108093258B (en) Code stream data decoding method, computer device and computer readable storage medium
US20070177595A1 (en) DTV decoding system and de-multiplexing method thereof
US6625218B1 (en) Audio/video separator including a user data start address register
CN105847990B (en) The method and apparatus for playing media file
US20040184528A1 (en) Data processing system, data processing apparatus and data processing method
CN110968288A (en) Method, device, storage medium and equipment for isolated acquisition of application audio
CN112911390B (en) Video data playing method and terminal equipment
US6097758A (en) Device for extracting parameters for decoding a video data flow coded according to an MPEG standard
KR100382655B1 (en) Method for storing a program and apparatus therefor
US8571053B2 (en) Method and system for architecture of a fast programmable transport demultiplexer using double buffered approach
CN115834949A (en) Method and device for extracting program information, computer readable storage medium and terminal
CN114710685B (en) Video stream processing method and device, terminal equipment and storage medium
CN109743521B (en) Video data transmission method and device, electronic equipment and storage medium
CN111050106B (en) Video playback method, device and computer storage medium
US20030215019A1 (en) Audio/video separator including a user data start address register

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination