Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
27th November 2011, 22:35 | #1 | Link |
Registered User
Join Date: Aug 2008
Posts: 233
|
PARResize() | PAR-aware resizing function
PARResize() is useful for standards conversions and arbitrary anamorphic pixel resizing.
It can automatically detect the "correct" input and output PAR using the assumptions here. Or you can specify SourcePAR or TargetPAR as a decimal or fraction string. It operates in two modes: Boxing=true (default) will add borders to achieve the target dimensions. When Boxing=false, it will crop the source to match the PAR-compensated target dimensions. 100% AviSynth, no dependent DLLs required. Download it here Code:
##################################################################################################### # PARResize() # 2011/11/29 ##################################################################################################### # # Parameters: # # TargetWidth, TargetHeight [integer] # These determine the output width and height # SourcePAR, TargetPAR [string or float] # These determine the PAR of the input and output, respectively # Legal vales are either a floating decimal PAR (ex: SourcePAR=0.909091) or a string # The allowed string values are: # "" (default) # A blank string will set the corresponding PAR automatically, assuming 4:3 DAR # "ws" # A value of "ws" (widescreen) will set the corresponding PAR automatically, assuming 16:9 DAR # Fractional String # You can also use fractions as strings (Example: SourcePAR="10/11", TargetPAR="40/33") # Boxing [boolean] # When Boxing=true (default), borders will be added to achieve the TargetWidth or Height as needed # When false, PARResize will crop the source as needed to achieve the target DAR # Color [int] # The Color parameter determines the border color when Boxing=true # CropBias [float] # When CropBias=0.5 (default), any cropping of the source will be symmetrical # Setting it lower (minimum is 0.0) will show more of the source's left or top, cropping more from the right or bottom # Setting it higher (minimum is 1.0) will show more of the source's right or bottom, cropping more from the left or top # CropBias has no effect if Boxing=true # ##################################################################################################### Code:
# Assume 4:3 input and resize to 4:3 NTSC DVD PARResize(720, 480, SourcePAR="", TargetPAR="") # Assume widescreen input and output PARResize(720, 480, SourcePAR="ws", TargetPAR="ws") # Use arbitrary PARs PARResize(176, 576, SourcePAR=1.0, TargetPAR="472/81") # Assume an HD source, convert to widescreen DVD specs # Here, Boxing=false will crop a few lines from the source before scaling to fill the width PARResize(720, 576, "ws", "ws", Boxing=false) # Assume an HD source, convert to 4:3 DVD specs # Here, Boxing=false will crop the sides to fit the screen PARResize(720, 576, "ws" , "", false) # Set the letterboxing color to white PARResize(704, 480, color=$FFFFFF) Last edited by vampiredom; 29th November 2011 at 22:37. Reason: revision 2011/11/29 - fixed a bug |
29th November 2011, 01:14 | #2 | Link |
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,433
|
I haven't looked in detail at the algorithmic part, so can't comment on that, but I spotted a couple of things on a quick look at the code.
In the Assert statement error messages, CHR(13) does not produce a newline, just a square blob. Use CHR(10) instead, or just use a multi-line string literal, eg "first line second line" # note no '\' required Also, Avisynth string comparison is case-insensitive, so there's no need to use LCase when comparing. |
29th November 2011, 02:01 | #3 | Link | ||
Registered User
Join Date: Aug 2008
Posts: 233
|
Quote:
Quote:
|
||
Tags |
conversion, par, pixel aspect ratio, resizer, scaling |
Thread Tools | Search this Thread |
Display Modes | |
|
|