alexh110
10th February 2013, 19:44
Was wondering if it would be possible to implement the following process as an Avisynth script using the new AVSLib and GScript extensions:
Starting with a DVD vob file originally sourced from an analogue PAL tape, I would like to populate a pair of arrays u(x,y) and v(x,y) with the PAL U and V values of each pixel in the first frame.
Then execute the following code to modify these values:
FOR y = 1 TO 576
FOR x = 1 TO 720
N(u(x, y)+k, v(x, y)+k) = N(u(x, y)+k, v(x, y)+k) + 1
NEXT x
NEXT y
FOR y1 = 1 TO 576
FOR x1 = 1 TO 720
FOR y = 1 TO 576
FOR x = 1 TO 720
IF u(x1,y1) = -u(x,y) AND v(x1,y1) = v(x,y) AND N(u(x1,y1)+k,v(x1,y1)+k) < N(u(x,y)+k,v(x,y)+k) THEN
u(x1,y1) = u(x,y)
GOTO cont
END IF
IF u(x1,y1) = -u(x,y) AND v(x1,y1) = -v(x,y) AND N(u(x1,y1)+k,v(x1,y1)+k) < N(u(x,y)+k,v(x,y)+k) THEN
u(x1,y1) = u(x,y)
v(x1,y1) = v(x,y)
GOTO cont
END IF
IF u(x1,y1) = u(x,y) AND v(x1,y1) = -v(x,y) AND N(u(x1,y1)+k,v(x1,y1)+k) < N(u(x,y)+k,v(x,y)+k) THEN
v(x1,y1) = v(x,y)
GOTO cont
END IF
NEXT x
NEXT y
cont:
NEXT x1
NEXT y1
(I wrote this in QBASIC for my own convenience, as I'm not familiar with other programming languages.)
The first block of code simply counts the number of pixels of each colour in the frame: so each element of the array N(u,v) corresponds to a different colour. N(u,v) would be dimensioned to contain all possible colours in the PAL palette.
The constant k would be set to a value that would shift all the negative u and v values to become positives, so we don't end up with negative indices in the array.
The whole process would be repeated for each frame in the footage, and the modified U and V values would be used to produce the output video stream.
Starting with a DVD vob file originally sourced from an analogue PAL tape, I would like to populate a pair of arrays u(x,y) and v(x,y) with the PAL U and V values of each pixel in the first frame.
Then execute the following code to modify these values:
FOR y = 1 TO 576
FOR x = 1 TO 720
N(u(x, y)+k, v(x, y)+k) = N(u(x, y)+k, v(x, y)+k) + 1
NEXT x
NEXT y
FOR y1 = 1 TO 576
FOR x1 = 1 TO 720
FOR y = 1 TO 576
FOR x = 1 TO 720
IF u(x1,y1) = -u(x,y) AND v(x1,y1) = v(x,y) AND N(u(x1,y1)+k,v(x1,y1)+k) < N(u(x,y)+k,v(x,y)+k) THEN
u(x1,y1) = u(x,y)
GOTO cont
END IF
IF u(x1,y1) = -u(x,y) AND v(x1,y1) = -v(x,y) AND N(u(x1,y1)+k,v(x1,y1)+k) < N(u(x,y)+k,v(x,y)+k) THEN
u(x1,y1) = u(x,y)
v(x1,y1) = v(x,y)
GOTO cont
END IF
IF u(x1,y1) = u(x,y) AND v(x1,y1) = -v(x,y) AND N(u(x1,y1)+k,v(x1,y1)+k) < N(u(x,y)+k,v(x,y)+k) THEN
v(x1,y1) = v(x,y)
GOTO cont
END IF
NEXT x
NEXT y
cont:
NEXT x1
NEXT y1
(I wrote this in QBASIC for my own convenience, as I'm not familiar with other programming languages.)
The first block of code simply counts the number of pixels of each colour in the frame: so each element of the array N(u,v) corresponds to a different colour. N(u,v) would be dimensioned to contain all possible colours in the PAL palette.
The constant k would be set to a value that would shift all the negative u and v values to become positives, so we don't end up with negative indices in the array.
The whole process would be repeated for each frame in the footage, and the modified U and V values would be used to produce the output video stream.