12k lines of sequencer back! Only seqaudio.c skipped for now.
Notes:

- it only draws now, nothing refreshes or edits.
- fixed bug in view2d.c with vertical grid step being 0.0f
- render code and fileselect code is #ifdeffed out
- sequence evaluation code moved to blenkernel, so it can
  be used for render without bad level calls

General note; sequencer code is very untidy, mixing styles too
much. Tried to clean it some, but it would be nice if formatting
is kept consistant from now on.
This commit is contained in:
Ton Roosendaal 2009-01-12 19:02:08 +00:00
parent ca45efba28
commit 03fc5696dc
12 changed files with 11940 additions and 50 deletions

View File

@ -33,11 +33,17 @@
struct Editing;
struct Sequence;
struct Strip;
struct StripElem;
struct ImBuf;
struct Scene;
/* free */
#define MAXSEQ 32
#define BUILD_SEQAR_COUNT_NOTHING 0
#define BUILD_SEQAR_COUNT_CURRENT 1
#define BUILD_SEQAR_COUNT_CHILDREN 2
void seq_free_sequence(struct Sequence *seq);
void seq_free_editing(struct Editing *ed);
/* sequence iterator */
@ -49,16 +55,21 @@ typedef struct SeqIterator {
int valid;
} SeqIterator;
void seq_begin(struct Editing *ed, SeqIterator *iter);
void seq_begin(struct Editing *ed, SeqIterator *iter, int use_pointer);
void seq_next(SeqIterator *iter);
void seq_end(SeqIterator *iter);
void seq_array(struct Editing *ed, struct Sequence ***seqarray, int *tot, int use_pointer);
void seq_array(struct Editing *ed, struct Sequence ***array, int *tot);
#define SEQP_BEGIN(ed, seq) \
{ \
SeqIterator iter;\
for(seq_begin(ed, &iter, 1); iter.valid; seq_next(&iter)) { \
seq= iter.seq;
#define SEQ_BEGIN(ed, seq) \
{ \
SeqIterator iter;\
for(seq_begin(ed, &iter); iter.valid; seq_next(&iter)) { \
for(seq_begin(ed, &iter, 0); iter.valid; seq_next(&iter)) { \
seq= iter.seq;
#define SEQ_END \
@ -68,3 +79,89 @@ void seq_array(struct Editing *ed, struct Sequence ***array, int *tot);
#endif
/* Wipe effect */
enum {DO_SINGLE_WIPE, DO_DOUBLE_WIPE, DO_BOX_WIPE, DO_CROSS_WIPE,
DO_IRIS_WIPE,DO_CLOCK_WIPE};
struct SeqEffectHandle {
/* constructors & destructor */
/* init & init_plugin are _only_ called on first creation */
void (*init)(struct Sequence *seq);
void (*init_plugin)(struct Sequence *seq, const char *fname);
/* number of input strips needed
(called directly after construction) */
int (*num_inputs)();
/* load is called first time after readblenfile in
get_sequence_effect automatically */
void (*load)(struct Sequence *seq);
/* duplicate */
void (*copy)(struct Sequence *dst, struct Sequence *src);
/* destruct */
void (*free)(struct Sequence *seq);
/* returns: -1: no input needed,
0: no early out,
1: out = ibuf1,
2: out = ibuf2 */
int (*early_out)(struct Sequence *seq,
float facf0, float facf1);
/* stores the y-range of the effect IPO */
void (*store_icu_yrange)(struct Sequence * seq,
short adrcode, float *ymin, float *ymax);
/* stores the default facf0 and facf1 if no IPO is present */
void (*get_default_fac)(struct Sequence *seq, int cfra,
float * facf0, float * facf1);
/* execute the effect
sequence effects are only required to either support
float-rects or byte-rects
(mixed cases are handled one layer up...) */
void (*execute)(struct Sequence *seq, int cfra,
float facf0, float facf1,
int x, int y,
struct ImBuf *ibuf1, struct ImBuf *ibuf2,
struct ImBuf *ibuf3, struct ImBuf *out);
};
/* ********************* prototypes *************** */
/* sequence.c */
// extern
void seq_free_sequence(struct Sequence *seq);
void seq_free_strip(struct Strip *strip);
void seq_free_editing(struct Editing *ed);
char *give_seqname(struct Sequence *seq);
struct ImBuf *give_ibuf_seq(struct Scene *scene, int rectx, int recty, int cfra, int chanshown);
struct ImBuf *give_ibuf_seq_threaded(struct Scene *scene, int rectx, int recty, int cfra, int chanshown);
struct ImBuf *give_ibuf_seq_direct(struct Scene *scene, int rectx, int recty, int cfra, struct Sequence *seq);
void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown);
void calc_sequence(struct Sequence *seq);
void new_tstripdata(struct Sequence *seq);
void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq);
void sort_seq(struct Scene *scene);
void build_seqar_cb(struct ListBase *seqbase, struct Sequence ***seqar, int *totseq,
int (*test_func)(struct Sequence * seq));
int evaluate_seq_frame(struct Scene *scene, int cfra);
struct StripElem *give_stripelem(struct Sequence *seq, int cfra);
// intern?
void update_changed_seq_and_deps(struct Scene *scene, struct Sequence *changed_seq, int len_change, int ibuf_change);
/* seqeffects.c */
// intern?
struct SeqEffectHandle get_sequence_blend(struct Sequence *seq);
void sequence_effect_speed_rebuild_map(struct Scene *scene, struct Sequence *seq, int force);
// extern
struct SeqEffectHandle get_sequence_effect(struct Sequence *seq);
int get_sequence_effect_num_inputs(int seq_type);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -218,7 +218,7 @@ static struct Sequence *seq_stepdata__internal(struct BPathIterator *bpi, int st
if (bpi->seqdata.scene->ed) {
if (bpi->seqdata.seqar == NULL) {
/* allocate the sequencer array */
seq_array(bpi->seqdata.scene->ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq);
seq_array(bpi->seqdata.scene->ed, &bpi->seqdata.seqar, &bpi->seqdata.totseq, 0);
bpi->seqdata.seq = 0;
}

View File

@ -1522,9 +1522,11 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v
fac += 0.5f * dfac;
/* draw vertical steps */
for (; fac < vert.ymax; fac+= dfac, val += grid->dy) {
scroll_printstr(vs, scene, (float)(vert.xmax)-14.0f, fac, val, grid->powery, vs->yunits, 'v');
}
if (dfac != 0.0f) {
for (; fac < vert.ymax; fac+= dfac, val += grid->dy) {
scroll_printstr(vs, scene, (float)(vert.xmax)-14.0f, fac, val, grid->powery, vs->yunits, 'v');
}
}
}
/* decoration outer bevel line */

View File

@ -38,6 +38,8 @@ CFLAGS += $(LEVEL_1_C_WARNINGS)
CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_BMFONT)/include
# not very neat....
CPPFLAGS += -I../../windowmanager
CPPFLAGS += -I../../blenloader

View File

@ -5,5 +5,6 @@ sources = env.Glob('*.c')
incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
incs += ' #intern/bmfont'
env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] )

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -28,14 +28,36 @@
#ifndef ED_SEQUENCER_INTERN_H
#define ED_SEQUENCER_INTERN_H
#define MAXSEQ 32
/* internal exports only */
struct Sequence;
struct bContext;
struct rctf;
struct SpaceSeq;
struct ARegion;
struct Scene;
#define SEQ_ZOOM_FAC(szoom) (szoom > 0)? (szoom) : (szoom == 0)? (1.0) : (-1.0/szoom)
/* sequencer_header.c */
void sequencer_header_buttons(const bContext *C, ARegion *ar);
void sequencer_header_buttons(const struct bContext *C, struct ARegion *ar);
/* sequencer_draw.c */
void drawseqspace(const struct bContext *C, struct ARegion *ar);
/* sequencer_edit.c */
int check_single_seq(struct Sequence *seq);
int seq_tx_get_final_left(struct Sequence *seq, int metaclip);
int seq_tx_get_final_right(struct Sequence *seq, int metaclip);
void boundbox_seq(struct Scene *scene, struct rctf *rect);
struct Sequence *get_last_seq(struct Scene *scene);
/* sequencer_scope.c */
struct ImBuf *make_waveform_view_from_ibuf(struct ImBuf * ibuf);
struct ImBuf *make_sep_waveform_view_from_ibuf(struct ImBuf * ibuf);
struct ImBuf *make_vectorscope_view_from_ibuf(struct ImBuf * ibuf);
struct ImBuf *make_zebra_view_from_ibuf(struct ImBuf * ibuf, float perc);
struct ImBuf *make_histogram_view_from_ibuf(struct ImBuf * ibuf);
#endif /* ED_SEQUENCER_INTERN_H */

View File

@ -0,0 +1,701 @@
/**
* $Id$
*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Author: Peter Schlaile < peter [at] schlaile [dot] de >
*
* ***** END GPL LICENSE BLOCK *****
*
*/
#include <math.h>
#include <string.h>
#include "BKE_utildefines.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "sequencer_intern.h"
static void rgb_to_yuv(float rgb[3], float yuv[3])
{
yuv[0]= 0.299*rgb[0] + 0.587*rgb[1] + 0.114*rgb[2];
yuv[1]= 0.492*(rgb[2] - yuv[0]);
yuv[2]= 0.877*(rgb[0] - yuv[0]);
/* Normalize */
yuv[1]*= 255.0/(122*2.0);
yuv[1]+= 0.5;
yuv[2]*= 255.0/(157*2.0);
yuv[2]+= 0.5;
}
static void scope_put_pixel(unsigned char* table, unsigned char * pos)
{
char newval = table[*pos];
pos[0] = pos[1] = pos[2] = newval;
pos[3] = 255;
}
static void scope_put_pixel_single(unsigned char* table, unsigned char * pos,
int col)
{
char newval = table[pos[col]];
pos[col] = newval;
pos[3] = 255;
}
static void wform_put_line(int w,
unsigned char * last_pos, unsigned char * new_pos)
{
if (last_pos > new_pos) {
unsigned char* temp = new_pos;
new_pos = last_pos;
last_pos = temp;
}
while (last_pos < new_pos) {
if (last_pos[0] == 0) {
last_pos[0] = last_pos[1] = last_pos[2] = 32;
last_pos[3] = 255;
}
last_pos += 4*w;
}
}
static void wform_put_line_single(
int w, unsigned char * last_pos, unsigned char * new_pos, int col)
{
if (last_pos > new_pos) {
unsigned char* temp = new_pos;
new_pos = last_pos;
last_pos = temp;
}
while (last_pos < new_pos) {
if (last_pos[col] == 0) {
last_pos[col] = 32;
last_pos[3] = 255;
}
last_pos += 4*w;
}
}
static void wform_put_border(unsigned char * tgt, int w, int h)
{
int x, y;
for (x = 0; x < w; x++) {
unsigned char * p = tgt + 4 * x;
p[1] = p[3] = 255.0;
p[4 * w + 1] = p[4 * w + 3] = 255.0;
p = tgt + 4 * (w * (h - 1) + x);
p[1] = p[3] = 255.0;
p[-4 * w + 1] = p[-4 * w + 3] = 255.0;
}
for (y = 0; y < h; y++) {
unsigned char * p = tgt + 4 * w * y;
p[1] = p[3] = 255.0;
p[4 + 1] = p[4 + 3] = 255.0;
p = tgt + 4 * (w * y + w - 1);
p[1] = p[3] = 255.0;
p[-4 + 1] = p[-4 + 3] = 255.0;
}
}
static void wform_put_gridrow(unsigned char * tgt, float perc, int w, int h)
{
int i;
tgt += (int) (perc/100.0 * h) * w * 4;
for (i = 0; i < w*2; i++) {
tgt[0] = 255;
tgt += 4;
}
}
static void wform_put_grid(unsigned char * tgt, int w, int h)
{
wform_put_gridrow(tgt, 90.0, w, h);
wform_put_gridrow(tgt, 70.0, w, h);
wform_put_gridrow(tgt, 10.0, w, h);
}
static struct ImBuf *make_waveform_view_from_ibuf_byte(struct ImBuf * ibuf)
{
struct ImBuf * rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect, 0);
int x,y;
unsigned char* src = (unsigned char*) ibuf->rect;
unsigned char* tgt = (unsigned char*) rval->rect;
int w = ibuf->x + 3;
int h = 515;
float waveform_gamma = 0.2;
unsigned char wtable[256];
wform_put_grid(tgt, w, h);
for (x = 0; x < 256; x++) {
wtable[x] = (unsigned char) (pow(((float) x + 1)/256,
waveform_gamma)*255);
}
for (y = 0; y < ibuf->y; y++) {
unsigned char * last_p = 0;
for (x = 0; x < ibuf->x; x++) {
unsigned char * rgb = src + 4 * (ibuf->x * y + x);
float v = 1.0 *
( 0.299*rgb[0]
+ 0.587*rgb[1]
+ 0.114*rgb[2]) / 255.0;
unsigned char * p = tgt;
p += 4 * (w * ((int) (v * (h - 3)) + 1) + x + 1);
scope_put_pixel(wtable, p);
p += 4 * w;
scope_put_pixel(wtable, p);
if (last_p != 0) {
wform_put_line(w, last_p, p);
}
last_p = p;
}
}
wform_put_border(tgt, w, h);
return rval;
}
static struct ImBuf *make_waveform_view_from_ibuf_float(struct ImBuf * ibuf)
{
struct ImBuf * rval = IMB_allocImBuf(ibuf->x + 3, 515, 32, IB_rect, 0);
int x,y;
float* src = ibuf->rect_float;
unsigned char* tgt = (unsigned char*) rval->rect;
int w = ibuf->x + 3;
int h = 515;
float waveform_gamma = 0.2;
unsigned char wtable[256];
wform_put_grid(tgt, w, h);
for (x = 0; x < 256; x++) {
wtable[x] = (unsigned char) (pow(((float) x + 1)/256,
waveform_gamma)*255);
}
for (y = 0; y < ibuf->y; y++) {
unsigned char * last_p = 0;
for (x = 0; x < ibuf->x; x++) {
float * rgb = src + 4 * (ibuf->x * y + x);
float v = 1.0 *
( 0.299*rgb[0]
+ 0.587*rgb[1]
+ 0.114*rgb[2]);
unsigned char * p = tgt;
CLAMP(v, 0.0, 1.0);
p += 4 * (w * ((int) (v * (h - 3)) + 1) + x + 1);
scope_put_pixel(wtable, p);
p += 4 * w;
scope_put_pixel(wtable, p);
if (last_p != 0) {
wform_put_line(w, last_p, p);
}
last_p = p;
}
}
wform_put_border(tgt, w, h);
return rval;
}
struct ImBuf *make_waveform_view_from_ibuf(struct ImBuf * ibuf)
{
if (ibuf->rect_float) {
return make_waveform_view_from_ibuf_float(ibuf);
} else {
return make_waveform_view_from_ibuf_byte(ibuf);
}
}
static struct ImBuf *make_sep_waveform_view_from_ibuf_byte(struct ImBuf * ibuf)
{
struct ImBuf * rval = IMB_allocImBuf(
ibuf->x + 3, 515, 32, IB_rect, 0);
int x,y;
unsigned char* src = (unsigned char*) ibuf->rect;
unsigned char* tgt = (unsigned char*) rval->rect;
int w = ibuf->x + 3;
int sw = ibuf->x/3;
int h = 515;
float waveform_gamma = 0.2;
unsigned char wtable[256];
wform_put_grid(tgt, w, h);
for (x = 0; x < 256; x++) {
wtable[x] = (unsigned char) (pow(((float) x + 1)/256,
waveform_gamma)*255);
}
for (y = 0; y < ibuf->y; y++) {
unsigned char * last_p[3] = {0,0,0};
for (x = 0; x < ibuf->x; x++) {
int c;
unsigned char * rgb = src + 4 * (ibuf->x * y + x);
for (c = 0; c < 3; c++) {
unsigned char * p = tgt;
p += 4 * (w * ((rgb[c] * (h - 3))/255 + 1)
+ c * sw + x/3 + 1);
scope_put_pixel_single(wtable, p, c);
p += 4 * w;
scope_put_pixel_single(wtable, p, c);
if (last_p[c] != 0) {
wform_put_line_single(
w, last_p[c], p, c);
}
last_p[c] = p;
}
}
}
wform_put_border(tgt, w, h);
return rval;
}
static struct ImBuf *make_sep_waveform_view_from_ibuf_float(
struct ImBuf * ibuf)
{
struct ImBuf * rval = IMB_allocImBuf(
ibuf->x + 3, 515, 32, IB_rect, 0);
int x,y;
float* src = ibuf->rect_float;
unsigned char* tgt = (unsigned char*) rval->rect;
int w = ibuf->x + 3;
int sw = ibuf->x/3;
int h = 515;
float waveform_gamma = 0.2;
unsigned char wtable[256];
wform_put_grid(tgt, w, h);
for (x = 0; x < 256; x++) {
wtable[x] = (unsigned char) (pow(((float) x + 1)/256,
waveform_gamma)*255);
}
for (y = 0; y < ibuf->y; y++) {
unsigned char * last_p[3] = {0, 0, 0};
for (x = 0; x < ibuf->x; x++) {
int c;
float * rgb = src + 4 * (ibuf->x * y + x);
for (c = 0; c < 3; c++) {
unsigned char * p = tgt;
float v = rgb[c];
CLAMP(v, 0.0, 1.0);
p += 4 * (w * ((int) (v * (h - 3)) + 1)
+ c * sw + x/3 + 1);
scope_put_pixel_single(wtable, p, c);
p += 4 * w;
scope_put_pixel_single(wtable, p, c);
if (last_p[c] != 0) {
wform_put_line_single(
w, last_p[c], p, c);
}
last_p[c] = p;
}
}
}
wform_put_border(tgt, w, h);
return rval;
}
struct ImBuf *make_sep_waveform_view_from_ibuf(struct ImBuf * ibuf)
{
if (ibuf->rect_float) {
return make_sep_waveform_view_from_ibuf_float(ibuf);
} else {
return make_sep_waveform_view_from_ibuf_byte(ibuf);
}
}
static void draw_zebra_byte(struct ImBuf * src,struct ImBuf * ibuf, float perc)
{
unsigned int limit = 255 * perc / 100.0;
unsigned char * p = (unsigned char*) src->rect;
unsigned char * o = (unsigned char*) ibuf->rect;
int x;
int y;
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
unsigned char r = *p++;
unsigned char g = *p++;
unsigned char b = *p++;
unsigned char a = *p++;
if (r >= limit || g >= limit || b >= limit) {
if (((x + y) & 0x08) != 0) {
r = 255 - r;
g = 255 - g;
b = 255 - b;
}
}
*o++ = r;
*o++ = g;
*o++ = b;
*o++ = a;
}
}
}
static void draw_zebra_float(struct ImBuf * src,struct ImBuf * ibuf,float perc)
{
float limit = perc / 100.0;
float * p = src->rect_float;
unsigned char * o = (unsigned char*) ibuf->rect;
int x;
int y;
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
float r = *p++;
float g = *p++;
float b = *p++;
float a = *p++;
if (r >= limit || g >= limit || b >= limit) {
if (((x + y) & 0x08) != 0) {
r = -r;
g = -g;
b = -b;
}
}
*o++ = FTOCHAR(r);
*o++ = FTOCHAR(g);
*o++ = FTOCHAR(b);
*o++ = FTOCHAR(a);
}
}
}
struct ImBuf * make_zebra_view_from_ibuf(struct ImBuf * src, float perc)
{
struct ImBuf * ibuf = IMB_allocImBuf(src->x, src->y, 32, IB_rect, 0);
if (src->rect_float) {
draw_zebra_float(src, ibuf, perc);
} else {
draw_zebra_byte(src, ibuf, perc);
}
return ibuf;
}
static void draw_histogram_marker(struct ImBuf * ibuf, int x)
{
unsigned char * p = (unsigned char*) ibuf->rect;
int barh = ibuf->y * 0.1;
int i;
p += 4 * (x + ibuf->x * (ibuf->y - barh + 1));
for (i = 0; i < barh-1; i++) {
p[0] = p[1] = p[2] = 255;
p += ibuf->x * 4;
}
}
static void draw_histogram_bar(struct ImBuf * ibuf, int x,float val, int col)
{
unsigned char * p = (unsigned char*) ibuf->rect;
int barh = ibuf->y * val * 0.9;
int i;
p += 4 * (x + ibuf->x);
for (i = 0; i < barh; i++) {
p[col] = 255;
p += ibuf->x * 4;
}
}
static struct ImBuf *make_histogram_view_from_ibuf_byte(
struct ImBuf * ibuf)
{
struct ImBuf * rval = IMB_allocImBuf(515, 128, 32, IB_rect, 0);
int n,c,x,y;
unsigned char* src = (unsigned char*) ibuf->rect;
unsigned int bins[3][256];
memset(bins, 0, 3 * 256* sizeof(unsigned int));
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
bins[0][*src++]++;
bins[1][*src++]++;
bins[2][*src++]++;
src++;
}
}
n = 0;
for (c = 0; c < 3; c++) {
for (x = 0; x < 256; x++) {
if (bins[c][x] > n) {
n = bins[c][x];
}
}
}
for (c = 0; c < 3; c++) {
for (x = 0; x < 256; x++) {
draw_histogram_bar(rval, x*2+1,
((float) bins[c][x])/n, c);
draw_histogram_bar(rval, x*2+2,
((float) bins[c][x])/n, c);
}
}
wform_put_border((unsigned char*) rval->rect, rval->x, rval->y);
return rval;
}
static int get_bin_float(float f)
{
if (f < -0.25) {
f = -0.25;
} else if (f > 1.25) {
f = 1.25;
}
return (int) (((f + 0.25) / 1.5) * 512);
}
static struct ImBuf *make_histogram_view_from_ibuf_float(
struct ImBuf * ibuf)
{
struct ImBuf * rval = IMB_allocImBuf(515, 128, 32, IB_rect, 0);
int n,c,x,y;
float* src = ibuf->rect_float;
unsigned int bins[3][512];
memset(bins, 0, 3 * 256* sizeof(unsigned int));
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
bins[0][get_bin_float(*src++)]++;
bins[1][get_bin_float(*src++)]++;
bins[2][get_bin_float(*src++)]++;
src++;
}
}
draw_histogram_marker(rval, get_bin_float(0.0));
draw_histogram_marker(rval, get_bin_float(1.0));
n = 0;
for (c = 0; c < 3; c++) {
for (x = 0; x < 512; x++) {
if (bins[c][x] > n) {
n = bins[c][x];
}
}
}
for (c = 0; c < 3; c++) {
for (x = 0; x < 512; x++) {
draw_histogram_bar(rval, x+1, (float) bins[c][x]/n, c);
}
}
wform_put_border((unsigned char*) rval->rect, rval->x, rval->y);
return rval;
}
struct ImBuf *make_histogram_view_from_ibuf(struct ImBuf * ibuf)
{
if (ibuf->rect_float) {
return make_histogram_view_from_ibuf_float(ibuf);
} else {
return make_histogram_view_from_ibuf_byte(ibuf);
}
}
static void vectorscope_put_cross(unsigned char r, unsigned char g,
unsigned char b,
char * tgt, int w, int h, int size)
{
float rgb[3], yuv[3];
char * p;
int x = 0;
int y = 0;
rgb[0]= (float)r/255.0;
rgb[1]= (float)g/255.0;
rgb[2]= (float)b/255.0;
rgb_to_yuv(rgb, yuv);
p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1))
+ (int) ((yuv[1] * (w - 3) + 1)));
if (r == 0 && g == 0 && b == 0) {
r = 255;
}
for (y = -size; y <= size; y++) {
for (x = -size; x <= size; x++) {
char * q = p + 4 * (y * w + x);
q[0] = r; q[1] = g; q[2] = b; q[3] = 255;
}
}
}
static struct ImBuf *make_vectorscope_view_from_ibuf_byte(struct ImBuf * ibuf)
{
struct ImBuf * rval = IMB_allocImBuf(515, 515, 32, IB_rect, 0);
int x,y;
char* src = (char*) ibuf->rect;
char* tgt = (char*) rval->rect;
float rgb[3], yuv[3];
int w = 515;
int h = 515;
float scope_gamma = 0.2;
unsigned char wtable[256];
for (x = 0; x < 256; x++) {
wtable[x] = (unsigned char) (pow(((float) x + 1)/256,
scope_gamma)*255);
}
for (x = 0; x <= 255; x++) {
vectorscope_put_cross(255 , 0,255 - x, tgt, w, h, 1);
vectorscope_put_cross(255 , x, 0, tgt, w, h, 1);
vectorscope_put_cross(255- x, 255, 0, tgt, w, h, 1);
vectorscope_put_cross(0, 255, x, tgt, w, h, 1);
vectorscope_put_cross(0, 255 - x, 255, tgt, w, h, 1);
vectorscope_put_cross(x, 0, 255, tgt, w, h, 1);
}
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
char * src1 = src + 4 * (ibuf->x * y + x);
char * p;
rgb[0]= (float)src1[0]/255.0;
rgb[1]= (float)src1[1]/255.0;
rgb[2]= (float)src1[2]/255.0;
rgb_to_yuv(rgb, yuv);
p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1))
+ (int) ((yuv[1] * (w - 3) + 1)));
scope_put_pixel(wtable, (unsigned char*)p);
}
}
vectorscope_put_cross(0, 0, 0, tgt, w, h, 3);
return rval;
}
static struct ImBuf *make_vectorscope_view_from_ibuf_float(struct ImBuf * ibuf)
{
struct ImBuf * rval = IMB_allocImBuf(515, 515, 32, IB_rect, 0);
int x,y;
float* src = ibuf->rect_float;
char* tgt = (char*) rval->rect;
float rgb[3], yuv[3];
int w = 515;
int h = 515;
float scope_gamma = 0.2;
unsigned char wtable[256];
for (x = 0; x < 256; x++) {
wtable[x] = (unsigned char) (pow(((float) x + 1)/256,
scope_gamma)*255);
}
for (x = 0; x <= 255; x++) {
vectorscope_put_cross(255 , 0,255 - x, tgt, w, h, 1);
vectorscope_put_cross(255 , x, 0, tgt, w, h, 1);
vectorscope_put_cross(255- x, 255, 0, tgt, w, h, 1);
vectorscope_put_cross(0, 255, x, tgt, w, h, 1);
vectorscope_put_cross(0, 255 - x, 255, tgt, w, h, 1);
vectorscope_put_cross(x, 0, 255, tgt, w, h, 1);
}
for (y = 0; y < ibuf->y; y++) {
for (x = 0; x < ibuf->x; x++) {
float * src1 = src + 4 * (ibuf->x * y + x);
char * p;
memcpy(rgb, src1, 3 * sizeof(float));
CLAMP(rgb[0], 0.0, 1.0);
CLAMP(rgb[1], 0.0, 1.0);
CLAMP(rgb[2], 0.0, 1.0);
rgb_to_yuv(rgb, yuv);
p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1))
+ (int) ((yuv[1] * (w - 3) + 1)));
scope_put_pixel(wtable, (unsigned char*)p);
}
}
vectorscope_put_cross(0, 0, 0, tgt, w, h, 3);
return rval;
}
struct ImBuf *make_vectorscope_view_from_ibuf(struct ImBuf * ibuf)
{
if (ibuf->rect_float) {
return make_vectorscope_view_from_ibuf_float(ibuf);
} else {
return make_vectorscope_view_from_ibuf_byte(ibuf);
}
}

View File

@ -43,6 +43,7 @@
#include "BKE_colortools.h"
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_sequence.h"
#include "ED_space_api.h"
#include "ED_screen.h"
@ -111,8 +112,6 @@ static SpaceLink *sequencer_new(const bContext *C)
ar->v2d.keepzoom= 0;
ar->v2d.keeptot= 0;
return (SpaceLink *)sseq;
}
@ -156,28 +155,6 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar)
WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
}
static void sequencer_main_area_draw(const bContext *C, ARegion *ar)
{
/* draw entirely, view changes should be handled here */
// SpaceSeq *sseq= (SpaceSeq*)CTX_wm_space_data(C);
View2D *v2d= &ar->v2d;
float col[3];
/* clear and setup matrix */
UI_GetThemeColor3fv(TH_BACK, col);
glClearColor(col[0], col[1], col[2], 0.0);
glClear(GL_COLOR_BUFFER_BIT);
UI_view2d_view_ortho(C, v2d);
/* data... */
/* reset view matrix */
UI_view2d_view_restore(C);
/* scrollers? */
}
void sequencer_operatortypes(void)
{
@ -241,7 +218,7 @@ void ED_spacetype_sequencer(void)
art= MEM_callocN(sizeof(ARegionType), "spacetype sequencer region");
art->regionid = RGN_TYPE_WINDOW;
art->init= sequencer_main_area_init;
art->draw= sequencer_main_area_draw;
art->draw= drawseqspace;
art->listener= sequencer_main_area_listener;
art->keymapflag= ED_KEYMAP_VIEW2D;