OSDN Git Service

BuildSystem:
[handbrake-jp/handbrake-jp-git.git] / libhb / encxvid.c
index 7bdee7b..843d12a 100644 (file)
@@ -1,7 +1,7 @@
 /* $Id: encxvid.c,v 1.10 2005/03/09 23:28:39 titer Exp $
 
    This file is part of the HandBrake source code.
-   Homepage: <http://handbrake.m0k.org/>.
+   Homepage: <http://handbrake.fr/>.
    It may be used under the terms of the GNU General Public License. */
 
 #include "hb.h"
@@ -63,7 +63,7 @@ int encxvidInit( hb_work_object_t * w, hb_job_t * job )
         case 0:
             memset( &single, 0, sizeof( single ) );
             single.version   = XVID_VERSION;
-            if( job->vquality < 0.0 || job->vquality > 1.0 )
+            if( job->vquality < 0.0 )
             {
                 /* Rate control */
                 single.bitrate = 1000 * job->vbitrate;
@@ -71,8 +71,16 @@ int encxvidInit( hb_work_object_t * w, hb_job_t * job )
             }
             else
             {
-                /* Constant quantizer */
-                pv->quant = 31 - job->vquality * 30;
+                if( job->vquality > 0 && job->vquality < 1 )
+                {
+                    /* Constant quantizer */
+                    pv->quant = 31 - job->vquality * 30;
+                }
+                else
+                {
+                    pv->quant = job->vquality;
+                }
+                
                 hb_log( "encxvid: encoding at constant quantizer %d",
                         pv->quant );
             }
@@ -128,10 +136,10 @@ void encxvidClose( hb_work_object_t * w )
 
     if( pv->xvid )
     {
-        hb_log( "encxvid: closing libxvidcore" );
+        hb_deep_log( 2, "encxvid: closing libxvidcore" );
         xvid_encore( pv->xvid, XVID_ENC_DESTROY, NULL, NULL);
     }
-    
+
     free( pv );
     w->private_data = NULL;
 }
@@ -149,18 +157,18 @@ int encxvidWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     xvid_enc_frame_t frame;
     hb_buffer_t * in = *buf_in, * buf;
 
-    /* If this is the last empty frame, we're done */
-    if(!in->data)
+    if ( in->size <= 0 )
     {
-       *buf_out        = NULL;
+        /* EOF on input - send it downstream & say we're done */
+        *buf_out = in;
+        *buf_in = NULL;
        return HB_WORK_DONE;
     }
 
     /* Should be way too large */
-    buf = hb_buffer_init( 3 * job->width * job->height / 2 );
+    buf = hb_video_buffer_init( job->width, job->height );
     buf->start = in->start;
     buf->stop  = in->stop;
-    //buf->chap  = in->chap;
 
     memset( &frame, 0, sizeof( frame ) );
 
@@ -173,11 +181,11 @@ int encxvidWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     frame.vol_flags = 0;
     frame.vop_flags = XVID_VOP_HALFPEL | XVID_VOP_INTER4V |
                       XVID_VOP_TRELLISQUANT | XVID_VOP_HQACPRED;
-    if( job->pixel_ratio )
+    if( job->anamorphic.mode )
     {
         frame.par = XVID_PAR_EXT;
-        frame.par_width = job->pixel_aspect_width;
-        frame.par_height = job->pixel_aspect_height;
+        frame.par_width  = job->anamorphic.par_width;
+        frame.par_height = job->anamorphic.par_height;
     }
 
     if( job->grayscale )
@@ -220,7 +228,7 @@ int encxvidWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
             }
         }
 
-        hb_log( "encxvid: VOL size is %d bytes", vop_start - vol_start );
+        hb_deep_log( 2, "encxvid: VOL size is %d bytes", vop_start - vol_start );
         job->config.mpeg4.length = vop_start - vol_start;
         memcpy( job->config.mpeg4.bytes, &buf->data[vol_start],
                 job->config.mpeg4.length );