]> git.sesse.net Git - ffmpeg/commitdiff
fix pes overhead computation, patch by Niobos, niobos at dest-unreach dot be
authorNiobos <niobos@dest-unreach.be>
Thu, 17 Sep 2009 19:07:09 +0000 (19:07 +0000)
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>
Thu, 17 Sep 2009 19:07:09 +0000 (19:07 +0000)
Originally committed as revision 19902 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavformat/mpegtsenc.c
tests/lavf.regression.ref

index 7138009716e9efb11085b6deb2d2c25ad3a86af6..48df4386dadd29aae9e36c37363ddb4eb71102d2 100644 (file)
@@ -428,10 +428,18 @@ static int mpegts_write_header(AVFormatContext *s)
         total_bit_rate += st->codec->bit_rate;
         /* PES header size */
         if (st->codec->codec_type == CODEC_TYPE_VIDEO ||
-            st->codec->codec_type == CODEC_TYPE_SUBTITLE)
-            total_bit_rate += 25 * 8 / av_q2d(st->codec->time_base);
-        else
-            total_bit_rate += total_bit_rate * 25 / DEFAULT_PES_PAYLOAD_SIZE;
+            st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
+            /* 1 PES per frame
+             * 19 bytes of PES header
+             * on average a half TS-packet (184/2) of padding-overhead every PES */
+            total_bit_rate += (19 + 184/2)*8 / av_q2d(st->codec->time_base);
+        } else {
+            /* 1 PES per DEFAULT_PES_PAYLOAD_SIZE bytes of audio data
+             * 14 bytes of PES header
+             * on average a half TS-packet (184/2) of padding-overhead every PES */
+            total_bit_rate += (14 + 184/2) *
+                st->codec->bit_rate / DEFAULT_PES_PAYLOAD_SIZE;
+        }
     }
 
     /* if no video stream, use the first stream as PCR */
index a00aaad91910f15c02e85fd47b7356833bc9bdcb..8b0b1555c999618538a5e109380b835ee05afa2e 100644 (file)
@@ -15,8 +15,8 @@ e36a005ecca9add8bda6e0655d03716f *./tests/data/b-lavf.mpg
 b3174e2db508564c1cce0b5e3c1bc1bd *./tests/data/b-lavf.mxf_d10
 5330989 ./tests/data/b-lavf.mxf_d10
 ./tests/data/b-lavf.mxf_d10 CRC=0xc3f4f92e
-34c47c149402e602c87455c4276ea0a5 *./tests/data/b-lavf.ts
-438792 ./tests/data/b-lavf.ts
+5db794c5f69f934bbcdbe32de1df9f3a *./tests/data/b-lavf.ts
+436160 ./tests/data/b-lavf.ts
 ./tests/data/b-lavf.ts CRC=0x133216c1
 62c5aeb636fc82cf6ba6277d36e42cb5 *./tests/data/b-lavf.swf
 329479 ./tests/data/b-lavf.swf