71 lines
2.4 KiB
Diff
71 lines
2.4 KiB
Diff
--- libtheora-1.0beta2/examples/png2theora.c 2007-10-04 20:37:00.000000000 +0200
|
|
+++ libtheora-1.0beta2/examples/png2theora.c.new 2007-11-29 21:30:56.000000000 +0100
|
|
@@ -12,7 +12,7 @@
|
|
|
|
function: example encoder application; makes an Ogg Theora
|
|
file from a sequence of png images
|
|
- last mod: $Id: png2theora.c 13925 2007-10-03 18:51:06Z sping $
|
|
+ last mod: $Id$
|
|
based on code from Vegard Nossum
|
|
|
|
********************************************************************/
|
|
@@ -132,22 +132,24 @@
|
|
fwrite(og.header, og.header_len, 1, ogg_fp);
|
|
fwrite(og.body, og.body_len, 1, ogg_fp);
|
|
}
|
|
+ /* libogg flushes automatically after the first header */
|
|
|
|
theora_comment_init(&tc);
|
|
theora_encode_comment(&tc, &op);
|
|
ogg_stream_packetin(&ogg_os, &op);
|
|
- if(ogg_stream_pageout(&ogg_os, &og)) {
|
|
+ while(ogg_stream_pageout(&ogg_os, &og)) {
|
|
fwrite(og.header, og.header_len, 1, ogg_fp);
|
|
fwrite(og.body, og.body_len, 1, ogg_fp);
|
|
}
|
|
|
|
theora_encode_tables(&theora_td, &op);
|
|
ogg_stream_packetin(&ogg_os, &op);
|
|
- if(ogg_stream_pageout(&ogg_os, &og)) {
|
|
+ while(ogg_stream_pageout(&ogg_os, &og)) {
|
|
fwrite(og.header, og.header_len, 1, ogg_fp);
|
|
fwrite(og.body, og.body_len, 1, ogg_fp);
|
|
}
|
|
|
|
+ /* flush at the end of the headers */
|
|
if(ogg_stream_flush(&ogg_os, &og)) {
|
|
fwrite(og.header, og.header_len, 1, ogg_fp);
|
|
fwrite(og.body, og.body_len, 1, ogg_fp);
|
|
@@ -234,7 +236,7 @@
|
|
}
|
|
|
|
ogg_stream_packetin(&ogg_os, &op);
|
|
- if(ogg_stream_pageout(&ogg_os, &og)) {
|
|
+ while(ogg_stream_pageout(&ogg_os, &og)) {
|
|
fwrite(og.header, og.header_len, 1, ogg_fp);
|
|
fwrite(og.body, og.body_len, 1, ogg_fp);
|
|
}
|
|
@@ -254,7 +256,11 @@
|
|
|
|
if (theora_initialized) {
|
|
theora_encode_packetout(&theora_td, 1, &op);
|
|
- if(ogg_stream_pageout(&ogg_os, &og)) {
|
|
+ while(ogg_stream_pageout(&ogg_os, &og)) {
|
|
+ fwrite(og.header, og.header_len, 1, ogg_fp);
|
|
+ fwrite(og.body, og.body_len, 1, ogg_fp);
|
|
+ }
|
|
+ if(ogg_stream_flush(&ogg_os, &og)) {
|
|
fwrite(og.header, og.header_len, 1, ogg_fp);
|
|
fwrite(og.body, og.body_len, 1, ogg_fp);
|
|
}
|
|
@@ -369,7 +375,8 @@
|
|
png_init_io(png_ptr, fp);
|
|
png_set_sig_bytes(png_ptr, 8);
|
|
|
|
- png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_16, NULL);
|
|
+ png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_STRIP_16 |
|
|
+ PNG_TRANSFORM_STRIP_ALPHA | PNG_TRANSFORM_PACKING, NULL);
|
|
|
|
row_pointers = png_get_rows(png_ptr, info_ptr);
|
|
|