Improve peak reading efficiency.
This commit is contained in:
parent
48bcd7ed98
commit
22030e41b6
|
@ -127,19 +127,20 @@ Peak_Server::handle_request ( int s, const char *buf, int l )
|
||||||
|
|
||||||
int npeaks = pk->fill_buffer( fpp, start, end );
|
int npeaks = pk->fill_buffer( fpp, start, end );
|
||||||
|
|
||||||
/* deinterlace and transmit */
|
|
||||||
int channels = af->channels();
|
int channels = af->channels();
|
||||||
|
|
||||||
/* FIXME: really inefficient */
|
Peak *pbuf = new Peak[ npeaks * channels ];
|
||||||
|
|
||||||
|
/* deinterlace */
|
||||||
|
int k = 0;
|
||||||
for ( int i = 0; i < channels; i++ )
|
for ( int i = 0; i < channels; i++ )
|
||||||
for ( int j = i; j < npeaks * channels; j += channels )
|
for ( int j = i; j < npeaks * channels; j += channels )
|
||||||
send( s, pk->peakbuf() + j, sizeof( Peak ), 0 );
|
pbuf[ k++ ] = pk->peakbuf()[ j ];
|
||||||
|
|
||||||
|
/* transmit */
|
||||||
|
send( s, pbuf, sizeof( Peak ) * npeaks * channels, 0 );
|
||||||
|
|
||||||
/* for ( int i = 0; i < af->channels(); ++i ) */
|
delete pbuf;
|
||||||
/* { */
|
|
||||||
/* send( s, pk->peakbuf(), npeaks * sizeof( Peak ), 0 ); */
|
|
||||||
/* } */
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ Peaks::read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const
|
Peaks::read_source_peaks ( Peak *peaks, int npeaks, int chunksize ) const
|
||||||
{
|
{
|
||||||
int channels = _clip->channels();
|
int channels = _clip->channels();
|
||||||
|
|
||||||
|
@ -155,9 +155,6 @@ Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize )
|
||||||
|
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
_clip->open();
|
|
||||||
_clip->seek( s );
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
for ( i = 0; i < npeaks; ++i )
|
for ( i = 0; i < npeaks; ++i )
|
||||||
{
|
{
|
||||||
|
@ -190,6 +187,17 @@ Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize )
|
||||||
|
|
||||||
delete fbuf;
|
delete fbuf;
|
||||||
|
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Peaks::read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const
|
||||||
|
{
|
||||||
|
_clip->open();
|
||||||
|
_clip->seek( s );
|
||||||
|
|
||||||
|
int i = read_source_peaks( peaks, npeaks, chunksize );
|
||||||
|
|
||||||
_clip->close();
|
_clip->close();
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
|
@ -340,10 +348,8 @@ Peaks::make_peaks ( int chunksize )
|
||||||
Peak peaks[ _clip->channels() ];
|
Peak peaks[ _clip->channels() ];
|
||||||
|
|
||||||
size_t len;
|
size_t len;
|
||||||
nframes_t s = 0;
|
|
||||||
do {
|
do {
|
||||||
len = read_source_peaks( peaks, s, 1, chunksize );
|
len = read_source_peaks( peaks, 1, chunksize );
|
||||||
s += len * chunksize;
|
|
||||||
fwrite( peaks, sizeof( peaks ), 1, fp );
|
fwrite( peaks, sizeof( peaks ), 1, fp );
|
||||||
}
|
}
|
||||||
while ( len );
|
while ( len );
|
||||||
|
|
|
@ -64,6 +64,7 @@ class Peaks
|
||||||
|
|
||||||
void read_peaks ( int s, int e, int npeaks, int chunksize ) const;
|
void read_peaks ( int s, int e, int npeaks, int chunksize ) const;
|
||||||
int read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const;
|
int read_source_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const;
|
||||||
|
int read_source_peaks ( Peak *peaks, int npeaks, int chunksize ) const;
|
||||||
int read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const;
|
int read_peakfile_peaks ( Peak *peaks, nframes_t s, int npeaks, int chunksize ) const;
|
||||||
|
|
||||||
const char *peakname ( const char *filename ) const;
|
const char *peakname ( const char *filename ) const;
|
||||||
|
|
Loading…
Reference in New Issue