X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fencoder_example.c;h=38070a9d47fe23d607a8e2fceda173f2ca598886;hb=8b8e92ebb388a84c70e21d1e548fb068dcfefbf4;hp=530e27f2301665adf1aacdc56f06750029c42d59;hpb=5ccc61230de45f33b8d976c97fad2c09a2d6b1e7;p=platform%2Fupstream%2Flibvorbis.git diff --git a/examples/encoder_example.c b/examples/encoder_example.c index 530e27f..38070a9 100644 --- a/examples/encoder_example.c +++ b/examples/encoder_example.c @@ -12,7 +12,7 @@ ******************************************************************** function: simple example encoder - last mod: $Id: encoder_example.c,v 1.6 2000/01/28 15:25:07 xiphmont Exp $ + last mod: $Id: encoder_example.c,v 1.9 2000/08/14 22:33:50 xiphmont Exp $ ********************************************************************/ @@ -27,6 +27,15 @@ #include #include "vorbis/modes.h" +#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ +#include +#include +#endif + +#if defined(macintosh) && defined(__MWERKS__) +#include /* CodeWarrior's Mac "command-line" support */ +#endif + #define READ 1024 signed char readbuffer[READ*4+44]; /* out of the data segment, not the stack */ @@ -45,10 +54,25 @@ int main(){ int eos=0; +#if defined(macintosh) && defined(__MWERKS__) + int argc = 0; + char **argv = NULL; + argc = ccommand(&argv); /* get a "command line" from the Mac user */ + /* this also lets the user set stdin and stdout */ +#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. */ + /* 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. */ + _setmode( _fileno( stdin ), _O_BINARY ); + _setmode( _fileno( stdout ), _O_BINARY ); +#endif + + fread(readbuffer,1,44,stdin); /********** Encode setup ************/ @@ -68,8 +92,8 @@ int main(){ /* set up our packet->stream encoder */ /* pick a random serial number; that way we can more likely build chained streams just by concatenation */ - srandom(time(NULL)); - ogg_stream_init(&os,random()); + srand(time(NULL)); + ogg_stream_init(&os,rand()); /* Vorbis streams begin with three headers; the initial header (with most of the codec setup parameters) which is mandated by the Ogg @@ -128,7 +152,7 @@ int main(){ /* analysis */ vorbis_analysis(&vb,&op); - + /* weld the packet into the bitstream */ ogg_stream_packetin(&os,&op);