[xiph-commits] r14403 - trunk/ffmpeg2theora
j at svn.xiph.org
j at svn.xiph.org
Wed Jan 16 01:11:49 PST 2008
Author: j
Date: 2008-01-16 01:11:48 -0800 (Wed, 16 Jan 2008)
New Revision: 14403
Modified:
trunk/ffmpeg2theora/ffmpeg2theora.c
trunk/ffmpeg2theora/theorautils.c
trunk/ffmpeg2theora/theorautils.h
Log:
cleanup whitespace
Modified: trunk/ffmpeg2theora/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.c 2008-01-15 12:18:53 UTC (rev 14402)
+++ trunk/ffmpeg2theora/ffmpeg2theora.c 2008-01-16 09:11:48 UTC (rev 14403)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
+ *
*/
#include <stdio.h>
@@ -73,7 +73,7 @@
V2V_PRESET_PREVIEW,
V2V_PRESET_VIDEOBIN
} F2T_PRESETS;
-
+
#define PAL_HALF_WIDTH 384
#define PAL_HALF_HEIGHT 288
#define NTSC_HALF_WIDTH 320
@@ -91,7 +91,7 @@
AVFormatContext *context;
int video_index;
int audio_index;
-
+
int deinterlace;
int vhook;
int audiostream;
@@ -121,13 +121,13 @@
double force_input_fps;
int sync;
-
+
/* cropping */
int frame_topBand;
int frame_bottomBand;
int frame_leftBand;
int frame_rightBand;
-
+
int frame_width;
int frame_height;
int frame_x_offset;
@@ -135,7 +135,7 @@
/* In seconds */
int start_time;
- int end_time;
+ int end_time;
AVRational framerate_new;
@@ -178,7 +178,7 @@
if (v < 0.0) v = 0.0;
v = pow(v, g) * 255.0; // mplayer's vf_eq2.c multiplies with 256 here, strange...
- if (v >= 255)
+ if (v >= 255)
lut[i] = 255;
else
lut[i] = (unsigned char)(v+0.5);
@@ -201,7 +201,7 @@
v = 127.0 + (s * ((double)i - 127.0));
if (v < 0.0) v = 0.0;
- if (v >= 255.0)
+ if (v >= 255.0)
lut[i] = 255;
else
lut[i] = (unsigned char)(v+0.5);
@@ -232,7 +232,7 @@
/**
- * Allocate and initialise an AVFrame.
+ * Allocate and initialise an AVFrame.
*/
AVFrame *frame_alloc (int pix_fmt, int width, int height) {
AVFrame *picture;
@@ -272,7 +272,7 @@
this->audio_quality = 1.00;// audio quality 1
this->audio_bitrate=0;
this->audiostream = -1;
-
+
// video
this->picture_width=0; // set to 0 to not resize the output
this->picture_height=0; // set to 0 to not resize the output
@@ -285,7 +285,7 @@
this->aspect_numerator=0;
this->aspect_denominator=0;
this->frame_aspect=0;
- this->deinterlace=0; // auto by default, if input is flaged as interlaced it will deinterlace.
+ this->deinterlace=0; // auto by default, if input is flaged as interlaced it will deinterlace.
this->vhook=0;
this->framerate_new.num = -1;
this->framerate_new.den = 1;
@@ -294,7 +294,7 @@
this->frame_bottomBand=0;
this->frame_leftBand=0;
this->frame_rightBand=0;
-
+
this->pix_fmt = PIX_FMT_YUV420P;
}
return this;
@@ -312,7 +312,7 @@
pp_context_t *ppContext = NULL;
float frame_aspect;
double fps = 0.0;
-
+
if(this->audiostream >= 0 && this->context->nb_streams > this->audiostream) {
AVCodecContext *enc = this->context->streams[this->audiostream]->codec;
if (enc->codec_type == CODEC_TYPE_AUDIO) {
@@ -323,7 +323,7 @@
fprintf(stderr," The selected stream is not audio, falling back to automatic selection\n");
}
}
-
+
for (i = 0; i < this->context->nb_streams; i++){
AVCodecContext *enc = this->context->streams[i]->codec;
switch (enc->codec_type){
@@ -381,7 +381,7 @@
int width=venc->width-this->frame_leftBand-this->frame_rightBand;
int height=venc->height-this->frame_topBand-this->frame_bottomBand;
if(venc->sample_aspect_ratio.den!=0 && venc->sample_aspect_ratio.num!=0) {
- height=((float)venc->sample_aspect_ratio.den/venc->sample_aspect_ratio.num) * height;
+ height=((float)venc->sample_aspect_ratio.den/venc->sample_aspect_ratio.num) * height;
}
if( ((float)width /height) <= 1.5) {
if(width > 448) {
@@ -405,14 +405,14 @@
this->picture_height=height;
}
}
-
+
}
- if(this->picture_height==0 &&
+ if(this->picture_height==0 &&
(this->frame_leftBand || this->frame_rightBand || this->frame_topBand || this->frame_bottomBand) ){
this->picture_height=venc->height-
this->frame_topBand-this->frame_bottomBand;
}
- if(this->picture_width==0 &&
+ if(this->picture_width==0 &&
(this->frame_leftBand || this->frame_rightBand || this->frame_topBand || this->frame_bottomBand) ){
this->picture_width=venc->width-
this->frame_leftBand-this->frame_rightBand;
@@ -469,7 +469,7 @@
fprintf(stderr," Postprocessing: %s\n", this->pp_mode);
}
- if(!this->picture_width)
+ if(!this->picture_width)
this->picture_width = venc->width;
if(!this->picture_height)
this->picture_height = venc->height;
@@ -481,16 +481,16 @@
this->frame_x_offset = 0;
this->frame_y_offset = 0;
-
- if(this->frame_width > 0 || this->frame_height > 0){
+
+ if(this->frame_width > 0 || this->frame_height > 0){
this->sws_colorspace_ctx = sws_getContext(
venc->width, venc->height, venc->pix_fmt,
venc->width, venc->height, this->pix_fmt,
sws_flags, NULL, NULL, NULL
);
this->sws_scale_ctx = sws_getContext(
- venc->width - (this->frame_leftBand + this->frame_rightBand),
- venc->height - (this->frame_topBand + this->frame_bottomBand),
+ venc->width - (this->frame_leftBand + this->frame_rightBand),
+ venc->height - (this->frame_topBand + this->frame_bottomBand),
this->pix_fmt,
this->frame_width, this->frame_height, this->pix_fmt,
sws_flags, NULL, NULL, NULL
@@ -502,17 +502,17 @@
venc->width-this->frame_leftBand-this->frame_rightBand,
venc->height-this->frame_topBand-this->frame_bottomBand);
}
- if(this->picture_width != (venc->width-this->frame_leftBand - this->frame_rightBand)
+ if(this->picture_width != (venc->width-this->frame_leftBand - this->frame_rightBand)
|| this->picture_height != (venc->height-this->frame_topBand-this->frame_bottomBand))
fprintf(stderr," => %dx%d",this->picture_width, this->picture_height);
fprintf(stderr,"\n");
}
- if (video_gamma != 0.0 || video_bright != 0.0 || video_contr != 0.0 || video_satur != 1.0)
+ if (video_gamma != 0.0 || video_bright != 0.0 || video_contr != 0.0 || video_satur != 1.0)
lut_init(video_contr, video_bright, video_gamma, video_satur);
}
if (this->framerate_new.num > 0) {
- fprintf(stderr," Resample Framerate: %0.2f => %0.2f\n",
+ fprintf(stderr," Resample Framerate: %0.2f => %0.2f\n",
this->fps,(double)this->framerate_new.num / this->framerate_new.den);
}
if (this->audio_index >= 0){
@@ -555,7 +555,7 @@
AVFrame *output_tmp=NULL;
AVFrame *output_resized=NULL;
AVFrame *output_buffered=NULL;
-
+
AVPacket pkt;
int len;
int len1;
@@ -567,39 +567,39 @@
int16_t *audio_buf= av_malloc(4*AVCODEC_MAX_AUDIO_FRAME_SIZE);
int16_t *resampled= av_malloc(4*AVCODEC_MAX_AUDIO_FRAME_SIZE);
int no_frames;
-
+
double framerate_add;
double framerate_tmpcount = 0;
-
+
if(this->video_index >= 0)
info.audio_only=0;
else
info.audio_only=1;
-
+
if(this->audio_index>=0)
info.video_only=0;
else
info.video_only=1;
-
+
if(!info.audio_only){
frame = frame_alloc(vstream->codec->pix_fmt,
vstream->codec->width,vstream->codec->height);
frame_tmp = frame_alloc(vstream->codec->pix_fmt,
vstream->codec->width,vstream->codec->height);
- output_tmp =frame_alloc(this->pix_fmt,
+ output_tmp =frame_alloc(this->pix_fmt,
vstream->codec->width,vstream->codec->height);
- output =frame_alloc(this->pix_fmt,
+ output =frame_alloc(this->pix_fmt,
vstream->codec->width,vstream->codec->height);
- output_resized =frame_alloc(this->pix_fmt,
+ output_resized =frame_alloc(this->pix_fmt,
this->frame_width, this->frame_height);
output_buffered =frame_alloc(this->pix_fmt,
- this->frame_width, this->frame_height);
+ this->frame_width, this->frame_height);
/* video settings here */
/* config file? commandline options? v2v presets? */
-
+
theora_info_init (&info.ti);
-
+
info.ti.width = this->frame_width;
info.ti.height = this->frame_height;
info.ti.frame_width = this->picture_width;
@@ -612,17 +612,17 @@
}
else {
if (this->framerate_new.num > 0) {
- // new framerate is interger only right now,
+ // new framerate is interger only right now,
// so denominator is always 1
info.ti.fps_numerator = this->framerate_new.num;
info.ti.fps_denominator = this->framerate_new.den;
- }
+ }
else {
info.ti.fps_numerator=vstream->r_frame_rate.num;
info.ti.fps_denominator = vstream->r_frame_rate.den;
}
}
-
+
/* this is pixel aspect ratio */
info.ti.aspect_numerator=this->aspect_numerator;
info.ti.aspect_denominator=this->aspect_denominator;
@@ -635,7 +635,7 @@
else
info.ti.colorspace = OC_CS_UNSPECIFIED;
- info.ti.target_bitrate = this->video_bitrate;
+ info.ti.target_bitrate = this->video_bitrate;
info.ti.quality = this->video_quality;
info.ti.dropframes_p = 0;
info.ti.keyframe_auto_p = 1;
@@ -647,7 +647,7 @@
info.ti.noise_sensitivity = 1;
// range 0-2, 0 sharp, 2 less sharp,less bandwidth
info.ti.sharpness = this->sharpness;
-
+
}
/* audio settings here */
info.channels = this->channels;
@@ -678,7 +678,7 @@
}
/* main decoding loop */
- do{
+ do{
if(no_frames > 0){
if(this->frame_count > no_frames){
break;
@@ -688,7 +688,7 @@
if(ret<0){
e_o_s=1;
}
-
+
ptr = pkt.data;
len = pkt.size;
if (e_o_s && !info.audio_only || (ret >= 0 && pkt.stream_index == this->video_index)){
@@ -704,11 +704,11 @@
// this is disabled by default since it does not work
// for all input formats the way it should.
if(this->sync == 1) {
- double delta = ((double) pkt.dts /
- AV_TIME_BASE - this->pts_offset) *
+ double delta = ((double) pkt.dts /
+ AV_TIME_BASE - this->pts_offset) *
this->fps - this->frame_count;
/* 0.7 is an arbitrary value */
- /* it should be larger than half a frame to
+ /* it should be larger than half a frame to
avoid excessive dropping and duplicating */
if (delta < -0.7) {
#ifdef DEBUG
@@ -727,28 +727,28 @@
#endif
}
}
-
+
if (this->framerate_new.num > 0) {
framerate_tmpcount += framerate_add;
if (framerate_tmpcount < (double)(this->frame_count+1)) {
got_picture = 0;
- }
+ }
else {
dups = 0;
while (framerate_tmpcount >= (double)(this->frame_count+2+dups)) {
dups += 1;
- }
+ }
}
}
-
+
//For audio only files command line option"-e" will not work
//as we don't increment frame_count in audio section.
-
+
if(venc->pix_fmt != this->pix_fmt) {
sws_scale(this->sws_colorspace_ctx,
frame->data, frame->linesize, 0, venc->height,
output_tmp->data, output_tmp->linesize);
-
+
}
else{
output_tmp = frame;
@@ -773,7 +773,7 @@
frame_hook_process((AVPicture *)output, this->pix_fmt, venc->width,venc->height);
if (this->frame_topBand || this->frame_leftBand) {
- if (av_picture_crop((AVPicture *)output_tmp, (AVPicture *)output,
+ if (av_picture_crop((AVPicture *)output_tmp, (AVPicture *)output,
this->pix_fmt, this->frame_topBand, this->frame_leftBand) < 0) {
av_log(NULL, AV_LOG_ERROR, "error cropping picture\n");
}
@@ -783,7 +783,7 @@
sws_scale(this->sws_scale_ctx,
output->data, output->linesize, 0, venc->height - (this->frame_topBand + this->frame_bottomBand),
output_resized->data, output_resized->linesize);
- }
+ }
else{
output_resized=output;
}
@@ -828,11 +828,11 @@
break;
}
}
-
+
}
- if(e_o_s && !info.video_only
+ if(e_o_s && !info.video_only
|| (ret >= 0 && pkt.stream_index == this->audio_index)){
- this->pts_offset = (double) pkt.pts / AV_TIME_BASE -
+ this->pts_offset = (double) pkt.pts / AV_TIME_BASE -
(double) this->sample_count / this->sample_rate;
while(e_o_s || len > 0 ){
int samples=0;
@@ -848,7 +848,7 @@
ptr += len1;
if(data_size >0){
samples =data_size / (aenc->channels * 2);
-
+
samples_out = samples;
if(this->audio_resample_ctx){
samples_out = audio_resample(this->audio_resample_ctx, resampled, audio_buf, samples);
@@ -857,7 +857,7 @@
resampled=audio_buf;
}
}
- oggmux_add_audio(&info, resampled,
+ oggmux_add_audio(&info, resampled,
samples_out *(this->channels),samples_out,e_o_s);
this->sample_count += samples_out;
if(e_o_s && len <= 0){
@@ -934,7 +934,7 @@
{
const char *p;
AVRational framerate;
-
+
p = strchr(arg, ':');
if (!p) {
p = strchr(arg, '/');
@@ -943,7 +943,7 @@
framerate.num = strtol(arg, (char **)&arg, 10);
if (arg == p)
framerate.den = strtol(arg+1, (char **)&arg, 10);
- if(framerate.num <= 0)
+ if(framerate.num <= 0)
framerate.num = -1;
if(framerate.den <= 0)
framerate.den = 1;
@@ -956,7 +956,7 @@
int crop_check(ff2theora this, char *name, const char *arg)
{
- int crop_value = atoi(arg);
+ int crop_value = atoi(arg);
if (crop_value < 0) {
fprintf(stderr, "Incorrect crop size `%s'.\n",name);
exit(1);
@@ -977,7 +977,7 @@
void print_presets_info() {
- fprintf (stdout,
+ fprintf (stdout,
// "v2v presets - more info at http://wiki.v2v.cc/presets"
"v2v presets:\n"
" preview Video: 320x240 if fps ~ 30, 384x288 otherwise\n"
@@ -996,7 +996,7 @@
}
void print_usage (){
- fprintf (stdout,
+ fprintf (stdout,
PACKAGE " " PACKAGE_VERSION "\n"
"\n"
" Usage: " PACKAGE " [options] input\n"
@@ -1020,8 +1020,8 @@
" -y, --height scale to given height (in pixels)\n"
" --aspect define frame aspect ratio: i.e. 4:3 or 16:9\n"
" -F, --framerate output framerate e.g 25:2 or 16\n"
- " --croptop, --cropbottom, --cropleft, --cropright\n"
- " crop input by given pixels before resizing\n"
+ " --croptop, --cropbottom, --cropleft, --cropright\n"
+ " crop input by given pixels before resizing\n"
" -S, --sharpness [0 to 2] sharpness of images (default: 2).\n"
" Note: lower values make the video sharper.\n"
" -K, --keyint [8 to 65536] keyframe interval (default: 64)\n"
@@ -1111,13 +1111,13 @@
char outputfile_name[255];
char inputfile_name[255];
char *str_ptr;
-
+
static int flag = -1;
static int metadata_flag = 0;
AVInputFormat *input_fmt = NULL;
AVFormatParameters *formatParams = NULL;
-
+
int c,long_option_index;
const char *optstring = "P:o:k:f:F:x:y:v:V:a:A:S:K:d:H:c:G:Z:C:B:p:N:s:e:D:h::";
struct option options [] = {
@@ -1175,7 +1175,7 @@
{"help",0,NULL,'h'},
{NULL,0,NULL,0}
};
-
+
char pidfile_name[255] = { '\0' };
FILE *fpid = NULL;
@@ -1188,13 +1188,13 @@
// set some variables;
init_info(&info);
theora_comment_init (&info.tc);
-
+
while((c=getopt_long(argc,argv,optstring,options,&long_option_index))!=EOF){
switch(c)
{
case 0:
if (flag) {
- switch (flag)
+ switch (flag)
{
case DEINTERLACE_FLAG:
convert->deinterlace = 1;
@@ -1366,7 +1366,7 @@
break;
case 'C':
video_contr = atof(optarg);
- break;
+ break;
case 'Z':
video_satur = atof(optarg);
break;
@@ -1386,7 +1386,7 @@
fprintf (stderr, "Only values from 8 to 65536 are valid for keyframe interval.\n");
exit(1);
}
- break;
+ break;
case 'H':
convert->sample_rate=atoi(optarg);
break;
@@ -1449,9 +1449,9 @@
case 'h':
print_usage ();
exit(1);
- }
- }
-
+ }
+ }
+
while(optind<argc){
/* assume that anything following the options must be a filename */
snprintf(inputfile_name,sizeof(inputfile_name),"%s",argv[optind]);
@@ -1503,8 +1503,8 @@
using_stdin |= !strcmp(inputfile_name, "pipe:" ) ||
!strcmp( inputfile_name, "/dev/stdin" );
- if(outputfile_set!=1){
- fprintf(stderr,"You have to specify an output file with -o output.ogv.\n");
+ if(outputfile_set!=1){
+ fprintf(stderr,"You have to specify an output file with -o output.ogv.\n");
exit(1);
}
@@ -1524,16 +1524,16 @@
exit(1);
}
- if (*pidfile_name)
+ if (*pidfile_name)
{
fpid = fopen(pidfile_name, "w");
if (fpid != NULL)
{
fprintf(fpid, "%i", getpid());
fclose(fpid);
- }
+ }
}
-
+
if (av_open_input_file(&convert->context, inputfile_name, input_fmt, 0, formatParams) >= 0){
if (av_find_stream_info (convert->context) >= 0){
#ifdef WIN32
@@ -1551,10 +1551,10 @@
info.outfile = fopen(outputfile_name,"wb");
#endif
if(info.frontend) {
- fprintf(stderr, "\nf2t ;duration: %d;\n", convert->context->duration / AV_TIME_BASE);
+ fprintf(stderr, "\nf2t ;duration: %d;\n", convert->context->duration / AV_TIME_BASE);
}
else {
- dump_format (convert->context, 0,inputfile_name, 0);
+ dump_format (convert->context, 0,inputfile_name, 0);
}
if(convert->disable_audio){
fprintf(stderr," [audio disabled].\n");
@@ -1563,11 +1563,11 @@
fprintf(stderr," Use A/V Sync from input container.\n");
}
- convert->pts_offset =
+ convert->pts_offset =
(double) convert->context->start_time / AV_TIME_BASE;
if(!info.outfile) {
if(info.frontend)
- fprintf(stderr, "\nf2t ;result: Unable to open output file.;\n");
+ fprintf(stderr, "\nf2t ;result: Unable to open output file.;\n");
else
fprintf (stderr,"\nUnable to open output file `%s'.\n", outputfile_name);
return(1);
@@ -1580,7 +1580,7 @@
}
else{
if(info.frontend)
- fprintf(stderr, "\nf2t ;result: input format not suported.;\n");
+ fprintf(stderr, "\nf2t ;result: input format not suported.;\n");
else
fprintf (stderr,"\nUnable to decode input.\n");
return(1);
@@ -1593,12 +1593,12 @@
}
ff2theora_close (convert);
fprintf(stderr,"\n");
-
+
if (*pidfile_name)
unlink(pidfile_name);
-
+
if(info.frontend)
- fprintf(stderr, "\nf2t ;result: ok;\n");
-
+ fprintf(stderr, "\nf2t ;result: ok;\n");
+
return(0);
}
Modified: trunk/ffmpeg2theora/theorautils.c
===================================================================
--- trunk/ffmpeg2theora/theorautils.c 2008-01-15 12:18:53 UTC (rev 14402)
+++ trunk/ffmpeg2theora/theorautils.c 2008-01-16 09:11:48 UTC (rev 14403)
@@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
+ *
*/
#include <stdio.h>
@@ -42,7 +42,7 @@
}
void init_info(oggmux_info *info) {
- info->with_skeleton = 1; /* skeleton is enabled by default */
+ info->with_skeleton = 1; /* skeleton is enabled by default */
info->frontend = 0; /*frontend mode*/
info->videotime = 0;
info->audiotime = 0;
@@ -58,7 +58,7 @@
info->start_time = time(NULL);
info->duration = -1;
info->speed_level = -1;
-
+
info->v_pkg=0;
info->a_pkg=0;
#ifdef OGGMUX_DEBUG
@@ -71,7 +71,7 @@
ogg_packet op;
memset (&op, 0, sizeof (op));
-
+
op.packet = _ogg_calloc (64, sizeof(unsigned char));
memset (op.packet, 0, 64);
memcpy (op.packet, FISHEAD_IDENTIFIER, 8); /* identifier */
@@ -83,7 +83,7 @@
*((ogg_int64_t*)(op.packet+36)) = (ogg_int64_t)1000; /* basetime denominator */
/* both the numerator are zero hence handled by the memset */
*((ogg_uint32_t*)(op.packet+44)) = 0; /* UTC time, set to zero for now */
-
+
op.b_o_s = 1; /* its the first packet of the stream */
op.e_o_s = 0; /* its not the last packet of the stream */
op.bytes = 64; /* length of the packet in bytes */
@@ -99,54 +99,54 @@
ogg_packet op;
if (!info->audio_only) {
- memset (&op, 0, sizeof (op));
+ memset (&op, 0, sizeof (op));
op.packet = _ogg_calloc (82, sizeof(unsigned char));
memset (op.packet, 0, 82);
- /* it will be the fisbone packet for the theora video */
+ /* it will be the fisbone packet for the theora video */
memcpy (op.packet, FISBONE_IDENTIFIER, 8); /* identifier */
- *((ogg_uint32_t*)(op.packet+8)) = FISBONE_MESSAGE_HEADER_OFFSET; /* offset of the message header fields */
+ *((ogg_uint32_t*)(op.packet+8)) = FISBONE_MESSAGE_HEADER_OFFSET; /* offset of the message header fields */
*((ogg_uint32_t*)(op.packet+12)) = info->to.serialno; /* serialno of the theora stream */
- *((ogg_uint32_t*)(op.packet+16)) = 3; /* number of header packets */
- /* granulerate, temporal resolution of the bitstream in samples/microsecond */
+ *((ogg_uint32_t*)(op.packet+16)) = 3; /* number of header packets */
+ /* granulerate, temporal resolution of the bitstream in samples/microsecond */
*((ogg_int64_t*)(op.packet+20)) = info->ti.fps_numerator; /* granulrate numerator */
- *((ogg_int64_t*)(op.packet+28)) = info->ti.fps_denominator; /* granulrate denominator */
+ *((ogg_int64_t*)(op.packet+28)) = info->ti.fps_denominator; /* granulrate denominator */
*((ogg_int64_t*)(op.packet+36)) = 0; /* start granule */
- *((ogg_uint32_t*)(op.packet+44)) = 0; /* preroll, for theora its 0 */
+ *((ogg_uint32_t*)(op.packet+44)) = 0; /* preroll, for theora its 0 */
*(op.packet+48) = theora_granule_shift (&info->ti); /* granule shift */
memcpy(op.packet+FISBONE_SIZE, "Content-Type: video/x-theora\r\n", 30); /* message header field, Content-Type */
-
- op.b_o_s = 0;
- op.e_o_s = 0;
- op.bytes = 82; /* size of the packet in bytes */
-
+
+ op.b_o_s = 0;
+ op.e_o_s = 0;
+ op.bytes = 82; /* size of the packet in bytes */
+
ogg_stream_packetin (&info->so, &op);
- _ogg_free (op.packet);
+ _ogg_free (op.packet);
}
if (!info->video_only) {
- memset (&op, 0, sizeof (op));
- op.packet = _ogg_calloc (82, sizeof(unsigned char));
- memset (op.packet, 0, 82);
+ memset (&op, 0, sizeof (op));
+ op.packet = _ogg_calloc (82, sizeof(unsigned char));
+ memset (op.packet, 0, 82);
/* it will be the fisbone packet for the vorbis audio */
- memcpy (op.packet, FISBONE_IDENTIFIER, 8); /* identifier */
+ memcpy (op.packet, FISBONE_IDENTIFIER, 8); /* identifier */
*((ogg_uint32_t*)(op.packet+8)) = FISBONE_MESSAGE_HEADER_OFFSET; /* offset of the message header fields */
- *((ogg_uint32_t*)(op.packet+12)) = info->vo.serialno; /* serialno of the vorbis stream */
+ *((ogg_uint32_t*)(op.packet+12)) = info->vo.serialno; /* serialno of the vorbis stream */
*((ogg_uint32_t*)(op.packet+16)) = 3; /* number of header packet */
- /* granulerate, temporal resolution of the bitstream in Hz */
- *((ogg_int64_t*)(op.packet+20)) = info->sample_rate; /* granulerate numerator */
+ /* granulerate, temporal resolution of the bitstream in Hz */
+ *((ogg_int64_t*)(op.packet+20)) = info->sample_rate; /* granulerate numerator */
*((ogg_int64_t*)(op.packet+28)) = (ogg_int64_t)1; /* granulerate denominator */
- *((ogg_int64_t*)(op.packet+36)) = 0; /* start granule */
+ *((ogg_int64_t*)(op.packet+36)) = 0; /* start granule */
*((ogg_uint32_t*)(op.packet+44)) = 2; /* preroll, for vorbis its 2 */
- *(op.packet+48) = 0; /* granule shift, always 0 for vorbis */
- memcpy (op.packet+FISBONE_SIZE, "Content-Type: audio/x-vorbis\r\n", 30);
- /* Important: Check the case of Content-Type for correctness */
-
- op.b_o_s = 0;
- op.e_o_s = 0;
- op.bytes = 82;
-
+ *(op.packet+48) = 0; /* granule shift, always 0 for vorbis */
+ memcpy (op.packet+FISBONE_SIZE, "Content-Type: audio/x-vorbis\r\n", 30);
+ /* Important: Check the case of Content-Type for correctness */
+
+ op.b_o_s = 0;
+ op.e_o_s = 0;
+ op.bytes = 82;
+
ogg_stream_packetin (&info->so, &op);
- _ogg_free (op.packet);
+ _ogg_free (op.packet);
}
}
@@ -156,12 +156,12 @@
/* yayness. Set up Ogg output stream */
srand (time (NULL));
- ogg_stream_init (&info->vo, rand ());
-
+ ogg_stream_init (&info->vo, rand ());
+
if(!info->audio_only){
ogg_stream_init (&info->to, rand ()); /* oops, add one ot the above */
theora_encode_init (&info->td, &info->ti);
-
+
if(info->speed_level >= 0) {
int max_speed_level;
theora_control(&info->td, TH_ENCCTL_GET_SPLEVEL_MAX, &max_speed_level, sizeof(int));
@@ -177,10 +177,10 @@
int ret;
vorbis_info_init (&info->vi);
/* Encoding using a VBR quality mode. */
- if(info->vorbis_quality>-99)
+ if(info->vorbis_quality>-99)
ret =vorbis_encode_init_vbr (&info->vi, info->channels,info->sample_rate,info->vorbis_quality);
else
- ret=vorbis_encode_init(&info->vi,info->channels,info->sample_rate,-1,info->vorbis_bitrate,-1);
+ ret=vorbis_encode_init(&info->vi,info->channels,info->sample_rate,-1,info->vorbis_bitrate,-1);
if (ret){
fprintf (stderr,
@@ -201,9 +201,9 @@
/* first packet should be skeleton fishead packet, if skeleton is used */
if (info->with_skeleton) {
- ogg_stream_init (&info->so, rand());
- add_fishead_packet (info);
- if (ogg_stream_pageout (&info->so, &og) != 1){
+ ogg_stream_init (&info->so, rand());
+ add_fishead_packet (info);
+ if (ogg_stream_pageout (&info->so, &og) != 1){
fprintf (stderr, "Internal Ogg library error.\n");
exit (1);
}
@@ -255,23 +255,23 @@
/* output the appropriate fisbone packets */
if (info->with_skeleton) {
- add_fisbone_packet (info);
- while (1) {
- int result = ogg_stream_flush (&info->so, &og);
+ add_fisbone_packet (info);
+ while (1) {
+ int result = ogg_stream_flush (&info->so, &og);
if (result < 0){
- /* can't get here */
- fprintf (stderr, "Internal Ogg library error.\n");
- exit (1);
+ /* can't get here */
+ fprintf (stderr, "Internal Ogg library error.\n");
+ exit (1);
}
- if (result == 0)
- break;
+ if (result == 0)
+ break;
fwrite (og.header, 1, og.header_len, info->outfile);
- fwrite (og.body, 1, og.body_len, info->outfile);
- }
+ fwrite (og.body, 1, og.body_len, info->outfile);
}
+ }
if (!info->audio_only) {
- theora_info_clear(&info->ti);
+ theora_info_clear(&info->ti);
}
/* Flush the rest of our headers. This ensures
@@ -303,17 +303,17 @@
}
if (info->with_skeleton) {
- int result;
+ int result;
/* build and add the e_o_s packet */
- memset (&op, 0, sizeof (op));
+ memset (&op, 0, sizeof (op));
op.b_o_s = 0;
- op.e_o_s = 1; /* its the e_o_s packet */
+ op.e_o_s = 1; /* its the e_o_s packet */
op.granulepos = 0;
- op.bytes = 0; /* e_o_s packet is an empty packet */
+ op.bytes = 0; /* e_o_s packet is an empty packet */
ogg_stream_packetin (&info->so, &op);
- result = ogg_stream_flush (&info->so, &og);
+ result = ogg_stream_flush (&info->so, &og);
if (result < 0){
/* can't get here */
fprintf (stderr, "Internal Ogg library error.\n");
@@ -324,10 +324,10 @@
}
}
-/**
+/**
* adds a video frame to the encoding sink
* if e_o_s is 1 the end of the logical bitstream will be marked.
- * @param this ff2theora struct
+ * @param this ff2theora struct
* @param info oggmux_info
* @param yuv_buffer
* @param e_o_s 1 indicates ond of stream
@@ -340,8 +340,8 @@
info->v_pkg++;
}
}
-
-/**
+
+/**
* adds audio samples to encoding sink
* @param buffer pointer to buffer
* @param bytes bytes in buffer
@@ -372,7 +372,7 @@
/* analysis, assume we want to use bitrate management */
vorbis_analysis (&info->vb, NULL);
vorbis_bitrate_addblock (&info->vb);
-
+
/* weld packets into the bitstream */
while (vorbis_bitrate_flushpacket (&info->vd, &op)){
ogg_stream_packetin (&info->vo, &op);
@@ -384,7 +384,7 @@
static double get_remaining(oggmux_info *info, double timebase) {
double remaining = 0;
double to_encode, time_so_far;
-
+
if(info->duration != -1 && timebase > 0) {
time_so_far = time(NULL) - info->start_time;
to_encode = info->duration - timebase;
@@ -410,7 +410,7 @@
info->akbps, info->vkbps,
remaining
);
-
+
}
else {
if(!remaining) {
@@ -440,7 +440,7 @@
ret = fwrite(info->audiopage, 1, info->audiopage_len, info->outfile);
if(ret < info->audiopage_len) {
- fprintf(stderr,"error writing audio page\n");
+ fprintf(stderr,"error writing audio page\n");
}
else {
info->audio_bytesout += ret;
@@ -542,7 +542,7 @@
info->audiopage_valid = 1;
if(ogg_page_granulepos(&og)>0) {
- info->audiotime= vorbis_granule_time (&info->vd,
+ info->audiotime= vorbis_granule_time (&info->vd,
ogg_page_granulepos(&og));
}
}
@@ -564,7 +564,7 @@
write_video_page(info);
else
write_audio_page(info);
- }
+ }
else if(e_o_s && info->videopage_valid) {
write_video_page(info);
}
Modified: trunk/ffmpeg2theora/theorautils.h
===================================================================
--- trunk/ffmpeg2theora/theorautils.h 2008-01-15 12:18:53 UTC (rev 14402)
+++ trunk/ffmpeg2theora/theorautils.h 2008-01-16 09:11:48 UTC (rev 14403)
@@ -56,7 +56,7 @@
theora_comment tc;
int speed_level;
- /* state info */
+ /* state info */
theora_state td;
vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
vorbis_block vb; /* local working space for packet->PCM decode */
@@ -67,7 +67,7 @@
ogg_stream_state vo; /* take physical pages, weld into a logical
* stream of packets */
ogg_stream_state so; /* take physical pages, weld into a logical
- * stream of packets, used for skeleton stream */
+ * stream of packets, used for skeleton stream */
int audiopage_valid;
int videopage_valid;
@@ -82,7 +82,7 @@
double audiotime;
double videotime;
double duration;
-
+
int vkbps;
int akbps;
ogg_int64_t audio_bytesout;
More information about the commits
mailing list