summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfred <fred@home.lan>2011-04-06 14:45:54 (GMT)
committer fred <fred@home.lan>2011-04-06 14:45:54 (GMT)
commit1135374cf905d03f84471681ccc96fd8259e2197 (patch)
tree003e058191f0e04e6fa9322b57dc272c5296948b
parente245e045935bb6a81f6393085d5b70c0a4c86106 (diff)
try to manage videos which frame rate is not an integer.
- In QqWidget::QqWidget, modified the FPS to be changed in percentage. changed actualFps and normalFps to be taken as a float. - In FPS:: , modified to use float instead of int. - In oggmux_add_audio, limit the ratio to +- 10% resampling, which is a lot ..... just in case of big drift.
-rw-r--r--qt/QqWidget.cpp12
-rw-r--r--qt/QqWidget.h5
-rw-r--r--src/fps.cpp8
-rw-r--r--src/include/fps.h6
-rw-r--r--src/include/layer.h2
-rw-r--r--src/include/video_layer.h2
-rw-r--r--src/theorautils.cpp5
-rw-r--r--src/video_layer.cpp4
8 files changed, 25 insertions, 19 deletions
diff --git a/qt/QqWidget.cpp b/qt/QqWidget.cpp
index cc3a8bc..3767771 100644
--- a/qt/QqWidget.cpp
+++ b/qt/QqWidget.cpp
@@ -43,7 +43,7 @@ QqWidget::QqWidget(Context *freej, QqTabWidget* tabWidget, Qfreej* qfreej, QStri
fakeView = NULL;
fakeLay = NULL;
ctx = NULL;
- actualFps = normalFps = 0;
+ actualFps = normalFps = fpsP = 0;
qLayer = freej->open((char*)fichier.toStdString().c_str(), 0, 0); // hey, this already init and open the layer !!
if(qLayer)
{
@@ -63,6 +63,7 @@ QqWidget::QqWidget(Context *freej, QqTabWidget* tabWidget, Qfreej* qfreej, QStri
qLayer->fps.set(qLayer->frame_rate);
normalFps = qLayer->frame_rate;
actualFps = qLayer->frame_rate;
+ fpsP = 100;
qDebug() << "--- actualFps :" << actualFps;
// }
tabWidget->addTab(this, qLayer->get_filename());
@@ -119,9 +120,9 @@ QqWidget::QqWidget(Context *freej, QqTabWidget* tabWidget, Qfreej* qfreej, QStri
slowFps = new QSlider(this);
slowFps->setOrientation(Qt::Vertical);
connect(slowFps, SIGNAL(sliderMoved(int)), this, SLOT(changeFps(int)));
- slowFps->setRange(1, (normalFps*2));
+ slowFps->setRange(2, 100);
slowFps->setToolTip("speed control (grey: normal speed, red: higher or lower)");
- slowFps->setValue(normalFps);
+ slowFps->setValue(50);
slowFps->setSliderDown(true);
slowFps->setStyleSheet("background: grey");
layoutH->addWidget(slowFps);
@@ -537,9 +538,10 @@ void QqWidget::changeFps(int val)
{
if (qLayer)
{
- if (val != actualFps)
+ if (val != 50)
{
- qLayer->fps.set(val);
+ actualFps = ((float)val / 50.0) * normalFps;
+ qLayer->fps.set(actualFps);
slowFps->setStyleSheet("background: red");
}
else
diff --git a/qt/QqWidget.h b/qt/QqWidget.h
index 7ab0b0c..59e5f12 100644
--- a/qt/QqWidget.h
+++ b/qt/QqWidget.h
@@ -57,8 +57,9 @@ private:
QPushButton *textButton;
QPushButton *slowButton;
QSlider *slowFps;
- int normalFps;
- int actualFps;
+ float normalFps;
+ float actualFps;
+ int fpsP;
QPushButton *playButton;
bool isPlaying;
QComboBox *fontSizeBox;
diff --git a/src/fps.cpp b/src/fps.cpp
index bfd2f16..289051b 100644
--- a/src/fps.cpp
+++ b/src/fps.cpp
@@ -58,7 +58,7 @@ FPS::~FPS() {
error("error destroying POSIX thread feed attribute");
}
-void FPS::init(int rate) {
+void FPS::init(float rate) {
this->set(25);
@@ -110,12 +110,12 @@ void FPS::calc() {
}
-int FPS::get() {
+float FPS::get() {
return (_fps ? fpsd.sum / fpsd.n : 0 );
}
-int FPS::set(int rate) {
- func("FPS set to %u",rate);
+float FPS::set(float rate) {
+ func("FPS set to %f",rate);
if (rate < 0) // invalid
return fps_old;
diff --git a/src/include/fps.h b/src/include/fps.h
index ae790cb..1338a91 100644
--- a/src/include/fps.h
+++ b/src/include/fps.h
@@ -29,10 +29,10 @@ class FPS {
FPS();
~FPS();
- void init(int rate);
+ void init(float rate);
- int get();
- int set(int rate);
+ float get();
+ float set(float rate);
void calc();
void delay();
void select_sleep(long usec);
diff --git a/src/include/layer.h b/src/include/layer.h
index 15d30aa..77e0da6 100644
--- a/src/include/layer.h
+++ b/src/include/layer.h
@@ -213,7 +213,7 @@ class Layer: public Entry, public JSyncThread {
unsigned int textureID; ///< opengl texture id
- int frame_rate; ///< value set by implemented layer type
+ float frame_rate; ///< value set by implemented layer type
protected:
diff --git a/src/include/video_layer.h b/src/include/video_layer.h
index 48118f3..37ddea9 100644
--- a/src/include/video_layer.h
+++ b/src/include/video_layer.h
@@ -157,7 +157,7 @@ class VideoLayer: public Layer {
double mark_out;
/** dropping frames variables */
int user_play_speed; /** play speed to be visualized to the user */
- int play_speed; /** real speed */
+ float play_speed; /** real speed */
int play_speed_control;
diff --git a/src/theorautils.cpp b/src/theorautils.cpp
index 9726252..44ab7a7 100644
--- a/src/theorautils.cpp
+++ b/src/theorautils.cpp
@@ -699,12 +699,15 @@ void oggmux_add_audio (oggmux_info *info, float * buffer, int bytes, int samples
vorbis_analysis_wrote (&info->vd, 0);
}
else{ //resample code
- sampleOut = (float *)realloc(sampleOut, ((samples * info->channels * sizeof(float)) + 1000));
+ sampleOut = (float *)realloc(sampleOut, ((samples * info->channels * sizeof(float)) \
+ + (1.2 * ((samples * info->channels * sizeof(float))))));
memset(src_data, 0, sizeof(SRC_DATA));
src_data->data_in = buffer;
src_data->input_frames = (long)samples;
src_data->data_out = sampleOut;
src_data->output_frames = (long)((double)samples * 1.1);
+ if (ratio > 1.1 || ratio < 0.9)
+ ratio = 1.0;
src_data->src_ratio = ratio;
src_data->end_of_input = 0;
if (int processError = src_process (src_state, src_data)) {
diff --git a/src/video_layer.cpp b/src/video_layer.cpp
index cfa0348..ba275ff 100644
--- a/src/video_layer.cpp
+++ b/src/video_layer.cpp
@@ -252,7 +252,7 @@ bool VideoLayer::open(const char *file) {
/* this saves only file without full path! */
set_filename (file);
- act ("%s (codec: %s) has resolution %dx%d and framerate %d",
+ act ("%s (codec: %s) has resolution %dx%d and framerate %f",
get_filename(), video_codec->name,
video_codec_ctx->width, video_codec_ctx->height, frame_rate);
@@ -317,7 +317,7 @@ bool VideoLayer::open(const char *file) {
geo.init(video_codec_ctx->width, video_codec_ctx->height, 32);
func("VideoLayer :: w[%u] h[%u] size[%u]", geo.w, geo.h, geo.bytesize);
- func("VideoLayer :: frame_rate[%d]",frame_rate);
+ func("VideoLayer :: frame_rate[%f]",frame_rate);
// initialize picture
if( new_picture(rgba_picture) < 0) {