From a2adb92f17159c0399504ab4b18acb1d94122077 Mon Sep 17 00:00:00 2001 From: Good Guy Date: Mon, 22 Jun 2015 16:36:35 -0600 Subject: [PATCH] vorbis bld msgs, ffmpeg one frame/frame flush bug, ffmpeg audio history fixes --- cinelerra-5.0/cinelerra/ffmpeg.C | 43 +++++++++++++++++----------- cinelerra-5.0/cinelerra/file.C | 9 ++++-- cinelerra-5.0/cinelerra/filevorbis.C | 6 ++++ 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/cinelerra-5.0/cinelerra/ffmpeg.C b/cinelerra-5.0/cinelerra/ffmpeg.C index 48a8bf40..db6ca9d6 100644 --- a/cinelerra-5.0/cinelerra/ffmpeg.C +++ b/cinelerra-5.0/cinelerra/ffmpeg.C @@ -105,14 +105,15 @@ void FFAudioHistory::reserve(long sz, int nch) 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; @@ -157,42 +158,49 @@ int64_t FFAudioHistory::get_inp(int ofs) 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(); @@ -200,8 +208,9 @@ int FFAudioHistory::read(double *dp, long len, int ch) 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; } @@ -345,9 +354,9 @@ int FFStream::decode(AVFrame *frame) 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; } diff --git a/cinelerra-5.0/cinelerra/file.C b/cinelerra-5.0/cinelerra/file.C index 294c6c6c..17e555aa 100644 --- a/cinelerra-5.0/cinelerra/file.C +++ b/cinelerra-5.0/cinelerra/file.C @@ -79,8 +79,11 @@ #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() { @@ -808,7 +811,7 @@ int File::open_file(Preferences *preferences, 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; } diff --git a/cinelerra-5.0/cinelerra/filevorbis.C b/cinelerra-5.0/cinelerra/filevorbis.C index 83df5e72..4740fe87 100644 --- a/cinelerra-5.0/cinelerra/filevorbis.C +++ b/cinelerra-5.0/cinelerra/filevorbis.C @@ -35,6 +35,12 @@ #include #include +//suppress noref warning +void *vorbis1_ov_callbacks[] = { + &OV_CALLBACKS_DEFAULT, &OV_CALLBACKS_NOCLOSE, + &OV_CALLBACKS_STREAMONLY, &OV_CALLBACKS_STREAMONLY_NOCLOSE, +}; + FileVorbis::FileVorbis(Asset *asset, File *file) : FileBase(asset, file) { -- 2.26.2