[FFmpeg-devel] [PATCH] avformat/mpegtsenc: Fix multi program so that it supports adding the same stream to multiple programs.

Michael Niedermayer michael at niedermayer.cc
Mon Jan 25 19:35:58 CET 2016


On Sun, Jan 24, 2016 at 03:54:34PM +0100, Vittorio Gambaletta (VittGam) wrote:
> Hi,
> 
> On 24/01/2016 12:01:38 CET, Michael Niedermayer wrote:
> >On Sun, Jan 24, 2016 at 06:06:36AM +0100, Vittorio Gambaletta (VittGam) wrote:
> >>Signed-off-by: Vittorio Gambaletta <ffmpeg-dev at vittgam.net>
> >>---
> >> libavformat/mpegtsenc.c |   15 +++++++++++++--
> >> 1 file changed, 13 insertions(+), 2 deletions(-)
> >>
> >>diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> >>index 2c12043..a20e229 100644
> >>--- a/libavformat/mpegtsenc.c
> >>+++ b/libavformat/mpegtsenc.c
> >>@@ -275,8 +275,19 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
> >>         AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
> >>
> >>         if (s->nb_programs) {
> >>-            AVProgram *program = av_find_program_from_stream(s, NULL, i);
> >>-            if (program->id != service->sid)
> >>+            int j, k, found = 0;
> >>+
> >>+            for (j = 0; j < s->nb_programs; j++)
> >>+                if (s->programs[j]->id == service->sid) {
> >>+                    for (k = 0; k < s->programs[j]->nb_stream_indexes; k++)
> >>+                        if (s->programs[j]->stream_index[k] == i) {
> >>+                            found = 1;
> >>+                            break;
> >>+                        }
> >>+                    break;
> >>+                }
> >
> >av_find_program_from_stream() should be run in a loop to enumerate
> >the programs, see other uses of av_find_program_from_stream()
> 
> Wouldn't this solve the problem backwards?

yes, though it would avoid directly accessing the data structs.
no big problem really though, i see the av_find_program_from_stream()
isnt exactly optimal here
so applied

thanks

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have often repented speaking, but never of holding my tongue.
-- Xenocrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160125/f34172da/attachment.sig>


More information about the ffmpeg-devel mailing list