Browse code

In ipod/mov/mp4 muxer, always write esds descriptor length using 4 bytes, ipod shuffle doesn't support anything else.

Baptiste Coudurier authored on 2011/03/31 06:08:16
Showing 4 changed files
... ...
@@ -238,16 +238,9 @@ static int mov_write_enda_tag(AVIOContext *pb)
238 238
     return 10;
239 239
 }
240 240
 
241
-static unsigned int descrLength(unsigned int len)
242
-{
243
-    int i;
244
-    for(i=1; len>>(7*i); i++);
245
-    return len + 1 + i;
246
-}
247
-
248 241
 static void putDescr(AVIOContext *pb, int tag, unsigned int size)
249 242
 {
250
-    int i= descrLength(size) - size - 2;
243
+    int i = 3;
251 244
     avio_w8(pb, tag);
252 245
     for(; i>0; i--)
253 246
         avio_w8(pb, (size>>(7*i)) | 0x80);
... ...
@@ -257,15 +250,14 @@ static void putDescr(AVIOContext *pb, int tag, unsigned int size)
257 257
 static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
258 258
 {
259 259
     int64_t pos = avio_tell(pb);
260
-    int decoderSpecificInfoLen = track->vosLen ? descrLength(track->vosLen):0;
260
+    int decoderSpecificInfoLen = track->vosLen ? 5+track->vosLen : 0;
261 261
 
262 262
     avio_wb32(pb, 0); // size
263 263
     ffio_wfourcc(pb, "esds");
264 264
     avio_wb32(pb, 0); // Version
265 265
 
266 266
     // ES descriptor
267
-    putDescr(pb, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) +
268
-             descrLength(1));
267
+    putDescr(pb, 0x03, 3 + 5+13 + decoderSpecificInfoLen + 5+1);
269 268
     avio_wb16(pb, track->trackID);
270 269
     avio_w8(pb, 0x00); // flags (= no flags)
271 270
 
... ...
@@ -1,3 +1,3 @@
1
-c145305a775eb2de43cdf94eb1ab5240 *./tests/data/lavf/lavf.mov
2
-357669 ./tests/data/lavf/lavf.mov
1
+439684b82ccc1fdd24a23392c238ae53 *./tests/data/lavf/lavf.mov
2
+357681 ./tests/data/lavf/lavf.mov
3 3
 ./tests/data/lavf/lavf.mov CRC=0x2f6a9b26
... ...
@@ -1,4 +1,4 @@
1
-fd83f2ef5887a62b4d755d7cb5f0ac59 *./tests/data/vsynth1/odivx.mp4
2
-540144 ./tests/data/vsynth1/odivx.mp4
1
+080e75117f8142001b096cd977ba287e *./tests/data/vsynth1/odivx.mp4
2
+540156 ./tests/data/vsynth1/odivx.mp4
3 3
 8828a375448dc5c2215163ba70656f89 *./tests/data/mpeg4.vsynth1.out.yuv
4 4
 stddev:    7.97 PSNR: 30.10 MAXDIFF:  105 bytes:  7603200/  7603200
... ...
@@ -1,4 +1,4 @@
1
-47de227982e77830a2db278214a08773 *./tests/data/vsynth2/odivx.mp4
2
-119797 ./tests/data/vsynth2/odivx.mp4
1
+8ffbe8ce43fe126b12cf9621717d641b *./tests/data/vsynth2/odivx.mp4
2
+119809 ./tests/data/vsynth2/odivx.mp4
3 3
 90a3577850239083a9042bef33c50e85 *./tests/data/mpeg4.vsynth2.out.yuv
4 4
 stddev:    5.34 PSNR: 33.57 MAXDIFF:   83 bytes:  7603200/  7603200