[xiph-commits] r9595 - experimental/j/ffmpeg2theora-exp

j at svn.xiph.org j at svn.xiph.org
Wed Jul 20 11:59:56 PDT 2005


Author: j
Date: 2005-07-20 11:59:52 -0700 (Wed, 20 Jul 2005)
New Revision: 9595

Modified:
   experimental/j/ffmpeg2theora-exp/configure.ac
   experimental/j/ffmpeg2theora-exp/ffmpeg2theora.c
   experimental/j/ffmpeg2theora-exp/theorautils.c
   experimental/j/ffmpeg2theora-exp/theorautils.h
Log:
port ffmpeg2theora to theora-exp



Modified: experimental/j/ffmpeg2theora-exp/configure.ac
===================================================================
--- experimental/j/ffmpeg2theora-exp/configure.ac	2005-07-20 18:56:34 UTC (rev 9594)
+++ experimental/j/ffmpeg2theora-exp/configure.ac	2005-07-20 18:59:52 UTC (rev 9595)
@@ -1,6 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ(2.59)
-AC_INIT(ffmpeg2theora,0.13)
+AC_INIT(ffmpeg2theora-exp,0.13-svn)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2])
 
@@ -94,7 +94,7 @@
 	FFMPEG_LIBS="$FFMPEG_LIBS -ldts"
 fi
 
-PKG_CHECK_MODULES(XIPH,ogg >= 1.1 vorbis vorbisenc theora )
+PKG_CHECK_MODULES(XIPH,ogg >= 1.1 vorbis vorbisenc theoraenc)
 
 AC_SUBST(XIPH_CFLAGS)
 AC_SUBST(XIPH_LIBS)

Modified: experimental/j/ffmpeg2theora-exp/ffmpeg2theora.c
===================================================================
--- experimental/j/ffmpeg2theora-exp/ffmpeg2theora.c	2005-07-20 18:56:34 UTC (rev 9594)
+++ experimental/j/ffmpeg2theora-exp/ffmpeg2theora.c	2005-07-20 18:59:52 UTC (rev 9595)
@@ -27,10 +27,6 @@
 #include <string.h>
 #include <getopt.h>
 
-#include "theora/theora.h"
-#include "vorbis/codec.h"
-#include "vorbis/vorbisenc.h"
-
 #ifdef WIN32
 #include "fcntl.h"
 #endif
@@ -364,13 +360,13 @@
             /* config file? commandline options? v2v presets? */
             
             theora_info_init (&info.ti);
-            
-            info.ti.width = this->frame_width;
-            info.ti.height = this->frame_height;
-            info.ti.frame_width = this->picture_width;
-            info.ti.frame_height = this->picture_height;
-            info.ti.offset_x = this->frame_x_offset;
-            info.ti.offset_y = this->frame_y_offset;
+
+            info.ti.frame_width = this->frame_width;
+            info.ti.frame_height = this->frame_height;
+            info.ti.pic_width = this->picture_width;
+            info.ti.pic_height = this->picture_height;
+            info.ti.pic_x = this->frame_x_offset;
+            info.ti.pic_y = this->frame_y_offset;
             if(this->force_input_fps) {
                 info.ti.fps_numerator = 1000000 * (this->fps);    /* fps= numerator/denominator */
                 info.ti.fps_denominator = 1000000;
@@ -394,7 +390,7 @@
 
             info.ti.target_bitrate = this->video_bitrate; 
             info.ti.quality = this->video_quality;
-            info.ti.dropframes_p = 1;
+/*            info.ti.dropframes_p = 1;
             info.ti.quick_p = 1;
             info.ti.keyframe_auto_p = 1;
             info.ti.keyframe_frequency = this->keyint;
@@ -405,7 +401,9 @@
             info.ti.noise_sensitivity = 1;
             // range 0-2, 0 sharp, 2 less sharp,less bandwidth
             info.ti.sharpness = this->sharpness;
-            
+*/
+            info.ti.pixel_fmt=OC_PF_420;
+            info.ti.keyframe_granule_shift=6;
         }
         /* audio settings here */
         info.channels = this->channels;

Modified: experimental/j/ffmpeg2theora-exp/theorautils.c
===================================================================
--- experimental/j/ffmpeg2theora-exp/theorautils.c	2005-07-20 18:56:34 UTC (rev 9594)
+++ experimental/j/ffmpeg2theora-exp/theorautils.c	2005-07-20 18:59:52 UTC (rev 9595)
@@ -26,10 +26,6 @@
 #include <unistd.h>
 #include <string.h>
 
-#include "theora/theora.h"
-#include "vorbis/codec.h"
-#include "vorbis/vorbisenc.h"
-
 #include "theorautils.h"
 
 
@@ -49,8 +45,8 @@
     info->debug = 0;
 }
 
-
 void theoraframes_init (theoraframes_info *info){
+    int ret = 0;
     info->audio_bytesout = 0;
     info->video_bytesout = 0;
 
@@ -60,14 +56,13 @@
     
     if(!info->audio_only){
         ogg_stream_init (&info->to, rand ());    /* oops, add one ot the above */
-        theora_encode_init (&info->td, &info->ti);
+        info->td=theora_encode_alloc(&info->ti);
         theora_info_clear (&info->ti);
     }
     /* init theora done */
 
     /* initialize Vorbis too, if we have audio. */
     if(!info->video_only){
-        int ret;
         vorbis_info_init (&info->vi);
         /* Encoding using a VBR quality mode.  */
         if(info->vorbis_quality>-99) 
@@ -95,22 +90,31 @@
 
     /* first packet will get its own page automatically */
     if(!info->audio_only){
-        theora_encode_header (&info->td, &info->op);
-        ogg_stream_packetin (&info->to, &info->op);
-        if (ogg_stream_pageout (&info->to, &info->og) != 1){
-            fprintf (stderr, "Internal Ogg library error.\n");
-            exit (1);
+      theora_comment_init(&info->tc);
+      theora_comment_add_tag (&info->tc, "ENCODER",PACKAGE_STRING);
+
+      if(theora_encode_flushheader(info->td,&info->tc,&info->op)<=0){
+        fprintf(stderr,"Internal Theora library error.\n");
+        exit(1);
+      }
+      ogg_stream_packetin(&info->to,&info->op);
+      if(ogg_stream_pageout(&info->to,&info->og)!=1){
+        fprintf(stderr,"Internal Ogg library error.\n");
+        exit(1);
+      }
+      fwrite(info->og.header, 1, info->og.header_len, info->outfile);
+      fwrite(info->og.body, 1, info->og.body_len, info->outfile);
+
+      /* create the remaining theora headers */
+      for(;;){
+        ret = theora_encode_flushheader(info->td,&info->tc,&info->op);
+        if(ret<0){
+          fprintf(stderr,"Internal Theora library error.\n");
+          exit(1);
         }
-        fwrite (info->og.header, 1, info->og.header_len, info->outfile);
-        fwrite (info->og.body, 1, info->og.body_len, info->outfile);
-
-        /* create the remaining theora headers */
-        /* theora_comment_init (&info->tc); is called in main() prior to parsing options */
-        theora_comment_add_tag (&info->tc, "ENCODER",PACKAGE_STRING);
-        theora_encode_comment (&info->tc, &info->op);
-        ogg_stream_packetin (&info->to, &info->op);
-        theora_encode_tables (&info->td, &info->op);
-        ogg_stream_packetin (&info->to, &info->op);
+        else if(!ret)break;
+        ogg_stream_packetin(&info->to,&info->op);
+      }
     }
     if(!info->video_only){
         ogg_packet header;
@@ -174,26 +178,32 @@
  */
 int theoraframes_add_video (ff2theora this, theoraframes_info *info, AVFrame * avframe, int e_o_s){
     /* pysical pages */
-    yuv_buffer yuv;
+    static theora_ycbcr_buffer ycbcr;
     /* Theora is a one-frame-in,one-frame-out system; submit a frame
      * for compression and pull out the packet */
-    {
-        yuv.y_width = this->frame_width;
-        yuv.y_height = this->frame_height;
-        yuv.y_stride = avframe->linesize[0];
 
-        yuv.uv_width = this->frame_width / 2;
-        yuv.uv_height = this->frame_height / 2;
-        yuv.uv_stride = avframe->linesize[1];
+    ycbcr[0].width = this->frame_width;
+    ycbcr[0].height = this->frame_height;
+    ycbcr[0].ystride = avframe->linesize[0];
 
-        yuv.y = avframe->data[0];
-        yuv.u = avframe->data[1];
-        yuv.v = avframe->data[2];
+    ycbcr[1].width = this->frame_width / 2;
+    ycbcr[1].height = this->frame_height / 2;
+    ycbcr[1].ystride = avframe->linesize[1];
 
+    ycbcr[2].width = this->frame_width / 2;
+    ycbcr[2].height = this->frame_height / 2;
+    ycbcr[2].ystride = avframe->linesize[1];
+
+
+    ycbcr[0].data = avframe->data[0];
+    ycbcr[1].data = avframe->data[1];
+    ycbcr[2].data = avframe->data[2];
+
+    theora_encode_ycbcr_in(info->td,ycbcr);
+    while(theora_encode_packetout(info->td, e_o_s, &info->op)) {
+        ogg_stream_packetin (&info->to, &info->op);
     }
-    theora_encode_YUVin (&info->td, &yuv);
-    theora_encode_packetout (&info->td, e_o_s, &info->op);
-    ogg_stream_packetin (&info->to, &info->op);
+
     info->videoflag=1;
     return 0;
 }
@@ -276,16 +286,14 @@
     while(flushloop){
         int video = -1;
         flushloop=0;
-        //some debuging 
-        //fprintf(stderr,"\ndiff: %f\n",info->audiotime-info->videotime);
         while(!info->audio_only && (e_o_s || 
             ((info->videotime <= info->audiotime || info->video_only) && info->videoflag == 1))){
                 
             info->videoflag = 0;
             while(ogg_stream_pageout (&info->to, &info->videopage) > 0){
                 info->videotime =
-                    theora_granule_time (&info->td,ogg_page_granulepos(&info->videopage));
-                
+                    theora_granule_time (info->td,ogg_page_granulepos(&info->videopage));
+
                 /* flush a video page */
                 info->video_bytesout +=
                     fwrite (info->videopage.header, 1,info->videopage.header_len, info->outfile);
@@ -336,7 +344,7 @@
     vorbis_info_clear (&info->vi);
 
     ogg_stream_clear (&info->to);
-    theora_clear (&info->td);
+    theora_encode_free (info->td);
 
     if (info->outfile && info->outfile != stdout)
         fclose (info->outfile);

Modified: experimental/j/ffmpeg2theora-exp/theorautils.h
===================================================================
--- experimental/j/ffmpeg2theora-exp/theorautils.h	2005-07-20 18:56:34 UTC (rev 9594)
+++ experimental/j/ffmpeg2theora-exp/theorautils.h	2005-07-20 18:59:52 UTC (rev 9595)
@@ -18,7 +18,8 @@
  */
 
 #include <stdint.h>
-#include "theora/theora.h"
+#include "theora/codec.h"
+#include "theora/theoraenc.h"
 #include "vorbis/codec.h"
 #include "vorbis/vorbisenc.h"
 
@@ -114,9 +115,8 @@
     theora_info ti;
     theora_comment tc;
     
-    theora_state td;
+    theora_enc_ctx  *td;
 
-
     vorbis_info vi;       /* struct that stores all the static vorbis bitstream settings */
     vorbis_comment vc;    /* struct that stores all the user comments */
 



More information about the commits mailing list