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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 11th September 2002, 15:36   #41  |  Link
trbarry
Registered User
 
trbarry's Avatar
 
Join Date: Oct 2001
Location: Gainesville FL USA
Posts: 2,092
Quote:
About resize, does anybody know if last bug of simpleresize.dll concerning chroma/luma shift has been solved?
Haven't find any post by trbarry talking about this... yet.
Sorry, some other stuff came up and I confess I haven't done anything on that. I'll try to get back to it soon.

But SimpleResize is just an optimized bilinear resize without the triangle filter. This means it goes faster but does not filter and is then (duh) best when you don't need any filtering. So if you had overly sharp material already (uncommon) then it could create aliasing artifacts if you downsized a lot. And of course it passes through all the noise, but also all the detail.

I think the more sophisticated (but slower) algorithms like BiCubic and Lanczos3 are general purpose and can do a much better job when upsizing, filling in gradients smoothly. SimpleResize probably wouldn't upsize very well, at least at ratios bigger than (swag) 1.5:1 or so. But of course for encoding purposes we are usually downsizing.

Anyway, I promise to go look for the chroma shift bug.

- Tom
trbarry is offline   Reply With Quote
Old 11th September 2002, 15:59   #42  |  Link
Blight
Software Developer
 
Blight's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 1,005
I wonder how my factor resizing would look in comparison, sadly, it's impossibly slow (around 400ms/frame) and I don't think I could incorporate delphi code into avisynth without someone translating headers.
__________________
Yaron Gur
Zoom Player . Lead Developer
Blight is offline   Reply With Quote
Old 11th September 2002, 16:42   #43  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
delphi is easy to translate in C.
(i'm a former delohi user )
Marc FD is offline   Reply With Quote
Old 11th September 2002, 16:56   #44  |  Link
Blight
Software Developer
 
Blight's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 1,005
Here's the function I wrote, rather crude but give it a shot.
Code:
procedure ImageFactorResize(SrcBitmap,DestBitmap : TBitmap; DestX,DestY,dWidth,dHeight : Integer);
var
  Speed1            : Integer;
  Speed2            : Integer;
  Speed4            : Integer;
  PixR              : Integer;
  PixG              : Integer;
  PixB              : Integer;
  SX,SY             : Integer;
  X,Y               : Integer;
  PixXShl           : Integer;
  PixYShl           : Integer;
  PixXRnd           : Integer;
  PixYRnd           : Integer;
  PicWidth          : Integer;
  PicHeight         : Integer;
  PixCount          : Integer;
  PixXPos           : Integer;
  PixYPos           : Integer;
  P                 : ^TMyScanLine;
  PL                : Array[0..4095] of ^TMyScanLine;
  PDif              : Integer;
begin
  // Calculate memory used for each line display for quick scanline seeks (dest image)
  PL[0] := SrcBitmap.Scanline[0];
  PL[1] := SrcBitmap.Scanline[1];
  PDif  := Integer(PL[1])-Integer(PL[0]);
  // Pre-Calculate scanline positions for source image
  For Y := 2 to SrcBitmap.Height-1 do Integer(PL[Y]) := Integer(PL[Y-1])+PDif;

  // Pre-Calcualte some repeated math
  PicWidth     := SrcBitmap.Width  shl 2;
  PicHeight    := SrcBitmap.Height shl 2;
  PixXShl      := (PicWidth  shl 8) div dWidth;
  PixYShl      := (PicHeight shl 8) div dHeight;
  PixXRnd      := Round(PicWidth  / dWidth);
  PixYRnd      := Round(PicHeight / dHeight);
  PixCount     := PixXRnd*PixYRnd;

  // Calculate memory used for each line display for quick scanline seeks (source image)
  P            := DestBitmap.Scanline[DestY];
  PDif         := Integer(DestBitmap.Scanline[DestY+1])-Integer(P);

  // scale the image
  For Y := 0 to dHeight-1 do
  Begin
    PixYPos := (Y*PixYShl) shr 8;
    For X := 0 to dWidth-1 do
    Begin
      PixR         := 0;
      PixG         := 0;
      PixB         := 0;
      PixXPos      := (X*PixXShl) shr 8;
      For SY := 0 to PixYRnd-1 do
      Begin
        Speed1 := ((PixYPos+SY) shr 2);
        For SX := 0 to PixXRnd-1 do
        Begin
          Speed2 := (PixXPos+SX) shr 2;
          Inc(PixR,PL[Speed1]^[Speed2].MRed);
          Inc(PixG,PL[Speed1]^[Speed2].MGreen);
          Inc(PixB,PL[Speed1]^[Speed2].MBlue);
        End;
      End;
      Speed4 := X+DestX;
      P^[Speed4].MRed   := PixR div PixCount;
      P^[Speed4].MGreen := PixG div PixCount;
      P^[Speed4].MBlue  := PixB div PixCount;
    End;
    Inc(Integer(P),PDif);
  End;
end;
Oh, and there's the factor value in here somewhere, I think it's the shr 2, you can up the quality by doing shr 3, shr 4 (which increase the sub-picture calculation), etc...

This is more accurate than biliniar for downscaling, but not for upscaling. Very CPU intensive
__________________
Yaron Gur
Zoom Player . Lead Developer

Last edited by Blight; 11th September 2002 at 17:00.
Blight is offline   Reply With Quote
Old 11th September 2002, 19:24   #45  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
Argh.
I'm really bad when it comes to resamplers... never really etudied the stuff.
and this is only a portion of code....
so i don't understand it really...

I think i should do a benchmark a day between all these resampling algos to find wich is best for each purpose.

BTW, vlad, you integrated the Lanczos3 in the resampling-engine of your avisynth version, or you just added the filter ?
Marc FD is offline   Reply With Quote
Old 11th September 2002, 22:30   #46  |  Link
Defiler
Asker of Questions
 
Join Date: Oct 2001
Location: Florida
Posts: 433
Blight: What programming language is that? Delphi?
It looks a little like Ada.
__________________
"The real trick to optimizing color space conversions is of course to not do them." --trbarry, April 2002
Defiler is offline   Reply With Quote
Old 11th September 2002, 22:58   #47  |  Link
Dark-Cracker
Registered User
 
Dark-Cracker's Avatar
 
Join Date: Feb 2002
Posts: 1,195
i am not sure your resize filter will be faster even if u translate it in c , try to use asm else it will be very slow .
if u are interested i think u could find the source of the lanczos aviutl filter on the site web indicated by nic (scroll up) and it seems to me there is an another filter resize with source code called "icubic convolution algorythm" perhaps this will help u to make a quick filter resize.

++
__________________

AutoDub v1.8 : Divx3/4/5 & Xvid Video codec and .OGG/.MP3/.AC3/.WMA audio codec.
AutoRV10 v1.0 : Use RealVideo 10 Codec and support 2 Audio Streams and Subtitles.

Dark-Cracker is offline   Reply With Quote
Old 13th September 2002, 11:23   #48  |  Link
Blight
Software Developer
 
Blight's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 1,005
This is Delphi (Visual Pascal), and even if I converted it to ASM+MMX+SSE+SSE2 it would probably be a lot slower than bicubic as the amount of calculations is very high.

It basically does a sub-pixel calculation on a factor level, at a factor of 2 of splits a pixel into a 4x4 grid, at a factor of 3, an 8x8 grid, a factor for 4 a 16x16 grid.

Factor of 4 looks nice when downscaling. But even if optimized up the wazoo would probably take over 250ms per frame.
__________________
Yaron Gur
Zoom Player . Lead Developer
Blight is offline   Reply With Quote
Old 13th September 2002, 11:47   #49  |  Link
Didée
Registered User
 
Join Date: Apr 2002
Location: Germany
Posts: 5,389
Confirmation

Matrix: Kung-Fu Scene (Neo vs. Morpheus), MPEG-quant 2, 640*256, 4min23s

Code:
Bilinear:              59776 kB
Bicubic 0.333/0.333:   61580 kB
SimpleResize:          65782 kB
Bicubic 0.0/0.5:       67102 kB
Bicubic 0.0/0.75:      69638 kB
Lanczos3Resize:        69804 kB
Bicubic -0.2/0.6:      70670 kB
Bicubic -0.333/0.666:  73056 kB
-------------------------------
Bicubic -2.0/1.5:     125194 kB  <-- Just for fun
So, Lanczos is my favorite, if there are enough bits available for a sharp downscaling.
Because, where Bicubic 0/0.75 starts producing halos, Lanczos3 deals alot better for me.
__________________
- We´re at the beginning of the end of mankind´s childhood -

My little flickr gallery. (Yes indeed, I do have hobbies other than digital video!)
Didée is offline   Reply With Quote
Old 13th September 2002, 13:13   #50  |  Link
ookzDVD
DVD Rebuilder!
 
ookzDVD's Avatar
 
Join Date: Oct 2001
Posts: 1,147
Yes,

the lanczos3 produce the sharper image than the neutral bicubic,
I just finish the _Monsters_Inc_ and the result is superb.

@Nic,
thanks for the lanczos3.dll
slower than the build-in modified avisynth, but it produce sharper
image imho, as you could see the aigo's screenshot.
ookzDVD is offline   Reply With Quote
Old 13th September 2002, 14:31   #51  |  Link
Dark-Cracker
Registered User
 
Dark-Cracker's Avatar
 
Join Date: Feb 2002
Posts: 1,195
hi,

for those who are interested to make some tests u can find my tool (autodub) here : http://forum.doom9.org/showthread.php?s=&threadid=24678

test the v1.6 it come bundle with the lanczos filter and u can make a compressibility test of course it support the codec divx3/4/5 & xvid

bye.
__________________

AutoDub v1.8 : Divx3/4/5 & Xvid Video codec and .OGG/.MP3/.AC3/.WMA audio codec.
AutoRV10 v1.0 : Use RealVideo 10 Codec and support 2 Audio Streams and Subtitles.

Dark-Cracker is offline   Reply With Quote
Old 13th September 2002, 16:21   #52  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
Just a question :

- why do you all want to sharpen your image when you downsize ?

If i want the best image possible, i would keep 720x...

I don't see why you need to downsize if you want to achieve a bigger filesize.

I thinked the problem in ripping was to get a low enough file to put it on 1-2 CDs.

I think i've missed something.... let's re-read the whole doom9 forum....
Marc FD is offline   Reply With Quote
Old 13th September 2002, 16:34   #53  |  Link
drizztcanrender
Registered User
 
drizztcanrender's Avatar
 
Join Date: Aug 2002
Location: Athens,Greece
Posts: 33
Quote:
Originally posted by Marc FD
Just a question :

- why do you all want to sharpen your image when you downsize ?

If i want the best image possible, i would keep 720x...

I don't see why you need to downsize if you want to achieve a bigger filesize.

I thinked the problem in ripping was to get a low enough file to put it on 1-2 CDs.

I think i've missed something.... let's re-read the whole doom9 forum....
Well in my encodes, lanczos3 doesn't increase the filesize,not more than sharp bicubic at least.And encodes on full resolutions are hard to make,even with 2 cds.At least for my eyes some resizing looks better than none...
drizztcanrender is offline   Reply With Quote
Old 13th September 2002, 17:12   #54  |  Link
Marc FD
XviD fan
 
Marc FD's Avatar
 
Join Date: Jun 2002
Location: France
Posts: 907
for my eyes

That's the reason why RV9 as so many adepts.
It "looks" so good.

But i'm not a serial ripper.
pratically, you're right.
theorically, not.
Marc FD is offline   Reply With Quote
Old 13th September 2002, 18:30   #55  |  Link
drizztcanrender
Registered User
 
drizztcanrender's Avatar
 
Join Date: Aug 2002
Location: Athens,Greece
Posts: 33
A lot of stuff have a theoretical advantage but they don't have much practical significance.And the encoding procedure is indeed based on a theoretical background but it all comes down to practical results.So, imho,if it looks better then it is better.After all isn't that what we are trying to do?Make our film content look better?
The only problem of course would be the effect that lanczos3 resize would have in compressability and therefore in the final filesize.But, in my tests, lanczos resize and (even)sharp bicubic encodes have the same final filesize and display almost the same compressability and lanczos3 resize looks better,at least with divx5(it really needs the extra sharpening effect to diminish the blurring of divx5 encodes).
drizztcanrender is offline   Reply With Quote
Old 13th September 2002, 19:57   #56  |  Link
FuPP
TotalEclipseOfTheBrain
 
FuPP's Avatar
 
Join Date: Sep 2002
Posts: 347
Why downresizing ?

@MARC :

Quote :
---------------------------------------------------------------------
- why do you all want to sharpen your image when you downsize ?

if i want the best image possible, i would keep 720x...

I don't see why you need to downsize if you want to achieve a bigger filesize.
---------------------------------------------------------------------

In some case, we HAVE to resize (cf svcd , vcd, cvd specifications...). We don't all encode with XVID
FuPP is offline   Reply With Quote
Old 13th September 2002, 21:50   #57  |  Link
vlad59
Vlad, the Buffy slayer
 
vlad59's Avatar
 
Join Date: Oct 2001
Location: France
Posts: 445
@iago (= serial tester )

Thanks a lot for the testing.
With your screenshots it's clear the Nic's filter provide sharper picture (IrfanView 300%) and also greater compressibility. I was right to be doubtful about my Lanczos implementation in avisynth (it was too easy).

I think I should remove the dll.
__________________
Vlad59
Convolution3D for avisynth 2.0X : http://www.hellninjacommando.com/con3d
Convolution3D for avisynth 2.5 : http://www.hellninjacommando.com/con3d/beta
vlad59 is offline   Reply With Quote
Old 14th September 2002, 15:09   #58  |  Link
droolian01
Registered User
 
Join Date: Feb 2002
Location: uk
Posts: 157
Hi there.

I've been using the lanczos3 resise for my last few encodes and i like the results. Now i know there is a bicubic directshow filter for keeping sharper output during full screen playback, i wonder if it is possible to produce al anczos3 directshow filter.

OK - please please please can one of you brainy programmers do this, i think it would really improve fullscreen playback

Waiting with baited breath
droolian01 is offline   Reply With Quote
Old 14th September 2002, 16:00   #59  |  Link
Koepi
Moderator
 
Koepi's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 4,454
I'm mostly impressed by the nice color representation of lanczos3. Now it's really easy to beat some group releases as the filter is the right one
But "from hell" looks so nice now, I'm trying zoolander as well with it. I'm so glad that I stepped back from simple resize... I like the speed of it, but the resulting picture has too many downscaling artefacts (like aliasing from "thin lines" [ the bamboo-stick in rush hour 2 where chirs tucker and jacky chan are hanging on for example looks horrible with simpleresize])

To bad that compressability lowers about 10%-15%...

Best regards,
Koepi
Koepi is offline   Reply With Quote
Old 14th September 2002, 16:08   #60  |  Link
int 21h
Still Laughing
 
int 21h's Avatar
 
Join Date: Oct 2001
Location: Around
Posts: 1,312
I've noticed also SimpleResize making jagged artifacts. I tried using it only once for a SVCD and the quality was horrible. My only guess is that it has issues doing very large downscaling.
int 21h is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:00.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.