Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
8e86c76d
Commit
8e86c76d
authored
Nov 29, 2014
by
Ilkka Ollakka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fps: new video filter to convert between fps rates
parent
e8d253fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
0 deletions
+176
-0
modules/MODULES_LIST
modules/MODULES_LIST
+1
-0
modules/video_filter/Modules.am
modules/video_filter/Modules.am
+2
-0
modules/video_filter/fps.c
modules/video_filter/fps.c
+173
-0
No files found.
modules/MODULES_LIST
View file @
8e86c76d
...
...
@@ -134,6 +134,7 @@ $Id$
* float_mixer: Precise float audio mixer
* fluidsynth: Software MIDI synthetizer using libfluidsynth
* folder: folder meta data and art finder
* fps: convert picture rate
* freetype: Utility to put text on video using freetype2
* freeze: picture freezing video filter
* ftp: FTP Network access module
...
...
modules/video_filter/Modules.am
View file @
8e86c76d
...
...
@@ -10,6 +10,7 @@ SOURCES_blend = blend.cpp
SOURCES_scale = scale.c
SOURCES_marq = marq.c
SOURCES_rss = rss.c
SOURCES_fps = fps.c
SOURCES_motiondetect = motiondetect.c
libdeinterlace_plugin_la_SOURCES = \
...
...
@@ -163,5 +164,6 @@ video_filter_LTLIBRARIES += \
libanaglyph_plugin.la \
liboldmovie_plugin.la \
libvhs_plugin.la \
libfps_plugin.la \
libfreeze_plugin.la
modules/video_filter/fps.c
0 → 100644
View file @
8e86c76d
/*****************************************************************************
* fps.c : fps conversion plugin for vlc
*****************************************************************************
* Copyright (C) 2014 VLC authors and VideoLAN
*
* Author: Ilkka Ollakka <ileoo at videolan dot org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
int
Open
(
vlc_object_t
*
p_this
);
void
Close
(
vlc_object_t
*
p_this
);
picture_t
*
Filter
(
filter_t
*
p_filter
,
picture_t
*
p_picture
);
#define CFG_PREFIX "fps-"
vlc_module_begin
()
set_description
(
N_
(
"FPS conversion video filter"
)
)
set_shortname
(
N_
(
"FPS Converter"
))
set_capability
(
"video filter2"
,
0
)
set_category
(
CAT_VIDEO
)
set_subcategory
(
SUBCAT_VIDEO_VFILTER
)
add_shortcut
(
"fps"
)
add_string
(
CFG_PREFIX
"fps"
,
NULL
,
NULL
,
NULL
,
false
)
set_callbacks
(
Open
,
Close
)
vlc_module_end
()
static
const
char
*
const
ppsz_filter_options
[]
=
{
"fps"
,
NULL
};
/* We'll store pointer for previous picture we have received
and copy that if needed on framerate increase (not preferred)*/
struct
filter_sys_t
{
date_t
next_output_pts
;
/**< output calculated PTS */
picture_t
*
p_previous_pic
;
int
i_output_frame_interval
;
};
picture_t
*
Filter
(
filter_t
*
p_filter
,
picture_t
*
p_picture
)
{
filter_sys_t
*
p_sys
=
p_filter
->
p_sys
;
/* If input picture doesn't have actual valid timestamp,
we don't really have currently a way to know what else
to do with it other than drop it for now*/
if
(
unlikely
(
p_picture
->
date
<
VLC_TS_0
)
)
{
msg_Dbg
(
p_filter
,
"skipping non-dated picture"
);
picture_Release
(
p_picture
);
return
NULL
;
}
/* First time we get some valid timestamp, we'll take it as base for output*/
if
(
unlikely
(
date_Get
(
&
p_sys
->
next_output_pts
)
==
VLC_TS_INVALID
)
)
{
msg_Dbg
(
p_filter
,
"Resetting timestamps"
);
date_Set
(
&
p_sys
->
next_output_pts
,
p_picture
->
date
);
p_sys
->
p_previous_pic
=
picture_Hold
(
p_picture
);
date_Increment
(
&
p_sys
->
next_output_pts
,
p_filter
->
fmt_out
.
video
.
i_frame_rate_base
);
return
p_picture
;
}
/* Check if we can skip input as better should follow */
if
(
p_picture
->
date
<
(
date_Get
(
&
p_sys
->
next_output_pts
)
-
(
mtime_t
)
p_sys
->
i_output_frame_interval
)
)
{
if
(
p_sys
->
p_previous_pic
)
picture_Release
(
p_sys
->
p_previous_pic
);
p_sys
->
p_previous_pic
=
p_picture
;
return
NULL
;
}
p_sys
->
p_previous_pic
->
date
=
date_Get
(
&
p_sys
->
next_output_pts
);
date_Increment
(
&
p_sys
->
next_output_pts
,
p_filter
->
fmt_out
.
video
.
i_frame_rate_base
);
picture_t
*
last_pic
=
p_sys
->
p_previous_pic
;
/* Duplicating pictures are not that effective and framerate increase
should be avoided, it's only here as filter should work in that direction too*/
while
(
unlikely
(
(
date_Get
(
&
p_sys
->
next_output_pts
)
+
p_sys
->
i_output_frame_interval
)
<
p_picture
->
date
)
)
{
picture_t
*
p_tmp
=
NULL
;
p_tmp
=
picture_NewFromFormat
(
&
p_filter
->
fmt_in
.
video
);
picture_Copy
(
p_tmp
,
p_sys
->
p_previous_pic
);
p_tmp
->
date
=
date_Get
(
&
p_sys
->
next_output_pts
);
p_tmp
->
p_next
=
NULL
;
last_pic
->
p_next
=
p_tmp
;
last_pic
=
p_tmp
;
date_Increment
(
&
p_sys
->
next_output_pts
,
p_filter
->
fmt_out
.
video
.
i_frame_rate_base
);
}
last_pic
=
p_sys
->
p_previous_pic
;
p_sys
->
p_previous_pic
=
p_picture
;
return
last_pic
;
}
int
Open
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
filter_sys_t
*
p_sys
;
p_sys
=
p_filter
->
p_sys
=
malloc
(
sizeof
(
*
p_sys
)
);
if
(
unlikely
(
!
p_sys
)
)
return
VLC_ENOMEM
;
unsigned
frame_rate
=
p_filter
->
fmt_out
.
video
.
i_frame_rate
,
frame_rate_base
=
p_filter
->
fmt_out
.
video
.
i_frame_rate_base
;
config_ChainParse
(
p_filter
,
CFG_PREFIX
,
ppsz_filter_options
,
p_filter
->
p_cfg
);
/* If we don't have fps option, use filter output values */
if
(
var_InheritURational
(
p_filter
,
&
frame_rate
,
&
frame_rate_base
,
CFG_PREFIX
"fps"
)
)
{
frame_rate
=
p_filter
->
fmt_out
.
video
.
i_frame_rate
;
frame_rate_base
=
p_filter
->
fmt_out
.
video
.
i_frame_rate_base
;
}
memcpy
(
&
p_filter
->
fmt_out
.
video
,
&
p_filter
->
fmt_in
.
video
,
sizeof
(
video_format_t
));
p_filter
->
fmt_out
.
video
.
i_frame_rate
=
frame_rate
;
p_filter
->
fmt_out
.
video
.
i_frame_rate_base
=
frame_rate_base
;
msg_Dbg
(
p_filter
,
"Converting fps from %d/%d -> %d/%d"
,
p_filter
->
fmt_in
.
video
.
i_frame_rate
,
p_filter
->
fmt_in
.
video
.
i_frame_rate_base
,
p_filter
->
fmt_out
.
video
.
i_frame_rate
,
p_filter
->
fmt_out
.
video
.
i_frame_rate_base
);
p_sys
->
i_output_frame_interval
=
p_filter
->
fmt_out
.
video
.
i_frame_rate_base
*
CLOCK_FREQ
/
p_filter
->
fmt_out
.
video
.
i_frame_rate
;
date_Init
(
&
p_sys
->
next_output_pts
,
p_filter
->
fmt_out
.
video
.
i_frame_rate
,
1
);
date_Set
(
&
p_sys
->
next_output_pts
,
VLC_TS_INVALID
);
p_filter
->
pf_video_filter
=
Filter
;
return
VLC_SUCCESS
;
}
void
Close
(
vlc_object_t
*
p_this
)
{
filter_t
*
p_filter
=
(
filter_t
*
)
p_this
;
if
(
p_filter
->
p_sys
->
p_previous_pic
)
picture_Release
(
p_filter
->
p_sys
->
p_previous_pic
);
free
(
p_filter
->
p_sys
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment