[FFmpeg-devel] [PATCH] demux individual program out of MPEG-TS

Michael Niedermayer michaelni
Wed Sep 12 20:18:49 CEST 2007


Hi

On Sun, Sep 09, 2007 at 12:09:38PM +0200, Nico Sabbi wrote:
> Nico Sabbi wrote:
>> Nico Sabbi wrote:
>>> Michael Niedermayer wrote:
>>>
>>>
>>>> information about programs should be properly exported and the user
>>>> should be able to select any set of program (id) s she wants
>>>> this could possibly be realized with AVDiscard per program(id) similar 
>>>> to
>>>> AVStream
>>>>
>>>> [...]
>>>>
>>>
>>> like this? I exported MpegTSService from mpegts.c as AVProgram (a more
>>> generic name) to avformat.h and added code to discard programs
>>> on her request.
>>> ffmpeg.c is still unpatched
>> sprry, forget it: I just realized  it's buggy
>
>
> updated.
> I added some code to keep track of pids <==> programs mapping,
> in order to detect if the pid is to be discarded
> (if belonging only to discarded programs) or not

> Index: libavformat/mpegts.c
> ===================================================================
> --- libavformat/mpegts.c	(revisione 10435)
> +++ libavformat/mpegts.c	(copia locale)
[not maintained by me]
> Index: libavformat/avformat.h
> ===================================================================
> --- libavformat/avformat.h	(revisione 10435)
> +++ libavformat/avformat.h	(copia locale)
> @@ -345,6 +345,14 @@
>      int64_t pts_buffer[MAX_REORDER_DELAY+1];
>  } AVStream;
>  
> +typedef struct AVProgram {
> +    int running:1;

please use some normal int flags


> +    enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller
> +    int id;
> +    char *provider_name; /**< DVB Network name, "" if not DVB stream */
> +    char *name; /**< DVB Service name, "MPEG Program [sid]" if not DVB stream*/
> +} AVProgram;

please vertically align them


> +
>  #define AVFMTCTX_NOHEADER      0x0001 /**< signal that no header is present
>                                           (streams are added dynamically) */
>  
> @@ -360,6 +368,8 @@
>      ByteIOContext pb;
>      unsigned int nb_streams;
>      AVStream *streams[MAX_STREAMS];
> +    unsigned int nb_programs;
> +    AVProgram **programs;
>      char filename[1024]; /**< input or output filename */
>      /* stream info */
>      int64_t timestamp;

adding these in the middle breaks the ABI


> @@ -647,6 +657,7 @@
>   * @param id file format dependent stream id
>   */
>  AVStream *av_new_stream(AVFormatContext *s, int id);
> +AVProgram *av_new_program(AVFormatContext *s, int id, char *provider_name, char *name);

to match av_new_stream() i would prefer if its just
AVProgram *av_new_program(AVFormatContext *s, int id);


>  
>  /**
>   * Set the pts for a given stream.
> Index: libavformat/utils.c
> ===================================================================
> --- libavformat/utils.c	(revisione 10435)
> +++ libavformat/utils.c	(copia locale)
> @@ -2067,6 +2067,11 @@
>          av_free(st->codec);
>          av_free(st);
>      }
> +    for(i=s->nb_programs-1; i>=0; i--) {
> +        av_free(s->programs[i]->provider_name);
> +        av_free(s->programs[i]->name);
> +        av_free(s->programs[i]);

use av_freep() please so they all are NULL

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070912/e05aadd9/attachment.pgp>



More information about the ffmpeg-devel mailing list