View Full Version : Cropping a 1080p YV12 source to mod8 height
SVD
2nd December 2009, 20:14
I have a 1920x1080 blu-ray source which has black borders top and bottom:
137px at the top and -139px at the bottom.
I wanted to crop both values with Crop(0,137,-0,-139) and then use AddBorders(0,2,0,2) to add 2px at the top and bottom to end up with a mod8 compatible height of 808px.
This is was not possible.
AviSynth told me it's only possible to crop even numbers. I tried cropping 136px top and -138px bottom. This would result in 806px including a 1px border top and bottom. To achieve 808px I tried AddBorders(0,1,0,1) to get a resolution of 1920x808 including a 2px border top and bottom.
There was no AviSynth error but I ended up with an image of 1920x808 which had 1px black at top and 3px black at the bottom. I'm sure the AddBorders syntax is correct.
What's wrong then?
Gavino
2nd December 2009, 20:35
Adding an odd-sized border to a YV12 clip would require resampling the chroma, so Avisynth doesn't do it. It silently rounds the borders to even numbers, rounding down for the top and left, and up for the bottom and right. So 1 and 1 become 0 and 2.
Maybe it would be better for it to report an error instead (as in Crop)?
Alex_ander
2nd December 2009, 22:54
Not sure what happens to chroma here, but cropping must work:
Spline36Resize(1920,804,0,137,0,-139).AddBorders(0,2,0,2)
Keiyakusha
2nd December 2009, 23:12
Not sure what happens to chroma here, but cropping must work:
Spline36Resize(1920,804,0,137,0,-139).AddBorders(0,2,0,2)
But this does resizing. If SVD wanted to crop black borders, its probably better just overcrop (or undercrop) by 1px instead of resampling the whole thing...
EDIT: In this case (if resizing is OK) its better to do Spline36Resize(1920,808,0,137,0,-139) without any borders...
SVD
2nd December 2009, 23:31
I don't want to resize so I guess I'm going with Crop(0, 140, -0, -140). This overcrops 3px top and 1px bottom. Is this to be considered a really bad overcrop or common practice in such a case?
Gavino
2nd December 2009, 23:38
In this case (if resizing is OK) its better to do Spline36Resize(1920,808,0,137,0,-139) without any borders...
That will resample both luma and chroma, whereas Spline36Resize(1920,804,0,137,0,-139) will only resample chroma and copy luma.
Inspector.Gadget
2nd December 2009, 23:41
Is this to be considered a really bad overcrop or common practice in such a case?
Are you going to miss 4 lines of vertical resolutions? If so, are you going to be bothered by 4px of black/soft borders? This is entirely up to you. You'll get great advice here on the technical side of things, but this is an aesthetic question only you can answer.
FWIW, a lot of Blu-ray discs have sharpening artifacts near the picture edges...if me mentioning this curses you with noticing them now (haha), maybe you want to crop those out too and you may end up with a mod8 resolution with no "good" areas thrown away.
Keiyakusha
2nd December 2009, 23:45
That will resample both luma and chroma, whereas Spline36Resize(1920,804,0,137,0,-139) will only resample chroma and copy luma.
Yep, you right. But who knows, maybe its still better because absence of black borders will helps compression.
SVD
2nd December 2009, 23:51
Are you going to miss 4 lines of vertical resolutions? If so, are you going to be bothered by 4px of black/soft borders? This is entirely up to you. You'll get great advice here on the technical side of things, but this is an aesthetic question only you can answer.
FWIW, a lot of Blu-ray discs have sharpening artifacts near the picture edges...if me mentioning this curses you with noticing them now (haha), maybe you want to crop those out too and you may end up with a mod8 resolution with no "good" areas thrown away.Hehe, yes, I see them in the 1st and last line of the actual picture. Leaves me cropping 2 px of the image. Well if non-present black borders help the compression I can live with that. Thanks for the advice.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.