[FFmpeg-devel] [PATCH] make packet_size in AVFormatContext unsigned

Michael Niedermayer michaelni
Wed Jun 17 20:24:44 CEST 2009

On Wed, Jun 17, 2009 at 09:45:01AM -0400, Ronald S. Bultje wrote:
> Hi,
> On Tue, Jun 16, 2009 at 9:07 PM, Ronald S. Bultje <rsbultje at gmail.com>wrote:
> > Arent you maintainer?or maybe you have the spec handy w/o me having to pay
> > for it? :)
>  Oh boy, a spec. How exciting. Let's do my reading.
> "The PES packet data from elementary stream n is passed to the input buffer
> for stream n, Bn. Transfer of byte i from the
> system target decoder input to Bn is instantaneous, so that byte i enters
> the buffer for stream n, of size BSn, at time t(i).
> Bytes present in the pack header, system headers, Program Stream Maps,
> Program Stream Directories, or PES packet
> headers of the Program Stream such as SCR, DTS, PTS, and packet_length
> fields, are not delivered to any of the
> buffers, but may be used to control the system."
> and then:
> "The input buffer sizes BS1 through BSn are given by the P-STD buffer size
> parameter in the syntax in equations 2-16
> and 2-17." (p.53,
> So there is a max packet size, which is minus the packet header, but is
> stream-dependent. That's not what we do. But anyway, let's see what the max
> value for BSn is.
> 2.16/17:
> "P-STD_buffer_size ? The P-STD_buffer_size is a 13-bit unsigned integer, the
> meaning of which is only defined if this
> PES packet is contained in a Program Stream. It defines the size of the
> input buffer, BSn, in the P-STD. If
> P-STD_buffer_scale has the value '0', then the P-STD_buffer_size measures
> the buffer size in units of 128 bytes. If
> P-STD_buffer_scale has the value '1', then the P-STD_buffer_size measures
> the buffer size in units of 1024 bytes. Thus:
> if (P-STD_buffer_scale == 0)
>     BSn = P-STD_buffer_size x 128 (2-16)
> else
>     BSn = P-STD_buffer_size x 1024 (2-17)" (p. 40)
> so the max buffer size, and thus the max size of the packet data, should fit
> 10+13 bytes, i.e. 1<<23 = 8MB (ok, ok, +10 bytes for the packet header). Am
> I close here? Then the minimum size required is the size of the packet
> header, i.e. 10 bytes, and mpegenc.c makes assumptions that it is at least
> 10 bytes more than this, so 20 bytes.
> Attached patch OK?

probably, and even if not the packet size limits are not going to be an
issue in practice, so ok

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.
-------------- 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/20090617/2485fc19/attachment.pgp>

More information about the ffmpeg-devel mailing list