comparison libmpdemux/demux_viv.c @ 3502:1ff0ff94ac91

added -vivo subconfig
author alex
date Sat, 15 Dec 2001 16:44:54 +0000
parents e5aae38e6a09
children 7aed2edd99ab
comparison
equal deleted inserted replaced
3501:685b85faefc8 3502:1ff0ff94ac91
12 12
13 #include "stream.h" 13 #include "stream.h"
14 #include "demuxer.h" 14 #include "demuxer.h"
15 #include "stheader.h" 15 #include "stheader.h"
16 #include "bswap.h" 16 #include "bswap.h"
17
18 /* parameters ! */
19 char *vivo_param_acodec = NULL;
20 int vivo_param_abitrate = -1;
21 int vivo_param_samplerate = -1;
22 int vivo_param_bytesperblock = -1;
23 int vivo_param_width = -1;
24 int vivo_param_height = -1;
25 int vivo_param_vformat = -1;
17 26
18 /* VIVO audio standards from vivog723.acm: 27 /* VIVO audio standards from vivog723.acm:
19 28
20 G.723: 29 G.723:
21 FormatTag = 0x111 30 FormatTag = 0x111
31 SamplesPerSec = 16000 - 16khz 40 SamplesPerSec = 16000 - 16khz
32 AvgBytesPerSec = 2000 41 AvgBytesPerSec = 2000
33 BlockAlign (bytes per block) = 40 42 BlockAlign (bytes per block) = 40
34 BitsPerSample = 8 43 BitsPerSample = 8
35 */ 44 */
45
46 //enum { VIVO_AUDIO_G723, VIVO_AUDIO_SIREN };
36 47
37 #define VIVO_AUDIO_G723 1 48 #define VIVO_AUDIO_G723 1
38 #define VIVO_AUDIO_SIREN 2 49 #define VIVO_AUDIO_SIREN 2
39 50
40 typedef struct { 51 typedef struct {
539 550
540 { sh_video_t* sh=new_sh_video(demuxer,0); 551 { sh_video_t* sh=new_sh_video(demuxer,0);
541 552
542 /* viv1, viv2 (for better codecs.conf) */ 553 /* viv1, viv2 (for better codecs.conf) */
543 sh->format = mmioFOURCC('v', 'i', 'v', priv->version); 554 sh->format = mmioFOURCC('v', 'i', 'v', priv->version);
544 // sh->format=0x6f766976; // "vivo"
545 if(!sh->fps) 555 if(!sh->fps)
546 { 556 {
547 if (priv->fps) 557 if (priv->fps)
548 sh->fps=priv->fps; 558 sh->fps=priv->fps;
549 else 559 else
550 sh->fps=15.0f; 560 sh->fps=15.0f;
551 } 561 }
552 sh->frametime=1.0f/sh->fps; 562 sh->frametime=1.0f/sh->fps;
553 563
554 #warning "FIXME! we can't scale" 564 /* XXX: FIXME: can't scale image. */
565 /* hotfix to disable: */
555 priv->disp_width = priv->width; 566 priv->disp_width = priv->width;
556 priv->disp_height = priv->height; 567 priv->disp_height = priv->height;
568
569 if (vivo_param_width != -1)
570 priv->disp_width = priv->width = vivo_param_width;
571
572 if (vivo_param_height != -1)
573 priv->disp_height = priv->height = vivo_param_height;
574
575 if (vivo_param_vformat != -1)
576 {
577 priv->disp_width = priv->width = h263_format[vivo_param_vformat][0];
578 priv->disp_height = priv->height = h263_format[vivo_param_vformat][1];
579 }
557 580
558 if (priv->disp_width) 581 if (priv->disp_width)
559 sh->disp_w = priv->disp_width; 582 sh->disp_w = priv->disp_width;
560 else 583 else
561 sh->disp_w = width; 584 sh->disp_w = width;
578 sh->bih->biHeight = height; 601 sh->bih->biHeight = height;
579 sh->bih->biPlanes=1; 602 sh->bih->biPlanes=1;
580 sh->bih->biBitCount=24; 603 sh->bih->biBitCount=24;
581 sh->bih->biCompression=sh->format; 604 sh->bih->biCompression=sh->format;
582 sh->bih->biSizeImage=sh->bih->biWidth*sh->bih->biHeight*3; 605 sh->bih->biSizeImage=sh->bih->biWidth*sh->bih->biHeight*3;
583 demuxer->video->sh=sh; sh->ds=demuxer->video; 606
607 /* insert as stream */
608 demuxer->video->sh=sh;
609 sh->ds=demuxer->video;
584 demuxer->video->id=0; 610 demuxer->video->id=0;
585 611
612 /* disable seeking */
586 demuxer->seekable = 0; 613 demuxer->seekable = 0;
587 614
588 printf("VIVO Video stream %d size: display: %dx%d, codec: %lux%lu\n", 615 printf("VIVO Video stream %d size: display: %dx%d, codec: %lux%lu\n",
589 demuxer->video->id, sh->disp_w, sh->disp_h, sh->bih->biWidth, 616 demuxer->video->id, sh->disp_w, sh->disp_h, sh->bih->biWidth,
590 sh->bih->biHeight); 617 sh->bih->biHeight);
591 } 618 }
592 619
593 if(demuxer->audio->id>=-1){ 620 /* AUDIO init */
621 if (demuxer->audio->id >= -1){
594 if(!ds_fill_buffer(demuxer->audio)){ 622 if(!ds_fill_buffer(demuxer->audio)){
595 mp_msg(MSGT_DEMUX,MSGL_ERR,"VIVO: " MSGTR_MissingAudioStream); 623 mp_msg(MSGT_DEMUX,MSGL_ERR,"VIVO: " MSGTR_MissingAudioStream);
596 } else 624 } else
597 { sh_audio_t* sh=new_sh_audio(demuxer,1); 625 { sh_audio_t* sh=new_sh_audio(demuxer,1);
598 626
627 /* Select audio codec */
599 if (priv->audio_codec == 0) 628 if (priv->audio_codec == 0)
600 { 629 {
601 if (priv->version == '2') 630 if (priv->version == '2')
602 priv->audio_codec = VIVO_AUDIO_SIREN; 631 priv->audio_codec = VIVO_AUDIO_SIREN;
603 else 632 else
604 priv->audio_codec = VIVO_AUDIO_G723; 633 priv->audio_codec = VIVO_AUDIO_G723;
605 } 634 }
606 635 if (vivo_param_acodec != NULL)
607 // if (priv->version == '2') 636 {
608 // if (priv->audio_bytesperblock == 40) 637 if (!strcasecmp(vivo_param_acodec, "g723"))
638 priv->audio_codec = VIVO_AUDIO_G723;
639 if (!strcasecmp(vivo_param_acodec, "siren"))
640 priv->audio_codec = VIVO_AUDIO_SIREN;
641 }
642
643 sh->format = -1;
644 if (priv->audio_codec == VIVO_AUDIO_G723)
645 sh->format = 0x111;
609 if (priv->audio_codec == VIVO_AUDIO_SIREN) 646 if (priv->audio_codec == VIVO_AUDIO_SIREN)
610 sh->format=0x112; /* Vivo Siren */ 647 sh->format = 0x112;
611 else 648 if (sh->format == -1)
612 // if (priv->version == '1') 649 {
613 sh->format=0x111; /* Vivo G.723 */ 650 mp_msg(MSGT_DEMUX, MSGL_ERR, "VIVO: Not support audio codec (%d)\n",
651 priv->audio_codec);
652 goto nosound;
653 }
614 654
615 // Emulate WAVEFORMATEX struct: 655 // Emulate WAVEFORMATEX struct:
616 sh->wf=malloc(sizeof(WAVEFORMATEX)); 656 sh->wf=malloc(sizeof(WAVEFORMATEX));
617 memset(sh->wf,0,sizeof(WAVEFORMATEX)); 657 memset(sh->wf,0,sizeof(WAVEFORMATEX));
618 sh->wf->wFormatTag=sh->format; 658 sh->wf->wFormatTag=sh->format;
619 sh->wf->nChannels=1; 659 sh->wf->nChannels=1; /* 1 channels for both Siren and G.723 */
620 /* FIXME bits, samplerate, avgbytes, and blockalign */ 660
661 /* Set bits per sample */
621 if (priv->audio_codec == VIVO_AUDIO_SIREN) 662 if (priv->audio_codec == VIVO_AUDIO_SIREN)
622 // if (priv->audio_len == 40) 663 sh->wf->wBitsPerSample = 16;
623 sh->wf->wBitsPerSample=16; /* siren */
624 else 664 else
625 sh->wf->wBitsPerSample=8; 665 if (priv->audio_codec == VIVO_AUDIO_G723)
626 if (priv->audio_samplerate) 666 sh->wf->wBitsPerSample = 8;
627 sh->wf->nSamplesPerSec=priv->audio_samplerate; 667
668 /* Set sampling rate */
669 if (priv->audio_samplerate) /* got from header */
670 sh->wf->nSamplesPerSec = priv->audio_samplerate;
628 else 671 else
629 { 672 {
630 if (priv->audio_codec == VIVO_AUDIO_SIREN) 673 if (priv->audio_codec == VIVO_AUDIO_SIREN)
631 sh->wf->nSamplesPerSec=16000; 674 sh->wf->nSamplesPerSec = 16000;
632 else 675 if (priv->audio_codec == VIVO_AUDIO_G723)
633 sh->wf->nSamplesPerSec=8000; 676 sh->wf->nSamplesPerSec = 8000;
634 } 677 }
635 if (priv->audio_bitrate) 678 if (vivo_param_samplerate != -1)
636 sh->wf->nAvgBytesPerSec=priv->audio_bitrate; 679 sh->wf->nSamplesPerSec = vivo_param_samplerate;
680
681 /* Set audio bitrate */
682 if (priv->audio_bitrate) /* got from header */
683 sh->wf->nAvgBytesPerSec = priv->audio_bitrate;
637 else 684 else
638 { 685 {
639 if (priv->audio_codec == VIVO_AUDIO_SIREN) 686 if (priv->audio_codec == VIVO_AUDIO_SIREN)
640 // if (priv->version == '2')
641 sh->wf->nAvgBytesPerSec = 2000; 687 sh->wf->nAvgBytesPerSec = 2000;
642 else 688 if (priv->audio_codec == VIVO_AUDIO_G723)
643 sh->wf->nAvgBytesPerSec = 800; 689 sh->wf->nAvgBytesPerSec = 800;
644 } 690 }
645 // sh->wf->nAvgBytesPerSec=sh->wf->nChannels*sh->wf->wBitsPerSample*sh->wf->nSamplesPerSec/8; 691 if (vivo_param_abitrate != -1)
646 // sh->wf->nBlockAlign=2*sh->wf->nChannels; 692 sh->wf->nAvgBytesPerSec = vivo_param_abitrate;
693
647 if (!priv->audio_bytesperblock) 694 if (!priv->audio_bytesperblock)
648 { 695 {
649 if (priv->audio_codec == VIVO_AUDIO_SIREN) 696 if (priv->audio_codec == VIVO_AUDIO_SIREN)
650 // if (priv->version == '2') 697 sh->wf->nBlockAlign = 40;
651 sh->wf->nBlockAlign=40; /* siren */ 698 if (priv->audio_codec == VIVO_AUDIO_G723)
652 else 699 sh->wf->nBlockAlign = 24;
653 sh->wf->nBlockAlign=24;
654 } 700 }
655 else 701 else
656 sh->wf->nBlockAlign=priv->audio_bytesperblock; 702 sh->wf->nBlockAlign = priv->audio_bytesperblock;
657 demuxer->audio->sh=sh; sh->ds=demuxer->audio; 703 if (vivo_param_bytesperblock != -1)
704 sh->wf->nBlockAlign = vivo_param_bytesperblock;
705
706 sound_ok:
707 /* insert as stream */
708 demuxer->audio->sh=sh;
709 sh->ds=demuxer->audio;
658 demuxer->audio->id=1; 710 demuxer->audio->id=1;
711 nosound:
659 } 712 }
660 } 713 }
661 714
662 } 715 }
663 716