Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER for Video Editing/Mangling

Reply
 
Thread Tools Display Modes
Old 11-25-2018, 07:49 PM   #41
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,685
Default

wwwmaze, btw, there's a typo in your YV12 version, it needs to be _1=eval_w*.5-1, in order to reset every scanline

I've merged the updated Gaussian kernel into my newer blur, here it is:
Code:
// Blur (Gaussian)
//@param1:sigma_parm 'Sigma' 10 0.5 100 25 0.1
//@param2:weight_mod 'Y modifier' 1 .25 4 1.0 0.01
//@param4:want_l 'leftward' 1 0 1 0 1
//@param5:want_r 'rightward' 1 0 1 0 1
//@param6:want_u 'upward' 1 0 1 0 1
//@param7:want_d 'downward' 1 0 1 0 1

in=0;

colorspace!='RGBA' ? colorspace='YV12';
input_info(in,project_w,project_h);
w=project_w; h=project_h;

function rot(new_ang, dest, blur) local(lw,lh,ang) (
  gfx_dest=dest;
  ang = (new_ang+4-c_ang)&3;
  c_ang = new_ang&3;
  lw=(c_ang&1) ? h:w;
  lh=(c_ang&1) ? w:h;
  ang==0 ? gfx_blit(c_last,0, 0,0,lw,lh,0,0,lw,lh) :
  ang==1 ? gfx_deltablit(c_last, 0,0, lw,lh, 0,   lw-1,  0, -1,  1,  0) :
  ang==2 ? gfx_deltablit(c_last, 0,0, lw,lh, lw-1,lh-1, -1,  0,  0, -1):
  ang==3 ? gfx_deltablit(c_last, 0,0, lw,lh, lh-1,0,     0,  1, -1,  0);
  blur ? (
    sigma = sigma_parm * ((c_ang&1)?weight_mod:1/weight_mod);
    sigma > 0.5 ? (
    
      q = sigma <=2.5 ? 3.97156-4.14554*sqrt(1-0.26891*sigma) : 0.98711*sigma-0.96330;
      b0 = 1.57825 + 2.44413*q + 1.4281*q^2 + 0.422205*q^3;
      b1 = 2.44413*q + 2.85619*q^2 + 1.26661*q^3;
      b2 = -1.4281*q^2 - 1.26661*q^3;
      b3 = 0.422205*q^3;
      BB = 1-(b1+b2+b3)/b0;
      b1b0=b1/b0;
      b2b0=b2/b0;
      b3b0=b3/b0;
    
      eval_w = lw; 
      gfx_evalrect(0,0,lw,lh, 
        colorspace=='RGBA' ? "
          (_1 -= 1) < 0 ? (
            _1=eval_w-1;
            _31=_21=_11=r; _32=_22=_12=g; _33=_23=_13=b;
          );
          r=BB*r + b1b0*_11 + b2b0*_21 +b3b0*_31; _31=_21; _21=_11; _11=r;
          g=BB*g + b1b0*_12 + b2b0*_22 +b3b0*_32; _32=_22; _22=_12; _12=g;
          b=BB*b + b1b0*_13 + b2b0*_23 +b3b0*_33; _33=_23; _23=_13; _13=b;
        " : "
          (_1 -= 1) < 0 ? (
            _1=eval_w*.5-1;
            _31=_21=_11=y1; _32=_22=_12=y3; _33=_23=_13=u; _34=_24=_14=v;
          );
          y1=BB*y1 + b1b0*_11 + b2b0*_21 +b3b0*_31;
          y2=BB*y2 + b1b0*y1 + b2b0*_11 +b3b0*_21; _31=_11; _21=y1; _11=y2;
          y3=BB*y3 + b1b0*_12 + b2b0*_22 +b3b0*_32;
          y4=BB*y4 + b1b0*y3 + b2b0*_12 +b3b0*_22; _32=_12; _22=y3; _12=y4;
          
          _90=BB*u + b1b0*_13 + b2b0*_23 +b3b0*_33;
          u=BB*u + b1b0*_90 + b2b0*_13 +b3b0*_23; _33=_13; _23=_90; _13=u;
          _91=BB*v + b1b0*_14 + b2b0*_24 +b3b0*_34;
          v=BB*v + b1b0*_91 + b2b0*_14 +b3b0*_24; _34=_14; _24=_91; _14=v;
        "
      );
    );
  );
  c_last=dest;
);

c_ang=0;
c_last=in;
max(sigma_parm/weight_mod,sigma_parm*weight_mod)>.5? (
  want_l ? rot(2, -1, 1);
  want_d ? rot(3, img3 = gfx_img_resize(img3,h,w),1);
  want_u ? rot(1, img2 = gfx_img_resize(img2,h,w),1);
  want_r || c_last==-1 ? rot(0, c_last==-1 ? (img1 = gfx_img_resize(img1,w,h)) : -1,want_r);
);
c_last != -1 ? rot(0, -1, 0);
Justin is online now   Reply With Quote
Old 11-26-2018, 12:58 AM   #42
Eliseat
Human being with feelings
 
Join Date: Mar 2018
Location: Cologne
Posts: 620
Default

Wow! This more and more looks like the battle of the titans. Like Muhammad Ali vs. George Foreman. Or maybe more like Magnus Carlsen and Fabiano Caruana?

Anyway. We are pretty happy about how this thread turned out. Many thanks.
Eliseat is offline   Reply With Quote
Old 11-26-2018, 02:18 PM   #43
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,685
Default

Quote:
Originally Posted by Eliseat View Post
Wow! This more and more looks like the battle of the titans. Like Muhammad Ali vs. George Foreman. Or maybe more like Magnus Carlsen and Fabiano Caruana?

Anyway. We are pretty happy about how this thread turned out. Many thanks.
Except we get to add on to eachother's work
Justin is online now   Reply With Quote
Old 11-26-2018, 06:16 PM   #44
wwwmaze
Human being with feelings
 
Join Date: Oct 2009
Posts: 104
Default

Quote:
Originally Posted by Justin View Post
Here's a version that uses the native colorspace (YV12 or RGBA), rather than forcing a colorspace (colorspace conversion is quite slow by itself!)
Good idea! Great to know this about conversion too, thanks. It seems to make a rather big difference.

Quote:
Originally Posted by Justin View Post
and here is the lower quality linear blur with the same multi-colorspace support:
Really like that one!

Quote:
Originally Posted by Justin View Post
wwwmaze, btw, there's a typo in your YV12 version, it needs to be _1=eval_w*.5-1, in order to reset every scanline
Ha you're right! Quite silly one too. That's probably why my YV12 version was so slow.

Quote:
Originally Posted by Justin View Post
I've merged the updated Gaussian kernel into my newer blur, here it is:
That's my favorite one by now. Love the controls, thanks!

Quote:
Originally Posted by Eliseat View Post
Wow! This more and more looks like the battle of the titans. Like Muhammad Ali vs. George Foreman. Or maybe more like Magnus Carlsen and Fabiano Caruana?
Hehe no battle at all Without all the help from Justin and the assurance that my approach of rotating the workspace might not be that hacky as I initially thought I probably would have stopped after the first blur
It's awesome to know that many filters are really feasible.
__________________
Video processor programming: (1) How inputs work: https://forum.cockos.com/showthread....26#post2057426 (2) YV12 colorspace: https://forum.cockos.com/showthread....54#post2059354 (3) EEL documentation: https://www.cockos.com/EEL2/
wwwmaze is offline   Reply With Quote
Old 11-29-2018, 07:16 PM   #45
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,685
Default

Some improvements coming in the latest pre-release -- gfx_evalrect() can take flags to process right to left, or vertically, avoiding all of the image shuffling. I've updated the built-in blur presets to take advantage of this, they should both be quite a bit faster.
Justin is online now   Reply With Quote
Old 11-30-2018, 08:23 AM   #46
wwwmaze
Human being with feelings
 
Join Date: Oct 2009
Posts: 104
Default

Quote:
Originally Posted by Justin View Post
Some improvements coming in the latest pre-release -- gfx_evalrect() can take flags to process right to left, or vertically, avoiding all of the image shuffling. I've updated the built-in blur presets to take advantage of this, they should both be quite a bit faster.
How cool is that! The code looks so much cleaner now. Thanks a lot! And it's faster too (21% instead of 25% on my old Linux box here) classic win-win.

Just a heads up: If I set colorspace to 'RGB' in project settings and run this I420/YV12 video through any blur preset I'm getting reproducible crashes with dev1129. Not with the edge detection preset and not with dev1128.

Just saw the mention in the preset Thank you I'm feeling very honored man
(shhhh...originally not my work...got it from here: https://www.researchgate.net/publica...aussian_filter )
__________________
Video processor programming: (1) How inputs work: https://forum.cockos.com/showthread....26#post2057426 (2) YV12 colorspace: https://forum.cockos.com/showthread....54#post2059354 (3) EEL documentation: https://www.cockos.com/EEL2/
wwwmaze is offline   Reply With Quote
Old 11-30-2018, 08:51 AM   #47
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 11,685
Default

Quote:
Originally Posted by wwwmaze View Post
How cool is that! The code looks so much cleaner now. Thanks a lot! And it's faster too (21% instead of 25% on my old Linux box here) classic win-win.

Just a heads up: If I set colorspace to 'RGB' in project settings and run this I420/YV12 video through any blur preset I'm getting reproducible crashes with dev1129. Not with the edge detection preset and not with dev1128.

Just saw the mention in the preset Thank you I'm feeling very honored man
(shhhh...originally not my work...got it from here: https://www.researchgate.net/publica...aussian_filter )
Thanks, fixing! I tested the YV12 mode extensively (got it to produce byte-for-byte identical results to the old algorithm) but didn't really test RGBA, oops.
Justin is online now   Reply With Quote
Old 12-06-2018, 03:51 AM   #48
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,230
Lightbulb

I left in last Pre release thread about about RGB color shift with blur, the common approach and the better one :


https://forum.cockos.com/showpost.ph...61&postcount=5


Can interest some of you here :P
X-Raym is offline   Reply With Quote
Old 12-06-2018, 06:20 AM   #49
Eliseat
Human being with feelings
 
Join Date: Mar 2018
Location: Cologne
Posts: 620
Default

Quote:
Originally Posted by X-Raym View Post
I left in last Pre release thread about about RGB color shift with blur, the common approach and the better one :


https://forum.cockos.com/showpost.ph...61&postcount=5


Can interest some of you here :P
Very interesting. And it seems its a pretty simple fix as shown in the video.

Many thanks for the info.

Btw: Why are you not coding in video processor? Is it not your programming language or is it just not your genre? I'm just curios as you are known for your lots of scripts in other areas.
Eliseat is offline   Reply With Quote
Old 12-06-2018, 11:36 AM   #50
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,230
Default

@Eliseat
I coded few things for video items but not actual new video processor preset indeed.


Basically, it's just that I'm used to video editor softwares which offers the tools I need (mostly GUI acceleration and RGB curves and advanced text tools) for video editing. I do use Video features in REAPER, mostly when I need to make a sound for video. Though basic color correction are very welcome in this case.


Also, it's pretty hard :P Justin code is very conzise, but there is more complexlity in it than all my scripts of the same size ^^


I keep an eye on new video features, native or user made.
X-Raym is offline   Reply With Quote
Reply

Thread Tools
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 -7. The time now is 05:59 PM.


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