diff options
author | jstebbins <[email protected]> | 2014-08-27 15:58:29 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2014-08-27 15:58:29 +0000 |
commit | cd1b955b6d297fb4003b0bc02d39586a689ffaf7 (patch) | |
tree | b5d6ec7356eeaf00f8a304ea1a73347b252f70e6 | |
parent | 15417070c594a330923a62f0ab2054c39d3115f4 (diff) |
CLI: fix dimensions problem when both width and height are specified
The GUI will precompute both width and height and specify both on the
command line. But then the CLI recomputes width based on height which
can result in the width being changed.
So, in non-anamorphic mode, disable keep_aspect so that width and heigh
are both kept. And in other anamorphic modes, use custom ana when computing
dimensions so that both width and height are kept (i.e. recompute par).
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6369 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/common.h | 9 | ||||
-rw-r--r-- | libhb/hb.c | 16 | ||||
-rw-r--r-- | test/test.c | 11 |
3 files changed, 23 insertions, 13 deletions
diff --git a/libhb/common.h b/libhb/common.h index 2882bdf37..ef10fff41 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -63,11 +63,10 @@ #define HB_DEBUG_ASSERT(x, y) { if ((x)) { hb_error("ASSERT: %s", y); exit(1); } } #endif -#define EVEN( a ) ( (a) + ( (a) & 1 ) ) -#define MULTIPLE_16( a ) ( 16 * ( ( (a) + 8 ) / 16 ) ) -#define MULTIPLE_MOD( a, b ) ((b==1)?a:( b * ( ( (a) + (b / 2) - 1) / b ) )) -#define MULTIPLE_MOD_UP( a, b ) ((b==1)?a:( b * ( ( (a) + (b) - 1) / b ) )) -#define MULTIPLE_MOD_DOWN( a, b ) ((b==1)?a:( b * ( (a) / b ) )) +#define EVEN( a ) ((a) + ((a) & 1)) +#define MULTIPLE_MOD(a, b) (((b) * (int)(((a) + ((b) / 2)) / (b)))) +#define MULTIPLE_MOD_UP(a, b) (((b) * (int)(((a) + ((b) - 1)) / (b)))) +#define MULTIPLE_MOD_DOWN(a, b) (((b) * (int)((a) / (b)))) #define HB_DVD_READ_BUFFER_SIZE 2048 diff --git a/libhb/hb.c b/libhb/hb.c index e7c9c22bf..1ba78d774 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -1079,12 +1079,12 @@ void hb_set_anamorphic_size2(hb_geometry_t *src_geo, if (!keep_height) { width = MULTIPLE_MOD_UP(ui_geo->width, mod); - height = MULTIPLE_MOD((int)(width / dar), mod); + height = MULTIPLE_MOD(width / dar, mod); } else { height = MULTIPLE_MOD_UP(ui_geo->height, mod); - width = MULTIPLE_MOD((int)(height * dar), mod); + width = MULTIPLE_MOD(height * dar, mod); } } else @@ -1095,12 +1095,12 @@ void hb_set_anamorphic_size2(hb_geometry_t *src_geo, if (maxWidth && (width > maxWidth)) { width = maxWidth; - height = MULTIPLE_MOD((int)(width / dar), mod); + height = MULTIPLE_MOD(width / dar, mod); } if (maxHeight && (height > maxHeight)) { height = maxHeight; - width = MULTIPLE_MOD((int)(height * dar), mod); + width = MULTIPLE_MOD(height * dar, mod); } dst_par_num = dst_par_den = 1; } break; @@ -1141,24 +1141,24 @@ void hb_set_anamorphic_size2(hb_geometry_t *src_geo, if (!keep_height) { width = MULTIPLE_MOD_UP(ui_geo->width, mod); - height = MULTIPLE_MOD_UP((int)(width / storage_aspect + 0.5), mod); + height = MULTIPLE_MOD_UP(width / storage_aspect + 0.5, mod); } else { height = MULTIPLE_MOD_UP(ui_geo->height, mod); - width = MULTIPLE_MOD_UP((int)(height * storage_aspect + 0.5), mod); + width = MULTIPLE_MOD_UP(height * storage_aspect + 0.5, mod); } if (maxWidth && (maxWidth < width)) { width = maxWidth; - height = MULTIPLE_MOD((int)(width / storage_aspect + 0.5), mod); + height = MULTIPLE_MOD(width / storage_aspect + 0.5, mod); } if (maxHeight && (maxHeight < height)) { height = maxHeight; - width = MULTIPLE_MOD((int)(height * storage_aspect + 0.5), mod); + width = MULTIPLE_MOD(height * storage_aspect + 0.5, mod); } /* Adjust the output PAR for new width/height diff --git a/test/test.c b/test/test.c index 44d9dd349..28dce55fd 100644 --- a/test/test.c +++ b/test/test.c @@ -1730,6 +1730,17 @@ static int HandleEvents( hb_handle_t * h ) keep_display_aspect |= anamorphic_mode != HB_ANAMORPHIC_CUSTOM; uiGeo.mode = job->anamorphic.mode = anamorphic_mode; + if (width != 0 && height != 0) + { + if (anamorphic_mode == HB_ANAMORPHIC_NONE) + { + keep_display_aspect = 0; + } + else + { + uiGeo.mode = HB_ANAMORPHIC_CUSTOM; + } + } job->anamorphic.keep_display_aspect = keep_display_aspect; uiGeo.keep = !!keep_display_aspect * HB_KEEP_DISPLAY_ASPECT; uiGeo.itu_par = job->anamorphic.itu_par = itu_par; |