Revision 1d92cc2b libavformat/avienc.c

View differences:

libavformat/avienc.c
264 264
        put_byte(pb, 0);
265 265
}
266 266

  
267
static void parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale)
267
void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale)
268 268
{
269 269
    int gcd;
270 270

  
......
384 384
        /* stream generic header */
385 385
        strh = start_tag(pb, "strh");
386 386
        switch(stream->codec_type) {
387
        case CODEC_TYPE_VIDEO:
388
            put_tag(pb, "vids");
389
            put_le32(pb, stream->codec_tag);
390
            put_le32(pb, 0); /* flags */
391
            put_le16(pb, 0); /* priority */
392
            put_le16(pb, 0); /* language */
393
            put_le32(pb, 0); /* initial frame */
394
            
395
            put_le32(pb, stream->time_base.num); /* scale */
396
            put_le32(pb, stream->time_base.den); /* rate */
397
            av_set_pts_info(s->streams[i], 64, stream->time_base.num, stream->time_base.den);
398

  
399
            put_le32(pb, 0); /* start */
400
            avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */
401
            put_le32(pb, nb_frames); /* length, XXX: fill later */
402
            put_le32(pb, 1024 * 1024); /* suggested buffer size */
403
            put_le32(pb, -1); /* quality */
404
            put_le32(pb, 0); /* sample size */
405
            put_le16(pb, 0);
406
            put_le16(pb, 0);
407
            put_le16(pb, stream->width);
408
            put_le16(pb, stream->height);
409
            break;
410
        case CODEC_TYPE_AUDIO:
411
            put_tag(pb, "auds");
412
            put_le32(pb, 1); /* tag */
413
            put_le32(pb, 0); /* flags */
414
            put_le16(pb, 0); /* priority */
415
            put_le16(pb, 0); /* language */
416
            put_le32(pb, 0); /* initial frame */
417
            parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
418
            put_le32(pb, au_scale); /* scale */
419
            put_le32(pb, au_byterate); /* rate */
420
            av_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
421
            put_le32(pb, 0); /* start */
422
            avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */
423
            put_le32(pb, 0); /* length, XXX: filled later */
424
            put_le32(pb, 12 * 1024); /* suggested buffer size */
425
            put_le32(pb, -1); /* quality */
426
            put_le32(pb, au_ssize); /* sample size */
427
            put_le32(pb, 0);
428
            put_le32(pb, 0);
429
            break;
430
        default:
431
            return -1;
387
        case CODEC_TYPE_VIDEO: put_tag(pb, "vids"); break;
388
        case CODEC_TYPE_AUDIO: put_tag(pb, "auds"); break;
389
//        case CODEC_TYPE_TEXT : put_tag(pb, "txts"); break;
390
        case CODEC_TYPE_DATA : put_tag(pb, "dats"); break;
432 391
        }
392
        if(stream->codec_type == CODEC_TYPE_VIDEO)
393
            put_le32(pb, stream->codec_tag);
394
        else
395
            put_le32(pb, 1);
396
        put_le32(pb, 0); /* flags */
397
        put_le16(pb, 0); /* priority */
398
        put_le16(pb, 0); /* language */
399
        put_le32(pb, 0); /* initial frame */
400

  
401
        ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
402

  
403
        put_le32(pb, au_scale); /* scale */
404
        put_le32(pb, au_byterate); /* rate */
405
        av_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
406

  
407
        put_le32(pb, 0); /* start */
408
        avi->frames_hdr_strm[i] = url_ftell(pb); /* remember this offset to fill later */
409
        put_le32(pb, 0); /* length, XXX: filled later */
410
        
411
        /* suggested buffer size */ //FIXME set at the end to largest chunk
412
        if(stream->codec_type == CODEC_TYPE_VIDEO)
413
            put_le32(pb, 1024 * 1024); 
414
        else if(stream->codec_type == CODEC_TYPE_AUDIO)
415
            put_le32(pb, 12 * 1024); 
416
        else
417
            put_le32(pb, 0); 
418
        put_le32(pb, -1); /* quality */
419
        put_le32(pb, au_ssize); /* sample size */
420
        put_le32(pb, 0);
421
        put_le16(pb, stream->width);
422
        put_le16(pb, stream->height);
433 423
        end_tag(pb, strh);
434 424

  
425
      if(stream->codec_type != CODEC_TYPE_DATA){
435 426
        strf = start_tag(pb, "strf");
436 427
        switch(stream->codec_type) {
437 428
        case CODEC_TYPE_VIDEO:
......
447 438
            return -1;
448 439
        }
449 440
        end_tag(pb, strf);
441
      }
450 442
	
451 443
	if (!url_is_streamed(pb)) {
452 444
	    unsigned char tag[5];
......
599 591
            if (avi->frames_hdr_strm[n] != 0) {
600 592
                stream = &s->streams[n]->codec;
601 593
                url_fseek(pb, avi->frames_hdr_strm[n], SEEK_SET);
602
                parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
594
                ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
603 595
                if (au_ssize == 0) {
604 596
                    put_le32(pb, stream->frame_number);
605 597
                    nb_frames += stream->frame_number;

Also available in: Unified diff