summaryrefslogtreecommitdiffstats
path: root/libhb
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2009-05-04 05:26:13 +0000
committerjstebbins <[email protected]>2009-05-04 05:26:13 +0000
commit11317ace31dcd579f353d26849b24d2250f45abf (patch)
tree62fc29c50cd35cd01d64f4f805ffc6507395059d /libhb
parentb2661d006f5b972e8599903b4909a8633ea5d5b3 (diff)
LinGui: preview changes
- update hb_get_preview to allow upscaling and remove borders - allow upscaling in the gui - add user option to show visible cropping borders - gui generates borders when needed instead of hb_get_preview, which allows for flexible alternatives like alternate colors git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2376 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb')
-rw-r--r--libhb/hb.c39
1 files changed, 9 insertions, 30 deletions
diff --git a/libhb/hb.c b/libhb/hb.c
index 943e2389f..2ffa16976 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -384,7 +384,7 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
char filename[1024];
FILE * file;
uint8_t * buf1, * buf2, * buf3, * buf4, * pen;
- uint32_t * p32, swsflags;
+ uint32_t swsflags;
AVPicture pic_in, pic_preview, pic_deint, pic_crop, pic_scale;
struct SwsContext * context;
int i;
@@ -395,14 +395,14 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
buf1 = av_malloc( avpicture_get_size( PIX_FMT_YUV420P, title->width, title->height ) );
buf2 = av_malloc( avpicture_get_size( PIX_FMT_YUV420P, title->width, title->height ) );
- buf3 = av_malloc( avpicture_get_size( PIX_FMT_YUV420P, job->width, job->height ) );
+ buf3 = av_malloc( avpicture_get_size( PIX_FMT_YUV420P, rgb_width, job->height ) );
buf4 = av_malloc( avpicture_get_size( PIX_FMT_RGBA32, rgb_width, job->height ) );
avpicture_fill( &pic_in, buf1, PIX_FMT_YUV420P,
title->width, title->height );
avpicture_fill( &pic_deint, buf2, PIX_FMT_YUV420P,
title->width, title->height );
avpicture_fill( &pic_scale, buf3, PIX_FMT_YUV420P,
- job->width, job->height );
+ rgb_width, job->height );
avpicture_fill( &pic_preview, buf4, PIX_FMT_RGBA32,
rgb_width, job->height );
@@ -439,7 +439,7 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
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,
+ rgb_width, job->height, PIX_FMT_YUV420P,
swsflags, NULL, NULL, NULL);
// Scale
@@ -465,33 +465,12 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
// Free context
sws_freeContext( context );
- if( job->height < title->height || job->width < title->width )
+ preview_size = pic_preview.linesize[0];
+ pen = buffer;
+ for( i = 0; i < job->height; i++ )
{
- /* Gray background */
- p32 = (uint32_t *) buffer;
- for( i = 0; i < ( title->width + 2 ) * ( title->height + 2 ); i++ )
- {
- p32[i] = 0xFF808080;
- }
-
- /* Draw the picture, centered, and draw the cropping zone */
- preview_size = pic_preview.linesize[0];
- pen = buffer + ( title->height - job->height ) *
- ( title->width + 2 ) * 2 + ( title->width - job->width ) * 2;
- memset( pen, 0xFF, 4 * ( job->width + 2 ) );
- pen += 4 * ( title->width + 2 );
- for( i = 0; i < job->height; i++ )
- {
- uint8_t * nextLine;
- nextLine = pen + 4 * ( title->width + 2 );
- memset( pen, 0xFF, 4 );
- pen += 4;
- memcpy( pen, buf4 + preview_size * i, 4 * job->width );
- pen += 4 * job->width;
- memset( pen, 0xFF, 4 );
- pen = nextLine;
- }
- memset( pen, 0xFF, 4 * ( job->width + 2 ) );
+ memcpy( pen, buf4 + preview_size * i, 4 * job->width );
+ pen += 4 * job->width;
}
// Clean up