CN113784188A - TS (transport stream) hardware analysis method and system - Google Patents

TS (transport stream) hardware analysis method and system Download PDF

Info

Publication number
CN113784188A
CN113784188A CN202110913891.XA CN202110913891A CN113784188A CN 113784188 A CN113784188 A CN 113784188A CN 202110913891 A CN202110913891 A CN 202110913891A CN 113784188 A CN113784188 A CN 113784188A
Authority
CN
China
Prior art keywords
packet
data
pes
length
storage unit
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
CN202110913891.XA
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.)
Zhuhai Haiqi Semiconductor Co ltd
Original Assignee
Zhuhai Haiqi Semiconductor 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 Zhuhai Haiqi Semiconductor Co ltd filed Critical Zhuhai Haiqi Semiconductor Co ltd
Priority to CN202110913891.XA priority Critical patent/CN113784188A/en
Publication of CN113784188A publication Critical patent/CN113784188A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/41Structure of client; Structure of client peripherals
    • H04N21/426Internal components of the client ; Characteristics thereof
    • H04N21/42607Internal components of the client ; Characteristics thereof for processing the incoming bitstream
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/433Content storage operation, e.g. storage operation in response to a pause request, caching operations
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/40Client devices specifically adapted for the reception of or interaction with content, e.g. set-top-box [STB]; Operations thereof
    • H04N21/43Processing of content or additional data, e.g. demultiplexing additional data from a digital video stream; Elementary client operations, e.g. monitoring of home network or synchronising decoder's clock; Client middleware
    • H04N21/443OS processes, e.g. booting an STB, implementing a Java virtual machine in an STB or power management in an STB
    • H04N21/4435Memory management

Abstract

A TS hardware analysis method and a system thereof are provided, the TS hardware analysis method comprises the following steps: storing the TS data to a static storage unit; identifying a sync byte of a TS packet in a static storage unit; acquiring TS packet header data in the TS packet according to the synchronous bytes, wherein the TS packet header data comprises the synchronous bytes and PID; confirming the specific type of the TS packet according to the PID; if the TS packet is confirmed to be a PCR packet, acquiring a PCR value in the PCR packet; if the TS packet is confirmed to be an AV packet, valid data in the TS packet is extracted and written into the dynamic storage unit. The invention stores the TS data decoded by the software into the static storage unit, and can directly determine the position of the synchronous byte by utilizing the characteristic that the length of the TS packet is fixed, and further can directly determine the position of the TS packet header data by utilizing the synchronous byte so as to finish the extraction of effective data in the AV packet. Compared with a software analysis method, the TS data analysis process is completed by hardware, software does not need to participate, and occupation of CPU resources is greatly reduced.

Description

TS (transport stream) hardware analysis method and system
Technical Field
The invention belongs to the technical field of electronic information, and particularly relates to a TS (transport stream) hardware analysis method and a TS hardware analysis system.
Background
In the MPEG-2 standard, there are two different types of code streams output to a channel, one is a Program Stream (PS), which is suitable for media storage without error, such as storage media like DVD; another type is a Transport Stream (TS), which is a Transport Stream in the MPEG-2 standard, and is suitable for transmission in which channel noise is generated, and can be transmitted over a long distance in a network, and therefore, the TS is widely used in broadcast television systems and network streaming media.
The basic storage unit of the TS file is TS packets, the size of each TS packet is fixed to 188 bytes, and after the TS packets need to be analyzed to obtain effective data, the effective data are output and displayed through a corresponding display interface. The TS stream parsing process is usually completed by software, and consumes more CPU resources, which may cause insufficient CPU resources for an embedded system, thereby affecting the real-time performance of the system, and the screen-casting delay is too large for a terminal user of a mobile phone.
Disclosure of Invention
The present invention is directed to solving at least one of the problems of the prior art. Therefore, the invention provides a TS hardware analysis method, which solves the problem that CPU resources are excessively occupied in the TS analysis process. The invention also provides a TS stream hardware analysis system.
The TS stream hardware parsing method according to the first aspect of the invention includes the following steps:
storing the TS data to a static storage unit;
identifying a synchronization byte of a TS packet in the static storage unit, wherein the synchronization byte is used for representing the starting position of the TS packet;
acquiring TS packet header data in the TS packet according to the synchronous bytes, wherein the TS packet header data comprises the synchronous bytes and a PID;
confirming the specific types of the TS packets according to the PID, wherein the specific types comprise PCR packets and AV packets;
if the TS packet is confirmed to be the PCR packet, acquiring a PCR value in the PCR packet;
and if the TS packet is confirmed to be the AV packet, extracting valid data in the TS packet and writing the valid data into a dynamic storage unit.
The TS stream hardware analysis method provided by the embodiment of the invention at least has the following technical effects: the TS data decoded by the software is stored in a static storage unit, and because the length of the TS packet is fixed to 188 bytes, the position of the synchronous byte can be directly determined, the position of the TS packet header data can be directly determined by using the synchronous byte, and the specific type of the TS packet can be directly determined according to the PID in the TS packet header data, thereby completing the extraction of the effective data in the AV packet. Compared with the traditional software analysis method, the TS hardware analysis method provided by the embodiment of the invention has the advantages that the TS data analysis process is completed by hardware, software is not required to participate, the occupation of CPU resources is greatly reduced, and the method is suitable for industrial popularization.
According to some embodiments of the invention, the storing the TS data to the static storage unit comprises:
writing the TS data with the length being the preset code stream length into a memory buffer unit;
and reading TS data with the length of a preset input unit length from the memory buffer unit and storing the TS data into the static storage unit, wherein the input unit length is greater than the length of a single TS packet.
According to some embodiments of the present invention, writing valid data in the TS packet into a dynamic storage unit includes the following steps:
writing the effective data into an intermediate register, wherein the intermediate register is used for storing the effective data with a preset output unit length;
and when the intermediate register is full, writing the valid data in the intermediate register into the dynamic storage unit.
According to some embodiments of the present invention, the TS header data further includes adjustment field information, the adjustment field information corresponds to a first adjustment state, a second adjustment state, and a third adjustment state, the first adjustment state is used for representing that only the adjustment field is contained, the second adjustment state is used for representing that only the payload is contained, and the third adjustment state is used for representing that both the adjustment field and the payload are contained; if the TS packet is confirmed to be the AV packet, the effective data in the TS packet is extracted and written into a dynamic storage unit, and the method comprises the following steps:
if the adjusting field information is in the first adjusting state or the third adjusting state, acquiring adjusting field length information and PCR mark information in the TS packet; if the length information of the adjusting field is 0, ending the step; if the length information of the adjusting field is not 0 and the PCR mark information is effective, reading an AV _ PCR value in the TS packet;
and if the adjustment field information is in the second adjustment state or the third adjustment state, acquiring valid data in the TS packet, and writing the valid data into the dynamic storage unit.
According to some embodiments of the present invention, the TS packet header data further includes payload start information, where the payload start information is used to characterize position information of the TS packet, the position information includes a PES start position and an intermediate position, the TS packet corresponding to the PES start position is a PES start packet, and the TS packet corresponding to the intermediate position is a middle packet; if the TS packet is confirmed to be a PES start packet, the effective data in the TS packet is obtained, and the method comprises the following steps:
acquiring PES header data in the PES start packet;
and acquiring valid data in the PES start packet according to the PES header data.
According to some embodiments of the present invention, the PES header data includes a code stream identifier, a packet start identifier, and packet raw stream length information, the code stream identifier corresponds to a first data state and a second data state, the first data state is used to indicate that the PES start packet only contains valid data, and the second data state is used to indicate that the PES start packet contains both PES header information and valid data;
the method for acquiring the valid data in the PES start packet according to the PES header data comprises the following steps:
if the code stream identification is confirmed to be in a first data state, effective data are directly extracted according to the data packet initial character and the length information of the grouped original stream;
and if the code stream identifier confirms that the code stream identifier is in the second data state, obtaining PTS data, DTS data, PES data and the valid data, and writing the PTS data, the DTS data and the PES data into an IO register.
According to some embodiments of the present invention, when the bitstream id identifies a second data state, the PTS data, the DTS data, the PES data, and the valid data are obtained by:
obtaining PTS identification information, DTS identification information, PES special mark information and PES packet header length from the PES start packet;
reading the PTS data, the DTS data and the PES data from the PES start packet according to the PTS identification information, the DTS identification information and the PES special presentation information, and writing the PTS data, the DTS data and the PES data into the IO register;
and reading the valid data in the PES start packet according to the length of the PES packet header.
According to some embodiments of the present invention, the obtaining of valid data in the TS packet if the TS packet is determined to be a middle packet comprises:
and directly acquiring the effective data in the intermediate packet.
The TS hardware parsing system according to the second aspect of the invention comprises:
the static storage unit is used for storing TS data;
the hardware analysis circuit is used for identifying the synchronous bytes of the TS packets in the static storage unit, determining TS packet header data in the TS packets according to the synchronous bytes, determining the specific types of the TS packets according to the PID in the TS packet header data, and extracting effective data in the AV packets; the TS packet header data comprises the synchronization byte and the PID, and the specific type comprises a PCR packet and the AV packet;
a dynamic storage unit for writing the valid data;
and the data writing-out circuit is used for writing the valid data analyzed by the hardware analysis circuit into the dynamic storage unit.
The TS stream hardware analysis system according to the embodiment of the invention at least has the following technical effects: the TS data decoded by the software is stored in a static storage unit, and because the length of the TS packet is fixed to 188 bytes, the position of a synchronous byte can be directly determined, the position of TS packet header data can be directly determined by using the synchronous byte, and the specific type of the TS packet can be directly determined according to PID (proportion integration differentiation) in the TS packet header data, so that the effective data in the AV packet can be extracted and written into a dynamic storage unit. The TS stream hardware analysis system of the embodiment of the invention provides a system framework for executing the TS stream hardware analysis method of the embodiment of the invention, improves the access efficiency of a memory bus, reduces the bandwidth requirement, and further can ensure the normal execution of the TS stream hardware analysis method of the embodiment of the invention, thereby achieving the purpose of reducing the occupation of CPU resources.
According to some embodiments of the present invention, the above TS stream hardware parsing system further includes:
the internal buffer unit is connected with the input end of the static storage unit and is used for caching TS data with the length being the preset code stream length; the static storage unit stores the TS data with the length of a preset input unit length each time, wherein the input unit length is larger than the length of a single TS packet;
the intermediate register is used for storing the effective data with preset output unit length; the data write-out circuit and the intermediate register are used together to write the valid data to the dynamic memory cell in the output unit length.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
The above and additional aspects and advantages of the present invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
FIG. 1 is a flow chart of a TS hardware parsing method according to an embodiment of the present invention;
fig. 2 is a block diagram of a TS stream hardware parsing system according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative only for the purpose of explaining the present invention, and are not to be construed as limiting the present invention.
In the description of the present invention, it is to be understood that the directional descriptions, such as the directions of upper, lower, front, rear, left, right, etc., are referred to only for convenience of describing the present invention and for simplicity of description, and are not intended to indicate or imply that the device or element so referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be considered as limiting the present invention.
In the description of the present invention, the meaning of a plurality of means is one or more, the meaning of a plurality of means is two or more, and larger, smaller, larger, etc. are understood as excluding the number, and larger, smaller, inner, etc. are understood as including the number. If the first and second are described for the purpose of distinguishing technical features, they are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated or implicitly indicating the precedence of the technical features indicated.
In the description of the present invention, unless otherwise explicitly limited, terms such as arrangement, installation, connection and the like should be understood in a broad sense, and those skilled in the art can reasonably determine the specific meanings of the above terms in the present invention in combination with the specific contents of the technical solutions.
A TS stream hardware parsing method according to an embodiment of the first aspect of the present invention is described below with reference to fig. 1 to 2.
The TS stream hardware analysis method according to the embodiment of the invention comprises the following steps:
storing the TS data to a static storage unit;
identifying a Sync byte (Sync _ byte) of the TS packet in the static storage unit, the Sync byte being used to characterize a start position of the TS packet;
acquiring TS packet header data in the TS packet according to the synchronous bytes, wherein the TS packet header data comprises the synchronous bytes and PID;
confirming the specific types of the TS packets according to the PID, wherein the specific types comprise PCR packets and AV packets;
if the TS packet is confirmed to be a PCR packet, acquiring a PCR value in the PCR packet;
if the TS packet is confirmed to be an AV packet, valid data in the TS packet is extracted and written into the dynamic storage unit.
Referring to fig. 1 to 2, when reading the TS data into the static storage unit, 16 bytes or 32 bytes (i.e. one burst) are read each time, so that at least 192 bytes are read when one TS packet is read, and in order to ensure that the TS data read at one time can be stored, the size of the static storage unit needs to be set to 256 bytes. It should be noted that, the TS data written in the static storage unit is decoded by software, after the soft decoding, how many TS packets are specifically known, and the fixed size of each TS packet is 188 bytes, so that the position of the sync byte of each TS packet can be directly confirmed, and this process does not need to be analyzed by software, and can be directly implemented by a counter, for example: the count of one byte is processed 1 time, after 188 bytes are processed, it can be determined that one TS packet is executed, at this time, the count is reset to zero, and the next TS packet is processed.
After the determined sync byte is confirmed, it is equal to the start position of the confirmed TS packet, so that the TS header data (i.e. the first four bytes of each TS packet) including the sync byte, PID, adaptation field information (adaptation _ field), and payload start information (payload _ unit _ start) can be directly read. The specific type of the TS packet, i.e., whether the TS packet is a PCR packet or an AV packet, is directly confirmed using the PID here. Here, the PID is identification information, and the specific type is determined by judging a specific value of the PID. It should be further noted that the AV packet includes an audio packet and a video packet, which correspond to video and audio, respectively, but the procedure is the same when the TS stream hardware parsing method according to the embodiment of the present invention is performed on the audio packet and the video packet, and therefore, the description is not separately provided.
After the TS packet is confirmed to be a PCR packet, since the PCR packet does not include a payload, data does not need to be written into the dynamic memory unit, and the next TS packet can be immediately analyzed after the PCR value is obtained. After the TS packet is determined to be an AV packet, whether the TS packet is an audio packet or a video packet, it is required to determine whether the TS packet includes valid data according to the adjustment field information and the payload start information, and if the TS packet includes valid data, the valid data needs to be written into the dynamic storage unit, so that the TS packet is conveniently output to a decoder for subsequent decoding and playing.
According to the TS stream hardware analysis method provided by the embodiment of the invention, the TS data decoded by software is stored in the static storage unit, and the length of the TS packet is fixed to 188 bytes, so that the position of the synchronous byte can be directly determined, the position of the TS packet header data can be further directly determined by using the synchronous byte, and the specific type of the TS packet can be directly determined according to the PID in the TS packet header data, thereby completing the extraction of effective data in the AV packet. Compared with the traditional software analysis method, the TS hardware analysis method provided by the embodiment of the invention has the advantages that the TS data analysis process is completed by hardware, software is not required to participate, the occupation of CPU resources is greatly reduced, and the method is suitable for industrial popularization.
In some embodiments of the present invention, storing TS data to a static storage unit comprises:
writing the TS data with the length being the preset code stream length into a memory buffer unit;
and reading TS data with the length of a preset input unit length from the memory buffer unit and storing the TS data into the static storage unit, wherein the input unit length is greater than the length of a single TS packet.
Referring to fig. 2, when reading the TS data into the static storage unit, the data is first read into the memory buffer unit TS _ BUF, and then the static storage unit reads the TS data from the memory buffer unit, so as to reduce the number of interrupts in data processing.
Specifically, for the network streaming media, the RTP packets are obtained after the UDP protocol is analyzed, and each RTP packet includes 7 TS packets. In order to ensure that the memory buffer interval is enough, a memory buffer area with 188x7 bytes is provided, a plurality of memory buffer areas form a memory buffer unit TS _ BUF, and TS data after software decoding is stored into the memory buffer unit firstly. Then, 192 bytes or 224 bytes of TS data are read by the static storage unit each time, and the subsequent TS packet parsing is performed. In the above embodiment, the preset code stream length needs to be smaller than the storable capacity of the memory buffer unit, the input unit length is 192 bytes or 224 bytes, and the specific number can be adjusted according to the actual transmission condition. In some embodiments, the memory buffer unit includes 8 memory buffers.
It should be noted that, because each read data needs to be in a burst mode, if the size of a burst is 32 bytes, 192 bytes or 224 bytes are acquired at one time, it cannot be guaranteed that the first bit of the TS data read each time is synchronous byte data. Therefore, in the TS stream hardware parsing method according to the embodiment of the present invention, after the static storage unit reads data, the synchronization byte is determined based on a counter, that is, the hardware can automatically set an alignment access address to start parsing the TS packet. In addition, the sync byte is usually more than 0x47, so when the counter counts to 188, it can be determined whether it is 0x47, if it is, it is a normal TS packet, if it is not 0x47, it indicates that the packet is abnormal, and it can be directly discarded.
In some embodiments of the present invention, writing valid data in the TS packet into the dynamic storage unit includes the following steps:
writing effective data into an intermediate register, wherein the intermediate register is used for storing the effective data with the preset output unit length;
and writing the effective data in the intermediate register into the dynamic memory unit when the intermediate register is full.
Referring to fig. 2, when data is written from a static memory cell to a dynamic memory cell, the data is also written into the dynamic memory cell in a burst size, and in order to ensure that the data can be written in the burst size, an intermediate register is provided between the static memory cell and the dynamic memory cell. Specifically, in some embodiments of the present invention, the size of the intermediate register is 32 bytes, and when the hardware parsing circuit reads the TS packet and parses valid data, the data is written into the intermediate register, and when the intermediate register is full (that is, when the size of one burst is reached), the data writing circuit is responsible for writing data into a corresponding position in the dynamic memory, where the audio data and the video data are written into different positions.
In some embodiments of the present invention, the TS header data further includes adjustment field information, where the adjustment field information corresponds to a first adjustment state, a second adjustment state, and a third adjustment state, where the first adjustment state is used to indicate that only the adjustment field is included, the second adjustment state is used to indicate that only the payload is included, and the third adjustment state is used to indicate that both the adjustment field and the payload are included; if the TS packet is confirmed to be the AV packet, extracting effective data in the TS packet and writing the effective data into the dynamic storage unit, wherein the method comprises the following steps:
if the adjusting field information is in the first adjusting state or the third adjusting state, acquiring the length information of the adjusting field and PCR mark information in the TS packet; if the length information of the adjusting field is 0, ending the step; if the length information of the adjusting field is not 0 and the PCR mark information is effective, reading an AV _ PCR value in the TS packet;
and if the adjustment field information is in the second adjustment state or the third adjustment state, acquiring effective data in the TS packet, and writing the effective data into the dynamic storage unit.
The adaptation field information may be used to determine whether a payload or an adaptation field is contained within the TS packet. If the TS packet has the adjustment field, reading adjustment field length information (adapt _ field _ len) and PCR mark information (PCR _ flag) in the TS packet, if the adjustment field length information is confirmed to be 0, directly confirming that no adjustment field exists in the TS packet, directly stopping subsequent steps, returning and re-reading the next TS packet; if the adaptation field length information is not 0 and the PCR flag information is "1", the AV _ PCR value in the TS packet is read (the audio _ PCR value in the audio packet and the video _ PCR value in the video packet). If the TS packet only contains the adjustment field, the reading of the AV _ PCR value is finished, then the reading of the next TS packet is started, if the TS packet also contains the effective load, the effective data in the TS packet is continuously acquired, and the effective data is written into the dynamic storage unit. It should be noted here that if there is no adjustment field and there is only payload, valid data in TS will be directly obtained and written into dynamic storage unit.
It should be noted that the length information of the adjustment field and the PCR flag information usually follow two bytes of the TS header data. The length information of the adjusting field and the PCR mark information can be quickly confirmed by reading the contents of the two bytes.
In some embodiments of the present invention, the TS packet header data further includes payload start information, where the payload start information is used to represent position information of the TS packet, the position information includes a PES start position and an intermediate position, the TS packet corresponding to the PES start position is a PES start packet, and the TS packet corresponding to the intermediate position is an intermediate packet; if the TS packet is confirmed to be a PES start packet, effective data in the TS packet is obtained, and the method comprises the following steps:
acquiring PES header data (PES _ frame _ header) in a PES start packet;
and acquiring valid data in the PES start packet according to the PES header data.
The PES start packet and the middle packet adopt different processing modes, the PES start packet also comprises PES header data besides TS header data, whether the PES start packet comprises valid data or not can be determined through the PES header data, the valid data can be filling data or naked data for the PES start packet, and then the filling data or the naked data can be written into a middle register and further written into a dynamic memory. Note that, when the payload activation information is "1", the TS packet is determined as the PES start position, the corresponding TS packet is the PES start packet, and when the payload activation information is "0", the TS packet is determined as the intermediate position, and the corresponding TS packet is the middle packet.
In some embodiments of the present invention, the PES header data includes a stream identifier (stream _ id), a packet start identifier (packet _ start _ code), and a packet original stream length information (PES _ frame _ length), where the stream identifier corresponds to a first data state and a second data state, the first data state is used to indicate that the PES start packet only contains valid data, and the second data state is used to indicate that the PES start packet contains both PES header information and valid data;
the method for acquiring the valid data in the PES start packet according to the PES header data comprises the following steps:
if the code stream identification is confirmed to be in a first data state, effective data are directly extracted according to the initial character of the data packet and the length information of the grouped original stream;
and if the code stream identification confirms to be in the second data state, obtaining PTS data, DTS data, PES data and valid data, and writing the PTS data, the DTS data and the PES data into an IO register.
The stream id can be used to determine whether the PES start packet contains PES header information. If only valid data is contained, the valid data can be directly extracted; if the PES header information is included, it is necessary to read data such as PTS data, DTS data, and PES data, and then extract valid data.
In some embodiments of the present invention, when the code stream identifier identifies the second data state, the PTS data, the DTS data, the PES data, and the valid data are obtained by:
obtaining PTS identification information, DTS identification information, PES special mark information and PES packet header length from a PES start packet;
reading PTS data, DTS data and PES data from a PES start packet according to the PTS identification information, the DTS identification information and the PES special presentation information, and writing the PTS data, the DTS data and the PES data into an IO register;
and reading valid data in the PES start packet according to the length of the PES packet header.
After confirming that there is PES header information, in order to extract PTS identification information, DTS identification information, and PES dedicated flag information, it is necessary to continue reading data of 3 bytes after PES header data, where the data of 3 bytes includes PTS identification information (PTS _ flag), DTS identification information (DTS _ flag), PES dedicated representation information (PES _ private _ flag), and PES header length (PES _ header _ data _ length), and further, PTS data, DTS data, and PES data can be read from a PES start packet according to the PTS identification information, the DTS identification information, and the PES dedicated representation information, and written into an IO register. And then, neglecting the data with the byte number being the length of the PES packet header, and then extracting effective data.
In some embodiments of the present invention, the method for obtaining valid data in a TS packet includes the following steps: and directly acquiring valid data in the tundish. The intermediate packet only contains the TS header data and the bare data with respect to the PES start packet, and therefore, the bare data can be directly extracted after confirming that the intermediate packet is the intermediate packet.
It should be noted that the standard for completing data extraction in a TS packet is simple, taking count of 1 per read byte as an example, it is only necessary to determine that one TS packet is processed when the counter reaches 188, and then directly start reading the next packet. It should be noted that, when the read TS data constitutes a complete audio _ frame or video _ frame, the software is informed of the audio _ frame _ length or video _ frame _ length, so that the software knows that a PES _ frame has been executed.
The TS hardware analysis system comprises a static storage unit, a hardware analysis circuit, a dynamic storage unit and a data writing-out circuit.
The static storage unit is used for storing TS data;
the hardware analysis circuit is used for identifying the synchronous bytes of the TS packets in the static storage unit, determining TS packet header data in the TS packets according to the synchronous bytes, determining the specific types of the TS packets according to PID (proportion integration differentiation) in the TS packet header data, and extracting effective data in the AV packets; the TS packet header data comprises a synchronous byte and a PID, and the specific types comprise a PCR packet and an AV packet;
the dynamic storage unit is used for writing valid data;
and the data writing-out circuit is used for writing the valid data analyzed by the hardware analysis circuit into the dynamic storage unit.
Referring to fig. 1 to 2, when reading the TS data into the static storage unit, 16 bytes or 32 bytes (i.e. one burst) are read each time, so that at least 192 bytes are read when one TS packet is read, and in order to ensure that the TS data read at one time can be stored, the size of the static storage unit needs to be set to 256 bytes. It should be noted that, the TS data written in the static storage unit is decoded by software, after the soft decoding, how many TS packets are specifically known, and the fixed size of each TS packet is 188 bytes, so that the position of the sync byte of each TS packet can be directly confirmed, and this process does not need to be analyzed by software, and can be directly implemented by a counter, for example: the count of one byte is processed 1 time, after 188 bytes are processed, it can be determined that one TS packet is executed, at this time, the count is reset to zero, and the next TS packet is processed.
After the determined sync byte is confirmed, it is equal to the start position of the confirmed TS packet, so that the TS header data (i.e. the first four bytes of each TS packet) including the sync byte, PID, adaptation field information (adaptation _ field), and payload start information (payload _ unit _ start) can be directly read. The specific type of the TS packet, i.e., whether the TS packet is a PCR packet or an AV packet, is directly confirmed using the PID here. Here, the PID is identification information, and the specific type is determined by judging a specific value of the PID. It should be noted here that the AV packet includes an audio packet and a video packet, which correspond to video and audio, respectively, but the procedure is the same when the TS stream hardware parsing method according to the embodiment of the present invention is performed for both of them, and therefore, the description is not separately provided.
After the TS packet is confirmed to be a PCR packet, since the PCR packet does not include a payload, data does not need to be written into the dynamic memory unit, and the next TS packet can be immediately analyzed after the PCR value is obtained. After the TS packet is determined to be an AV packet, whether the TS packet is an audio packet or a video packet, it is required to determine whether the TS packet includes valid data according to the adjustment field information and the payload start information, and if the TS packet includes valid data, the valid data needs to be written into the dynamic storage unit, so that the TS packet is conveniently output to a decoder for subsequent decoding and playing.
According to the TS stream hardware analysis system provided by the embodiment of the invention, the TS data decoded by software is stored in the static storage unit, and the length of the TS packet is fixed to 188 bytes, so that the position of the synchronous byte can be directly determined, the position of the TS packet header data can be further directly determined by using the synchronous byte, and the specific type of the TS packet can be directly determined according to the PID in the TS packet header data, so that the effective data in the AV packet can be extracted and written into the dynamic storage unit. The TS stream hardware analysis system of the embodiment of the invention provides a system framework for executing the TS stream hardware analysis method of the embodiment of the invention, improves the access efficiency of a memory bus, reduces the bandwidth requirement, and further can ensure the normal execution of the TS stream hardware analysis method of the embodiment of the invention, thereby achieving the purpose of reducing the occupation of CPU resources.
In some embodiments of the present invention, the TS stream hardware parsing system further includes:
the internal buffer unit is connected with the input end of the static storage unit and is used for caching TS data with the length being the preset code stream length; the static storage unit stores TS data with the length of a preset input unit length each time, and the input unit length is larger than the length of a single TS packet;
the intermediate register is used for storing effective data with preset output unit length; the data write-out circuit and the intermediate register are used together to write valid data into the dynamic memory cell in output unit length.
Referring to fig. 2, when reading the TS data into the static storage unit, the data is first read into the memory buffer unit, and then the static storage unit reads the TS data from the memory buffer unit, so as to reduce the number of interrupts during data processing.
Specifically, for the network streaming media, the RTP packets are obtained after the UDP protocol is analyzed, and each RTP packet includes 7 TS packets. In order to ensure that the memory buffer interval is enough, a memory buffer area with 188x7 bytes is provided, a plurality of memory buffer areas form a memory buffer unit TS _ BUF, and TS data after software decoding is stored into the memory buffer unit firstly. Then, 192 bytes or 224 bytes of TS data are read by the static storage unit each time, and the subsequent TS packet parsing is performed. In the above embodiment, the preset code stream length needs to be smaller than the storable capacity of the memory buffer unit, the input unit length is 192 bytes or 224 bytes, and the specific number can be adjusted according to the actual transmission condition. In some embodiments, the memory buffer unit includes 8 memory buffers.
It should be noted that, because each read data needs to be in a burst mode, if the size of a burst is 32 bytes, 192 bytes or 224 bytes are acquired at one time, it cannot be guaranteed that the first bit of the TS data read each time is synchronous byte data. Therefore, in the TS stream hardware parsing method according to the embodiment of the present invention, after the static storage unit reads data, the synchronization byte is determined based on a counter, that is, the hardware can automatically set an alignment access address to start parsing the TS packet. In addition, the sync byte is usually more than 0x47, so when the counter counts to 188, it can be determined whether it is 0x47, if it is, it is a normal TS packet, if it is not 0x47, it indicates that the packet is abnormal, and it can be directly discarded.
When data is written from the static memory unit to the dynamic memory unit, the data is also written into the dynamic memory unit in a burst size, and in order to ensure that the data can be written in the burst size, an intermediate register is arranged between the static memory unit and the dynamic memory unit. Specifically, in some embodiments of the present invention, the size of the intermediate register is 32 bytes, and when the hardware parsing circuit reads the TS packet and parses valid data, the data is written into the intermediate register, and when the intermediate register is full (that is, when the size of one burst is reached), the data writing circuit is responsible for writing data into a corresponding position in the dynamic memory, where the audio data and the video data are written into different positions.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an illustrative embodiment," "an example," "a specific example," or "some examples" or the like mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
Although the embodiments of the present invention have been described in detail with reference to the accompanying drawings, the present invention is not limited to the embodiments, and those skilled in the art will understand that: various changes, modifications, substitutions and alterations can be made to the embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims (10)

1. A TS hardware analysis method is characterized by comprising the following steps:
storing the TS data to a static storage unit;
identifying a synchronization byte of a TS packet in the static storage unit, wherein the synchronization byte is used for representing the starting position of the TS packet;
acquiring TS packet header data in the TS packet according to the synchronous bytes, wherein the TS packet header data comprises the synchronous bytes and a PID;
confirming the specific types of the TS packets according to the PID, wherein the specific types comprise PCR packets and AV packets;
if the TS packet is confirmed to be the PCR packet, acquiring a PCR value in the PCR packet;
and if the TS packet is confirmed to be the AV packet, extracting valid data in the TS packet and writing the valid data into a dynamic storage unit.
2. The TS streaming hardware parsing method according to claim 1, wherein the storing TS data to a static storage unit comprises the following steps:
writing the TS data with the length being the preset code stream length into a memory buffer unit;
and reading TS data with the length of a preset input unit length from the memory buffer unit and storing the TS data into the static storage unit, wherein the input unit length is greater than the length of a single TS packet.
3. The TS hardware parsing method of claim 2, wherein writing valid data in the TS packet into a dynamic storage unit comprises the following steps:
writing the effective data into an intermediate register, wherein the intermediate register is used for storing the effective data with a preset output unit length;
and when the intermediate register is full, writing the valid data in the intermediate register into the dynamic storage unit.
4. The method for analyzing TS hardware according to claim 1, wherein the TS header data further includes adjustment field information, the adjustment field information corresponds to a first adjustment state, a second adjustment state, and a third adjustment state, the first adjustment state is used for representing that only the adjustment field is included, the second adjustment state is used for representing that only the payload is included, and the third adjustment state is used for representing that both the adjustment field and the payload are included; if the TS packet is confirmed to be the AV packet, the effective data in the TS packet is extracted and written into a dynamic storage unit, and the method comprises the following steps:
if the adjusting field information is in the first adjusting state or the third adjusting state, acquiring adjusting field length information and PCR mark information in the TS packet; if the length information of the adjusting field is 0, ending the step; if the length information of the adjusting field is not 0 and the PCR mark information is effective, reading an AV _ PCR value in the TS packet;
and if the adjustment field information is in the second adjustment state or the third adjustment state, acquiring valid data in the TS packet, and writing the valid data into the dynamic storage unit.
5. The TS streaming hardware parsing method of claim 4, wherein the TS packet header data further comprises payload start information, the payload start information is used to characterize position information of the TS packet, the position information comprises a PES start position and an intermediate position, the TS packet corresponding to the PES start position is a PES start packet, and the TS packet corresponding to the intermediate position is a middle packet; if the TS packet is confirmed to be a PES start packet, the effective data in the TS packet is obtained, and the method comprises the following steps:
acquiring PES header data in the PES start packet;
and acquiring valid data in the PES start packet according to the PES header data.
6. The TS streaming hardware parsing method of claim 5, wherein the PES header data comprises a code stream identifier, a packet start identifier, and packet raw stream length information, the code stream identifier corresponds to a first data state and a second data state, the first data state is used for indicating that the PES start packet contains only valid data, and the second data state is used for indicating that the PES start packet contains both PES packet header information and valid data;
the method for acquiring the valid data in the PES start packet according to the PES header data comprises the following steps:
if the code stream identification is confirmed to be in a first data state, effective data are directly extracted according to the data packet initial character and the length information of the grouped original stream;
and if the code stream identifier confirms that the code stream identifier is in the second data state, obtaining PTS data, DTS data, PES data and the valid data, and writing the PTS data, the DTS data and the PES data into an IO register.
7. The TS hardware parsing method of claim 6, wherein when the code stream ID identifies a second data state, the PTS data, the DTS data, the PES data, and the valid data are obtained by:
obtaining PTS identification information, DTS identification information, PES special mark information and PES packet header length from the PES start packet;
reading the PTS data, the DTS data and the PES data from the PES start packet according to the PTS identification information, the DTS identification information and the PES special presentation information, and writing the PTS data, the DTS data and the PES data into the IO register;
and reading the valid data in the PES start packet according to the length of the PES packet header.
8. The method for analyzing hardware of TS stream according to claim 5, wherein the middle packet only contains valid data, and if the TS packet is determined to be a middle packet, the method for obtaining the valid data in the TS packet comprises the following steps:
and directly acquiring the effective data in the intermediate packet.
9. A TS streaming hardware parsing system, comprising:
the static storage unit is used for storing TS data;
the hardware analysis circuit is used for identifying the synchronous bytes of the TS packets in the static storage unit, determining TS packet header data in the TS packets according to the synchronous bytes, determining the specific types of the TS packets according to the PID in the TS packet header data, and extracting effective data in the AV packets; the TS packet header data comprises the synchronization byte and the PID, and the specific type comprises a PCR packet and the AV packet;
a dynamic storage unit for writing the valid data;
and the data writing-out circuit is used for writing the valid data analyzed by the hardware analysis circuit into the dynamic storage unit.
10. The TS streaming hardware parsing system of claim 9, further comprising:
the internal buffer unit is connected with the input end of the static storage unit and is used for caching TS data with the length being the preset code stream length; the static storage unit stores the TS data with the length of a preset input unit length each time, wherein the input unit length is larger than the length of a single TS packet;
the intermediate register is used for storing the effective data with preset output unit length; the data write-out circuit and the intermediate register are used together to write the valid data to the dynamic memory cell in the output unit length.
CN202110913891.XA 2021-08-10 2021-08-10 TS (transport stream) hardware analysis method and system Pending CN113784188A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110913891.XA CN113784188A (en) 2021-08-10 2021-08-10 TS (transport stream) hardware analysis method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110913891.XA CN113784188A (en) 2021-08-10 2021-08-10 TS (transport stream) hardware analysis method and system

Publications (1)

Publication Number Publication Date
CN113784188A true CN113784188A (en) 2021-12-10

Family

ID=78837264

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110913891.XA Pending CN113784188A (en) 2021-08-10 2021-08-10 TS (transport stream) hardware analysis method and system

Country Status (1)

Country Link
CN (1) CN113784188A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008135845A (en) * 2006-11-27 2008-06-12 Ikegami Tsushinki Co Ltd Transport stream recording and reproducing method and device
US20080159279A1 (en) * 2006-12-27 2008-07-03 Waleed Younis Unified interfacing for dvb-t/h mobile tv applications
CN101453641A (en) * 2007-11-29 2009-06-10 北京中电华大电子设计有限责任公司 Transmission stream deplexing hardware construction and implementation method
CN101516029A (en) * 2009-02-27 2009-08-26 航天恒星科技有限公司 Frame synchronous byte recognition system based on FPGA and recognition method
CN104853243A (en) * 2015-05-13 2015-08-19 上海玮舟微电子科技有限公司 Transport stream de-multiplexing method and apparatus

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008135845A (en) * 2006-11-27 2008-06-12 Ikegami Tsushinki Co Ltd Transport stream recording and reproducing method and device
US20080159279A1 (en) * 2006-12-27 2008-07-03 Waleed Younis Unified interfacing for dvb-t/h mobile tv applications
CN101453641A (en) * 2007-11-29 2009-06-10 北京中电华大电子设计有限责任公司 Transmission stream deplexing hardware construction and implementation method
CN101516029A (en) * 2009-02-27 2009-08-26 航天恒星科技有限公司 Frame synchronous byte recognition system based on FPGA and recognition method
CN104853243A (en) * 2015-05-13 2015-08-19 上海玮舟微电子科技有限公司 Transport stream de-multiplexing method and apparatus

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
陈国华: "MPEG-2传输流解复用器的硬件实现", 《中国优秀硕士学位论文全文数据库》 *

Similar Documents

Publication Publication Date Title
US8286213B2 (en) HTTP based video streaming apparatus and method in mobile communication system
US20070058730A1 (en) Media stream error correction
JP5214659B2 (en) Transport stream for program stream conversion
US20110066896A1 (en) Attack packet detecting apparatus, attack packet detecting method, video receiving apparatus, content recording apparatus, and ip communication apparatus
US20110064094A1 (en) Signal processing apparatus and method, recording medium and program
US7609768B2 (en) Video buffer control apparatus for dual video decoding and digital broadcasting receiver thereof
JP3052824B2 (en) Audio playback time adjustment circuit
CN110830460A (en) Connection establishing method and device, electronic equipment and storage medium
CN114339378A (en) Audio and video code stream processing method and device and electronic equipment
CN113784188A (en) TS (transport stream) hardware analysis method and system
CN110753259B (en) Video data processing method and device, electronic equipment and computer readable medium
US20070177595A1 (en) DTV decoding system and de-multiplexing method thereof
CN100388776C (en) Digital video storage system and related method of storing digital video data
WO2023083213A1 (en) Data decoding method and apparatus, electronic device and readable storage medium
US20120039396A1 (en) Data transmitting device and data transmitting and receiving system
US20070081528A1 (en) Method and system for storing data packets
WO2021093500A1 (en) Method and device for processing video data, electronic device and computer readable medium
US8422518B2 (en) Managing transmit jitter for multi-format digital audio transmission
US20070208872A1 (en) System and method for processing streaming data
CN115942000B (en) H.264 format video stream transcoding method, device, equipment and medium
JP2006033812A (en) Method of managing auxiliary programs and corresponding receiver and system
EP2615844A1 (en) Wireless data card and method for implementing television program display by said wireless data card
WO2017054742A1 (en) Method and apparatus for processing data
CN116437134B (en) Method and device for detecting audio and video synchronicity
KR100785968B1 (en) De- multiplexer in a dmb receiver

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