[Ffmpeg-devel] mpeg transport streams

Måns Rullgård mru
Wed Jun 1 11:38:58 CEST 2005


Better, but you're still needlessly moving things to mpegts.h.  If a
struct is only used within one source file, the definition may as well
be at the top of that file.

> --- ../FFMpeg-20050530/libavformat/mpegtsenc.c	2005-03-09 03:12:44.000000000 +0100
> +++ libavformat/mpegtsenc.c	2005-06-01 10:55:59.000000000 +0200
> @@ -22,6 +22,8 @@
>
>  /* write DVB SI sections */
>
> +char *service_name = 0;

What's this?  A global variable.  What for?

> @@ -186,40 +188,210 @@ int mpegts_write_section1(MpegTSSection 
>  /* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
>  #define DEFAULT_PES_HEADER_FREQ 16
>  #define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
> +#define MAX_PES_PAYLOAD_SIZE DEFAULT_PES_PAYLOAD_SIZE * 1024

That's needlessly large.  The PES payload can never be more than
0xfffc bytes, unless it's one of the unbounded video packets allowed
in transport streams, and those are, well, unbounded.

> +/* write empty cat */
> +static void mpegts_write_cat(AVFormatContext *s)
> +{
> +    uint8_t data[TS_PACKET_SIZE];
> +    uint16_t len = 9;
> +    MpegTSWrite *ts = s->priv_data;
> +
> +    data[0] = CAT_TID;
> +    data[1] = 0xb0 | len >> 8;
> +    data[2] = len & 0xff;
> +    data[3] = 0;		// reserved
> +    data[4] = 0;		// reserved
> +    data[5] = 1;		// reserved | version | current_next_indicator
> +    data[6] = 0;		// section_number
> +    data[7] = 0;		// last_section_number
> +    mpegts_write_section(&ts->cat, data, len + 3);
> +}

This is not needed.  The CAT is only required if at least one program
is scrambled, and AFAIK we're not scrambling things.

I haven't looked closely at the rest of it yet.

-- 
M?ns Rullg?rd
mru at inprovide.com





More information about the ffmpeg-devel mailing list