[xiph-commits] r16341 - branches/theora-thusnelda/examples
tterribe at svn.xiph.org
tterribe at svn.xiph.org
Sun Jul 26 21:03:45 PDT 2009
Author: tterribe
Date: 2009-07-26 21:03:45 -0700 (Sun, 26 Jul 2009)
New Revision: 16341
Modified:
branches/theora-thusnelda/examples/encoder_example.c
Log:
Fix two-passes at once mode.
It worked when Monty gave it to me, but I broke it.
Modified: branches/theora-thusnelda/examples/encoder_example.c
===================================================================
--- branches/theora-thusnelda/examples/encoder_example.c 2009-07-27 03:33:27 UTC (rev 16340)
+++ branches/theora-thusnelda/examples/encoder_example.c 2009-07-27 04:03:45 UTC (rev 16341)
@@ -1090,7 +1090,7 @@
/*Ask the encoder how many bytes it would like.*/
bytes=th_encode_ctl(td,TH_ENCCTL_2PASS_IN,NULL,0);
if(bytes<0){
- fprintf(stderr,"Error submitting pass data in second pass.\n");
+ fprintf(stderr,"Error submitting pass data in second pass1.\n");
exit(1);
}
/*If it's got enough, stop.*/
@@ -1104,7 +1104,7 @@
/*And pass them off.*/
ret=th_encode_ctl(td,TH_ENCCTL_2PASS_IN,buffer,bytes);
if(ret<0){
- fprintf(stderr,"Error submitting pass data in second pass.\n");
+ fprintf(stderr,"Error submitting pass data in second pass2.\n");
exit(1);
}
/*If the encoder consumed the whole buffer, reset it.*/
@@ -1512,8 +1512,8 @@
th_info_clear(&ti);
/* setting just the granule shift only allows power-of-two keyframe
spacing. Set the actual requested spacing. */
- ret=th_encode_ctl(td,TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE,&keyframe_frequency,
- sizeof(keyframe_frequency-1));
+ ret=th_encode_ctl(td,TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE,
+ &keyframe_frequency,sizeof(keyframe_frequency-1));
if(ret<0){
fprintf(stderr,"Could not set keyframe interval to %d.\n",(int)keyframe_frequency);
}
@@ -1549,15 +1549,16 @@
/* set up two-pass if needed */
if(passno==1){
unsigned char *buffer;
- int bytes = th_encode_ctl(td, TH_ENCCTL_2PASS_OUT, &buffer, sizeof(buffer));
+ int bytes;
+ bytes=th_encode_ctl(td,TH_ENCCTL_2PASS_OUT,&buffer,sizeof(buffer));
if(bytes<0){
fprintf(stderr,"Could not set up the first pass of two-pass mode.\n");
fprintf(stderr,"Did you remember to specify an estimated bitrate?\n");
exit(1);
}
/*Perform a seek test to ensure we can overwrite this placeholder data at
- the end; this is better than letting the user sit through a whole encode
- only to find out their pass 1 file is useless at the end.*/
+ the end; this is better than letting the user sit through a whole
+ encode only to find out their pass 1 file is useless at the end.*/
if(fseek(twopass_file,0,SEEK_SET)<0){
fprintf(stderr,"Unable to seek in two-pass data file.\n");
exit(1);
@@ -1580,12 +1581,17 @@
fprintf(stderr,"Could not rewind video input file for second pass!\n");
exit(1);
}
+ if(fseek(twopass_file,0,SEEK_SET)<0){
+ fprintf(stderr,"Unable to seek in two-pass data file.\n");
+ exit(1);
+ }
frame_state=0;
frames=0;
}
}
if(passno!=1&&buf_delay>=0){
- ret=th_encode_ctl(td,TH_ENCCTL_SET_RATE_BUFFER,&buf_delay,sizeof(buf_delay));
+ ret=th_encode_ctl(td,TH_ENCCTL_SET_RATE_BUFFER,
+ &buf_delay,sizeof(buf_delay));
if(ret<0){
fprintf(stderr,"Warning: could not set desired buffer delay.\n");
}
More information about the commits
mailing list