]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Add a flag to avoid calling vorbis_analysis_wrote twice with an empty buffer.
authorbenoit <benoit@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 15 Oct 2008 07:29:37 +0000 (07:29 +0000)
committerbenoit <benoit@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Wed, 15 Oct 2008 07:29:37 +0000 (07:29 +0000)
Patch by Nicolas George: name surname normalesup org

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@15620 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/libvorbis.c

index ce796a05f70746cf46a5756719cfdd614ad2e1bb..6963e708e2055bc1fc56d326b722c7b9076801bb 100644 (file)
@@ -42,6 +42,7 @@ typedef struct OggVorbisContext {
     vorbis_block vb ;
     uint8_t buffer[BUFFER_SIZE];
     int buffer_index;
+    int eof;
 
     /* decoder */
     vorbis_comment vc ;
@@ -136,10 +137,13 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
                            int buf_size, void *data)
 {
     OggVorbisContext *context = avccontext->priv_data ;
-    float **buffer ;
     ogg_packet op ;
     signed short *audio = data ;
-    int l, samples = data ? OGGVORBIS_FRAME_SIZE : 0;
+    int l;
+
+    if(data) {
+        int samples = OGGVORBIS_FRAME_SIZE;
+        float **buffer ;
 
     buffer = vorbis_analysis_buffer(&context->vd, samples) ;
 
@@ -154,6 +158,11 @@ static int oggvorbis_encode_frame(AVCodecContext *avccontext,
     }
 
     vorbis_analysis_wrote(&context->vd, samples) ;
+    } else {
+        if(!context->eof)
+            vorbis_analysis_wrote(&context->vd, 0) ;
+        context->eof = 1;
+    }
 
     while(vorbis_analysis_blockout(&context->vd, &context->vb) == 1) {
         vorbis_analysis(&context->vb, NULL);