9 #include <QApplication>
11 #include "tab_movie_h264.h"
12 #include "dialog_movie.h"
13 #include "../avio/movie_saver.h"
14 #include "../../config.h"
15 #include "menu_flags.h"
17 CSP_TabMovieH264::CSP_TabMovieH264(MOVIE_SAVER *ms, CSP_DialogMovie *parent_window, USING_FLAGS *p, QWidget *parent) : QWidget(parent)
23 p_window = parent_window;
25 video_maxq = using_flags->get_config_ptr()->video_h264_maxq;
26 video_minq = using_flags->get_config_ptr()->video_h264_minq;
28 label_video_bframes = new QLabel(QApplication::translate("MainWindow", "Max B Frames", 0), this);
29 combo_video_bframes = new QComboBox(this);
30 label_video_b_adapt = new QLabel(QApplication::translate("MainWindow", "B Adaption", 0), this);
31 combo_video_b_adapt = new QComboBox(this);
32 label_video_subme = new QLabel(QApplication::translate("MainWindow", "Subpixel motion estimate", 0), this);
33 combo_video_subme = new QComboBox(this);
36 label_video_bitrate = new QLabel(QApplication::translate("MainWindow", "Bitrate", 0), this);
37 combo_video_bitrate = new QComboBox(this);
38 combo_video_bitrate->addItem(QString::fromUtf8("128Kbps"), 128);
39 combo_video_bitrate->addItem(QString::fromUtf8("256Kbps"), 256);
40 combo_video_bitrate->addItem(QString::fromUtf8("300Kbps"), 300);
41 combo_video_bitrate->addItem(QString::fromUtf8("512Kbps"), 512);
42 combo_video_bitrate->addItem(QString::fromUtf8("600Kbps"), 600);
43 combo_video_bitrate->addItem(QString::fromUtf8("768Kbps"), 768);
44 combo_video_bitrate->addItem(QString::fromUtf8("900Kbps"), 900);
45 combo_video_bitrate->addItem(QString::fromUtf8("1000Kbps"), 1000);
46 combo_video_bitrate->addItem(QString::fromUtf8("1200Kbps"), 1200);
47 combo_video_bitrate->addItem(QString::fromUtf8("1500Kbps"), 1500);
48 combo_video_bitrate->addItem(QString::fromUtf8("1800Kbps"), 1800);
49 combo_video_bitrate->addItem(QString::fromUtf8("3000Kbps"), 3000);
50 combo_video_bitrate->addItem(QString::fromUtf8("4500Kbps"), 4500);
51 for(int i = 0; i < combo_video_bitrate->count(); i++) {
52 int br = combo_video_bitrate->itemData(i).toInt();
53 if(br == using_flags->get_config_ptr()->video_h264_bitrate) {
54 combo_video_bitrate->setCurrentIndex(i);
57 connect(combo_video_bitrate, SIGNAL(activated(int)), this, SLOT(do_set_video_bitrate(int)));
58 video_bitrate = using_flags->get_config_ptr()->video_h264_bitrate;
61 combo_video_bframes->addItem(QString::fromUtf8("0"), 0);
62 combo_video_bframes->addItem(QString::fromUtf8("1"), 1);
63 combo_video_bframes->addItem(QString::fromUtf8("2"), 2);
64 combo_video_bframes->addItem(QString::fromUtf8("3"), 3);
65 combo_video_bframes->addItem(QString::fromUtf8("4"), 4);
66 combo_video_bframes->addItem(QString::fromUtf8("5"), 5);
67 combo_video_bframes->addItem(QString::fromUtf8("6"), 6);
68 combo_video_bframes->addItem(QString::fromUtf8("7"), 7);
69 combo_video_bframes->addItem(QString::fromUtf8("8"), 8);
70 for(int i = 0; i < combo_video_bframes->count(); i++) {
71 int br = combo_video_bframes->itemData(i).toInt();
72 if(br == using_flags->get_config_ptr()->video_h264_bframes) {
73 combo_video_bframes->setCurrentIndex(i);
76 video_bframes = using_flags->get_config_ptr()->video_h264_bframes;
77 connect(combo_video_bframes, SIGNAL(activated(int)), this, SLOT(do_set_bframes(int)));
80 combo_video_b_adapt->addItem(QApplication::translate("MainWindow", "None", 0), 0);
81 combo_video_b_adapt->addItem(QApplication::translate("MainWindow", "Fast", 0), 1);
82 combo_video_b_adapt->addItem(QApplication::translate("MainWindow", "Optimal (Slow with high B-Frames)", 0), 2);
83 for(int i = 0; i < combo_video_b_adapt->count(); i++) {
84 int br = combo_video_b_adapt->itemData(i).toInt();
85 if(br == using_flags->get_config_ptr()->video_h264_b_adapt) {
86 combo_video_b_adapt->setCurrentIndex(i);
89 video_b_adapt = using_flags->get_config_ptr()->video_h264_b_adapt;
90 connect(combo_video_b_adapt, SIGNAL(activated(int)), this, SLOT(do_set_b_adapt(int)));
92 slider_qmin = new QSlider(Qt::Horizontal, this);
93 slider_qmin->setMinimum(0);
94 slider_qmin->setMaximum(63);
95 slider_qmin->setValue(using_flags->get_config_ptr()->video_h264_minq);
96 label_qmin_val = new QLabel(this);
97 tmps.setNum(using_flags->get_config_ptr()->video_h264_minq);
98 label_qmin_val->setText(tmps);
99 label_qmin_name = new QLabel(QString::fromUtf8("QP Min"), this);
100 video_minq = using_flags->get_config_ptr()->video_h264_minq;
101 connect(slider_qmin, SIGNAL(valueChanged(int)), this, SLOT(do_set_qmin(int)));
103 slider_qmax = new QSlider(Qt::Horizontal, this);
104 slider_qmax->setMinimum(0);
105 slider_qmax->setMaximum(63);
106 slider_qmax->setValue(using_flags->get_config_ptr()->video_h264_maxq);
107 label_qmax_val = new QLabel(this);
108 tmps.setNum(using_flags->get_config_ptr()->video_h264_maxq);
109 label_qmax_val->setText(tmps);
110 label_qmax_name = new QLabel(QString::fromUtf8("QP Max"), this);
111 connect(slider_qmax, SIGNAL(valueChanged(int)), this, SLOT(do_set_qmax(int)));
112 video_maxq = using_flags->get_config_ptr()->video_h264_maxq;
115 combo_video_subme->addItem(QApplication::translate("MainWindow", "RD mode decision for I/P-frames", 0), 6);
116 combo_video_subme->addItem(QApplication::translate("MainWindow", "RD mode decision for all frames", 0), 7);
117 combo_video_subme->addItem(QApplication::translate("MainWindow", "RD refinement for I/P-frames", 0), 8);
118 combo_video_subme->addItem(QApplication::translate("MainWindow", "RD refinement for all frames", 0), 9);
119 combo_video_subme->addItem(QApplication::translate("MainWindow", "QP-RD", 0), 10); // Trellis 2, admode > 0
120 combo_video_subme->addItem(QApplication::translate("MainWindow", "Full RD: disable all early terminations", 0), 11);
121 for(int i = 0; i < combo_video_subme->count(); i++) {
122 int br = combo_video_subme->itemData(i).toInt();
123 if(br == using_flags->get_config_ptr()->video_h264_subme) {
124 combo_video_subme->setCurrentIndex(i);
127 video_subme = using_flags->get_config_ptr()->video_h264_subme;
128 connect(combo_video_subme, SIGNAL(activated(int)), this, SLOT(do_set_subme(int)));
130 label_title = new QLabel(QApplication::translate("MainWindow", "Set H.264 parameter.", 0), this);
131 grid_layout = new QGridLayout(this);
133 grid_layout->addWidget(label_title, 0, 0);
135 grid_layout->addWidget(label_qmin_name, 1, 0);
136 grid_layout->addWidget(label_qmin_val, 1, 3);
137 grid_layout->addWidget(slider_qmin, 2, 0, 1, 4);
138 grid_layout->addWidget(label_qmax_name, 3, 0);
139 grid_layout->addWidget(label_qmax_val, 3, 3);
140 grid_layout->addWidget(slider_qmax, 4, 0, 1, 4);
141 grid_layout->addWidget(label_video_bitrate, 5, 0);
142 grid_layout->addWidget(combo_video_bitrate, 5, 1);
145 grid_layout->addWidget(label_video_bframes, 6, 0);
146 grid_layout->addWidget(combo_video_bframes, 6, 1);
148 grid_layout->addWidget(label_video_b_adapt, 6, 2);
149 grid_layout->addWidget(combo_video_b_adapt, 6, 3);
151 grid_layout->addWidget(label_video_subme, 7, 0);
152 grid_layout->addWidget(combo_video_subme, 7, 1);
154 this->setLayout(grid_layout);
156 connect(this, SIGNAL(sig_video_add_option(QString, QString)), p_movie, SLOT(do_add_option(QString, QString)));
157 connect(this, SIGNAL(sig_set_video_bitrate(int)), p_movie, SLOT(do_set_video_bitrate(int)));
162 CSP_TabMovieH264::~CSP_TabMovieH264()
166 void CSP_TabMovieH264::do_set_codecs(void)
170 // https://libav.org/avconv.html#Video-Options
171 using_flags->get_config_ptr()->video_h264_bitrate = video_bitrate;
173 using_flags->get_config_ptr()->video_h264_maxq = video_maxq;
174 using_flags->get_config_ptr()->video_h264_minq = video_minq;
175 using_flags->get_config_ptr()->video_h264_bframes = video_bframes;
176 using_flags->get_config_ptr()->video_h264_b_adapt = video_b_adapt;
177 using_flags->get_config_ptr()->video_h264_subme = video_subme;
180 void CSP_TabMovieH264::do_set_qmin(int n)
187 label_qmin_val->setText(tmps);
190 void CSP_TabMovieH264::do_set_qmax(int n)
198 label_qmax_val->setText(tmps);
201 void CSP_TabMovieH264::do_set_bframes(int n)
203 int val = combo_video_bframes->itemData(n).toInt();
205 if(val > 10) val = 10;
209 void CSP_TabMovieH264::do_set_video_bitrate(int n)
211 int val = combo_video_bitrate->itemData(n).toInt();
212 if(val < 64) val = 64;
216 void CSP_TabMovieH264::do_set_b_adapt(int n)
218 int val = combo_video_b_adapt->itemData(n).toInt();
224 void CSP_TabMovieH264::do_set_subme(int n)
226 int val = combo_video_subme->itemData(n).toInt();
228 if(val > 11) val = 11;