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

Reply
 
Thread Tools Display Modes
Old 05-23-2020, 08:51 AM   #1
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default I need a video processor/gfx tutorial. Anyone can help?

I am trying to understand how things work with the video processor and its gfx functions. But they all seem very complicated. Could anyone help? I have lots of questions unfortunately..

1) Could someone explain me how the gfx_blit works?
Code:
gfx_blit(input[,preserve_aspect=0,x,y,w,h,srcx,srcy,srcw,srch])
Draws input to framebuffer. preserve_aspect=-1 for no fill in pad areas
From what I have understood, it will draw the specified input to the dest set by gfx_dest. Right? And -1 is the final layer (the current framebuffer), right?
Let's say that I have this code that will half the width of the video while preserving the aspect:
Code:
input_info(0, w, h); // getting the w,h of the video
gfx_blit(-1); // blitting a black layer on the frame
gfx_blit(0, 1, 0, 0, w/2, h, 0, 0, w, h ); // halving the width of the frame
But although x=y=0 the image is blitted centralized in height. I found out that in order to place it up/down or left/right I must use this:

Code:
input_info(0, w, h);
gfx_blit(-1);
// example for up right
div = 0.5;
vert_position = 1; //1 for up, -1 for down
k = vert_position*(0.5*div - 0.5);
horiz_position = w*div; // 0 for left, w*div for right
gfx_blit(0, 1, w*div, h*k, w*div, h, 0, 0, w, h );
And the opposite function is true if only the height is changed:
Code:
input_info(0, w, h);
gfx_blit(-1);
// example for up right
div = 0.5;
horiz_position = -1; //1 for left, -1 for right
k = horiz_position*(0.5*div - 0.5);
vert_position = 0; // 0 for up, h*div for down
gfx_blit(0, 1, w*k, vert_position, w, h*div, 0, 0, w, h );
Let's say that I have figured out these (although they seem to me very complicated and unexpected results)...
...

What happens with these: ?
Code:
gfx_blit(input,1,x,y,w,h,srcx,srcy,srcw,srch)
The scrx and srcy I think I understood how they work. But the other two give me totally unexpected results (plus Reaper hard-crashes if I set a negative value to srcw!).

Is there a logic on how all these interact?

2) For gfx_blit the final layer was -1 but for the input_info function the current is 0 and not -1, right? So, for which functions is the current -1 and for which is it 0?

Code:
input_info(input, w, h[,srctime, wet, parm1, ...])
Returns 1 if input is available, sets w/h to dimensions. If srctime specified, it will be set with the source-local time of the underlying media. if input is a video processor in effect form, automated parameters can be queried via wet/parm1/...
3) If I try to draw something on the image the image flickers like crazy. Why?
Code:
input_info(0, w, h);
gfx_set(0,0,0,1,0);
gfx_fillrect(0,0,100,h);
Thanks in advance for any help!
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 05-23-2020 at 08:59 AM.
amagalma is offline   Reply With Quote
Old 05-27-2020, 06:58 AM   #2
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Code:
gfx_blit(input[,preserve_aspect=0,x,y,w,h,srcx,srcy,srcw,srch])
I'm no expert and I haven't done any of this with video but I'd imagine it's the same as with jsfx, so IIRC gfx_blit will copy a section of the input buffer to the currently selected buffer. Arguments x,y,w,h define a rectangular section of the destination buffer where the image will be put and srcx, srcy, srcw, srch define the rectangular area of the input buffer to be copied.

To avoid flickering, the best technique is to draw everything into an offscreen buffer first then blit the whole thing to the display when you're done.

Hope that helps a bit.
IXix is online now   Reply With Quote
Old 05-27-2020, 10:39 AM   #3
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thank you very much for helping me

So, is this the correct way?:
Code:
// Crop Image (curtains)
//@param1:x_pos 'Horiz Shift' 0 -1 1 0 0.01
//@param2:y_pos 'Vert Shift' 0 -1 1 0 0.01
//@param3:w_size 'Horizontal Curtains' 0 0 1 0.5 0.01
//@param4:h_size 'Vertical Curtains' 0 0 1 0.5 0.01

input_info(0, w, h);
gfx_dest = mybuf = gfx_img_alloc(w,h);
gfx_blit(0, 1, 0, 0, w, h, -x_pos*w, y_pos*h, w, h );
w_size != 0 ? (
  w_size = w*w_size/2;
  gfx_fillrect(0,0,w_size,h);
  gfx_fillrect(w-w_size,0,w_size,h);
);
h_size != 0 ? (
  h_size = h*h_size/2;
  gfx_fillrect(0,0,w,h_size);
  gfx_fillrect(0,h-h_size,w,h_size);
);
gfx_dest = -1;
gfx_blit(mybuf, 1);
gfx_img_free(mybuf);
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-27-2020, 10:49 AM   #4
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

A test image:


full size 1920x1080

I want to copy the red rectangle to point 0,0.

I understood how the gfx_blit works.. But still I think I am not drawing correctly to the buffer because it flickers:
Code:
input_info(0, w, h);
gfx_dest = mybuf = gfx_img_alloc(w,h);
gfx_blit(0,1,0,0,242,137,1200,540,242,137);
gfx_dest = -1;
gfx_blit(mybuf, 1);
gfx_img_free(mybuf);
Edit: this works! :
Code:
input_info(0, w, h);
mybuf = gfx_img_alloc(w,h);
gfx_dest = mybuf;
gfx_blit(0,1);
gfx_blit(0,1,0,0,242,137,1200,540,242,137);
gfx_dest = -1;
gfx_blit(mybuf, 1);
gfx_img_free(mybuf);
Is it the correct way to do it?
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 05-27-2020, 10:59 AM   #5
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

I've been playing with it this afternoon as well and tbh I'm not sure any advice I give you is worth the pixels it's displayed on!


It looks, to my untrained eye, like you're doing the right things but what do I know? I'm in the dark too!
IXix is online now   Reply With Quote
Old 05-27-2020, 11:21 AM   #6
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Nahh... your advice cleared things up to me! Thank you!


__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 05-27-2020 at 11:28 AM.
amagalma is offline   Reply With Quote
Old 05-27-2020, 11:26 AM   #7
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,889
Default

Quote:
Originally Posted by amagalma View Post
Nahh,.. you're advice cleared things up to me!
Miracles do happen! Looking good there.
IXix is online now   Reply With Quote
Old 06-01-2020, 10:09 AM   #8
Eliseat
Human being with feelings
 
Eliseat's Avatar
 
Join Date: Mar 2018
Location: Cologne
Posts: 1,362
Default

This very strange moment when you look into a thread and don't understand it.

__________________
☆.。.:*・°☆.。.:*・°☆.。.:*・°☆REAPER//✿◔‿◔)°☆.。.:*・°☆.。.:*・°☆
Eliseat 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 01:39 PM.


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