diff options
author | jbrjake <[email protected]> | 2007-08-01 17:13:36 +0000 |
---|---|---|
committer | jbrjake <[email protected]> | 2007-08-01 17:13:36 +0000 |
commit | 8cb0b130a99d34794a9223553478ca23830f9f2c (patch) | |
tree | e7366073daaff12f0fb74c38493bb04b41034371 /libhb/render.c | |
parent | 6bf190d7481c23c148c5fa737a6174f62a4fcf3c (diff) |
Implements libswscale in HandBrake, giving it Lanczos scaling! This major enhancement comes to us courtesy of superdump, who deserves much praise and glory. To make this work, ffmpeg's been updated to a recent revision.
Darwin contrib binary pack ++ to 0016. Includes fresh ffmpeg and libswscale as well as the recently-patched libmp4v2.
I've also added the configure option --disable-sdl to libmpeg2 in the contrib/Jamfile, because without it jam always fails for me and I'm sick of adding it in every time. Hopefully this doesn't break anything for anyone, but if it does it's just a one-word change.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@778 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/render.c')
-rw-r--r-- | libhb/render.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/libhb/render.c b/libhb/render.c index 20b581383..a49bdfada 100644 --- a/libhb/render.c +++ b/libhb/render.c @@ -7,13 +7,15 @@ #include "hb.h" #include "ffmpeg/avcodec.h" +#include "ffmpeg/swscale.h" struct hb_work_private_s { hb_job_t * job; - ImgReSampleContext * context; + struct SwsContext * context; AVPicture pic_tmp_in; + AVPicture pic_tmp_crop; AVPicture pic_tmp_out; hb_buffer_t * buf_scale; hb_fifo_t * subtitle_queue; @@ -102,9 +104,6 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in, hb_job_t * job = pv->job; hb_title_t * title = job->title; hb_buffer_t * in = *buf_in, * buf_tmp_in = *buf_in; - - int title_size = 3 * title->width * title->height / 2; - int job_size = 3 * job->width * job->height / 2; if(!in->data) { @@ -124,7 +123,7 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in, } /* Setup render buffer */ - hb_buffer_t * buf_render = hb_buffer_init( job_size ); + hb_buffer_t * buf_render = hb_buffer_init( 3 * job->width * job->height / 2 ); /* Apply filters */ if( job->filters ) @@ -194,8 +193,16 @@ int renderWork( hb_work_object_t * w, hb_buffer_t ** buf_in, avpicture_fill( &pv->pic_tmp_out, buf_render->data, PIX_FMT_YUV420P, job->width, job->height ); - - img_resample( pv->context, &pv->pic_tmp_out, &pv->pic_tmp_in ); + + // Crop; this alters the pointer to the data to point to the correct place for cropped frame + av_picture_crop( &pv->pic_tmp_crop, &pv->pic_tmp_in, PIX_FMT_YUV420P, + job->crop[0], job->crop[2] ); + + // Scale pic_crop into pic_render according to the context set up in renderInit + sws_scale(pv->context, + pv->pic_tmp_crop.data, pv->pic_tmp_crop.linesize, + 0, title->height - (job->crop[0] + job->crop[1]), + pv->pic_tmp_out.data, pv->pic_tmp_out.linesize); hb_buffer_copy_settings( buf_render, buf_tmp_in ); @@ -271,17 +278,17 @@ int renderInit( hb_work_object_t * w, hb_job_t * job ) w->private_data = pv; /* Get title and title size */ - hb_title_t * title = job->title; - int title_size = 3 * title->width * title->height / 2; - + hb_title_t * title = job->title; + /* If crop or scale is specified, setup rescale context */ if( job->crop[0] || job->crop[1] || job->crop[2] || job->crop[3] || job->width != title->width || job->height != title->height ) { - pv->context = img_resample_full_init( - job->width, job->height, title->width, title->height, - job->crop[0], job->crop[1], job->crop[2], job->crop[3], - 0, 0, 0, 0 ); + pv->context = sws_getContext(title->width - (job->crop[2] + job->crop[3]), + title->height - (job->crop[0] + job->crop[1]), + PIX_FMT_YUV420P, + job->width, job->height, PIX_FMT_YUV420P, + SWS_LANCZOS, NULL, NULL, NULL); } /* Setup FIFO queue for subtitle cache */ |