From BlenderWiki

Jump to: navigation, search
Note: This is an archived version of the Blender Developer Wiki. The current and active wiki is available on wiki.blender.org.

About

This is a design proposal to replace the filter options of the strips in the video sequencer by a stack of filter like the modifier stack for objects.

Actual filters are: Premul, Makefloat, Deinterlace, FlipX, FlipY, FlipTime, Multiply, Strobe, Color balance and also (even if they are in the input panel) crop and translate.

There are also some sound filters and some time parameters thta can be considered as filters (startstill, endstill)

Further some filter can even modify image and time, like a pulldown/pullup deinterlace/interlace filters for example.

Link to patch: https://projects.blender.org/tracker/index.php?func=detail&aid=20678&group_id=9&atid=127

Screenshot: http://www.pasteall.org/pic/show.php?id=834

Note that this not mean to replace the effect strips, but it can be used to replace some effect strips that takes only one input strip (like glow and transform).

Design proposal

For now we stick to filters only affecting image strip (not sound) and only filtering the image pixel (not time) but the system is flexible enough to add them later.

Workflow changes

Actually when we add a strip to the sequencer it is automatically scaled to the project resolution, this is often unexpected by the user and also distort the images that do not have the project ratio. There is no way to customize this scale operation so we often need to scale the sequence a second time.

This scaling don't happen when using crop or translate this have unexpected behavior when editing sequence.

For all these reasons, and because the actual code for filtering and scaling to project resolution are mixed together the present proposal will also address this issue.

The proposed work-flow here is inspired from NLE that have a more natural approach:

  • The default is to center the image at is original size (no scaling)
  • It can be scaled to any resolution later in one operation

Basics

Each sequence have a list where filters data are stored in the same order they will be applied.

DNA_sequence_types.h:

typedef struct Sequence {
    ...
    ListBase filters;
}

Filter data store in this list constained the parameters of each filter and are inherited from SequencFilterData.

DNA_seqfilter_types.h:

typedef struct SequenceFilterData {
	struct SequenceFilterData *next, *prev;
	int type, mode;
	char name[32];
} SequenceFilterData;

At the time of applying the filters, we can parse the list and calling a static function depending of the type of the filter. Actually, all information common to each filter type (including pointer to functions) are store in a SequenceFilterTypeInfo array created at startup.

Applying

For image and video sequences all actual filtering is done in the input_preprocess function of sequencer.c (blenderkernel). This is also there that the input image is (was) scaled to the scene size, so this is a nice place to apply the filters

There we go along the list of filters and for each of them we call the functions corresponding with the type of the filters.

Each type of filter can modify an image buffer or a transformation matrix (that will be applied to the image at the end) or both... or more (coming soon).

Applying ImBuf filters

Filter function receive an ImBuf and the filter data, it can modifi the size of the image and the color of each pixel, these can be slow, specially if a lot are stacked on top of each other. Exemple of these are Premul, Makefloat, LiftGammaGain, ...

Applying Transform filters

Filter function receive a transformation matrix and the filter data, they modify the matrix which will be applied later.

This permit to make all the transform operation in one. But it require to store the interpolation method used to applied the transformation in the strip data (not the filter data)

Further while it is easy to translate rotate and scale around a center point (specially if you can grab rotate scale in the preview) it is not usual to stack a lot of transform operation, so it may make more sense to get it out of the stack and have one transformation per sequence only.

Note this can be extanded to permit 3Dprejection even with zbuffer and perspective.

Image treatment library

For the moment lot of code are duplicated between video sequence editor and compositing nodes. A lot of image manipulation code could be made common in some library. BLI_image have been suggested by Matt Ebb, but if it needs to link again imbuf and node lib Campbell think BKE is better.

This library would include some code to transform (translate, rotate, scale, skew, 3D projection) image and filter image pixel (color balance, hue/saturation/value, contrast, brightness).

For this we should find a method that work for ImBuf and CompBuf, maybe the lib could work directly with pointer to float/char array with dimensions passed along or it can just do it internally and have 2 public functions for each operation (one for Imbuf and one for CompBuf).

Further

  • Video sequencer code cleanup refactor
  • Make sequence ID
  • Preview independent result
  • Time filter(strobe, startstill, endstill, speed effect, more deinterlace)
  • Sound filter
  • etc