Revision 01f4895c libavformat/dv.c

View differences:

libavformat/dv.c
560 560
	   if (!c->ast[i])
561 561
	       break;
562 562
	   av_set_pts_info(c->ast[i], 64, 1, 30000);
563
	   c->ast[i]->codec.codec_type = CODEC_TYPE_AUDIO;
564
	   c->ast[i]->codec.codec_id = CODEC_ID_PCM_S16LE;
563
	   c->ast[i]->codec->codec_type = CODEC_TYPE_AUDIO;
564
	   c->ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE;
565 565

  
566 566
           av_init_packet(&c->audio_pkt[i]);
567 567
           c->audio_pkt[i].size     = 0;
......
569 569
           c->audio_pkt[i].stream_index = c->ast[i]->index;
570 570
           c->audio_pkt[i].flags |= PKT_FLAG_KEY;
571 571
       }
572
       c->ast[i]->codec.sample_rate = dv_audio_frequency[freq];
573
       c->ast[i]->codec.channels = 2;
574
       c->ast[i]->codec.bit_rate = 2 * dv_audio_frequency[freq] * 16;
572
       c->ast[i]->codec->sample_rate = dv_audio_frequency[freq];
573
       c->ast[i]->codec->channels = 2;
574
       c->ast[i]->codec->bit_rate = 2 * dv_audio_frequency[freq] * 16;
575 575
       c->ast[i]->start_time = 0;
576 576
    }
577 577
    c->ach = i;
......
589 589
    
590 590
    sys = dv_frame_profile(frame);
591 591
    if (sys) {
592
        avctx = &c->vst->codec;
592
        avctx = c->vst->codec;
593 593
	
594 594
        av_set_pts_info(c->vst, 64, sys->frame_rate_base, sys->frame_rate);
595 595
        avctx->time_base= (AVRational){sys->frame_rate_base, sys->frame_rate};
......
628 628
	c->has_video = 0;
629 629
    }
630 630
    
631
    if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
631
    if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
632 632
        /* FIXME: we have to have more sensible approach than this one */
633 633
	if (c->has_video)
634
	    av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
634
	    av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
635 635
	    
636 636
        dv_inject_video(c, data, *frame);
637 637
	c->has_video = 1;
......
642 642
    
643 643
    reqasize = 4 * dv_audio_frame_size(c->sys, c->frames);
644 644
    fsize = fifo_size(&c->audio_data, c->audio_data.rptr);
645
    if (st->codec.codec_type == CODEC_TYPE_AUDIO || (c->has_video && fsize >= reqasize)) { 
645
    if (st->codec->codec_type == CODEC_TYPE_AUDIO || (c->has_video && fsize >= reqasize)) { 
646 646
	if (fsize + data_size >= reqasize && !c->has_audio) {
647 647
            if (fsize >= reqasize) {
648 648
	        fifo_read(&c->audio_data, &pcm[0], reqasize, &c->audio_data.rptr);
......
658 658
    
659 659
        /* FIXME: we have to have more sensible approach than this one */
660 660
        if (fifo_size(&c->audio_data, c->audio_data.rptr) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
661
	    av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
661
	    av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
662 662
	fifo_write(&c->audio_data, (uint8_t *)data, data_size, &c->audio_data.wptr);
663 663
    }
664 664

  
......
682 682

  
683 683
    /* We have to sort out where audio and where video stream is */
684 684
    for (i=0; i<s->nb_streams; i++) {
685
         switch (s->streams[i]->codec.codec_type) {
685
         switch (s->streams[i]->codec->codec_type) {
686 686
	 case CODEC_TYPE_VIDEO:
687 687
	       vst = s->streams[i];
688 688
	       break;
......
695 695
    }
696 696
    
697 697
    /* Some checks -- DV format is very picky about its incoming streams */
698
    if (!vst || vst->codec.codec_id != CODEC_ID_DVVIDEO)
698
    if (!vst || vst->codec->codec_id != CODEC_ID_DVVIDEO)
699 699
        goto bail_out;
700
    if (ast  && (ast->codec.codec_id != CODEC_ID_PCM_S16LE ||
701
	         ast->codec.sample_rate != 48000 ||
702
	         ast->codec.channels != 2))
700
    if (ast  && (ast->codec->codec_id != CODEC_ID_PCM_S16LE ||
701
	         ast->codec->sample_rate != 48000 ||
702
	         ast->codec->channels != 2))
703 703
	goto bail_out;
704
    c->sys = dv_codec_profile(&vst->codec);
704
    c->sys = dv_codec_profile(vst->codec);
705 705
    if (!c->sys)
706 706
	goto bail_out;
707 707
    
......
711 711
    c->has_video = 0;
712 712
    c->start_time = (time_t)s->timestamp;
713 713
    c->aspect = 0; /* 4:3 is the default */
714
    if ((int)(av_q2d(vst->codec.sample_aspect_ratio) * vst->codec.width / vst->codec.height * 10) == 17) /* 16:9 */ 
714
    if ((int)(av_q2d(vst->codec->sample_aspect_ratio) * vst->codec->width / vst->codec->height * 10) == 17) /* 16:9 */ 
715 715
        c->aspect = 0x07;
716 716

  
717 717
    if (ast && fifo_init(&c->audio_data, 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0)
......
751 751
    c->frames = 0;
752 752
    c->abytes = 0;
753 753

  
754
    c->vst->codec.codec_type = CODEC_TYPE_VIDEO;
755
    c->vst->codec.codec_id = CODEC_ID_DVVIDEO;
756
    c->vst->codec.bit_rate = 25000000;
754
    c->vst->codec->codec_type = CODEC_TYPE_VIDEO;
755
    c->vst->codec->codec_id = CODEC_ID_DVVIDEO;
756
    c->vst->codec->bit_rate = 25000000;
757 757
    c->vst->start_time = 0;
758 758
    
759 759
    return c;
......
790 790
    size = dv_extract_audio_info(c, buf);
791 791
    for (i=0; i<c->ach; i++) {
792 792
       c->audio_pkt[i].size = size;
793
       c->audio_pkt[i].pts  = c->abytes * 30000*8 / c->ast[i]->codec.bit_rate;
793
       c->audio_pkt[i].pts  = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
794 794
    }
795 795
    dv_extract_audio(buf, c->audio_buf[0], c->audio_buf[1]);
796 796
    c->abytes += size;
......
813 813
                              int64_t timestamp, int flags)
814 814
{
815 815
    // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
816
    const DVprofile* sys = dv_codec_profile(&c->vst->codec);
816
    const DVprofile* sys = dv_codec_profile(c->vst->codec);
817 817
    int64_t offset;
818 818
    int64_t size = url_fsize(&s->pb);
819 819
    int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size;
......
886 886
    RawDVContext *r = s->priv_data;
887 887
    DVDemuxContext *c = r->dv_demux;
888 888
    int64_t offset= dv_frame_offset(s, c, timestamp, flags);
889
    const DVprofile* sys = dv_codec_profile(&c->vst->codec);
889
    const DVprofile* sys = dv_codec_profile(c->vst->codec);
890 890

  
891 891
    c->frames= offset / sys->frame_size;
892 892
    if (c->ach)
893 893
        c->abytes= av_rescale(c->frames,
894
                          c->ast[0]->codec.bit_rate * (int64_t)sys->frame_rate_base,
894
                          c->ast[0]->codec->bit_rate * (int64_t)sys->frame_rate_base,
895 895
                          8*sys->frame_rate);
896 896
			  
897 897
    dv_flush_audio_packets(c);

Also available in: Unified diff