add_subwindow(new HighlightInverseColor(pwindow, x, y, hex_color));
y += 35;
+ x = x0;
+ add_subwindow(title = new BC_Title(x, y, _("YUV color space:")));
+ x += title->get_w() + margin;
+ add_subwindow(yuv_color_space = new YuvColorSpace(x, y, pwindow));
+ yuv_color_space->create_objects();
+ y += yuv_color_space->get_h() + 5;
+
+ x = x0;
+ add_subwindow(title = new BC_Title(x, y, _("YUV color range:")));
+ x += title->get_w() + margin;
+ add_subwindow(yuv_color_range = new YuvColorRange(x, y, pwindow));
+ yuv_color_range->create_objects();
+ y += yuv_color_range->get_h() + 5;
+
UseTipWindow *tip_win = new UseTipWindow(pwindow, x1, y1);
add_subwindow(tip_win);
y1 += tip_win->get_h() + 5;
return 1;
}
+
+const char *YuvColorSpace::color_space[] = {
+ N_("BT601"),
+ N_("BT709"),
+};
+
+YuvColorSpace::YuvColorSpace(int x, int y, PreferencesWindow *pwindow)
+ : BC_PopupMenu(x, y, 100,
+ _(color_space[pwindow->thread->preferences->yuv_color_space]), 1)
+{
+ this->pwindow = pwindow;
+}
+YuvColorSpace::~YuvColorSpace()
+{
+}
+
+void YuvColorSpace::create_objects()
+{
+ for( int id=0,nid=sizeof(color_space)/sizeof(color_space[0]); id<nid; ++id )
+ add_item(new YuvColorSpaceItem(this, _(color_space[id]), id));
+ handle_event();
+}
+
+int YuvColorSpace::handle_event()
+{
+ set_text(color_space[pwindow->thread->preferences->yuv_color_space]);
+ return 1;
+}
+
+YuvColorSpaceItem::YuvColorSpaceItem(YuvColorSpace *popup, const char *text, int id)
+ : BC_MenuItem(text)
+{
+ this->popup = popup;
+ this->id = id;
+}
+
+int YuvColorSpaceItem::handle_event()
+{
+ popup->set_text(get_text());
+ popup->pwindow->thread->preferences->yuv_color_space = id;
+ return popup->handle_event();
+}
+
+
+const char *YuvColorRange::color_range[] = {
+ N_("JPEG"),
+ N_("MPEG"),
+};
+
+YuvColorRange::YuvColorRange(int x, int y, PreferencesWindow *pwindow)
+ : BC_PopupMenu(x, y, 100,
+ _(color_range[pwindow->thread->preferences->yuv_color_range]), 1)
+{
+ this->pwindow = pwindow;
+}
+YuvColorRange::~YuvColorRange()
+{
+}
+
+void YuvColorRange::create_objects()
+{
+ for( int id=0,nid=sizeof(color_range)/sizeof(color_range[0]); id<nid; ++id )
+ add_item(new YuvColorRangeItem(this, _(color_range[id]), id));
+ handle_event();
+}
+
+int YuvColorRange::handle_event()
+{
+ set_text(color_range[pwindow->thread->preferences->yuv_color_range]);
+ return 1;
+}
+
+YuvColorRangeItem::YuvColorRangeItem(YuvColorRange *popup, const char *text, int id)
+ : BC_MenuItem(text)
+{
+ this->popup = popup;
+ this->id = id;
+}
+
+int YuvColorRangeItem::handle_event()
+{
+ popup->set_text(get_text());
+ popup->pwindow->thread->preferences->yuv_color_range = id;
+ return popup->handle_event();
+}
+
TimeFormatFeet *feet;
TimeFormatSeconds *seconds;
ViewThumbnails *thumbnails;
+ YuvColorSpace *yuv_color_space;
+ YuvColorRange *yuv_color_range;
};
PreferencesWindow *pwindow;
};
+class YuvColorSpace : public BC_PopupMenu
+{
+ static const char *color_space[2];
+public:
+ YuvColorSpace(int x, int y, PreferencesWindow *pwindow);
+ ~YuvColorSpace();
+
+ void create_objects();
+ int handle_event();
+
+ PreferencesWindow *pwindow;
+};
+
+class YuvColorSpaceItem : public BC_MenuItem
+{
+public:
+ YuvColorSpaceItem(YuvColorSpace *popup, const char *text, int id);
+ int handle_event();
+ YuvColorSpace *popup;
+ int id;
+};
+
+class YuvColorRange : public BC_PopupMenu
+{
+ static const char *color_range[2];
+public:
+ YuvColorRange(int x, int y, PreferencesWindow *pwindow);
+ ~YuvColorRange();
+
+ void create_objects();
+ int handle_event();
+
+ PreferencesWindow *pwindow;
+};
+
+class YuvColorRangeItem : public BC_MenuItem
+{
+public:
+ YuvColorRangeItem(YuvColorRange *popup, const char *text, int id);
+ int handle_event();
+ YuvColorRange *popup;
+ int id;
+};
+
#endif
class PopupMenuBtnup;
class ActivateFocusPolicy;
class DeactivateFocusPolicy;
+class ForwardRenderDisplacement;
+class HighlightInverseColor;
+class YuvColorSpace;
+class YuvColorSpaceItem;
+class YuvColorRange;
+class YuvColorRangeItem;
#endif
void ColorWindow::update_rgb(float r, float g, float b)
{
{ float y, u, v;
- YUV::rgb_to_yuv_f(r, g, b, y, u, v);
+ YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v);
u += 0.5; v += 0.5;
bclamp(y, 0, 1); yuv.y = y;
bclamp(u, 0, 1); yuv.u = u;
{
u -= 0.5; v -= 0.5;
{ float r, g, b;
- YUV::yuv_to_rgb_f(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v);
bclamp(r, 0, 1); rgb.r = r;
bclamp(g, 0, 1); rgb.g = g;
bclamp(b, 0, 1); rgb.b = b;
bclamp(g, 0, 1); rgb.g = g;
bclamp(b, 0, 1); rgb.b = b;
float y, u, v;
- YUV::rgb_to_yuv_f(r, g, b, y, u, v);
+ YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v);
u += 0.5; v += 0.5;
bclamp(y, 0, 1); yuv.y = y;
bclamp(u, 0, 1); yuv.u = u;
CWrapper(overwrite_selection)
CWrapper(set_inpoint)
CWrapper(set_outpoint)
-CWrapper(clear_inpoint)
-CWrapper(clear_outpoint)
+CWrapper(unset_inoutpoint)
CWrapper(toggle_label)
CWrapper(prev_label)
CWrapper(next_label)
void overwrite_selection();
void set_inpoint();
void set_outpoint();
- void clear_inpoint();
- void clear_outpoint();
+ void unset_inoutpoint();
void to_clip();
void toggle_label();
void prev_label();
rgb_hex->update(rgb_text);
float y, u, v;
- YUV::rgb_to_yuv_f(r, g, b, y, u, v);
+ YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v);
this->y->update(y);
this->u->update(u); u += 0.5;
this->v->update(v); v += 0.5;
temp_keyframe.copy_data(keyframe);
// Update parameter
SubMask *submask = temp_keyframe.get_submask(mwindow->edl->session->cwindow_mask);
+ if( shift_down() )
+ submask->points.remove_all_objects();
+
for(int i = mwindow->cwindow->gui->affected_point;
i < submask->points.total - 1;
i++)
current; )
{
SubMask *submask = current->get_submask(mwindow->edl->session->cwindow_mask);
+ if( shift_down() )
+ submask->points.remove_all_objects();
for(int i = mwindow->cwindow->gui->affected_point;
i < submask->points.total - 1;
mwindow->set_outpoint(1);
}
-void EditPanel::clear_inpoint()
+void EditPanel::unset_inoutpoint()
{
- mwindow->delete_inpoint();
-}
-
-void EditPanel::clear_outpoint()
-{
- mwindow->delete_outpoint();
+ mwindow->unset_inoutpoint(1);
}
panel->set_inpoint();
return 1;
}
+ if(ctrl_down() && get_keypress() == 't')
+ {
+ panel->unset_inoutpoint();
+ return 1;
+ }
return 0;
}
panel->set_outpoint();
return 1;
}
+ if(ctrl_down() && get_keypress() == 't')
+ {
+ panel->unset_inoutpoint();
+ return 1;
+ }
return 0;
}
virtual void overwrite_selection();
virtual void set_inpoint();
virtual void set_outpoint();
- virtual void clear_inpoint();
- virtual void clear_outpoint();
+ virtual void unset_inoutpoint();
virtual void to_clip() = 0;
virtual void toggle_label();
virtual void prev_label();
}
}
+void EDL::unset_inoutpoint()
+{
+ local_session->unset_inpoint();
+ local_session->unset_outpoint();
+}
+
int EDL::blade(double position)
{
return tracks->blade(position);
// Set points and labels
void set_inpoint(double position);
void set_outpoint(double position);
+ void unset_inoutpoint();
// Redraw resources during index builds
void set_index_file(Indexable *indexable);
// Add assets from the src to the destination
return ffvideo[stream]->st->id;
}
+int FFMPEG::ff_video_mpeg_color_range(int stream)
+{
+ return ffvideo[stream]->st->codecpar->color_range == AVCOL_RANGE_MPEG ? 1 : 0;
+}
int FFMPEG::ff_cpus()
{
const char *ff_video_format(int stream);
int64_t ff_video_frames(int stream);
int ff_video_pid(int stream);
+ int ff_video_mpeg_color_range(int stream);
int ff_cpus();
void dump_context(AVCodecContext *ctx);
}
-
-
-
-int File::get_best_colormodel(int driver)
+int File::get_best_colormodel(int driver, int vstream)
{
- return get_best_colormodel(asset, driver);
+ return file ? file->get_best_colormodel(driver, vstream) :
+ get_best_colormodel(asset, driver);
}
int File::get_best_colormodel(Asset *asset, int driver)
// allocated.
// Get best colormodel to translate for hardware accelerated playback.
// Called by VRender.
- int get_best_colormodel(int driver);
+ int get_best_colormodel(int driver, int vstream=-1);
// Get best colormodel for hardware accelerated recording.
// Called by VideoDevice.
static int get_best_colormodel(Asset *asset, int driver);
}
}
+int FileBase::get_best_colormodel(int driver, int vstream)
+{
+ return File::get_best_colormodel(asset, driver);
+}
+
// ======================================= audio codecs
virtual int check_header() { return 0; } // Test file to see if it is of this type.
virtual int reset_parameters_derived() { return 0; }
virtual int read_header() { return 1; } // WAV files for getting header
+ virtual int get_best_colormodel(int driver, int vstream);
+
virtual int open_file(int rd, int wr) { return 1; }
virtual int close_file();
virtual int close_file_derived() { return 0; }
return colormodel;
}
+
+int FileFFMPEG::get_best_colormodel(int driver, int vstream)
+{
+ if( vstream < 0 ) vstream = 0;
+ int is_mpeg = !ff ? 0 : ff->ff_video_mpeg_color_range(vstream);
+
+ switch(driver) {
+ case PLAYBACK_X11: return is_mpeg ? BC_YUV888 : BC_RGB888;
+ case PLAYBACK_X11_XV: return BC_YUV420P;
+ case PLAYBACK_X11_GL: return BC_RGB_FLOAT;
+ }
+
+ return BC_RGB888;
+}
+
int FileFFMPEG::get_best_colormodel(Asset *asset, int driver)
{
switch(driver) {
// the direct X11 color model requires scaling in the codec
- case PLAYBACK_X11: return BC_BGR8888;
-// case PLAYBACK_X11: return BC_RGB888;
- case PLAYBACK_X11_GL: return BC_RGB888;
+ case PLAYBACK_X11: return BC_RGB888;
+ case PLAYBACK_X11_XV: return BC_YUV420P;
+ case PLAYBACK_X11_GL: return BC_RGB_FLOAT;
}
return BC_YUV420P;
static void get_parameters(BC_WindowBase *parent_window,Asset *asset,
BC_WindowBase *&format_window,int audio_options,int video_options);
static int check_sig(Asset *asset);
+ int get_best_colormodel(int driver, int vstream);
int get_video_info(int track, int &pid, double &framerate,
int &width, int &height, char *title=0);
int get_audio_for_video(int vstream, int astream, int64_t &channel_mask);
file->set_layer(local_layer, 1);
file->set_video_position(local_position, 1);
int supported_colormodel =
- file->get_best_colormodel(PLAYBACK_ASYNCHRONOUS);
+ file->get_best_colormodel(PLAYBACK_ASYNCHRONOUS, local_layer);
if(debug) PRINT_TRACE
BC_WindowBase::get_resources()->popupmenu_btnup = preferences->popupmenu_btnup;
BC_WindowBase::get_resources()->textbox_focus_policy = preferences->textbox_focus_policy;
BC_WindowBase::get_resources()->grab_input_focus = preferences->grab_input_focus;
+ YUV::yuv.yuv_set_colors(preferences->yuv_color_space, preferences->yuv_color_range);
}
void MWindow::clean_indexes()
edl->session->proxy_use_scaler = 0;
edl->session->proxy_auto_scale = 0;
edl->local_session->preview_start = 0;
- edl->local_session->preview_end = edl->tracks->total_length();
+ edl->local_session->preview_end = 0;
edl->local_session->loop_playback = 0;
edl->local_session->set_selectionstart(0);
edl->local_session->set_selectionend(0);
static void create_defaults_path(char *string, const char *config_file);
void delete_folder(char *folder);
- void delete_inpoint();
- void delete_outpoint();
void delete_track();
void delete_track(Track *track);
void toggle_editing_mode();
void set_inpoint(int is_mwindow);
void set_outpoint(int is_mwindow);
+ void unset_inoutpoint(int is_mwindow);
void splice(EDL *source);
void toggle_loop_playback();
void trim_selection();
}
-void MWindow::delete_inpoint()
-{
- edl->local_session->unset_inpoint();
- save_backup();
-}
-
-void MWindow::delete_outpoint()
-{
- edl->local_session->unset_outpoint();
- save_backup();
-}
-
-
void MWindow::delete_track()
{
if( edl->tracks->last )
}
}
+void MWindow::unset_inoutpoint(int is_mwindow)
+{
+ undo->update_undo_before();
+ edl->unset_inoutpoint();
+ save_backup();
+ undo->update_undo_after(_("clear in/out"), LOAD_TIMEBAR);
+
+ if( !is_mwindow ) {
+ gui->lock_window("MWindow::unset_inoutpoint 1");
+ }
+ gui->update_timebar(1);
+ if( !is_mwindow ) {
+ gui->unlock_window();
+ }
+
+ if( is_mwindow ) {
+ cwindow->gui->lock_window("MWindow::unset_inoutpoint 2");
+ }
+ cwindow->gui->timebar->update(1);
+ if( is_mwindow ) {
+ cwindow->gui->unlock_window();
+ }
+}
+
void MWindow::splice(EDL *source)
{
FileXML file;
forward_render_displacement = 0;
dvd_yuv420p_interlace = 0;
highlight_inverse = 0xffffff;
+ yuv_color_space = 0; // bt601
+ yuv_color_range = 0; // jpeg
// Default brender asset
brender_asset = new Asset;
forward_render_displacement = that->forward_render_displacement;
dvd_yuv420p_interlace = that->dvd_yuv420p_interlace;
highlight_inverse = that->highlight_inverse;
+ yuv_color_space = that->yuv_color_space;
+ yuv_color_range = that->yuv_color_range;
renderfarm_nodes.remove_all_objects();
renderfarm_ports.remove_all();
renderfarm_enabled.remove_all();
forward_render_displacement = defaults->get("FORWARD_RENDER_DISPLACEMENT", forward_render_displacement);
dvd_yuv420p_interlace = defaults->get("DVD_YUV420P_INTERLACE", dvd_yuv420p_interlace);
highlight_inverse = defaults->get("HIGHLIGHT_INVERSE", highlight_inverse);
+ yuv_color_space = defaults->get("YUV_COLOR_SPACE", yuv_color_space);
+ yuv_color_range = defaults->get("YUV_COLOR_RANGE", yuv_color_range);
use_brender = defaults->get("USE_BRENDER", use_brender);
brender_fragment = defaults->get("BRENDER_FRAGMENT", brender_fragment);
cache_size = defaults->get("CACHE_SIZE", cache_size);
defaults->update("FORWARD_RENDER_DISPLACEMENT", forward_render_displacement);
defaults->update("DVD_YUV420P_INTERLACE", dvd_yuv420p_interlace);
defaults->update("HIGHLIGHT_INVERSE", highlight_inverse);
+ defaults->update("YUV_COLOR_SPACE", yuv_color_space);
+ defaults->update("YUV_COLOR_RANGE", yuv_color_range);
brender_asset->save_defaults(defaults, "BRENDER_", 1, 1, 1, 0, 0);
defaults->update("USE_BRENDER", use_brender);
defaults->update("BRENDER_FRAGMENT", brender_fragment);
int dvd_yuv420p_interlace;
// highlight inversion color
int highlight_inverse;
+// yuv color space/range
+ int yuv_color_space;
+ int yuv_color_range;
// Default positions for channels
int channel_positions[MAXCHANNELS * MAXCHANNELS];
(*this_aconfig != *aconfig) || (*this_vconfig != *vconfig) ||
!preferences->brender_asset->equivalent(*mwindow->preferences->brender_asset, 0, 1, edl);
+ if( preferences->yuv_color_space != mwindow->preferences->yuv_color_space ||
+ preferences->yuv_color_range != mwindow->preferences->yuv_color_range ) {
+ YUV::yuv.yuv_set_colors(
+ preferences->yuv_color_space,
+ preferences->yuv_color_range);
+ rerender = 1;
+ }
+
if( preferences->highlight_inverse != mwindow->preferences->highlight_inverse ) {
mwindow->gui->lock_window("PreferencesThread::apply_settings 0");
mwindow->gui->hide_cursor(0);
}
-int VRender::get_colormodel(VEdit *playable_edit,
- int use_vconsole, int use_brender)
+int VRender::get_colormodel(VEdit *playable_edit, int use_vconsole, int use_brender)
{
+ EDL *edl = renderengine->get_edl();
int colormodel = renderengine->get_edl()->session->color_model;
-
- if(!use_vconsole && !renderengine->command->single_frame())
- {
+ VideoOutConfig *vconfig = renderengine->config->vconfig;
+// check for playback: no plugins, not single frame
+ if( !use_vconsole && !renderengine->command->single_frame() ) {
// Get best colormodel supported by the file
- int driver = renderengine->config->vconfig->driver;
- File *file;
- Asset *asset;
-
- if(use_brender)
- {
- asset = renderengine->preferences->brender_asset;
- }
- else
- {
- int64_t source_position = 0;
- asset = playable_edit->get_nested_asset(&source_position,
- current_position,
+// colormodel yuv/rgb affects mpeg/jpeg color range,
+// dont mix them or loose color acccuracy
+ int64_t source_position = 0;
+ Asset *asset = use_brender ?
+ renderengine->preferences->brender_asset :
+ playable_edit->get_nested_asset(&source_position, current_position,
renderengine->command->get_direction());
- }
- if( asset )
- {
- file = renderengine->get_vcache()->check_out(asset,
- renderengine->get_edl());
-
- if(file)
- {
- colormodel = file->get_best_colormodel(driver);
-//printf("VRender::get_colormodel %d driver=%d colormodel=%d\n", __LINE__, driver, colormodel);
+ if( asset ) {
+ File *file = renderengine->get_vcache()->check_out(asset, edl);
+ if( file ) {
+// damn the color range, full speed ahead
+ if( vconfig->driver == PLAYBACK_X11 && vconfig->use_direct_x11 &&
+ file->colormodel_supported(BC_BGR8888) == BC_BGR8888 )
+ colormodel = BC_BGR8888;
+ else {
+// file favorite colormodel may mismatch rgb/yuv
+ int vstream = playable_edit->channel;
+ int best_colormodel = file->get_best_colormodel(vconfig->driver, vstream);
+ if( BC_CModels::is_yuv(best_colormodel) == BC_CModels::is_yuv(colormodel) )
+ colormodel = best_colormodel;
+ }
renderengine->get_vcache()->check_in(asset);
}
-// ffmpeg files are side effected by color_model, affects colorspace,color_range
-// if( asset->format == FILE_FFMPEG && !BC_CModels::is_yuv(colormodel) )
-// colormodel = BC_BGR8888;
}
}
}
-
-
-
-
-
void VRender::run()
{
int reconfigure;
}
}
-void VWindow::clear_inpoint()
+void VWindow::unset_inoutpoint()
{
EDL *edl = get_edl();
if(edl)
{
- edl->local_session->unset_inpoint();
- gui->timebar->update(1);
- }
-}
-
-void VWindow::clear_outpoint()
-{
- EDL *edl = get_edl();
- if(edl)
- {
- edl->local_session->unset_outpoint();
+ edl->unset_inoutpoint();
gui->timebar->update(1);
}
}
int update_position(double position);
void set_inpoint();
void set_outpoint();
- void clear_inpoint();
- void clear_outpoint();
+ void unset_inoutpoint();
void copy();
void splice_selection();
void overwrite_selection();
vwindow->set_outpoint();
}
-void VWindowEditing::clear_inpoint()
+void VWindowEditing::unset_inoutpoint()
{
- vwindow->clear_inpoint();
+ vwindow->unset_inoutpoint();
}
-void VWindowEditing::clear_outpoint()
-{
- vwindow->clear_outpoint();
-}
void VWindowEditing::to_clip()
{
void overwrite_selection();
void set_inpoint();
void set_outpoint();
- void clear_inpoint();
- void clear_outpoint();
+ void unset_inoutpoint();
void to_clip();
void toggle_label();
void prev_label();
--- /dev/null
+matroska flac
--- /dev/null
+matroska libopus
--- /dev/null
+webm libopus
--- /dev/null
+webm libopus
--- /dev/null
+matroska opus
+strict -2
--- /dev/null
+webm opus
+strict -2
--- /dev/null
+webm opus
+strict -2
--- /dev/null
+matroska libvorbis
--- /dev/null
+ogg libvorbis
+cin_quality=5
--- /dev/null
+webm libvorbis
--- /dev/null
+matroska libtheora
+cin_quality=7
--- /dev/null
+ogg libtheora
+cin_quality=7
--- /dev/null
+matroska libvpx
\ No newline at end of file
--- /dev/null
+webm libvpx
-webm libvpx
+webm libvpx-vp9
base = {
"rgb8": {
"i8": {
- "r": " uint32_t in = *inp, r = ((in>>6)&3)*0x55u, g = ((in>>3)&7)*0x24u, b = (in&7)*0x24u;",
+ "r": " uint32_t in = *inp; int r = ((in>>6)&3)*0x55u, g = ((in>>3)&7)*0x24u, b = (in&7)*0x24u;",
"w": " uint32_t ot = (r&0xc0u) | ((g>>2)&0x38u) | ((b>>5)&0x07u);\n" +
" *out++ = ot;",
},
"i16": {
- "r": " uint32_t in = *inp, r = ((in>>6)&3)*0x5555u, g = ((in>>3)&7)*0x2492u, b = (in&7)*0x2492u;",
+ "r": " uint32_t in = *inp; int r = ((in>>6)&3)*0x5555u, g = ((in>>3)&7)*0x2492u, b = (in&7)*0x2492u;",
"w": " uint32_t ot = ((r>>8)&0xc0u) | ((g>>10) & 0x38u) >> 2) | ((b>>13)&0x07u);\n" +
" *out++ = ot;",
},
"w": " *out++ = r; *out++ = g; *out++ = b;",
},
"i16": {
- "r": " int r = *inp++*0x101u, g = *inp++*0x101u, b = *inp++*0x101u;",
+ "r": " int r = *inp++, g = *inp++, b = *inp++;\n" +
+ " r = (r<<8) | r; g = (g<<8) | g; b = (b<<8) | b;",
"w": " *out++ = r>>8; *out++ = g>>8; *out++ = b>>8;",
},
"fp": {
"rgb161616": {
"i8": {
"r": " int r = *inp++>>8, g = *inp++>>8, b = *inp++>>8;",
- "w": " *out++ = r*0x101u; *out++ = g*0x101u; *out++ = b*0x101u;",
+ "w": " *out++ = (r<<8) | r; *out++ = (g<<8) | g; *out++ = (b<<8) | b;"
},
"i16": {
"r": " int r = *inp++, g = *inp++, b = *inp++;",
"w": " *out++ = b; *out++ = g; *out++ = r;",
},
"i16": {
- "r": " int b = *inp++*0x101u, g = *inp++*0x101u, r = *inp++*0x101u;",
- "w": " *out.16++ = b>>8; *out.16++ = g>>8; *out.16++ = r>>8;",
+ "r": " int b = *inp++, g = *inp++, r = *inp++;\n" +
+ " b = (b<<8) | b; g = (g<<8) | g; r = (r<<8) | r;",
+ "w": " *out++ = b>>8; *out++ = g>>8; *out++ = r>>8;",
},
"fp": {
"r": " float b = fclp(*inp++,256), g=fclp(*inp++,256), r = fclp(*inp++,256);",
"w": " *out++ = b; *out++ = g; *out++ = r; ++out;",
},
"i16": {
- "r": " int b = *inp++*0x101u, g = *inp++*0x101u, r = *inp++*0x101u;",
+ "r": " int b = *inp++, g = *inp++, r = *inp++;\n" +
+ " b = (b<<8) | b; g = (g<<8) | g; r = (r<<8) | r;",
"w": " *out++ = b>>8; *out++ = g>>8; *out++ = r>>8; ++out;",
},
"fp": {
"bgr161616": {
"i8": {
"r": " int b = *inp++>>8, g = *inp++>>8, r = *inp++>>8;",
- "w": " *out++ = b*0x101u; *out++ = g*0x101u; *out++ = r*0x101u;",
+ "w": " *out++ = (r<<8) | r; *out++ = (g<<8) | g; *out++ = (b<<8) | b;"
},
"i16": {
"r": " int b = *inp++, g = *inp++, r = *inp++;",
"yuv888": {
"i8": {
- "r": " int32_t y = *inp++*0x010101u, u = *inp++, v = *inp++;",
+ "r": " int32_t y = *inp++, u = *inp++, v = *inp++;",
"w": " *out++ = y; *out++ = u; *out++ = v;",
},
"i16": {
- "r": " int32_t y = *inp++*0x010101u, u = *inp++<<8, v = *inp++<<8;",
+ "r": " int32_t iy = *inp++, y = (iy<<8) | iy, u = *inp++<<8, v = *inp++<<8;",
"w": " *out++ = y>>8; *out++ = u>>8; *out++ = v>>8;",
},
},
"yuv161616": {
"i8": {
- "r": " int32_t iy = *inp++, y = (iy<<8) | (iy>>8), u = *inp++>>8, v = *inp++>>8;",
- "w": " *out++ = y<<8; *out++ = u<<8; *out++ = v<<8;",
+ "r": " int32_t y = *inp++>>8, u = *inp++>>8, v = *inp++>>8;",
+ "w": " *out++ = (y<<8) | y; *out++ = u<<8; *out++ = v<<8;",
},
"i16": {
- "r": " int32_t iy = *inp++, y = (iy<<8) | (iy>>8), u = *inp++, v = *inp++;",
+ "r": " int32_t y = *inp++, u = *inp++, v = *inp++;",
"w": " *out++ = y; *out++ = u; *out++ = v;",
},
},
"yuyv8888": {
"i8": {
- "r": " int32_t iy = inp[(j&1)<<1], y = iy*0x010101u, u = inp[1], v = inp[3];",
+ "r": " int32_t y = inp[(j&1)<<1], u = inp[1], v = inp[3];",
"w": " if( !(j&1) ) { *out++ = y; *out = u; out[2] = v; }\n" +
" else { *out++ = u; *out++= y; *out++ = v; }",
},
"i16": {
- "r": " int32_t iy = inp[(j&1)<<1], y = iy*0x010101u, u = inp[1]<<8, v = inp[3]<<8;",
+ "r": " int32_t iy = inp[(j&1)<<1], y = (iy<<8) | iy, u = inp[1]<<8, v = inp[3]<<8;",
"w": " if( !(j&1) ) { *out++ = y>>8; *out = u>>8; out[2] = v>>8; }\n" +
" else { *out++ = u>>8; *out++= y>>8; *out++ = v>>8; }",
},
"uyvy8888": {
"i8": {
- "r": " int32_t u = inp[0], iy = inp[((j&1)<<1)+1], y = iy*0x010101u, v = inp[2];",
+ "r": " int32_t u = inp[0], y = inp[((j&1)<<1)+1], v = inp[2];",
"w": " if( !(j&1) ) { *out++ = u; *out++ = y; *out++ = v; *out = y; }\n" +
" else { *out++= y; }",
},
"i16": {
- "r": " int32_t u = inp[0]<<8, iy = inp[((j&1)<<1)+1], y = iy*0x010101u, v = inp[2]<<8;",
+ "r": " int32_t u = inp[0]<<8, iy = inp[((j&1)<<1)+1], y = (iy<<8) | iy, v = inp[2]<<8;",
"w": " if( !(j&1) ) { *out++ = u>>8; *out++ = y>>8; *out++ = v>>8; *out = y>>8; }\n" +
" else { *out++= y>>8; }",
},
"yuv10101010": {
"i8": {
"r": " uint32_t it = *(uint32_t*)inp;\n" +
- " int32_t y = ((it>>22)&0x3ffu)*0x4010u, u = (it>>14)&0xffu, v = (it>>4)&0xffu;",
+ " int32_t y = (it>>24)&0xffu, u = (it>>14)&0xffu, v = (it>>4)&0xffu;",
"w": " uint32_t ot = (y<<24) | (u<<14) | (v<<4);\n" +
" *(uint32_t*)out = ot; out += sizeof(uint32_t)/sizeof(*out);",
},
"i16": {
"r": " uint32_t it = *(uint32_t*)inp;\n" +
- " int32_t y = ((it>>22)&0x3ffu)*0x4010u, u = (it>>6)&0xffc0u, v = (it<<4)&0xffc0u;",
+ " int32_t y = (it>>16)&0xffc0u, u = (it>>6)&0xffc0u, v = (it<<4)&0xffc0u;",
"w": " uint32_t ot = ((y&0xffc0u)<<16) | ((u&0xffc0u)<<6) | ((v&0xffc0u)>>4);\n" +
" *(uint32_t*)out = ot; out += sizeof(uint32_t)/sizeof(*out);",
},
"vyu888": {
"i8": {
- "r": " int32_t v = *inp++, y = *inp++*0x010101u, u = *inp++;",
+ "r": " int32_t v = *inp++, y = *inp++, u = *inp++;",
"w": " *out++ = v; *out++ = y; *out++ = u;",
},
"i16": {
- "r": " int32_t v = *inp++<<8, y = *inp++*0x010101u, u = *inp++<<8;",
+ "r": " int32_t v = *inp++<<8, iy = *inp++, y = (iy<<8) | iy, u = *inp++<<8;",
"w": " *out++ = v>>8; *out++ = y>>8; *out++ = u>>8;",
},
},
"uyv888": {
"i8": {
- "r": " int32_t u = *inp++, y = *inp++*0x010101u, v = *inp++;",
+ "r": " int32_t u = *inp++, y = *inp++, v = *inp++;",
"w": " *out++ = u; *out++ = y; *out++ = v;",
},
"i16": {
- "r": " int32_t u = *inp++<<8, y = *inp++*0x010101u, v = *inp++<<8;",
+ "r": " int32_t u = *inp++<<8, iy = *inp++, y = (iy<<8) | iy, v = *inp++<<8;",
"w": " *out++ = u>>8; *out++ = y>>8; *out++ = v>>8;",
},
},
"yuv420p": {
"i8": {
- "r": " int32_t y = *yip*0x010101u, u = *uip, v = *vip;",
+ "r": " int32_t y = *yip, u = *uip, v = *vip;",
"w": " yop[j] = y; uop[j/2] = u; vop[j/2] = v;",
},
"i16": {
- "r": " int32_t y = *yip*0x010101u, u = *uip<<8, v = *vip<<8;",
+ "r": " int32_t iy = *yip, y = (iy<<8) | iy, u = *uip<<8, v = *vip<<8;",
"w": " yop[j] = y>>8; uop[j/2] = u>>8; vop[j/2] = v>>8;",
},
},
"yuv420pi": {
"i8": {
- "r": " int32_t y = *yip*0x010101u, u = *uip, v = *vip;",
+ "r": " int32_t y = *yip, u = *uip, v = *vip;",
"w": " yop[j] = y; uop[j/2] = u; vop[j/2] = v;",
},
"i16": {
- "r": " int32_t y = *yip*0x010101u, u = *uip<<8, v = *vip<<8;",
+ "r": " int32_t iy = *yip, y = (iy<<8) | iy, u = *uip<<8, v = *vip<<8;",
"w": " yop[j] = y>>8; uop[j/2] = u>>8; vop[j/2] = v>>8;",
},
},
"yuv422p": {
"i8": {
- "r": " int32_t y = *yip*0x010101u, u = *uip, v = *vip;",
+ "r": " int32_t y = *yip, u = *uip, v = *vip;",
"w": " yop[j] = y; uop[j/2] = u; vop[j/2] = v;",
},
"i16": {
- "r": " int32_t y = *yip*0x010101u, u = *uip<<8, v = *vip<<8;",
+ "r": " int32_t iy = *yip, y = (iy<<8) | iy, u = *uip<<8, v = *vip<<8;",
"w": " yop[j] = y>>8; uop[j/2] = u>>8; vop[j/2] = v>>8;",
},
},
"yuv444p": {
"i8": {
- "r": " int32_t y = *yip*0x010101u, u = *uip, v = *vip;",
+ "r": " int32_t y = *yip, u = *uip, v = *vip;",
"w": " yop[j] = y; uop[j] = u; vop[j] = v;",
},
"i16": {
- "r": " int32_t y = *yip*0x010101u, u = *uip<<8, v = *vip<<8;",
+ "r": " int32_t iy = *yip, y = (iy<<8) | iy, u = *uip<<8, v = *vip<<8;",
"w": " yop[j] = y>>8; uop[j] = u>>8; vop[j] = v>>8;",
},
},
"yuv411p": {
"i8": {
- "r": " int32_t y = *yip*0x010101u, u = *uip, v = *vip;",
+ "r": " int32_t y = *yip, u = *uip, v = *vip;",
"w": " yop[j] = y; uop[j/4] = u; vop[j/4] = v;",
},
"i16": {
- "r": " int32_t y = *yip*0x010101u, u = *uip<<8, v = *vip<<8;",
+ "r": " int32_t iy = *yip, y = (iy<<8) | iy, u = *uip<<8, v = *vip<<8;",
"w": " yop[j] = y>>8; uop[j/4] = u>>8; vop[j/4] = v>>8;",
},
},
"yuv410p": {
"i8": {
- "r": " int32_t y = *yip*0x010101u, u = *uip, v = *vip;",
+ "r": " int32_t y = *yip, u = *uip, v = *vip;",
"w": " yop[j] = y; uop[j/4] = u; vop[j/4] = v;",
},
"i16": {
- "r": " int32_t y = *yip*0x010101u, u = *uip<<8, v = *vip<<8;",
+ "r": " int32_t iy = *yip, y = (iy<<8) | iy, u = *uip<<8, v = *vip<<8;",
"w": " yop[j] = y>>8; uop[j/4] = u>>8; vop[j/4] = v>>8;",
},
},
"grey8": {
"i8": {
- "r": " int32_t iy = *inp++, y = iy * 0x010101u, u = 0x80, v = 0x80;",
+ "r": " int32_t y = *inp++, u = 0x80, v = 0x80;",
"w": " *out++ = y; (void)u; (void)v;",
},
"i16": {
- "r": " int32_t iy = *inp++, y = iy * 0x010101u, u = 0x8000, v = 0x8000;",
+ "r": " int32_t iy = *inp++, y = (iy<<8) | iy, u = 0x8000, v = 0x8000;",
"w": " *out++ = y>>8; (void)u; (void)v;",
},
},
"grey16": {
"i8": {
- "r": " int32_t iy = *inp++, y = (iy<<8) | (iy>>8), u = 0x80, v = 0x80;",
- "w": " *out++ = y<<8; (void)u; (void)v;",
+ "r": " int32_t y = *inp++>>8, u = 0x80, v = 0x80;",
+ "w": " *out++ = (y<<8) | y; (void)u; (void)v;",
},
"i16": {
- "r": " int32_t iy = *inp++, y = (iy<<8) | (iy>>8), u = 0x8000, v = 0x8000;",
+ "r": " int32_t y = *inp++, u = 0x8000, v = 0x8000;",
"w": " *out++ = y; (void)u; (void)v;",
},
},
"w": " *out++ = a;",
},
"i16": {
- "r": " z_int a = *inp++<<8;",
+ "r": " z_int a = *inp++; a = (a<<8) | a;",
"w": " *out++ = a>>8;",
},
"fp": {
"a16": {
"i8": {
"r": " z_int a = *inp++>>8;",
- "w": " *out++ = a<<8;",
+ "w": " *out++ = (a<<8) | a;",
},
"i16": {
"r": " z_int a = *inp++;",
if( is_float(to_cmdl) and is_yuv(fr_cmdl) ):
for ic in layout[fr_cmdl]: print "%s" % (base[ic][ityp]['r']),
if( ityp == "i8" ):
- print "\n float fy = y/16777215.f, r, g, b; YUV_TO_FLOAT(fy, u, v, r, g, b);",
+ print "\n float r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);",
elif( ityp == "i16" ):
- print "\n float fy = y/16777215.f, r, g, b; YUV16_TO_RGB_FLOAT(fy, u, v, r, g, b);",
+ print "\n float r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);",
if( has_alpha(fr_cmdl) or has_alpha(to_cmdl) ):
if( not has_alpha(fr_cmdl) ):
print " z_float fa = 1;",
# xfer
if( is_rgb(fr_cmdl) and is_yuv(to_cmdl) ):
if( otyp == "i8" ):
- print " int32_t y, u, v; RGB_TO_YUV(y, u, v, r, g, b);"
+ print " int32_t y, u, v; YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v);"
elif( otyp == "i16" ):
- print " int32_t y, u, v; RGB_TO_YUV16(y, u, v, r, g, b);"
+ print " int32_t y, u, v; YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v);"
elif( is_yuv(fr_cmdl) and is_rgb(to_cmdl)):
if( otyp == "i8" ):
- print " int32_t r, g, b; YUV_TO_RGB(y, u, v, r, g, b);"
+ print " int32_t r, g, b; YUV::yuv.yuv_to_rgb_8(r, g, b, y, u, v);"
elif( otyp == "i16" ):
- print " int32_t r, g, b; YUV_TO_RGB16(y, u, v, r, g, b);"
- elif( is_yuv(fr_cmdl) and is_yuv(to_cmdl) ):
- if( otyp == "i8" ):
- print " y >>= 16;",
- elif( otyp == "i16" ):
- print " y >>= 8;",
+ print " int32_t r, g, b; YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);"
# blend
if( has_bgcolor(fr_cmdl,to_cmdl) ):
print "%s" % (base["bbg"][otyp])
#include "bccolors.h"
#include <stdio.h>
+#include <stdlib.h>
HSV::HSV()
{
{
}
-YUV YUV::yuv;
-
int HSV::rgb_to_hsv(float r, float g, float b, float &h, float &s, float &v)
{
float min = ((r < g) ? r : g) < b ? ((r < g) ? r : g) : b;
return 0;
}
-YUV::YUV()
-{
- for(int i = 0; i < 0x100; i++) {
-// compression
- rtoy_tab_8[i] = (int)(R_TO_Y * 0x100 * i);
- rtou_tab_8[i] = (int)(R_TO_U * 0x100 * i);
- rtov_tab_8[i] = (int)(R_TO_V * 0x100 * i);
-
- gtoy_tab_8[i] = (int)(G_TO_Y * 0x100 * i);
- gtou_tab_8[i] = (int)(G_TO_U * 0x100 * i);
- gtov_tab_8[i] = (int)(G_TO_V * 0x100 * i);
-
- btoy_tab_8[i] = (int)(B_TO_Y * 0x100 * i);
- btou_tab_8[i] = (int)(B_TO_U * 0x100 * i) + 0x8000;
- btov_tab_8[i] = (int)(B_TO_V * 0x100 * i) + 0x8000;
- }
- vtor_8 = &(vtor_tab_8[(0x100) / 2]);
- vtog_8 = &(vtog_tab_8[(0x100) / 2]);
- utog_8 = &(utog_tab_8[(0x100) / 2]);
- utob_8 = &(utob_tab_8[(0x100) / 2]);
+YUV YUV::yuv;
- for(int i = (-0x100) / 2; i < (0x100) / 2; i++) {
-// decompression
- vtor_8[i] = (int)(V_TO_R * 0x100 * i);
- vtog_8[i] = (int)(V_TO_G * 0x100 * i);
+YUV::YUV()
+{
+ this->tab = new int[0xe0e00];
+ this->tabf = new float[0x40400];
+ yuv_set_colors(0, 0);
+}
- utog_8[i] = (int)(U_TO_G * 0x100 * i);
- utob_8[i] = (int)(U_TO_B * 0x100 * i);
+void YUV::yuv_set_colors(int color_space, int color_range)
+{
+ double kr, kb;
+ int mpeg;
+ switch( color_space ) {
+ default:
+ case 0: kr = BT601_Kr; kb = BT601_Kb; break;
+ case 1: kr = BT709_Kr; kb = BT709_Kb; break;
}
+ switch( color_range ) {
+ default:
+ case 0: mpeg = 0; break;
+ case 1: mpeg = 1; break;
+ }
+ init(kr, kb, mpeg);
+}
- for(int i = 0; i < 0x10000; i++) {
-// compression
- rtoy_tab_16[i] = (int)(R_TO_Y * 0x100 * i);
- rtou_tab_16[i] = (int)(R_TO_U * 0x100 * i);
- rtov_tab_16[i] = (int)(R_TO_V * 0x100 * i);
-
- gtoy_tab_16[i] = (int)(G_TO_Y * 0x100 * i);
- gtou_tab_16[i] = (int)(G_TO_U * 0x100 * i);
- gtov_tab_16[i] = (int)(G_TO_V * 0x100 * i);
+void YUV::init(double Kr, double Kb, int mpeg)
+{
+ this->mpeg = mpeg;
+ int ymin = !mpeg? 0 : 16;
+ int ymax = !mpeg? 255 : 235;
+ int uvmin = !mpeg? 0 : 16;
+ int uvmax = !mpeg? 255 : 240;
+ this->ymin8 = ymin;
+ this->ymax8 = ymax;
+ this->ymin16 = ymin*0x100;
+ this->ymax16 = (ymax+1)*0x100 - 1;
+ this->yzero = 0x10000 * ymin;
+ this->uvmin8 = uvmin;
+ this->uvmax8 = uvmax;
+ this->uvmin16 = uvmin*0x100;
+ this->uvmax16 = (uvmax+1)*0x100 - 1;
+ this->uvzero = 0x800000;
+ this->yminf = ymin / 256.;
+ this->ymaxf = (ymax+1) / 256.;
+ this->yrangef = ymaxf - yminf;
+ this->uvminf = uvmin / 256.;
+ this->uvmaxf = (uvmax+1) / 256.;
+ this->uvrangef = uvmaxf - uvminf;
+ this->Kr = Kr;
+ this->Kg = 1. - Kr - Kb;
+ this->Kb = Kb;
+ double R_to_Y = Kr;
+ double G_to_Y = Kg;
+ double B_to_Y = Kb;
+ double R_to_U = -0.5*Kr/(1-Kb);
+ double G_to_U = -0.5*Kg/(1-Kb);
+ double B_to_U = 0.5;
+ double R_to_V = 0.5;
+ double G_to_V = -0.5*Kg/(1-Kr);
+ double B_to_V = -0.5*Kb/(1-Kr);
+ double V_to_R = 2.0*(1-Kr);
+ double V_to_G = -2.0*Kr*(1-Kr)/Kg;
+ double U_to_G = -2.0*Kb*(1-Kb)/Kg;
+ double U_to_B = 2.0*(1-Kb);
+
+ this->r_to_y = yrangef * R_to_Y;
+ this->g_to_y = yrangef * G_to_Y;
+ this->b_to_y = yrangef * B_to_Y;
+ this->r_to_u = uvrangef * R_to_U;
+ this->g_to_u = uvrangef * G_to_U;
+ this->b_to_u = uvrangef * B_to_U;
+ this->r_to_v = uvrangef * R_to_V;
+ this->g_to_v = uvrangef * G_to_V;
+ this->b_to_v = uvrangef * B_to_V;
+ this->v_to_r = V_to_R / uvrangef;
+ this->v_to_g = V_to_G / uvrangef;
+ this->u_to_g = U_to_G / uvrangef;
+ this->u_to_b = U_to_B / uvrangef;
+
+ init_tables(0x100,
+ rtoy8, rtou8, rtov8,
+ gtoy8, gtou8, gtov8,
+ btoy8, btou8, btov8,
+ ytab8, vtor8, vtog8, utog8, utob8);
+ init_tables(0x10000,
+ rtoy16, rtou16, rtov16,
+ gtoy16, gtou16, gtov16,
+ btoy16, btou16, btov16,
+ ytab16, vtor16, vtog16, utog16, utob16);
+ init_tables(0x100,
+ vtor8f, vtog8f, utog8f, utob8f);
+ init_tables(0x10000,
+ vtor16f, vtog16f, utog16f, utob16f);
+}
- btoy_tab_16[i] = (int)(B_TO_Y * 0x100 * i);
- btou_tab_16[i] = (int)(B_TO_U * 0x100 * i) + 0x800000;
- btov_tab_16[i] = (int)(B_TO_V * 0x100 * i) + 0x800000;
+void YUV::init_tables(int len,
+ int *rtoy, int *rtou, int *rtov,
+ int *gtoy, int *gtou, int *gtov,
+ int *btoy, int *btou, int *btov,
+ int *ytab,
+ int *vtor, int *vtog,
+ int *utog, int *utob)
+{
+// rgb->yuv
+ double s = (double)0xffffff / len;
+ double r2y = s*r_to_y, g2y = s*g_to_y, b2y = s*b_to_y;
+ double r2u = s*r_to_u, g2u = s*g_to_u, b2u = s*b_to_u;
+ double r2v = s*r_to_v, g2v = s*g_to_v, b2v = s*b_to_v;
+ for( int rgb=0; rgb<len; ++rgb ) {
+ rtoy[rgb] = r2y*rgb; rtou[rgb] = r2u*rgb; rtov[rgb] = r2v*rgb;
+ gtoy[rgb] = g2y*rgb; gtou[rgb] = g2u*rgb; gtov[rgb] = g2v*rgb;
+ btoy[rgb] = b2y*rgb; btou[rgb] = b2u*rgb; btov[rgb] = b2v*rgb;
}
- vtor_16 = &(vtor_tab_16[(0x10000) / 2]);
- vtog_16 = &(vtog_tab_16[(0x10000) / 2]);
- utog_16 = &(utog_tab_16[(0x10000) / 2]);
- utob_16 = &(utob_tab_16[(0x10000) / 2]);
-
- for(int i = (-0x10000) / 2; i < (0x10000) / 2; i++) {
-// decompression
- vtor_16[i] = (int)(V_TO_R * 0x100 * i);
- vtog_16[i] = (int)(V_TO_G * 0x100 * i);
+// yuv->rgb
+ int y0 = ymin8 * len/0x100, y1 = (ymax8+1) * len/0x100 - 1;
+ s = (double)0xffffff / (y1 - y0);
+ int y = 0, iy = 0;
+ while( y < y0 ) ytab[y++] = 0;
+ while( y < y1 ) ytab[y++] = s*iy++;
+ while( y < len ) ytab[y++] = 0xffffff;
+
+ int uv0 = uvmin8 * len/0x100, uv1 = (uvmax8+1) * len/0x100 - 1;
+ s = (double)0xffffff / (uv1 - uv0);
+ double v2r = s*v_to_r, v2g = s*v_to_g;
+ double u2g = s*u_to_g, u2b = s*u_to_b;
+ int uv = 0, iuv = uv0 - len/2;
+ int vr0 = v2r * iuv, vg0 = v2g * iuv;
+ int ug0 = u2g * iuv, ub0 = u2b * iuv;
+ while( uv < uv0 ) {
+ vtor[uv] = vr0; vtog[uv] = vg0;
+ utog[uv] = ug0; utob[uv] = ub0;
+ ++uv;
+ }
+ while( uv < uv1 ) {
+ vtor[uv] = iuv * v2r; vtog[uv] = iuv * v2g;
+ utog[uv] = iuv * u2g; utob[uv] = iuv * u2b;
+ ++uv; ++iuv;
+ }
+ int vr1 = v2r * iuv, vg1 = v2g * iuv;
+ int ug1 = u2g * iuv, ub1 = u2b * iuv;
+ while( uv < len ) {
+ vtor[uv] = vr1; vtog[uv] = vg1;
+ utog[uv] = ug1; utob[uv] = ub1;
+ ++uv;
+ }
+}
- utog_16[i] = (int)(U_TO_G * 0x100 * i);
- utob_16[i] = (int)(U_TO_B * 0x100 * i);
+void YUV::init_tables(int len,
+ float *vtorf, float *vtogf, float *utogf, float *utobf)
+{
+ int len1 = len-1, len2 = len/2;
+ for( int i=0,k=-len2; i<len; ++i,++k ) {
+ vtorf[i] = (v_to_r * k)/len1;
+ vtogf[i] = (v_to_g * k)/len1;
+ utogf[i] = (u_to_g * k)/len1;
+ utobf[i] = (u_to_b * k)/len1;
}
}
YUV::~YUV()
{
+ delete [] tab;
+ delete [] tabf;
}
#include <stdint.h>
+// bt601 coefs originaly used
// Compression coefficients straight out of jpeglib
-#define R_TO_Y 0.29900
-#define G_TO_Y 0.58700
-#define B_TO_Y 0.11400
+#define R_TO_Y 0.29900
+#define G_TO_Y 0.58700
+#define B_TO_Y 0.11400
-#define R_TO_U -0.16874
-#define G_TO_U -0.33126
-#define B_TO_U 0.50000
+#define R_TO_U -0.16874
+#define G_TO_U -0.33126
+#define B_TO_U 0.50000
-#define R_TO_V 0.50000
-#define G_TO_V -0.41869
-#define B_TO_V -0.08131
+#define R_TO_V 0.50000
+#define G_TO_V -0.41869
+#define B_TO_V -0.08131
// Decompression coefficients straight out of jpeglib
-#define V_TO_R 1.40200
-#define V_TO_G -0.71414
+#define V_TO_R 1.40200
+#define V_TO_G -0.71414
-#define U_TO_G -0.34414
-#define U_TO_B 1.77200
+#define U_TO_G -0.34414
+#define U_TO_B 1.77200
+/*
+Digital YCbCr is derived from analog RGB as follows:
+RGB are 0..1 (gamma corrected supposedly),
+normalized equations:
+Y Py = Kr * R + Kg * G + Kb * B
+U Pb = - 0.5*Kr/(1-Kb)*R - 0.5*Kg/(1-Kb)*G + 0.5*B
+V Pr = 0.5*R - 0.5*Kg/(1-Kr)*G - 0.5*Kb/(1-Kr)*B
+inverse:
+ R = Py + Pr * 2*(1-Kr)
+ G = Py - Pr * 2*Kr*(1-Kr)/Kg - Pb * 2*Kb*(1-Kb)/Kg
+ B = Py + Pb * 2*(1-Kb)
+
+bt601, white vector= Kr=0.299,Kg=0.587,Kb=0.114
+ Py = + 0.299000*R + 0.587000*G + 0.114000*B
+ Pb = - 0.168736*R - 0.331264*G + 0.500000*B
+ Pr = + 0.500000*R - 0.418698*G - 0.081312*B
+inverse:
+ R = Py + 1.402000*Pr
+ G = Py - 0.714136*Pr - 0.344136*Pb
+ B = Py + 1.772000*Pb
+
+equations zeroed at (0,128,128), range (255,255,255)
+bt.601 0..255
+ Y = 0 + 0.299000*R + 0.587000*G + 0.114000*B
+ Cb = 128 - 0.168736*R - 0.331264*G + 0.500000*B
+ Cr = 128 + 0.500000*R - 0.418698*G - 0.081312*B
+inverse:
+ R = Y + 1.402000*(Cr-128)
+ G = Y - 0.714136*(Cr-128) - 0.344136*(Cb-128)
+ B = Y + 1.772000*(Cb-128)
+
+equations zeroed at (16,128,128), range (219,224,224)
+Y,Cb,Cr = (16,128,128) + (219*Py,224*Pb,224*Pr)
+
+bt.601 16..235
+ Y = 16 + 0.256788*R + 0.504129*G + 0.097906*B
+ Cb = 128 - 0.148227*R - 0.290992*G + 0.439216*B
+ Cr = 128 + 0.439216*R - 0.367789*G - 0.071426*B
+inverse:
+ R = (Y-16)*1.164384 + 1.596027*(Cr-128)
+ G = (Y-16)*1.164384 - 0.812968*(Cr-128) - 0.391762*(Cb-128)
+ B = (Y-16)*1.164384 + 2.017232*(Cb-128)
+
+bt.709, white vector= Kr=0.2126,Kg=0.7152,Kb=0.0722
+ Py = + 0.212600*R + 0.715200*G + 0.072200*B
+ Pb = - 0.114572*R - 0.385428*G + 0.500000*B
+ Pr = + 0.500000*R - 0.454153*G - 0.045847*B
+
+equations zeroed at (0,128,128), range (255,255,255)
+bt.709 0..255
+ Y = 0 + 0.212600*R + 0.715200*G + 0.072200*B
+ Cb = 128 - 0.114572*R - 0.385428*G + 0.500000*B
+ Cr = 128 + 0.500000*R - 0.454153*G - 0.045847*B
+inverse:
+ R = Y + 1.574800*(Cr-128)
+ G = Y - 0.468124*(Cr-128) - 0.187324*(Cb-128)
+ B = Y + 1.855600*(Cb-128)
+
+equations zeroed at (16,128,128), range (219,224,224)
+Y,Cb,Cr = (16,128,128) + (219*Py,224*Pb,224*Pr)
+ Y = 16 + 0.182586*R + 0.614231*G + 0.062007*B
+ Cb = 128 - 0.100644*R - 0.338572*G + 0.439216*B
+ Cr = 128 + 0.439216*R - 0.398942*G - 0.040276*B
+inverse:
+ R = (Y-16)*1.164384 + 1.792741*(Cr-128)
+ G = (Y-16)*1.164384 - 0.532909*(Cr-128) - 0.213249*(Cb-128)
+ B = (Y-16)*1.164384 + 2.112402*(Cb-128)
+
+*/
+// white vector normalized, so:
+// Kg = 1 - Kr - Kb
+
+#define BT601_Kr 0.299
+#define BT601_Kb 0.114
+
+#define BT709_Kr 0.2126
+#define BT709_Kb 0.0722
+
+#define BT2020_Kr 0.2627
+#define BT2020_Kb 0.0593
class YUV
{
+ int mpeg, yzero, uvzero;
+ int ymin8, ymax8, ymin16, ymax16;
+ int uvmin8, uvmax8, uvmin16, uvmax16;
+ double Kr, Kg, Kb;
+ float yminf, ymaxf, yrangef;
+ float uvminf, uvmaxf, uvrangef;
+ float r_to_y, g_to_y, b_to_y;
+ float r_to_u, g_to_u, b_to_u;
+ float r_to_v, g_to_v, b_to_v;
+ float v_to_r, v_to_g;
+ float u_to_g, u_to_b;
+ int *tab;
+ float *tabf;
+
+ void init(double Kr, double Kb, int mpeg);
+ void init_tables(int len,
+ int *rtoy, int *rtou, int *rtov,
+ int *gtoy, int *gtou, int *gtov,
+ int *btoy, int *btou, int *btov,
+ int *ytab, int *vtor, int *vtog, int *utog, int *utob);
+ void init_tables(int len,
+ float *vtorf, float *vtogf, float *utogf, float *utobf);
+
+// dont use pointers,
+// offsets do not require indirect access
+#define rtoy16 (tab+0x00000)
+#define gtoy16 (tab+0x10000)
+#define btoy16 (tab+0x20000)
+#define rtou16 (tab+0x30000)
+#define gtou16 (tab+0x40000)
+#define btou16 (tab+0x50000)
+#define rtov16 (tab+0x60000)
+#define gtov16 (tab+0x70000)
+#define btov16 (tab+0x80000)
+#define ytab16 (tab+0x90000)
+#define vtor16 (tab+0xa0000)
+#define vtog16 (tab+0xb0000)
+#define utog16 (tab+0xc0000)
+#define utob16 (tab+0xd0000)
+
+#define rtoy8 (tab+0xe0000)
+#define gtoy8 (tab+0xe0100)
+#define btoy8 (tab+0xe0200)
+#define rtou8 (tab+0xe0300)
+#define gtou8 (tab+0xe0400)
+#define btou8 (tab+0xe0500)
+#define rtov8 (tab+0xe0600)
+#define gtov8 (tab+0xe0700)
+#define btov8 (tab+0xe0800)
+#define ytab8 (tab+0xe0900)
+#define vtor8 (tab+0xe0a00)
+#define vtog8 (tab+0xe0b00)
+#define utog8 (tab+0xe0c00)
+#define utob8 (tab+0xe0d00)
+
+#define vtor16f (tabf+0x00000)
+#define vtog16f (tabf+0x10000)
+#define utog16f (tabf+0x20000)
+#define utob16f (tabf+0x30000)
+
+#define vtor8f (tabf+0x40000)
+#define vtog8f (tabf+0x40100)
+#define utog8f (tabf+0x40200)
+#define utob8f (tabf+0x40300)
+
+#define bc_always_inline __attribute__ ((__always_inline__)) inline
+
public:
YUV();
~YUV();
- static YUV yuv;
-
- inline void rgb_to_yuv_8(int &y, int &u, int &v)
- {
- int r = y;
- int g = u;
- int b = v;
- y = (rtoy_tab_8[r] + gtoy_tab_8[g] + btoy_tab_8[b]) >> 8;
- u = (rtou_tab_8[r] + gtou_tab_8[g] + btou_tab_8[b]) >> 8;
- v = (rtov_tab_8[r] + gtov_tab_8[g] + btov_tab_8[b]) >> 8;
- };
-
- inline void rgb_to_yuv_8(int r, int g, int b, int &y, int &u, int &v)
- {
- y = (rtoy_tab_8[r] + gtoy_tab_8[g] + btoy_tab_8[b]) >> 8;
- u = (rtou_tab_8[r] + gtou_tab_8[g] + btou_tab_8[b]) >> 8;
- v = (rtov_tab_8[r] + gtov_tab_8[g] + btov_tab_8[b]) >> 8;
- };
-
- inline void rgb_to_yuv_8(int r, int g, int b, unsigned char &y, unsigned char &u, unsigned char &v)
- {
- y = (rtoy_tab_8[r] + gtoy_tab_8[g] + btoy_tab_8[b]) >> 8;
- u = (rtou_tab_8[r] + gtou_tab_8[g] + btou_tab_8[b]) >> 8;
- v = (rtov_tab_8[r] + gtov_tab_8[g] + btov_tab_8[b]) >> 8;
- };
-
- static inline void rgb_to_yuv_f(float r, float g, float b, float &y, float &u, float &v)
- {
- y = r * R_TO_Y + g * G_TO_Y + b * B_TO_Y;
- u = r * R_TO_U + g * G_TO_U + b * B_TO_U;
- v = r * R_TO_V + g * G_TO_V + b * B_TO_V;
- };
-
- inline void rgb_to_yuv_16(int r, int g, int b, int &y, int &u, int &v)
- {
- y = (rtoy_tab_16[r] + gtoy_tab_16[g] + btoy_tab_16[b]) >> 8;
- u = (rtou_tab_16[r] + gtou_tab_16[g] + btou_tab_16[b]) >> 8;
- v = (rtov_tab_16[r] + gtov_tab_16[g] + btov_tab_16[b]) >> 8;
- };
+ void yuv_set_colors(int color_space, int color_range);
+ inline int is_mpeg() { return mpeg; }
-// For easier programming. Doesn't do anything.
- inline void rgb_to_yuv_8(float r, float g, float b, float &y, float &u, float &v)
- {
- };
-
- inline void rgb_to_yuv_16(float r, float g, float b, float &y, float &u, float &v)
- {
- };
-
- static inline void rgb_to_yuv_f(int r, int g, int b, int &y, int &u, int &v)
- {
- };
-
- inline void yuv_to_rgb_8(int &r, int &g, int &b)
- {
- int y = r;
- int u = g;
- int v = b;
- y = (y << 8) | y;
- r = (y + vtor_tab_8[v]) >> 8;
- g = (y + utog_tab_8[u] + vtog_tab_8[v]) >> 8;
- b = (y + utob_tab_8[u]) >> 8;
-
- CLAMP(r, 0, 0xff);
- CLAMP(g, 0, 0xff);
- CLAMP(b, 0, 0xff);
- };
- inline void yuv_to_rgb_8(int &r, int &g, int &b, int y, int u, int v)
- {
- y = (y << 8) | y;
- r = (y + vtor_tab_8[v]) >> 8;
- g = (y + utog_tab_8[u] + vtog_tab_8[v]) >> 8;
- b = (y + utob_tab_8[u]) >> 8;
-
- CLAMP(r, 0, 0xff);
- CLAMP(g, 0, 0xff);
- CLAMP(b, 0, 0xff);
- };
-
- static inline void yuv_to_rgb_f(float &r, float &g, float &b, float y, float u, float v)
- {
- r = y + V_TO_R * v;
- g = y + U_TO_G * u + V_TO_G * v;
- b = y + U_TO_B * u;
- };
-
- inline void rgb_to_yuv_16(int r, int g, int b, uint16_t &y, uint16_t &u, uint16_t &v)
- {
- y = (rtoy_tab_16[r] + gtoy_tab_16[g] + btoy_tab_16[b]) >> 8;
- u = (rtou_tab_16[r] + gtou_tab_16[g] + btou_tab_16[b]) >> 8;
- v = (rtov_tab_16[r] + gtov_tab_16[g] + btov_tab_16[b]) >> 8;
- };
-
- inline void yuv_to_rgb_16(int &r, int &g, int &b, int y, int u, int v)
- {
- y = (y << 8) | y;
- r = (y + vtor_tab_16[v]) >> 8;
- g = (y + utog_tab_16[u] + vtog_tab_16[v]) >> 8;
- b = (y + utob_tab_16[u]) >> 8;
-
- CLAMP(r, 0, 0xffff);
- CLAMP(g, 0, 0xffff);
- CLAMP(b, 0, 0xffff);
- };
+ static YUV yuv;
-// For easier programming. Doesn't do anything.
- inline void yuv_to_rgb_8(float &r, float &g, float &b, float y, float u, float v)
- {
- };
+#define YUV_rgb_to_yuv_8(r,g,b, y,u,v) \
+ y = (rtoy8[r] + gtoy8[g] + btoy8[b] + yzero) >> 16; \
+ u = (rtou8[r] + gtou8[g] + btou8[b] + uvzero) >> 16; \
+ v = (rtov8[r] + gtov8[g] + btov8[b] + uvzero) >> 16
+
+ bc_always_inline void rgb_to_yuv_8(int r, int g, int b, int &y, int &u, int &v) {
+ YUV_rgb_to_yuv_8(r,g,b, y,u,v);
+ }
+ bc_always_inline void rgb_to_yuv_8(int r, int g, int b, uint8_t &y, uint8_t &u, uint8_t &v) {
+ YUV_rgb_to_yuv_8(r,g,b, y,u,v);
+ }
+ bc_always_inline void rgb_to_yuv_8(int &y, int &u, int &v) {
+ int r = y, g = u, b = v; YUV_rgb_to_yuv_8(r, g, b, y, u, v);
+ }
+
+#define YUV_rgb_to_yuv_16(r,g,b, y,u,v) \
+ y = (rtoy16[r] + gtoy16[g] + btoy16[b] + yzero) >> 8; \
+ u = (rtou16[r] + gtou16[g] + btou16[b] + uvzero) >> 8; \
+ v = (rtov16[r] + gtov16[g] + btov16[b] + uvzero) >> 8
+
+ bc_always_inline void rgb_to_yuv_16(int r, int g, int b, int &y, int &u, int &v) {
+ YUV_rgb_to_yuv_16(r,g,b, y,u,v);
+ }
+ bc_always_inline void rgb_to_yuv_16(int r, int g, int b, uint16_t &y, uint16_t &u, uint16_t &v) {
+ YUV_rgb_to_yuv_16(r,g,b, y,u,v);
+ }
+ bc_always_inline void rgb_to_yuv_16(int &y, int &u, int &v) {
+ int r = y, g = u, b = v;
+ YUV_rgb_to_yuv_16(r, g, b, y, u, v);
+ }
+
+ bc_always_inline void rgb_to_yuv_f(float r, float g, float b, float &y, float &u, float &v) {
+ y = r * r_to_y + g * g_to_y + b * b_to_y + yminf;
+ u = r * r_to_u + g * g_to_u + b * b_to_u + uvminf;
+ v = r * r_to_v + g * g_to_v + b * b_to_v + uvminf;
+ }
+ bc_always_inline void rgb_to_yuv_8(float r, float g, float b, int &y, int &u, int &v) {
+ float fy, fu, fv; rgb_to_yuv_f(r, g, b, fy, fu, fv);
+ int iy = fy * 0x100, iu = fu * 0x100, iv = fv * 0x100;
+ CLAMP(iy, ymin8, ymax8);
+ CLAMP(iu, uvmin8, uvmax8); CLAMP(iv, uvmin8, uvmax8);
+ y = iy; u = iu; v = iv;
+ }
+ bc_always_inline void rgb_to_yuv_16(float r, float g, float b,
+ int &y, int &u, int &v) {
+ float fy, fu, fv; rgb_to_yuv_f(r, g, b, fy, fu, fv);
+ int iy = fy * 0x10000, iu = fu * 0x10000, iv = fv * 0x10000;
+ CLAMP(iy, ymin16, ymax16);
+ CLAMP(iu, uvmin16, uvmax16); CLAMP(iv, uvmin16, uvmax16);
+ y = iy; u = iu; v = iv;
+ }
+
+#define YUV_yuv_to_rgb_8(r,g,b, y,u,v) \
+ r = (ytab8[y] + vtor8[v]) >> 16; \
+ g = (ytab8[y] + utog8[u] + vtog8[v]) >> 16; \
+ b = (ytab8[y] + utob8[u]) >> 16
+
+ bc_always_inline void yuv_to_rgb_8(int &r, int &g, int &b, int y, int u, int v) {
+ YUV_yuv_to_rgb_8(r,g,b, y,u,v);
+ CLAMP(r, 0, 0xff); CLAMP(g, 0, 0xff); CLAMP(b, 0, 0xff);
+ }
+ bc_always_inline void yuv_to_rgb_8(uint8_t &r, uint8_t &g, uint8_t &b, int y, int u, int v) {
+ YUV_yuv_to_rgb_8(r,g,b, y,u,v);
+ }
+ bc_always_inline void yuv_to_rgb_8(int &r, int &g, int &b) {
+ int y = r, u = g, v = b; YUV_yuv_to_rgb_8(r,g,b, y,u,v);
+ CLAMP(r, 0, 0xff); CLAMP(g, 0, 0xff); CLAMP(b, 0, 0xff);
+ }
+ bc_always_inline void yuv_to_rgb_8(float &r, float &g, float &b, int y, int u, int v) {
+ int ir, ig, ib; YUV_yuv_to_rgb_8(ir,ig,ib, y,u,v);
+ float s = 1/255.f; r = s*ir; g = s*ig; b = s*ib;
+ }
+
+#define YUV_yuv_to_rgb_16(r,g,b, y,u,v) \
+ r = (ytab16[y] + vtor16[v]) >> 8; \
+ g = (ytab16[y] + utog16[u] + vtog16[v]) >> 8; \
+ b = (ytab16[y] + utob16[u]) >> 8
+
+ bc_always_inline void yuv_to_rgb_16(int &r, int &g, int &b, int y, int u, int v) {
+ YUV_yuv_to_rgb_16(r,g,b, y,u,v);
+ CLAMP(r, 0, 0xffff); CLAMP(g, 0, 0xffff); CLAMP(b, 0, 0xffff);
+ }
+ bc_always_inline void yuv_to_rgb_16(uint16_t &r, uint16_t &g, uint16_t &b, int y, int u, int v) {
+ YUV_yuv_to_rgb_16(r,g,b, y,u,v);
+ }
+ bc_always_inline void yuv_to_rgb_16(int &r, int &g, int &b) {
+ int y = r, u = g, v = b; YUV_yuv_to_rgb_16(r,g,b, y,u,v);
+ CLAMP(r, 0, 0xffff); CLAMP(g, 0, 0xffff); CLAMP(b, 0, 0xffff);
+ }
+ bc_always_inline void yuv_to_rgb_16(float &r, float &g, float &b, int y, int u, int v) {
+ int ir, ig, ib; YUV_yuv_to_rgb_16(ir,ig,ib, y,u,v);
+ float s = 1/65535.f; r = s*ir; g = s*ig; b = s*ib;
+ }
+
+ bc_always_inline void yuv_to_rgb_f(float &r, float &g, float &b, float y, float u, float v) {
+ y = (y-yminf) / yrangef;
+ u = u-uvminf; v = v-uvminf;
+ r = y + v_to_r * v;
+ g = u + u_to_g * u + v_to_g * v;
+ b = y + u_to_b * u;
+ }
// For easier programming. Doesn't do anything.
- inline void yuv_to_rgb_16(float &r, float &g, float &b, float y, float u, float v)
- {
- };
-
- static inline void yuv_to_rgb_f(int &r, int &g, int &b, int y, int u, int v)
- {
- };
-
-private:
- int rtoy_tab_8[0x100], gtoy_tab_8[0x100], btoy_tab_8[0x100];
- int rtou_tab_8[0x100], gtou_tab_8[0x100], btou_tab_8[0x100];
- int rtov_tab_8[0x100], gtov_tab_8[0x100], btov_tab_8[0x100];
-
- int vtor_tab_8[0x100], vtog_tab_8[0x100];
- int utog_tab_8[0x100], utob_tab_8[0x100];
- int *vtor_8, *vtog_8, *utog_8, *utob_8;
-
- int rtoy_tab_16[0x10000], gtoy_tab_16[0x10000], btoy_tab_16[0x10000];
- int rtou_tab_16[0x10000], gtou_tab_16[0x10000], btou_tab_16[0x10000];
- int rtov_tab_16[0x10000], gtov_tab_16[0x10000], btov_tab_16[0x10000];
-
- int vtor_tab_16[0x10000], vtog_tab_16[0x10000];
- int utog_tab_16[0x10000], utob_tab_16[0x10000];
- int *vtor_16, *vtog_16, *utog_16, *utob_16;
+// unused cases in macro expansions, mismatched argument types
+ inline void yuv_to_rgb_8(float &r, float &g, float &b, float y, float u, float v) {}
+ inline void yuv_to_rgb_16(float &r, float &g, float &b, float y, float u, float v) {}
+ inline void yuv_to_rgb_f(int &r, int &g, int &b, int y, int u, int v) {}
+ inline void yuv_to_rgb_f(uint8_t &r, uint8_t &g, uint8_t &b, int y, int u, int v) {}
+ inline void yuv_to_rgb_f(uint16_t &r, uint16_t &g, uint16_t &b, int y, int u, int v) {}
+ inline void rgb_to_yuv_8(float r, float g, float b, float &y, float &u, float &v) {}
+ inline void rgb_to_yuv_16(float r, float g, float b, float &y, float &u, float &v) {}
+ inline void rgb_to_yuv_f(int &r, int &g, int &b, int y, int u, int v) {}
+ inline void rgb_to_yuv_f(uint8_t &r, uint8_t &g, uint8_t &b, int y, int u, int v) {}
+ inline void rgb_to_yuv_f(uint16_t &r, uint16_t &g, uint16_t &b, int y, int u, int v) {}
};
{
public:
HSV();
- ~HSV();
+ ~HSV();
// All units are 0 - 1
static int rgb_to_hsv(float r, float g, float b, float &h, float &s, float &v);
// standard colors
-#define BLACK 0x000000
-#define WHITE 0xFFFFFF
-
-#define LTBLUE 0x9090FF
-#define BLUE 0x0000FF
-#define DKBLUE 0x000090
-
-#define LTPINK 0xFFC0C0
-#define PINK 0xFF8080
-#define RED 0xFF0000
-
-#define LTGREEN 0xC0FFC0
-#define GREEN 0x00FF00
-#define DKGREEN 0x009000
-
-#define YELLOW 0xFFFF00
-#define LTYELLOW 0xFFFFA0
-#define MEYELLOW 0xFFFF00
-#define MDYELLOW 0xFFFFD2
-#define DKYELLOW 0xFFFFB4
-
-#define LTCYAN 0x00CBCB
-#define MECYAN 0x009696
-#define MDCYAN 0x007E7E
-#define DKCYAN 0x004949
-
-#define LTPURPLE 0xFFC0FF
-#define MEPURPLE 0xFF00FF
-#define MDPURPLE 0xC000C0
-#define DKPURPLE 0xA000A0
-
-#define LTGREY 0xE0E0E0
-#define MEGREY 0xAFAFAF
-#define DMGREY 0x999999
-#define MDGREY 0x7D7D7D
-#define DKGREY 0x4B4B4B
-
-#define BLOND 0xb4b487
-#define SLBLUE 0x6040c0
-
-#define MNGREY 0xe6e6e6
-#define FGGREY 0xe3e3e3
-#define MNBLUE 0x003cff
-#define ORANGE 0xffdd76
-#define FTGREY 0xbcbcbc
+#define BLACK 0x000000
+#define WHITE 0xFFFFFF
+
+#define LTBLUE 0x9090FF
+#define BLUE 0x0000FF
+#define DKBLUE 0x000090
+
+#define LTPINK 0xFFC0C0
+#define PINK 0xFF8080
+#define RED 0xFF0000
+
+#define LTGREEN 0xC0FFC0
+#define GREEN 0x00FF00
+#define DKGREEN 0x009000
+
+#define YELLOW 0xFFFF00
+#define LTYELLOW 0xFFFFA0
+#define MEYELLOW 0xFFFF00
+#define MDYELLOW 0xFFFFD2
+#define DKYELLOW 0xFFFFB4
+
+#define LTCYAN 0x00CBCB
+#define MECYAN 0x009696
+#define MDCYAN 0x007E7E
+#define DKCYAN 0x004949
+
+#define LTPURPLE 0xFFC0FF
+#define MEPURPLE 0xFF00FF
+#define MDPURPLE 0xC000C0
+#define DKPURPLE 0xA000A0
+
+#define LTGREY 0xE0E0E0
+#define MEGREY 0xAFAFAF
+#define DMGREY 0x999999
+#define MDGREY 0x7D7D7D
+#define DKGREY 0x4B4B4B
+
+#define BLOND 0xb4b487
+#define SLBLUE 0x6040c0
+
+#define MNGREY 0xe6e6e6
+#define FGGREY 0xe3e3e3
+#define MNBLUE 0x003cff
+#define ORANGE 0xffdd76
+#define FTGREY 0xbcbcbc
#endif
#include <sys/types.h>
#include <sys/stat.h>
+#include "bcwindowbase.h"
#include "bcwindow.h"
#include "bcsignals.h"
#include "bccolors.h"
"yuv422p", "rgb888", "rgba8888", "rgb161616", "rgba16161616", "yuv888", "yuva8888", "yuv161616",
"yuva16161616", "yuv411p", "uvy422", "yuv422", "argb8888", "abgr8888", "a8", "a16",
"yuv101010", "vyu888", "uyva8888", "yuv444p", "yuv410p", "rgb_float", "rgba_float", "a_float",
- "rgb_floatp", "rgba_floatp", "yuv420pi",
+ "rgb_floatp", "rgba_floatp", "yuv420pi", "ayuv16161616", "grey8", "grey16",
};
void write_pgm(uint8_t *tp, int w, int h, const char *fmt, ...)
close(fd);
int w = ifrm.get_w(), h = ifrm.get_h();
TestWindow test_window(100, 100, w, h);
- for( int fr_cmdl=1; fr_cmdl<=34; ++fr_cmdl ) {
+ for( int fr_cmdl=1; fr_cmdl<=37; ++fr_cmdl ) {
if( fr_cmdl == BC_TRANSPARENCY || fr_cmdl == BC_COMPRESSED ) continue;
if( fr_cmdl == BC_A8 || fr_cmdl == BC_A16 ) continue;
if( fr_cmdl == BC_A_FLOAT || fr_cmdl == 8 ) continue;
VFrame afrm(w, h, fr_cmdl, -1);
afrm.transfer_from(&ifrm, 0);
- for( int to_cmdl=1; to_cmdl<=32; ++to_cmdl ) {
+ for( int to_cmdl=1; to_cmdl<=37; ++to_cmdl ) {
if( to_cmdl == BC_TRANSPARENCY || to_cmdl == BC_COMPRESSED ) continue;
if( to_cmdl == BC_A8 || to_cmdl == BC_A16 ) continue;
if( to_cmdl == BC_A_FLOAT || to_cmdl == 8 ) continue;
+ printf("xfer_%s_to_%s\n", cmdl[fr_cmdl],cmdl[to_cmdl]);
VFrame bfrm(w, h, to_cmdl, -1);
bfrm.transfer_from(&afrm, 0);
test_window.draw(&bfrm);
-// Compression coefficients straight out of jpeglib
-#define R_TO_Y 0.29900
-#define G_TO_Y 0.58700
-#define B_TO_Y 0.11400
-
-#define R_TO_U -0.16874
-#define G_TO_U -0.33126
-#define B_TO_U 0.50000
-
-#define R_TO_V 0.50000
-#define G_TO_V -0.41869
-#define B_TO_V -0.08131
-
-// Decompression coefficients straight out of jpeglib
-#define V_TO_R 1.40200
-#define V_TO_G -0.71414
-
-#define U_TO_G -0.34414
-#define U_TO_B 1.77200
-
-int BC_Xfer::rtoy_tab[0x100], BC_Xfer::gtoy_tab[0x100], BC_Xfer::btoy_tab[0x100];
-int BC_Xfer::rtou_tab[0x100], BC_Xfer::gtou_tab[0x100], BC_Xfer::btou_tab[0x100];
-int BC_Xfer::rtov_tab[0x100], BC_Xfer::gtov_tab[0x100], BC_Xfer::btov_tab[0x100];
-int BC_Xfer::vtor_tab[0x100], BC_Xfer::vtog_tab[0x100];
-int BC_Xfer::utog_tab[0x100], BC_Xfer::utob_tab[0x100];
-float BC_Xfer::vtor_float_tab[0x100], BC_Xfer::vtog_float_tab[0x100];
-float BC_Xfer::utog_float_tab[0x100], BC_Xfer::utob_float_tab[0x100];
-int BC_Xfer::rtoy_tab16[0x10000], BC_Xfer::gtoy_tab16[0x10000], BC_Xfer::btoy_tab16[0x10000];
-int BC_Xfer::rtou_tab16[0x10000], BC_Xfer::gtou_tab16[0x10000], BC_Xfer::btou_tab16[0x10000];
-int BC_Xfer::rtov_tab16[0x10000], BC_Xfer::gtov_tab16[0x10000], BC_Xfer::btov_tab16[0x10000];
-int BC_Xfer::vtor_tab16[0x10000], BC_Xfer::vtog_tab16[0x10000];
-int BC_Xfer::utog_tab16[0x10000], BC_Xfer::utob_tab16[0x10000];
-float BC_Xfer::v16tor_float_tab[0x10000], BC_Xfer::v16tog_float_tab[0x10000];
-float BC_Xfer::u16tog_float_tab[0x10000], BC_Xfer::u16tob_float_tab[0x10000];
-
-BC_Xfer::Tables BC_Xfer::tables;
-
-void BC_Xfer::init()
-{
- for( int i=0; i<0x100; ++i ) {
- rtoy_tab[i] = (int)(R_TO_Y * 0x10000 * i);
- rtou_tab[i] = (int)(R_TO_U * 0x10000 * i);
- rtov_tab[i] = (int)(R_TO_V * 0x10000 * i);
-
- gtoy_tab[i] = (int)(G_TO_Y * 0x10000 * i);
- gtou_tab[i] = (int)(G_TO_U * 0x10000 * i);
- gtov_tab[i] = (int)(G_TO_V * 0x10000 * i);
-
- btoy_tab[i] = (int)(B_TO_Y * 0x10000 * i);
- btou_tab[i] = (int)(B_TO_U * 0x10000 * i) + 0x800000;
- btov_tab[i] = (int)(B_TO_V * 0x10000 * i) + 0x800000;
- }
-
- for( int i=0; i<0x10000; ++i ) {
- rtoy_tab16[i] = (int)(R_TO_Y * 0x100 * i);
- rtou_tab16[i] = (int)(R_TO_U * 0x100 * i);
- rtov_tab16[i] = (int)(R_TO_V * 0x100 * i);
-
- gtoy_tab16[i] = (int)(G_TO_Y * 0x100 * i);
- gtou_tab16[i] = (int)(G_TO_U * 0x100 * i);
- gtov_tab16[i] = (int)(G_TO_V * 0x100 * i);
-
- btoy_tab16[i] = (int)(B_TO_Y * 0x100 * i);
- btou_tab16[i] = (int)(B_TO_U * 0x100 * i) + 0x800000;
- btov_tab16[i] = (int)(B_TO_V * 0x100 * i) + 0x800000;
- }
-
- for( int i=-0x80; i<0x80; ++i ) {
- vtor_tab[i+0x80] = (int)(V_TO_R * 0x10000 * i);
- vtog_tab[i+0x80] = (int)(V_TO_G * 0x10000 * i);
- utog_tab[i+0x80] = (int)(U_TO_G * 0x10000 * i);
- utob_tab[i+0x80] = (int)(U_TO_B * 0x10000 * i);
- }
-
- for( int i=-0x80; i<0x80; ++i ) {
- vtor_float_tab[i+0x80] = V_TO_R * i / 0xff;
- vtog_float_tab[i+0x80] = V_TO_G * i / 0xff;
- utog_float_tab[i+0x80] = U_TO_G * i / 0xff;
- utob_float_tab[i+0x80] = U_TO_B * i / 0xff;
- }
-
- for( int i=-0x8000; i<0x8000; ++i ) {
- vtor_tab16[i+0x8000] = (int)(V_TO_R * 0x100 * i);
- vtog_tab16[i+0x8000] = (int)(V_TO_G * 0x100 * i);
- utog_tab16[i+0x8000] = (int)(U_TO_G * 0x100 * i);
- utob_tab16[i+0x8000] = (int)(U_TO_B * 0x100 * i);
- }
-
- for( int i=-0x8000; i<0x8000; ++i ) {
- v16tor_float_tab[i+0x8000] = V_TO_R * i / 0xffff;
- v16tog_float_tab[i+0x8000] = V_TO_G * i / 0xffff;
- u16tog_float_tab[i+0x8000] = U_TO_G * i / 0xffff;
- u16tob_float_tab[i+0x8000] = U_TO_B * i / 0xffff;
- }
-}
-
void BC_Xfer::init(
uint8_t **output_rows, int out_colormodel, int out_x, int out_y, int out_w, int out_h,
uint8_t *out_yp, uint8_t *out_up, uint8_t *out_vp, uint8_t *out_ap, int out_rowspan,
switch( in_colormodel ) {
case BC_RGB_FLOATP:
case BC_RGBA_FLOATP:
+ if( !BC_CModels::has_alpha(out_colormodel) )
+ this->in_colormodel = BC_RGB_FLOATP;
in_rowspan = in_w * sizeof(float);
break;
}
ZTYP(int);
ZTYP(float);
-// All variables are unsigned
-// y -> 24 bits u, v, -> 8 bits r, g, b -> 8 bits
-#define YUV_TO_RGB(y, u, v, r, g, b) \
-{ \
- (r) = ((y + vtor_tab[v]) >> 16); \
- (g) = ((y + utog_tab[u] + vtog_tab[v]) >> 16); \
- (b) = ((y + utob_tab[u]) >> 16); \
- CLAMP(r, 0, 0xff); CLAMP(g, 0, 0xff); CLAMP(b, 0, 0xff); \
-}
-
-// y -> 0 - 1 float
-// u, v, -> 8 bits
-// r, g, b -> float
-#define YUV_TO_FLOAT(y, u, v, r, g, b) \
-{ \
- (r) = y + vtor_float_tab[v]; \
- (g) = y + utog_float_tab[u] + vtog_float_tab[v]; \
- (b) = y + utob_float_tab[u]; \
-}
-
-// y -> 0 - 1 float
-// u, v, -> 16 bits
-// r, g, b -> float
-#define YUV16_TO_RGB_FLOAT(y, u, v, r, g, b) \
-{ \
- (r) = y + v16tor_float_tab[v]; \
- (g) = y + u16tog_float_tab[u] + v16tog_float_tab[v]; \
- (b) = y + u16tob_float_tab[u]; \
-}
-
-// y -> 24 bits u, v-> 16 bits
-#define YUV_TO_RGB16(y, u, v, r, g, b) \
-{ \
- (r) = ((y + vtor_tab16[v]) >> 8); \
- (g) = ((y + utog_tab16[u] + vtog_tab16[v]) >> 8); \
- (b) = ((y + utob_tab16[u]) >> 8); \
- CLAMP(r, 0, 0xffff); CLAMP(g, 0, 0xffff); CLAMP(b, 0, 0xffff); \
-}
-
-
-
-
-#define RGB_TO_YUV(y, u, v, r, g, b) \
-{ \
- y = ((rtoy_tab[r] + gtoy_tab[g] + btoy_tab[b]) >> 16); \
- u = ((rtou_tab[r] + gtou_tab[g] + btou_tab[b]) >> 16); \
- v = ((rtov_tab[r] + gtov_tab[g] + btov_tab[b]) >> 16); \
- CLAMP(y, 0, 0xff); CLAMP(u, 0, 0xff); CLAMP(v, 0, 0xff); \
-}
-
-// r, g, b -> 16 bits
-#define RGB_TO_YUV16(y, u, v, r, g, b) \
-{ \
- y = ((rtoy_tab16[r] + gtoy_tab16[g] + btoy_tab16[b]) >> 8); \
- u = ((rtou_tab16[r] + gtou_tab16[g] + btou_tab16[b]) >> 8); \
- v = ((rtov_tab16[r] + gtov_tab16[g] + btov_tab16[b]) >> 8); \
- CLAMP(y, 0, 0xffff); CLAMP(u, 0, 0xffff); CLAMP(v, 0, 0xffff); \
-}
-
#define xfer_flat_row_out(oty_t) \
for( unsigned i=y0; i<y1; ++i ) { \
};
static SlicerList slicers;
- static void init();
- static class Tables { public: Tables() { init(); } } tables;
- static int rtoy_tab[0x100], gtoy_tab[0x100], btoy_tab[0x100];
- static int rtou_tab[0x100], gtou_tab[0x100], btou_tab[0x100];
- static int rtov_tab[0x100], gtov_tab[0x100], btov_tab[0x100];
- static int vtor_tab[0x100], vtog_tab[0x100];
- static int utog_tab[0x100], utob_tab[0x100];
- static float vtor_float_tab[0x100], vtog_float_tab[0x100];
- static float utog_float_tab[0x100], utob_float_tab[0x100];
- static int rtoy_tab16[0x10000], gtoy_tab16[0x10000], btoy_tab16[0x10000];
- static int rtou_tab16[0x10000], gtou_tab16[0x10000], btou_tab16[0x10000];
- static int rtov_tab16[0x10000], gtov_tab16[0x10000], btov_tab16[0x10000];
- static int vtor_tab16[0x10000], vtog_tab16[0x10000];
- static int utog_tab16[0x10000], utob_tab16[0x10000];
- static float v16tor_float_tab[0x10000], v16tog_float_tab[0x10000];
- static float u16tog_float_tab[0x10000], u16tob_float_tab[0x10000];
-
void init(
uint8_t **output_rows, int out_colormodel, int out_x, int out_y, int out_w, int out_h,
uint8_t *out_yp, uint8_t *out_up, uint8_t *out_vp, uint8_t *out_ap, int out_rowspan,
PLUGIN_CLASS_MEMBERS(BluebananaConfig);
- YUV yuv;
VFrame *frame;
BluebananaEngine *engine;
int ants_counter;
-YUV BrightnessMain::yuv;
-
BrightnessMain::BrightnessMain(PluginServer *server)
: PluginVClient(server)
{
b = input_row[j * components + 2]; \
if(max == 0xff) \
{ \
- BrightnessMain::yuv.rgb_to_yuv_8( \
+ YUV::yuv.rgb_to_yuv_8( \
r, \
g, \
b, \
} \
else \
{ \
- BrightnessMain::yuv.rgb_to_yuv_16( \
+ YUV::yuv.rgb_to_yuv_16( \
r, \
g, \
b, \
{ \
if(max == 0xff) \
{ \
- BrightnessMain::yuv.yuv_to_rgb_8( \
+ YUV::yuv.yuv_to_rgb_8( \
r, \
g, \
b, \
} \
else \
{ \
- BrightnessMain::yuv.yuv_to_rgb_16( \
+ YUV::yuv.yuv_to_rgb_16( \
r, \
g, \
b, \
r = input_row[j * components]; \
g = input_row[j * components + 1]; \
b = input_row[j * components + 2]; \
- YUV::rgb_to_yuv_f( \
- r, \
- g, \
- b, \
- y, \
- u, \
- v); \
- \
+ YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v); \
y = y * contrast + offset; \
- \
- \
- YUV::yuv_to_rgb_f( \
- r, \
- g, \
- b, \
- y, \
- u, \
- v); \
+ YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v); \
input_row[j * components] = r; \
input_row[j * components + 1] = g; \
input_row[j * components + 2] = b; \
BrightnessEngine *engine;
- int redo_buffers;
- static YUV yuv;
+ int redo_buffers;
VFrame *input, *output;
};
burn_server = 0;
buffer = 0;
effecttv = 0;
- yuv = new YUV;
-
}
BurnMain::~BurnMain()
if(buffer) delete [] buffer;
if(burn_server) delete burn_server;
if(effecttv) delete effecttv;
- if(yuv) delete yuv;
}
const char* BurnMain::plugin_title() { return _("BurningTV"); }
b1 = plugin->palette[0][plugin->buffer[i]]; \
b2 = plugin->palette[1][plugin->buffer[i]]; \
b3 = plugin->palette[2][plugin->buffer[i]]; \
- if(is_yuv) plugin->yuv->yuv_to_rgb_8(a1, a2, a3); \
+ if(is_yuv) YUV::yuv.yuv_to_rgb_8(a1, a2, a3); \
a1 += b1; \
a2 += b2; \
a3 += b3; \
CLAMP(a1, 0, 0xff); \
CLAMP(a2, 0, 0xff); \
CLAMP(a3, 0, 0xff); \
- plugin->yuv->rgb_to_yuv_8(a1, a2, a3); \
+ YUV::yuv.rgb_to_yuv_8(a1, a2, a3); \
} \
rows[0][i * components + 0] = a1 | (a1 << 8); \
rows[0][i * components + 1] = a2 | (a2 << 8); \
b1 = plugin->palette[0][plugin->buffer[i]]; \
b2 = plugin->palette[1][plugin->buffer[i]]; \
b3 = plugin->palette[2][plugin->buffer[i]]; \
- if(is_yuv) plugin->yuv->yuv_to_rgb_8(a1, a2, a3); \
+ if(is_yuv) YUV::yuv.yuv_to_rgb_8(a1, a2, a3); \
a1 += b1; \
a2 += b2; \
a3 += b3; \
CLAMP(a1, 0, 0xff); \
CLAMP(a2, 0, 0xff); \
CLAMP(a3, 0, 0xff); \
- plugin->yuv->rgb_to_yuv_8(a1, a2, a3); \
+ YUV::yuv.rgb_to_yuv_8(a1, a2, a3); \
} \
rows[0][i * components + 0] = a1; \
rows[0][i * components + 1] = a2; \
#define OUTER_VARIABLES(plugin) \
- YUV yuv; \
float value = RGB_TO_VALUE(plugin->config.red, \
plugin->config.green, \
plugin->config.blue); \
float g_key = plugin->config.green; \
float b_key = plugin->config.blue; \
int y_key, u_key, v_key; \
- yuv.rgb_to_yuv_8((int)(r_key * 0xff), (int)(g_key * 0xff), (int)(b_key * 0xff), y_key, u_key, v_key); \
+ YUV::yuv.rgb_to_yuv_8( \
+ (int)(r_key * 0xff), (int)(g_key * 0xff), (int)(b_key * 0xff), \
+ y_key, u_key, v_key); \
float run = plugin->config.slope / 100; \
float threshold_run = threshold + run;
float y = r;
float u = g;
float v = b;
- YUV::yuv_to_rgb_f (r, g, b, y, u - 0.5, v - 0.5);
+ YUV::yuv.yuv_to_rgb_f (r, g, b, y, u - 0.5, v - 0.5);
}
HSV::rgb_to_hsv (r, g, b, h, s, v);
float y;
float u;
float v;
- YUV::rgb_to_yuv_f (r, g, b, y, u, v);
+ YUV::yuv.rgb_to_yuv_f (r, g, b, y, u, v);
CLAMP (y, 0, 1.0);
CLAMP (u, 0, 1.0);
CLAMP (v, 0, 1.0);
float b; \
if(is_yuv) \
{ \
- YUV::yuv_to_rgb_f(r, \
- g, \
- b, \
+ YUV::yuv.yuv_to_rgb_f(r, g, b, \
(float)in[0] / max, \
(float)in[1] / max - 0.5, \
(float)in[2] / max - 0.5); \
if(is_yuv) \
{ \
float y, u, v; \
- YUV::rgb_to_yuv_f(r, g, b, y, u, v); \
+ YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v); \
r = y; \
g = u + 0.5; \
b = v + 0.5; \
float b = ((color>> 0) & 0xff) / 255.0f;
if( is_yuv ) {
float y, u, v;
- YUV::rgb_to_yuv_f(r,g,b, y,u,v);
+ YUV::yuv.rgb_to_yuv_f(r,g,b, y,u,v);
target[0] = y;
target[1] = u + 0.5f;
target[2] = v + 0.5f;
float b = target[2];
if( is_yuv ) {
float y = r, u = g-0.5f, v = b-0.5f;
- YUV::yuv_to_rgb_f(y,u,v, r,g,b);
+ YUV::yuv.yuv_to_rgb_f(y,u,v, r,g,b);
}
int ir = r >= 1 ? 0xff : r < 0 ? 0 : (int)(r * 256);
int ig = g >= 1 ? 0xff : g < 0 ? 0 : (int)(g * 256);
y /= 0xff;
u = (float)((u - 0x80) / 0xff);
v = (float)((v - 0x80) / 0xff);
- YUV::yuv_to_rgb_f(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v);
HISTOGRAM_TAIL(3)
break;
case BC_YUVA8888:
y /= 0xff;
u = (float)((u - 0x80) / 0xff);
v = (float)((v - 0x80) / 0xff);
- YUV::yuv_to_rgb_f(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v);
HISTOGRAM_TAIL(4)
break;
}
y /= 0xff;
u = (float)((u - 0x80) / 0xff);
v = (float)((v - 0x80) / 0xff);
- YUV::yuv_to_rgb_f(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v);
GAMMA_MID
- YUV::rgb_to_yuv_f(r, g, b, y, u, v);
+ YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v);
y *= 0xff;
u = u * 0xff + 0x80;
v = v * 0xff + 0x80;
y /= 0xff;
u = (float)((u - 0x80) / 0xff);
v = (float)((v - 0x80) / 0xff);
- YUV::yuv_to_rgb_f(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_f(r, g, b, y, u, v);
GAMMA_MID
- YUV::rgb_to_yuv_f(r, g, b, y, u, v);
+ YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v);
y *= 0xff;
u = u * 0xff + 0x80;
v = v * 0xff + 0x80;
{
float in1, in2, in3, in4;
float out1, out2, out3, out4;
- YUV::rgb_to_yuv_f((float)config.in_r / 0xff,
+ YUV::yuv.rgb_to_yuv_f((float)config.in_r / 0xff,
(float)config.in_g / 0xff,
(float)config.in_b / 0xff,
in1,
in2,
in3);
in4 = (float)config.in_a / 0xff;
- YUV::rgb_to_yuv_f((float)config.out_r / 0xff,
+ YUV::yuv.rgb_to_yuv_f((float)config.out_r / 0xff,
(float)config.out_g / 0xff,
(float)config.out_b / 0xff,
out1,
y = (row[0] << 8) | row[0];
u = (row[1] << 8) | row[1];
v = (row[2] << 8) | row[2];
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
HISTOGRAM_TAIL(3)
break;
case BC_RGBA8888:
y = (row[0] << 8) | row[0];
u = (row[1] << 8) | row[1];
v = (row[2] << 8) | row[2];
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
HISTOGRAM_TAIL(4)
break;
case BC_RGB161616:
y = row[0];
u = row[1];
v = row[2];
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
HISTOGRAM_TAIL(3)
break;
case BC_RGBA16161616:
y = row[0];
u = row[1];
v = row[2];
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
HISTOGRAM_TAIL(4)
break;
}
v = row[2]; \
} \
\
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v); \
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); \
\
/* Look up in RGB domain */ \
r = lookup_r[r]; \
b = lookup_b[b]; \
\
/* Convert to 16 bit YUV */ \
- plugin->yuv.rgb_to_yuv_16(r, g, b, y, u, v); \
+ YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v); \
\
if(max == 0xff) \
{ \
- YUV yuv;
VFrame *input, *output;
HistogramEngine *engine;
int *lookup[HISTOGRAM_MODES];
y = (row[0] << 8) | row[0];
u = (row[1] << 8) | row[1];
v = (row[2] << 8) | row[2];
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
HISTOGRAM_TAIL(3)
break;
case BC_RGBA8888:
y = (row[0] << 8) | row[0];
u = (row[1] << 8) | row[1];
v = (row[2] << 8) | row[2];
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
HISTOGRAM_TAIL(4)
break;
case BC_RGB161616:
y = row[0];
u = row[1];
v = row[2];
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
HISTOGRAM_TAIL(3)
break;
case BC_RGBA16161616:
y = row[0];
u = row[1];
v = row[2];
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v);
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v);
HISTOGRAM_TAIL(4)
break;
}
v = row[2]; \
} \
\
- plugin->yuv.yuv_to_rgb_16(r, g, b, y, u, v); \
+ YUV::yuv.yuv_to_rgb_16(r, g, b, y, u, v); \
\
/* Look up in RGB domain */ \
r = lookup_r[r]; \
b = lookup_b[b]; \
\
/* Convert to 16 bit YUV */ \
- plugin->yuv.rgb_to_yuv_16(r, g, b, y, u, v); \
+ YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v); \
\
if(max == 0xff) \
{ \
- YUV yuv;
VFrame *input, *output;
HistogramEngine *engine;
int *lookup[HISTOGRAM_MODES];
effecttv = 0;
bgimage = 0;
do_reconfigure = 1;
- yuv = new YUV;
-
}
HoloMain::~HoloMain()
{
-
-
-
- if(effecttv)
- {
+ if(effecttv) {
delete holo_server;
delete effecttv;
}
if(bgimage)
delete bgimage;
- delete yuv;
}
const char* HoloMain::plugin_title() { return _("HolographicTV"); }
int r = (int)src[0] >> 8; \
int g = (int)src[1] >> 8; \
int b = (int)src[2] >> 8; \
- plugin->yuv->yuv_to_rgb_8(r, g, b); \
+ YUV::yuv.yuv_to_rgb_8(r, g, b); \
dest = (r << 16) | (g << 8) | b; \
} \
else \
int r = (int)src[0]; \
int g = (int)src[1]; \
int b = (int)src[2]; \
- plugin->yuv->yuv_to_rgb_8(r, g, b); \
+ YUV::yuv.yuv_to_rgb_8(r, g, b); \
dest = (r << 16) | (g << 8) | b; \
} \
else \
if(g > 255) g = 255; \
if(b > 255) b = 255; \
\
- if(is_yuv) plugin->yuv->rgb_to_yuv_8(r, g, b); \
+ if(is_yuv) YUV::yuv.rgb_to_yuv_8(r, g, b); \
if(sizeof(type) == 4) \
{ \
dest[0] = (type)r / 0xff; \
if(g > 255) g = 255; \
if(b > 255) b = 255; \
\
- if(is_yuv) plugin->yuv->rgb_to_yuv_8(r, g, b); \
+ if(is_yuv) YUV::yuv.rgb_to_yuv_8(r, g, b); \
if(sizeof(type) == 4) \
{ \
dest[0] = (type)r / 0xff; \
unsigned int noisepattern[256];
VFrame *bgimage, *tmp;
- YUV *yuv;
int total;
};
float y_mid, u_mid, v_mid;
float y_high, u_high, v_high;
- YUV::rgb_to_yuv_f((float)config.low_color.r / 0xff,
+ YUV::yuv.rgb_to_yuv_f((float)config.low_color.r / 0xff,
(float)config.low_color.g / 0xff,
(float)config.low_color.b / 0xff,
y_low,
v_low);
u_low += 0.5;
v_low += 0.5;
- YUV::rgb_to_yuv_f((float)config.mid_color.r / 0xff,
+ YUV::yuv.rgb_to_yuv_f((float)config.mid_color.r / 0xff,
(float)config.mid_color.g / 0xff,
(float)config.mid_color.b / 0xff,
y_mid,
v_mid);
u_mid += 0.5;
v_mid += 0.5;
- YUV::rgb_to_yuv_f((float)config.high_color.r / 0xff,
+ YUV::yuv.rgb_to_yuv_f((float)config.high_color.r / 0xff,
(float)config.high_color.g / 0xff,
(float)config.high_color.b / 0xff,
y_high,
return v << 8 | v;
}
-static inline void rgb_to_yuv(YUV & yuv,
- unsigned char r, unsigned char g, unsigned char b,
+static inline void rgb_to_yuv(unsigned char r, unsigned char g, unsigned char b,
unsigned char & y, unsigned char & u, unsigned char & v)
{
- yuv.rgb_to_yuv_8(r, g, b, y, u, v);
+ YUV::yuv.rgb_to_yuv_8(r, g, b, y, u, v);
}
-static inline void rgb_to_yuv(YUV & yuv,
- float r, float g, float b,
+static inline void rgb_to_yuv(float r, float g, float b,
float & y, float & u, float & v)
{
- yuv.rgb_to_yuv_f(r, g, b, y, u, v);
+ YUV::yuv.rgb_to_yuv_f(r, g, b, y, u, v);
}
-static inline void rgb_to_yuv(YUV & yuv,
- uint16_t r, uint16_t g, uint16_t b,
+static inline void rgb_to_yuv(uint16_t r, uint16_t g, uint16_t b,
uint16_t & y, uint16_t & u, uint16_t & v)
{
- yuv.rgb_to_yuv_16(r, g, b, y, u, v);
+ YUV::yuv.rgb_to_yuv_16(r, g, b, y, u, v);
}
template<typename TYPE, int COMPONENTS, bool USE_YUV>
if (USE_YUV)
{
- rgb_to_yuv(*server->yuv, r_low, g_low, b_low, y_low, u_low, v_low);
- rgb_to_yuv(*server->yuv, r_mid, g_mid, b_mid, y_mid, u_mid, v_mid);
- rgb_to_yuv(*server->yuv, r_high, g_high, b_high, y_high, u_high, v_high);
+ rgb_to_yuv(r_low, g_low, b_low, y_low, u_low, v_low);
+ rgb_to_yuv(r_mid, g_mid, b_mid, y_mid, u_mid, v_mid);
+ rgb_to_yuv(r_high, g_high, b_high, y_high, u_high, v_high);
}
for(int i = pkg->start; i < pkg->end; i++)
plugin->get_project_smp() + 1)
{
this->plugin = plugin;
- yuv = new YUV;
}
ThresholdEngine::~ThresholdEngine()
{
- delete yuv;
}
void ThresholdEngine::process_packages(VFrame *data)
LoadClient* new_client();
LoadPackage* new_package();
- YUV *yuv;
ThresholdMain *plugin;
VFrame *data;
};
*/
#include "bcdisplayinfo.h"
+#include "bccolors.h"
#include "clip.h"
#include "bchash.h"
#include "filexml.h"
VideoScopeUnit(VideoScopeEffect *plugin, VideoScopeEngine *server);
void process_package(LoadPackage *package);
VideoScopeEffect *plugin;
- YUV yuv;
};
class VideoScopeEngine : public LoadServer
{ \
if(sizeof(type) == 2) \
{ \
- yuv.yuv_to_rgb_16(r, \
- g, \
- b, \
- in_pixel[0], \
- in_pixel[1], \
- in_pixel[2]); \
+ YUV::yuv.yuv_to_rgb_16(r, g, b, \
+ in_pixel[0], in_pixel[1], in_pixel[2]); \
} \
else \
{ \
- yuv.yuv_to_rgb_8(r, \
- g, \
- b, \
- in_pixel[0], \
- in_pixel[1], \
- in_pixel[2]); \
+ YUV::yuv.yuv_to_rgb_8(r, g, b, \
+ in_pixel[0], in_pixel[1], in_pixel[2]); \
} \
} \
else \