From: Good Guy Date: Wed, 29 Nov 2017 00:15:35 +0000 (-0700) Subject: yuv colorspace/range + prefs, ffmpeg colorrange probe, x11 direct force colormodel... X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=243336668c89096732786c6b3f3c5918aa2eff26;p=goodguy%2Fhistory.git yuv colorspace/range + prefs, ffmpeg colorrange probe, x11 direct force colormodel, freds opts files, rgbafloatp segv, clr [] ^t, del all mask pts shift del btnpress --- diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.C b/cinelerra-5.1/cinelerra/appearanceprefs.C index 0bf2e4f5..90b39c00 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.C +++ b/cinelerra-5.1/cinelerra/appearanceprefs.C @@ -142,6 +142,20 @@ void AppearancePrefs::create_objects() 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; @@ -521,3 +535,89 @@ int HighlightInverseColor::handle_event() 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]); idthread->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]); idthread->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(); +} + diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.h b/cinelerra-5.1/cinelerra/appearanceprefs.h index 7fbeeb92..e93563a5 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.h +++ b/cinelerra-5.1/cinelerra/appearanceprefs.h @@ -47,6 +47,8 @@ public: TimeFormatFeet *feet; TimeFormatSeconds *seconds; ViewThumbnails *thumbnails; + YuvColorSpace *yuv_color_space; + YuvColorRange *yuv_color_range; }; @@ -251,4 +253,48 @@ public: 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 diff --git a/cinelerra-5.1/cinelerra/appearanceprefs.inc b/cinelerra-5.1/cinelerra/appearanceprefs.inc index c96d4bc9..69f617ce 100644 --- a/cinelerra-5.1/cinelerra/appearanceprefs.inc +++ b/cinelerra-5.1/cinelerra/appearanceprefs.inc @@ -43,5 +43,11 @@ class BD_WarnRoot; class PopupMenuBtnup; class ActivateFocusPolicy; class DeactivateFocusPolicy; +class ForwardRenderDisplacement; +class HighlightInverseColor; +class YuvColorSpace; +class YuvColorSpaceItem; +class YuvColorRange; +class YuvColorRangeItem; #endif diff --git a/cinelerra-5.1/cinelerra/colorpicker.C b/cinelerra-5.1/cinelerra/colorpicker.C index b9db0c76..1b40fcf0 100644 --- a/cinelerra-5.1/cinelerra/colorpicker.C +++ b/cinelerra-5.1/cinelerra/colorpicker.C @@ -862,7 +862,7 @@ int PaletteCb::handle_event() 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; @@ -878,7 +878,7 @@ void ColorWindow::update_yuv(float y, float u, float v) { 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; @@ -897,7 +897,7 @@ void ColorWindow::update_hsv(float h, float s, float v) 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; diff --git a/cinelerra-5.1/cinelerra/cwindowgui.C b/cinelerra-5.1/cinelerra/cwindowgui.C index 21e8e90f..1c56a6d6 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.C +++ b/cinelerra-5.1/cinelerra/cwindowgui.C @@ -716,8 +716,7 @@ CWrapper(splice_selection) 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) diff --git a/cinelerra-5.1/cinelerra/cwindowgui.h b/cinelerra-5.1/cinelerra/cwindowgui.h index d08291d1..8ab72ac2 100644 --- a/cinelerra-5.1/cinelerra/cwindowgui.h +++ b/cinelerra-5.1/cinelerra/cwindowgui.h @@ -166,8 +166,7 @@ public: 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(); diff --git a/cinelerra-5.1/cinelerra/cwindowtool.C b/cinelerra-5.1/cinelerra/cwindowtool.C index bfb78560..329b09ec 100644 --- a/cinelerra-5.1/cinelerra/cwindowtool.C +++ b/cinelerra-5.1/cinelerra/cwindowtool.C @@ -546,7 +546,7 @@ void CWindowEyedropGUI::update() 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; @@ -1662,6 +1662,9 @@ int CWindowMaskDelete::handle_event() 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++) @@ -1683,6 +1686,8 @@ int CWindowMaskDelete::handle_event() 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; diff --git a/cinelerra-5.1/cinelerra/editpanel.C b/cinelerra-5.1/cinelerra/editpanel.C index d140faee..c056e2eb 100644 --- a/cinelerra-5.1/cinelerra/editpanel.C +++ b/cinelerra-5.1/cinelerra/editpanel.C @@ -646,14 +646,9 @@ void EditPanel::set_outpoint() 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); } @@ -679,6 +674,11 @@ int EditInPoint::keypress_event() panel->set_inpoint(); return 1; } + if(ctrl_down() && get_keypress() == 't') + { + panel->unset_inoutpoint(); + return 1; + } return 0; } @@ -704,6 +704,11 @@ int EditOutPoint::keypress_event() panel->set_outpoint(); return 1; } + if(ctrl_down() && get_keypress() == 't') + { + panel->unset_inoutpoint(); + return 1; + } return 0; } diff --git a/cinelerra-5.1/cinelerra/editpanel.h b/cinelerra-5.1/cinelerra/editpanel.h index 24cea3b7..054f6930 100644 --- a/cinelerra-5.1/cinelerra/editpanel.h +++ b/cinelerra-5.1/cinelerra/editpanel.h @@ -440,8 +440,7 @@ public: 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(); diff --git a/cinelerra-5.1/cinelerra/edl.C b/cinelerra-5.1/cinelerra/edl.C index 9b4e9c14..7298baa3 100644 --- a/cinelerra-5.1/cinelerra/edl.C +++ b/cinelerra-5.1/cinelerra/edl.C @@ -825,6 +825,12 @@ void EDL::set_outpoint(double position) } } +void EDL::unset_inoutpoint() +{ + local_session->unset_inpoint(); + local_session->unset_outpoint(); +} + int EDL::blade(double position) { return tracks->blade(position); diff --git a/cinelerra-5.1/cinelerra/edl.h b/cinelerra-5.1/cinelerra/edl.h index 13fd8d5d..e5955664 100644 --- a/cinelerra-5.1/cinelerra/edl.h +++ b/cinelerra-5.1/cinelerra/edl.h @@ -131,6 +131,7 @@ public: // 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 diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C index c536a265..fc3726e2 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.C +++ b/cinelerra-5.1/cinelerra/ffmpeg.C @@ -2533,6 +2533,10 @@ int FFMPEG::ff_video_pid(int stream) 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() { diff --git a/cinelerra-5.1/cinelerra/ffmpeg.h b/cinelerra-5.1/cinelerra/ffmpeg.h index 34bb7364..9a9f8552 100644 --- a/cinelerra-5.1/cinelerra/ffmpeg.h +++ b/cinelerra-5.1/cinelerra/ffmpeg.h @@ -350,6 +350,7 @@ public: 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); diff --git a/cinelerra-5.1/cinelerra/file.C b/cinelerra-5.1/cinelerra/file.C index bd1a0c6d..76cb743f 100644 --- a/cinelerra-5.1/cinelerra/file.C +++ b/cinelerra-5.1/cinelerra/file.C @@ -1317,12 +1317,10 @@ int File::bytes_per_sample(int bits) } - - - -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) diff --git a/cinelerra-5.1/cinelerra/file.h b/cinelerra-5.1/cinelerra/file.h index f62739e0..779b3d1e 100644 --- a/cinelerra-5.1/cinelerra/file.h +++ b/cinelerra-5.1/cinelerra/file.h @@ -228,7 +228,7 @@ public: // 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); diff --git a/cinelerra-5.1/cinelerra/filebase.C b/cinelerra-5.1/cinelerra/filebase.C index 5629f6c2..29813196 100644 --- a/cinelerra-5.1/cinelerra/filebase.C +++ b/cinelerra-5.1/cinelerra/filebase.C @@ -245,6 +245,11 @@ void FileBase::get_mode(char *mode, int rd, int wr) } } +int FileBase::get_best_colormodel(int driver, int vstream) +{ + return File::get_best_colormodel(asset, driver); +} + // ======================================= audio codecs diff --git a/cinelerra-5.1/cinelerra/filebase.h b/cinelerra-5.1/cinelerra/filebase.h index 1fc58c0b..5e8d291e 100644 --- a/cinelerra-5.1/cinelerra/filebase.h +++ b/cinelerra-5.1/cinelerra/filebase.h @@ -75,6 +75,8 @@ public: 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; } diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.C b/cinelerra-5.1/cinelerra/fileffmpeg.C index f3f53568..4d797431 100644 --- a/cinelerra-5.1/cinelerra/fileffmpeg.C +++ b/cinelerra-5.1/cinelerra/fileffmpeg.C @@ -335,13 +335,28 @@ int FileFFMPEG::colormodel_supported(int colormodel) 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; diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.h b/cinelerra-5.1/cinelerra/fileffmpeg.h index 973cde15..f6328f38 100644 --- a/cinelerra-5.1/cinelerra/fileffmpeg.h +++ b/cinelerra-5.1/cinelerra/fileffmpeg.h @@ -35,6 +35,7 @@ public: 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); diff --git a/cinelerra-5.1/cinelerra/filethread.C b/cinelerra-5.1/cinelerra/filethread.C index 338176e6..84b20fcd 100644 --- a/cinelerra-5.1/cinelerra/filethread.C +++ b/cinelerra-5.1/cinelerra/filethread.C @@ -197,7 +197,7 @@ void FileThread::run() 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 diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C index 0bfd3770..84ba6830 100644 --- a/cinelerra-5.1/cinelerra/mwindow.C +++ b/cinelerra-5.1/cinelerra/mwindow.C @@ -904,6 +904,7 @@ void MWindow::init_preferences() 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() @@ -2068,7 +2069,7 @@ if(debug) printf("MWindow::load_filenames %d\n", __LINE__); 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); diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h index 19d9436a..ef4ca955 100644 --- a/cinelerra-5.1/cinelerra/mwindow.h +++ b/cinelerra-5.1/cinelerra/mwindow.h @@ -352,8 +352,6 @@ public: 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); @@ -482,6 +480,7 @@ public: 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(); diff --git a/cinelerra-5.1/cinelerra/mwindowedit.C b/cinelerra-5.1/cinelerra/mwindowedit.C index b7fcd9dd..c0dcd61d 100644 --- a/cinelerra-5.1/cinelerra/mwindowedit.C +++ b/cinelerra-5.1/cinelerra/mwindowedit.C @@ -631,19 +631,6 @@ int MWindow::cut_default_keyframe() } -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 ) @@ -1983,6 +1970,30 @@ void MWindow::set_outpoint(int is_mwindow) } } +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; diff --git a/cinelerra-5.1/cinelerra/preferences.C b/cinelerra-5.1/cinelerra/preferences.C index 257a12ab..b44319be 100644 --- a/cinelerra-5.1/cinelerra/preferences.C +++ b/cinelerra-5.1/cinelerra/preferences.C @@ -90,6 +90,8 @@ Preferences::Preferences() 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; @@ -208,6 +210,8 @@ void Preferences::copy_from(Preferences *that) 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(); @@ -366,6 +370,8 @@ int Preferences::load_defaults(BC_Hash *defaults) 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); @@ -498,6 +504,8 @@ int Preferences::save_defaults(BC_Hash *defaults) 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); diff --git a/cinelerra-5.1/cinelerra/preferences.h b/cinelerra-5.1/cinelerra/preferences.h index c93187ea..55d47e89 100644 --- a/cinelerra-5.1/cinelerra/preferences.h +++ b/cinelerra-5.1/cinelerra/preferences.h @@ -124,6 +124,9 @@ public: 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]; diff --git a/cinelerra-5.1/cinelerra/preferencesthread.C b/cinelerra-5.1/cinelerra/preferencesthread.C index 9cca7fa5..39a198d4 100644 --- a/cinelerra-5.1/cinelerra/preferencesthread.C +++ b/cinelerra-5.1/cinelerra/preferencesthread.C @@ -211,6 +211,14 @@ int PreferencesThread::apply_settings() (*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); diff --git a/cinelerra-5.1/cinelerra/vrender.C b/cinelerra-5.1/cinelerra/vrender.C index f46a4096..1a3706fa 100644 --- a/cinelerra-5.1/cinelerra/vrender.C +++ b/cinelerra-5.1/cinelerra/vrender.C @@ -247,43 +247,37 @@ int VRender::get_use_vconsole(VEdit **playable_edit, } -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; } } @@ -291,11 +285,6 @@ int VRender::get_colormodel(VEdit *playable_edit, } - - - - - void VRender::run() { int reconfigure; diff --git a/cinelerra-5.1/cinelerra/vwindow.C b/cinelerra-5.1/cinelerra/vwindow.C index 897f21ec..8de4eb73 100644 --- a/cinelerra-5.1/cinelerra/vwindow.C +++ b/cinelerra-5.1/cinelerra/vwindow.C @@ -384,22 +384,12 @@ void VWindow::set_outpoint() } } -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); } } diff --git a/cinelerra-5.1/cinelerra/vwindow.h b/cinelerra-5.1/cinelerra/vwindow.h index fb5268be..a9ee980a 100644 --- a/cinelerra-5.1/cinelerra/vwindow.h +++ b/cinelerra-5.1/cinelerra/vwindow.h @@ -68,8 +68,7 @@ public: 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(); diff --git a/cinelerra-5.1/cinelerra/vwindowgui.C b/cinelerra-5.1/cinelerra/vwindowgui.C index 0642dd81..d6ab939d 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.C +++ b/cinelerra-5.1/cinelerra/vwindowgui.C @@ -640,15 +640,11 @@ void VWindowEditing::set_outpoint() 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() { diff --git a/cinelerra-5.1/cinelerra/vwindowgui.h b/cinelerra-5.1/cinelerra/vwindowgui.h index 424e9e50..5dcdc784 100644 --- a/cinelerra-5.1/cinelerra/vwindowgui.h +++ b/cinelerra-5.1/cinelerra/vwindowgui.h @@ -137,8 +137,7 @@ public: 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(); diff --git a/cinelerra-5.1/ffmpeg/audio/flac.mkv b/cinelerra-5.1/ffmpeg/audio/flac.mkv new file mode 100644 index 00000000..e3f32508 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/flac.mkv @@ -0,0 +1 @@ +matroska flac diff --git a/cinelerra-5.1/ffmpeg/audio/flac.ogg b/cinelerra-5.1/ffmpeg/audio/flac.ogg new file mode 100644 index 00000000..0ff419b1 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/flac.ogg @@ -0,0 +1 @@ +ogg flac diff --git a/cinelerra-5.1/ffmpeg/audio/flac.webm b/cinelerra-5.1/ffmpeg/audio/flac.webm new file mode 100644 index 00000000..84f34f94 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/flac.webm @@ -0,0 +1 @@ +webm flac diff --git a/cinelerra-5.1/ffmpeg/audio/opus.mkv b/cinelerra-5.1/ffmpeg/audio/opus.mkv new file mode 100644 index 00000000..37213a91 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/opus.mkv @@ -0,0 +1 @@ +matroska libopus diff --git a/cinelerra-5.1/ffmpeg/audio/opus.ogg b/cinelerra-5.1/ffmpeg/audio/opus.ogg new file mode 100644 index 00000000..bca147e4 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/opus.ogg @@ -0,0 +1 @@ +webm libopus diff --git a/cinelerra-5.1/ffmpeg/audio/opus.webm b/cinelerra-5.1/ffmpeg/audio/opus.webm new file mode 100644 index 00000000..bca147e4 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/opus.webm @@ -0,0 +1 @@ +webm libopus diff --git a/cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.mkv b/cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.mkv new file mode 100644 index 00000000..df4e2cea --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.mkv @@ -0,0 +1,2 @@ +matroska opus +strict -2 diff --git a/cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.ogg b/cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.ogg new file mode 100644 index 00000000..17fa00ee --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.ogg @@ -0,0 +1,2 @@ +webm opus +strict -2 diff --git a/cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.webm b/cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.webm new file mode 100644 index 00000000..17fa00ee --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.webm @@ -0,0 +1,2 @@ +webm opus +strict -2 diff --git a/cinelerra-5.1/ffmpeg/audio/vorbis.mkv b/cinelerra-5.1/ffmpeg/audio/vorbis.mkv new file mode 100644 index 00000000..e3dbcb7d --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/vorbis.mkv @@ -0,0 +1 @@ +matroska libvorbis diff --git a/cinelerra-5.1/ffmpeg/audio/vorbis.ogg b/cinelerra-5.1/ffmpeg/audio/vorbis.ogg new file mode 100644 index 00000000..1fa55073 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/vorbis.ogg @@ -0,0 +1,2 @@ +ogg libvorbis +cin_quality=5 diff --git a/cinelerra-5.1/ffmpeg/audio/vorbis.webm b/cinelerra-5.1/ffmpeg/audio/vorbis.webm new file mode 100644 index 00000000..d380c117 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/audio/vorbis.webm @@ -0,0 +1 @@ +webm libvorbis diff --git a/cinelerra-5.1/ffmpeg/video/theora.mkv b/cinelerra-5.1/ffmpeg/video/theora.mkv new file mode 100644 index 00000000..f2913e4c --- /dev/null +++ b/cinelerra-5.1/ffmpeg/video/theora.mkv @@ -0,0 +1,2 @@ +matroska libtheora +cin_quality=7 diff --git a/cinelerra-5.1/ffmpeg/video/theora.ogg b/cinelerra-5.1/ffmpeg/video/theora.ogg new file mode 100644 index 00000000..17565ef0 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/video/theora.ogg @@ -0,0 +1,2 @@ +ogg libtheora +cin_quality=7 diff --git a/cinelerra-5.1/ffmpeg/video/vp8.mkv b/cinelerra-5.1/ffmpeg/video/vp8.mkv new file mode 100644 index 00000000..f5b40fc8 --- /dev/null +++ b/cinelerra-5.1/ffmpeg/video/vp8.mkv @@ -0,0 +1 @@ +matroska libvpx \ No newline at end of file diff --git a/cinelerra-5.1/ffmpeg/video/vp8.webm b/cinelerra-5.1/ffmpeg/video/vp8.webm new file mode 100644 index 00000000..da4b56ed --- /dev/null +++ b/cinelerra-5.1/ffmpeg/video/vp8.webm @@ -0,0 +1 @@ +webm libvpx diff --git a/cinelerra-5.1/ffmpeg/video/webm.webm b/cinelerra-5.1/ffmpeg/video/webm.webm index da4b56ed..4f852d0b 100644 --- a/cinelerra-5.1/ffmpeg/video/webm.webm +++ b/cinelerra-5.1/ffmpeg/video/webm.webm @@ -1 +1 @@ -webm libvpx +webm libvpx-vp9 diff --git a/cinelerra-5.1/guicast/bccmdl.py b/cinelerra-5.1/guicast/bccmdl.py index 27c3a050..3f7709cc 100755 --- a/cinelerra-5.1/guicast/bccmdl.py +++ b/cinelerra-5.1/guicast/bccmdl.py @@ -3,12 +3,12 @@ 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;", }, @@ -44,7 +44,8 @@ base = { "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": { @@ -55,7 +56,7 @@ base = { "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++;", @@ -107,8 +108,9 @@ base = { "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);", @@ -121,7 +123,8 @@ base = { "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": { @@ -132,7 +135,7 @@ base = { "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++;", @@ -160,33 +163,33 @@ base = { "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; }", }, @@ -194,12 +197,12 @@ base = { "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; }", }, @@ -208,13 +211,13 @@ base = { "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);", }, @@ -222,87 +225,87 @@ base = { "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;", }, }, @@ -324,22 +327,22 @@ base = { "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;", }, }, @@ -351,7 +354,7 @@ base = { "w": " *out++ = a;", }, "i16": { - "r": " z_int a = *inp++<<8;", + "r": " z_int a = *inp++; a = (a<<8) | a;", "w": " *out++ = a>>8;", }, "fp": { @@ -362,7 +365,7 @@ base = { "a16": { "i8": { "r": " z_int a = *inp++>>8;", - "w": " *out++ = a<<8;", + "w": " *out++ = (a<<8) | a;", }, "i16": { "r": " z_int a = *inp++;", @@ -558,9 +561,9 @@ def gen_xfer_fn(fr_cmdl, to_cmdl): 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;", @@ -576,19 +579,14 @@ def gen_xfer_fn(fr_cmdl, to_cmdl): # 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]) diff --git a/cinelerra-5.1/guicast/bccolors.C b/cinelerra-5.1/guicast/bccolors.C index 48dcb02a..a287fb78 100644 --- a/cinelerra-5.1/guicast/bccolors.C +++ b/cinelerra-5.1/guicast/bccolors.C @@ -22,6 +22,7 @@ #include "bccolors.h" #include +#include HSV::HSV() { @@ -32,8 +33,6 @@ 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; @@ -125,68 +124,171 @@ int HSV::hsv_to_yuv(int &y, int &u, int &v, float h, float s, float va, int max) 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; rgbrgb + 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 +// 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) {} }; @@ -197,7 +329,7 @@ class HSV { 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); @@ -213,50 +345,50 @@ public: // 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 diff --git a/cinelerra-5.1/guicast/test4.C b/cinelerra-5.1/guicast/test4.C index 23535cd1..79b8623e 100644 --- a/cinelerra-5.1/guicast/test4.C +++ b/cinelerra-5.1/guicast/test4.C @@ -11,6 +11,7 @@ #include #include +#include "bcwindowbase.h" #include "bcwindow.h" #include "bcsignals.h" #include "bccolors.h" @@ -81,7 +82,7 @@ const char *cmdl[] = { "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, ...) @@ -124,16 +125,17 @@ int main(int ac, char **av) 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); diff --git a/cinelerra-5.1/guicast/xfer.C b/cinelerra-5.1/guicast/xfer.C index f5c52196..e4ac81fe 100644 --- a/cinelerra-5.1/guicast/xfer.C +++ b/cinelerra-5.1/guicast/xfer.C @@ -1,100 +1,4 @@ -// 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, @@ -143,6 +47,8 @@ void BC_Xfer::init( 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; } diff --git a/cinelerra-5.1/guicast/xfer.h b/cinelerra-5.1/guicast/xfer.h index 84098b51..508f977b 100644 --- a/cinelerra-5.1/guicast/xfer.h +++ b/cinelerra-5.1/guicast/xfer.h @@ -22,65 +22,6 @@ static inline float fclp(float v, const int n) { 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; ipalette[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; \ @@ -302,7 +299,7 @@ BurnClient::BurnClient(BurnServer *server) 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); \ @@ -316,7 +313,7 @@ BurnClient::BurnClient(BurnServer *server) 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; \ @@ -331,7 +328,7 @@ BurnClient::BurnClient(BurnServer *server) 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; \ diff --git a/cinelerra-5.1/plugins/chromakey/chromakey.C b/cinelerra-5.1/plugins/chromakey/chromakey.C index 4eb39787..9bae8312 100644 --- a/cinelerra-5.1/plugins/chromakey/chromakey.C +++ b/cinelerra-5.1/plugins/chromakey/chromakey.C @@ -389,7 +389,6 @@ void ChromaKeyUnit::process_package(LoadPackage *package) #define OUTER_VARIABLES(plugin) \ - YUV yuv; \ float value = RGB_TO_VALUE(plugin->config.red, \ plugin->config.green, \ plugin->config.blue); \ @@ -400,7 +399,9 @@ void ChromaKeyUnit::process_package(LoadPackage *package) 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; diff --git a/cinelerra-5.1/plugins/chromakeyhsv/chromakey.C b/cinelerra-5.1/plugins/chromakeyhsv/chromakey.C index b0a09757..a56cff1e 100644 --- a/cinelerra-5.1/plugins/chromakeyhsv/chromakey.C +++ b/cinelerra-5.1/plugins/chromakeyhsv/chromakey.C @@ -703,7 +703,7 @@ void ChromaKeyUnit::process_chromakey(int components, 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); @@ -797,7 +797,7 @@ void ChromaKeyUnit::process_chromakey(int components, 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); diff --git a/cinelerra-5.1/plugins/color3way/color3way.C b/cinelerra-5.1/plugins/color3way/color3way.C index 5e5d4126..5704ded3 100644 --- a/cinelerra-5.1/plugins/color3way/color3way.C +++ b/cinelerra-5.1/plugins/color3way/color3way.C @@ -204,9 +204,7 @@ Color3WayUnit::Color3WayUnit(Color3WayMain *plugin, 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); \ @@ -225,7 +223,7 @@ Color3WayUnit::Color3WayUnit(Color3WayMain *plugin, 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; \ diff --git a/cinelerra-5.1/plugins/crikey/crikey.C b/cinelerra-5.1/plugins/crikey/crikey.C index 17373ef5..6c110c43 100644 --- a/cinelerra-5.1/plugins/crikey/crikey.C +++ b/cinelerra-5.1/plugins/crikey/crikey.C @@ -255,7 +255,7 @@ void CriKeyConfig::set_target(int is_yuv, int color, float *target) 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; @@ -273,7 +273,7 @@ void CriKeyConfig::set_color(int is_yuv, float *target, int &color) 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); diff --git a/cinelerra-5.1/plugins/gamma/gamma.C b/cinelerra-5.1/plugins/gamma/gamma.C index 28d04fc5..1307d8cd 100644 --- a/cinelerra-5.1/plugins/gamma/gamma.C +++ b/cinelerra-5.1/plugins/gamma/gamma.C @@ -177,7 +177,7 @@ void GammaUnit::process_package(LoadPackage *package) 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: @@ -188,7 +188,7 @@ void GammaUnit::process_package(LoadPackage *package) 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; } @@ -275,9 +275,9 @@ void GammaUnit::process_package(LoadPackage *package) 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; @@ -294,9 +294,9 @@ void GammaUnit::process_package(LoadPackage *package) 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; diff --git a/cinelerra-5.1/plugins/gradient/gradient.C b/cinelerra-5.1/plugins/gradient/gradient.C index 2fa78984..9b49f85c 100644 --- a/cinelerra-5.1/plugins/gradient/gradient.C +++ b/cinelerra-5.1/plugins/gradient/gradient.C @@ -983,14 +983,14 @@ int GradientMain::handle_opengl() { 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, diff --git a/cinelerra-5.1/plugins/histogram/histogram.C b/cinelerra-5.1/plugins/histogram/histogram.C index fd2cdc86..a31f2fec 100644 --- a/cinelerra-5.1/plugins/histogram/histogram.C +++ b/cinelerra-5.1/plugins/histogram/histogram.C @@ -957,7 +957,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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: @@ -979,7 +979,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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: @@ -994,7 +994,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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: @@ -1009,7 +1009,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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; } @@ -1060,7 +1060,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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]; \ @@ -1068,7 +1068,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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) \ { \ diff --git a/cinelerra-5.1/plugins/histogram/histogram.h b/cinelerra-5.1/plugins/histogram/histogram.h index 317c1beb..6a5d527b 100644 --- a/cinelerra-5.1/plugins/histogram/histogram.h +++ b/cinelerra-5.1/plugins/histogram/histogram.h @@ -65,7 +65,6 @@ public: - YUV yuv; VFrame *input, *output; HistogramEngine *engine; int *lookup[HISTOGRAM_MODES]; diff --git a/cinelerra-5.1/plugins/histogram_bezier/bistogram.C b/cinelerra-5.1/plugins/histogram_bezier/bistogram.C index 23688b18..7c096cbe 100644 --- a/cinelerra-5.1/plugins/histogram_bezier/bistogram.C +++ b/cinelerra-5.1/plugins/histogram_bezier/bistogram.C @@ -649,7 +649,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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: @@ -671,7 +671,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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: @@ -686,7 +686,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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: @@ -701,7 +701,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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; } @@ -752,7 +752,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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]; \ @@ -760,7 +760,7 @@ void HistogramUnit::process_package(LoadPackage *package) 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) \ { \ diff --git a/cinelerra-5.1/plugins/histogram_bezier/bistogram.h b/cinelerra-5.1/plugins/histogram_bezier/bistogram.h index 97f31520..2a3849d5 100644 --- a/cinelerra-5.1/plugins/histogram_bezier/bistogram.h +++ b/cinelerra-5.1/plugins/histogram_bezier/bistogram.h @@ -68,7 +68,6 @@ public: - YUV yuv; VFrame *input, *output; HistogramEngine *engine; int *lookup[HISTOGRAM_MODES]; diff --git a/cinelerra-5.1/plugins/holo/holo.C b/cinelerra-5.1/plugins/holo/holo.C index 7a111923..717f0f36 100644 --- a/cinelerra-5.1/plugins/holo/holo.C +++ b/cinelerra-5.1/plugins/holo/holo.C @@ -60,24 +60,17 @@ HoloMain::HoloMain(PluginServer *server) 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"); } @@ -361,7 +354,7 @@ if(sizeof(type) == 2) \ 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 \ @@ -378,7 +371,7 @@ 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 \ @@ -435,7 +428,7 @@ 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; \ @@ -502,7 +495,7 @@ 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; \ diff --git a/cinelerra-5.1/plugins/holo/holo.h b/cinelerra-5.1/plugins/holo/holo.h index 37dbb0b1..85c47fc8 100644 --- a/cinelerra-5.1/plugins/holo/holo.h +++ b/cinelerra-5.1/plugins/holo/holo.h @@ -104,7 +104,6 @@ public: unsigned int noisepattern[256]; VFrame *bgimage, *tmp; - YUV *yuv; int total; }; diff --git a/cinelerra-5.1/plugins/threshold/threshold.C b/cinelerra-5.1/plugins/threshold/threshold.C index 052ba252..fdcd5af6 100644 --- a/cinelerra-5.1/plugins/threshold/threshold.C +++ b/cinelerra-5.1/plugins/threshold/threshold.C @@ -316,7 +316,7 @@ int ThresholdMain::handle_opengl() 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, @@ -324,7 +324,7 @@ int ThresholdMain::handle_opengl() 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, @@ -332,7 +332,7 @@ int ThresholdMain::handle_opengl() 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, @@ -456,25 +456,22 @@ inline uint16_t scale_to_range(int v) 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 @@ -509,9 +506,9 @@ void ThresholdUnit::render_data(LoadPackage *package) 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++) @@ -631,12 +628,10 @@ ThresholdEngine::ThresholdEngine(ThresholdMain *plugin) plugin->get_project_smp() + 1) { this->plugin = plugin; - yuv = new YUV; } ThresholdEngine::~ThresholdEngine() { - delete yuv; } void ThresholdEngine::process_packages(VFrame *data) diff --git a/cinelerra-5.1/plugins/threshold/threshold.h b/cinelerra-5.1/plugins/threshold/threshold.h index 0d8769f2..1dcd13cd 100644 --- a/cinelerra-5.1/plugins/threshold/threshold.h +++ b/cinelerra-5.1/plugins/threshold/threshold.h @@ -149,7 +149,6 @@ public: LoadClient* new_client(); LoadPackage* new_package(); - YUV *yuv; ThresholdMain *plugin; VFrame *data; }; diff --git a/cinelerra-5.1/plugins/videoscope/videoscope.C b/cinelerra-5.1/plugins/videoscope/videoscope.C index 0fbae88f..57722432 100644 --- a/cinelerra-5.1/plugins/videoscope/videoscope.C +++ b/cinelerra-5.1/plugins/videoscope/videoscope.C @@ -20,6 +20,7 @@ */ #include "bcdisplayinfo.h" +#include "bccolors.h" #include "clip.h" #include "bchash.h" #include "filexml.h" @@ -83,7 +84,6 @@ public: VideoScopeUnit(VideoScopeEffect *plugin, VideoScopeEngine *server); void process_package(LoadPackage *package); VideoScopeEffect *plugin; - YUV yuv; }; class VideoScopeEngine : public LoadServer @@ -416,21 +416,13 @@ static void draw_point(unsigned char **rows, { \ 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 \