Commit f99e292f authored by cwolf's avatar cwolf

Rollback unnecessary file name features.

svn path=/trunk/vorbis/; revision=2060
parent 2da51b6c
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: illustrate simple use of chained bitstream and vorbisfile.a function: illustrate simple use of chained bitstream and vorbisfile.a
last mod: $Id: chaining_example.c,v 1.12 2001/09/15 04:47:47 cwolf Exp $ last mod: $Id: chaining_example.c,v 1.13 2001/09/17 01:06:18 cwolf Exp $
********************************************************************/ ********************************************************************/
...@@ -23,10 +23,8 @@ ...@@ -23,10 +23,8 @@
#include <fcntl.h> #include <fcntl.h>
#endif #endif
int main(int argc, char *argv[]){ int main(){
OggVorbis_File ov; OggVorbis_File ov;
char msg[256];
FILE *fpin=NULL;
int i; int i;
#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
...@@ -36,22 +34,8 @@ int main(int argc, char *argv[]){ ...@@ -36,22 +34,8 @@ int main(int argc, char *argv[]){
_setmode( _fileno( stdout ), _O_BINARY ); _setmode( _fileno( stdout ), _O_BINARY );
#endif #endif
/* If command line args were supplied, open the named file(s)
for i/o, else maintain use of stdin/stdout.*/
if (argc == 2)
{
if ((fpin = fopen(argv[1], "rb")) == (FILE*)NULL)
{
(void)sprintf(msg, "Can't open \"%s\" for input", argv[1]);
perror(msg);
return 1;
}
}
else
fpin = stdin;
/* open the file/pipe on stdin */ /* open the file/pipe on stdin */
if(ov_open(fpin,&ov,NULL,-1)<0){ if(ov_open(stdin,&ov,NULL,-1)<0){
printf("Could not open input as an OggVorbis file.\n\n"); printf("Could not open input as an OggVorbis file.\n\n");
exit(1); exit(1);
} }
...@@ -59,33 +43,27 @@ int main(int argc, char *argv[]){ ...@@ -59,33 +43,27 @@ int main(int argc, char *argv[]){
/* print details about each logical bitstream in the input */ /* print details about each logical bitstream in the input */
if(ov_seekable(&ov)){ if(ov_seekable(&ov)){
printf("Input bitstream contained %ld logical bitstream section(s).\n", printf("Input bitstream contained %ld logical bitstream section(s).\n",
ov_streams(&ov)); ov_streams(&ov));
printf("Total bitstream playing time: %ld seconds\n\n", printf("Total bitstream playing time: %ld seconds\n\n",
(long)ov_time_total(&ov,-1)); (long)ov_time_total(&ov,-1));
}else{ }else{
printf("Standard input was not seekable.\n" printf("Standard input was not seekable.\n"
"First logical bitstream information:\n\n"); "First logical bitstream information:\n\n");
} }
for(i=0;i<ov_streams(&ov);i++){ for(i=0;i<ov_streams(&ov);i++){
vorbis_info *vi=ov_info(&ov,i); vorbis_info *vi=ov_info(&ov,i);
printf("\tlogical bitstream section %d information:\n",i+1); printf("\tlogical bitstream section %d information:\n",i+1);
printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n", printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
vi->rate,vi->channels,ov_bitrate(&ov,i)/1000, vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
ov_serialnumber(&ov,i)); ov_serialnumber(&ov,i));
printf("\t\theader length: %ld bytes\n",(long) printf("\t\theader length: %ld bytes\n",(long)
(ov.dataoffsets[i]-ov.offsets[i])); (ov.dataoffsets[i]-ov.offsets[i]));
printf("\t\tcompressed length: %ld bytes ",(long)(ov_raw_total(&ov,i))); printf("\t\tcompressed length: %ld bytes ",(long)(ov_raw_total(&ov,i)));
printf(" play time: %lds\n",(long)ov_time_total(&ov,i)); printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
} }
ov_clear(&ov); ov_clear(&ov);
if (argc == 2)
{
(void)fclose(fpin);
}
return 0; return 0;
} }
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: simple example decoder function: simple example decoder
last mod: $Id: decoder_example.c,v 1.21 2001/09/15 04:47:48 cwolf Exp $ last mod: $Id: decoder_example.c,v 1.22 2001/09/17 01:06:18 cwolf Exp $
********************************************************************/ ********************************************************************/
...@@ -53,9 +53,6 @@ int main(int argc, char **argv){ ...@@ -53,9 +53,6 @@ int main(int argc, char **argv){
char *buffer; char *buffer;
int bytes; int bytes;
FILE *fpin=NULL;
FILE *fpout=NULL;
char msg[512];
#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
/* Beware the evil ifdef. We avoid these where we can, but this one we /* Beware the evil ifdef. We avoid these where we can, but this one we
...@@ -70,29 +67,6 @@ int main(int argc, char **argv){ ...@@ -70,29 +67,6 @@ int main(int argc, char **argv){
/* this also lets the user set stdin and stdout */ /* this also lets the user set stdin and stdout */
#endif #endif
/* If command line args were supplied, open the named file(s)
for i/o, else maintain use of stdin/stdout.*/
if (argc == 3)
{
if ((fpin = fopen(argv[1], "rb")) == (FILE*)NULL)
{
(void)sprintf(msg, "Can't open %s for reading.", argv[1]);
perror(msg);
return 1;
}
if ((fpout = fopen(argv[2], "wb")) == (FILE*)NULL)
{
(void)sprintf(msg, "Can't open %s for writing.", argv[2]);
perror(msg);
return 1;
}
}
else
{
fpin = stdin;
fpout = stdout;
}
/********** Decode setup ************/ /********** Decode setup ************/
ogg_sync_init(&oy); /* Now we can read pages */ ogg_sync_init(&oy); /* Now we can read pages */
...@@ -108,7 +82,7 @@ int main(int argc, char **argv){ ...@@ -108,7 +82,7 @@ int main(int argc, char **argv){
/* submit a 4k block to libvorbis' Ogg layer */ /* submit a 4k block to libvorbis' Ogg layer */
buffer=ogg_sync_buffer(&oy,4096); buffer=ogg_sync_buffer(&oy,4096);
bytes=fread(buffer,1,4096,fpin); bytes=fread(buffer,1,4096,stdin);
ogg_sync_wrote(&oy,bytes); ogg_sync_wrote(&oy,bytes);
/* Get the first page. */ /* Get the first page. */
...@@ -191,7 +165,7 @@ int main(int argc, char **argv){ ...@@ -191,7 +165,7 @@ int main(int argc, char **argv){
} }
/* no harm in not checking before adding more */ /* no harm in not checking before adding more */
buffer=ogg_sync_buffer(&oy,4096); buffer=ogg_sync_buffer(&oy,4096);
bytes=fread(buffer,1,4096,fpin); bytes=fread(buffer,1,4096,stdin);
if(bytes==0 && i<2){ if(bytes==0 && i<2){
fprintf(stderr,"End of file before finding all Vorbis headers!\n"); fprintf(stderr,"End of file before finding all Vorbis headers!\n");
exit(1); exit(1);
...@@ -287,7 +261,7 @@ int main(int argc, char **argv){ ...@@ -287,7 +261,7 @@ int main(int argc, char **argv){
fprintf(stderr,"Clipping in frame %ld\n",(long)(vd.sequence)); fprintf(stderr,"Clipping in frame %ld\n",(long)(vd.sequence));
fwrite(convbuffer,2*vi.channels,bout,fpout); fwrite(convbuffer,2*vi.channels,bout,stdout);
vorbis_synthesis_read(&vd,bout); /* tell libvorbis how vorbis_synthesis_read(&vd,bout); /* tell libvorbis how
many samples we many samples we
...@@ -300,7 +274,7 @@ int main(int argc, char **argv){ ...@@ -300,7 +274,7 @@ int main(int argc, char **argv){
} }
if(!eos){ if(!eos){
buffer=ogg_sync_buffer(&oy,4096); buffer=ogg_sync_buffer(&oy,4096);
bytes=fread(buffer,1,4096,fpin); bytes=fread(buffer,1,4096,stdin);
ogg_sync_wrote(&oy,bytes); ogg_sync_wrote(&oy,bytes);
if(bytes==0)eos=1; if(bytes==0)eos=1;
} }
...@@ -326,4 +300,3 @@ int main(int argc, char **argv){ ...@@ -326,4 +300,3 @@ int main(int argc, char **argv){
fprintf(stderr,"Done.\n"); fprintf(stderr,"Done.\n");
return(0); return(0);
} }
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: simple example encoder function: simple example encoder
last mod: $Id: encoder_example.c,v 1.24 2001/09/15 04:47:48 cwolf Exp $ last mod: $Id: encoder_example.c,v 1.25 2001/09/17 01:06:18 cwolf Exp $
********************************************************************/ ********************************************************************/
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include <string.h>
#include <vorbis/vorbisenc.h> #include <vorbis/vorbisenc.h>
#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ #ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
...@@ -39,7 +38,7 @@ ...@@ -39,7 +38,7 @@
#define READ 1024 #define READ 1024
signed char readbuffer[READ*4+44]; /* out of the data segment, not the stack */ signed char readbuffer[READ*4+44]; /* out of the data segment, not the stack */
int main(int argc, char *argv[]){ int main(){
ogg_stream_state os; /* take physical pages, weld into a logical ogg_stream_state os; /* take physical pages, weld into a logical
stream of packets */ stream of packets */
ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */ ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
...@@ -53,18 +52,19 @@ int main(int argc, char *argv[]){ ...@@ -53,18 +52,19 @@ int main(int argc, char *argv[]){
vorbis_block vb; /* local working space for packet->PCM decode */ vorbis_block vb; /* local working space for packet->PCM decode */
int eos=0; int eos=0;
FILE *fpin=NULL;
FILE *fpout=NULL;
char msg[512];
int i, founddata; int i, founddata;
#if defined(macintosh) && defined(__MWERKS__) #if defined(macintosh) && defined(__MWERKS__)
int ac = 0; int argc = 0;
char **av = NULL; char **argv = NULL;
ac = ccommand(&av); /* get a "command line" from the Mac user */ argc = ccommand(&argv); /* get a "command line" from the Mac user */
/* this also lets the user set stdin and stdout */ /* this also lets the user set stdin and stdout */
#endif #endif
/* we cheat on the WAV header; we just bypass 44 bytes and never
verify that it matches 16bit/stereo/44.1kHz. This is just an
example, after all. */
#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
/* Beware the evil ifdef. We avoid these where we can, but this one we /* Beware the evil ifdef. We avoid these where we can, but this one we
cannot. Don't add any more, you'll probably go to hell if you do. */ cannot. Don't add any more, you'll probably go to hell if you do. */
...@@ -72,30 +72,6 @@ int main(int argc, char *argv[]){ ...@@ -72,30 +72,6 @@ int main(int argc, char *argv[]){
_setmode( _fileno( stdout ), _O_BINARY ); _setmode( _fileno( stdout ), _O_BINARY );
#endif #endif
/* If command line args were supplied, open the named file(s)
for i/o, else maintain use of stdin/stdout.*/
if (argc == 3)
{
if ((fpin = fopen(argv[1], "rb")) == (FILE*)NULL)
{
(void)sprintf(msg, "Can't open %s for reading.", argv[1]);
perror(msg);
return 1;
}
if ((fpout = fopen(argv[2], "wb")) == (FILE*)NULL)
{
(void)sprintf(msg, "Can't open %s for writing.", argv[2]);
perror(msg);
return 1;
}
}
else
{
fpin = stdin;
fpout = stdout;
}
/* we cheat on the WAV header; we just bypass the header and never /* we cheat on the WAV header; we just bypass the header and never
verify that it matches 16bit/stereo/44.1kHz. This is just an verify that it matches 16bit/stereo/44.1kHz. This is just an
example, after all. */ example, after all. */
...@@ -170,15 +146,15 @@ int main(int argc, char *argv[]){ ...@@ -170,15 +146,15 @@ int main(int argc, char *argv[]){
while(!eos){ while(!eos){
int result=ogg_stream_flush(&os,&og); int result=ogg_stream_flush(&os,&og);
if(result==0)break; if(result==0)break;
fwrite(og.header,1,og.header_len,fpout); fwrite(og.header,1,og.header_len,stdout);
fwrite(og.body,1,og.body_len,fpout); fwrite(og.body,1,og.body_len,stdout);
} }
} }
while(!eos){ while(!eos){
long i; long i;
long bytes=fread(readbuffer,1,READ*4,fpin); /* stereo hardwired here */ long bytes=fread(readbuffer,1,READ*4,stdin); /* stereo hardwired here */
if(bytes==0){ if(bytes==0){
/* end of file. this can be done implicitly in the mainline, /* end of file. this can be done implicitly in the mainline,
...@@ -220,8 +196,8 @@ int main(int argc, char *argv[]){ ...@@ -220,8 +196,8 @@ int main(int argc, char *argv[]){
while(!eos){ while(!eos){
int result=ogg_stream_pageout(&os,&og); int result=ogg_stream_pageout(&os,&og);
if(result==0)break; if(result==0)break;
fwrite(og.header,1,og.header_len,fpout); fwrite(og.header,1,og.header_len,stdout);
fwrite(og.body,1,og.body_len,fpout); fwrite(og.body,1,og.body_len,stdout);
/* this could be set above, but for illustrative purposes, I do /* this could be set above, but for illustrative purposes, I do
it here (to show that vorbis does know where the stream ends) */ it here (to show that vorbis does know where the stream ends) */
...@@ -246,4 +222,3 @@ int main(int argc, char *argv[]){ ...@@ -246,4 +222,3 @@ int main(int argc, char *argv[]){
fprintf(stderr,"Done.\n"); fprintf(stderr,"Done.\n");
return(0); return(0);
} }
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: illustrate seeking, and test it too function: illustrate seeking, and test it too
last mod: $Id: seeking_example.c,v 1.9 2001/09/15 04:47:48 cwolf Exp $ last mod: $Id: seeking_example.c,v 1.10 2001/09/17 01:06:18 cwolf Exp $
********************************************************************/ ********************************************************************/
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <stdio.h> #include <stdio.h>
#include "vorbis/codec.h" #include "vorbis/codec.h"
#include "vorbis/vorbisfile.h" #include "vorbis/vorbisfile.h"
//#include "../lib/misc.h"
#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ #ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
# include <io.h> # include <io.h>
...@@ -66,30 +65,15 @@ int main(int argc, char *argv[]){ ...@@ -66,30 +65,15 @@ int main(int argc, char *argv[]){
ogg_int64_t pcmlength; ogg_int64_t pcmlength;
char *bigassbuffer; char *bigassbuffer;
int dummy; int dummy;
char msg[256];
FILE *fpin=NULL;
#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
_setmode( _fileno( stdin ), _O_BINARY ); _setmode( _fileno( stdin ), _O_BINARY );
_setmode( _fileno( stdout ), _O_BINARY ); _setmode( _fileno( stdout ), _O_BINARY );
#endif #endif
/* If command line args were supplied, open the named file(s)
for i/o, else maintain use of stdin/stdout.*/
if (argc == 2)
{
if ((fpin = fopen(argv[1], "rb")) == (FILE*)NULL)
{
(void)sprintf(msg, "Can't open \"%s\" for input", argv[1]);
perror(msg);
return 1;
}
}
else
fpin = stdin;
/* open the file/pipe on stdin */ /* open the file/pipe on stdin */
if(ov_open(fpin,&ov,NULL,-1)<0){ if(ov_open(stdin,&ov,NULL,-1)<0){
printf("Could not open input as an OggVorbis file.\n\n"); printf("Could not open input as an OggVorbis file.\n\n");
exit(1); exit(1);
} }
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
******************************************************************** ********************************************************************
function: simple example decoder using vorbisfile function: simple example decoder using vorbisfile
last mod: $Id: vorbisfile_example.c,v 1.6 2001/09/15 04:47:48 cwolf Exp $ last mod: $Id: vorbisfile_example.c,v 1.7 2001/09/17 01:06:18 cwolf Exp $
********************************************************************/ ********************************************************************/
...@@ -36,9 +36,6 @@ int main(int argc, char **argv){ ...@@ -36,9 +36,6 @@ int main(int argc, char **argv){
OggVorbis_File vf; OggVorbis_File vf;
int eof=0; int eof=0;
int current_section; int current_section;
FILE *fpin=NULL;
FILE *fpout=NULL;
char msg[512];
#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */ #ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
/* Beware the evil ifdef. We avoid these where we can, but this one we /* Beware the evil ifdef. We avoid these where we can, but this one we
...@@ -47,29 +44,7 @@ int main(int argc, char **argv){ ...@@ -47,29 +44,7 @@ int main(int argc, char **argv){
_setmode( _fileno( stdout ), _O_BINARY ); _setmode( _fileno( stdout ), _O_BINARY );
#endif #endif
if (argc == 3) if(ov_open(stdin, &vf, NULL, 0) < 0) {
{
if ((fpin = fopen(argv[1], "rb")) == (FILE*)NULL)
{
(void)sprintf(msg, "Can't open %s for reading.", argv[1]);
perror(msg);
return 1;
}
if ((fpout = fopen(argv[2], "wb")) == (FILE*)NULL)
{
(void)sprintf(msg, "Can't open %s for writing.", argv[2]);
perror(msg);
return 1;
}
}
else
{
fpin = stdin;
fpout = stdout;
}
if(ov_open(fpin, &vf, NULL, 0) < 0) {
fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
exit(1); exit(1);
} }
...@@ -100,7 +75,7 @@ int main(int argc, char **argv){ ...@@ -100,7 +75,7 @@ int main(int argc, char **argv){
} else { } else {
/* we don't bother dealing with sample rate changes, etc, but /* we don't bother dealing with sample rate changes, etc, but
you'll have to*/ you'll have to*/
fwrite(pcmout,1,ret,fpout); fwrite(pcmout,1,ret,stdout);
} }
} }
...@@ -110,4 +85,3 @@ int main(int argc, char **argv){ ...@@ -110,4 +85,3 @@ int main(int argc, char **argv){
fprintf(stderr,"Done.\n"); fprintf(stderr,"Done.\n");
return(0); return(0);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment