summaryrefslogtreecommitdiffstats
path: root/libhb/hb.c
diff options
context:
space:
mode:
authordynaflash <[email protected]>2007-09-13 19:28:19 +0000
committerdynaflash <[email protected]>2007-09-13 19:28:19 +0000
commitbfcd060f9b555f88b01086331fb79d0ec1b8e1e2 (patch)
tree7148452f5dc8f69316e84b4aaec98c48ad1abea4 /libhb/hb.c
parent59da0d1afd24ff1f72664ed30023f07e01e5b07d (diff)
Reverts an errant checking for from rev 960
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@961 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/hb.c')
-rw-r--r--libhb/hb.c119
1 files changed, 52 insertions, 67 deletions
diff --git a/libhb/hb.c b/libhb/hb.c
index b2d672872..a53bd1f4a 100644
--- a/libhb/hb.c
+++ b/libhb/hb.c
@@ -431,90 +431,75 @@ void hb_get_preview( hb_handle_t * h, hb_title_t * title, int picture,
* @param job Handle to hb_job_t.
* @param aspect Desired aspect ratio. Value of -1 uses title aspect.
* @param pixels Maximum desired pixel count.
- * @param par If true, skip the cropping and keep-aspect-ratio stuff.
*/
-void hb_set_size( hb_job_t * job, int aspect, int pixels, int par )
+void hb_set_size( hb_job_t * job, int aspect, int pixels )
{
hb_title_t * title = job->title;
int croppedWidth = title->width - title->crop[2] - title->crop[3];
int croppedHeight = title->height - title->crop[0] - title->crop[1];
-
- int croppedAspect;
- if (par)
+ int croppedAspect = title->aspect * title->height * croppedWidth /
+ croppedHeight / title->width;
+ int addCrop;
+ int i, w, h;
+
+ if( aspect <= 0 )
{
- /* That means we're setting size for video with non-square pixels */
- croppedAspect = croppedWidth * HB_ASPECT_BASE / croppedHeight;
+ /* Keep the best possible aspect ratio */
aspect = croppedAspect;
}
- else
- {
- /* We're free to change cropping and maintain display aspect ratio */
- croppedAspect = title->aspect * title->height * croppedWidth /
- croppedHeight / title->width;
-
- int addCrop;
- if( aspect <= 0 )
+ /* Crop if necessary to obtain the desired ratio */
+ memcpy( job->crop, title->crop, 4 * sizeof( int ) );
+ if( aspect < croppedAspect )
+ {
+ /* Need to crop on the left and right */
+ addCrop = croppedWidth - aspect * croppedHeight * title->width /
+ title->aspect / title->height;
+ if( addCrop & 3 )
{
- /* Keep the best possible aspect ratio */
- aspect = croppedAspect;
+ addCrop = ( addCrop + 1 ) / 2;
+ job->crop[2] += addCrop;
+ job->crop[3] += addCrop;
}
-
- /* Crop if necessary to obtain the desired ratio */
- memcpy( job->crop, title->crop, 4 * sizeof( int ) );
- if( aspect < croppedAspect )
+ else if( addCrop & 2 )
{
- /* Need to crop on the left and right */
- addCrop = croppedWidth - aspect * croppedHeight * title->width /
- title->aspect / title->height;
- if( addCrop & 3 )
- {
- addCrop = ( addCrop + 1 ) / 2;
- job->crop[2] += addCrop;
- job->crop[3] += addCrop;
- }
- else if( addCrop & 2 )
- {
- addCrop /= 2;
- job->crop[2] += addCrop - 1;
- job->crop[3] += addCrop + 1;
- }
- else
- {
- addCrop /= 2;
- job->crop[2] += addCrop;
- job->crop[3] += addCrop;
- }
+ addCrop /= 2;
+ job->crop[2] += addCrop - 1;
+ job->crop[3] += addCrop + 1;
}
- else if( aspect > croppedAspect )
+ else
{
- /* Need to crop on the top and bottom */
- addCrop = croppedHeight - croppedWidth * title->aspect *
- title->height / aspect / title->width;
- if( addCrop & 3 )
- {
- addCrop = ( addCrop + 1 ) / 2;
- job->crop[0] += addCrop;
- job->crop[1] += addCrop;
- }
- else if( addCrop & 2 )
- {
- addCrop /= 2;
- job->crop[0] += addCrop - 1;
- job->crop[1] += addCrop + 1;
- }
- else
- {
- addCrop /= 2;
- job->crop[0] += addCrop;
- job->crop[1] += addCrop;
- }
+ addCrop /= 2;
+ job->crop[2] += addCrop;
+ job->crop[3] += addCrop;
}
-
}
-
- int i, w, h;
+ else if( aspect > croppedAspect )
+ {
+ /* Need to crop on the top and bottom */
+ addCrop = croppedHeight - croppedWidth * title->aspect *
+ title->height / aspect / title->width;
+ if( addCrop & 3 )
+ {
+ addCrop = ( addCrop + 1 ) / 2;
+ job->crop[0] += addCrop;
+ job->crop[1] += addCrop;
+ }
+ else if( addCrop & 2 )
+ {
+ addCrop /= 2;
+ job->crop[0] += addCrop - 1;
+ job->crop[1] += addCrop + 1;
+ }
+ else
+ {
+ addCrop /= 2;
+ job->crop[0] += addCrop;
+ job->crop[1] += addCrop;
+ }
+ }
+
/* Compute a resolution from the number of pixels and aspect */
for( i = 0;; i++ )
{