rework proxy scaler, fix crop-gui coord, video_data tweak for proxy_format
authorGood Guy <[email protected]>
Wed, 25 Sep 2019 17:18:21 +0000 (11:18 -0600)
committerGood Guy <[email protected]>
Wed, 25 Sep 2019 17:18:21 +0000 (11:18 -0600)
12 files changed:
cinelerra-5.1/cinelerra/asset.C
cinelerra-5.1/cinelerra/asset.h
cinelerra-5.1/cinelerra/cwindowtool.C
cinelerra-5.1/cinelerra/edl.C
cinelerra-5.1/cinelerra/edl.h
cinelerra-5.1/cinelerra/filelist.C
cinelerra-5.1/cinelerra/indexfile.C
cinelerra-5.1/cinelerra/mwindow.C
cinelerra-5.1/cinelerra/mwindow.h
cinelerra-5.1/cinelerra/mwindowedit.C
cinelerra-5.1/cinelerra/proxy.C
cinelerra-5.1/cinelerra/proxy.h

index eebc6f2739f96ceeec6ce8ccb49de3c6bc3ffe3a..48dfca3ca66934d7379e30570f3bd115773dbd42 100644 (file)
@@ -147,6 +147,7 @@ void Asset::reset_video()
        layers = 0;
        actual_width = width = 0;
        actual_height = height = 0;
+       proxy_scale = 0; // not a proxy
        video_length = 0;
        single_frame = 0;
        vmpeg_cmodel = BC_YUV420P;
@@ -206,6 +207,7 @@ void Asset::copy_format(Asset *asset, int do_index)
        height = asset->height;
        actual_width = asset->actual_width;
        actual_height = asset->actual_height;
+       proxy_scale = asset->proxy_scale;
        strcpy(vcodec, asset->vcodec);
        strcpy(acodec, asset->acodec);
 
@@ -479,6 +481,7 @@ int Asset::read_video(FileXML *file)
        actual_width = file->tag.get_property("ACTUAL_WIDTH", actual_width);
        height = file->tag.get_property("HEIGHT", height);
        width = file->tag.get_property("WIDTH", width);
+       proxy_scale = file->tag.get_property("PROXY_SCALE", 0);
        layers = file->tag.get_property("LAYERS", layers);
        program = file->tag.get_property("PROGRAM", program);
 // This is loaded from the index file after the EDL but this
@@ -626,6 +629,7 @@ int Asset::write_video(FileXML *file)
        file->tag.set_property("ACTUAL_WIDTH", actual_width);
        file->tag.set_property("HEIGHT", height);
        file->tag.set_property("WIDTH", width);
+       file->tag.set_property("PROXY_SCALE", proxy_scale);
        file->tag.set_property("LAYERS", layers);
        file->tag.set_property("PROGRAM", program);
        file->tag.set_property("FRAMERATE", frame_rate);
@@ -727,6 +731,7 @@ void Asset::load_defaults(BC_Hash *defaults,
                width = GET_DEFAULT("WIDTH", width);
                actual_height = GET_DEFAULT("ACTUAL_HEIGHT", actual_height);
                actual_width = GET_DEFAULT("ACTUAL_WIDTH", actual_width);
+               proxy_scale = GET_DEFAULT("PROXY_SCALE", proxy_scale);
                program = GET_DEFAULT("PROGRAM", program);
                layers = GET_DEFAULT("LAYERS", layers);
                if(EQUIV(frame_rate, 0)) frame_rate = GET_DEFAULT("FRAMERATE", frame_rate);
@@ -885,6 +890,7 @@ void Asset::save_defaults(BC_Hash *defaults,
                UPDATE_DEFAULT("WIDTH", width);
                UPDATE_DEFAULT("ACTUAL_HEIGHT", actual_height);
                UPDATE_DEFAULT("ACTUAL_WIDTH", actual_width);
+               UPDATE_DEFAULT("PROXY_SCALE", proxy_scale);
                UPDATE_DEFAULT("PROGRAM", program);
                UPDATE_DEFAULT("LAYERS", layers);
                UPDATE_DEFAULT("FRAMERATE", frame_rate);
@@ -925,9 +931,13 @@ int Asset::dump(FILE *fp)
        char string[BCTEXTLEN];
        ilacemode_to_xmltext(string, interlace_mode);
        fprintf(fp,"   video_data %d program %d layers %d framerate %f width %d"
-               " height %d vcodec %4.4s aspect_ratio %f ilace_mode %s\n",
+               " height %d vcodec %s aspect_ratio %f ilace_mode %s\n",
                video_data, layers, program, frame_rate, width, height,
                vcodec, aspect_ratio,string);
+       fprintf(fp,"   actual_width %d actual_height %d proxy_scale %d"
+               " video_length %jd repeat %d\n",
+               actual_width, actual_height, proxy_scale, video_length,
+               single_frame);
        fprintf(fp,"   video_length %jd repeat %d\n", video_length, single_frame);
        fprintf(fp,"   mov_sphere=%d jpeg_sphere=%d\n", mov_sphere, jpeg_sphere);
        return 0;
index 0a2372cb829a3845f4f6e8d22b3a48b80907d559..80a29eb5cc33c48b84778abf8ef01679ea71168d 100644 (file)
@@ -146,6 +146,8 @@ public:
 
        int actual_width, actual_height;
        int width, height;
+// scale factor or 0 if not proxy
+       int proxy_scale;
 // String or FourCC describing compression
        char vcodec[BCTEXTLEN];
 
index e701b9d69ed43bd09e9ac4221ac94ae61dea4f6e..8ba0e3b2c7bbc85cbcdf1c7f5d452f15427a18a4 100644 (file)
@@ -360,7 +360,7 @@ CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, float value, int l
 }
 
 CWindowCoord::CWindowCoord(CWindowToolGUI *gui, int x, int y, int value)
- : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 70, 3)
+ : BC_TumbleTextBox(gui, (int64_t)value, (int64_t)-65536, (int64_t)65536, x, y, 70)
 {
        this->gui = gui;
 }
index fd481cea332c1628fabc683a8b2b8301ef15aa98..fc47bb3cf33ea38b4f4e503ededa1124f89e2850 100644 (file)
@@ -1627,39 +1627,31 @@ void EDL::rescale_proxy(int orig_scale, int new_scale)
        }
 }
 
-void EDL::set_proxy(int new_scale, int use_scaler,
+void EDL::set_proxy(int new_scale, int new_use_scaler,
        ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
 {
        int orig_scale = session->proxy_scale;
-       int orig_use_scaler = session->proxy_use_scaler;
-
-// rescale to full size asset in read_frame
        session->proxy_scale = new_scale;
-       session->proxy_use_scaler = use_scaler;
-
-       if( use_scaler ) {
-               for( int i=0; i<proxy_assets->size(); ++i ) {
-                       Asset *proxy_asset = (Asset *)proxy_assets->get(i);
-                       proxy_asset->width = orig_assets->get(i)->get_w();
-                       proxy_asset->height = orig_assets->get(i)->get_h();
-               }
-               new_scale = 1;
-       }
-
-       if( !orig_use_scaler )
-               rescale_proxy(orig_scale, new_scale);
-
+       int orig_use_scaler = session->proxy_use_scaler;
+       session->proxy_use_scaler = new_use_scaler;
+       if( orig_use_scaler ) orig_scale = 1;
+       int scale = new_use_scaler ? new_scale : 1;
+       int asset_scale = new_scale == 1 && !new_use_scaler ? 0 : scale;
 // change original assets to proxy assets
-       int folder_no = use_scaler || new_scale != 1 ? AW_PROXY_FOLDER : AW_MEDIA_FOLDER;
+       int folder_no = new_use_scaler || new_scale != 1 ? AW_PROXY_FOLDER : AW_MEDIA_FOLDER;
        for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
                Indexable *proxy_idxbl = proxy_assets->get(i);
                proxy_idxbl->folder_no = folder_no;
                if( !proxy_idxbl->is_asset ) continue;
                Asset *proxy_asset = assets->update((Asset *)proxy_idxbl);
-               if( proxy_asset == (Asset *)proxy_idxbl ) continue;
-               proxy_asset->width = proxy_idxbl->get_w();
-               proxy_asset->height = proxy_idxbl->get_h();
+               proxy_asset->width = proxy_asset->actual_width * scale;
+               proxy_asset->height = proxy_asset->actual_height * scale;
+               proxy_asset->proxy_scale = asset_scale;
        }
+// rescale to full size asset in read_frame
+       if( new_use_scaler ) new_scale = 1;
+       rescale_proxy(orig_scale, new_scale);
+
 // replace track contents
        for( Track *track=tracks->first; track; track=track->next ) {
                if( track->data_type != TRACK_VIDEO ) continue;
@@ -1706,15 +1698,17 @@ void EDL::set_proxy(int new_scale, int use_scaler,
        }
 }
 
-void EDL::add_proxy(int use_scaler,
-       ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
+void EDL::add_proxy(ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
 {
-       if( use_scaler ) {
-               for( int i=0,n=proxy_assets->size(); i<n; ++i ) {
-                       Asset *proxy_asset = (Asset *)proxy_assets->get(i);
-                       proxy_asset->width = orig_assets->get(i)->get_w();
-                       proxy_asset->height = orig_assets->get(i)->get_h();
-               }
+       int asset_scale = session->proxy_scale;
+       if( asset_scale == 1 ) asset_scale = 0;
+       int scale = !asset_scale ? 1 : asset_scale;
+// update proxy geom using scale
+       for( int i=0; i<proxy_assets->size(); ++i ) {
+               Asset *proxy_asset = (Asset *)proxy_assets->get(i);
+               proxy_asset->proxy_scale = asset_scale;
+               proxy_asset->width = proxy_asset->actual_width * scale;
+               proxy_asset->height = proxy_asset->actual_height * scale;
        }
 
 // change original assets to proxy assets
index b1c4fd3f405257dd30480a43ec0877331896fe87..361996cae599f1407495444fe22859cf7683e03a 100644 (file)
@@ -269,8 +269,7 @@ public:
        void rescale_proxy(int orig_scale, int new_scale);
        void set_proxy(int new_scale, int use_scaler,
                ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets);
-       void add_proxy(int use_scaler,
-               ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets);
+       void add_proxy(ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets);
        Asset *get_proxy_asset();
        Track *add_new_track(int data_type);
 
index f4f26dac22e9479c53b74881780180ad3d3c3dc9..591cb8114a3454a24b87db6745f6af3f9203abeb 100644 (file)
@@ -131,12 +131,12 @@ int FileList::open_file(int rd, int wr)
                                else
                                        result = 1;
                                if( !result ) {
-                                       int width = asset->width;
-                                       int height = asset->height;
                                        asset->actual_width = asset->width;
-                                       if( width ) asset->width = width;
                                        asset->actual_height = asset->height;
-                                       if( height ) asset->height = height;
+                                       int scale = asset->proxy_scale;
+                                       if( !scale ) scale = 1;
+                                       asset->width = asset->actual_width * scale;
+                                       asset->height = asset->actual_height * scale;
                                        asset->layers = 1;
                                        if( !asset->frame_rate )
                                                asset->frame_rate = 10;
index aedbfbb8a12581ad21d7872c6ce0d12fc6ac5905..3e1ce389fa7ae911af92717c78f18e5aefd9982d 100644 (file)
@@ -328,6 +328,11 @@ int IndexFile::open_source()
                        FileSystem fs;
                        asset->index_state->index_bytes = fs.get_size(asset->path);
                        source_length = source->get_audio_length();
+                       int proxy_scale = asset->proxy_scale;
+                       if( proxy_scale > 0 ) {
+                               asset->width = asset->actual_width * proxy_scale;
+                               asset->height = asset->actual_height * proxy_scale;
+                       }
                }
        }
        else
index 35bd21e4d44d534c857972aced98adc3399bca38..a99d30982ba1e837ba052ca7c6dafedea4533574 100644 (file)
@@ -2275,9 +2275,8 @@ int MWindow::render_proxy(ArrayList<Indexable *> &new_idxbls)
        Asset *format_asset = new Asset;
        format_asset->format = FILE_FFMPEG;
        format_asset->load_defaults(defaults, "PROXY_", 1, 1, 0, 0, 0);
-       ProxyRender proxy_render(this, format_asset);
        int new_scale = edl->session->proxy_scale;
-       int use_scaler = edl->session->proxy_use_scaler;
+       ProxyRender proxy_render(this, format_asset, new_scale);
 
        for( int i=0; i<new_idxbls.size(); ++i ) {
                Indexable *orig = new_idxbls.get(i);
@@ -2294,8 +2293,7 @@ int MWindow::render_proxy(ArrayList<Indexable *> &new_idxbls)
 // render needed proxies
        int result = proxy_render.create_needed_proxies(new_scale);
        if( !result ) {
-               add_proxy(use_scaler,
-                       &proxy_render.orig_idxbls, &proxy_render.orig_proxies);
+               add_proxy(&proxy_render.orig_idxbls, &proxy_render.orig_proxies);
        }
        format_asset->remove_user();
        return !result ? proxy_render.needed_proxies.size() : -1;
@@ -2344,7 +2342,9 @@ int MWindow::to_proxy(Asset *asset, int new_scale, int new_use_scaler)
        edl->Garbage::add_user();
        save_backup();
        undo_before(_("proxy"), this);
-       ProxyRender proxy_render(this, asset);
+       int asset_scale = new_scale == 1 ? 0 :
+                       !new_use_scaler ? 1 : new_scale;
+       ProxyRender proxy_render(this, asset, asset_scale);
 
 // revert project to original size from current size
 // remove all session proxy assets at the at the current proxy_scale
index 6083242d37ac8a235996d729670d02de6d9d1505..6eb384cec586e71c38afed90a7e20c0767f1f515 100644 (file)
@@ -522,9 +522,8 @@ public:
        int modify_pluginhandles();
        void finish_modify_handles();
        void rescale_proxy(EDL *clip, int orig_scale, int new_scale);
-       void add_proxy(int use_scaler,
-               ArrayList<Indexable*> *orig_assets,
-               ArrayList<Indexable*> *proxy_assets);
+       void add_proxy(ArrayList<Indexable*> *orig_assets,
+                       ArrayList<Indexable*> *proxy_assets);
        int render_proxy(ArrayList<Indexable *> &new_idxbls);
        void beep(double freq, double secs, double gain);
        int enable_proxy();
index 82c4f1e4471479b98797d79bc9d3ff09a0a22a19..2d09eeb0434a94d283b4c8496645e4c257b71ffb 100644 (file)
@@ -2457,10 +2457,9 @@ void MWindow::rescale_proxy(EDL *clip, int orig_scale, int new_scale)
        edl->rescale_proxy(orig_scale, new_scale);
 }
 
-void MWindow::add_proxy(int use_scaler,
-       ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
+void MWindow::add_proxy(ArrayList<Indexable*> *orig_assets, ArrayList<Indexable*> *proxy_assets)
 {
-       edl->add_proxy(use_scaler, orig_assets, proxy_assets);
+       edl->add_proxy(orig_assets, proxy_assets);
 }
 
 void MWindow::cut_commercials()
index fd1ba562cb725aaebee1b41fce341f0710483d87..a0f5fa72cf4a258fd32042daa4453b85da9d1e73 100644 (file)
@@ -88,6 +88,7 @@ ProxyDialog::ProxyDialog(MWindow *mwindow)
        strcpy(asset->fformat, "mpeg");
        strcpy(asset->vcodec, "mpeg.mpeg");
        asset->ff_video_bitrate = 2000000;
+       asset->video_data = 1;
 
        bzero(size_text, sizeof(char*) * MAX_SIZES);
        bzero(size_factors, sizeof(int) * MAX_SIZES);
@@ -230,10 +231,11 @@ int ProxyRender::from_proxy_path(char *new_path, Indexable *indexable, int scale
        return 0;
 }
 
-ProxyRender::ProxyRender(MWindow *mwindow, Asset *format_asset)
+ProxyRender::ProxyRender(MWindow *mwindow, Asset *format_asset, int asset_scale)
 {
        this->mwindow = mwindow;
        this->format_asset = format_asset;
+       this->asset_scale = asset_scale;
        progress = 0;
        counter_lock = new Mutex("ProxyDialog::counter_lock");
        total_rendered = 0;
@@ -442,6 +444,7 @@ ProxyFormatTools::ProxyFormatTools(MWindow *mwindow, ProxyWindow *pwindow, Asset
 
 void ProxyFormatTools::update_format()
 {
+       asset->save_defaults(mwindow->defaults, "PROXY_", 1, 1, 0, 0, 0);
         FormatTools::update_format();
        pwindow->use_scaler->update();
 }
@@ -722,7 +725,12 @@ void ProxyClient::process_package(LoadPackage *ptr)
                proxy_render->update_progress();
        }
        if( !proxy_render->failed && !proxy_render->is_canceled() ) {
-               Asset *asset = mwindow->edl->assets->update(proxy);
+               Asset *asset = edl->assets->update(proxy);
+               asset->proxy_scale = proxy_render->asset_scale;
+               int scale = asset->proxy_scale;
+               if( !scale ) scale = 1;
+               asset->width = asset->actual_width * scale;
+               asset->height = asset->actual_height * scale;
                mwindow->mainindexes->add_next_asset(0, asset);
                mwindow->mainindexes->start_build();
        }
index f48df9680ace632a93b2d491f9517688ed7777e8..7fa9fd261fa90840d0a56f3d274728b9599c5b35 100644 (file)
@@ -64,7 +64,7 @@ public:
 class ProxyRender
 {
 public:
-       ProxyRender(MWindow *mwindow, Asset *format_asset);
+       ProxyRender(MWindow *mwindow, Asset *format_asset, int asset_scale);
        ~ProxyRender();
        void to_proxy_path(char *new_path, Indexable *indexable, int scale);
        static int from_proxy_path(char *new_path, Indexable *indexable, int scale);
@@ -88,6 +88,7 @@ public:
        Mutex *counter_lock;
        int total_rendered;
        int failed, canceled;
+       int asset_scale;
 };
 
 class ProxyDialog : public BC_DialogThread