View Single Post
Old 20th April 2007, 01:54   #4  |  Link
gzarkadas
Registered User
 
gzarkadas's Avatar
 
Join Date: Sep 2005
Location: 100011110010001000001 10000011111111000001
Posts: 221
Damn, this forces me to think more . Can you perhaps supply the argument lists of ColorKeyFrame and ColorInterpolation? A bit more of information would certainly help. Up to this point, as I re-read more carefully your 1st post's description, I can only conclude (hopefully correct) that either:
  • you seek a linearly changing ColorYUV on any of its argument per frame, based on values on frames f0, f1, f2, ..., or
  • something different, which however needs only a single-frame clip to hold the info needed by ColorInterpolation.

In the first case you could (since STL is not a choice) setup
  • a structure to hold child->p, f0, f1, f2, ..., arg10, arg11, arg12, ..., ..., argn0, argn1, argn2, ..., (except for the first all others should be lists)
  • a linked list of those structs to identify the struct associated with its first argument (the source clip) with a linear (in size) search
Then you could (in each step a scan of the linked list for a match on child->p is implied)
  • In each ColorKeyFrame, insert a new "column" to the struct that corresponds to clip passed in (ie add an item in each list)
  • In ColorInterpolation::GetFrame construct for each k=1,...,n an f0, argk0, f1, argk1, ... array to pass to Spline (if up to ~25 keyframes are enough) or your linear interpolation function (if > ~25 keyframes are wanted), gather all calculated values and make the final env->Invoke to ColorYUV.

In the second case ColorKeyFrame could simply return this clip as its value and the user would need to supply it as an optional arg in each succesive ColorKeyFrame call. If the above is however considered complicated for the user (probably is) then the following recipy could be used (ColorKeyFrame returns the source clip):
  1. In the constructor of ColorKeyFrame, env->GetVar for a global var that is based on child->p value as a hex string (plus a long prefix to reduce the posibility of conflicting with user script variables). Example: __color_key_frame_0x2E48AB0C
  2. If var is found and is a clip, update it (we are inside a succesive call to ColorKeyFrame); if not create it (we are inside the 1st call for this IClip*)
  3. In the constructor of ColorInterpolation, env->GetVar for the above global var; if found proceed else exit with error

Another approach that came to me while writing those lines - but which did *not* devoted much time to think of - would be to:
  1. make a base filter class that holds a private frame buffer (initialised to child->GetFrame(0) ?) and returns it for every value of n in its GetFrame.
  2. derive ColorKeyFrame from it to modify appropriately the frame buffer based on the other arguments
That way we modify a single frame buffer only at the constructor, irrespectively of number of frames.

I will stop here because my head started complaining for scratching it too hard ; hope something of the above is of use.
__________________
AVSLib, a free extension library for Avisynth. Current version: 1.1.0 (beta), 14/05/2007.
[ Home page | Download page ]
gzarkadas is offline   Reply With Quote