X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=libhb%2Fenctheora.c;h=29dfed1b57b0706be5653160f39ed8a53f900d96;hb=69bcedab6772552b36bc8f1591db6ea0c8de08c3;hp=3773b708a6a8af7a100871af000d34aec8a7120e;hpb=4e3f08663b249ff5604e4de3878a226b21f342dc;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/libhb/enctheora.c b/libhb/enctheora.c index 3773b708..29dfed1b 100644 --- a/libhb/enctheora.c +++ b/libhb/enctheora.c @@ -1,5 +1,5 @@ /* This file is part of the HandBrake source code. - Homepage: . + Homepage: . 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 { @@ -63,7 +63,7 @@ int enctheoraInit( hb_work_object_t * w, hb_job_t * job ) ti.keyframe_mindistance = 8; ti.noise_sensitivity = 1; ti.sharpness = 0; - if (job->vquality < 0.0 || job->vquality > 1.0) + if (job->vquality < 0.0) { ti.target_bitrate = job->vbitrate * 1000; ti.keyframe_data_target_bitrate = job->vbitrate * 1000 * 1.5; @@ -72,7 +72,15 @@ int enctheoraInit( hb_work_object_t * w, hb_job_t * job ) else { ti.target_bitrate = 0; - ti.quality = 63 * job->vquality; + + if( job->vquality > 0 && job->vquality < 1 ) + { + ti.quality = 63 * job->vquality; + } + else + { + ti.quality = job->vquality; + } } theora_encode_init( &pv->theora, &ti ); @@ -122,39 +130,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));