Method and device for recombining multi-channel TS (transport stream) programs

文档序号:1925627 发布日期:2021-12-03 浏览:14次 中文

阅读说明:本技术 多路ts流节目的重组方法及装置 (Method and device for recombining multi-channel TS (transport stream) programs ) 是由 单琳伟 毛珂 樊晓婷 于 2021-08-02 设计创作,主要内容包括:本发明公开了一种多路TS流节目的重组方法及装置,涉及数字电视技术领域。该方法包括:解复用模块对N路TS流进行解复用;解码模块生成每路节目的PCR/STC样值对,并对视频和音频进行解码;系统时间管理模块根据预设的映射关系计算得到PCR′/STC′样值对;分组合并模块将解码后的视频和音频进行重组;编码模块对重组后的每路视频和音频进行编码压缩,计算每路输出节目的PCR信息,并进行TS封装;复用输出模块将输出节目流复用为TS流。本发明适用于数字电视领域的TS流节目重组,实现了多个TS流内的不同节目的音视频进行重新分组合并,消除了系统时间误差的影响,解决了合并的新节目丢帧或卡顿的情况,能够满足高质量的节目转换要求。(The invention discloses a method and a device for recombining multi-channel TS (transport stream) programs, and relates to the technical field of digital televisions. The method comprises the following steps: the demultiplexing module demultiplexes the N paths of TS streams; the decoding module generates PCR/STC sample value pairs of each program and decodes the video and audio; the system time management module calculates to obtain a PCR '/STC' sample value pair according to a preset mapping relation; the grouping and merging module recombines the decoded video and audio; the coding module performs coding compression on each path of recombined video and audio, calculates PCR information of each path of output program, and performs TS (transport stream) encapsulation; the multiplexing output module multiplexes the output program stream into a TS stream. The invention is suitable for the TS stream program recombination in the digital television field, realizes the regrouping and merging of the audios and videos of different programs in a plurality of TS streams, eliminates the influence of system time error, solves the problem of frame loss or blockage of the merged new program, and can meet the requirement of high-quality program conversion.)

1. A method for recombining a plurality of TS streams is characterized by comprising the following steps:

the demultiplexing module acquires N paths of TS streams, demultiplexes the N paths of TS streams to obtain N paths of programs, and sends the N paths of programs to the decoding module;

when receiving the PCR information of the N paths of programs, the decoding module records the current STC information, generates a PCR/STC sample value pair of each path of program, and sends the PCR/STC sample value pair of each path of program to the system time management module; decoding the videos and the audios of the N paths of programs, and sending the decoded videos and audios to a grouping and combining module;

the system time management module stores the PCR/STC sample value pairs of the N paths of programs in N paths of input queues, calculates to obtain PCR '/STC' sample value pairs in corresponding output queues according to a preset mapping relation, and sends the obtained PCR '/STC' sample value pairs in all the output queues to the coding module;

the grouping and merging module recombines the decoded video and audio according to a preset recombination requirement to obtain at least one path of recombination result, and sends all the obtained recombination results to the coding module;

the encoding module encodes and compresses each path of recombined video and audio, calculates PCR information of each path of output program according to PCR '/STC' sample value in a corresponding output queue, performs TS packaging on each path of encoded and compressed video and audio according to the PCR information of each path of output program to obtain at least one path of output program stream, and sends all the obtained output program streams to the multiplexing output module;

the multiplexing output module multiplexes the at least one output program stream into at least one TS stream;

wherein N is more than or equal to 2.

2. The method of claim 1, wherein the decoding module further comprises, before sending the PCR/STC sample pairs of each program to the system time management module:

judging whether each PCR/STC sample value pair of each path of program is a discontinuous point or not through a discontinuous indication flag bit in the TS stream, and if the current sample value pair is the discontinuous point, adding a discontinuous point identifier for the current sample value pair;

if the current sample value pair is not a discontinuity, adding a discontinuity identification to the current sample value pair if the current sample value pair satisfies the following formula:

|PCR2-PCR1|>|STC2-STC1|×G

wherein, PCR2/STC2For the current sample value pair, PCR1/STC1G is a preset constant and is a previous sample value pair of the current sample value pair.

3. The method of claim 2, wherein the encoding module calculates the PCR information of each output program according to the PCR '/STC' sample pairs in the corresponding output queue, and specifically comprises:

judging whether the PCR '/STC' sample value pairs in the corresponding output queues are continuous sample value pairs or not according to the discontinuity point identification, and calculating the PCR information of each path of output programs according to the following conditions aiming at the continuous sample value pairs:

if STCpGreater than STC' in all sample pairs in the corresponding output queue, and PCRmin′/STCmin' continuous sample centering STCmin' and STCpThe absolute value of the difference of (A) is the STC 'and STC' of the PCR '/STC' sample pair of all output queuespThe minimum value of the absolute value of the difference value of (b), the PCR information PCR of the currently output program is calculated according to the following formulap

PCRp=PCRmin′+STCp-STCmin′;

If STCpLess than STC' of all sample pairs in the corresponding output queue, and PCRmin′/STCmin' continuous sample centering STCmin' and STCpThe absolute value of the difference of (A) is the STC 'and STC' of the PCR '/STC' sample pair of all output queuespThe minimum value of the absolute value of the difference value of (b), the PCR information PCR of the currently output program is calculated according to the following formulap

PCRp=PCRmin′+STCmin′-STCp

If STCpFirst PCR in corresponding output queue1′/STC1' STC in consecutive sample pairs1' and second PCR2′/STC2' STC in consecutive sample pairs2In between, the PCR information PCR of the currently output program is calculated according to the following formulap

Wherein, STCpThe current system time of the program is output.

4. The method of claim 1, wherein the decoding module decodes the video and audio of the N programs, and specifically comprises:

decoding the video and the audio of the N paths of programs according to a preset format;

respectively establishing a first annular cache and a second annular cache according to the video format and the audio format of each path of program;

respectively detecting whether the residual space of the first annular cache and the second annular cache meets a preset space storage value;

if the first annular cache meets the preset spatial storage value, storing the decoded video in the first annular cache;

storing the decoded audio in the second ring cache if the second ring cache satisfies the preset spatial storage value;

otherwise, the decoded video and the decoded video are put into a queue until the first annular buffer memory or the second annular buffer memory meets the preset spatial storage value, and then the decoded video and the decoded video are taken out from the queue for storage.

5. The method of claim 1, wherein the system time management module calculates PCR '/STC' sample value pairs in corresponding output queues according to a preset mapping relationship, and specifically includes:

setting PCR integral time difference PCR of input program and output program recorded with mapping relation for each output queueoffset

The PCR '/STC' sample value pairs in the corresponding output queue are calculated according to the following formula:

PCR′=PCR+PCRoffset

STC′=STC。

6. the method as claimed in any one of claims 1 to 5, wherein the multiplexing output module multiplexes the at least one output program stream into at least one TS stream, specifically comprising:

calculating the transmission time required by each TS packet according to the total bit rate of the TS stream to be output and the total bit number of the standard TS packets;

respectively calculating the bit number of each path of output program to be output in the time of a single TS packet according to the transmission time required by each TS packet;

calculating the total bit number of each path of output program according to the bit number of each path of output program which should be output in a single TS packet time;

and when the total bit number of any one path of output program reaches the total bit number of the standard TS packet, taking out one TS packet in the any one path of output program according to the input sequence and inserting the TS packet into the TS stream to be output, and then updating the total bit number of the any one path of output program.

7. The method for reassembling a multi-TS stream program according to claim 6, further comprising:

when the total bit number of at least two paths of output programs reaches the total bit number of a standard TS packet, determining the priority sequence of each path of output program according to the number of conflicts, the total bit rate of the TS stream to be output and the bit rate of each path of output program, and selecting one path of output program to output according to the priority sequence;

and transferring the output program which is not output to the next TS packet, increasing the number of times of collision and judging the priority again.

8. The method of claim 7, wherein the priority order of each output program is determined according to the following steps:

if the conflicted output program contains the PCR packet, setting the output program containing the PCR packet as the highest priority;

if the TS packet to be inserted in the output program in conflict is a null packet, discarding the null packet;

if the conflicted output program does not contain the PCR packet and the TS packet to be inserted is not an empty packet, calculating the priority of each path of output program according to the following formula:

wherein the content of the first and second substances,indicates the priority, BitRATE, of the n-th output program in case of C-time conflictnBit rate, Bitrate, representing the nth output programTDenotes the total bit rate of the TS stream to be output, and C denotes the number of collisions.

9. A storage medium having stored therein instructions which, when read by a computer, cause the computer to execute a method of reassembling a multi-channel TS stream program according to any one of claims 1 to 8.

10. An apparatus for recombining a plurality of TS streams, comprising:

a memory for storing a computer program;

a processor for executing the computer program to implement the method of reassembling a multi-path TS stream program as claimed in any one of claims 1 to 8.

Technical Field

The invention relates to the technical field of digital televisions, in particular to a method and a device for recombining multi-channel TS (transport stream) programs.

Background

In a program making, broadcasting and encoding device, an application scenario is that audio and video of different programs in a plurality of TS streams (Transport Stream) need to be regrouped and combined to generate a new program combination. For example, suppose that there are two TS streams input in the system, set as TS1 and TS2, there are 1 program P1 in TS1, and 1 video V1 and 1 audio a1 in P1; TS2 includes 1 program path P2, and P2 includes 1 video path V2 and 1 audio path a 2. According to the requirements of service scenes, V1 and A2 need to be recombined into 1 new program P3. However, since V1 and a2 are derived from different programs P1 and P2, not only the audio-video data itself needs to be processed during merging, but also a new PCR needs to be generated during merging due to different Program Clock references (Program Clock references), and the new PCR needs to have a mapping conversion relationship with the original PCRs in P1 and P2. If the mapping transformation relationship is not well processed, the accumulated error of the time stamp can cause frame loss or pause of the video.

Disclosure of Invention

The technical problem to be solved by the present invention is to provide a method and an apparatus for reconstructing a multi-channel TS stream program, which is directed to the deficiency of the prior art.

The technical scheme for solving the technical problems is as follows:

a method for recombining a multi-path TS stream program comprises the following steps:

the demultiplexing module acquires N paths of TS streams, demultiplexes the N paths of TS streams to obtain N paths of programs, and sends the N paths of programs to the decoding module;

when receiving the PCR information of the N paths of programs, the decoding module records the current STC (System Time Clock) information, generates a PCR/STC sample value pair of each path of program, and sends the PCR/STC sample value pair of each path of program to the System Time management module; decoding the videos and the audios of the N paths of programs, and sending the decoded videos and audios to a grouping and combining module;

the system time management module stores the PCR/STC sample value pairs of the N paths of programs in N paths of input queues, calculates to obtain PCR '/STC' sample value pairs in corresponding output queues according to a preset mapping relation, and sends the obtained PCR '/STC' sample value pairs in all the output queues to the coding module;

the grouping and merging module recombines the decoded video and audio according to a preset recombination requirement to obtain at least one path of recombination result, and sends all the obtained recombination results to the coding module;

the encoding module encodes and compresses each path of recombined video and audio, calculates PCR information of each path of output program according to PCR '/STC' sample value in a corresponding output queue, performs TS packaging on each path of encoded and compressed video and audio according to the PCR information of each path of output program to obtain at least one path of output program stream, and sends all the obtained output program streams to the multiplexing output module;

the multiplexing output module multiplexes the at least one output program stream into at least one TS stream;

wherein N is more than or equal to 2.

Another technical solution of the present invention for solving the above technical problems is as follows:

a storage medium, wherein instructions are stored, and when the instructions are read by a computer, the instructions cause the computer to execute the method for reorganizing multiple TS streams as described in the above technical solution.

Another technical solution of the present invention for solving the above technical problems is as follows:

a reassembly device for multiple TS streams, comprising:

a memory for storing a computer program;

and the processor is used for executing the computer program to realize the recombination method of the multi-path TS programs according to the technical scheme.

The invention has the beneficial effects that: the recombination method and the device provided by the invention are suitable for the recombination of TS stream programs in the field of digital televisions, PCR/STC sample value pairs of the programs are generated through a decoding module, the PCR/STC sample value pairs of the programs are mapped by using a preset mapping relation through a system time management module, videos and audios are recombined through a grouping and combining module, and then each path of corresponding videos and audios after being coded and compressed is subjected to TS packaging according to the PCR information of each path of output programs, so that the audio and video of different programs in a plurality of TS streams are grouped and combined again, the influence of system time errors is eliminated, the problem that the combined new program is lost or blocked is solved, and the requirement of high-quality program conversion can be met.

Advantages of additional aspects 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

FIG. 1 is a schematic flow chart of a recombination method according to an embodiment of the present invention;

FIG. 2 is a schematic block diagram of a system provided in an embodiment of the reassembly method of the present invention;

FIG. 3 is a schematic diagram of an input/output queue mapping relationship provided by an embodiment of the reassembly method of the present invention;

FIG. 4 is a schematic structural framework diagram of a reconstitution device according to an embodiment of the present invention.

Detailed Description

The principles and features of this invention are described below in conjunction with the following drawings, which are set forth to illustrate, but are not to be construed to limit the scope of the invention.

At present, most of existing systems do not support free combination of video and audio among multiple programs, but adopt a mode of program integral switching, and cannot solve the problem that the audio and video in a new program may come from different program sources, so that application scenes are limited, higher requirements on program making equipment are met, and better flexibility and compatibility are not achieved.

In addition, in the existing scheme, a method for mapping and converting the PCR of the new program and the original PCR is not provided, but a local or external clock is used to regenerate a brand new time according to the frame rate. Although simple, this implementation has the problem of being inconsistent with the time it was originally intended for. Because the original programs are originated from different systems, if the equipment for producing and transmitting the programs and the equipment for recombining and combining the programs are different equipment, system time errors necessarily exist among the equipment. If a new PCR is used in a new program and does not correspond to the original time, the system time error is accumulated continuously, and finally the new program is blocked or lost, which is more serious particularly in the case of real-time program processing, so that the requirement of high-quality program conversion cannot be met.

Finally, in the existing scheme, in the video data processing, a data replication mode is basically adopted, but because the video data volume is large, the replication mode consumes a large amount of operation and I/O resources of the system, and increases the processing delay of the system, thereby increasing the processing capacity requirement and the end-to-end delay of the whole system.

Based on the above problems, the present invention provides a method and apparatus for recombining and merging multiple TS streams, which is further described below.

As shown in fig. 1, a schematic flow chart is provided for an embodiment of a reassembly method according to the present invention, the reassembly method is used for reassembly of multiple TS streams, and is implemented based on a reassembly system as shown in fig. 2, the reassembly system includes: the system comprises a demultiplexing module 1, a decoding module 2, a system time management module 3, a grouping and merging module 4, an encoding module 5 and a multiplexing output module 6, and a recombination method is described below by combining the recombination system, wherein the recombination method comprises the following steps:

s1, the demultiplexing module 1 obtains N paths of TS streams, demultiplexes the N paths of TS streams to obtain N paths of programs, and sends the N paths of programs to the decoding module 2;

it should be understood that a video, at least zero audio, and PCR for this program are included, for example, the 1 st program includes 1 video, 5 audios, and PCR for this program, the 2 nd program includes 1 video and PCR for this program, and the 3 rd program includes 1 video, 1 audio, and PCR for this program.

After demultiplexing by the demultiplexing module 1, only program information exists, and which TS stream each program originates from is not recorded. The program information refers to program-related information, such as video, audio, PCR, etc. contained in the program, and PSI information (program specific information) may be added according to service requirements.

All the demultiplexed information is sent to the decoding module 2 in real time to maintain the time base line information of the source program.

Alternatively, a unique integer number may be set for each program to be output for subsequent encoding, for example, 1 may be added in sequence from 1, such as program 1, program 2, program 3, and so on.

S2, when receiving the PCR information of N programs, the decoding module 2 records the current STC information, generates the PCR/STC sample value pair of each program, and sends the PCR/STC sample value pair of each program to the system time management module 3; the video and audio of the N programs are decoded, and the decoded video and audio are sent to a grouping and combining module 4;

it will be appreciated that the PCR/STC sample values are the basis for tracking the PCR time drift of the incoming program, and the decoding module 2 feeds this value to the system time management module 3.

The format information of the video and audio may be transmitted to the packet merging module 4 through a message.

Optionally, when the sample value pair is sent to the system time management module 3, a discontinuity point message may be added at the same time to prompt the system time management module 3 whether the sample value pair is a discontinuity point.

Where STC is the system clock.

S3, the system time management module 3 stores the PCR/STC sample value pairs of N paths of programs in N paths of input queues, calculates the PCR '/STC' sample value pairs in the corresponding output queues according to the preset mapping relation, and sends the PCR '/STC' sample value pairs in all the obtained output queues to the coding module 5;

the system time management module 3 is used for recording the clock characteristics of each path of input programs and generating the clock of the output program according to the mapping relation of input and output.

It should be understood that each incoming program has an input queue for storing all PCR/STC sample value pairs for that program; similarly, each output program has an output queue for storing PCR '/STC' sample value pairs of the output program. The number of input queues and output queues may be different, but it is necessary to satisfy one-to-one or one-to-many mapping relationship, i.e. one input queue may map to one or more output queues, but not allow many-to-one mapping relationship, i.e. multiple input queues may not map to the same output queue.

The mapping of the input and output queues can be configured by a user after one-to-one and one-to-many mapping relations are satisfied.

For example, as shown in fig. 3, an exemplary mapping relationship diagram of input/output queues is provided, where a and B in the input queues represent different PCR/STC sample value pairs of the same input program, and a ' and B ' in the input queues represent different PCR '/STC sample value pairs of the same output program.

In fig. 3, the number of input queues is m, and the number of output queues is n, corresponding to m input programs and n output programs, respectively. In fig. 3, the specific mapping relationship is: input queue 1 is mapped to output queue 1; input queue 2 maps to output queues 3 and 4; input queue 3 maps to output queue 2; input queue m maps to output queue n.

In addition, there is one PCR per output queueoffsetThe PCR overall time difference of the input and output programs with the mapping relation can be configured by a user according to actual requirements.

It should be understood that in the corresponding relation of input and output, the present embodiment uses video as the basis for mapping, that is, if the video of one input program becomes the video of the other output program by grouping and combining, the PCR/STC queue of the input program will be mapped to the corresponding output PCR '/STC' queue, where for the convenience of representation, the input program number and the input queue number are made to be the same, and likewise, the output program number and the output queue number are made to be the same.

S4, the grouping and merging module 4 recombines the decoded video and audio according to the preset recombination requirement to obtain at least one path of recombination result, and sends all the obtained recombination results to the encoding module 5;

it should be noted that the grouping and merging module 4 is configured to establish a corresponding relationship between input and output audio/videos, where in the corresponding relationship, input and output have a relationship of 1 to 1 and 1 to many, but there is no relationship of many to 1, that is, 1 output audio/video has and only has 1 input audio/video.

For example, 1 input video corresponds to 1 output video, or 1 input video corresponds to 3 output videos, but 1 output video cannot correspond to 3 input videos.

Specific recombination requirements can be configured by a user according to actual requirements, in order to facilitate regrouping, the grouping and merging module 4 numbers input audio and video respectively, and 1 may be added sequentially from 1, for example, 3 input videos are numbered as input video 1, input video 2 and input video 3, and 4 audio videos are numbered as input audio 1, input audio 2, input audio 3 and input audio 4.

The output audio/video is grouped according to the re-assembly requirement of the output program, for example, the output program 1 includes output video 1, output audio 1 and output audio 3, and then the output video 1, output audio 1 and output audio 3 are grouped.

Where output video 1 may be derived from input video 2, output audio 1 may be derived from input audio 2, and output audio 3 may be derived from input audio 3.

The packetized audio and video are sent to the following encoding module 5 according to the program groups and further processed by the encoding module 5.

Preferably, in order to avoid the delay and overhead caused by data copying, data transmission is performed by means of transmitting a ring buffer handle, and the following encoding module 5 obtains the ring buffer handle corresponding to the audio or video in the program, and then directly obtains the audio or video data from the ring buffer handle.

S5, the encoding module 5 encodes and compresses each path of recombined video and audio, calculates the PCR information of each path of output program according to the PCR '/STC' sample value in the corresponding output queue, and performs TS packaging on each path of encoded and compressed video and audio according to the PCR information of each path of output program to obtain at least one path of output program stream, and sends all the obtained output program streams to the multiplexing output module 6;

for example, each path of video and audio after being recomposed can be compressed into the formats of AAC, AC3, AVC, and HEVC.

It should be understood that the time stamp information for each outgoing program is stored in an output queue of the system time management module 3. For convenience, the output program group number may be set to coincide with the output queue number of the system time management module 3.

S6, the multiplexing output module 6 multiplexes at least one output program stream into at least one TS stream, and the output TS stream is sent to a subsequent transmission or playing link;

wherein N is more than or equal to 2.

The reassembly method and apparatus provided in this embodiment are suitable for TS stream program reassembly in the digital television field, generate PCR/STC sample value pairs of programs through the decoding module 2, map the PCR/STC sample values of the programs by using a preset mapping relationship through the system time management module 3, reassemble the video and audio through the grouping and combining module 4, and then perform TS encapsulation on each path of video and audio corresponding to the encoded and compressed program according to the PCR information of each path of output program, thereby implementing audio and video re-grouping and combining of different programs in multiple TS streams, eliminating the influence of system time errors, solving the problem of frame loss or stumbling of a combined new program, and being capable of satisfying the high-quality program conversion requirement.

Optionally, in some possible embodiments, before sending the PCR/STC sample pair of each program to the system time management module 3, the decoding module 2 further includes:

judging whether each PCR/STC sample value pair of each path of program is a discontinuous point or not through a discontinuous indication flag bit in the TS stream, and if the current sample value pair is the discontinuous point, adding a discontinuous point identifier for the current sample value pair;

if the current sample value pair is not a discontinuity, adding a discontinuity identification to the current sample value pair if the current sample value pair satisfies the following formula:

|PCR2-PCR1|>|STC2-STC1|×G

it is understood that there are at least 2 PCR/STC pairs to determine discontinuities, wherein PCR2/STC2For the current sample value pair, PCR1/STC1G is a preset constant and is a previous sample value pair of the current sample value pair.

It should be noted that the discontinuous indication flag bit may be determined by a discontinuous _ indicator flag bit in the TS header, and if the flag bit is 1, the current sample value pair is marked as a discontinuous point; if the flag bit is 0, the discontinuity point is judged through the formula.

Alternatively, G may be 3/50000+27, assuming that the maximum drift of the transceiver system clock is ± 30ppm, so the absolute value of the maximum drift is 60ppm, i.e. 3/50000 parts per million, and 27 is the maximum own 10ppm drift of the 27MHz clock, i.e. 27 parts per million.

It will be appreciated that these two thresholds may be increased depending on the clock conditions of the actual system in particular.

Optionally, in some possible embodiments, the encoding module 5 calculates PCR information of each output program according to the PCR '/STC' sample pair in the corresponding output queue, and specifically includes:

judging whether the PCR '/STC' sample value pairs in the corresponding output queues are continuous sample value pairs or not according to the discontinuous point identifiers, and calculating the PCR information of each path of output programs according to the following conditions aiming at the continuous sample value pairs:

if STCpGreater than STC' in all sample pairs in the corresponding output queue, and PCRmin′/STCmin' continuous sample centering STCmin' and STCpThe absolute value of the difference of (A) is the STC 'and STC' of the PCR '/STC' sample pair of all output queuespThe minimum value of the absolute value of the difference value of (b), the PCR information PCR of the currently output program is calculated according to the following formulap

PCRp=PCRmin′+STCp-STCmin′;

If STCpLess than STC' of all sample pairs in the corresponding output queue, and PCRmin′/STCmin' continuous sample centering STCmin' and STCpThe absolute value of the difference of (A) is the STC 'and STC' of the PCR '/STC' sample pair of all output queuespThe minimum value of the absolute value of the difference value of (b), the PCR information PCR of the currently output program is calculated according to the following formulap

PCRp=PCRmin′+STCmin′-STCp

If STCpFirst PCR in corresponding output queue1′/STC1' STC in consecutive sample pairs1' and second PCR2′/STC2' STC in consecutive sample pairs2In between, the PCR information PCR of the currently output program is calculated according to the following formulap

PCRp=(PCR2′-PCR1′)×(STCp-STC1′)÷(STC2′-STC1′)+PCR1′;

Wherein, STCpThe current system time of the program is output.

It should be understood that the encoded video data and audio data may be inserted into the program stream at the following time points:

PCRp=DTS-VBVDelay

wherein DTS is a decoding time stamp of each frame data, VBVDelayIs defined in the T-STD buffer model in the standard ISO/IEC13818-1 and may be provided by the coding unit.

The program stream generated by the encoding module 5 is sent to the multiplexing output module 6, and in order to facilitate multiplexing synthesis of the multiplexing output module 6, the program stream generated by the encoding module 5 may use a constant bit rate manner, and null packets may be inserted to maintain the constant bit rate when necessary.

Optionally, in some possible embodiments, the decoding module 2 decodes the video and audio of the N channels of programs, which specifically includes:

respectively decoding the video and the audio of the N channels of programs according to a preset format;

for example, video may be decoded to YCbCr format and audio may be decoded to PCM format.

Respectively establishing a first annular cache and a second annular cache according to the video format and the audio format of each path of program;

respectively detecting whether the residual space of the first annular cache and the second annular cache meets a preset space storage value;

if the first annular cache meets the preset spatial storage value, storing the decoded video in the first annular cache;

if the second shape cache meets the preset spatial storage value, storing the decoded audio in a second ring cache;

otherwise, the decoded video and the decoded video are put into a queue until the first annular buffer memory or the second annular buffer memory meets the preset spatial storage value, and then the decoded video and the decoded video are taken out from the queue for storage.

It should be noted that the ring buffer is a segment of continuous main memory storage area, and the ring means that when data is read or written to the last storage area, the data can jump to the beginning of the continuous main memory storage area through logic judgment to continue reading or writing. The establishing process is to allocate a section of continuous storage area according to the required size and set corresponding read-write pointer and the like.

The ring buffer is shared by the decoding module 2 and the encoding module 5, and the decoded original data is put into the ring buffer. Before decoding, the decoding module 2 will check whether the output ring buffer has enough residual space, and will continue decoding only when the residual space has at least one frame size, otherwise the decoding of the path of video or audio will wait until the encoder consumes a part of the data in the ring buffer, and will continue decoding only when there is residual space greater than or equal to one frame. The buffer size is determined according to the decoded format and stores 200ms data, or can be reduced or increased according to the system memory resource condition, and the byte size of the ring buffer is determined by the following formula:

wherein, buffer size is the byte size of the ring buffer, FrameSize is the size of each frame of YCbCr data, FrameRate is the frame rate of video, SampleRate is the sampling rate of audio, BitDepth is the audio bit depth, and ChannnelNum is the number of audio channels.

Optionally, in some possible embodiments, the calculating, by the system time management module 3, the PCR '/STC' sample value pair in the corresponding output queue according to a preset mapping relationship specifically includes:

setting PCR integral time difference PCR of input program and output program recorded with mapping relation for each output queueoffset

The PCR '/STC' sample value pairs in the corresponding output queue are calculated according to the following formula:

PCR′=PCR+PCRoffset

STC′=STC。

wherein, PCRoffsetCan be configured by users according to actual requirements.

It will be appreciated that when a PCR/STC sample pair of an input queue contains a discontinuity identification, a PCR '/STC' sample pair of an output queue retains a discontinuity indication for the corresponding PCR/STC sample pair of the input queue.

Optionally, in some possible embodiments, the multiplexing output module 6 multiplexes at least one output program stream into at least one TS stream, specifically including:

according to the total bit rate Bitrate of TS stream to be outputTCalculating the transmission time required by each TS packet according to the total bit number of the standard TS packets;

for example, the transmission Time required for each TS packet can be calculated according to the following formulaperPacket

TimeperPacket=188×8÷BitRateT

Wherein 188 × 8 represents the total number of bits of a standard TS packet, 188 represents 188 bytes, which is the length of one TS packet defined in standard ISO/IEC13818-1, and 8 represents 8 bits, which is the number of bits contained in one byte.

Respectively calculating the bit number of each path of output program to be output in the time of a single TS packet according to the transmission time required by each TS packet;

for example, the nth output program should be output within a single TS packet time can be calculated according to the following formulaBit number BitCountPerPacketn

BitCountPerPacketn=BitRaten×TimeperPacket

Wherein, BitratenIndicating the bit rate of the first output program.

Calculating the total bit number of each path of output program according to the bit number of each path of output program which should be output in a single TS packet time;

for example, TotalBitCount, which is the total number of bits per path of output program, may be calculated in segments according to the following formulan k

Where K is the TS packet sequence number of the entire TS stream, K is 0,1,2, …, K is the number of TS packets of the entire TS stream, n is the program sequence number, n is 1,2 … m, and m is the number of output programs of the current TS stream.

And when the total bit number of any one path of output program reaches the total bit number of the standard TS packet, taking out one TS packet from any one path of output program according to the input sequence and inserting the TS packet into the TS stream to be output, and then updating the total bit number of any one path of output program.

For example, the total number of bits may be updated according to the following equation:

optionally, in some possible embodiments, the method further includes:

when the total bit number of at least two paths of output programs reaches the total bit number of a standard TS packet, determining the priority sequence of each path of output program according to the number of conflicts, the total bit rate of the TS stream to be output and the bit rate of each path of output program, and selecting one path of output program to output according to the priority sequence;

and transferring the output program which is not output to the next TS packet, increasing the number of times of collision and judging the priority again.

Optionally, in some possible embodiments, the priority order of each output program is determined according to the following steps:

if the conflicted output program contains the PCR packet, setting the output program containing the PCR packet as the highest priority;

if the TS packet to be inserted in the output program in conflict is an empty packet, discarding the empty packet;

if the conflicted output program does not contain the PCR packet and the TS packet to be inserted is not an empty packet, calculating the priority of each path of output program according to the following formula:

wherein the content of the first and second substances,indicates the priority, BitRATE, of the n-th output program in case of C-time conflictnBit rate, Bitrate, representing the nth output programTIndicates the total bit rate of the TS stream to be output, C indicates the number of collisions, 24 is a preset value,<<indicating a left shift operation indicating that the bit rate of the nth output program is shifted left by 24 bits to increase the value.

It should be noted that all variables in the formula are converted into 64-bit integers, so as to ensure that data does not overflow, where C is 1 when a collision occurs for the first time, and if the program in the current collision is not output, that is, the priority is not the highest, when the priority of the next output packet is determined, C is made to be C + 1.

The method for selecting the conflict comprises the following steps: firstly, selecting the program with the highest priority under the current conflict to output; and (3) moving the rest un-output programs to the next TS packet, judging the priority again, wherein C is C +1, in addition, a new conflict program can be added into the next TS packet, C is set to be 1 for the newly added conflict program, and finally, judging the priority uniformly for all conflict programs including the program which is delayed in the last conflict and newly added in the current conflict, including the judgment of the PCR and the empty packet in the steps, and outputting the program with the highest priority. And moving the un-output program to the next output TS packet for priority judgment, and so on.

It is to be understood that some or all of the various embodiments described above may be included in some embodiments.

The present invention also provides a storage medium, in which instructions are stored, and when the instructions are read by a computer, the computer is caused to execute the method for recombining multiple TS streams as disclosed in any of the above embodiments.

As shown in fig. 4, a schematic structural framework is provided for an embodiment of the reassembly device of the present invention, the reassembly device is used for reassembly of multiple TS streams, and includes:

a memory 10 for storing a computer program;

the processor 20 is configured to execute a computer program to implement the method for recombining multiple TS streams as disclosed in any of the above embodiments.

The reassembly device provided by this embodiment is suitable for TS stream program reassembly in the field of digital televisions, generates PCR/STC sample value pairs of programs through a decoding module, maps the PCR/STC sample values of the programs using a preset mapping relationship through a system time management module, reassembles video and audio through a grouping and merging module, and then performs TS encapsulation on each path of video and audio corresponding to the encoded and compressed program according to PCR information of each path of output program, thereby implementing re-grouping and merging of audio and video of different programs in multiple TS streams, eliminating the influence of system time error, solving the problem of frame loss or stutter of a merged new program, and being capable of meeting the requirement of high-quality program conversion.

It should be noted that the above embodiments are product embodiments corresponding to previous method embodiments, and for the description of the product embodiments, reference may be made to corresponding descriptions in the above method embodiments, and details are not repeated here.

The reader should understand that in the description of this specification, reference to the description of the terms "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means 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 are not necessarily intended to 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. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.

In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described method embodiments are merely illustrative, and for example, the division of steps into only one logical functional division may be implemented in practice in another way, for example, multiple steps may be combined or integrated into another step, or some features may be omitted, or not implemented.

The above method, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention essentially or partially contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product stored in a storage medium and including instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method 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.

While the invention has been described with reference to specific embodiments, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

15页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于云端传送的智能遥控器信息读取方法

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类