OSDN Git Service

BuildSystem:
[handbrake-jp/handbrake-jp-git.git] / libhb / render.c
index 1989199..55295a4 100644 (file)
@@ -5,9 +5,7 @@
    It may be used under the terms of the GNU General Public License. */
 
 #include "hb.h"
-
-#include "libavcodec/avcodec.h"
-#include "libswscale/swscale.h"
+#include "hbffmpeg.h"
 
 struct hb_work_private_s
 {
@@ -55,13 +53,13 @@ hb_work_object_t hb_render =
  */
 static uint8_t *getU(uint8_t *data, int width, int height, int x, int y)
 {
-    return(&data[(((y/2) * (width/2)) + (x/2)) + (width*height)]);
+    return(&data[(y>>1) * ((width+1)>>1) + (x>>1) + width*height]);
 }
 
 static uint8_t *getV(uint8_t *data, int width, int height, int x, int y)
 {
-    return(&data[(((y/2) * (width/2)) + (x/2)) + (width*height) +
-                 (width*height)/4]);
+    int w2 = (width+1) >> 1, h2 = (height+1) >> 1;
+    return(&data[(y>>1) * w2 + (x>>1) + width*height + w2*h2]);
 }
 
 static void ApplySub( hb_job_t * job, hb_buffer_t * buf,
@@ -248,7 +246,7 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
     }
 
     /* Setup render buffer */
-    hb_buffer_t * buf_render = hb_buffer_init( 3 * job->width * job->height / 2 );
+    hb_buffer_t * buf_render = hb_video_buffer_init( job->width, job->height );
 
     /* Apply filters */
     if( job->filters )
@@ -311,7 +309,6 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
                     /* Pop the frame's subtitle and dispose of it. */
                     hb_buffer_t * subtitles = hb_fifo_get( pv->subtitle_queue );
                     hb_buffer_close( &subtitles );
-
                     buf_tmp_in = NULL;
                     break;
                 }
@@ -413,7 +410,7 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in,
 
     if( job->vfr )
     {
-        if( hb_fifo_size( pv->delay_queue ) >= 3 )
+        if( hb_fifo_size( pv->delay_queue ) >= 4 )
         {
             *buf_out = hb_fifo_get( pv->delay_queue );
         }
@@ -534,10 +531,7 @@ int renderInit( hb_work_object_t * w, hb_job_t * job )
     w->private_data = pv;
     uint32_t    swsflags;
 
-    swsflags = SWS_LANCZOS;
-#ifndef __x86_64__
-    swsflags |= SWS_ACCURATE_RND;
-#endif  /* __x86_64__ */
+    swsflags = SWS_LANCZOS | SWS_ACCURATE_RND;
 
     /* Get title and title size */
     hb_title_t * title = job->title;