[xiph-commits] r6938 - trunk/ffmpeg2theora
j at dactyl.lonelymoon.com
j
Wed Jun 30 15:54:42 PDT 2004
Author: j
Date: Wed Jun 30 15:54:42 2004
New Revision: 6938
Modified:
trunk/ffmpeg2theora/ffmpeg2theora.c
trunk/ffmpeg2theora/theorautils.c
Log:
add audiotime,videotime diff to output for now, to help figure out what goes wrong with ffmpegcvs audio decoding
Modified: trunk/ffmpeg2theora/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/ffmpeg2theora.c 2004-06-30 21:15:17 UTC (rev 6937)
+++ trunk/ffmpeg2theora/ffmpeg2theora.c 2004-06-30 22:54:40 UTC (rev 6938)
@@ -57,8 +57,8 @@
int output_width;
int output_height;
double fps;
- int audio_resample;
ImgReSampleContext *img_resample_ctx; /* for image resampling/resizing */
+ ReSampleContext *audio_resample_ctx;
double aspect_numerator;
double aspect_denominator;
int video_quality;
@@ -112,7 +112,6 @@
AVStream *vstream = NULL;
AVCodec *acodec = NULL;
AVCodec *vcodec = NULL;
- ReSampleContext *resample = NULL;
double fps = 0.0;
@@ -205,7 +204,14 @@
if (this->channels != aenc->channels && aenc->codec_id == CODEC_ID_AC3)
aenc->channels = this->channels;
if (acodec != NULL && avcodec_open (aenc, acodec) >= 0)
- resample = audio_resample_init (this->channels,aenc->channels,this->frequency,aenc->sample_rate);
+ if(this->frequency!=aenc->sample_rate){
+ this->audio_resample_ctx = audio_resample_init (this->channels,aenc->channels,this->frequency,aenc->sample_rate);
+ fprintf(stderr," Resample: %dHz => %dHz\n",aenc->sample_rate,this->frequency);
+ }
+ else{
+ this->audio_resample_ctx=NULL;
+ }
+
else
this->audio_index = -1;
}
@@ -315,7 +321,7 @@
if(got_picture){
/* might have to cast other progressive formats here */
- if(venc->pix_fmt != PIX_FMT_YUV420P){
+ //if(venc->pix_fmt != PIX_FMT_YUV420P){
img_convert((AVPicture *)output,PIX_FMT_YUV420P,
(AVPicture *)frame,venc->pix_fmt,
venc->width,venc->height);
@@ -325,9 +331,10 @@
,venc->width,venc->height)<0){
output_tmp = output;
}
- }
- else{
+ //}
+ //else{
/* there must be better way to do this, it seems to work like this though */
+ /*
if(frame->linesize[0] != vstream->codec.width){
img_convert((AVPicture *)output_tmp,PIX_FMT_YUV420P,
(AVPicture *)frame,venc->pix_fmt,venc->width,venc->height);
@@ -336,6 +343,7 @@
output_tmp=frame;
}
}
+ */
// now output_tmp
if(this->img_resample_ctx){
img_resample(this->img_resample_ctx,
@@ -370,7 +378,12 @@
ptr += len1;
if(data_size >0){
int samples =data_size / (aenc->channels * 2);
- int samples_out = audio_resample(resample, resampled, audio_buf, samples);
+ int samples_out = samples;
+ if(this->audio_resample_ctx)
+ samples_out = audio_resample(this->audio_resample_ctx, resampled, audio_buf, samples);
+ else
+ resampled=audio_buf;
+
if (theoraframes_add_audio(resampled, samples_out *(aenc->channels),samples_out)){
ret = -1;
fprintf (stderr,"No audio frames available\n");
@@ -390,8 +403,8 @@
if (this->img_resample_ctx)
img_resample_close(this->img_resample_ctx);
- if (this->audio_resample)
- audio_resample_close(resample);
+ if (this->audio_resample_ctx)
+ audio_resample_close(this->audio_resample_ctx);
av_free(resampled);
theoraframes_close ();
Modified: trunk/ffmpeg2theora/theorautils.c
===================================================================
--- trunk/ffmpeg2theora/theorautils.c 2004-06-30 21:15:17 UTC (rev 6937)
+++ trunk/ffmpeg2theora/theorautils.c 2004-06-30 22:54:40 UTC (rev 6938)
@@ -276,6 +276,7 @@
timebase = info.audiotime;
video=0;
}
+ if(video>=0)
{
int hundredths = timebase * 100 - (long) timebase * 100;
int seconds = (long) timebase % 60;
@@ -289,8 +290,8 @@
info.akbps = rint (info.audio_bytesout *
8. / timebase * .001);
- fprintf (stderr,"\r %d:%02d:%02d.%02d audio: %dkbps video: %dkbps ",
- hours, minutes, seconds, hundredths,info.akbps, info.vkbps);
+ fprintf (stderr,"\r %d:%02d:%02d.%02d audio: %dkbps video: %dkbps diff: %.4f ",
+ hours, minutes, seconds, hundredths,info.akbps, info.vkbps,info.audiotime-info.videotime);
}
}
More information about the commits
mailing list