Revision 0809b51e libavformat/nutenc.c

View differences:

libavformat/nutenc.c
281 281
    }
282 282
}
283 283

  
284
static int write_streamheader(NUTContext *nut, ByteIOContext *bc, AVCodecContext *codec, int i){
285
    put_v(bc, i);
286
    switch(codec->codec_type){
287
    case CODEC_TYPE_VIDEO: put_v(bc, 0); break;
288
    case CODEC_TYPE_AUDIO: put_v(bc, 1); break;
289
//    case CODEC_TYPE_TEXT : put_v(bc, 2); break;
290
    default              : put_v(bc, 3); break;
291
    }
292
    put_v(bc, 4);
293
    if (codec->codec_tag){
294
        put_le32(bc, codec->codec_tag);
295
    }else
296
        return -1;
297

  
298
    put_v(bc, (nut->stream[i].time_base - nut->time_base)/sizeof(AVRational));
299
    put_v(bc, nut->stream[i].msb_pts_shift);
300
    put_v(bc, nut->stream[i].max_pts_distance);
301
    put_v(bc, codec->has_b_frames);
302
    put_byte(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
303

  
304
    put_v(bc, codec->extradata_size);
305
    put_buffer(bc, codec->extradata, codec->extradata_size);
306

  
307
    switch(codec->codec_type){
308
    case CODEC_TYPE_AUDIO:
309
        put_v(bc, codec->sample_rate);
310
        put_v(bc, 1);
311
        put_v(bc, codec->channels);
312
        break;
313
    case CODEC_TYPE_VIDEO:
314
        put_v(bc, codec->width);
315
        put_v(bc, codec->height);
316
        put_v(bc, codec->sample_aspect_ratio.num);
317
        put_v(bc, codec->sample_aspect_ratio.den);
318
        put_v(bc, 0); /* csp type -- unknown */
319
        break;
320
    default:
321
        break;
322
    }
323
    return 0;
324
}
325

  
284 326
static int write_header(AVFormatContext *s){
285 327
    NUTContext *nut = s->priv_data;
286 328
    ByteIOContext *bc = &s->pb;
......
334 376

  
335 377
        put_be64(bc, STREAM_STARTCODE);
336 378
        put_packetheader(nut, bc, 120/*FIXME check*/ + codec->extradata_size, 1);
337
        put_v(bc, i);
338
        switch(codec->codec_type){
339
        case CODEC_TYPE_VIDEO: put_v(bc, 0); break;
340
        case CODEC_TYPE_AUDIO: put_v(bc, 1); break;
341
//        case CODEC_TYPE_TEXT : put_v(bc, 2); break;
342
        default              : put_v(bc, 3); break;
343
        }
344
        put_v(bc, 4);
345
        if (codec->codec_tag){
346
            put_le32(bc, codec->codec_tag);
347
        }else
348
            return -1;
349

  
350
        put_v(bc, (nut->stream[i].time_base - nut->time_base)/sizeof(AVRational));
351
        put_v(bc, nut->stream[i].msb_pts_shift);
352
        put_v(bc, nut->stream[i].max_pts_distance);
353
        put_v(bc, codec->has_b_frames);
354
        put_byte(bc, 0); /* flags: 0x1 - fixed_fps, 0x2 - index_present */
355

  
356
        put_v(bc, codec->extradata_size);
357
        put_buffer(bc, codec->extradata, codec->extradata_size);
358

  
359
        switch(codec->codec_type){
360
        case CODEC_TYPE_AUDIO:
361
            put_v(bc, codec->sample_rate);
362
            put_v(bc, 1);
363
            put_v(bc, codec->channels);
364
            break;
365
        case CODEC_TYPE_VIDEO:
366
            put_v(bc, codec->width);
367
            put_v(bc, codec->height);
368
            put_v(bc, codec->sample_aspect_ratio.num);
369
            put_v(bc, codec->sample_aspect_ratio.den);
370
            put_v(bc, 0); /* csp type -- unknown */
371
            break;
372
        default:
373
            break;
374
        }
379
        write_streamheader(nut, bc, codec, i);
375 380
        update_packetheader(nut, bc, 0, 1);
376 381
    }
377 382

  

Also available in: Unified diff