View Single Post
Old 22nd November 2011, 07:40   #1  |  Link
Gainnothing
Registered User
 
Join Date: Jan 2005
Posts: 23
Questions: Understanding Resizing

This may be one of Doom’s longest questions. It is comprised of like 4 questions or more. This post can also be a learning experience as well as a question to help me with.

INTRODUCTION/PREFACE

Hi people of doom (not Dune). I like to encode videos sometimes as a hobbyist but I was never really a “once-click solution type of guy” . I like to use 4 or 5 programs sometimes just to encode one video. My programs I have used but really do not use them “correctly” may include Avisynth , vdub, quenc, procoder express, BBMpeg, and dgavcdec/dgindex.


I have been doing this for about a few years in my off time. But now I want to even take it a step further by understanding some concepts I really have never taken into account. And when you do not take these things into account, it might as well have been a “Nero click to burn my DVD type of solution”


Basically, I am going to ask some questions regarding resizing and appropriate telecine procedures. But the first question does need some background as to why and how. So it includes my procedure on how I came up to a possible solution.


But even before I begin my questions about this, I will show you some quick examples of incorrect resizing that I have been doing for the last few years or so.

Here is an example: Burn an SVCD

BicubicResize(480,480)

Burn a DVD
LanzcosResize(720,480)

Results: Lazy video where things are CHOPPED OFF. Incorrect usage. My avisynth understanding is not a true understanding. It is a HACK at what is common so that I can learn other things. But now it is time to tighter grasps on the concept of resizing and speed and speed correction. And to tell you the truth, I even found that doing the bottom script is even somewhat of a hack.

I read somewhere that even this is a hack:

LanzcosResize(704,480)
AddBorders(8,0,8,0)

Why is this a hack? Well, even with this so-called perfect solution it still can loose a little of the image. Now the strange thing is I am learning about resizing doing things the uncommon way since most of the time the DVD resizing theory from above was never explained to me in great detail. I do not know even how you guys got 720 x 480 to be resized as (704, 480). But now I am going to things the uncommon way.

Yes, aspect ratio was explained to me and got lost in the wilderness, so I am going to just stick to simple encoding. And when I read the article “A Quick Guide to Digital Video Resolutions and Aspect Ratio Conversions” I found a procedure that works OK for me. But it’s not really well known.. So I am advancing without even knowing the common way of doing resizing. And I will show you how through following this guide I came up with:

Uncommon:
LanczosResize (704 x 476)
AddBorders (8,2,8,2)

Versus:

Common:
LanzcosResize(704,480)
AddBorders(8,0,8,0)

But what is the question? Well my question is: What is the ACTIVE PICTURE AREA in a 640 x 360 matrix since this sampling matrix is not included in the NTSC chart in the article?

I have come up with: 646 5/22 x 368

The second part of the question is: If I use this as the active image area and thus use the LanczosResize (704 x 476) AddBorders (8,2,8,2) script, is it appropriate? Did I kill my image? Did I add to much black stuff to it?

One bit of info I forgot that you probably figured out: The resizing are to DVD 720 x 480 but I think you people at doom probably figured that one out already.

Now: Don’t answer the question yet. Let me show you how I got there. And once you read how I heinously got to this “random guestimate,” then answer and then we can press on to the next of my questions.


HERE ARE SOME NEW CONCETPS I HAVE LEARNED OVER THE INTERNET:

“A Quick Guide to Digital Video Resolutions and Aspect Ratio Conversions” wrote about how even some people who have been doing this professionally do it incorrectly and how there is a sampling matrix and an active area and it really does not work to just change the resolutions—like I have done. So I guess you can say really “WE ARE ALL LEARNING.” And the other concept that you should know is I do not have a “luminance meter” or whatever it is called to measure MHZ, so I have been using pre setup standards.

It is a very informative short article. Google it.


HERE COMES THE PROCEDURE:

The thing that is defined clearly in the article is the active image area for NTSC DVD including aspect ratio for PAR. But since my question deals with something not written in the chart, I have to make a random guess to what par is for 640 x 360. We have the par for 720 x 480 (710.85 x 486) in the article. But we need to figure it out for 640 by 360. And I am going to used my GUESTIMATE for the active image area (466 5/22 x 368)

Based upon the theory that NTSC has an active scanline length of 52 59/90 Microseconds, you can kind of guess the Width of PAR. And then try to match it with a common PAR and sampling rate in the chart.


52 59/90 x = 640
4739/90 x = 640
4739x = 57600
x = 12.15446296687065 which is closest to 3 types of standards: true compute square pixels, D2 standard for 525 line NTSC, or cropped true computer square pixels.

I just liked the sound of d2 so I said OK I will use the 12 3/11 MHZ setting from the chart

so:

52 59/90 (12 3/11)
4739/90 (135/11)

4739/18 (27/11)
127,953/198= 646.2272727272727

Therefore as a wild GUESS I could say the width of 640 in 640 x 360 is
646 5/22.

Now, I tried doing the same thing for the HEIGHT but I was looking at the pattern for NTSC width and the height basically stays at 486 except there is one height that is reduced by ½. But if I tried resizing using 486 as the height, I came up with a heinous calculation. So I was thinking to myself that since most heights are usually 4-8 more or less than the sampling matrix, then it probably will be something like 368.
I came up with something that had an OK solution, BUT maybe incorrect but is really feasible:

My guess for active sampling area for 640 x 360 is 646 5/22 x 368 .Now you know.


I will NOW be using 646 5/22 x 368 for 640 x 360 for NTSC. There will be NO resizing for HDTV. Just keeping it in letterbox 4:3 going to DVD NTSC 740 x 480 sampling matrix


First figuring out PAR since it is NOT in this guy’s chart:

Par = dar/sar
(4/3) / 646 5/22/368

(4/3) {368/646 5/22)
1472/1938.681818181818

= .759278797683524

Again, no resizing for HDTV. Just a regular par for 1.333333….
There is a calculator on the Internet that is helpful for this purpose that I found:

http://www.basic-mathematics.com/dec...alculator.html



Using bottom one here for PAR
323384/42651 = 0.7592787976835245 sounds like a great answer that is really close to the division but is off by a couple and that is why I underlined the end of the number. But we will use this fraction as the GUESTIMATE for PAR. Actually now that I am looking at the numbers it is a perfect match with an added number.

Now, following the procedure as outlined in “A Quick Guide to Digital Video Resolution and Apect Ratio conversions. Read the procedure or my numbers will be meaning nothing to you.

This is my work below: Please note I am not great at finding the LCM or GCF right away, so that is why it takes me so long.


Vertical ConversIon factor
486/368 = 1.320652173913044 or 243/184

The article mentions that anything other than 0.5, 1, or 2 may be because you are doing standards conversions between NTSC and PAL. Well, I am not really. It is a mp4 AVC with h.264 when demuxed becomes a 25 FPS pal frame rate. But let us not get into that yet.

Next step;

Horizontal Conversion Factor

(32384/42651) / (4320/4739)

(32384/42651) (4739/4320)

(8096/6093) (677/1080)

( 2024)/6093) (677/270)

(1012/6093) (677/135)

Now, taking the result from the above 2 and multiplying it by the Vertical Conversion Factor:

(685,124/822,555 ) )( 243/184) (v. conversion factor

(685,124 /274, 185) (81/184)

685,124 /30,465) (9/184)

(685,124 /3,385) (1/184)

(171,281/3385) (1/46)

(7,447/3385) (1/2)

7447/6770 = 1.1


NEW HORIZONTAL SIZE (width)

1.1 (640) = 704

NEW VERTICAL SIZE (height)

(243/184) (360/1)
(243/46) (90/1)

(243/23) (45/1)

(243/23) (45/1)
(10935/23)= 475.434783 or just 475

Thus 640 x 360 gets resized to 704 x 475


And then ADD BLACK BORDERS TO THE TOP AND BOTTOM

Horizontal is 704 and we need 720. So add 8 pixels to the left and right

Vertically is 475 and we need 480 BUT 475 is not a multiple of 2 so bump it up one number to 476. So we add 2. pixels to the top and bottom.

Hence:

LanczosResize (704 x 476)
AddBorders (8,2,8,2)

AddBorders(clip clip, int left, int top, int right, int bottom


Now, you may ask: Why does this look such like a good answer to me?
it LOOKS SO CLOSE TO THE HACK of 704 x 480. If so said hack version chops off some pixels maybe 476 would show these. Of course, I would not know since I am not a hardcore video person. This is just a wild guess from outside yonder. It also looked good because when I tried 352 as a height, I got something that was not so great

LanzcosResize(704,498)
Crop (0,18,0,0)
Addborders (8,0,8,0)

=NOT SO GREAT

Again, I am NOT looking for 16:9 yet. I just want 4:3

So my conclusion is that for NTSC is 640 x 360 the active image area is around 646 5/22 x 368 and the reason why that is is because it so close to the hack.


So, now you are asking: Is this a guide or a question? IT is a QUESTION simply because I want to know what the approximate value for the ACTIVE IMAGE AREA of 640 x 360 is and 2.) is my guess fair? If not fair, what is the active image area and show your work like the way I did it?


This is the first question. Ok I got to write my other questions with a different post.

Last edited by Gainnothing; 22nd November 2011 at 08:28.
Gainnothing is offline   Reply With Quote