OSDN Git Service

[UI][Qt][MOVIE_SAVER] Selective video codecs.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 17 Jun 2016 15:26:49 +0000 (00:26 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Fri, 17 Jun 2016 15:26:49 +0000 (00:26 +0900)
[MOVIE_SAVER] Fix deadlock when closing movie.

22 files changed:
source/src/config.cpp
source/src/config.h
source/src/qt/CMakeLists.txt
source/src/qt/avio/CMakeLists.txt
source/src/qt/avio/movie_saver.cpp
source/src/qt/avio/movie_saver.h
source/src/qt/avio/movie_saver_audio.cpp
source/src/qt/avio/movie_saver_fileio.cpp
source/src/qt/avio/movie_saver_video.cpp
source/src/qt/common/qt_utils.cpp
source/src/qt/gui/CMakeLists.txt
source/src/qt/gui/agar_logger.h
source/src/qt/gui/dialog_movie.cpp
source/src/qt/gui/dialog_movie.h
source/src/qt/gui/dialog_set_key_combo.h
source/src/qt/gui/menu_screen.cpp
source/src/qt/gui/tab_movie_general.cpp [new file with mode: 0644]
source/src/qt/gui/tab_movie_general.h [new file with mode: 0644]
source/src/qt/gui/tab_movie_h264.cpp [new file with mode: 0644]
source/src/qt/gui/tab_movie_h264.h [new file with mode: 0644]
source/src/qt/gui/tab_movie_mpeg4.cpp [new file with mode: 0644]
source/src/qt/gui/tab_movie_mpeg4.h [new file with mode: 0644]

index bec0df7..2b68833 100644 (file)
@@ -138,12 +138,20 @@ void initialize_config()
 #if defined(USE_QT)
        config.video_width = 640;
        config.video_height = 480;
-       config.video_bitrate = 512;
-       config.video_bframes = 4;
-       config.video_b_adapt = 2;
-       config.video_minq = 14;
-       config.video_maxq = 25;
-       config.video_subme = 8;
+       config.video_codec_type = 0; // MPEG4
+       
+       config.video_h264_bitrate = 512;
+       config.video_h264_bframes = 4;
+       config.video_h264_b_adapt = 2;
+       config.video_h264_minq = 14;
+       config.video_h264_maxq = 25;
+       config.video_h264_subme = 8;
+       
+       config.video_mpeg4_bitrate = 512;
+       config.video_mpeg4_bframes = 4;
+       config.video_mpeg4_minq = 1;
+       config.video_mpeg4_maxq = 20;
+       
        config.video_threads = 0;
        config.audio_bitrate = 128;
        config.video_frame_rate = 30;
@@ -363,29 +371,54 @@ void load_config(const _TCHAR *config_path)
        config.video_height  = MyGetPrivateProfileInt(_T("Video"), _T("VideoHeight"), config.video_height, config_path);
        if(config.video_height < 80) config.video_height = 80;
        
-       config.video_bitrate = MyGetPrivateProfileInt(_T("Video"), _T("VideoBitrate"), config.video_bitrate, config_path);
-       if(config.video_bitrate < 64) config.video_bitrate = 64;
+       config.video_codec_type = MyGetPrivateProfileInt(_T("Video"), _T("VideoCodecType"), config.video_codec_type, config_path);
+       if(config.video_codec_type > 1) config.video_codec_type = 1;
+       if(config.video_codec_type < 0) config.video_codec_type = 0;
+       
+       config.video_h264_bitrate = MyGetPrivateProfileInt(_T("Video"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
+       if(config.video_h264_bitrate < 64) config.video_h264_bitrate = 64;
 
-       config.video_bframes = MyGetPrivateProfileInt(_T("Video"), _T("VideoBFrames"), config.video_bframes, config_path);
-       if(config.video_bframes < 0) config.video_bframes = 0;
-       if(config.video_bframes > 10) config.video_bframes = 10;
+       config.video_h264_bframes = MyGetPrivateProfileInt(_T("Video"), _T("H264BFrames"), config.video_h264_bframes, config_path);
+       if(config.video_h264_bframes < 0) config.video_h264_bframes = 0;
+       if(config.video_h264_bframes > 10) config.video_h264_bframes = 10;
 
-       config.video_b_adapt = MyGetPrivateProfileInt(_T("Video"), _T("VideoBAdapt"), config.video_b_adapt, config_path);
-       if(config.video_b_adapt < 0) config.video_b_adapt = 0;
-       if(config.video_b_adapt > 2) config.video_b_adapt = 2;
+       config.video_h264_b_adapt = MyGetPrivateProfileInt(_T("Video"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
+       if(config.video_h264_b_adapt < 0) config.video_h264_b_adapt = 0;
+       if(config.video_h264_b_adapt > 2) config.video_h264_b_adapt = 2;
        
-       config.video_subme   = MyGetPrivateProfileInt(_T("Video"), _T("VideoSubme"), config.video_subme, config_path);
-       if(config.video_subme < 0) config.video_subme = 0;
-       if(config.video_subme > 11) config.video_subme = 11;
+       config.video_h264_subme   = MyGetPrivateProfileInt(_T("Video"), _T("H264Subme"), config.video_h264_subme, config_path);
+       if(config.video_h264_subme < 0) config.video_h264_subme = 0;
+       if(config.video_h264_subme > 11) config.video_h264_subme = 11;
 
-       config.video_minq   = MyGetPrivateProfileInt(_T("Video"), _T("VideoMinQ"), config.video_minq, config_path);
-       if(config.video_minq < 0) config.video_minq = 0;
-       if(config.video_minq > 63) config.video_minq = 63;
+       config.video_h264_minq   = MyGetPrivateProfileInt(_T("Video"), _T("H264MinQ"), config.video_h264_minq, config_path);
+       if(config.video_h264_minq < 0) config.video_h264_minq = 0;
+       if(config.video_h264_minq > 63) config.video_h264_minq = 63;
 
-       config.video_maxq   = MyGetPrivateProfileInt(_T("Video"), _T("VideoMaxQ"), config.video_maxq, config_path);
-       if(config.video_maxq < 0) config.video_maxq = 0;
-       if(config.video_maxq > 63) config.video_maxq = 63;
+       config.video_h264_maxq   = MyGetPrivateProfileInt(_T("Video"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
+       if(config.video_h264_maxq < 0) config.video_h264_maxq = 0;
+       if(config.video_h264_maxq > 63) config.video_h264_maxq = 63;
        
+       config.video_mpeg4_bitrate = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
+       if(config.video_mpeg4_bitrate < 64) config.video_mpeg4_bitrate = 64;
+
+       config.video_mpeg4_bframes = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
+       if(config.video_mpeg4_bframes < 0) config.video_mpeg4_bframes = 0;
+       if(config.video_mpeg4_bframes > 10) config.video_mpeg4_bframes = 10;
+
+       config.video_mpeg4_minq   = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
+       if(config.video_mpeg4_minq < 1) config.video_mpeg4_minq = 1;
+       if(config.video_mpeg4_minq > 31) config.video_mpeg4_minq = 31;
+
+       config.video_mpeg4_maxq   = MyGetPrivateProfileInt(_T("Video"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
+       if(config.video_mpeg4_maxq < 1) config.video_mpeg4_maxq = 1;
+       if(config.video_mpeg4_maxq > 31) config.video_mpeg4_maxq = 31;
+       if(config.video_mpeg4_maxq < config.video_mpeg4_minq) {
+               int n;
+               n = config.video_mpeg4_maxq;
+               config.video_mpeg4_maxq  = config.video_mpeg4_minq;
+               config.video_mpeg4_minq = n;
+       }
+
        config.video_threads = MyGetPrivateProfileInt(_T("Video"), _T("VideoThreads"), config.video_threads, config_path);
        if(config.video_threads < 0) config.video_threads = 0;
        if(config.video_threads > 16) config.video_threads = 16;
@@ -601,12 +634,20 @@ void save_config(const _TCHAR *config_path)
 #if defined(_USE_QT)
        MyWritePrivateProfileInt(_T("Video"), _T("VideoWidth"), config.video_width, config_path);
        MyWritePrivateProfileInt(_T("Video"), _T("VideoHeight"), config.video_height, config_path);
-       MyWritePrivateProfileInt(_T("Video"), _T("VideoBitrate"), config.video_bitrate, config_path);
-       MyWritePrivateProfileInt(_T("Video"), _T("VideoBFrames"), config.video_bframes, config_path);
-       MyWritePrivateProfileInt(_T("Video"), _T("VideoBAdapt"), config.video_b_adapt, config_path);
-       MyWritePrivateProfileInt(_T("Video"), _T("VideoMinQ"), config.video_minq, config_path);
-       MyWritePrivateProfileInt(_T("Video"), _T("VideoMaxQ"), config.video_maxq, config_path);
-       MyWritePrivateProfileInt(_T("Video"), _T("VideoSubme"), config.video_subme, config_path);
+       MyWritePrivateProfileInt(_T("Video"), _T("VideoCodecType"), config.video_codec_type, config_path);
+       
+       MyWritePrivateProfileInt(_T("Video"), _T("H264Bitrate"), config.video_h264_bitrate, config_path);
+       MyWritePrivateProfileInt(_T("Video"), _T("H264BFrames"), config.video_h264_bframes, config_path);
+       MyWritePrivateProfileInt(_T("Video"), _T("H264BAdapt"), config.video_h264_b_adapt, config_path);
+       MyWritePrivateProfileInt(_T("Video"), _T("H264MinQ"), config.video_h264_minq, config_path);
+       MyWritePrivateProfileInt(_T("Video"), _T("H264MaxQ"), config.video_h264_maxq, config_path);
+       MyWritePrivateProfileInt(_T("Video"), _T("H264Subme"), config.video_h264_subme, config_path);
+       
+       MyWritePrivateProfileInt(_T("Video"), _T("MPEG4Bitrate"), config.video_mpeg4_bitrate, config_path);
+       MyWritePrivateProfileInt(_T("Video"), _T("MPEG4BFrames"), config.video_mpeg4_bframes, config_path);
+       MyWritePrivateProfileInt(_T("Video"), _T("MPEG4MinQ"), config.video_mpeg4_minq, config_path);
+       MyWritePrivateProfileInt(_T("Video"), _T("MPEG4MaxQ"), config.video_mpeg4_maxq, config_path);
+       
        MyWritePrivateProfileInt(_T("Video"), _T("VideoThreads"), config.video_threads, config_path);
        MyWritePrivateProfileInt(_T("Video"), _T("AudioBitrate"), config.audio_bitrate, config_path);
        MyWritePrivateProfileInt(_T("Video"), _T("VideoFramerate"), config.video_frame_rate, config_path);
index 6c6a7e7..fa95da3 100644 (file)
@@ -139,12 +139,20 @@ typedef struct {
 
        int video_width;
        int video_height;
-       int video_bitrate;
-       int video_bframes;
-       int video_b_adapt;
-       int video_minq;
-       int video_maxq;
-       int video_subme;
+       int video_codec_type;
+       
+       int video_h264_bitrate;
+       int video_h264_bframes;
+       int video_h264_b_adapt;
+       int video_h264_minq;
+       int video_h264_maxq;
+       int video_h264_subme;
+
+       int video_mpeg4_bitrate;
+       int video_mpeg4_bframes;
+       int video_mpeg4_minq;
+       int video_mpeg4_maxq;
+       
        int video_threads;
        int audio_bitrate;
        int video_frame_rate; // FPS * 1000.0
index 12d9b80..bfa7029 100644 (file)
@@ -39,8 +39,8 @@ else()
   )
   
   set_target_properties(CSPosd PROPERTIES 
-     SOVERSION 1.2.2
-     VERSION 1.2.2
+     SOVERSION 1.2.3
+     VERSION 1.2.3
   )
   INSTALL(TARGETS CSPosd DESTINATION ${LIBCSP_INSTALL_DIR})
 endif()
index e67f40e..8574841 100644 (file)
@@ -91,8 +91,8 @@ add_library(CSPavio SHARED
 #endif()
 
 set_target_properties(CSPavio PROPERTIES 
-                            SOVERSION 1.2.1
-                            VERSION 1.2.1
+                            SOVERSION 1.2.2
+                            VERSION 1.2.2
                             )
 INSTALL(TARGETS CSPavio DESTINATION ${LIBCSP_INSTALL_DIR})
 endif()
index bfeba85..ffa388a 100644 (file)
@@ -263,6 +263,7 @@ void MOVIE_SAVER::run()
                        }
                }
        _next_turn:
+               //printf("%d\n", req_close);
                old_recording = recording;
                if(!bRunThread) break;
                if(need_video_transcode || need_audio_transcode) {
@@ -282,6 +283,9 @@ void MOVIE_SAVER::run()
                        tmp_wait = fps_wait;
                }
                old_recording = recording;
+               if(req_close) {
+                       do_close_main();
+               }
                continue;
        _final:
                old_recording = recording;
index 67fdc4c..e411e82 100644 (file)
@@ -32,6 +32,12 @@ extern "C" {
 //#define SCALE_FLAGS SWS_BICUBLIN
 #define SCALE_FLAGS SWS_POINT
 
+enum {
+       VIDEO_CODEC_MPEG4 = 0,
+       VIDEO_CODEC_H264,
+       VIDEO_CODEC_END,
+};
+
 // a wrapper around a single output AVStream
 typedef struct OutputStream {
        AVStream *st;
@@ -58,12 +64,11 @@ class MOVIE_SAVER: public QThread
 private:
        int n_encode_audio;
        int n_encode_video;
-
 protected:
        OSD *p_osd;
 
        bool req_close;
-       
+
        bool have_video;
        bool have_audio;
        bool encode_video;
@@ -157,7 +162,10 @@ protected:
        int write_video_frame();
        //void MOVIE_SAVER::close_stream(AVFormatContext *oc, OutputStream *ost)
        void close_stream(void *_oc, void *_ost);
-
+       //void MOVIE_SAVER::setup_h264(AVCodecContext *_codec)
+       void setup_h264(void *_codec);
+       //void MOVIE_SAVER::setup_mpeg4(AVCodecContext *_codec)
+       void setup_mpeg4(void *_codec);
 
        QString ts2str(int64_t ts);
        QString ts2timestr(int64_t ts, void *timebase);
index 6c70f4a..fda1dae 100644 (file)
@@ -9,6 +9,7 @@
 #include "../osd.h"
 #include "agar_logger.h"
 
+#if defined(USE_LIBAV)
 extern "C" {
        #include <libavutil/avassert.h>
        #include <libavutil/channel_layout.h>
@@ -19,7 +20,7 @@ extern "C" {
        #include <libswscale/swscale.h>
        #include <libswresample/swresample.h>
 }
-
+#endif
 /**************************************************************/
 /* audio output */
 
@@ -30,6 +31,7 @@ void *MOVIE_SAVER::alloc_audio_frame(uint64_t _sample_fmt,
                                                                  uint64_t channel_layout,
                                                                  int sample_rate, int nb_samples)
 {
+#if defined(USE_LIBAV)
        AVFrame *frame = av_frame_alloc();
        int ret;
        enum AVSampleFormat sample_fmt = (enum AVSampleFormat)_sample_fmt; 
@@ -52,11 +54,15 @@ void *MOVIE_SAVER::alloc_audio_frame(uint64_t _sample_fmt,
        }
 
        return (void *)frame;
+#else
+       return (void *)NULL;
+#endif
 }
 
 //static void open_audio(AVFormatContext *oc, AVCodec *codec, OutputStream *ost, AVDictionary *opt_arg)
 bool MOVIE_SAVER::open_audio(void)
 {
+#if defined(USE_LIBAV)
        AVDictionary *opt_arg = raw_options_list;
        OutputStream *ost = &audio_st;
        AVCodec *codec = audio_codec;
@@ -109,6 +115,9 @@ bool MOVIE_SAVER::open_audio(void)
        }
        AGAR_DebugLog(AGAR_LOG_DEBUG, "MOVIE: Open to write audio : Success.");
        return true;
+#else
+       return true;
+#endif
 }
 
 /* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
@@ -116,6 +125,7 @@ bool MOVIE_SAVER::open_audio(void)
 //static AVFrame *get_audio_frame(OutputStream *ost)
 void *MOVIE_SAVER::get_audio_frame()
 {
+#if defined(USE_LIBAV)
        OutputStream *ost = &audio_st;
        AVFrame *frame = ost->tmp_frame;
        int j, i, v;
@@ -127,6 +137,7 @@ void *MOVIE_SAVER::get_audio_frame()
                        while(audio_data_queue.isEmpty()) {
                                if(!bRunThread) return NULL;
                                if(!recording) return NULL;
+                               if(req_close) return NULL;
                                msleep(1);
                        }
                        dequeue_audio(audio_frame_buf);
@@ -151,6 +162,9 @@ void *MOVIE_SAVER::get_audio_frame()
        ost->next_pts  += frame->nb_samples;
 
        return frame;
+#else
+       return (void *)NULL;
+#endif
 }
 
 /*
@@ -160,6 +174,7 @@ void *MOVIE_SAVER::get_audio_frame()
 //static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
 int MOVIE_SAVER::write_audio_frame()
 {
+#if defined(USE_LIBAV)
        AVFormatContext *oc = output_context;
        OutputStream *ost = &audio_st;
        AVCodecContext *c;
@@ -174,7 +189,7 @@ int MOVIE_SAVER::write_audio_frame()
        c = ost->st->codec;
 
        frame_src = (AVFrame *)get_audio_frame();
-
+       //if(req_close) return 1;
        if (frame_src) {
                /* convert samples from native format to destination codec format, using the resampler */
                /* compute destination number of samples */
@@ -227,4 +242,7 @@ int MOVIE_SAVER::write_audio_frame()
                //}
        }
        return (frame_dst || got_packet) ? 0 : 1;
+#else
+       return 1;
+#endif
 }
index 955c484..0a4284f 100644 (file)
@@ -15,6 +15,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
+#if defined(USE_LIBAV)
 extern "C" {
        #include <libavutil/avassert.h>
        #include <libavutil/channel_layout.h>
@@ -25,10 +26,12 @@ extern "C" {
        #include <libswscale/swscale.h>
        #include <libswresample/swresample.h>
 }
+#endif
 
 //int MOVIE_SAVER::write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
 int MOVIE_SAVER::write_frame(void *_fmt_ctx, const void *_time_base, void *_st, void *_pkt)
 {
+#if defined(USE_LIBAV)
        AVFormatContext *fmt_ctx = (AVFormatContext *)_fmt_ctx;
        const AVRational *time_base = (const AVRational *)_time_base;
        AVStream *st = (AVStream *)_st;
@@ -40,6 +43,9 @@ int MOVIE_SAVER::write_frame(void *_fmt_ctx, const void *_time_base, void *_st,
        /* Write the compressed frame to the media file. */
        //log_packet(fmt_ctx, pkt);
        return av_interleaved_write_frame(fmt_ctx, pkt);
+#else
+       return 0;
+#endif
 }
 
 /* Add an output stream. */
@@ -50,6 +56,7 @@ bool MOVIE_SAVER::add_stream(void *_ost, void *_oc,
                                           void **_codec,
                                           uint64_t _codec_id)
 {
+#if defined(USE_LIBAV)
        AVCodecContext *c;
        int i;
 
@@ -108,32 +115,7 @@ bool MOVIE_SAVER::add_stream(void *_ost, void *_oc,
                /* Resolution must be a multiple of two. */
                c->width        = video_geometry.width();
                c->height   = video_geometry.height();
-               c->qmin  = config.video_minq;
-               c->qmax  = config.video_maxq;
                c->thread_count  = video_encode_threads;
-               c->max_b_frames  = config.video_bframes;
-               
-               c->b_quant_offset = 2;
-               c->temporal_cplx_masking = 0.1;
-               c->spatial_cplx_masking = 0.15;
-               c->scenechange_threshold = 35;
-               c->noise_reduction = 0;
-               c->bidir_refine = 2;
-               c->refs = 5;
-               c->chromaoffset = 2;
-               c->max_qdiff = 6;
-               //c->b_frame_strategy = config.video_b_adapt;
-               c->me_subpel_quality = config.video_subme;
-               c->i_quant_offset = 1.2;
-               c->i_quant_factor = 1.5;
-               c->trellis = 2;
-               c->mb_lmin = 4;
-               c->mb_lmax = 18;
-               c->bidir_refine = 2;
-               c->keyint_min = rec_fps / 5;
-               c->gop_size = rec_fps * 5;
-               c->b_sensitivity = 55;
-               c->scenechange_threshold = 50;
                
                /* timebase: This is the fundamental unit of time (in seconds) in terms
                 * of which frame timestamps are represented. For fixed-fps content,
@@ -150,15 +132,7 @@ bool MOVIE_SAVER::add_stream(void *_ost, void *_oc,
                        c->gop_size  = rec_fps; /* emit one intra frame every one second */
                }
                if (c->codec_id == AV_CODEC_ID_MPEG4) {
-                       if(c->qmin > c->qmax) {
-                               int tmp;
-                               tmp = c->qmin;
-                               c->qmin = c->qmax;
-                               c->qmax = tmp;
-                       }
-                       if(c->qmin <= 0) c->qmin = 1;
-                       if(c->qmax <= 0) c->qmax = 1;
-                       c->gop_size  = rec_fps; /* emit one intra frame every one second */
+                       setup_mpeg4((void *)c);
                }
                if (c->codec_id == AV_CODEC_ID_MPEG1VIDEO) {
                        /* Needed to avoid using macroblocks in which some coeffs overflow.
@@ -167,12 +141,7 @@ bool MOVIE_SAVER::add_stream(void *_ost, void *_oc,
                        c->mb_decision = 2;
                }
                if (c->codec_id == AV_CODEC_ID_H264) {
-                       /* Needed to avoid using macroblocks in which some coeffs overflow.
-                        * This does not happen with normal video, it just happens here as
-                        * the motion of the chroma plane does not match the luma plane. */
-                       c->mb_decision = 2;
-                       c->me_method = ME_UMH;
-                       c->profile=FF_PROFILE_H264_HIGH;
+                       setup_h264((void *)c);
                }
        break;
 
@@ -184,6 +153,9 @@ bool MOVIE_SAVER::add_stream(void *_ost, void *_oc,
        if (oc->oformat->flags & AVFMT_GLOBALHEADER)
                c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
        return true;
+#else
+       return false;
+#endif 
 }
 
 
@@ -191,6 +163,7 @@ bool MOVIE_SAVER::add_stream(void *_ost, void *_oc,
 //void MOVIE_SAVER::close_stream(AVFormatContext *oc, OutputStream *ost)
 void MOVIE_SAVER::close_stream(void *_oc, void *_ost)
 {
+#if defined(USE_LIBAV)
        AVFormatContext *oc = (AVFormatContext *)_oc;
        OutputStream *ost = (OutputStream *)_ost;
        avcodec_close(ost->st->codec);
@@ -199,19 +172,21 @@ void MOVIE_SAVER::close_stream(void *_oc, void *_ost)
        av_frame_free(&ost->tmp_frame);
        sws_freeContext(ost->sws_ctx);
        swr_free(&ost->swr_ctx);
+#endif 
 }
 
 
 
 bool MOVIE_SAVER::do_open(QString filename, int _fps, int _sample_rate)
 {
+#if defined(USE_LIBAV)
        AVOutputFormat *fmt;
        AVFormatContext *oc;
        //AVCodec *audio_codec, *video_codec;
        int ret;
        have_video = 0, have_audio = 0;
        int encode_video = 0, encode_audio = 0;
-       if(recording) do_close_main();
+       do_close_main();
        raw_options_list = NULL;
 
        do_set_record_fps(_fps);
@@ -232,26 +207,8 @@ bool MOVIE_SAVER::do_open(QString filename, int _fps, int _sample_rate)
                //do_add_option(QString::fromUtf8("c:v"), QString::fromUtf8("theora"));
                //do_add_option(QString::fromUtf8("c:a"), QString::fromUtf8("vorbis"));
                
-               value.setNum(config.video_minq);
-               do_add_option(QString::fromUtf8("qmin"), value);
-               value.setNum(config.video_maxq);
-               do_add_option(QString::fromUtf8("qmax"), value);
-               
-               value.setNum(config.video_bframes);
-               do_add_option(QString::fromUtf8("bframes"), value);
-               
-               value.setNum(config.video_b_adapt);
-               do_add_option(QString::fromUtf8("b_adapt"), value);
-               
-               value.setNum(config.video_subme);
-               do_add_option(QString::fromUtf8("subme"), value);
-
-               value.setNum(config.video_subme);
-               do_add_option(QString::fromUtf8("subme"), value);
-               
                video_encode_threads = config.video_threads;
                video_geometry = QSize(config.video_width, config.video_height);
-               video_bit_rate = config.video_bitrate * 1000;
                audio_bit_rate = config.audio_bitrate * 1000;
                
        }
@@ -272,8 +229,14 @@ bool MOVIE_SAVER::do_open(QString filename, int _fps, int _sample_rate)
                return false;
 
        fmt = oc->oformat;
-       fmt->video_codec = AV_CODEC_ID_MPEG4;
-       //fmt->video_codec = AV_CODEC_ID_H264;
+       switch(config.video_codec_type) {
+       case VIDEO_CODEC_MPEG4:
+               fmt->video_codec = AV_CODEC_ID_MPEG4;
+               break;
+       case VIDEO_CODEC_H264:
+               fmt->video_codec = AV_CODEC_ID_H264;
+               break;
+       }
        fmt->audio_codec = AV_CODEC_ID_AAC;
        
        /* Add the audio and video streams using the default format codecs
@@ -329,6 +292,9 @@ _err_final:
        output_context = NULL;
        stream_format  = NULL;
        return false;
+#else
+       return true;
+#endif 
 }
 
 void MOVIE_SAVER::do_close()
@@ -338,13 +304,12 @@ void MOVIE_SAVER::do_close()
 
 void MOVIE_SAVER::do_close_main()
 {
-       recording = false;
-       req_close = false;
 #if defined(USE_LIBAV)
        int ret, i;
        OutputStream *ost;
        int got_packet;
        int64_t total_packets_written = 0;
+
        if(output_context != NULL) {
                AVFormatContext *oc = output_context;
                AVOutputFormat *fmt = oc->oformat;
@@ -380,6 +345,8 @@ void MOVIE_SAVER::do_close_main()
                av_dict_free(&raw_options_list);
                raw_options_list = NULL;
        }
+       recording = false;
+       req_close = false;
 #endif   // defined(USE_LIBAV)
        memset(audio_frame_buf, 0x00, sizeof(audio_frame_buf));
        memset(video_frame_buf, 0x00, sizeof(video_frame_buf));
index 807e263..e8f9694 100644 (file)
@@ -15,6 +15,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <math.h>
+
+#if defined(USE_LIBAV)
 extern "C" {
        #include <libavutil/avassert.h>
        #include <libavutil/channel_layout.h>
@@ -25,13 +27,91 @@ extern "C" {
        #include <libswscale/swscale.h>
        #include <libswresample/swresample.h>
 }
-
+#endif
 /**************************************************************/
 /* video output */
 
+void MOVIE_SAVER::setup_h264(void *_codec)
+{
+#if defined(USE_LIBAV)
+       AVCodecContext *c = (AVCodecContext *)_codec;
+
+       c->qmin  = config.video_h264_minq;
+       c->qmax  = config.video_h264_maxq;
+       c->bit_rate = config.video_h264_bitrate * 1000;
+       c->max_b_frames = config.video_h264_bframes;
+       c->b_quant_offset = 2;
+       c->temporal_cplx_masking = 0.1;
+       c->spatial_cplx_masking = 0.15;
+       c->scenechange_threshold = 35;
+       c->noise_reduction = 0;
+       c->bidir_refine = 2;
+       c->refs = 5;
+       c->chromaoffset = 2;
+       c->max_qdiff = 6;
+       c->b_frame_strategy = config.video_h264_b_adapt;
+       c->me_subpel_quality = config.video_h264_subme;
+       c->i_quant_offset = 1.2;
+       c->i_quant_factor = 1.5;
+       c->trellis = 2;
+       c->mb_lmin = 4;
+       c->mb_lmax = 18;
+       c->bidir_refine = 2;
+       c->keyint_min = rec_fps / 5;
+       c->gop_size = rec_fps * 5;
+       c->b_sensitivity = 55;
+       c->scenechange_threshold = 40;
+       /* Needed to avoid using macroblocks in which some coeffs overflow.
+        * This does not happen with normal video, it just happens here as
+        * the motion of the chroma plane does not match the luma plane. */
+       c->mb_decision = 2;
+       c->me_method = ME_UMH;
+       c->profile=FF_PROFILE_H264_HIGH;
+#endif 
+}
+
+void MOVIE_SAVER::setup_mpeg4(void *_codec)
+{
+#if defined(USE_LIBAV)
+       AVCodecContext *c = (AVCodecContext *)_codec;
+       c->qmin  = config.video_mpeg4_minq;
+       c->qmax  = config.video_mpeg4_maxq;
+       c->max_b_frames  = config.video_mpeg4_bframes;
+       c->bit_rate = config.video_mpeg4_bitrate * 1000;
+       c->b_quant_offset = 2;
+       c->temporal_cplx_masking = 0.1;
+       c->spatial_cplx_masking = 0.15;
+       c->scenechange_threshold = 35;
+       c->noise_reduction = 0;
+       c->bidir_refine = 2;
+       c->refs = 5;
+       c->chromaoffset = 2;
+       c->max_qdiff = 6;
+       c->i_quant_offset = 1.2;
+       c->i_quant_factor = 1.5;
+       c->trellis = 2;
+       c->mb_lmin = 4;
+       c->mb_lmax = 18;
+       c->bidir_refine = 2;
+       c->keyint_min = rec_fps / 5;
+       c->gop_size = rec_fps * 5;
+       c->b_sensitivity = 55;
+       c->scenechange_threshold = 30;
+       if(c->qmin > c->qmax) {
+               int tmp;
+               tmp = c->qmin;
+               c->qmin = c->qmax;
+               c->qmax = tmp;
+       }
+       if(c->qmin <= 0) c->qmin = 1;
+       if(c->qmax <= 0) c->qmax = 1;
+       c->gop_size  = rec_fps; /* emit one intra frame every one second */
+#endif
+}
 //static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int height)
 void *MOVIE_SAVER::alloc_picture(uint64_t _pix_fmt, int width, int height)
 {
+#if defined(USE_LIBAV)
        enum AVPixelFormat pix_fmt = (enum AVPixelFormat)_pix_fmt;
        AVFrame *picture;
        int ret;
@@ -52,11 +132,15 @@ void *MOVIE_SAVER::alloc_picture(uint64_t _pix_fmt, int width, int height)
        }
 
        return (void *)picture;
+#else
+       return (void *)NULL;
+#endif 
 }
 
 //void MOVIE_SAVER::open_video(OutputStream *_ost, AVDictionary *_opt_arg)
 bool MOVIE_SAVER::open_video()
 {
+#if defined(USE_LIBAV)
        int ret;
        AVDictionary *opt_arg = raw_options_list;
        OutputStream *ost = &video_st;
@@ -86,7 +170,6 @@ bool MOVIE_SAVER::open_video()
         * picture is needed too. It is then converted to the required
         * output format. */
        ost->tmp_frame = NULL;
-#if 1  
        old_width = old_height = -1;
        //if (c->pix_fmt != AV_PIX_FMT_YUV420P) {
        ost->tmp_frame = (AVFrame *)alloc_picture(AV_PIX_FMT_RGBA, _width, _height);
@@ -95,14 +178,18 @@ bool MOVIE_SAVER::open_video()
                return false;
        }
        //}
-#endif 
+       
        AGAR_DebugLog(AGAR_LOG_DEBUG, "MOVIE: Open to write video : Success.");
        return true;
+#else
+       return false;
+#endif
 }
 
 static void fill_yuv_image(AVFrame *pict, int frame_index,
                                                   int width, int height)
 {
+#if defined(USE_LIBAV)
        int x, y, i, ret;
 
        /* when we pass a frame to the encoder, it may keep a reference to it
@@ -127,11 +214,13 @@ static void fill_yuv_image(AVFrame *pict, int frame_index,
                        pict->data[2][y * pict->linesize[2] + x] = 64 + x + i * 5;
                }
        }
+#endif 
 }
 
 //static AVFrame *get_video_frame(OutputStream *ost)
 void *MOVIE_SAVER::get_video_frame(void)
 {
+#if defined(USE_LIBAV)
        OutputStream *ost = &video_st;
        AVCodecContext *c = ost->st->codec;
 
@@ -201,6 +290,9 @@ void *MOVIE_SAVER::get_video_frame(void)
        }
        ost->frame->pts = ost->next_pts++;
        return (void *)(ost->frame);
+#else
+       return (void *)NULL;
+#endif 
 }
 
 /*
@@ -210,6 +302,7 @@ void *MOVIE_SAVER::get_video_frame(void)
 //static int write_video_frame(AVFormatContext *oc, OutputStream *ost)
 int MOVIE_SAVER::write_video_frame()
 {
+#if defined(USE_LIBAV)
        int ret;
        AVFormatContext *oc = output_context;
        OutputStream *ost = &video_st;
@@ -254,4 +347,7 @@ int MOVIE_SAVER::write_video_frame()
        //      AGAR_DebugLog(AGAR_LOG_DEBUG, "Movie: Write video to file. sec=%s", s);
        //}
        return (frame || got_packet) ? 0 : 1;
+#else
+       return 1;
+#endif
 }
index b4d6eb3..7694a50 100644 (file)
@@ -333,7 +333,7 @@ void Ui_MainWindow::LaunchEmuThread(void)
        connect(emu->get_osd(), SIGNAL(sig_stop_saving_movie()), hSaveMovieThread, SLOT(do_close()));
 
        actionStop_Record_Movie->setIcon(QIcon(":/icon_process_stop.png"));
-       actionStop_Record_Movie->setVisible(false);
+       //actionStop_Record_Movie->setVisible(false);
        
        connect(this, SIGNAL(sig_movie_set_width(int)), hSaveMovieThread, SLOT(do_set_width(int)));
        connect(this, SIGNAL(sig_movie_set_height(int)), hSaveMovieThread, SLOT(do_set_height(int)));
index dc346bc..8bae937 100644 (file)
@@ -26,6 +26,10 @@ set(s_qt_gui_headers
          dialog_set_key.h
          dialog_set_key_combo.h
          dialog_movie.h
+
+         tab_movie_general.h
+         tab_movie_h264.h
+         tab_movie_mpeg4.h
          
          draw_thread.h
          joy_thread.h
@@ -73,6 +77,10 @@ set(s_qt_gui_srcs
          dialog_set_key_combo.cpp
          dialog_movie.cpp
          
+         tab_movie_general.cpp
+         tab_movie_h264.cpp
+         tab_movie_mpeg4.cpp
+         
          draw_thread.cpp
          joy_thread.cpp
          agar_logger.cpp
@@ -123,8 +131,8 @@ add_library(CSPgui SHARED
 )
 
 set_target_properties(CSPgui PROPERTIES 
-                            SOVERSION 1.3.3
-                            VERSION 1.3.3
+                            SOVERSION 1.3.4
+                            VERSION 1.3.4
                             )
 INSTALL(TARGETS CSPgui DESTINATION ${LIBCSP_INSTALL_DIR})
 endif()
index 89413c4..47c7152 100644 (file)
 #include <sys/time.h>
 
 #include "simd_types.h"
-#ifdef __GNUC__
-       #if defined(Q_OS_WIN) || defined(__WIN32) || defined(__WIN64)
-               #define DLL_PREFIX __declspec(dllexport)
-       #else
-               #define DLL_PREFIX
-       #endif
-#else
-               #define DLL_PREFIX
-#endif
+#include "common.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
index e1a286e..e074925 100644 (file)
@@ -1,15 +1,16 @@
 
-#include <QHBoxLayout>
-#include <QVBoxLayout>
 #include <QGridLayout>
 #include <QWidget>
 #include <QPushButton>
-#include <QSlider>
-#include <QComboBox>
 #include <QLabel>
 #include <QApplication>
+#include <QTabWidget>
 
 #include "dialog_movie.h"
+#include "tab_movie_general.h"
+#include "tab_movie_h264.h"
+#include "tab_movie_mpeg4.h"
+
 #include "../avio/movie_saver.h"
 #include "../../config.h"
 
@@ -17,250 +18,28 @@ CSP_DialogMovie::CSP_DialogMovie(MOVIE_SAVER *ms, QWidget *parent) : QWidget(par
 {
        p_wid = parent;
        p_movie = ms;
+       tab_widget = new QTabWidget(this);
+
+       tab_general = new CSP_TabMovieGeneral(ms, this, parent);
+       tab_h264 = new CSP_TabMovieH264(ms, this, parent);
+       tab_mpeg4 = new CSP_TabMovieMPEG4(ms, this, parent);
 
-       QString tmps;
+       tab_widget->addTab(tab_general, QApplication::translate("MainWindow", "General", 0));
+       tab_widget->addTab(tab_h264, QApplication::translate("MainWindow", "H.264", 0));
+       tab_widget->addTab(tab_mpeg4, QApplication::translate("MainWindow", "MPEG4v1", 0));
+       
        label_title = new QLabel(QApplication::translate("MainWindow", "Set movie codecs.", 0), this);
        grid_layout = new QGridLayout(this);
-
-       label_resolution = new QLabel(QApplication::translate("MainWindow", "Resolution", 0), this);
-       combo_resolution = new QComboBox(this);
        
-       geometry.setWidth(config.video_width);
-       geometry.setHeight(config.video_height);
-       video_maxq = config.video_maxq;
-       video_minq = config.video_minq;
-       video_bitrate = config.video_bitrate;
-       audio_bitrate = config.audio_bitrate;
-
-       label_video_bitrate = new QLabel(QApplication::translate("MainWindow", "Video Bitrate", 0), this);
-       combo_video_bitrate = new QComboBox(this);
-       label_video_bframes = new QLabel(QApplication::translate("MainWindow", "Max B Frames", 0), this);
-       combo_video_bframes = new QComboBox(this);
-       label_video_b_adapt = new QLabel(QApplication::translate("MainWindow", "B Adaption", 0), this);
-       combo_video_b_adapt = new QComboBox(this);
-       label_video_subme = new QLabel(QApplication::translate("MainWindow", "Subpixel motion estimate", 0), this);
-       combo_video_subme = new QComboBox(this);
-       label_video_threads = new QLabel(QApplication::translate("MainWindow", "Video Threads", 0), this);
-       combo_video_threads = new QComboBox(this);
-       combo_audio_bitrate = new QComboBox(this);
        cancel_button = new QPushButton(QApplication::translate("MainWindow", "Cancel", 0));
        close_button = new QPushButton(QApplication::translate("MainWindow", "Save Options", 0));
-       label_audio_bitrate = new QLabel(QApplication::translate("MainWindow", "Audio Bitrate", 0), this);
-       label_video_fps = new QLabel(QApplication::translate("MainWindow", "Framerate", 0), this);
-       combo_video_fps = new QComboBox(this);
-       video_fps = config.video_frame_rate;
-       
-       // Value for resolution
-       combo_resolution->addItem(QString::fromUtf8("256x160"), QSize(256, 160));
-       combo_resolution->addItem(QString::fromUtf8("256x240"), QSize(256, 240));
-       combo_resolution->addItem(QString::fromUtf8("320x128"), QSize(320, 128));
-       combo_resolution->addItem(QString::fromUtf8("320x200"), QSize(320, 200));
-       combo_resolution->addItem(QString::fromUtf8("320x240"), QSize(320, 240));
-       combo_resolution->addItem(QString::fromUtf8("512x400"), QSize(512, 400));
-       combo_resolution->addItem(QString::fromUtf8("512x480"), QSize(512, 480));
-       combo_resolution->addItem(QString::fromUtf8("640x200"), QSize(640, 200));
-       combo_resolution->addItem(QString::fromUtf8("640x400"), QSize(640, 400));
-       combo_resolution->addItem(QString::fromUtf8("640x480"), QSize(640, 480));
-       combo_resolution->addItem(QString::fromUtf8("1024x768"), QSize(1024, 768));
-       combo_resolution->addItem(QString::fromUtf8("1280x800"), QSize(1280, 800));
-       combo_resolution->addItem(QString::fromUtf8("1280x960"), QSize(1280, 960));
-       for(int i = 0; i < combo_resolution->count(); i++) {
-               QSize s = combo_resolution->itemData(i).toSize();
-               if((s.width() == config.video_width) && (s.height() == config.video_height)) {
-                       combo_resolution->setCurrentIndex(i);
-               }
-       }
-       connect(combo_resolution, SIGNAL(activated(int)), this, SLOT(do_set_video_resolution(int)));
-
-       // Video bitrates
-       combo_video_bitrate->addItem(QString::fromUtf8("128Kbps"), 128);        
-       combo_video_bitrate->addItem(QString::fromUtf8("256Kbps"), 256);
-       combo_video_bitrate->addItem(QString::fromUtf8("300Kbps"), 300);
-       combo_video_bitrate->addItem(QString::fromUtf8("512Kbps"), 512);
-       combo_video_bitrate->addItem(QString::fromUtf8("600Kbps"), 600);
-       combo_video_bitrate->addItem(QString::fromUtf8("768Kbps"), 768);
-       combo_video_bitrate->addItem(QString::fromUtf8("900Kbps"), 900);
-       combo_video_bitrate->addItem(QString::fromUtf8("1000Kbps"), 1000);
-       combo_video_bitrate->addItem(QString::fromUtf8("1200Kbps"), 1200);
-       combo_video_bitrate->addItem(QString::fromUtf8("1500Kbps"), 1500);
-       combo_video_bitrate->addItem(QString::fromUtf8("1800Kbps"), 1800);
-       combo_video_bitrate->addItem(QString::fromUtf8("3000Kbps"), 3000);
-       combo_video_bitrate->addItem(QString::fromUtf8("4500Kbps"), 4500);
-       for(int i = 0; i < combo_video_bitrate->count(); i++) {
-               int br = combo_video_bitrate->itemData(i).toInt();
-               if(br == config.video_bitrate) {
-                       combo_video_bitrate->setCurrentIndex(i);
-               }
-       }
-       connect(combo_video_bitrate, SIGNAL(activated(int)), this, SLOT(do_set_video_bitrate(int)));
-
-       // Video bframes
-       combo_video_bframes->addItem(QString::fromUtf8("0"), 0);
-       combo_video_bframes->addItem(QString::fromUtf8("1"), 1);
-       combo_video_bframes->addItem(QString::fromUtf8("2"), 2);
-       combo_video_bframes->addItem(QString::fromUtf8("3"), 3);
-       combo_video_bframes->addItem(QString::fromUtf8("4"), 4);
-       combo_video_bframes->addItem(QString::fromUtf8("5"), 5);
-       combo_video_bframes->addItem(QString::fromUtf8("6"), 6);
-       combo_video_bframes->addItem(QString::fromUtf8("7"), 7);
-       combo_video_bframes->addItem(QString::fromUtf8("8"), 8);
-       for(int i = 0; i < combo_video_bframes->count(); i++) {
-               int br = combo_video_bframes->itemData(i).toInt();
-               if(br == config.video_bframes) {
-                       combo_video_bframes->setCurrentIndex(i);
-               }
-       }
-       video_bframes = config.video_bframes;
-       connect(combo_video_bframes, SIGNAL(activated(int)), this, SLOT(do_set_bframes(int)));
-
-       // B adapt
-       combo_video_b_adapt->addItem(QApplication::translate("MainWindow", "None", 0), 0);
-       combo_video_b_adapt->addItem(QApplication::translate("MainWindow", "Fast", 0), 1);
-       combo_video_b_adapt->addItem(QApplication::translate("MainWindow", "Optimal (Slow with high B-Frames)", 0), 2);
-       for(int i = 0; i < combo_video_b_adapt->count(); i++) {
-               int br = combo_video_b_adapt->itemData(i).toInt();
-               if(br == config.video_b_adapt) {
-                       combo_video_b_adapt->setCurrentIndex(i);
-               }
-       }
-       video_b_adapt = config.video_b_adapt;
-       connect(combo_video_b_adapt, SIGNAL(activated(int)), this, SLOT(do_set_b_adapt(int)));
-
-       slider_qmin = new QSlider(Qt::Horizontal, this);
-       //slider_qmin->setMinimum(0);
-       //slider_qmin->setMaximum(63);
-       slider_qmin->setMinimum(1);
-       slider_qmin->setMaximum(31);
-       slider_qmin->setValue(config.video_minq);
-       label_qmin_val = new QLabel(this);
-       tmps.setNum(config.video_minq);
-       label_qmin_val->setText(tmps);
-       label_qmin_name = new QLabel(QString::fromUtf8("QP Min"), this);
-       video_minq = config.video_minq;
-       connect(slider_qmin, SIGNAL(valueChanged(int)), this, SLOT(do_set_qmin(int)));
-               
-       slider_qmax = new QSlider(Qt::Horizontal, this);
-       //slider_qmax->setMinimum(0);
-       //slider_qmax->setMaximum(63);
-       slider_qmax->setMinimum(1);
-       slider_qmax->setMaximum(31);
-       slider_qmax->setValue(config.video_maxq);
-       label_qmax_val = new QLabel(this);
-       tmps.setNum(config.video_maxq);
-       label_qmax_val->setText(tmps);
-       label_qmax_name = new QLabel(QString::fromUtf8("QP Max"), this);
-       connect(slider_qmax, SIGNAL(valueChanged(int)), this, SLOT(do_set_qmax(int)));
-       video_maxq = config.video_maxq;
-       
-       // Subme
-       combo_video_subme->addItem(QApplication::translate("MainWindow", "RD mode decision for I/P-frames", 0), 6);
-       combo_video_subme->addItem(QApplication::translate("MainWindow", "RD mode decision for all frames", 0), 7);
-       combo_video_subme->addItem(QApplication::translate("MainWindow", "RD refinement for  I/P-frames", 0), 8);
-       combo_video_subme->addItem(QApplication::translate("MainWindow", "RD refinement for all frames", 0), 9);
-       combo_video_subme->addItem(QApplication::translate("MainWindow", "QP-RD", 0), 10); // Trellis 2, admode > 0
-       combo_video_subme->addItem(QApplication::translate("MainWindow", "Full RD: disable all early terminations", 0), 11);
-       for(int i = 0; i < combo_video_subme->count(); i++) {
-               int br = combo_video_subme->itemData(i).toInt();
-               if(br == config.video_subme) {
-                       combo_video_subme->setCurrentIndex(i);
-               }
-       }
-       video_subme = config.video_subme;
-       connect(combo_video_subme, SIGNAL(activated(int)), this, SLOT(do_set_subme(int)));
-               
-       // Threads
-       combo_video_threads->addItem(QString::fromUtf8("Auto"), 0);
-       combo_video_threads->addItem(QString::fromUtf8("1"), 1);
-       combo_video_threads->addItem(QString::fromUtf8("2"), 2);
-       combo_video_threads->addItem(QString::fromUtf8("3"), 3);
-       combo_video_threads->addItem(QString::fromUtf8("4"), 4);
-       combo_video_threads->addItem(QString::fromUtf8("5"), 5);
-       combo_video_threads->addItem(QString::fromUtf8("6"), 6);
-       combo_video_threads->addItem(QString::fromUtf8("7"), 7);
-       combo_video_threads->addItem(QString::fromUtf8("8"), 8);
-       combo_video_threads->addItem(QString::fromUtf8("9"), 9);
-       combo_video_threads->addItem(QString::fromUtf8("10"), 10);
-       combo_video_threads->addItem(QString::fromUtf8("11"), 11);
-       combo_video_threads->addItem(QString::fromUtf8("12"), 12);
-       for(int i = 0; i < combo_video_threads->count(); i++) {
-               int br = combo_video_threads->itemData(i).toInt();
-               if(br == config.video_threads) {
-                       combo_video_threads->setCurrentIndex(i);
-               }
-       }
-       video_threads = config.video_threads;
-       connect(combo_video_threads, SIGNAL(activated(int)), this, SLOT(do_set_video_threads(int)));
-
-       // Audio bitrate
-       combo_audio_bitrate->addItem(QString::fromUtf8("32kbps"), 32);
-       combo_audio_bitrate->addItem(QString::fromUtf8("48kbps"), 48);
-       combo_audio_bitrate->addItem(QString::fromUtf8("64kbps"), 64);
-       combo_audio_bitrate->addItem(QString::fromUtf8("128kbps"), 128);
-       combo_audio_bitrate->addItem(QString::fromUtf8("160kbps"), 160);
-       combo_audio_bitrate->addItem(QString::fromUtf8("192kbps"), 192);
-       for(int i = 0; i < combo_audio_bitrate->count(); i++) {
-               int br = combo_audio_bitrate->itemData(i).toInt();
-               if(br == config.audio_bitrate) {
-                       combo_audio_bitrate->setCurrentIndex(i);
-               }
-       }
-       connect(combo_audio_bitrate, SIGNAL(activated(int)), this, SLOT(do_set_audio_bitrate(int)));
-       // Video bitrates
-       combo_video_fps->addItem(QString::fromUtf8("15fps"), 15);       
-       combo_video_fps->addItem(QString::fromUtf8("24fps"), 24);       
-       combo_video_fps->addItem(QString::fromUtf8("30fps"), 30);
-       combo_video_fps->addItem(QString::fromUtf8("60fps"), 60); // Temporally disabled
-       for(int i = 0; i < combo_video_fps->count(); i++) {
-               int fps = combo_video_fps->itemData(i).toInt();
-               if(fps == config.video_frame_rate) {
-                       combo_video_fps->setCurrentIndex(i);
-               }
-       }
-       connect(combo_video_fps, SIGNAL(activated(int)), this, SLOT(do_set_video_fps(int)));
-       
-
-       grid_layout->addWidget(label_title, 0, 0);
-       grid_layout->addWidget(label_resolution, 1, 0);
-       grid_layout->addWidget(combo_resolution, 2, 0);
-
-       
-       grid_layout->addWidget(label_qmin_name, 3, 0);
-       grid_layout->addWidget(label_qmin_val, 3, 3);
-       grid_layout->addWidget(slider_qmin, 4, 0, 1, 4);
-       grid_layout->addWidget(label_qmax_name, 5, 0);
-       grid_layout->addWidget(label_qmax_val, 5, 3);
-       grid_layout->addWidget(slider_qmax, 6, 0, 1, 4);
-       grid_layout->addWidget(label_video_bitrate, 7, 0);
-       grid_layout->addWidget(combo_video_bitrate, 7, 1);
-       grid_layout->addWidget(label_audio_bitrate, 7, 2);
-       grid_layout->addWidget(combo_audio_bitrate, 7, 3);
-       
-       grid_layout->addWidget(label_video_fps, 8, 0);
-       grid_layout->addWidget(combo_video_fps, 8, 1);
-       
-       grid_layout->addWidget(label_video_bframes, 9, 0);
-       grid_layout->addWidget(combo_video_bframes, 9, 1);
-       
-       grid_layout->addWidget(label_video_b_adapt, 9, 2);
-       grid_layout->addWidget(combo_video_b_adapt, 9, 3);
-       
-       grid_layout->addWidget(label_video_subme, 10, 0);
-       grid_layout->addWidget(combo_video_subme, 10, 1);
-       
-       grid_layout->addWidget(label_video_threads, 10, 2);
-       grid_layout->addWidget(combo_video_threads, 10, 3);
-
-       grid_layout->addWidget(cancel_button, 11, 2);
-       grid_layout->addWidget(close_button, 11, 3);
 
+       grid_layout->addWidget(label_title, 0, 0, 1, 2);
+       grid_layout->addWidget(tab_widget, 1, 0, 8, 4);
+       grid_layout->addWidget(cancel_button, 9, 2);
+       grid_layout->addWidget(close_button, 9, 3);
        this->setLayout(grid_layout);
-       
-       connect(this, SIGNAL(sig_video_add_option(QString, QString)), p_movie, SLOT(do_add_option(QString, QString)));
-       connect(this, SIGNAL(sig_video_clear_options()), p_movie, SLOT(do_clear_options_list()));
-       connect(this, SIGNAL(sig_set_audio_bitrate(int)), p_movie, SLOT(do_set_audio_bitrate(int)));
-       connect(this, SIGNAL(sig_set_video_bitrate(int)), p_movie, SLOT(do_set_video_bitrate(int)));
-       connect(this, SIGNAL(sig_set_video_resolution(QSize)), p_movie, SLOT(do_set_video_geometry(QSize)));
-       
+
        connect(cancel_button, SIGNAL(clicked()), this, SLOT(close()));
        connect(close_button, SIGNAL(clicked()), this, SLOT(do_set_codecs()));
        
@@ -271,130 +50,17 @@ CSP_DialogMovie::~CSP_DialogMovie()
 {
 }
 
-void CSP_DialogMovie::do_set_video_resolution(int n)
-{
-       QSize s = combo_resolution->itemData(n).toSize();
-       int w = s.width();
-       int h = s.height();
-       if(w < 128) w = 128;
-       if(h < 80) h = 80;
-       geometry = QSize(w, h);
-       
-}
-
-void CSP_DialogMovie::do_set_video_fps(int n)
-{
-       int val = combo_video_fps->itemData(n).toInt();
-       if(val < 15) val = 15;
-       if(val > 75) val = 75;
-       video_fps = val;
-}
-
-void CSP_DialogMovie::do_set_qmin(int n)
-{
-       if(n < 0) n = 0;
-       if(n > 63) n = 63;
-       QString tmps;
-       video_minq = n;
-       tmps.setNum(n);
-       label_qmin_val->setText(tmps);
-}
-
-void CSP_DialogMovie::do_set_qmax(int n)
-{
-       if(n < 0) n = 0;
-       if(n > 63) n = 63;
-       
-       QString tmps;
-       video_maxq = n;
-       tmps.setNum(n);
-       label_qmax_val->setText(tmps);
-}
-
-void CSP_DialogMovie::do_set_bframes(int n)
-{
-       int val = combo_video_bframes->itemData(n).toInt();
-       if(val < 0) val = 0;
-       if(val > 10) val = 10;
-       video_bframes = val;
-}
-
-void CSP_DialogMovie::do_set_video_bitrate(int n)
-{
-       int val = combo_video_bitrate->itemData(n).toInt();
-       if(val < 64) val = 64;
-       video_bitrate = val;
-}
-
-void CSP_DialogMovie::do_set_b_adapt(int n)
-{
-       int val = combo_video_b_adapt->itemData(n).toInt();
-       if(val < 0) val = 0;
-       if(val > 2) val = 2;
-       video_b_adapt = val;
-}
-
-void CSP_DialogMovie::do_set_subme(int n)
-{
-       int val = combo_video_subme->itemData(n).toInt();
-       if(val < 4) val = 4;
-       if(val > 11) val = 11;
-       video_subme = val;
-}
-
-void CSP_DialogMovie::do_set_video_threads(int n)
-{
-       int val = combo_video_threads->itemData(n).toInt();
-       if(val < 0) val = 0;
-       if(val > 12) val = 12;
-       video_threads = val;
-}
-
-void CSP_DialogMovie::do_set_audio_bitrate(int n)
-{
-       int val = combo_audio_bitrate->itemData(n).toInt();
-       if(val < 16) val = 16;
-       if(val > 448) val = 448;
-       audio_bitrate = val;
-}
-
 void CSP_DialogMovie::do_set_codecs(void)
 {
        QString value;
 
        // See:
        // https://libav.org/avconv.html#Video-Options
-       config.video_bitrate = video_bitrate;
-       emit sig_set_video_bitrate(video_bitrate);
-       config.audio_bitrate = audio_bitrate;
-       emit sig_set_audio_bitrate(audio_bitrate);
-
        emit sig_video_clear_options();
-       emit sig_video_add_option(QString::fromUtf8("c:v"), QString::fromUtf8("mpeg4"));
-       emit sig_video_add_option(QString::fromUtf8("c:a"), QString::fromUtf8("aac"));
-       //emit sig_video_add_option(QString::fromUtf8("c:v"), QString::fromUtf8("theora"));
-       //emit sig_video_add_option(QString::fromUtf8("c:a"), QString::fromUtf8("vorbis"));
-       config.video_maxq = video_maxq;
-       config.video_minq = video_minq;
-       config.video_bframes = video_bframes;
-       config.video_b_adapt = video_b_adapt;
-       config.video_subme = video_subme;
-
-       value.setNum(video_bframes);
-       emit sig_video_add_option(QString::fromUtf8("bf"), value);
-
-       value.setNum(video_b_adapt);
-       emit sig_video_add_option(QString::fromUtf8("b_strategy"), value);
-
-       value.setNum(video_subme);
-       emit sig_video_add_option(QString::fromUtf8("subq"), value);
-
-
-       config.video_width = geometry.width();
-       config.video_height = geometry.height();
-       emit sig_set_video_resolution(geometry);
-
-       config.video_threads = video_threads;
-       config.video_frame_rate = video_fps;
+       if(tab_general != NULL) tab_general->do_set_codecs();
+       if(tab_h264 != NULL) tab_h264->do_set_codecs();
+       if(tab_mpeg4 != NULL) tab_mpeg4->do_set_codecs();
+       
        this->close();
 }
+
index 59ac61e..d276cd8 100644 (file)
  *  History: Feb 23, 2016 : Initial
  */
 
-#ifndef _CSP_QT_DIALOG_MOVIE_JSBUTTON_H
-#define _CSP_QT_DIALOG_MOVIE_JSBUTTON_H
+#ifndef _CSP_QT_DIALOG_MOVIE_H
+#define _CSP_QT_DIALOG_MOVIE_H
 
 #include <QString>
 #include <QStringList>
 #include <QSize>
 #include <QWidget>
 
-#ifdef __GNUC__
-       #if defined(Q_OS_WIN) || defined(__WIN32) || defined(__WIN64)
-               #define DLL_PREFIX __declspec(dllexport)
-       #else
-               #define DLL_PREFIX
-       #endif
-#else
-               #define DLL_PREFIX
-#endif
+#include "common.h"
+
 
 QT_BEGIN_NAMESPACE
-class QHBoxLayout;
-class QVBoxLayout;
 class QGridLayout;
 class QLabel;
-class QComboBox;
 class QPushButton;
 class QSlider;
+class QTabWidget;
 
 class MOVIE_SAVER;
+class CSP_TabMovieGeneral;
+class CSP_TabMovieH264;
+class CSP_TabMovieMPEG4;
 
 class DLL_PREFIX CSP_DialogMovie: public QWidget {
        Q_OBJECT;
 private:
-       QSize geometry;
-       
        QLabel *label_title;
        QGridLayout *grid_layout;
+       QTabWidget *tab_widget;
 
-       QLabel *label_resolution;
-       QComboBox *combo_resolution;
-       
-       QLabel *label_video_bitrate;
-       QComboBox *combo_video_bitrate;
-       
-       QLabel *label_video_bframes;
-       QComboBox *combo_video_bframes;
-       
-       QLabel *label_video_b_adapt;
-       QComboBox *combo_video_b_adapt;
-       
-       QLabel *label_video_subme;
-       QComboBox *combo_video_subme;
-       
-       QLabel *label_video_threads;
-       QComboBox *combo_video_threads;
-
-       QSlider *slider_qmin, *slider_qmax;
-       QLabel *label_audio_bitrate;
-
-       QLabel *label_qmin_val;
-       QLabel *label_qmax_val;
-       QLabel *label_qmin_name;
-       QLabel *label_qmax_name;
-       QComboBox *combo_audio_bitrate;
-
-       QLabel *label_video_fps;
-       QComboBox *combo_video_fps;
 
        QPushButton *cancel_button;
        QPushButton *close_button;
 
+       CSP_TabMovieGeneral *tab_general;
+       CSP_TabMovieH264 *tab_h264;
+       CSP_TabMovieMPEG4 *tab_mpeg4;
 protected:
        QWidget *p_wid;
        MOVIE_SAVER *p_movie;
 
-       int resolution;
-       int video_bitrate;
-       int video_bframes;
-       int video_b_adapt;
-       int video_subme;
-       int video_threads;
-       int video_minq;
-       int video_maxq;
-       int audio_bitrate;
-       int video_fps;
 public:
        CSP_DialogMovie(MOVIE_SAVER *ms, QWidget *parent = NULL);
        ~CSP_DialogMovie();
 public slots:
-       void do_set_video_resolution(int);
-       void do_set_video_bitrate(int);
-       void do_set_qmin(int n);
-       void do_set_qmax(int n);
-
-       void do_set_bframes(int);
-       void do_set_b_adapt(int);
-       void do_set_subme(int);
-       void do_set_video_threads(int);
-       void do_set_audio_bitrate(int);
-       void do_set_video_fps(int);
-       void do_set_codecs();
-       
+       void do_set_codecs(void);
 signals:
-       int sig_set_video_resolution(QSize);
-       int sig_set_video_bitrate(int);
        int sig_video_reset_options(void);
        int sig_video_clear_options(void);
        int sig_video_add_option(QString, QString);
-       int sig_set_audio_bitrate(int);
-       
 };
        QT_END_NAMESPACE
 #endif
index d5d48c2..faf1c01 100644 (file)
 #include <QComboBox>
 #include <QList>
 #include <QStringList>
-#ifdef __GNUC__
-       #if defined(Q_OS_WIN) || defined(__WIN32) || defined(__WIN64)
-               #define DLL_PREFIX __declspec(dllexport)
-       #else
-               #define DLL_PREFIX
-       #endif
-#else
-               #define DLL_PREFIX
-#endif
+#include "common.h"
 
 QT_BEGIN_NAMESPACE
 class DLL_PREFIX CSP_KeySetupCombo: public QComboBox
index 1daaa47..f76f4ec 100644 (file)
@@ -57,15 +57,15 @@ void Object_Menu_Control::set_screen_size(void) {
 
 void Ui_MainWindowBase::do_stop_saving_movie(void)
 {
-       actionStop_Record_Movie->setVisible(false);
-       actionStart_Record_Movie->setVisible(true);
+       //actionStop_Record_Movie->setVisible(false);
+       //actionStart_Record_Movie->setVisible(true);
        emit sig_stop_saving_movie();
 }
 
 void Ui_MainWindowBase::do_start_saving_movie(void)
 {
-       actionStop_Record_Movie->setVisible(true);
-       actionStart_Record_Movie->setVisible(false);
+       //actionStop_Record_Movie->setVisible(true);
+       //actionStart_Record_Movie->setVisible(false);
        emit sig_start_saving_movie();
 }
 
diff --git a/source/src/qt/gui/tab_movie_general.cpp b/source/src/qt/gui/tab_movie_general.cpp
new file mode 100644 (file)
index 0000000..b2088eb
--- /dev/null
@@ -0,0 +1,321 @@
+
+
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QWidget>
+#include <QPushButton>
+#include <QSlider>
+#include <QComboBox>
+#include <QLabel>
+#include <QApplication>
+
+#include "dialog_movie.h"
+#include "tab_movie_general.h"
+#include "../avio/movie_saver.h"
+#include "../../config.h"
+#include "menu_flags.h"
+
+extern USING_FLAGS *using_flags;
+
+CSP_TabMovieGeneral::CSP_TabMovieGeneral(MOVIE_SAVER *ms, CSP_DialogMovie *parent_window, QWidget *parent) : QWidget(parent)
+{
+       p_wid = parent;
+       p_movie = ms;
+       p_window = parent_window;
+       QString tmps;
+       grid_layout = new QGridLayout(this);
+
+       label_vcodec = new QLabel(QApplication::translate("MainWindow", "Video Codec", 0), this);
+       combo_vcodec = new QComboBox(this);
+       combo_vcodec->addItem(QString::fromUtf8("MPEG4"), VIDEO_CODEC_MPEG4);
+       combo_vcodec->addItem(QString::fromUtf8("H.264 (Drop tail frames)"), VIDEO_CODEC_H264);
+       for(int i = 0; i < combo_vcodec->count(); i++) {
+               int ii = combo_vcodec->itemData(i).toInt();
+               if(ii == config.video_codec_type) {
+                       combo_vcodec->setCurrentIndex(ii);
+               }
+       }
+       video_codec_type = config.video_codec_type;
+       connect(combo_vcodec, SIGNAL(activated(int)), this, SLOT(do_set_video_codec_type(int)));
+
+       label_resolution = new QLabel(QApplication::translate("MainWindow", "Resolution", 0), this);
+       combo_resolution = new QComboBox(this);
+
+       geometry.setWidth(config.video_width);
+       geometry.setHeight(config.video_height);
+       audio_bitrate = config.audio_bitrate;
+
+       label_video_threads = new QLabel(QApplication::translate("MainWindow", "Video Threads", 0), this);
+       combo_video_threads = new QComboBox(this);
+       combo_audio_bitrate = new QComboBox(this);
+       label_audio_bitrate = new QLabel(QApplication::translate("MainWindow", "Audio Bitrate", 0), this);
+       label_video_fps = new QLabel(QApplication::translate("MainWindow", "Framerate", 0), this);
+       combo_video_fps = new QComboBox(this);
+       video_fps = config.video_frame_rate;
+       
+       // Value for resolution
+       bool skipf = false;
+       int x_w[4];
+       int y_h[4];
+       for(int ii = 1; ii < 5; ii++) {
+               x_w[ii - 1] = using_flags->get_screen_width() * ii;
+       }
+       for(int ii = 1; ii < 5; ii++) {
+               y_h[ii - 1] = using_flags->get_screen_height() * ii;
+       }
+
+       for(int ii = 0; ii < 4; ii++) {
+               if(x_w[ii] < 256) {
+                       QString tmps_w, tmps_h;
+                       QString tmps;
+                       tmps_w.setNum(x_w[ii]);
+                       tmps_h.setNum(y_h[ii]);
+                       tmps = tmps_w + QString::fromUtf8("x") + tmps_h;
+                       combo_resolution->addItem(tmps, QSize(x_w[ii], y_h[ii]));
+               }
+       }
+       combo_resolution->addItem(QString::fromUtf8("256x160"), QSize(256, 160));
+       combo_resolution->addItem(QString::fromUtf8("256x240"), QSize(256, 240));
+
+       for(int ii = 0; ii < 4; ii++) {
+               if((x_w[ii] < 320) && (x_w[ii] > 256)){
+                       QString tmps_w, tmps_h;
+                       QString tmps;
+                       tmps_w.setNum(x_w[ii]);
+                       tmps_h.setNum(y_h[ii]);
+                       tmps = tmps_w + QString::fromUtf8("x") + tmps_h;
+                       combo_resolution->addItem(tmps, QSize(x_w[ii], y_h[ii]));
+               }
+       }
+       
+       combo_resolution->addItem(QString::fromUtf8("320x128"), QSize(320, 128));
+       combo_resolution->addItem(QString::fromUtf8("320x200"), QSize(320, 200));
+       combo_resolution->addItem(QString::fromUtf8("320x240"), QSize(320, 240));
+       
+       for(int ii = 0; ii < 4; ii++) {
+               if((x_w[ii] < 512) && (x_w[ii] > 320)){
+                       QString tmps_w, tmps_h;
+                       QString tmps;
+                       tmps_w.setNum(x_w[ii]);
+                       tmps_h.setNum(y_h[ii]);
+                       tmps = tmps_w + QString::fromUtf8("x") + tmps_h;
+                       combo_resolution->addItem(tmps, QSize(x_w[ii], y_h[ii]));
+               }
+       }
+       combo_resolution->addItem(QString::fromUtf8("512x400"), QSize(512, 400));
+       combo_resolution->addItem(QString::fromUtf8("512x480"), QSize(512, 480));
+
+       for(int ii = 0; ii < 4; ii++) {
+               if((x_w[ii] < 640) && (x_w[ii] > 512)){
+                       QString tmps_w, tmps_h;
+                       QString tmps;
+                       tmps_w.setNum(x_w[ii]);
+                       tmps_h.setNum(y_h[ii]);
+                       tmps = tmps_w + QString::fromUtf8("x") + tmps_h;
+                       combo_resolution->addItem(tmps, QSize(x_w[ii], y_h[ii]));
+               }
+       }
+       
+       combo_resolution->addItem(QString::fromUtf8("640x200"), QSize(640, 200));
+       combo_resolution->addItem(QString::fromUtf8("640x400"), QSize(640, 400));
+       combo_resolution->addItem(QString::fromUtf8("640x480"), QSize(640, 480));
+
+       for(int ii = 0; ii < 4; ii++) {
+               if((x_w[ii] < 1024) && (x_w[ii] > 640)){
+                       QString tmps_w, tmps_h;
+                       QString tmps;
+                       tmps_w.setNum(x_w[ii]);
+                       tmps_h.setNum(y_h[ii]);
+                       tmps = tmps_w + QString::fromUtf8("x") + tmps_h;
+                       combo_resolution->addItem(tmps, QSize(x_w[ii], y_h[ii]));
+               }
+       }
+       
+       combo_resolution->addItem(QString::fromUtf8("1024x768"), QSize(1024, 768));
+       
+       for(int ii = 0; ii < 4; ii++) {
+               if((x_w[ii] < 1280) && (x_w[ii] > 1024)){
+                       QString tmps_w, tmps_h;
+                       QString tmps;
+                       tmps_w.setNum(x_w[ii]);
+                       tmps_h.setNum(y_h[ii]);
+                       tmps = tmps_w + QString::fromUtf8("x") + tmps_h;
+                       combo_resolution->addItem(tmps, QSize(x_w[ii], y_h[ii]));
+               }
+       }
+       combo_resolution->addItem(QString::fromUtf8("1280x800"), QSize(1280, 800));
+       combo_resolution->addItem(QString::fromUtf8("1280x960"), QSize(1280, 960));
+
+       for(int ii = 0; ii < 4; ii++) {
+               if((x_w[ii] <= 1920) && (x_w[ii] > 1280)){
+                       QString tmps_w, tmps_h;
+                       QString tmps;
+                       tmps_w.setNum(x_w[ii]);
+                       tmps_h.setNum(y_h[ii]);
+                       tmps = tmps_w + QString::fromUtf8("x") + tmps_h;
+                       combo_resolution->addItem(tmps, QSize(x_w[ii], y_h[ii]));
+               }
+       }
+       
+       for(int i = 0; i < combo_resolution->count(); i++) {
+               QSize s = combo_resolution->itemData(i).toSize();
+               if((s.width() == config.video_width) && (s.height() == config.video_height)) {
+                       combo_resolution->setCurrentIndex(i);
+               }
+       }
+       connect(combo_resolution, SIGNAL(activated(int)), this, SLOT(do_set_video_resolution(int)));
+
+       // Threads
+       combo_video_threads->addItem(QString::fromUtf8("Auto"), 0);
+       combo_video_threads->addItem(QString::fromUtf8("1"), 1);
+       combo_video_threads->addItem(QString::fromUtf8("2"), 2);
+       combo_video_threads->addItem(QString::fromUtf8("3"), 3);
+       combo_video_threads->addItem(QString::fromUtf8("4"), 4);
+       combo_video_threads->addItem(QString::fromUtf8("5"), 5);
+       combo_video_threads->addItem(QString::fromUtf8("6"), 6);
+       combo_video_threads->addItem(QString::fromUtf8("7"), 7);
+       combo_video_threads->addItem(QString::fromUtf8("8"), 8);
+       combo_video_threads->addItem(QString::fromUtf8("9"), 9);
+       combo_video_threads->addItem(QString::fromUtf8("10"), 10);
+       combo_video_threads->addItem(QString::fromUtf8("11"), 11);
+       combo_video_threads->addItem(QString::fromUtf8("12"), 12);
+       for(int i = 0; i < combo_video_threads->count(); i++) {
+               int br = combo_video_threads->itemData(i).toInt();
+               if(br == config.video_threads) {
+                       combo_video_threads->setCurrentIndex(i);
+               }
+       }
+       video_threads = config.video_threads;
+       connect(combo_video_threads, SIGNAL(activated(int)), this, SLOT(do_set_video_threads(int)));
+
+       // Audio bitrate
+       combo_audio_bitrate->addItem(QString::fromUtf8("32kbps"), 32);
+       combo_audio_bitrate->addItem(QString::fromUtf8("48kbps"), 48);
+       combo_audio_bitrate->addItem(QString::fromUtf8("64kbps"), 64);
+       combo_audio_bitrate->addItem(QString::fromUtf8("128kbps"), 128);
+       combo_audio_bitrate->addItem(QString::fromUtf8("160kbps"), 160);
+       combo_audio_bitrate->addItem(QString::fromUtf8("192kbps"), 192);
+       for(int i = 0; i < combo_audio_bitrate->count(); i++) {
+               int br = combo_audio_bitrate->itemData(i).toInt();
+               if(br == config.audio_bitrate) {
+                       combo_audio_bitrate->setCurrentIndex(i);
+               }
+       }
+       connect(combo_audio_bitrate, SIGNAL(activated(int)), this, SLOT(do_set_audio_bitrate(int)));
+       // Video bitrates
+       combo_video_fps->addItem(QString::fromUtf8("15fps"), 15);       
+       combo_video_fps->addItem(QString::fromUtf8("24fps"), 24);       
+       combo_video_fps->addItem(QString::fromUtf8("30fps"), 30);
+       combo_video_fps->addItem(QString::fromUtf8("60fps"), 60); // Temporally disabled
+       for(int i = 0; i < combo_video_fps->count(); i++) {
+               int fps = combo_video_fps->itemData(i).toInt();
+               if(fps == config.video_frame_rate) {
+                       combo_video_fps->setCurrentIndex(i);
+               }
+       }
+       connect(combo_video_fps, SIGNAL(activated(int)), this, SLOT(do_set_video_fps(int)));
+       
+
+       grid_layout->addWidget(label_resolution, 1, 0);
+       grid_layout->addWidget(combo_resolution, 2, 0);
+       grid_layout->addWidget(label_vcodec, 3, 0);
+       grid_layout->addWidget(combo_vcodec, 4, 0);
+
+       grid_layout->addWidget(label_audio_bitrate, 5, 2);
+       grid_layout->addWidget(combo_audio_bitrate, 5, 3);
+       
+       grid_layout->addWidget(label_video_fps, 5, 0);
+       grid_layout->addWidget(combo_video_fps, 5, 1);
+       
+       grid_layout->addWidget(label_video_threads, 6, 2);
+       grid_layout->addWidget(combo_video_threads, 6, 3);
+
+       this->setLayout(grid_layout);
+       
+       connect(this, SIGNAL(sig_video_add_option(QString, QString)), p_movie, SLOT(do_add_option(QString, QString)));
+       connect(this, SIGNAL(sig_set_audio_bitrate(int)), p_movie, SLOT(do_set_audio_bitrate(int)));
+       connect(this, SIGNAL(sig_set_video_resolution(QSize)), p_movie, SLOT(do_set_video_geometry(QSize)));
+       
+}
+
+CSP_TabMovieGeneral::~CSP_TabMovieGeneral()
+{
+}
+
+void CSP_TabMovieGeneral::do_set_video_resolution(int n)
+{
+       QSize s = combo_resolution->itemData(n).toSize();
+       int w = s.width();
+       int h = s.height();
+       if(w < 128) w = 128;
+       if(h < 80) h = 80;
+       geometry = QSize(w, h);
+       
+}
+
+void CSP_TabMovieGeneral::do_set_video_fps(int n)
+{
+       int val = combo_video_fps->itemData(n).toInt();
+       if(val < 15) val = 15;
+       if(val > 75) val = 75;
+       video_fps = val;
+}
+
+
+void CSP_TabMovieGeneral::do_set_video_threads(int n)
+{
+       int val = combo_video_threads->itemData(n).toInt();
+       if(val < 0) val = 0;
+       if(val > 12) val = 12;
+       video_threads = val;
+}
+
+void CSP_TabMovieGeneral::do_set_video_codec_type(int n)
+{
+       int val = combo_vcodec->itemData(n).toInt();
+       if(val < 0) val = 0;
+       if(val >= VIDEO_CODEC_END) val = VIDEO_CODEC_END - 1;
+       video_codec_type = val;
+}
+
+void CSP_TabMovieGeneral::do_set_audio_bitrate(int n)
+{
+       int val = combo_audio_bitrate->itemData(n).toInt();
+       if(val < 16) val = 16;
+       if(val > 448) val = 448;
+       audio_bitrate = val;
+}
+
+void CSP_TabMovieGeneral::do_set_codecs(void)
+{
+       QString value;
+
+       // See:
+       // https://libav.org/avconv.html#Video-Options
+       config.audio_bitrate = audio_bitrate;
+       emit sig_set_audio_bitrate(audio_bitrate);
+
+       switch(video_codec_type) {
+       case VIDEO_CODEC_MPEG4:
+               emit sig_video_add_option(QString::fromUtf8("c:v"), QString::fromUtf8("mpeg4"));
+               break;
+       case VIDEO_CODEC_H264:
+               emit sig_video_add_option(QString::fromUtf8("c:v"), QString::fromUtf8("h264"));
+               break;
+       }
+       config.video_codec_type = video_codec_type;
+       
+       emit sig_video_add_option(QString::fromUtf8("c:a"), QString::fromUtf8("aac"));
+       //config.audio_codec_type = audio_codec_type;
+
+       config.video_threads = video_threads;
+       config.video_frame_rate = video_fps;
+
+       config.video_width = geometry.width();
+       config.video_height = geometry.height();
+       emit sig_set_video_resolution(geometry);
+
+       config.video_threads = video_threads;
+       config.video_frame_rate = video_fps;
+}
diff --git a/source/src/qt/gui/tab_movie_general.h b/source/src/qt/gui/tab_movie_general.h
new file mode 100644 (file)
index 0000000..07d1c06
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Common Source Project/ Qt
+ * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ *  Qt: Menu->Emulator->Define Strings
+ *  History: Feb 23, 2016 : Initial
+ */
+
+#ifndef _CSP_QT_TAB_MOVIE_GENERAL_H
+#define _CSP_QT_TAB_MOVIE_GENERAL_H
+
+#include <QString>
+#include <QStringList>
+#include <QSize>
+#include <QWidget>
+#include "common.h"
+
+class QHBoxLayout;
+class QVBoxLayout;
+class QGridLayout;
+class QLabel;
+class QComboBox;
+class QPushButton;
+class QSlider;
+
+class MOVIE_SAVER;
+class CSP_DialogMovie;
+
+class DLL_PREFIX CSP_TabMovieGeneral: public QWidget {
+       Q_OBJECT;
+private:
+       QSize geometry;
+       
+       QGridLayout *grid_layout;
+
+       QLabel *label_vcodec;
+       QComboBox *combo_vcodec;
+       
+       QLabel *label_resolution;
+       QComboBox *combo_resolution;
+       
+       QLabel *label_video_threads;
+       QComboBox *combo_video_threads;
+
+       QLabel *label_audio_bitrate;
+       QComboBox *combo_audio_bitrate;
+
+       QLabel *label_video_fps;
+       QComboBox *combo_video_fps;
+
+protected:
+       QWidget *p_wid;
+       MOVIE_SAVER *p_movie;
+       CSP_DialogMovie *p_window;
+       
+       int resolution;
+       int video_codec_type;
+       int video_threads;
+       int audio_bitrate;
+       int video_fps;
+public:
+       CSP_TabMovieGeneral(MOVIE_SAVER *ms, CSP_DialogMovie *parent_window, QWidget *parent = NULL);
+       ~CSP_TabMovieGeneral();
+public slots:
+       void do_set_video_codec_type(int);
+       void do_set_video_resolution(int);
+       void do_set_video_threads(int);
+       void do_set_audio_bitrate(int);
+       void do_set_video_fps(int);
+       void do_set_codecs();
+signals:
+       int sig_video_add_option(QString, QString);
+       int sig_set_video_resolution(QSize);
+       int sig_set_audio_bitrate(int);
+};
+
+#endif
diff --git a/source/src/qt/gui/tab_movie_h264.cpp b/source/src/qt/gui/tab_movie_h264.cpp
new file mode 100644 (file)
index 0000000..c550995
--- /dev/null
@@ -0,0 +1,229 @@
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QWidget>
+#include <QPushButton>
+#include <QSlider>
+#include <QComboBox>
+#include <QLabel>
+#include <QApplication>
+
+#include "tab_movie_h264.h"
+#include "dialog_movie.h"
+#include "../avio/movie_saver.h"
+#include "../../config.h"
+
+CSP_TabMovieH264::CSP_TabMovieH264(MOVIE_SAVER *ms, CSP_DialogMovie *parent_window, QWidget *parent) : QWidget(parent)
+{
+       QString tmps;
+       
+       p_wid = parent;
+       p_movie = ms;
+       p_window = parent_window;
+
+       video_maxq = config.video_h264_maxq;
+       video_minq = config.video_h264_minq;
+
+       label_video_bframes = new QLabel(QApplication::translate("MainWindow", "Max B Frames", 0), this);
+       combo_video_bframes = new QComboBox(this);
+       label_video_b_adapt = new QLabel(QApplication::translate("MainWindow", "B Adaption", 0), this);
+       combo_video_b_adapt = new QComboBox(this);
+       label_video_subme = new QLabel(QApplication::translate("MainWindow", "Subpixel motion estimate", 0), this);
+       combo_video_subme = new QComboBox(this);
+
+       // Video bitrates
+       label_video_bitrate = new QLabel(QApplication::translate("MainWindow", "Bitrate", 0), this);
+       combo_video_bitrate = new QComboBox(this);
+       combo_video_bitrate->addItem(QString::fromUtf8("128Kbps"), 128);        
+       combo_video_bitrate->addItem(QString::fromUtf8("256Kbps"), 256);
+       combo_video_bitrate->addItem(QString::fromUtf8("300Kbps"), 300);
+       combo_video_bitrate->addItem(QString::fromUtf8("512Kbps"), 512);
+       combo_video_bitrate->addItem(QString::fromUtf8("600Kbps"), 600);
+       combo_video_bitrate->addItem(QString::fromUtf8("768Kbps"), 768);
+       combo_video_bitrate->addItem(QString::fromUtf8("900Kbps"), 900);
+       combo_video_bitrate->addItem(QString::fromUtf8("1000Kbps"), 1000);
+       combo_video_bitrate->addItem(QString::fromUtf8("1200Kbps"), 1200);
+       combo_video_bitrate->addItem(QString::fromUtf8("1500Kbps"), 1500);
+       combo_video_bitrate->addItem(QString::fromUtf8("1800Kbps"), 1800);
+       combo_video_bitrate->addItem(QString::fromUtf8("3000Kbps"), 3000);
+       combo_video_bitrate->addItem(QString::fromUtf8("4500Kbps"), 4500);
+       for(int i = 0; i < combo_video_bitrate->count(); i++) {
+               int br = combo_video_bitrate->itemData(i).toInt();
+               if(br == config.video_h264_bitrate) {
+                       combo_video_bitrate->setCurrentIndex(i);
+               }
+       }
+       connect(combo_video_bitrate, SIGNAL(activated(int)), this, SLOT(do_set_video_bitrate(int)));
+       video_bitrate = config.video_h264_bitrate;
+
+       // Video bframes
+       combo_video_bframes->addItem(QString::fromUtf8("0"), 0);
+       combo_video_bframes->addItem(QString::fromUtf8("1"), 1);
+       combo_video_bframes->addItem(QString::fromUtf8("2"), 2);
+       combo_video_bframes->addItem(QString::fromUtf8("3"), 3);
+       combo_video_bframes->addItem(QString::fromUtf8("4"), 4);
+       combo_video_bframes->addItem(QString::fromUtf8("5"), 5);
+       combo_video_bframes->addItem(QString::fromUtf8("6"), 6);
+       combo_video_bframes->addItem(QString::fromUtf8("7"), 7);
+       combo_video_bframes->addItem(QString::fromUtf8("8"), 8);
+       for(int i = 0; i < combo_video_bframes->count(); i++) {
+               int br = combo_video_bframes->itemData(i).toInt();
+               if(br == config.video_h264_bframes) {
+                       combo_video_bframes->setCurrentIndex(i);
+               }
+       }
+       video_bframes = config.video_h264_bframes;
+       connect(combo_video_bframes, SIGNAL(activated(int)), this, SLOT(do_set_bframes(int)));
+
+       // B adapt
+       combo_video_b_adapt->addItem(QApplication::translate("MainWindow", "None", 0), 0);
+       combo_video_b_adapt->addItem(QApplication::translate("MainWindow", "Fast", 0), 1);
+       combo_video_b_adapt->addItem(QApplication::translate("MainWindow", "Optimal (Slow with high B-Frames)", 0), 2);
+       for(int i = 0; i < combo_video_b_adapt->count(); i++) {
+               int br = combo_video_b_adapt->itemData(i).toInt();
+               if(br == config.video_h264_b_adapt) {
+                       combo_video_b_adapt->setCurrentIndex(i);
+               }
+       }
+       video_b_adapt = config.video_h264_b_adapt;
+       connect(combo_video_b_adapt, SIGNAL(activated(int)), this, SLOT(do_set_b_adapt(int)));
+
+       slider_qmin = new QSlider(Qt::Horizontal, this);
+       slider_qmin->setMinimum(0);
+       slider_qmin->setMaximum(63);
+       slider_qmin->setValue(config.video_h264_minq);
+       label_qmin_val = new QLabel(this);
+       tmps.setNum(config.video_h264_minq);
+       label_qmin_val->setText(tmps);
+       label_qmin_name = new QLabel(QString::fromUtf8("QP Min"), this);
+       video_minq = config.video_h264_minq;
+       connect(slider_qmin, SIGNAL(valueChanged(int)), this, SLOT(do_set_qmin(int)));
+               
+       slider_qmax = new QSlider(Qt::Horizontal, this);
+       slider_qmax->setMinimum(0);
+       slider_qmax->setMaximum(63);
+       slider_qmax->setValue(config.video_h264_maxq);
+       label_qmax_val = new QLabel(this);
+       tmps.setNum(config.video_h264_maxq);
+       label_qmax_val->setText(tmps);
+       label_qmax_name = new QLabel(QString::fromUtf8("QP Max"), this);
+       connect(slider_qmax, SIGNAL(valueChanged(int)), this, SLOT(do_set_qmax(int)));
+       video_maxq = config.video_h264_maxq;
+       
+       // Subme
+       combo_video_subme->addItem(QApplication::translate("MainWindow", "RD mode decision for I/P-frames", 0), 6);
+       combo_video_subme->addItem(QApplication::translate("MainWindow", "RD mode decision for all frames", 0), 7);
+       combo_video_subme->addItem(QApplication::translate("MainWindow", "RD refinement for  I/P-frames", 0), 8);
+       combo_video_subme->addItem(QApplication::translate("MainWindow", "RD refinement for all frames", 0), 9);
+       combo_video_subme->addItem(QApplication::translate("MainWindow", "QP-RD", 0), 10); // Trellis 2, admode > 0
+       combo_video_subme->addItem(QApplication::translate("MainWindow", "Full RD: disable all early terminations", 0), 11);
+       for(int i = 0; i < combo_video_subme->count(); i++) {
+               int br = combo_video_subme->itemData(i).toInt();
+               if(br == config.video_h264_subme) {
+                       combo_video_subme->setCurrentIndex(i);
+               }
+       }
+       video_subme = config.video_h264_subme;
+       connect(combo_video_subme, SIGNAL(activated(int)), this, SLOT(do_set_subme(int)));
+               
+       label_title = new QLabel(QApplication::translate("MainWindow", "Set H.264 parameter.", 0), this);
+       grid_layout = new QGridLayout(this);
+
+       grid_layout->addWidget(label_title, 0, 0);
+       
+       grid_layout->addWidget(label_qmin_name, 1, 0);
+       grid_layout->addWidget(label_qmin_val, 1, 3);
+       grid_layout->addWidget(slider_qmin, 2, 0, 1, 4);
+       grid_layout->addWidget(label_qmax_name, 3, 0);
+       grid_layout->addWidget(label_qmax_val, 3, 3);
+       grid_layout->addWidget(slider_qmax, 4, 0, 1, 4);
+       grid_layout->addWidget(label_video_bitrate, 5, 0);
+       grid_layout->addWidget(combo_video_bitrate, 5, 1);
+       
+       
+       grid_layout->addWidget(label_video_bframes, 6, 0);
+       grid_layout->addWidget(combo_video_bframes, 6, 1);
+       
+       grid_layout->addWidget(label_video_b_adapt, 6, 2);
+       grid_layout->addWidget(combo_video_b_adapt, 6, 3);
+       
+       grid_layout->addWidget(label_video_subme, 7, 0);
+       grid_layout->addWidget(combo_video_subme, 7, 1);
+       
+       this->setLayout(grid_layout);
+
+       connect(this, SIGNAL(sig_video_add_option(QString, QString)), p_movie, SLOT(do_add_option(QString, QString)));
+       connect(this, SIGNAL(sig_set_video_bitrate(int)), p_movie, SLOT(do_set_video_bitrate(int)));
+       this->show();
+}
+
+
+CSP_TabMovieH264::~CSP_TabMovieH264()
+{
+}
+
+void CSP_TabMovieH264::do_set_codecs(void)
+{
+       QString value;
+       // See:
+       // https://libav.org/avconv.html#Video-Options
+       config.video_h264_bitrate = video_bitrate;
+
+       config.video_h264_maxq = video_maxq;
+       config.video_h264_minq = video_minq;
+       config.video_h264_bframes = video_bframes;
+       config.video_h264_b_adapt = video_b_adapt;
+       config.video_h264_subme = video_subme;
+}
+
+void CSP_TabMovieH264::do_set_qmin(int n)
+{
+       if(n < 0) n = 0;
+       if(n > 63) n = 63;
+       QString tmps;
+       video_minq = n;
+       tmps.setNum(n);
+       label_qmin_val->setText(tmps);
+}
+
+void CSP_TabMovieH264::do_set_qmax(int n)
+{
+       if(n < 0) n = 0;
+       if(n > 63) n = 63;
+       
+       QString tmps;
+       video_maxq = n;
+       tmps.setNum(n);
+       label_qmax_val->setText(tmps);
+}
+
+void CSP_TabMovieH264::do_set_bframes(int n)
+{
+       int val = combo_video_bframes->itemData(n).toInt();
+       if(val < 0) val = 0;
+       if(val > 10) val = 10;
+       video_bframes = val;
+}
+
+void CSP_TabMovieH264::do_set_video_bitrate(int n)
+{
+       int val = combo_video_bitrate->itemData(n).toInt();
+       if(val < 64) val = 64;
+       video_bitrate = val;
+}
+
+void CSP_TabMovieH264::do_set_b_adapt(int n)
+{
+       int val = combo_video_b_adapt->itemData(n).toInt();
+       if(val < 0) val = 0;
+       if(val > 2) val = 2;
+       video_b_adapt = val;
+}
+
+void CSP_TabMovieH264::do_set_subme(int n)
+{
+       int val = combo_video_subme->itemData(n).toInt();
+       if(val < 4) val = 4;
+       if(val > 11) val = 11;
+       video_subme = val;
+}
diff --git a/source/src/qt/gui/tab_movie_h264.h b/source/src/qt/gui/tab_movie_h264.h
new file mode 100644 (file)
index 0000000..7ea96fc
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Common Source Project/ Qt
+ * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ *  Qt: Menu->Emulator->Define Strings
+ *  History: Feb 23, 2016 : Initial
+ */
+
+#ifndef _CSP_QT_TAB_MOVIE_H264_H
+#define _CSP_QT_TAB_MOVIE_H264_H
+
+#include <QString>
+#include <QStringList>
+#include <QSize>
+#include <QWidget>
+#include "common.h"
+
+class QHBoxLayout;
+class QVBoxLayout;
+class QGridLayout;
+class QLabel;
+class QComboBox;
+class QPushButton;
+class QSlider;
+
+class MOVIE_SAVER;
+class CSP_DialogMovie;
+
+class DLL_PREFIX CSP_TabMovieH264: public QWidget {
+       Q_OBJECT;
+private:
+       
+       QLabel *label_title;
+       QGridLayout *grid_layout;
+
+       QLabel *label_video_bitrate;
+       QComboBox *combo_video_bitrate;
+       
+       QLabel *label_video_bframes;
+       QComboBox *combo_video_bframes;
+       
+       QLabel *label_video_b_adapt;
+       QComboBox *combo_video_b_adapt;
+       
+       QLabel *label_video_subme;
+       QComboBox *combo_video_subme;
+       
+       QSlider *slider_qmin, *slider_qmax;
+       QLabel *label_audio_bitrate;
+
+       QLabel *label_qmin_val;
+       QLabel *label_qmax_val;
+       QLabel *label_qmin_name;
+       QLabel *label_qmax_name;
+       QComboBox *combo_audio_bitrate;
+
+       QLabel *label_video_fps;
+       QComboBox *combo_video_fps;
+
+       QPushButton *cancel_button;
+       QPushButton *close_button;
+
+protected:
+       QWidget *p_wid;
+       MOVIE_SAVER *p_movie;
+       CSP_DialogMovie *p_window;
+       
+       int video_bitrate;
+       int video_bframes;
+       int video_b_adapt;
+       int video_subme;
+       int video_minq;
+       int video_maxq;
+public:
+       CSP_TabMovieH264(MOVIE_SAVER *ms, CSP_DialogMovie *parent_window, QWidget *parent = NULL);
+       ~CSP_TabMovieH264();
+       void do_set_codecs(void);
+public slots:
+       void do_set_video_bitrate(int);
+       void do_set_qmin(int n);
+       void do_set_qmax(int n);
+
+       void do_set_bframes(int);
+       void do_set_b_adapt(int);
+       void do_set_subme(int);
+signals:
+       int sig_set_video_bitrate(int);
+       int sig_video_add_option(QString, QString);
+
+};
+
+#endif
diff --git a/source/src/qt/gui/tab_movie_mpeg4.cpp b/source/src/qt/gui/tab_movie_mpeg4.cpp
new file mode 100644 (file)
index 0000000..5fa18f7
--- /dev/null
@@ -0,0 +1,186 @@
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QWidget>
+#include <QPushButton>
+#include <QSlider>
+#include <QComboBox>
+#include <QLabel>
+#include <QApplication>
+
+#include "tab_movie_mpeg4.h"
+#include "dialog_movie.h"
+#include "../avio/movie_saver.h"
+#include "../../config.h"
+
+CSP_TabMovieMPEG4::CSP_TabMovieMPEG4(MOVIE_SAVER *ms, CSP_DialogMovie *parent_window, QWidget *parent) : QWidget(parent)
+{
+       QString tmps;
+       
+       p_wid = parent;
+       p_movie = ms;
+       p_window = parent_window;
+
+       video_maxq = config.video_mpeg4_maxq;
+       video_minq = config.video_mpeg4_minq;
+       if(video_maxq < video_minq) {
+               int n = video_maxq;
+               video_maxq = video_minq;
+               video_minq = n;
+       }
+       if(video_maxq < 1) video_maxq = 1;
+       if(video_maxq > 31) video_maxq = 31;
+       if(video_minq < 1) video_minq = 1;
+       if(video_minq > 31) video_minq = 31;
+
+       label_video_bframes = new QLabel(QApplication::translate("MainWindow", "Max B Frames", 0), this);
+       combo_video_bframes = new QComboBox(this);
+       // Video bitrates
+       label_video_bitrate = new QLabel(QApplication::translate("MainWindow", "Bitrate", 0), this);
+       combo_video_bitrate = new QComboBox(this);
+       combo_video_bitrate->addItem(QString::fromUtf8("128Kbps"), 128);        
+       combo_video_bitrate->addItem(QString::fromUtf8("256Kbps"), 256);
+       combo_video_bitrate->addItem(QString::fromUtf8("300Kbps"), 300);
+       combo_video_bitrate->addItem(QString::fromUtf8("512Kbps"), 512);
+       combo_video_bitrate->addItem(QString::fromUtf8("600Kbps"), 600);
+       combo_video_bitrate->addItem(QString::fromUtf8("768Kbps"), 768);
+       combo_video_bitrate->addItem(QString::fromUtf8("900Kbps"), 900);
+       combo_video_bitrate->addItem(QString::fromUtf8("1000Kbps"), 1000);
+       combo_video_bitrate->addItem(QString::fromUtf8("1200Kbps"), 1200);
+       combo_video_bitrate->addItem(QString::fromUtf8("1500Kbps"), 1500);
+       combo_video_bitrate->addItem(QString::fromUtf8("1800Kbps"), 1800);
+       combo_video_bitrate->addItem(QString::fromUtf8("3000Kbps"), 3000);
+       combo_video_bitrate->addItem(QString::fromUtf8("4500Kbps"), 4500);
+       combo_video_bitrate->addItem(QString::fromUtf8("5000Kbps"), 5000);
+       combo_video_bitrate->addItem(QString::fromUtf8("7500Kbps"), 7500);
+       combo_video_bitrate->addItem(QString::fromUtf8("9000Kbps"), 9000);
+       combo_video_bitrate->addItem(QString::fromUtf8("10000Kbps"), 10000);
+       combo_video_bitrate->addItem(QString::fromUtf8("15000Kbps"), 15000);
+       combo_video_bitrate->addItem(QString::fromUtf8("20000Kbps"), 20000);
+       for(int i = 0; i < combo_video_bitrate->count(); i++) {
+               int br = combo_video_bitrate->itemData(i).toInt();
+               if(br == config.video_mpeg4_bitrate) {
+                       combo_video_bitrate->setCurrentIndex(i);
+               }
+       }
+       connect(combo_video_bitrate, SIGNAL(activated(int)), this, SLOT(do_set_video_bitrate(int)));
+       video_bitrate = config.video_mpeg4_bitrate;
+
+       // Video bframes
+       combo_video_bframes->addItem(QString::fromUtf8("1"), 1);
+       combo_video_bframes->addItem(QString::fromUtf8("2"), 2);
+       combo_video_bframes->addItem(QString::fromUtf8("3"), 3);
+       combo_video_bframes->addItem(QString::fromUtf8("4"), 4);
+       combo_video_bframes->addItem(QString::fromUtf8("5"), 5);
+       combo_video_bframes->addItem(QString::fromUtf8("6"), 6);
+       combo_video_bframes->addItem(QString::fromUtf8("7"), 7);
+       combo_video_bframes->addItem(QString::fromUtf8("8"), 8);
+       for(int i = 0; i < combo_video_bframes->count(); i++) {
+               int br = combo_video_bframes->itemData(i).toInt();
+               if(br == config.video_mpeg4_bframes) {
+                       combo_video_bframes->setCurrentIndex(i);
+               }
+       }
+       video_bframes = config.video_mpeg4_bframes;
+       connect(combo_video_bframes, SIGNAL(activated(int)), this, SLOT(do_set_bframes(int)));
+
+
+       slider_qmin = new QSlider(Qt::Horizontal, this);
+       slider_qmin->setMinimum(1);
+       slider_qmin->setMaximum(31);
+       slider_qmin->setValue(config.video_mpeg4_minq);
+       label_qmin_val = new QLabel(this);
+       tmps.setNum(config.video_mpeg4_minq);
+       label_qmin_val->setText(tmps);
+       label_qmin_name = new QLabel(QString::fromUtf8("QP Min"), this);
+       video_minq = config.video_mpeg4_minq;
+       connect(slider_qmin, SIGNAL(valueChanged(int)), this, SLOT(do_set_qmin(int)));
+               
+       slider_qmax = new QSlider(Qt::Horizontal, this);
+       slider_qmax->setMinimum(1);
+       slider_qmax->setMaximum(31);
+       slider_qmax->setValue(config.video_mpeg4_maxq);
+       label_qmax_val = new QLabel(this);
+       tmps.setNum(config.video_mpeg4_maxq);
+       label_qmax_val->setText(tmps);
+       label_qmax_name = new QLabel(QString::fromUtf8("QP Max"), this);
+       connect(slider_qmax, SIGNAL(valueChanged(int)), this, SLOT(do_set_qmax(int)));
+       video_maxq = config.video_mpeg4_maxq;
+       
+       label_title = new QLabel(QApplication::translate("MainWindow", "Set MPEG4v1 parameter.", 0), this);
+       grid_layout = new QGridLayout(this);
+
+       grid_layout->addWidget(label_title, 0, 0);
+       
+       grid_layout->addWidget(label_qmin_name, 1, 0);
+       grid_layout->addWidget(label_qmin_val, 1, 3);
+       grid_layout->addWidget(slider_qmin, 2, 0, 1, 4);
+       grid_layout->addWidget(label_qmax_name, 3, 0);
+       grid_layout->addWidget(label_qmax_val, 3, 3);
+       grid_layout->addWidget(slider_qmax, 4, 0, 1, 4);
+       grid_layout->addWidget(label_video_bitrate, 5, 0);
+       grid_layout->addWidget(combo_video_bitrate, 5, 1);
+       
+       grid_layout->addWidget(label_video_bframes, 5, 2);
+       grid_layout->addWidget(combo_video_bframes, 5, 3);
+       
+       this->setLayout(grid_layout);
+
+       connect(this, SIGNAL(sig_video_add_option(QString, QString)), p_movie, SLOT(do_add_option(QString, QString)));
+       connect(this, SIGNAL(sig_set_video_bitrate(int)), p_movie, SLOT(do_set_video_bitrate(int)));
+       this->show();
+}
+
+
+CSP_TabMovieMPEG4::~CSP_TabMovieMPEG4()
+{
+}
+
+void CSP_TabMovieMPEG4::do_set_codecs(void)
+{
+       QString value;
+       // See:
+       // https://libav.org/avconv.html#Video-Options
+       config.video_mpeg4_bitrate = video_bitrate;
+
+       config.video_mpeg4_maxq = video_maxq;
+       config.video_mpeg4_minq = video_minq;
+       config.video_mpeg4_bframes = video_bframes;
+}
+
+void CSP_TabMovieMPEG4::do_set_qmin(int n)
+{
+       if(n < 1) n = 1;
+       if(n > 31) n = 31;
+       QString tmps;
+       video_minq = n;
+       tmps.setNum(n);
+       label_qmin_val->setText(tmps);
+}
+
+void CSP_TabMovieMPEG4::do_set_qmax(int n)
+{
+       if(n < 1) n = 1;
+       if(n > 31) n = 31;
+       
+       QString tmps;
+       video_maxq = n;
+       tmps.setNum(n);
+       label_qmax_val->setText(tmps);
+}
+
+void CSP_TabMovieMPEG4::do_set_bframes(int n)
+{
+       int val = combo_video_bframes->itemData(n).toInt();
+       if(val < 1) val = 1;
+       if(val > 10) val = 10;
+       video_bframes = val;
+}
+
+void CSP_TabMovieMPEG4::do_set_video_bitrate(int n)
+{
+       int val = combo_video_bitrate->itemData(n).toInt();
+       if(val < 64) val = 64;
+       video_bitrate = val;
+}
+
diff --git a/source/src/qt/gui/tab_movie_mpeg4.h b/source/src/qt/gui/tab_movie_mpeg4.h
new file mode 100644 (file)
index 0000000..fa4dc4d
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Common Source Project/ Qt
+ * (C) 2015 K.Ohta <whatisthis.sowhat _at_ gmail.com>
+ *  Qt: Menu->Emulator->Define Strings
+ *  History: Feb 23, 2016 : Initial
+ */
+
+#ifndef _CSP_QT_TAB_MOVIE_MPEG4_H
+#define _CSP_QT_TAB_MOVIE_MPEG4_H
+
+#include <QString>
+#include <QStringList>
+#include <QSize>
+#include <QWidget>
+#include "common.h"
+
+class QHBoxLayout;
+class QVBoxLayout;
+class QGridLayout;
+class QLabel;
+class QComboBox;
+class QPushButton;
+class QSlider;
+
+class MOVIE_SAVER;
+class CSP_DialogMovie;
+
+class DLL_PREFIX CSP_TabMovieMPEG4: public QWidget {
+       Q_OBJECT;
+private:
+       
+       QLabel *label_title;
+       QGridLayout *grid_layout;
+
+       QLabel *label_video_bitrate;
+       QComboBox *combo_video_bitrate;
+       
+       QLabel *label_video_bframes;
+       QComboBox *combo_video_bframes;
+       
+       QSlider *slider_qmin, *slider_qmax;
+
+       QLabel *label_qmin_val;
+       QLabel *label_qmax_val;
+       QLabel *label_qmin_name;
+       QLabel *label_qmax_name;
+protected:
+       QWidget *p_wid;
+       MOVIE_SAVER *p_movie;
+       CSP_DialogMovie *p_window;
+       
+       int video_bitrate;
+       int video_bframes;
+       int video_minq;
+       int video_maxq;
+public:
+       CSP_TabMovieMPEG4(MOVIE_SAVER *ms, CSP_DialogMovie *parent_window, QWidget *parent = NULL);
+       ~CSP_TabMovieMPEG4();
+       void do_set_codecs(void);
+public slots:
+       void do_set_video_bitrate(int);
+       void do_set_qmin(int n);
+       void do_set_qmax(int n);
+
+       void do_set_bframes(int);
+signals:
+       int sig_set_video_bitrate(int);
+       int sig_video_add_option(QString, QString);
+
+};
+
+#endif