summaryrefslogtreecommitdiff
path: root/src/post/visualizations/fftscope.c
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-04-03 00:38:22 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-04-03 00:38:22 +0200
commit0ed2cd4f34189ec303dfac5a30de0abae0decba8 (patch)
tree7a8d08d25ca7c81daa9d6cd65fd4f633fd676b41 /src/post/visualizations/fftscope.c
parent6081bc9a06ee97333769f77a9e5c18a15afb29da (diff)
parent3dd7d925c2feb7868a49e7a1a0b953a5aab233f0 (diff)
downloadxine-lib-0ed2cd4f34189ec303dfac5a30de0abae0decba8.tar.gz
xine-lib-0ed2cd4f34189ec303dfac5a30de0abae0decba8.tar.bz2
Merge changes happened in 1.1 development.
Diffstat (limited to 'src/post/visualizations/fftscope.c')
-rw-r--r--src/post/visualizations/fftscope.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/post/visualizations/fftscope.c b/src/post/visualizations/fftscope.c
index 8448f3a65..aef517c59 100644
--- a/src/post/visualizations/fftscope.c
+++ b/src/post/visualizations/fftscope.c
@@ -22,7 +22,7 @@
*
* FFT code by Steve Haehnichen, originally licensed under GPL v1
*
- * $Id: fftscope.c,v 1.29 2006/01/27 07:46:14 tmattern Exp $
+ * $Id: fftscope.c,v 1.30 2006/12/02 22:35:18 miguelfreitas Exp $
*
*/
@@ -289,6 +289,7 @@ static int fftscope_port_open(xine_audio_port_t *port_gen, xine_stream_t *stream
this->channels = MAXCHANNELS;
this->samples_per_frame = rate / FPS;
this->data_idx = 0;
+ this->sample_counter = 0;
this->fft = fft_new(FFT_BITS);
this->vo_port->open(this->vo_port, XINE_ANON_STREAM);
@@ -363,7 +364,7 @@ static void fftscope_port_put_buffer (xine_audio_port_t *port_gen,
data8 += samples_used * this->channels;
/* scale 8 bit data to 16 bits and convert to signed as well */
- for( i = 0; i < buf->num_frames && this->data_idx < NUMSAMPLES;
+ for( i = samples_used; i < buf->num_frames && this->data_idx < NUMSAMPLES;
i++, this->data_idx++, data8 += this->channels ) {
for( c = 0; c < this->channels; c++){
this->wave[c][this->data_idx].re = (double)(data8[c] << 8) - 0x8000;
@@ -374,7 +375,7 @@ static void fftscope_port_put_buffer (xine_audio_port_t *port_gen,
data = buf->mem;
data += samples_used * this->channels;
- for( i = 0; i < buf->num_frames && this->data_idx < NUMSAMPLES;
+ for( i = samples_used; i < buf->num_frames && this->data_idx < NUMSAMPLES;
i++, this->data_idx++, data += this->channels ) {
for( c = 0; c < this->channels; c++){
this->wave[c][this->data_idx].re = (double)data[c];
@@ -383,17 +384,24 @@ static void fftscope_port_put_buffer (xine_audio_port_t *port_gen,
}
}
- if( this->sample_counter >= this->samples_per_frame &&
- this->data_idx == NUMSAMPLES ) {
+ if( this->sample_counter >= this->samples_per_frame ) {
- this->data_idx = 0;
samples_used += this->samples_per_frame;
frame = this->vo_port->get_frame (this->vo_port, FFT_WIDTH, FFT_HEIGHT,
this->ratio, XINE_IMGFMT_YUY2,
VO_BOTH_FIELDS);
frame->extra_info->invalid = 1;
- frame->bad_frame = 0;
+
+ /* frame is marked as bad if we don't have enough samples for
+ * updating the viz plugin (calculations may be skipped).
+ * we must keep the framerate though. */
+ if( this->data_idx == NUMSAMPLES ) {
+ frame->bad_frame = 0;
+ this->data_idx = 0;
+ } else {
+ frame->bad_frame = 1;
+ }
frame->duration = 90000 * this->samples_per_frame / port->rate;
frame->pts = pts;
this->metronom->got_video_frame(this->metronom, frame);