Revision 93dfda88 libavformat/movenc.c

View differences:

libavformat/movenc.c
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 250
static int mov_write_esds_tag(AVIOContext *pb, MOVTrack *track) // Basic
258 251
{
259 252
    int64_t pos = avio_tell(pb);
260
    int decoderSpecificInfoLen = track->vosLen ? descrLength(track->vosLen):0;
253
    int decoderSpecificInfoLen = track->vosLen ? 5+track->vosLen : 0;
261 254

  
262 255
    avio_wb32(pb, 0); // size
263 256
    ffio_wfourcc(pb, "esds");
264 257
    avio_wb32(pb, 0); // Version
265 258

  
266 259
    // ES descriptor
267
    putDescr(pb, 0x03, 3 + descrLength(13 + decoderSpecificInfoLen) +
268
             descrLength(1));
260
    putDescr(pb, 0x03, 3 + 5+13 + decoderSpecificInfoLen + 5+1);
269 261
    avio_wb16(pb, track->trackID);
270 262
    avio_w8(pb, 0x00); // flags (= no flags)
271 263

  

Also available in: Unified diff