[xiph-commits] r14952 - in trunk/ffmpeg2theora: . src

j at svn.xiph.org j at svn.xiph.org
Sun May 25 03:11:20 PDT 2008


Author: j
Date: 2008-05-25 03:11:19 -0700 (Sun, 25 May 2008)
New Revision: 14952

Modified:
   trunk/ffmpeg2theora/
   trunk/ffmpeg2theora/src/ffmpeg2theora.c
Log:
* free some buffers, thanks marty leisner for the patch
* remove output size restriction, thats no longer needed



Property changes on: trunk/ffmpeg2theora
___________________________________________________________________
Name: bzr:revision-info
   - timestamp: 2008-05-23 19:54:32.194999933 +0200
committer: j
properties: 
	branch-nick: ffmpeg2theora

   + timestamp: 2008-05-25 12:09:39.463000059 +0200
committer: j
properties: 
	branch-nick: ffmpeg2theora

Name: bzr:file-ids
   - src	src-20080523174144-dkwx1i25ujognb2c-1
src/ffmpeg2theora.c	6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:ffmpeg2theora.c
src/ffmpeg2theora.h	ffmpeg2theora.h-20080523174200-q6z54q34pgkgpz50-1
src/subtitles.c	subtitles.c-20080523092315-berdpbqhudpfrkh7-1
src/subtitles.h	subtitles.h-20080523092316-79y08zf0g4v687h5-1
src/theorautils.c	6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:theorautils.c
src/theorautils.h	6863 at 0101bb08-14d6-0310-b084-bc0e0c8e3800:trunk%2Fffmpeg2theora:theorautils.h

   + 
Name: bzr:revision-id:v3-single1-dHJ1bmsvZmZtcGVnMnRoZW9yYQ..
   - 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr

   + 191 j-20080517230830-he5x8v2m8yrfiw35
192 j-20080518224037-pkmoctzf4qce7tog
193 j-20080518224409-6hbfp3k2ssn6egqa
194 j-20080520111939-dhi52qwbqe7a47cu
195 j-20080523092252-gj9k9db0s67vl7dw
196 j-20080523092420-l0850yrq1qkgz9t0
197 j-20080523093057-l5g0ezzy5geu0pey
198 j-20080523094343-kcno1dm2e1lr38q4
199 j-20080523163006-kjl6ewea5sxawmq2
200 j-20080523165904-l2vm52qae0hlqkhp
201 j-20080523175432-2ed953iktnl8c7cr
202 j-20080525100939-7oja8pk08v9fquiw


Modified: trunk/ffmpeg2theora/src/ffmpeg2theora.c
===================================================================
--- trunk/ffmpeg2theora/src/ffmpeg2theora.c	2008-05-25 09:34:30 UTC (rev 14951)
+++ trunk/ffmpeg2theora/src/ffmpeg2theora.c	2008-05-25 10:11:19 UTC (rev 14952)
@@ -576,11 +576,15 @@
         }
     }
 
-    if (this->video_index >= 0 || this->audio_index >=0){
+    if (this->video_index >= 0 || this->audio_index >= 0){
         AVFrame *frame=NULL;
         AVFrame *output=NULL;
+        AVFrame *output_p=NULL;
+        AVFrame *output_tmp_p=NULL;
         AVFrame *output_tmp=NULL;
+        AVFrame *output_resized_p=NULL;
         AVFrame *output_resized=NULL;
+        AVFrame *output_buffered_p=NULL;
         AVFrame *output_buffered=NULL;
 
         AVPacket pkt;
@@ -591,8 +595,9 @@
         int e_o_s = 0;
         int ret;
         uint8_t *ptr;
-        int16_t *audio_buf= av_malloc(4*AVCODEC_MAX_AUDIO_FRAME_SIZE);
-        int16_t *resampled= av_malloc(4*AVCODEC_MAX_AUDIO_FRAME_SIZE);
+        int16_t *audio_buf=av_malloc(4*AVCODEC_MAX_AUDIO_FRAME_SIZE);
+        int16_t *resampled=av_malloc(4*AVCODEC_MAX_AUDIO_FRAME_SIZE);
+        int16_t *audio_p;
         int no_frames;
 
         double framerate_add;
@@ -611,13 +616,13 @@
         if(!info.audio_only){
             frame = frame_alloc(vstream->codec->pix_fmt,
                             vstream->codec->width,vstream->codec->height);
-            output_tmp =frame_alloc(this->pix_fmt,
+            output_tmp_p = output_tmp = frame_alloc(this->pix_fmt,
                             vstream->codec->width,vstream->codec->height);
-            output =frame_alloc(this->pix_fmt,
+            output_p = output = frame_alloc(this->pix_fmt,
                             vstream->codec->width,vstream->codec->height);
-            output_resized =frame_alloc(this->pix_fmt,
+            output_resized_p = output_resized = frame_alloc(this->pix_fmt,
                             this->frame_width, this->frame_height);
-            output_buffered =frame_alloc(this->pix_fmt,
+            output_buffered_p = output_buffered = frame_alloc(this->pix_fmt,
                             this->frame_width, this->frame_height);
 
             /* video settings here */
@@ -899,12 +904,13 @@
                             samples_out = samples;
                             if(this->audio_resample_ctx){
                                 samples_out = audio_resample(this->audio_resample_ctx, resampled, audio_buf, samples);
+                                audio_p = resampled;
                             }
                             else
-                                resampled=audio_buf;
+                                audio_p = audio_buf;
                         }
                     }
-                    oggmux_add_audio(&info, resampled,
+                    oggmux_add_audio(&info, audio_p,
                         samples_out *(this->channels),samples_out,e_o_s);
                     this->sample_count += samples_out;
                     if(e_o_s && len <= 0){
@@ -951,9 +957,23 @@
             }
         }
 
+        if (this->video_index >= 0) {
+            avcodec_close(venc);
+        }
+        if (this->audio_index >= 0) {
+            avcodec_close(aenc);
+        }
         oggmux_close (&info);
         if(ppContext)
             pp_free_context(ppContext);
+        if (!info.audio_only) {
+            av_free(frame);
+            av_free(output_p);
+            av_free(output_tmp_p);
+            av_free(output_resized_p);
+        }
+        av_free(audio_buf);
+        av_free(resampled);
     }
     else{
         fprintf (stderr, "No video or audio stream found.\n");
@@ -961,6 +981,8 @@
 }
 
 void ff2theora_close (ff2theora this){
+    sws_freeContext(this->sws_colorspace_ctx);
+    sws_freeContext(this->sws_scale_ctx);
     /* clear out state */
     free_subtitles(this);
     av_free (this);
@@ -1661,17 +1683,6 @@
         exit(1);
     }
 
-    /* could go, but so far no player supports offset_x/y */
-    if(convert->picture_width % 8 ||  convert->picture_height % 8){
-        fprintf(stderr,"Output size must be a multiple of 8 for now.\n");
-        exit(1);
-    }
-    /*
-    if(convert->picture_width % 4 ||  convert->picture_height % 4){
-        fprintf(stderr,"Output width and height size must be a multiple of 2.\n");
-        exit(1);
-    }
-    */
     if(convert->end_time>0 && convert->end_time <= convert->start_time){
         fprintf(stderr,"End time has to be bigger than start time.\n");
         exit(1);



More information about the commits mailing list