vorbis bld msgs, ffmpeg one frame/frame flush bug, ffmpeg audio history fixes
authorGood Guy <good1.2guy@gmail.com>
Mon, 22 Jun 2015 22:36:35 +0000 (16:36 -0600)
committerGood Guy <good1.2guy@gmail.com>
Mon, 22 Jun 2015 22:36:35 +0000 (16:36 -0600)
cinelerra-5.0/cinelerra/ffmpeg.C
cinelerra-5.0/cinelerra/file.C
cinelerra-5.0/cinelerra/filevorbis.C

index 48a8bf40099abc85932c1f266be1e84d0d9ebfb8..db6ca9d6e71278cb82bfdfefbef2dd0c290b5602 100644 (file)
@@ -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;
                        }
index 294c6c6c52bc6f89f55c049ed840c0711135d145..17e555aa11e8e6221c93afda84d10e0effba9125 100644 (file)
 #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;
        }
 
index 83df5e7270e4569292ea4749e10c5ed347f2ecfe..4740fe878dbb28266db8586f4509649cc6287ed4 100644 (file)
 #include <string.h>
 #include <unistd.h>
 
+//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)
 {