10 #define CHUNK_SIZE 4096
12 int main (int argc
, char **argv
)
14 char *fname
= "stream.ogg";
19 TarkinStream
*tarkin_stream
;
32 TarkinVideoLayerDesc
*layer
;
36 } else if (argc
!= 1) {
37 printf ("\n usage: %s <tarkin_stream>\n\n", argv
[0]);
41 if ((fd
= open (fname
, O_RDONLY
|O_BINARY
)) < 0) {
42 printf ("error opening '%s'\n", fname
);
46 tarkin_stream
= tarkin_stream_new (fd
);
48 ogg_stream_init(&os
,1);
49 tarkin_info_init(&ti
);
50 tarkin_comment_init(&tc
);
52 buffer
= ogg_sync_buffer(&oy
, CHUNK_SIZE
);
53 if((nread
= read(fd
, buffer
, CHUNK_SIZE
))>0)
54 ogg_sync_wrote(&oy
, nread
);
56 ogg_sync_wrote(&oy
,0);
58 if(ogg_sync_pageout(&oy
,&og
)){
59 ogg_stream_pagein(&os
,&og
);
60 while(ogg_stream_packetout(&os
,&op
)){
63 if(nheader
<3){ /* 3 first packets to headerin */
64 tarkin_synthesis_headerin(&ti
, &tc
, &op
);
66 tarkin_synthesis_init(tarkin_stream
, &ti
);
70 tarkin_synthesis_packetin(tarkin_stream
, &op
);
71 while(tarkin_synthesis_frameout(tarkin_stream
, &rgb
, 0, &date
)==0){
72 layer
= &tarkin_stream
->layer
->desc
;
73 snprintf(ofname
, 11, layer
->format
== TARKIN_GRAYSCALE
? "out%03d.pgm" : "out%03d.ppm", frame
);
74 printf ("write '%s' %dx%d\n", ofname
, layer
->width
, layer
->height
);
75 write_pnm (ofname
, rgb
, layer
->width
, layer
->height
);
76 tarkin_synthesis_freeframe(tarkin_stream
, rgb
);
86 tarkin_stream_destroy (tarkin_stream
);