void FFAudioHistory::realloc(long sz, int nch)
{
- if( this->sz >= sz && this->nch == nch ) return;
- long isz = used() * nch;
+ if( this->nch != nch )
+ reset();
+ else if( this->sz >= sz )
+ return;
this->nch = nch;
this->sz = sz;
bsz = sz * nch;
float *np = new float[bsz];
- if( isz > 0 ) copy(np, isz);
- inp = np + isz;
+ inp = np + copy(np, used());
outp = np;
lmt = np + bsz;
delete [] bfr; bfr = np;
int FFAudioHistory::write(const float *fp, long len)
{
long n = len * nch;
+ float *ip = inp;
while( n > 0 ) {
- int k = lmt - inp;
+ int k = lmt - ip;
if( k > n ) k = n;
n -= k;
- while( --k >= 0 ) *inp++ = *fp++;
- if( inp >= lmt ) inp -= bsz;
+ while( --k >= 0 ) *ip++ = *fp++;
+ if( ip >= lmt ) ip = bfr;
}
+ inp = ip;
return len;
}
int FFAudioHistory::copy(float *fp, long len)
{
- long n = len;
+ long n = len * nch;
+ float *op = outp;
while( n > 0 ) {
- int k = lmt - outp;
+ int k = lmt - op;
if( k > n ) k = n;
n -= k;
- while( --k >= 0 ) *fp++ = *outp++;
- if( outp >= lmt ) outp -= bsz;
+ while( --k >= 0 ) *fp++ = *op++;
+ if( op >= lmt ) op = bfr;
}
+ outp = op;
return len;
}
int FFAudioHistory::zero(long len)
{
long n = len * nch;
+ float *ip = inp;
while( n > 0 ) {
- int k = lmt - inp;
+ int k = lmt - ip;
if( k > n ) k = n;
n -= k;
- while( --k >= 0 ) *inp++ = 0;
- if( inp >= lmt ) inp -= bsz;
+ while( --k >= 0 ) *ip++ = 0;
+ if( ip >= lmt ) ip = bfr;
}
+ inp = ip;
return len;
}
+// does not advance outp
int FFAudioHistory::read(double *dp, long len, int ch)
{
long sz = used();
if( len > sz ) len = sz;
long n = len;
float *op = outp + ch;
+ float *lmt1 = lmt + nch-1;
while( n > 0 ) {
- int k = (lmt - outp) / nch;
+ int k = (lmt1 - op) / nch;
if( k > n ) k = n;
n -= k;
while( --k >= 0 ) { *dp++ = *op; op += nch; }
if( !ret ) ipkt->stream_index = st->index;
}
if( ipkt->stream_index == st->index ) {
- while( ipkt->size > 0 && !got_frame ) {
+ while( (ipkt->size > 0 || !ipkt->data) && !got_frame ) {
ret = decode_frame(frame, got_frame);
- if( ret < 0 ) break;
+ if( ret < 0 || !ipkt->data ) break;
ipkt->data += ret;
ipkt->size -= ret;
}
#include "stringfile.h"
#include "vframe.h"
-
-
+//suppress noref warning
+void *vorbis0_ov_callbacks[] = {
+ &OV_CALLBACKS_DEFAULT, &OV_CALLBACKS_NOCLOSE,
+ &OV_CALLBACKS_STREAMONLY, &OV_CALLBACKS_STREAMONLY_NOCLOSE,
+};
File::File()
{
if( rd ) {
// one frame image file, no specific length
if( !this->asset->audio_data && this->asset->video_data &&
- this->asset->video_length == 1 )
+ this->asset->video_length <= 1 )
this->asset->video_length = -1;
}