comparison libmpdemux/demux_ogg.c @ 14046:4802041ab8e3

Output more information about vids, aids, sids, alangs and slangs with -identify. Patch by kiriuja <mplayer-patches@en-directo.net>
author mosu
date Thu, 25 Nov 2004 22:24:00 +0000
parents e69a40dc1a19
children c920c525daa2
comparison
equal deleted inserted replaced
14045:7a129428a408 14046:4802041ab8e3
114 int hdr_packets; 114 int hdr_packets;
115 int vorbis; 115 int vorbis;
116 int theora; 116 int theora;
117 int flac; 117 int flac;
118 int text; 118 int text;
119 int id;
119 } ogg_stream_t; 120 } ogg_stream_t;
120 121
121 typedef struct ogg_demuxer { 122 typedef struct ogg_demuxer {
122 /// Physical stream state 123 /// Physical stream state
123 ogg_sync_state sync; 124 ogg_sync_state sync;
148 149
149 extern int index_mode; 150 extern int index_mode;
150 151
151 extern char *dvdsub_lang, *audio_lang; 152 extern char *dvdsub_lang, *audio_lang;
152 extern int dvdsub_id; 153 extern int dvdsub_id;
154 extern int demux_aid_vid_mismatch;
153 155
154 //-------- subtitle support - should be moved to decoder layer, and queue 156 //-------- subtitle support - should be moved to decoder layer, and queue
155 // - subtitles up in demuxer buffer... 157 // - subtitles up in demuxer buffer...
156 158
157 #include "../subreader.h" 159 #include "../subreader.h"
446 val = *cmt + 14; 448 val = *cmt + 14;
447 } 449 }
448 else if (!strncasecmp(*cmt, "LANGUAGE=", 9)) 450 else if (!strncasecmp(*cmt, "LANGUAGE=", 9))
449 { 451 {
450 val = *cmt + 9; 452 val = *cmt + 9;
453 if (identify)
454 {
455 if (ogg_d->subs[id].text)
456 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SID_%d_LANG=%s\n", ogg_d->subs[id].id, val);
457 else if (id != d->video->id)
458 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AID_%d_LANG=%s\n", ogg_d->subs[id].id, val);
459 }
451 // copy this language name into the array 460 // copy this language name into the array
452 index = demux_ogg_sub_reverse_id(d, id); 461 index = demux_ogg_sub_reverse_id(d, id);
453 if (index >= 0) { 462 if (index >= 0) {
454 // in case of malicious files with more than one lang per track: 463 // in case of malicious files with more than one lang per track:
455 if (ogg_d->text_langs[index]) free(ogg_d->text_langs[index]); 464 if (ogg_d->text_langs[index]) free(ogg_d->text_langs[index]);
795 804
796 // Reset our vars 805 // Reset our vars
797 sh_a = NULL; 806 sh_a = NULL;
798 sh_v = NULL; 807 sh_v = NULL;
799 808
809 demux_aid_vid_mismatch = 1; // don't identify in new_sh_* since ids don't match
810
800 // Check for Vorbis 811 // Check for Vorbis
801 if(pack.bytes >= 7 && ! strncmp(&pack.packet[1],"vorbis", 6) ) { 812 if(pack.bytes >= 7 && ! strncmp(&pack.packet[1],"vorbis", 6) ) {
802 sh_a = new_sh_audio(demuxer,ogg_d->num_sub); 813 sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
803 sh_a->format = 0xFFFE; 814 sh_a->format = 0xFFFE;
804 ogg_d->subs[ogg_d->num_sub].vorbis = 1; 815 ogg_d->subs[ogg_d->num_sub].vorbis = 1;
816 if (identify)
817 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
818 ogg_d->subs[ogg_d->num_sub].id = n_audio;
805 n_audio++; 819 n_audio++;
806 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg : stream %d is vorbis\n",ogg_d->num_sub); 820 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg : stream %d is vorbis\n",ogg_d->num_sub);
807 821
808 // check for Theora 822 // check for Theora
809 # ifdef HAVE_OGGTHEORA 823 # ifdef HAVE_OGGTHEORA
837 sh_v->bih->biPlanes = 3; 851 sh_v->bih->biPlanes = 3;
838 sh_v->bih->biSizeImage = ((sh_v->bih->biBitCount/8) * 852 sh_v->bih->biSizeImage = ((sh_v->bih->biBitCount/8) *
839 sh_v->bih->biWidth*sh_v->bih->biHeight); 853 sh_v->bih->biWidth*sh_v->bih->biHeight);
840 ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps; 854 ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps;
841 ogg_d->subs[ogg_d->num_sub].theora = 1; 855 ogg_d->subs[ogg_d->num_sub].theora = 1;
856 if (identify)
857 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", n_video);
858 ogg_d->subs[ogg_d->num_sub].id = n_video;
842 n_video++; 859 n_video++;
843 mp_msg(MSGT_DEMUX,MSGL_V, 860 mp_msg(MSGT_DEMUX,MSGL_V,
844 "Ogg : stream %d is theora v%i.%i.%i %i:%i, %.3f FPS," 861 "Ogg : stream %d is theora v%i.%i.%i %i:%i, %.3f FPS,"
845 " aspect %i:%i\n", ogg_d->num_sub, 862 " aspect %i:%i\n", ogg_d->num_sub,
846 (int)inf.version_major, 863 (int)inf.version_major,
854 # endif /* HAVE_OGGTHEORA */ 871 # endif /* HAVE_OGGTHEORA */
855 # ifdef HAVE_FLAC 872 # ifdef HAVE_FLAC
856 } else if (pack.bytes >= 4 && !strncmp (&pack.packet[0], "fLaC", 4)) { 873 } else if (pack.bytes >= 4 && !strncmp (&pack.packet[0], "fLaC", 4)) {
857 sh_a = new_sh_audio(demuxer,ogg_d->num_sub); 874 sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
858 sh_a->format = mmioFOURCC('f', 'L', 'a', 'C'); 875 sh_a->format = mmioFOURCC('f', 'L', 'a', 'C');
876 if (identify)
877 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
878 ogg_d->subs[ogg_d->num_sub].id = n_audio;
859 n_audio++; 879 n_audio++;
860 ogg_d->subs[ogg_d->num_sub].flac = 1; 880 ogg_d->subs[ogg_d->num_sub].flac = 1;
861 sh_a->wf = NULL; 881 sh_a->wf = NULL;
862 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg : stream %d is FLAC\n",ogg_d->num_sub); 882 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg : stream %d is FLAC\n",ogg_d->num_sub);
863 # endif /* HAVE_FLAC */ 883 # endif /* HAVE_FLAC */
881 if(!sh_v->bih->biBitCount) sh_v->bih->biBitCount=24; // hack, FIXME 901 if(!sh_v->bih->biBitCount) sh_v->bih->biBitCount=24; // hack, FIXME
882 sh_v->bih->biPlanes=1; 902 sh_v->bih->biPlanes=1;
883 sh_v->bih->biSizeImage=(sh_v->bih->biBitCount>>3)*sh_v->bih->biWidth*sh_v->bih->biHeight; 903 sh_v->bih->biSizeImage=(sh_v->bih->biBitCount>>3)*sh_v->bih->biWidth*sh_v->bih->biHeight;
884 904
885 ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps; 905 ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps;
906 if (identify)
907 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", n_video);
908 ogg_d->subs[ogg_d->num_sub].id = n_video;
886 n_video++; 909 n_video++;
887 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is video (old hdr)\n",ogg_d->num_sub); 910 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is video (old hdr)\n",ogg_d->num_sub);
888 if(verbose>0) print_video_header(sh_v->bih); 911 if(verbose>0) print_video_header(sh_v->bih);
889 // Old audio header 912 // Old audio header
890 } else if(get_uint32(pack.packet+96) == 0x05589F81) { 913 } else if(get_uint32(pack.packet+96) == 0x05589F81) {
902 sh_a->wf->cbSize = extra_size; 925 sh_a->wf->cbSize = extra_size;
903 if(extra_size > 0) 926 if(extra_size > 0)
904 memcpy(sh_a->wf+sizeof(WAVEFORMATEX),pack.packet+142,extra_size); 927 memcpy(sh_a->wf+sizeof(WAVEFORMATEX),pack.packet+142,extra_size);
905 928
906 ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels; 929 ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels;
930 if (identify)
931 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
932 ogg_d->subs[ogg_d->num_sub].id = n_audio;
907 n_audio++; 933 n_audio++;
908 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is audio (old hdr)\n",ogg_d->num_sub); 934 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is audio (old hdr)\n",ogg_d->num_sub);
909 if(verbose>0) print_wave_header(sh_a->wf); 935 if(verbose>0) print_wave_header(sh_a->wf);
910 } else 936 } else
911 mp_msg(MSGT_DEMUX,MSGL_WARN,"Ogg stream %d contains an old header but the header type is unknown\n",ogg_d->num_sub); 937 mp_msg(MSGT_DEMUX,MSGL_WARN,"Ogg stream %d contains an old header but the header type is unknown\n",ogg_d->num_sub);
930 if(!sh_v->bih->biBitCount) sh_v->bih->biBitCount=24; // hack, FIXME 956 if(!sh_v->bih->biBitCount) sh_v->bih->biBitCount=24; // hack, FIXME
931 sh_v->bih->biPlanes=1; 957 sh_v->bih->biPlanes=1;
932 sh_v->bih->biSizeImage=(sh_v->bih->biBitCount>>3)*sh_v->bih->biWidth*sh_v->bih->biHeight; 958 sh_v->bih->biSizeImage=(sh_v->bih->biBitCount>>3)*sh_v->bih->biWidth*sh_v->bih->biHeight;
933 959
934 ogg_d->subs[ogg_d->num_sub].samplerate= sh_v->fps; 960 ogg_d->subs[ogg_d->num_sub].samplerate= sh_v->fps;
961 if (identify)
962 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_VIDEO_ID=%d\n", n_video);
963 ogg_d->subs[ogg_d->num_sub].id = n_video;
935 n_video++; 964 n_video++;
936 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is video (new hdr)\n",ogg_d->num_sub); 965 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is video (new hdr)\n",ogg_d->num_sub);
937 if(verbose>0) print_video_header(sh_v->bih); 966 if(verbose>0) print_video_header(sh_v->bih);
938 /// New audio header 967 /// New audio header
939 } else if(strncmp(st->streamtype,"audio",5) == 0) { 968 } else if(strncmp(st->streamtype,"audio",5) == 0) {
953 sh_a->wf->cbSize = extra_size; 982 sh_a->wf->cbSize = extra_size;
954 if(extra_size) 983 if(extra_size)
955 memcpy(sh_a->wf+sizeof(WAVEFORMATEX),st+1,extra_size); 984 memcpy(sh_a->wf+sizeof(WAVEFORMATEX),st+1,extra_size);
956 985
957 ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels; 986 ogg_d->subs[ogg_d->num_sub].samplerate = sh_a->samplerate; // * sh_a->channels;
987 if (identify)
988 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
989 ogg_d->subs[ogg_d->num_sub].id = n_audio;
958 n_audio++; 990 n_audio++;
959 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is audio (new hdr)\n",ogg_d->num_sub); 991 mp_msg(MSGT_DEMUX,MSGL_V,"Ogg stream %d is audio (new hdr)\n",ogg_d->num_sub);
960 if(verbose>0) print_wave_header(sh_a->wf); 992 if(verbose>0) print_wave_header(sh_a->wf);
961 993
962 /// Check for text (subtitles) header 994 /// Check for text (subtitles) header
963 } else if (strncmp(st->streamtype, "text", 4) == 0) { 995 } else if (strncmp(st->streamtype, "text", 4) == 0) {
964 mp_msg(MSGT_DEMUX, MSGL_V, "Ogg stream %d is text\n", ogg_d->num_sub); 996 mp_msg(MSGT_DEMUX, MSGL_V, "Ogg stream %d is text\n", ogg_d->num_sub);
965 ogg_d->subs[ogg_d->num_sub].samplerate= get_uint64(&st->time_unit)/10; 997 ogg_d->subs[ogg_d->num_sub].samplerate= get_uint64(&st->time_unit)/10;
966 ogg_d->subs[ogg_d->num_sub].text = 1; 998 ogg_d->subs[ogg_d->num_sub].text = 1;
999 if (identify)
1000 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", ogg_d->n_text);
1001 ogg_d->subs[ogg_d->num_sub].id = ogg_d->n_text;
967 if (demuxer->sub->id == ogg_d->n_text) 1002 if (demuxer->sub->id == ogg_d->n_text)
968 text_id = ogg_d->num_sub; 1003 text_id = ogg_d->num_sub;
969 ogg_d->n_text++; 1004 ogg_d->n_text++;
970 ogg_d->text_ids = (int *)realloc(ogg_d->text_ids, sizeof(int) * ogg_d->n_text); 1005 ogg_d->text_ids = (int *)realloc(ogg_d->text_ids, sizeof(int) * ogg_d->n_text);
971 ogg_d->text_ids[ogg_d->n_text - 1] = ogg_d->num_sub; 1006 ogg_d->text_ids[ogg_d->n_text - 1] = ogg_d->num_sub;