[xiph-commits] r15970 - trunk/ffmpeg2theora/src

j at svn.xiph.org j at svn.xiph.org
Thu Apr 30 08:10:38 PDT 2009


Author: j
Date: 2009-04-30 08:10:38 -0700 (Thu, 30 Apr 2009)
New Revision: 15970

Modified:
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
   trunk/ffmpeg2theora/src/theorautils.c
Log:
dont segfault if theora_encode_packetout returns -1

Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-04-30 14:21:37 UTC (rev 15969)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2009-04-30 15:10:38 UTC (rev 15970)
@@ -1023,12 +1023,13 @@
             }
 
             /* check for end time */
-            if (no_samples > 0) {
+            if (info.audio_only && no_samples > 0) {
                 if (this->sample_count >= no_samples) {
                     break;
                 }
             }
             if (no_frames > 0) {
+                //why does this cause a crash for some input formats?
                 if (this->frame_count == no_frames) {
                     e_o_s = 1;
                 }
@@ -1206,7 +1207,7 @@
                         }
                     }
 
-                    if (this->end_time > 0 && this->sample_count + samples_out > no_samples) {
+                    if (info.audio_only && no_samples > 0 && this->sample_count + samples_out > no_samples) {
                         e_o_s = 1;
                         samples_out = no_samples - this->sample_count;
                         if (samples_out <= 0) {

Modified: trunk/ffmpeg2theora/src/theorautils.c
===================================================================
--- trunk/ffmpeg2theora/src/theorautils.c	2009-04-30 14:21:37 UTC (rev 15969)
+++ trunk/ffmpeg2theora/src/theorautils.c	2009-04-30 15:10:38 UTC (rev 15970)
@@ -497,7 +497,7 @@
 void oggmux_add_video (oggmux_info *info, yuv_buffer *yuv, int e_o_s) {
     ogg_packet op;
     theora_encode_YUVin (&info->td, yuv);
-    while (theora_encode_packetout (&info->td, e_o_s, &op)) {
+    while (theora_encode_packetout (&info->td, e_o_s, &op) > 0) {
         ogg_stream_packetin (&info->to, &op);
         info->v_pkg++;
     }
@@ -515,8 +515,10 @@
 
     int i,j, count = 0;
     float **vorbis_buffer;
-    if (e_o_s) {
-        vorbis_analysis_wrote (&info->vd, 0);
+    if (bytes <= 0 && samples <= 0) {
+        /* end of audio stream */
+        if (e_o_s)
+            vorbis_analysis_wrote (&info->vd, 0);
     }
     else{
         vorbis_buffer = vorbis_analysis_buffer (&info->vd, samples);
@@ -527,6 +529,9 @@
             }
         }
         vorbis_analysis_wrote (&info->vd, samples);
+        /* end of audio stream */
+        if (e_o_s)
+            vorbis_analysis_wrote (&info->vd, 0);
     }
     while (vorbis_analysis_blockout (&info->vd, &info->vb) == 1) {
         /* analysis, assume we want to use bitrate management */



More information about the commits mailing list