add ffmpeg dvd render option, fix undo deadlock, fix a few plugin interface gaffs
authorGood Guy <good1.2guy@gmail.com>
Thu, 2 Jul 2015 20:51:18 +0000 (14:51 -0600)
committerGood Guy <good1.2guy@gmail.com>
Thu, 2 Jul 2015 20:51:18 +0000 (14:51 -0600)
cinelerra-5.0/cinelerra/batchrender.C
cinelerra-5.0/cinelerra/batchrender.h
cinelerra-5.0/cinelerra/ffmpeg.C
cinelerra-5.0/cinelerra/filempeg.C
cinelerra-5.0/cinelerra/mwindow.C
cinelerra-5.0/cinelerra/mwindowedit.C
cinelerra-5.0/mpeg2enc/Makefile
cinelerra-5.0/plugins/Makefile

index 16d02ba15994fe52a1b1e9ad880c6762e2a3948a..6b8373bb7ed759c10a51172d794f14f730b3a6e2 100644 (file)
@@ -1354,6 +1354,7 @@ CreateDVD_Thread::CreateDVD_Thread(MWindow *mwindow)
        this->use_wide_audio = 0;
        this->use_wide_aspect = 0;
        this->use_label_chapters = 0;
+       this->use_ffmpeg = 0;
 }
 
 CreateDVD_Thread::~CreateDVD_Thread()
@@ -1419,8 +1420,10 @@ int CreateDVD_Thread::create_dvd_jobs(ArrayList<BatchRenderJob*> *jobs,
        fprintf(fp,"#!/bin/bash\n");
        fprintf(fp,"echo \"running %s\" $# $*\n", script_filename);
        fprintf(fp,"\n");
-       fprintf(fp,"mplex -f 8 -o $1/dvd.mpg $1/dvd.m2v $1/dvd.ac3\n");
-       fprintf(fp,"\n");
+       if( !use_ffmpeg ) {
+               fprintf(fp,"mplex -f 8 -o $1/dvd.mpg $1/dvd.m2v $1/dvd.ac3\n");
+               fprintf(fp,"\n");
+       }
        fprintf(fp,"rm -rf $1/iso\n");
        fprintf(fp,"mkdir -p $1/iso\n");
        fprintf(fp,"\n");
@@ -1515,43 +1518,71 @@ int CreateDVD_Thread::create_dvd_jobs(ArrayList<BatchRenderJob*> *jobs,
        strcpy(&job->edl_path[0], xml_filename);
        Asset *asset = job->asset;
 
-       sprintf(&asset->path[0],"%s/dvd.m2v", asset_dir);
-        asset->video_data = 1;
-       asset->format = FILE_VMPEG;
        asset->layers = DVD_STREAMS;
        asset->frame_rate = session->frame_rate;
        asset->width = session->output_w;
        asset->height = session->output_h;
        asset->aspect_ratio = session->aspect_w / session->aspect_h;
-       asset->vmpeg_cmodel = BC_YUV420P;
-       asset->vmpeg_fix_bitrate = 1;
-       asset->vmpeg_bitrate = vid_bitrate;
-       asset->vmpeg_quantization = 15;
-        asset->vmpeg_iframe_distance = 15;
-       asset->vmpeg_progressive = 0;
-       asset->vmpeg_denoise = 0;
-       asset->vmpeg_seq_codes = 0;
-       asset->vmpeg_derivative = 2;
-       asset->vmpeg_preset = 8;
-       asset->vmpeg_field_order = 0;
-       asset->vmpeg_pframe_distance = 0;
 
-       job = new BatchRenderJob(mwindow->preferences);
-       jobs->append(job);
-       strcpy(&job->edl_path[0], xml_filename);
-       asset = job->asset;
-
-       sprintf(&asset->path[0],"%s/dvd.ac3", asset_dir);
-        asset->audio_data = 1;
-       asset->format = FILE_AC3;
-       asset->channels = session->audio_channels;
-       asset->sample_rate = session->sample_rate;
-       asset->bits = 16;
-       asset->byte_order = 0;
-       asset->signed_ = 1;
-       asset->header = 0;
-       asset->dither = 0;
-       asset->ac3_bitrate = DVD_KAUDIO_RATE;
+       if( use_ffmpeg ) {
+               char option_path[BCTEXTLEN];
+               sprintf(&asset->path[0],"%s/dvd.mpg", asset_dir);
+               asset->format = FILE_FFMPEG;
+               strcpy(asset->fformat, "dvd");
+
+               asset->audio_data = 1;
+               strcpy(asset->acodec, "dvd.dvd");
+               FFMPEG::set_option_path(option_path, "audio/%s", asset->acodec);
+               FFMPEG::load_options(option_path, asset->ff_audio_options,
+                        sizeof(asset->ff_audio_options));
+               asset->ff_audio_bitrate = DVD_KAUDIO_RATE * 1000;
+
+               asset->video_data = 1;
+               strcpy(asset->vcodec, "dvd.dvd");
+               FFMPEG::set_option_path(option_path, "video/%s", asset->vcodec);
+               FFMPEG::load_options(option_path, asset->ff_video_options,
+                        sizeof(asset->ff_video_options));
+               asset->ff_video_bitrate = vid_bitrate;
+               asset->ff_video_quality = 0;
+
+               int len = strlen(asset->ff_video_options);
+               char *cp = asset->ff_video_options + len;
+               snprintf(cp, sizeof(asset->ff_video_options)-len-1,
+                       "aspect %.5f\n", asset->aspect_ratio);
+       }
+       else {
+               sprintf(&asset->path[0],"%s/dvd.m2v", asset_dir);
+               asset->video_data = 1;
+               asset->format = FILE_VMPEG;
+               asset->vmpeg_cmodel = BC_YUV420P;
+               asset->vmpeg_fix_bitrate = 1;
+               asset->vmpeg_bitrate = vid_bitrate;
+               asset->vmpeg_quantization = 15;
+               asset->vmpeg_iframe_distance = 15;
+               asset->vmpeg_progressive = 0;
+               asset->vmpeg_denoise = 0;
+               asset->vmpeg_seq_codes = 0;
+               asset->vmpeg_derivative = 2;
+               asset->vmpeg_preset = 8;
+               asset->vmpeg_field_order = 0;
+               asset->vmpeg_pframe_distance = 0;
+               job = new BatchRenderJob(mwindow->preferences);
+               jobs->append(job);
+               strcpy(&job->edl_path[0], xml_filename);
+               asset = job->asset;
+               
+               sprintf(&asset->path[0],"%s/dvd.ac3", asset_dir);
+               asset->audio_data = 1;
+               asset->format = FILE_AC3;
+               asset->channels = session->audio_channels;
+               asset->sample_rate = session->sample_rate;
+               asset->bits = 16;
+               asset->byte_order = 0;
+               asset->signed_ = 1;
+               asset->header = 0;
+               asset->dither = 0;
+               asset->ac3_bitrate = DVD_KAUDIO_RATE;
+       }
 
        job = new BatchRenderJob(mwindow->preferences);
        jobs->append(job);
@@ -1635,6 +1666,7 @@ BC_Window* CreateDVD_Thread::new_gui()
        use_wide_audio = 0;
        use_wide_aspect = 0;
        use_label_chapters = 0;
+       use_ffmpeg = 0;
        option_presets();
         int scr_x = mwindow->gui->get_screen_x(0, -1);
         int scr_w = mwindow->gui->get_screen_w(0, -1);
@@ -1858,6 +1890,16 @@ CreateDVD_WideAspect::~CreateDVD_WideAspect()
 {
 }
 
+CreateDVD_UseFFMpeg::CreateDVD_UseFFMpeg(CreateDVD_GUI *gui, int x, int y)
+ : BC_CheckBox(x, y, &gui->thread->use_ffmpeg, "Use FFMPEG")
+{
+       this->gui = gui;
+}
+
+CreateDVD_UseFFMpeg::~CreateDVD_UseFFMpeg()
+{
+}
+
 
 
 
@@ -1915,6 +1957,8 @@ void CreateDVD_GUI::create_objects()
        int x1 = x + 150, x2 = x1 + 150;
        need_inverse_telecine = new CreateDVD_InverseTelecine(this, x1, y);
        add_subwindow(need_inverse_telecine);
+       need_use_ffmpeg = new CreateDVD_UseFFMpeg(this, x2, y);
+       add_subwindow(need_use_ffmpeg);
        y += need_deinterlace->get_h() + pady/2;
        need_scale = new CreateDVD_Scale(this, x, y);
        add_subwindow(need_scale);
index a95ab589257db2eaaf5f106c3b15a565edc4fb76..3fa7418bbb9331c8c20fd9f2e34e17564f0fa98e 100644 (file)
@@ -343,6 +343,7 @@ public:
        int use_scale, use_resize_tracks;
        int use_wide_audio, use_wide_aspect;
        int use_histogram, use_label_chapters;
+       int use_ffmpeg;
 };
 
 class CreateDVD_OK : public BC_OKButton
@@ -472,6 +473,15 @@ public:
        CreateDVD_GUI *gui;
 };
 
+class CreateDVD_UseFFMpeg : public BC_CheckBox
+{
+public:
+       CreateDVD_UseFFMpeg(CreateDVD_GUI *gui, int x, int y);
+       ~CreateDVD_UseFFMpeg();
+
+       CreateDVD_GUI *gui;
+};
+
 class CreateDVD_GUI : public BC_Window
 {
 public:
@@ -494,6 +504,7 @@ public:
        CreateDVD_Deinterlace *need_deinterlace;
        CreateDVD_InverseTelecine *need_inverse_telecine;
        CreateDVD_Scale *need_scale;
+       CreateDVD_UseFFMpeg *need_use_ffmpeg;
        CreateDVD_ResizeTracks *need_resize_tracks;
        CreateDVD_Histogram *need_histogram;
        CreateDVD_WideAudio *need_wide_audio;
index 16d6fe056c4e06c952ed062414a8017b68b4b0c0..af0c5486f100adb86880e40b4093a4f9cb5a5298 100644 (file)
@@ -931,10 +931,15 @@ AVRational FFMPEG::check_frame_rate(AVCodec *codec, double frame_rate)
 
 AVRational FFMPEG::to_sample_aspect_ratio(double aspect_ratio)
 {
+#if 1
        int height = 1000000, width = height * aspect_ratio;
        float w, h;
        MWindow::create_aspect_ratio(w, h, width, height);
        return (AVRational){(int)w, (int)h};
+#else
+// square pixels
+       return (AVRational){1, 1};
+#endif
 }
 
 AVRational FFMPEG::to_time_base(int sample_rate)
@@ -1428,6 +1433,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
                                break;
                        }
                        if( asset->ff_audio_bitrate > 0 ) {
+                               ctx->bit_rate = asset->ff_audio_bitrate;
                                char arg[BCSTRLEN];
                                sprintf(arg, "%d", asset->ff_audio_bitrate);
                                av_dict_set(&sopts, "b", arg, 0);
@@ -1473,6 +1479,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
                                break;
                        }
                        if( asset->ff_video_bitrate > 0 ) {
+                               ctx->bit_rate = asset->ff_video_bitrate;
                                char arg[BCSTRLEN];
                                sprintf(arg, "%d", asset->ff_video_bitrate);
                                av_dict_set(&sopts, "b", arg, 0);
index 3791322508215d9a70d44add9a174c7b2e123c41..6e5da23a741933c37d3326cda80e6aaafc79451e 100644 (file)
@@ -518,7 +518,6 @@ int FileMPEG::open_file(int rd, int wr)
                                        append_vcommand_line("-q");
                                        append_vcommand_line(quant_string);
                                }
-                               append_vcommand_line(!asset->vmpeg_fix_bitrate ? quant_string : "");
                                append_vcommand_line("-n");
                                append_vcommand_line(iframe_string);
                                append_vcommand_line(asset->vmpeg_progressive ? "-p" : "");
index e992fe1d475a49dfcabbee1861cff989ca42b1b1..c528a4ab8a161c5ba1c63282c15ea420c9a2b612 100644 (file)
@@ -2662,8 +2662,16 @@ static inline int gcd(int m, int n)
 
 int MWindow::create_aspect_ratio(float &w, float &h, int width, int height)
 {
+       w = 1;  h = 1;
        if(!width || !height) return 1;
        double ar = (double)width / height;
+// square-ish pixels
+       if( EQUIV(ar, 1.0000) ) return 0;
+       if( EQUIV(ar, 1.3333) ) { w = 4;  h = 3;  return 0; }
+       if( EQUIV(ar, 1.7777) ) { w = 16; h = 9;  return 0; }
+       if( EQUIV(ar, 2.1111) ) { w = 19; h = 9;  return 0; }
+       if( EQUIV(ar, 2.2222) ) { w = 20; h = 9;  return 0; }
+       if( EQUIV(ar, 2.3333) ) { w = 21; h = 9;  return 0; }
        int ww = width, hh = height;
        // numerator, denominator must be under mx
        int mx = 255, n = gcd(ww, hh);
index 883efa79faba7717e2bf77238f436e3e63b59f33..a8f798df937e935001e8b9eab52b64526b4c8705 100644 (file)
@@ -2475,8 +2475,7 @@ void MWindow::undo_entry(BC_WindowBase *calling_window_gui)
        
        cwindow->update(1, 1, 1, 1, 1);
 
-       if (calling_window_gui != cwindow->gui) 
-               cwindow->gui->unlock_window();
+       cwindow->gui->unlock_window();
 
        for(int i = 0; i < vwindows.size(); i++)
        {
index a6184f9f16816b9dd48ec2299d3e886edbb24412..540920a8262d37b3cee3e0c5c87417366a52f587 100644 (file)
@@ -68,7 +68,7 @@ LIBS = \
        $(EXTRA_LIBS)
 
 HVEG2LIB = $(OBJDIR)/hveg2enc.a
-HVEG2ENC = $(PLUGIN_DIR)/hveg2enc.plugin
+HVEG2ENC = $(OBJDIR)/hveg2enc
 HVEG2ENC_G = $(OBJDIR)/hveg2enc_g
 
 $(shell echo $(CFLAGS) > $(OBJDIR)/c_flags)
@@ -87,7 +87,6 @@ OUTPUT = $(HVEG2LIB) $(HVEG2ENC)
 all: $(OUTPUT)
 
 clean:
-       rm -f $(HVEG2ENC)
        rm -rf $(OBJDIR)
 
 install:       $(OUTPUT)
index deaaf1abc76e993c6b3366dbda89018db436408d..da618f423227b0e76f1d847a8294619b55e7d9fa 100644 (file)
@@ -132,16 +132,20 @@ DIRS = \
 #      findobject \
 
 DATA = $(PLUGIN_DIR)/fonts $(PLUGIN_DIR)/shapes
-MPEG2ENC = $(BINDIR)/mpeg2enc.plugin
+MPEG2ENC = $(PLUGIN_DIR)/mpeg2enc.plugin
+HVEG2ENC = $(PLUGIN_DIR)/hveg2enc.plugin
 LADSPA = $(PLUGIN_DIR)/ladspa
 
-all:   $(DIRS) $(DATA) $(MPEG2ENC) $(LADSPA)
+all:   $(DIRS) $(DATA) $(MPEG2ENC) $(HVEG2ENC) $(LADSPA)
 
 $(DATA):
        cp -a $(notdir $@) $(PLUGIN_DIR)/.
 
 $(MPEG2ENC):
-       cp ../thirdparty/mjpegtools*/mpeg2enc/mpeg2enc $@
+       cp -a ../thirdparty/mjpegtools*/mpeg2enc/mpeg2enc $@
+
+$(HVEG2ENC):
+       cp -a ../mpeg2enc/$(OBJDIR)/hveg2enc $@
 
 $(LADSPA):
        mkdir -p $@
@@ -157,7 +161,6 @@ $(DIRS):
 clean:
        rm -rf $(foreach d,$(DIRS),$(d)/$(OBJDIR))
        rm -rf $(PLUGIN_DIR)
-       rm -f $(MPEG2ENC)
 
 install: