OSDN Git Service

x264 bump to r1101
[handbrake-jp/handbrake-jp-git.git] / libhb / enctheora.c
index 3773b70..e340bad 100644 (file)
@@ -1,5 +1,5 @@
 /* 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"
@@ -42,10 +42,10 @@ int enctheoraInit( hb_work_object_t * w, hb_job_t * job )
     ti.offset_x = ti.offset_y = 0;
     ti.fps_numerator = job->vrate;
     ti.fps_denominator = job->vrate_base;
-    if (job->pixel_ratio)
+    if( job->anamorphic.mode )
     {
-        ti.aspect_numerator = job->pixel_aspect_width;
-        ti.aspect_denominator = job->pixel_aspect_height;
+        ti.aspect_numerator = job->anamorphic.par_width;
+        ti.aspect_denominator = job->anamorphic.par_height;
     }
     else
     {
@@ -122,39 +122,37 @@ int enctheoraWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     hb_buffer_t * in = *buf_in, * buf;
     yuv_buffer yuv;
     ogg_packet op;
-    static int last_p = 0;
 
-    memset(&op, 0, sizeof(op));
-    memset(&yuv, 0, sizeof(yuv));
-
-    /* If this is the last empty frame, we're done */
-    if(!in->data)
+    if ( in->size <= 0 )
     {
-        if (!last_p)
-        {
-            last_p++;
-            goto finish;
-        }
-       *buf_out        = NULL;
+        // EOF on input - send it downstream & say we're done.
+        // XXX may need to flush packets via a call to
+        //  theora_encode_packetout(&pv->theora, 1, &op);
+        // but we don't have a timestamp to put on those packets so we
+        // drop them for now.
+        *buf_out = in;
+        *buf_in = NULL;
        return HB_WORK_DONE;
     }
 
+    memset(&op, 0, sizeof(op));
+    memset(&yuv, 0, sizeof(yuv));
+
     yuv.y_width = job->width;
     yuv.y_height = job->height;
     yuv.y_stride = job->width;
 
-    yuv.uv_width = job->width / 2;
-    yuv.uv_height = job->height / 2;
-    yuv.uv_stride = job->width / 2;
+    yuv.uv_width = (job->width + 1) / 2;
+    yuv.uv_height = (job->height + 1) / 2;
+    yuv.uv_stride = yuv.uv_width;
 
     yuv.y = in->data;
     yuv.u = in->data + job->width * job->height;
-    yuv.v = in->data + job->width * job->height * 5/4;
+    yuv.v = in->data + ( job->width * job->height ) + ( yuv.uv_width * yuv.uv_height );
 
     theora_encode_YUVin(&pv->theora, &yuv);
 
-finish:
-    theora_encode_packetout(&pv->theora, last_p, &op);
+    theora_encode_packetout(&pv->theora, 0, &op);
 
     buf = hb_buffer_init( op.bytes + sizeof(op) );
     memcpy(buf->data, &op, sizeof(op));