METHOD AND APPARATUS FOR SPLICING DATA STREAMS

Abstract: A method and apparatus for aligning in time, and subsequently splicing, first and second data streams representing first and second encoded signals, which streams have one or more in-points and out-points, meaning places in the streams at which it is safe to enter and leave without causing undesired loss of data. The method comprises the steps of receiving as input the first and the second data streams (1, 2), and initially transmitting as an output the first data stream (5); selecting an out-point in the first data stream (1) and an in-point in the second data stream (2); delaying or advancing the second data stream (2) in order to align the in-point and the out-point at a splice point in time; switching (6) to transmit as an output, said second data stream instead of said first data stream, at the time of said splice point. The invention is particularly suitable for the insertion of a second stream into a first stream, without requiring that the length of the second stream correspond to any distance between out-points and in-points of the first stream, by delaying or advancing the first stream when re-entering from the second stream. A variable delay is associated with the first stream, and is updated at the completion of every insertion cycle dependent on the delaying or advancing. Preferably the invention includes selecting an in-point in the first stream that will decrease the accumulated variable delay.

Description: METHOD AND APPARATUS FOR SPLICING DATA STREAMS Technical field The present invention relates generally to the processing of digital image data, and in particular to a method and an apparatus for aligning streams of digital data comprising image data compressed in accordance with MPEG as well as other data. The invention also relates to a method for splicing data streams, and particularly to media insertion in the MPEG domain. Background Digital compression technology has brought considerable benefits in terms of bandwidth savings and the potential for improved image quality when telecommunicating or telecasting. The advantages, however, are balanced with drawbacks in the shape of operational complexity. A simple video manipulation such as a cut between two sources is considerably more complex in the MPEG domain than with uncompressed data. A state of the art solution in the broadcasting industry is to convert from compressed to uncompressed data for presentation, then to switch back again to compressed data for onward transmission. This is, however, comparatively costly and has a severe impact on video quality. Consequently, until the problem is solved in a more satisfactory manner, the broadcasting industry and consumer networks will have no option but to remain uncompressed and many opportunities for new digital services will be stalled. The problem of splicing has so far been intimately coupled to data compressed according to the MPEG standard (MPEG = Moving Pictures Expert Group). This standard for generic encoding, i.e. compression, of moving image data is described in the International Standard ISO/IEC 13818-1. first edition 1996-04-15. and ISO/TEC 13818-2. first edition 1996-05-15. which are herewith incorporated by reference. These documents define the framework of encoding data within what is called the MPEG domain. In this context a splice is the term within MPEG for the process of connecting the end of a first MPEG stream to the beginning of a second MPEG stream in order to create a stream that may be decoded with a minimum of artefacts at the splice point. Typically, splicing is performed on programs carried in MPEG Transport streams (TS). A program can be described as a set of data streams such as video, audio and related data that share a common time base, characterised by the Program Clock Reference PCR. The transmission of data in the MPEG domain is divided into access units. For video the access unit is called a picture, representing a certain period of presentation. In MPEG2 the three different video picture types are called I, P and B pictures respectively. The I means that an I picture is intra-coded, which in turn means that all the information needed to decode such a picture is contained in the I picture. Contrarily, a P picture is predictive-coded, meaning that it contains data about picture changes in relation to a preceding reference picture. Such a preceding reference picture can be an I picture or a P picture. B pictures are bidirectionally- coded pictures also containing change data. A B picture, however, can be encoded with prediction from both preceding and succeeding pictures. For audio the data is arranged in access units called frames, which can be said to correspond to the pictures in the video stream. Audio is considerably easier to handle than video since the sizes of audio frames do not tend to vary as much, and since all frames are separately decodable (compare with an I picture). A problem connected to the processing of compressed video streams, and especially splicing programs comprising video, is that, unlike uncompressed video, picture boundaries in the bitstream are not evenly spaced. Transmission of P and B pictures often take only a fraction of the time for transmission of I pictures. Synchronising picture boundaries to splice two streams is a problem that must be solved dynamically at the time of the splice. Furthermore, since not all pictures are independently decodable (as an I picture) not all picture boundaries can be taken as candidates for a splice point. Designers of splicers and architects of digital television systems must take this into consideration. Most prior art describing video splicing operations assume that the delay through a splicer is constant for each bit stream and that the splicer output rate is equal to the input rate. Another way of achieving seamless splicing has been presented in Proposed SMPTE Standard for Television, Splice Points for MPEG-2 Transport Streams, which is herewith incorporated by reference. Further background information about splicing in general and the SMPTE splicing standard proposal is found in the publications MPEG Splicing. Tutorial and Proposed SMPTE Standard and Splicing FAQ, Frequently Asked Questions about MPEG Splicing and the SMPTE Splicing Standard by Norm Hurst and Katie Cornog. These documents are herewith incorporated by reference. One aspect of he SMPTE proposal is to put constraints on the decoding delay times of video elementary streams (VES), so that the delay time for leaving one VES matches the decoding delay time for entering another VES. Another aspect is that information on when the delay time matching can be achieved. So called in-points and out-points for entering and leaving a VES, has to be indicated in the associated transport packets. One drawback with this technique is that the required pre-processing of program material is costly, and another drawback is the fact that practically all existing program material already encoded into the MPEG domain will be impossible to splice. A further drawback is that existing encoders and multiplexers cannot be used with pre-processed material, and have to be replaced. Further prior art within this field is known through US Patents No. 5,534,944 and US 5,793,431, which are herewith incorporated by reference. Object of the invention A basic problem with splicing elementary streams in the MPEG domain is how to find a suitable cut point at which to leave one stream, and correspondingly to find a suitable cut point at which to enter another stream. These cut points are here referred to as out-points and in-points, respectively, but are not intended to be limited to the above-mentioned kind of in-points and out-points as proposed by SMPTE. Furthermore, leaving a first stream for a second stream means that an outpoint for the first stream must match an in-point for the second stream. An aspect of this problem becomes apparent when switching from a first elementary stream to a second elementary stream, and then back to the first stream after a certain period of time. This is the situation e.g. when locally inserting media, such as commercial messages, into a program which is encoded and broadcast without knowledge of the inserted material. Since reentering the feed from source A requires an I picture and the inserted program can end at a point in time when source A only has a B or P picture to be displayed, there will be a misalignment problem. One obvious way to handle the misalignment problem is to wait for the next I picture before switching back to the network. This approach prevents a seamless splice; an unbroken sequence of presented pictures such that the first picture of the new stream, without the intervening of transition pictures, immediately follows the last picture of the old stream. Instead it results in a gap of several pictures between the end of the inserted commercial message and the next available I picture in the network feed. Such gaps in the presentation sequence of the resulting stream needs to be filled with, e.g., black frames, freeze frames, re- encoded frames or other kinds of synthetic transition pictures. It is thus an object of the invention to achieve alignment in time of in-points and out-points of two data streams, in order to facilitate seamless splicing. It is also an object to do so without decoding or altering any of the data content in the elementary streams. Summary of the invention The invention fulfils the objects stated above by providing a method for aligning in time and subsequently splicing first and second data streams representing first and second encoded signals. Each of the streams have joints of a first type between aggregates of data, wherein a first aggregate is decodable independent of the subsequent aggregate of the stream, and a second type of joints between aggregates of data, wherein a first aggregate is decodable independent of the preceding aggregate of the stream. The first type of joints serve as potential out- points, and the second type of joints serve as potential in-points, meaning places in the streams at which it is safe to enter and leave without causing undesired loss of data. The method comprises the steps of receiving as input the first and the second data streams, and transmitting as an output the first data stream. When switching from the first stream to the second stream, an out-point is selected in the first data stream and an in-point is selected in the second data stream. The second data stream is then delayed or advanced in order to align the in-point with the out-point. Splicing is achieved by switching to transmit as an output, said second data stream instead of said first data stream, at the time of said out-point. When inserting the second data stream into the first data stream, the method comprises the steps of selecting an out-point in said first data stream and placing an in-point in said second data stream aligned in time with said out-point. A splice to the second stream is achieved by switching to transmit, as an output, the second data stream instead of said first data stream at the aligning out-point and in-point. Ending the insertion period of the second stream is begins by selecting an out-point in the second data stream and an in-point in the first data stream, and then delaying or advancing the first data stream in order to align the in-point in the second data stream and the out-point in the first data stream. Switching back to transmit the first data stream as an output instead of the second data stream completes an insertion cycle. A variable delay parameter and buffer is associated with the first stream, and is updated at the completion of every insertion cycle dependent on the delaying or advancing performed in order to align the first stream with the second stream. Preferably the method includes selecting an in-point in the first stream that will decrease the accumulated value of the variable delay parameter. Brief description of the drawings The invention will now be described in detailed with reference to the accompanying drawings, of which Figure 1 illustrates a structure of video pictures in an MPEG2 stream; Figure 2 illustrates the misalignment between in-points and out-points in respective data streams; Figure 3 illustrates the method used in one embodiment of the invention, and Figure 4 illustrates the splicing device according to the invention, in the form of a block diagram. Detailed description of the preferred embodiments The concept of the invention can be applied on any type of data stream that is characterised by comprising access units, although the description is focused on MPEG streams and particularly MPEG2 video. When splicing programs in the MPEG domain the audio part is much simpler to handle than the video. Therefore, the following description is focused on video. The audio part will always follow the decisions made for the video, as will be explained subsequently. The invention is not directed towards the splicing operation itself, but to the alignment in time of data streams in order to facilitate the splicing operation. Leaving an MPEG2 video stream can always be done seamlessly, provided that the last pictures, before the Out-point, constitute a complete Sub Group, SG. A sub group consists of an anchor picture and all the following B pictures, if any, in stream order, which is characterised by the decoding time stamp DTS. The DTS can be used in the PES header (Packetized Elementary Stream) to indicate when the picture (or other access unit, such as an audio frame) is to be decoded by the system target decoder. For PAL (Phase Alternating Line) the pictures in a video stream are often transmitted with a cycle of twelve pictures, as illustrated in the top section of Fig. 1. Such a cycle is called a Group of Pictures, GOP, and always begins with an I picture. One picture represents 1/25 s of display time and one GOP equals 12/25 s of displayed video. The invention is not limited to the example of PAL and a twelve picture GOP, though, this is just one way of describing the structure of an MPEG video stream. In other standards, such as the NTSC (National TV Standards Committee), one GOP comprises 15 pictures, each representing 1/30 s, and will work just as well with the invention. In presentation time, characterised by the presentation time stamp PTS, the anchor pictures (I and P) are reordered, as is illustrated by the lower part of Fig. 1. (Corresponding to DTS, the PTS can be used in the PES header to indicate when the picture is to be presented by the system target decoder.) The reordering is one of the reasons why a video stream cannot be abandoned arbitrarily. Leaving just after a pair of B pictures (in DTS), at a sub-group border, means that the presentation will end with an anchor picture which, at worst (if it is a P picture), is predicted from an earlier anchor picture. It is thus possible to present all pictures, or resulting images, up to the out-point. Had the out-point been chosen between two B pictures, the result would have been a gap in the sequence of pictures, meaning no picture information, between the last B picture and the following anchor picture. Even worse, if the out-point had been chosen just after an anchor picture (in DTS), a double gap would result from the removed B pictures. Consequently, it is always safe to leave a video stream between sub groups SG, and according to the invention subgroups are considered when selecting outpoints. Thus, instead of selecting a picture at which to leave a stream, a subgroup SG is selected. This is referred to as an out SG, the last SG to send. Another requirement for a seamless switch is that at the same time as the last picture of the old stream is presented the first I-picture of the new stream should be decoded. Entering a new stream in a splice must be made with an I picture as the first picture. Had the first picture been a P picture, the anchor picture(s) from which it was predicted would not be present and decoding will fail. The same problem occurs when entering on a B picture. Entering into a video stream thus requires an I picture to be used as the first picture in stream order. It may also be the first in presentation order. If not, the B-pictures to be presented prior to it, but located after it in the stream (DTS), must not be bidirectionally predicted. Had they been predicted from an earlier anchor picture, decoding would fail since that (those) earlier pictures were not fed to the decoder. This means that the I-picture should belong to a Group Of Pictures (GOP) which does not depend on any previous pictures as reference for its decoding, a so-called closed GOP. The tail of the last picture from the old stream must be aligned with the start of a suitable I picture from the new stream. Unfortunately, there may not be an I picture available at that point. However, there is an I picture nearby, within a few pictures. Figure 2 illustrates a splicing scenario when switching from a first stream to a second stream. Here, a suitable out-point, after an out SG, has been selected in the first video stream. However, the out-point is not aligned with a suitable in-point, meaning an I picture beginning a closed GOP, in the second stream. The closest I pictures are illustrated by I in the second stream, and are in this application assumed to represent closed GOPs. A transport stream consists of one or more programs. The programs are independent of each other. Since they are independent, it is possible to slide a program back or forth slightly within the TS. For instance to align the start of an I picture with a requested point in time. The differences are taken out in VPD buffers within the splicing device, supplied for this purpose. This is the basic idea of variable program delay VPD. According to the invention, whenever a program is delayed or advanced in a VPD buffer, the total accumulated VPD for the program is changed correspondingly. Furthermore, the one of the two closest I pictures that results in the smallest absolute accumulated VPD is selected. The basic idea of the VPD in accordance with the invention can be summed up as: Selecting one of the two closest I pictures from the stream to enter, by varying the delay of that program, either by - pulling the I picture back from the past or by - pushing it into the future, dependent on the change of the accumulated VPD, thereby - aligning it with a selected out-point. It is important that the overall transport stream delay is constant, but the target program may be slightly shifted in time within the transport stream. The inserted delay is unnoticeable to a human viewer of the video splice. Since the material broadcast in the new, second, stream prior to the splice point has not been presented to the viewer, he or she has nothing to compare to when viewing the new material. By buffering programs in the splicing device, and using variable program delay on the program that is not presently transmitted to the decoder, it is therefore possible to align in-points and out-points in two programs to be spliced. As previously mentioned, the description has been focused on video, due to the high complexity of the video stream structure. However, when splicing programs generally also audio will have to be spliced, and possibly other streams to. Leaving or entering an MPEG1 level II audio stream is very simple compared to the video situation described above. This is mainly because each audio frame is like an I picture in video, i.e. they are independently decodable. Audio frames are not very different in size either. In a TS, the video pictures are always scheduled ahead of their corresponding audio frame, due to the longer delay needed in the video buffer of the decoder. This is why, in a splicing device, the video splicer, which is more complex and has to reinterpret the timing of a switch command, will report to the audio splicer at which time the video switch actually did occur, PTS_switch. The PTS_switch will almost never line up with the presentation time of any audio frame, since the presentation duration for the respective access units, i.e. video pictures and audio frames, are not the same. In fact both the old and the new audio streams will in most cases be independently misaligned to the time of the video switch. However, since audio and video for a program generally are strongly connected in time, e.g. due to mouth to speech synchronisation, it is not possible to treat them completely independently. If the video stream for a program is delayed, the audio stream has to be delayed correspondingly. Hence the denomination variable program delay. It should be understood by the description, however, that the technique of variable delay can be used for any kind of elementary stream in the MPEG domain, and is not restricted to video. A typical scenario for using the invention is local advertisement insertion. A first program encoded according to MPEG2, which is transmitted in a transport stream TS from a remote station or the like, e.g. nationally, is received by a local broadcast station. This first program can be just one out of several programs transmitted on the same TS. A second program is selected to replace the first stream for a certain period of time by local insertion. This means that there will be two splice points, out and in, in both programs. This second program can e.g. be a commercial message or local media. If the second program is stored on some kind of hardware storing medium, such as a disc, the start point of the program is locally controlled. The beginning of the program is then also an in-point, and can be arbitrarily chosen in time by starting the program. With such a locally stored and controlled program it is an easy task for a person skilled in the art to select a suitable out-point, or out SG, in the first program, and to start broadcasting the second program at the switch point. Other techniques, such as the solution proposed by SMPTE, can be used to match out-points and in-points also for two continuous streams. However, since there generally is no connection between content or structure of the spliced programs, a suitable in-point in the first program is not likely be found at the end out-point of the inserted material. According to the invention, this problem is solved by always passing input programs of the splicing device through separate VPD buffer queues. As explained in conjunction with Fig. 2, an I picture in the first program will be located within a few pictures from the out-point of the second program, which in this case is also the end of that program. Fig. 3 illustrates in a simplified manner how the VPD works for a first data stream from source A, into which several insertions are made. These insertions do not have to be of the same kind, or come from the same source, but are nevertheless said to be originating from source B in this figure. Fig. 3 describes how the VPD is used at a video insertion, but in order to simplify the figure, B or P pictures are not specified, nor are GOPs. Every box is instead representative of one SG. Furthermore, it is assumed here that all GOPs are closed, meaning that all I pictures are the beginning of a closed GOP. The first SGs to be replaced, i.e. the SGs immediately following the out SGs, are indicated by their boxes having thinner lines. The boxes having thicker lines are those transmitted to the decoder, meaning those that are forwarded by the local station for viewers to see on one and the same TV channel. All potential in-points are marked with an I above the corresponding box. All SGs of source A, represented by boxes, are numbered consecutively by numbers inside said boxes. These numbers correspond to a unit of presentation time, and are here referred to as PTS. The program of source A is transmitted continuously in a transport stream. The SGs that are not marked with boxes, meaning not broadcast, can therefore not be seen by a channel viewer. The data stream of SGs from source B begins with an in-point for every insertion. This is to illustrate that these beginnings, or in-points, can be arbitrarily placed in time. In this exemplified figure source B thus transmits a locally stored and controlled data stream, such as a program, always beginning with an in-point. This should only be seen as an example for of ease understanding of the figure and the invention, and is not intended as a limitation. Underneath the boxes for source B the presentation time for source B is shown in the time base of source A. After the first switch from A to B the first SG therefore has PTS = 4, which is the same as the first replaced SG from source A. Further down in Fig. 3 the broadcast signal is illustrated, indicating source A or B. This can be said to be the new, resulting video stream. The numbers of the boxes are naturally the same as for source A, since it is a video stream comprised in a program in the same continuous transport stream. Underlined, above the sequences of source A between insertions, is the accumulated VPD. It is, in this example, assumed that the VPD of the data stream from source A is zero before the first insertion. Over the potential in-points of source A is shown the delay change (ΔVPD) resulting from choosing that in-point, and above that, the accumulated VPD for that choice expressed in the number of SGs. At every splice back to source A there is a choice between two in-points, i.e. I pictures. The in-point selection is based upon the distance to the two closest I pictures and the current VPD of the data stream. The choices made are marked in the figure by filled arrows, whereas the abandoned choices have open arrows. In Figure 3 all switches from A to B are performed without any change of delay, as illustrated by the arrow being vertical. This is a consequence of source B being a locally controlled storing medium, whereby the in-point for the source B data stream in this simplified example actively can be placed at the corresponding outpoint of the source A data stream. When the first inserted material from source B is over, the splicer must switch back to source A. In the example of the figure VPD is zero so the splicer chooses the closest I picture after the first insertion. Since this is an earlier picture, the data stream from A has to be delayed by one (SG) in order to align with the out-point of B. The PTS of the delayed source A data stream is shown underneath the corresponding SG boxes. The VPD, indicated by a VPD parameter, is constant within the whole transmission period between insertions and is only changed at the end of an insertion cycle. When selecting I picture the one that minimises the accumulated variable program delay VPD is chosen. Therefore, after the second insertion between PTS 17 - 21, the splicer has not chosen the closest in-point at PTS 20, but the advanced in-point at PTS 25 which gives the smallest accumulated VPD. The accumulated VPD is in this case 1 - 3 = -2 (SGs), whereas it would have been 1 + 2 = 3 if PTS 20 had been used. Normally, the accumulated VPD will vary back and forth around zero, or some other equilibrium defined by a static delay from zero, after every second insertion. This way, the accumulated VPD after an arbitrary number of insertions will always be close to zero (or the chosen equilibrium), and is not likely to exceed the duration of 1 GOP in the case of MPEG2 video. After the third illustrated insertion from Source B, the VPD is again changed by a delay of 3 SGs. The VPD is thus 1 after this insertion. In another embodiment, also the data stream from source B is transmitted in a continuous transport stream, having its own VPD. In such a case, the VPD for source B is only changed when re-entering that stream, and source A would be considered as an insertion by source B. The description given above is highly focused on video, but concerns all elementary streams in the programs affected by the splicing operation. Synchronised elementary streams, however, can not be independently delayed, as explained. The VPD is thus preferably chosen for one stream, generally video which has the most complicated stream structure, but is valid for all elementary streams in the program. The description of the invention does not explain the actual splicing, but rather a method for aligning in-points and out-points in order to facilitate the splicing operation. Furthermore, the inventive concept of delaying a stream in order to match an in-point with an out-point in another stream, can be applied to many types of streams. For a stream transmitting aggregates of associated data, out-points can be chosen at joints between aggregates for which a first aggregate is decodable by a down stream decoder independent of the subsequent aggregate. In-points can be chosen at joints between aggregates for which a first aggregate is decodable by a down stream decoder independent of the preceding aggregate. According to the invention, applied to MPEG2, such out-point joints are SG borders, and in-point joints are those succeeded by an I-SG. When switching from a first data stream to a second, the second data stream is re-stamped to fit the out-point of the first stream. More specifically, the first inserted access unit, e.g. picture, of the second data stream inherits the time-stamps from the access unit it replaces in the first stream. When switching back from the second stream to the first, clocks and time stamps of that first data stream are recalculated and re-stamped according to the VPD change caused by the insertion. Figure 4 shows a block diagram of an exemplified embodiment of the invention. The description will be given for video, but can apply to other types of data streams as well, as previously mentioned. In figure 4 the flow of data runs from left to right. The video data bytes are organised in containers like linked lists, arrays or similar to represent pictures. As previously described, the pictures are in turn similarly organised to form Subgroups, comprising an anchor-picture and the following B-pictures that occur before the next anchor-picture. If a Subgroup has an I-picture as its anchor-picture it is called an I-Subgroup. A preferred embodiment of the invention comprises five FIFO buffers 1 - 5, each of which can store zero or a plurality of subgroups at a time. Video pictures, or Subgroups of pictures, are pushed from an external data source A into a first source buffer 1, serving as a first input to the apparatus, at the current frame rate for the transmission of that source A. Operatively connected to the source buffer 1 is a VPD buffer 3 for source A, taking data from the source buffer 1 as an input, such as video subgroups. An output of the VPD buffer 3 is connected to a first input of a switch 6. In a preferred embodiment, with an apparatus for two input sources, the switch 6 also comprises two inputs and two outputs, respectively. The switch is devised to assume one out of two possible positions. In a first position, the first input is connected straight forward to the first output, and a second input is correspondingly connected straight forward to a second output. In a second position for the switch 6, represented by the cross in the figure, the first input is connected to the second output, and the second input is connected to the first output. The switch 6 is controlled by a controller 7. As indicated by the roman figures in Fig. 4, controller 7 is operatively connected to each of the elements of the apparatus. The first output of the switch 6 is connected to an input of an output buffer 5, serving as output for the apparatus. In a position of the switch 6, with the first input and output connected, the video data is drained from the apparatus at the current frame rate for source A from the output buffer 5. In average, the same frame rate is also maintained internally when subgroups are transferred from the source buffer 1 through the VPD buffer 3 and the switch 6 to the output buffer 5. One or even more Subgroups each comprising several pictures may still be instantly transferred in and out of the buffers. This process continues as long as pictures are fed from source A. The apparatus also comprises a second source buffer 2 as input for a source B. The second source buffer 2 has an output connected to an input of a second VPD buffer 4. In typical ad-insertion systems, for which the present invention is particularly advantageous, a data source B is often pulled from a local disc storage system, rather than pushed like a stream that is live fed from an external source, such as source A. The data flow from source B may therefore often be locally controlled so that the VPD mechanism is favourable only to source A. In such case the length of a VPD buffer 4 for source B may always be zero. The symmetry of the apparatus allows both sources to be live streams, though, and that both take advantage of the VPD functionality. To simplify the description it is assumed, if not otherwise stated, that source A is a live stream and source B is locally controlled. An output of VPD buffer 4 is connected to the second input of the switch 6. Initially, when data from source A is both received and transmitted by the apparatus, the switch 6 is set to route subgroups from source A via VPD buffer 3 to the output buffer 5. The stream from source A is initially delayed by means of the length of VPD buffer 3. This length is defined by a predetermined number of whole pictures, giving a nominal program delay value, which is controlled by controller 7. The actual program delay value may vary around the nominal value from one insertion cycle to the next. According to the invention, the actual delay value for source A can only change at a time when the switch 6 is about to resume its initial position, i.e., to route source A straight through to the output. A full insertion cycle will now be described, from the start of replacing content from source A with content from source B to its completion. The switch 6 is then operated from its original state "straight-through" to "cross" and back again. When subgroups from source B are to be inserted, the switch 6 is set to cross-route the streams. To maintain synchronisation between the two running video sources, the process of receiving from source A continues as earlier described. While subgroups from source B are routed to the output buffer 5, those from source A are now routed for deletion. When a VPD Buffer is routed for deletion its output is temporarily closed so that it can accumulate a variable length sequence of subgroups for possible future reference. The number of subgroups in the VPD buffer may then vary for example between one and up to the two most recent I- sub groups plus all the P-subgroups between them. Subgroups which are older than the most recent I-subgroups are released at certain but not necessarily regular intervals. They are then flushed out from the right end of the VPD buffer and deleted through the switch 6 as indicated by the ground symbol. This release of obsolete pictures may occur when it becomes clear that they will never be used if and when this source is to be routed for output again. That is, when it can be decided that the most suitable I-subgroup to resume at, in the event of a future order to switch back to source A, is either the most recent one or a later one that has not even arrived yet. When the last subgroup of source B has been inserted, i.e., transferred to output buffer 5, the switch 6 should be reverted to route source A to the output. However, in this situation there may be more than one I-subgroup accumulated in the VPD buffer 3. The I-subgroup most suitable to succeed the last subgroup of source B must therefore be selected before the switch may occur. When the last SG from source B has been detected, but before it has passed the apparatus, in-point selection for source A is achieved by the controller 7. In the preferred embodiment working with MPEG2 video, queuing in the input buffers 1 and 2 is arranged in subgroups. Thus, every joint between queued elements, subgroups, is a potential out-point. Detection of possible in-points in the subgroup queues is also achieved by controller 7, by detection of weather the anchor picture is a P-picture or an I- picture. According to the invention, the most suitable I-subgroup (in the VPD buffer) is the one that will result in an accumulated actual program delay, which is closest to the nominal program delay. Selecting the latest I-subgroup in the VPD buffer results in a shorter actual program delay than selecting an older one. All the superfluous subgroups that precedes the said selected I-subgroup in the VPD buffer 3 are flushed out through the switch 6 and deleted before the switch 6 is reverted, so that the selected I-subgroup is transmitted directly after the out-SG marking the end of data from source B. In an embodiment of the invention, the splicer has two inputs and two outputs, and is thus symmetrical. In such an embodiment, the splicer comprises two output buffers 5 a and 5b, each coupled to one output of the switch 6, respectively. The device is then adapted to receive and transmit two streams, with input-output relations l-5a and 2-5b, or l-5b and 2-5a, dependent on the position of the switch 6. Seamless splicing on one stream can then be achieved analogous to what has been described for the device with one output 5, although generally only for one output stream at a time. Data transmitted from the other output is then simply disregarded. In a scenario where a splice is to be performed from a continuous first input data stream and a locally stored and controlled second input data stream, the following steps are performed: - queuing the input streams in buffers; selecting an out-point in the first data stream. In the case of the input data stream being an MPEG2 program comprising video, the out-point is preferably determined by an out SG of video pictures. Switching to an in-point, an in SG, of the second data stream after said out SG. Since the second program is locally controlled, the in-point is free in time and can actively be placed after the out SG of the first stream. In the case of MPEG2, the in-point is preferably an I picture beginning a closed GOP in the video stream. re-stamping time stamps of the second stream program, i.e. DTS and PTS in the case of MPEG2, so that the first inserted access unit (picture, frame) of the second stream inherits the time stamps of the access unit it replaces in the first stream; outputting the second data stream after the switch. When performing a splice between programs in the MPEG domain, the process steps described above also have to comprise the steps of selecting, in the input transport streams, the programs to be spliced; separating and controlling the different data streams of those programs separately, such as audio and video, and reassembling the program and the transport stream to be output. When the insertion sequence is over and the second data stream has come to an end, at a suitable out-point of that second stream, the output stream is to return to comprise the first data stream. According to the invention, this is achieved by selecting an out-point in the second data stream; - searching for a suitable in-point in the first data stream near said outpoint; comparing the accumulated variable program delay VPD of the first data stream with the time distance to the two closest in-points in the first stream; selecting the in-point resulting in the smallest accumulated VPD, when adding the time distance to the in-point to the previous VPD; delaying or advancing the first data stream accordingly in the VPD buffer by re-stamping all time stamps in the first data stream corresponding to the time distance between the selected out-point and in-point, and; - changing the VPD correspondingly, thereby aligning the in-point of the first data stream and the out-point of the second data stream at the switch time; switching to output the first data stream instead of the second data stream In the steps of returning to the first stream, the considerations of in-points and out-points when dealing with MPEG2 is of course maintained. Also, as previously stressed, when splicing MPEG2 programs there are several other steps that must be comprised in the process. The steps of a full insertion cycle have been described, and the only difference for the output stream, between the beginning and the end of the steps, is that the accumulated VPD, or more correctly the value of the accumulated VPD parameter, is changed. No data has been altered, or decoded. The seamless splices have been made possible by perfect alignment of the data streams at the switch points. An implementation of the invention in hardware or on a computer comprises means for carrying out each step of the method as described. A preferred embodiment of the invention is a computer program product, for use with a data processing and storage system, comprising a recording medium, and means recorded on the recording medium for carrying out the described method steps of the invention. The steps given above show, as explained previously, the case of one locally stored and controlled data stream and one continuous stream. More specifically, a method for media insertion has been described. This is to illustrate that switching from one program to another is just one problem, and as such it can be solved in several other ways. However, inserting a program of a certain specified length (display duration) will give rise to a new problem when switching back. The inventive concept of variable program delay can be applied to a case with two continuous data streams as well, though, such as two continuous MPEG2 transport streams. In such a case, both streams may have an associated VPD. The VPD for the second data stream is then changed only at re-entry into that data stream. When the second data stream is switched in, it is also possible to make a new insertion into the second data stream of a third data stream, e.g. when inserting a regional program into a national broadcast, and then inserting a local program in the regional program. Also in this case, a VPD buffer for the second (regional) data stream (program) is used when re-entering the regional program from the insertion of the third (local) program. The described embodiments are given as examples of the invention, and the invention can of course be modified in order to obtain a device and method for different cases of splicing multiple continuous transport streams, as well as successive insertion including more than two programs.

Claims: CLAIMS 1. A method for splicing first and second data streams representing first and second encoded signals, each of said streams having - first type joints between aggregates of data, wherein a first aggregate is decodable independent of the subsequent aggregate of the stream, and - second type joints between aggregates of data, wherein a first aggregate is decodable independent of the preceding aggregate of the stream, comprising the steps of: receiving as an input a first data stream; - receiving as an input a second data stream; transmitting as an output said first data stream; selecting as an out-point a first type joint in said first data stream; selecting as an in-point a second type joint in said second data stream; delaying or advancing said second data stream in order to align said in- point with said out-point; switching to transmit as an output, said second data stream instead of said first data stream, at the time of said out point. 2. A method for splicing first and second data streams representing first and second encoded signals, each of said streams having - first type joints between aggregates of data, wherein a first aggregate is decodable independent of the subsequent aggregate of the stream, and - second type joints between aggregates of data, wherein a first aggregate is decodable independent of the preceding aggregate of the stream, comprising the steps of: receiving as an input a first data stream; receiving as an input a second data stream; transmitting as an output said first data stream; selecting as an out-point a first type joint in said first data stream; - selecting as an in-point a second type joint in said second data stream; placing said in-point aligned in time with said out-point; switching to transmit, as an output, said second data stream instead of said first data stream; selecting as an out-point a first type joint in said second data stream; - selecting as an in-point a second type joint in said first data stream; delaying or advancing said first data stream in order to align the in- point in the second data stream with the out-point in the first data stream; switching back to transmit said first data stream as an output instead of said second data stream. 3. The method as recited in claim 1 or 2. in which the step of delaying or advancing is followed by the further step of: - adding the time change caused by said delay or advancement to a variable delay parameter (VPD) for the corresponding data stream, accumulated from previous in-point selections for that data stream. 4. The method as recited in claim 3, in which selecting an in-point comprises the steps of: measuring the time distance to the two closest possible in-points, located in time before and after the selected out-point; comparing the measured time distances with the accumulated variable delay parameter (VPD) for the data stream to enter; selecting the in-point resulting in the smallest absolute value of the accumulated variable delay for the data stream to enter, and adding the time distance between the selected out-point and the selected in-point to the variable delay parameter (VPD) accumulated from previous in-point selections for the data stream to enter. 5. The method as recited in claim 3 or 4, in which selecting an in-point comprises the further steps of: regarding an I picture beginning a closed group of pictures in a video stream of the program to enter as a possible in-point. 6. The method as recited in any of the preceding claims, in which selecting an out-point means selecting an out subgroup, the last subgroup to send before leaving a program, a subgroup comprising an I or P picture and any following B pictures in stream order in a video stream of the program to leave. 7. The method as recited in any of the preceding claims, further comprising the steps of: re-stamping time stamps (DTS, PTS) in a delayed or advanced program, in accordance with the time delay or advancement. 8. The method as recited in any of the previous claims, wherein said data streams are video elementary streams encoded according to MPEG2. 9. The method as recited in any of the previous claims, characterised by being computer implemented, for use in a computer-based data processing and storage system (1,2,3,4,5,6,7). 10. An apparatus for splicing a first data stream from a source A and a second data stream from a source B representing first and second encoded signals, each of said streams having - first type joints between aggregates of data, wherein a first aggregate is decodable independent of the subsequent aggregate of the stream, and - second type joints between aggregates of data, wherein a first aggregate is decodable independent of the preceding aggregate of the stream, the apparatus comprising first buffering means (1, 3) for input of data from source A, second buffering means (2, 4) for input of data from source B, switching means (6) having a first input operatively connected to said first buffering means (3) and a second input operatively connected to said second buffering means (2, 4), the switch further having an output operatively connected to output means (5) for the apparatus, wherein controlling means (7) operatively connected to said switch (6) is devised to control the switch (6) to route data from said first buffering means (3) or said second buffering means (2, 4) to said output means (5). 11. The apparatus as recited in claim 10, wherein said data streams are video elementary streams encoded according to MPEG2. 12. The apparatus as recited in claim 10 or 11, wherein said first input buffering means includes a first input buffer (1) serving as an input for the apparatus, and a variable delay buffer (3) having an input operatively connected to the first input buffer (1) and an output operatively connected to said first input of the switching means (6). 13. The apparatus as recited in any of the claims 10 - 12, wherein said switching means have a second output connected to data deleting means, and said controlling means are devised to control the switch to route data from said first buffering means (3) or said second buffering means (2, 4) to said deleting means. 14. The apparatus as recited in claim 13, wherein said switching means is devised to assume a position where its first input and its first output are connected, and its second input and its second are connected, or a position where its first input and its second output are connected, and its second input and its first output are connected. 15. The apparatus as recited in any of the claims 10 - 14, wherein said output means comprises an output buffer (5) for onward transmission of data from one of said sources A or B.. 16. The apparatus as recited in claim 15 in conjunction with claim 12, wherein said buffers (1, 2, 3, 4, 5) are FIFO buffers. 17. The apparatus as recited in any of the claims 10 - 16, wherein said controlling means (7) is capable of controlling the rate of draining said input buffering means (1,3 and 2,4) to said switching means (6). 18. The apparatus as recited in claim 17, wherein said controlling means (7) includes means for reading the input data streams, means for detecting an outpoint in the stream currently routed to the output means (5), means for selecting an in-point in the other input stream, means for controlling the drain rate of data of said other input stream from the corresponding buffering means (1,3 or 2,4) to said deleting means in order to align said in-point with said out-point, and means for switching said switching means (6) to transmit said other data stream to the output buffering means (5) where said streams are aligned. 19. A computer program product, for use with a data processing and storage system, for splicing first and second data streams representing first and second encoded signals, each of said streams having - first type joints between aggregates of data, wherein a first aggregate is decodable independent of the subsequent aggregate of the stream, and - second type joints between aggregates of data, wherein a first aggregate is decodable independent of the preceding aggregate of the stream, the computer program product comprising: - a recording medium; - means, recorded on the recording medium for carrying out the steps of receiving as an input a first data stream (1); receiving as an input a second data stream (2); - transmitting as an output said first data stream (5); selecting an out-point in said first data stream; selecting an in-point in said second data stream; delaying or advancing said second data stream in order to align said in- point and out-point at a splice point in time; switching (6) to transmit as an output, said second data stream instead of said first data stream, at the time of said splice point. 20. A computer program product, for use with a data processing and storage system, for splicing first and second data streams representing first and second encoded signals, each of said streams having - first type joints between aggregates of data, wherein a first aggregate is decodable independent of the subsequent aggregate of the stream, and - second type joints between aggregates of data, wherein a first aggregate is decodable independent of the preceding aggregate of the stream, the computer program product comprising: - a recording medium; - means, recorded on the recording medium for carrying out the steps receiving as an input a first data stream; - receiving as an input a second data stream; transmitting as an output said first data stream; selecting an out-point in said first data stream; placing an in-point in said second data stream aligned in time with said out-point; - switching to transmit, as an output, said second data stream instead of said first data stream; selecting an out-point in said second data stream; selecting an in-point in said first data stream; delaying or advancing said first data stream in order to align the in- point in the second data stream and the out-point in the first data stream; switching back to transmit said first data stream as an output instead of said second data stream. 21. The computer program product as recited in claim 19 or 20, further comprising means for - adding the time change caused by said delay or advancement to a variable delay parameter (VPD) for the corresponding data stream, accumulated from previous in-point selections for that data stream. 22. The computer program product as recited in claim 21, further comprising means for selecting an in-point by carrying out the steps of: measuring the time distance to the two closest possible in-points, located in time before and after the selected out-point; comparing the measured time distances with the accumulated variable delay parameter (VPD) for the data stream to enter; selecting the in-point resulting in the smallest absolute value of the accumulated variable delay for the data stream to enter, and - adding the time distance between the selected out-point and the selected in-point to the variable delay parameter (VPD) accumulated from previous in-point selections for the data stream to enter. 23. The computer program product as recited in claim 21 or 22, further comprising means for selecting an in-point by carrying out the steps of: regarding an I picture beginning a closed group of pictures in a video stream of the program to enter as a possible in-point. 24. The computer program product as recited in any of the claims 19 - 23, further comprising means for selecting an out-point by selecting an out subgroup, the last subgroup to send before leaving a program, a subgroup comprising an I or P picture and any following B pictures in stream order in a video stream of the program to leave. 25. The computer program product as recited in any of the claims 19 - 24, further comprising means for re-stamping time stamps (DTS, PTS) in a delayed or advanced program, in accordance with the time delay or advancement. 26. The computer program product as recited in any of the claims 19 - 25, wherein said data streams are video elementary streams encoded according to MPEG2. 27. An apparatus for splicing a first data stream from a source A and a second data stream from a source B representing first and second encoded signals, each of said streams having - first type joints between aggregates of data, wherein a first aggregate is decodable independent of the subsequent aggregate of the stream, and - second type joints between aggregates of data, wherein a first aggregate is decodable independent of the preceding aggregate of the stream, the apparatus comprising first buffering means (1, 3) for input of data from source A, second buffering means (2, 4) for input of data from source B, switching means (6) having a first input operatively connected to said first buffering means (3) and a second input operatively connected to said second buffering means (4), the switch further having a first output operatively connected to first output means (5a) for the apparatus, and a second output operatively connected to second output means (5b) for the apparatus , wherein controlling means (7) operatively connected to said switch (6) is devised to control the switch (6) to route data from said first buffering means (3) to said first output means (5a) and from said second buffering means (4) to said second output means (5b),or from said first buffering means (3) to said to said second output means (5b) and from said second buffering means (4) to said first output means (5a).

Inventors: ANDERSSON ROGER, FARM LARS, ANDERSSON, ROGER, FARM, LARS
Applicants: ANDERSSON ROGER, FARM LARS, LIMT TECHNOLOGY AB, ANDERSSON, ROGER, FARM, LARS
Application year: 1999
Main classification: H04N7
IPC codes: H04N7