[MOVIE_SAVER] Fix deadlock when closing movie.
#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;
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;
#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);
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
)
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()
#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()
}
}
_next_turn:
+ //printf("%d\n", req_close);
old_recording = recording;
if(!bRunThread) break;
if(need_video_transcode || need_audio_transcode) {
tmp_wait = fps_wait;
}
old_recording = recording;
+ if(req_close) {
+ do_close_main();
+ }
continue;
_final:
old_recording = recording;
//#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;
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;
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);
#include "../osd.h"
#include "agar_logger.h"
+#if defined(USE_LIBAV)
extern "C" {
#include <libavutil/avassert.h>
#include <libavutil/channel_layout.h>
#include <libswscale/swscale.h>
#include <libswresample/swresample.h>
}
-
+#endif
/**************************************************************/
/* audio output */
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;
}
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;
}
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
//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;
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);
ost->next_pts += frame->nb_samples;
return frame;
+#else
+ return (void *)NULL;
+#endif
}
/*
//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;
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 */
//}
}
return (frame_dst || got_packet) ? 0 : 1;
+#else
+ return 1;
+#endif
}
#include <stdio.h>
#include <string.h>
#include <math.h>
+#if defined(USE_LIBAV)
extern "C" {
#include <libavutil/avassert.h>
#include <libavutil/channel_layout.h>
#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;
/* 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. */
void **_codec,
uint64_t _codec_id)
{
+#if defined(USE_LIBAV)
AVCodecContext *c;
int i;
/* 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,
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.
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;
if (oc->oformat->flags & AVFMT_GLOBALHEADER)
c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
return true;
+#else
+ return false;
+#endif
}
//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);
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);
//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;
}
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
output_context = NULL;
stream_format = NULL;
return false;
+#else
+ return true;
+#endif
}
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;
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));
#include <stdio.h>
#include <string.h>
#include <math.h>
+
+#if defined(USE_LIBAV)
extern "C" {
#include <libavutil/avassert.h>
#include <libavutil/channel_layout.h>
#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;
}
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;
* 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);
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
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;
}
ost->frame->pts = ost->next_pts++;
return (void *)(ost->frame);
+#else
+ return (void *)NULL;
+#endif
}
/*
//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;
// AGAR_DebugLog(AGAR_LOG_DEBUG, "Movie: Write video to file. sec=%s", s);
//}
return (frame || got_packet) ? 0 : 1;
+#else
+ return 1;
+#endif
}
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)));
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
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
)
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()
#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
-#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"
{
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()));
{
}
-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();
}
+
* 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
#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
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();
}
--- /dev/null
+
+
+#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;
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+#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;
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+#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;
+}
+
--- /dev/null
+/*
+ * 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