yuv colorspace/range + prefs, ffmpeg colorrange probe, x11 direct force colormodel...
authorGood Guy <[email protected]>
Wed, 29 Nov 2017 00:15:35 +0000 (17:15 -0700)
committerGood Guy <[email protected]>
Wed, 29 Nov 2017 00:15:35 +0000 (17:15 -0700)
73 files changed:
cinelerra-5.1/cinelerra/appearanceprefs.C
cinelerra-5.1/cinelerra/appearanceprefs.h
cinelerra-5.1/cinelerra/appearanceprefs.inc
cinelerra-5.1/cinelerra/colorpicker.C
cinelerra-5.1/cinelerra/cwindowgui.C
cinelerra-5.1/cinelerra/cwindowgui.h
cinelerra-5.1/cinelerra/cwindowtool.C
cinelerra-5.1/cinelerra/editpanel.C
cinelerra-5.1/cinelerra/editpanel.h
cinelerra-5.1/cinelerra/edl.C
cinelerra-5.1/cinelerra/edl.h
cinelerra-5.1/cinelerra/ffmpeg.C
cinelerra-5.1/cinelerra/ffmpeg.h
cinelerra-5.1/cinelerra/file.C
cinelerra-5.1/cinelerra/file.h
cinelerra-5.1/cinelerra/filebase.C
cinelerra-5.1/cinelerra/filebase.h
cinelerra-5.1/cinelerra/fileffmpeg.C
cinelerra-5.1/cinelerra/fileffmpeg.h
cinelerra-5.1/cinelerra/filethread.C
cinelerra-5.1/cinelerra/mwindow.C
cinelerra-5.1/cinelerra/mwindow.h
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/preferences.C
cinelerra-5.1/cinelerra/preferences.h
cinelerra-5.1/cinelerra/preferencesthread.C
cinelerra-5.1/cinelerra/vrender.C
cinelerra-5.1/cinelerra/vwindow.C
cinelerra-5.1/cinelerra/vwindow.h
cinelerra-5.1/cinelerra/vwindowgui.C
cinelerra-5.1/cinelerra/vwindowgui.h
cinelerra-5.1/ffmpeg/audio/flac.mkv [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/flac.ogg [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/flac.webm [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/opus.mkv [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/opus.ogg [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/opus.webm [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.mkv [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.ogg [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/opus_ffmpeg.webm [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/vorbis.mkv [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/vorbis.ogg [new file with mode: 0644]
cinelerra-5.1/ffmpeg/audio/vorbis.webm [new file with mode: 0644]
cinelerra-5.1/ffmpeg/video/theora.mkv [new file with mode: 0644]
cinelerra-5.1/ffmpeg/video/theora.ogg [new file with mode: 0644]
cinelerra-5.1/ffmpeg/video/vp8.mkv [new file with mode: 0644]
cinelerra-5.1/ffmpeg/video/vp8.webm [new file with mode: 0644]
cinelerra-5.1/ffmpeg/video/webm.webm
cinelerra-5.1/guicast/bccmdl.py
cinelerra-5.1/guicast/bccolors.C
cinelerra-5.1/guicast/bccolors.h
cinelerra-5.1/guicast/test4.C
cinelerra-5.1/guicast/xfer.C
cinelerra-5.1/guicast/xfer.h
cinelerra-5.1/plugins/bluebanana/bluebanana.h
cinelerra-5.1/plugins/brightness/brightness.C
cinelerra-5.1/plugins/brightness/brightness.h
cinelerra-5.1/plugins/burn/burn.C
cinelerra-5.1/plugins/chromakey/chromakey.C
cinelerra-5.1/plugins/chromakeyhsv/chromakey.C
cinelerra-5.1/plugins/color3way/color3way.C
cinelerra-5.1/plugins/crikey/crikey.C
cinelerra-5.1/plugins/gamma/gamma.C
cinelerra-5.1/plugins/gradient/gradient.C
cinelerra-5.1/plugins/histogram/histogram.C
cinelerra-5.1/plugins/histogram/histogram.h
cinelerra-5.1/plugins/histogram_bezier/bistogram.C
cinelerra-5.1/plugins/histogram_bezier/bistogram.h
cinelerra-5.1/plugins/holo/holo.C
cinelerra-5.1/plugins/holo/holo.h
cinelerra-5.1/plugins/threshold/threshold.C
cinelerra-5.1/plugins/threshold/threshold.h
cinelerra-5.1/plugins/videoscope/videoscope.C

index 0bf2e4f5ea008ac4605eef52263ade677e7d9515..90b39c0028d568a651e4dd368514a7eeac8fb232 100644 (file)
@@ -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]); 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();
+}
+
index 7fbeeb9259b50f6d40cc0badcb2a682200abf6ec..e93563a5483cd68bc6734e05c5fab44e04db02d5 100644 (file)
@@ -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
index c96d4bc9e6925066e97cffdca4e2fba39d5b93c8..69f617ce673709540a33fecc78743f521a284ab9 100644 (file)
@@ -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
index b9db0c76e96a8d4fed7c8ab129e6829b82bbd9ec..1b40fcf0c38f8d00bca6f4b35972422918d71c3c 100644 (file)
@@ -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;
index 21e8e90f76ce6d1e4cd80576abcd8e51480e3061..1c56a6d641e3b70f3f737906fe8c6d794d4a7884 100644 (file)
@@ -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)
index d08291d15da1c806e655b3e64e5ced55f286aa3a..8ab72ac2c2a0bde800a7e0f442425ec86f32085d 100644 (file)
@@ -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();
index bfb7856018b76733d106af2a97a94c491752f964..329b09ecc8bacacd120cf6ed7f965ebf5df5392a 100644 (file)
@@ -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;
index d140faee0f6d4230e58fe58c13640cbabdda09a4..c056e2ebbec836635550ebefa9f774a918bed480 100644 (file)
@@ -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;
 }
 
index 24cea3b74b9cb21c0e7b830a0b38febc7478fd09..054f6930b8d1cdd10e793daccdc59a16d7a9c286 100644 (file)
@@ -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();
index 9b4e9c142bf6358c4250d05dd98e981441ed2196..7298baa32cac604c0548507e0c171122114a05ae 100644 (file)
@@ -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);
index 13fd8d5df61c41cbbd37f873cebb629334f36646..e59556640eda8d440927af15e4af87d66f95df88 100644 (file)
@@ -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
index c536a2652291595c3f2c7b12e3c4e00eac2a9ee2..fc3726e222487fece097b629c66b06fb412edac7 100644 (file)
@@ -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()
 {
index 34bb736448ddc4384990abc6335857ece16e0d37..9a9f855249a1caf83434e00b998de1b8153e5c01 100644 (file)
@@ -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);
index bd1a0c6db5057c45e688b9207407a0394cc85ac1..76cb743f93f46e6efd525360fa27b5959120cdc6 100644 (file)
@@ -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)
index f62739e0990b23605f1ac0ff3d1c86867daacde9..779b3d1efea32902306bc09bc0bd1b07c6cf0521 100644 (file)
@@ -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);
index 5629f6c257229bba6951ab8fcd9140b88d00da0f..29813196beb308005ab5ac159175574fd4f1db27 100644 (file)
@@ -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
 
index 1fc58c0b28b99260926f7a75ab2a7f6da444feff..5e8d291e747b3105a1f289847409e18a658c2112 100644 (file)
@@ -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; }
index f3f535681234e3bbefe1a17d841eae4443458c55..4d797431eeb9e57151d13c6afca9469a7cae19eb 100644 (file)
@@ -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;
index 973cde15c847ff8f42eb48b624732a94311f522e..f6328f380fe472c5240358a0b0a59e6a387b9e14 100644 (file)
@@ -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);
index 338176e6d86932116178431fe3aab071863fb528..84b20fcdd45fbf289833c9c8dd6623143f8b2ba4 100644 (file)
@@ -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
 
 
index 0bfd3770b58e6fbbc4090e5cbe096f0eab411aa9..84ba6830aa88bd39cfea54d154dd94ead97a07ff 100644 (file)
@@ -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);
index 19d9436ae7b8959fd3c112a680828216ad7290e9..ef4ca95531af019066369b264d7ae92d85457591 100644 (file)
@@ -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();
index b7fcd9dda0ca1262aa0228c246b2b1bedd9b7b34..c0dcd61da4d24daec055e3cca68dcbe43c7c6025 100644 (file)
@@ -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;
index 257a12ab1ef2896a41e2843b44c7652c619c5bf9..b44319be24a0c32d8aaacf0d41f819853e5f54a5 100644 (file)
@@ -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);
index c93187ea86f2a328c30205e5400ad0ceb7b03c0a..55d47e890b176e264cb47e0a8cc9d7aba76b8500 100644 (file)
@@ -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];
index 9cca7fa56ec73eb89895ab442c671152fb4b4fd5..39a198d435cbef017e33cc449e6f050266bc1f3e 100644 (file)
@@ -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);
index f46a4096b95f8b3750725b7411b04467f9954946..1a3706fa7b9d3462c4f8d407175799ea5e5d9b37 100644 (file)
@@ -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;
index 897f21ec8c7e77a946984ac9634b0f78a1c978fe..8de4eb73170154add8af0a090bb621e81107e84c 100644 (file)
@@ -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);
        }
 }
index fb5268be679f480e9488fca7d4994d37a6e690c3..a9ee980ad88628d915103481769c374913c75d08 100644 (file)
@@ -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();
index 0642dd81f05dbed51e7850ab08ff9adc830fe525..d6ab939d0e6376ec0461c0a765dd61fa036e83d1 100644 (file)
@@ -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()
 {
index 424e9e50be5b79eabec3b4b90d1e73aa3daa12ab..5dcdc78471636b5734c061d61f890d0d7ab353d4 100644 (file)
@@ -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 (file)
index 0000000..e3f3250
--- /dev/null
@@ -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 (file)
index 0000000..0ff419b
--- /dev/null
@@ -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 (file)
index 0000000..84f34f9
--- /dev/null
@@ -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 (file)
index 0000000..37213a9
--- /dev/null
@@ -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 (file)
index 0000000..bca147e
--- /dev/null
@@ -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 (file)
index 0000000..bca147e
--- /dev/null
@@ -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 (file)
index 0000000..df4e2ce
--- /dev/null
@@ -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 (file)
index 0000000..17fa00e
--- /dev/null
@@ -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 (file)
index 0000000..17fa00e
--- /dev/null
@@ -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 (file)
index 0000000..e3dbcb7
--- /dev/null
@@ -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 (file)
index 0000000..1fa5507
--- /dev/null
@@ -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 (file)
index 0000000..d380c11
--- /dev/null
@@ -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 (file)
index 0000000..f2913e4
--- /dev/null
@@ -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 (file)
index 0000000..17565ef
--- /dev/null
@@ -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 (file)
index 0000000..f5b40fc
--- /dev/null
@@ -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 (file)
index 0000000..da4b56e
--- /dev/null
@@ -0,0 +1 @@
+webm libvpx
index da4b56ed5ec0a8b76692f7d0fb1c6b91ae451a14..4f852d0b364154aa27470c9845210f9ed75a1be1 100644 (file)
@@ -1 +1 @@
-webm libvpx
+webm libvpx-vp9
index 27c3a050fcbe162a1454459ac1ab934ea1511228..3f7709cc190c1ee1ab679aa1981dc6e2d1db28dc 100755 (executable)
@@ -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])
index 48dcb02aa5acd649c69591311bb056d5b712bf03..a287fb78c64fa7ee2bb0dedfb34483f160aa8df9 100644 (file)
@@ -22,6 +22,7 @@
 #include "bccolors.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 
 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; 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;
 }
 
index c91aba9fc405b97f061b3fc35b1cad5916161316..eed34fef482bcf4ee18c20ea87aebfff5d587a1e 100644 (file)
 
 #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) {}
 };
 
 
@@ -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
index 23535cd167297fc7e1543be6946be88666d58661..79b8623e94696dd58a1f05e07da7104c7ab1bcae 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
+#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);
index f5c521961105893957209b4d8a3c21298d6169f7..e4ac81feeca8ff1ff8a2b9ca4bc4e8d48e2f4df4 100644 (file)
@@ -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;
        }
index 84098b511f6563af6a6b575fb32aa26226313eaa..508f977bdd949726c460d2f0368f9b1dad57f2bb 100644 (file)
@@ -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; i<y1; ++i ) { \
@@ -318,23 +259,6 @@ public:
   };
   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,
index 556b6232e6ee16718c251467e335686feb525bf4..c1b5023d64317dbe2850664903333c7b04b53fc7 100644 (file)
@@ -94,7 +94,6 @@ public:
 
        PLUGIN_CLASS_MEMBERS(BluebananaConfig);
 
-       YUV yuv;
        VFrame *frame;
        BluebananaEngine *engine;
         int ants_counter;
index 621495cb34309bca214a3d3a42dfaec7fd0d5b6d..5c37b20b4cb6644999e855e476ea9514979dbdbc 100644 (file)
@@ -77,8 +77,6 @@ void BrightnessConfig::interpolate(BrightnessConfig &prev,
 
 
 
-YUV BrightnessMain::yuv;
-
 BrightnessMain::BrightnessMain(PluginServer *server)
  : PluginVClient(server)
 {
@@ -447,7 +445,7 @@ void BrightnessUnit::process_package(LoadPackage *package)
                                                b = input_row[j * components + 2]; \
                                                if(max == 0xff) \
                                                { \
-                                                       BrightnessMain::yuv.rgb_to_yuv_8( \
+                                                       YUV::yuv.rgb_to_yuv_8( \
                                                                r,  \
                                                                g,  \
                                                                b,  \
@@ -457,7 +455,7 @@ void BrightnessUnit::process_package(LoadPackage *package)
                                                } \
                                                else \
                                                { \
-                                                       BrightnessMain::yuv.rgb_to_yuv_16( \
+                                                       YUV::yuv.rgb_to_yuv_16( \
                                                                r,  \
                                                                g,  \
                                                                b,  \
@@ -482,7 +480,7 @@ void BrightnessUnit::process_package(LoadPackage *package)
                                        { \
                                                if(max == 0xff) \
                                                { \
-                                                       BrightnessMain::yuv.yuv_to_rgb_8( \
+                                                       YUV::yuv.yuv_to_rgb_8( \
                                                                r,  \
                                                                g,  \
                                                                b,  \
@@ -492,7 +490,7 @@ void BrightnessUnit::process_package(LoadPackage *package)
                                                } \
                                                else \
                                                { \
-                                                       BrightnessMain::yuv.yuv_to_rgb_16( \
+                                                       YUV::yuv.yuv_to_rgb_16( \
                                                                r,  \
                                                                g,  \
                                                                b,  \
@@ -597,24 +595,9 @@ void BrightnessUnit::process_package(LoadPackage *package)
                                        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; \
index a4eb7de0209b0807e635290b5174a9a339941d4c..c9b4472c357ae03cf73abf3db6abcdf3393dbe36 100644 (file)
@@ -73,8 +73,7 @@ public:
 
 
        BrightnessEngine *engine;
-    int redo_buffers;
-       static YUV yuv;
+       int redo_buffers;
 
        VFrame *input, *output;
 };
index 98261b20f293ca0c030cc288bd016a8571f6c765..f7a7d586e3c6609624729d7dfda807f86ae89b25 100644 (file)
@@ -62,8 +62,6 @@ BurnMain::BurnMain(PluginServer *server)
        burn_server = 0;
        buffer = 0;
        effecttv = 0;
-       yuv = new YUV;
-
 }
 
 BurnMain::~BurnMain()
@@ -73,7 +71,6 @@ 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"); }
@@ -287,7 +284,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; \
@@ -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; \
index 4eb39787aca1d997ac80c208f511c7393e39769f..9bae83120de3b45ef985910db506afbae0f6a8cb 100644 (file)
@@ -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;
 
index b0a09757891033a0f96476aedc2b26accc8ff602..a56cff1ecaa1a43381d5fa6f4b69f12a29ffd223 100644 (file)
@@ -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);
index 5e5d4126e82f22b8cbb562e42878f52223c21fef..5704ded383e5b8313430df4c1f95f00e452f978f 100644 (file)
@@ -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; \
index 17373ef5eca26e49b44fc2b36e78d0bff1a99a9f..6c110c43a1361c7d9c6d688ac727c51ab3a2ad09 100644 (file)
@@ -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);
index 28d04fc5b71a8365ca368e4611861d21ec1a1fdc..1307d8cd06aa58d8e20903d099640c8741373a35 100644 (file)
@@ -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;
index 2fa789841c8e2e1fdf9f2dc2448133286fa654f1..9b49f85c2770cf96b9c2e98bda86883d37e87f76 100644 (file)
@@ -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,
index fd2cdc86b5f2d35a89eb67a90ea58f11c8858965..a31f2fec9a04a1ad2d4ac8c724b4827fe3fea6e2 100644 (file)
@@ -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) \
                        { \
index 317c1beb712c1877b573f1ca3d38e1043ea4cb4c..6a5d527bc100d8ecb5728a36c3da4e532d156501 100644 (file)
@@ -65,7 +65,6 @@ public:
 
 
 
-       YUV yuv;
        VFrame *input, *output;
        HistogramEngine *engine;
        int *lookup[HISTOGRAM_MODES];
index 23688b183a043b1f32c9487659857cc0dd8529be..7c096cbeb81c0f11e020e1f5a8995886b2da209f 100644 (file)
@@ -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) \
                        { \
index 97f3152062c06e4ad20ff872adb35bc7048aec9a..2a3849d5a6b6671b0e867fd964e168e740a2d99a 100644 (file)
@@ -68,7 +68,6 @@ public:
 
 
 
-       YUV yuv;
        VFrame *input, *output;
        HistogramEngine *engine;
        int *lookup[HISTOGRAM_MODES];
index 7a111923429c3ecf56869818786bc0c49323da2b..717f0f362be7df2c2f941c571a478dc1c7d9170e 100644 (file)
@@ -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; \
index 37dbb0b10ad6bbd1d63415cbc33a1a37be74cca1..85c47fc88714044b2e4095e67a25d23996d5df57 100644 (file)
@@ -104,7 +104,6 @@ public:
 
        unsigned int noisepattern[256];
        VFrame *bgimage, *tmp;
-       YUV *yuv;
        int total;
 };
 
index 052ba25257c28a53b7e65214653acdb32db4729a..fdcd5af68779a43a14a97dd111ed55e3bc5bb1f8 100644 (file)
@@ -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<typename TYPE, int COMPONENTS, bool USE_YUV>
@@ -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)
index 0d8769f24a19cdf7de20cdb49d888503874f6c76..1dcd13cdcc6b5fafdb167e446375733305730e2b 100644 (file)
@@ -149,7 +149,6 @@ public:
        LoadClient* new_client();
        LoadPackage* new_package();
 
-       YUV *yuv;
        ThresholdMain *plugin;
        VFrame *data;
 };
index 0fbae88f197d966e315a4f40d7c76294b162f87e..577224326d6a5cd2781d7ac1e95058faab0ef9e9 100644 (file)
@@ -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 \