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
e5f9d1a3
Commit
e5f9d1a3
authored
Jun 17, 2002
by
Sam Hocevar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* ./plugins/filter/deinterlace.c: backported new deinterlacing routines.
parent
348eea48
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
288 additions
and
125 deletions
+288
-125
ChangeLog
ChangeLog
+3
-0
plugins/filter/deinterlace.c
plugins/filter/deinterlace.c
+285
-125
No files found.
ChangeLog
View file @
e5f9d1a3
...
...
@@ -4,6 +4,9 @@
HEAD
*
./
plugins
/
filter
/
deinterlace
.
c
:
backported
new
deinterlacing
routines
.
*
./
include
/
threads
.
h
,
./
include
/
threads_funcs
.
h
:
backported
the
new
Win32
cond_wait
implementation
from
MAIN
.
*
./
plugins
/
gtk
/
gnome_callbacks
.
c
:
fixed
a
crash
when
activating
preferences
from
the
popup
menu
.
...
...
plugins/filter/deinterlace.c
View file @
e5f9d1a3
...
...
@@ -2,7 +2,7 @@
* deinterlace.c : deinterlacer plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: deinterlace.c,v 1.12
2002/05/28 22:49:25
sam Exp $
* $Id: deinterlace.c,v 1.12
.2.1 2002/06/17 09:32:28
sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
...
...
@@ -35,15 +35,23 @@
#include "filter_common.h"
#define DEINTERLACE_MODE_BOB 1
#define DEINTERLACE_MODE_BLEND 2
#define DEINTERLACE_DISCARD 1
#define DEINTERLACE_MEAN 2
#define DEINTERLACE_BLEND 3
#define DEINTERLACE_BOB 4
#define DEINTERLACE_LINEAR 5
/*****************************************************************************
* Capabilities defined in the other files.
*****************************************************************************/
static
void
vout_getfunctions
(
function_list_t
*
p_function_list
);
static
void
*
memblend
(
void
*
,
const
void
*
,
const
void
*
,
size_t
);
static
void
RenderBob
(
vout_thread_t
*
,
picture_t
*
,
picture_t
*
,
int
);
static
void
RenderMean
(
vout_thread_t
*
,
picture_t
*
,
picture_t
*
);
static
void
RenderBlend
(
vout_thread_t
*
,
picture_t
*
,
picture_t
*
);
static
void
RenderLinear
(
vout_thread_t
*
,
picture_t
*
,
picture_t
*
,
int
);
static
void
Merge
(
void
*
,
const
void
*
,
const
void
*
,
size_t
);
/*****************************************************************************
* Build configuration tree.
...
...
@@ -51,7 +59,7 @@ static void *memblend( void *, const void *, const void *, size_t );
MODULE_CONFIG_START
ADD_CATEGORY_HINT
(
N_
(
"Miscellaneous"
),
NULL
)
ADD_STRING
(
"deinterlace-mode"
,
"bob"
,
NULL
,
N_
(
"Deinterlace mode"
),
N_
(
"one of '
bob' and 'blend
'"
)
)
N_
(
"one of '
discard', 'blend', 'mean', 'bob' or 'linear
'"
)
)
MODULE_CONFIG_STOP
MODULE_INIT_START
...
...
@@ -77,9 +85,13 @@ MODULE_DEACTIVATE_STOP
*****************************************************************************/
typedef
struct
vout_sys_s
{
int
i_mode
;
struct
vout_thread_s
*
p_vout
;
int
i_mode
;
/* Deinterlace mode */
boolean_t
b_double_rate
;
/* Shall we double the framerate? */
mtime_t
last_date
;
mtime_t
next_date
;
vout_thread_t
*
p_vout
;
}
vout_sys_t
;
...
...
@@ -126,6 +138,10 @@ static int vout_Create( vout_thread_t *p_vout )
return
(
1
);
}
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_DISCARD
;
p_vout
->
p_sys
->
b_double_rate
=
0
;
p_vout
->
p_sys
->
last_date
=
0
;
/* Look what method was requested */
psz_method
=
config_GetPszVariable
(
"deinterlace-mode"
);
...
...
@@ -134,28 +150,43 @@ static int vout_Create( vout_thread_t *p_vout )
intf_ErrMsg
(
"vout error: configuration variable %s empty"
,
"deinterlace-mode"
);
intf_ErrMsg
(
"filter error: no valid deinterlace mode provided, "
"using deinterlace:bob"
);
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_MODE_BOB
;
"using deinterlace:discard"
);
}
else
{
if
(
!
strcmp
(
psz_method
,
"bob"
)
)
if
(
!
strcmp
(
psz_method
,
"discard"
)
)
{
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_DISCARD
;
}
else
if
(
!
strcmp
(
psz_method
,
"mean"
)
)
{
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_MEAN
;
}
else
if
(
!
strcmp
(
psz_method
,
"blend"
)
||
!
strcmp
(
psz_method
,
"average"
)
||
!
strcmp
(
psz_method
,
"combine-fields"
)
)
{
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_
MODE_BOB
;
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_
BLEND
;
}
else
if
(
!
strcmp
(
psz_method
,
"blend"
)
)
else
if
(
!
strcmp
(
psz_method
,
"bob"
)
||
!
strcmp
(
psz_method
,
"progressive-scan"
)
)
{
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_MODE_BLEND
;
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_BOB
;
p_vout
->
p_sys
->
b_double_rate
=
1
;
}
else
if
(
!
strcmp
(
psz_method
,
"linear"
)
)
{
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_LINEAR
;
p_vout
->
p_sys
->
b_double_rate
=
1
;
}
else
{
intf_ErrMsg
(
"filter error: no valid deinterlace mode provided, "
"using deinterlace:bob"
);
p_vout
->
p_sys
->
i_mode
=
DEINTERLACE_MODE_BOB
;
}
"using deinterlace:discard"
);
}
free
(
psz_method
);
}
return
(
0
);
}
...
...
@@ -203,14 +234,17 @@ static int vout_Init( vout_thread_t *p_vout )
case
FOURCC_YV12
:
switch
(
p_vout
->
p_sys
->
i_mode
)
{
case
DEINTERLACE_MODE_BOB
:
case
DEINTERLACE_BOB
:
case
DEINTERLACE_MEAN
:
case
DEINTERLACE_DISCARD
:
p_vout
->
p_sys
->
p_vout
=
vout_CreateThread
(
NULL
,
p_vout
->
output
.
i_width
,
p_vout
->
output
.
i_height
/
2
,
p_vout
->
output
.
i_chroma
,
p_vout
->
output
.
i_aspect
);
break
;
case
DEINTERLACE_MODE_BLEND
:
case
DEINTERLACE_BLEND
:
case
DEINTERLACE_LINEAR
:
p_vout
->
p_sys
->
p_vout
=
vout_CreateThread
(
NULL
,
p_vout
->
output
.
i_width
,
p_vout
->
output
.
i_height
,
...
...
@@ -241,8 +275,6 @@ static int vout_Init( vout_thread_t *p_vout )
return
(
0
);
}
p_vout
->
p_sys
->
last_date
=
0
;
ALLOCATE_DIRECTBUFFERS
(
VOUT_MAX_PICTURES
);
return
(
0
);
...
...
@@ -295,31 +327,103 @@ static int vout_Manage( vout_thread_t *p_vout )
*****************************************************************************/
static
void
vout_Render
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
)
{
picture_t
*
p_outpic
;
int
i_plane
,
i_field
;
/* 20ms is a bit arbitrary, but it's only for the first image we get */
mtime_t
new_date
=
p_vout
->
p_sys
->
last_date
?
(
3
*
p_pic
->
date
-
p_vout
->
p_sys
->
last_date
)
/
2
:
p_pic
->
date
+
20000
;
picture_t
*
pp_outpic
[
2
];
p_vout
->
p_sys
->
last_date
=
p_pic
->
date
;
/* Get a new picture */
while
(
(
pp_outpic
[
0
]
=
vout_CreatePicture
(
p_vout
->
p_sys
->
p_vout
,
0
,
0
,
0
)
)
==
NULL
)
{
if
(
p_vout
->
b_die
||
p_vout
->
b_error
)
{
return
;
}
msleep
(
VOUT_OUTMEM_SLEEP
);
}
for
(
i_field
=
0
;
i_field
<
2
;
i_field
++
)
vout_DatePicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
0
],
p_pic
->
date
);
/* If we are using double rate, get an additional new picture */
if
(
p_vout
->
p_sys
->
b_double_rate
)
{
/* Get a structure from the video_output. */
while
(
(
p_outpic
=
vout_CreatePicture
(
p_vout
->
p_sys
->
p_vout
,
while
(
(
pp_outpic
[
1
]
=
vout_CreatePicture
(
p_vout
->
p_sys
->
p_vout
,
0
,
0
,
0
)
)
==
NULL
)
{
if
(
p_vout
->
b_die
||
p_vout
->
b_error
)
{
vout_DestroyPicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
0
]
);
return
;
}
msleep
(
VOUT_OUTMEM_SLEEP
);
}
vout_DatePicture
(
p_vout
->
p_sys
->
p_vout
,
p_outpic
,
p_pic
->
date
+
i_field
?
new_date
:
p_pic
->
date
);
/* 20ms is a bit arbitrary, but it's only for the first image we get */
if
(
!
p_vout
->
p_sys
->
last_date
)
{
vout_DatePicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
1
],
p_pic
->
date
+
20000
);
}
else
{
vout_DatePicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
1
],
(
3
*
p_pic
->
date
-
p_vout
->
p_sys
->
last_date
)
/
2
);
}
p_vout
->
p_sys
->
last_date
=
p_pic
->
date
;
}
switch
(
p_vout
->
p_sys
->
i_mode
)
{
case
DEINTERLACE_DISCARD
:
RenderBob
(
p_vout
,
pp_outpic
[
0
],
p_pic
,
0
);
vout_DisplayPicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
0
]
);
break
;
case
DEINTERLACE_BOB
:
RenderBob
(
p_vout
,
pp_outpic
[
0
],
p_pic
,
0
);
vout_DisplayPicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
0
]
);
RenderBob
(
p_vout
,
pp_outpic
[
1
],
p_pic
,
1
);
vout_DisplayPicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
1
]
);
break
;
case
DEINTERLACE_LINEAR
:
RenderLinear
(
p_vout
,
pp_outpic
[
0
],
p_pic
,
0
);
vout_DisplayPicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
0
]
);
RenderLinear
(
p_vout
,
pp_outpic
[
1
],
p_pic
,
1
);
vout_DisplayPicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
1
]
);
break
;
case
DEINTERLACE_MEAN
:
RenderMean
(
p_vout
,
pp_outpic
[
0
],
p_pic
);
vout_DisplayPicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
0
]
);
break
;
case
DEINTERLACE_BLEND
:
RenderBlend
(
p_vout
,
pp_outpic
[
0
],
p_pic
);
vout_DisplayPicture
(
p_vout
->
p_sys
->
p_vout
,
pp_outpic
[
0
]
);
break
;
}
}
/*****************************************************************************
* vout_Display: displays previously rendered output
*****************************************************************************
* This function send the currently rendered image to Invert image, waits
* until it is displayed and switch the two rendering buffers, preparing next
* frame.
*****************************************************************************/
static
void
vout_Display
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
)
{
;
}
/*****************************************************************************
* RenderBob: renders a bob picture
*****************************************************************************/
static
void
RenderBob
(
vout_thread_t
*
p_vout
,
picture_t
*
p_outpic
,
picture_t
*
p_pic
,
int
i_field
)
{
int
i_plane
;
/* Copy image and skip lines */
for
(
i_plane
=
0
;
i_plane
<
p_pic
->
i_planes
;
i_plane
++
)
...
...
@@ -340,9 +444,6 @@ static void vout_Render ( vout_thread_t *p_vout, picture_t *p_pic )
case
FOURCC_IYUV
:
case
FOURCC_YV12
:
switch
(
p_vout
->
p_sys
->
i_mode
)
{
case
DEINTERLACE_MODE_BOB
:
for
(
;
p_out
<
p_out_end
;
)
{
FAST_MEMCPY
(
p_out
,
p_in
,
p_pic
->
p
[
i_plane
].
i_pitch
);
...
...
@@ -352,7 +453,58 @@ static void vout_Render ( vout_thread_t *p_vout, picture_t *p_pic )
}
break
;
case
DEINTERLACE_MODE_BLEND
:
case
FOURCC_I422
:
i_increment
=
2
*
p_pic
->
p
[
i_plane
].
i_pitch
;
if
(
i_plane
==
Y_PLANE
)
{
for
(
;
p_out
<
p_out_end
;
)
{
FAST_MEMCPY
(
p_out
,
p_in
,
p_pic
->
p
[
i_plane
].
i_pitch
);
p_out
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
FAST_MEMCPY
(
p_out
,
p_in
,
p_pic
->
p
[
i_plane
].
i_pitch
);
p_out
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
p_in
+=
i_increment
;
}
}
else
{
for
(
;
p_out
<
p_out_end
;
)
{
FAST_MEMCPY
(
p_out
,
p_in
,
p_pic
->
p
[
i_plane
].
i_pitch
);
p_out
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
p_in
+=
i_increment
;
}
}
break
;
default:
break
;
}
}
}
/*****************************************************************************
* RenderLinear: displays previously rendered output
*****************************************************************************/
static
void
RenderLinear
(
vout_thread_t
*
p_vout
,
picture_t
*
p_outpic
,
picture_t
*
p_pic
,
int
i_field
)
{
int
i_plane
;
/* Copy image and skip lines */
for
(
i_plane
=
0
;
i_plane
<
p_pic
->
i_planes
;
i_plane
++
)
{
u8
*
p_in
,
*
p_out_end
,
*
p_out
;
p_in
=
p_pic
->
p
[
i_plane
].
p_pixels
+
i_field
*
p_pic
->
p
[
i_plane
].
i_pitch
;
p_out
=
p_outpic
->
p
[
i_plane
].
p_pixels
;
p_out_end
=
p_out
+
p_outpic
->
p
[
i_plane
].
i_pitch
*
p_outpic
->
p
[
i_plane
].
i_lines
;
if
(
i_field
==
0
)
{
FAST_MEMCPY
(
p_out
,
p_in
,
p_pic
->
p
[
i_plane
].
i_pitch
);
...
...
@@ -360,7 +512,7 @@ static void vout_Render ( vout_thread_t *p_vout, picture_t *p_pic )
p_out
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
}
p_out_end
-=
p_outpic
->
p
[
i_plane
].
i_pitch
;
p_out_end
-=
2
*
p_outpic
->
p
[
i_plane
].
i_pitch
;
for
(
;
p_out
<
p_out_end
;
)
{
...
...
@@ -368,8 +520,7 @@ static void vout_Render ( vout_thread_t *p_vout, picture_t *p_pic )
p_out
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
memblend
(
p_out
,
p_in
,
p_in
+
2
*
p_pic
->
p
[
i_plane
].
i_pitch
,
Merge
(
p_out
,
p_in
,
p_in
+
2
*
p_pic
->
p
[
i_plane
].
i_pitch
,
p_pic
->
p
[
i_plane
].
i_pitch
);
p_in
+=
2
*
p_pic
->
p
[
i_plane
].
i_pitch
;
...
...
@@ -383,59 +534,70 @@ static void vout_Render ( vout_thread_t *p_vout, picture_t *p_pic )
FAST_MEMCPY( p_out, p_in, p_pic->p[i_plane].i_pitch );
}
#endif
break
;
}
break
;
case
FOURCC_I422
:
}
i_increment
=
2
*
p_pic
->
p
[
i_plane
].
i_pitch
;
static
void
RenderMean
(
vout_thread_t
*
p_vout
,
picture_t
*
p_outpic
,
picture_t
*
p_pic
)
{
int
i_plane
;
if
(
i_plane
==
Y_PLANE
)
/* Copy image and skip lines */
for
(
i_plane
=
0
;
i_plane
<
p_pic
->
i_planes
;
i_plane
++
)
{
u8
*
p_in
,
*
p_out_end
,
*
p_out
;
p_in
=
p_pic
->
p
[
i_plane
].
p_pixels
;
p_out
=
p_outpic
->
p
[
i_plane
].
p_pixels
;
p_out_end
=
p_out
+
p_outpic
->
p
[
i_plane
].
i_pitch
*
p_outpic
->
p
[
i_plane
].
i_lines
;
/* All lines: mean value */
for
(
;
p_out
<
p_out_end
;
)
{
FAST_MEMCPY
(
p_out
,
p_in
,
p_pic
->
p
[
i_plane
].
i_pitch
);
p_out
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
FAST_MEMCPY
(
p_out
,
p_in
,
p_pic
->
p
[
i_plane
].
i_pitch
);
Merge
(
p_out
,
p_in
,
p_in
+
p_pic
->
p
[
i_plane
].
i_pitch
,
p_pic
->
p
[
i_plane
].
i_pitch
)
;
p_out
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
p_in
+=
i_increment
;
p_in
+=
2
*
p_pic
->
p
[
i_plane
].
i_pitch
;
}
}
else
{
for
(
;
p_out
<
p_out_end
;
)
}
static
void
RenderBlend
(
vout_thread_t
*
p_vout
,
picture_t
*
p_outpic
,
picture_t
*
p_pic
)
{
int
i_plane
;
/* Copy image and skip lines */
for
(
i_plane
=
0
;
i_plane
<
p_pic
->
i_planes
;
i_plane
++
)
{
u8
*
p_in
,
*
p_out_end
,
*
p_out
;
p_in
=
p_pic
->
p
[
i_plane
].
p_pixels
;
p_out
=
p_outpic
->
p
[
i_plane
].
p_pixels
;
p_out_end
=
p_out
+
p_outpic
->
p
[
i_plane
].
i_pitch
*
p_outpic
->
p
[
i_plane
].
i_lines
;
/* First line: simple copy */
FAST_MEMCPY
(
p_out
,
p_in
,
p_pic
->
p
[
i_plane
].
i_pitch
);
p_out
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
p_in
+=
i_increment
;
}
}
break
;
default:
break
;
}
}
/* Remaining lines: mean value */
for
(
;
p_out
<
p_out_end
;
)
{
Merge
(
p_out
,
p_in
,
p_in
+
p_pic
->
p
[
i_plane
].
i_pitch
,
p_pic
->
p
[
i_plane
].
i_pitch
);
vout_DisplayPicture
(
p_vout
->
p_sys
->
p_vout
,
p_outpic
);
p_out
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
p_in
+=
p_pic
->
p
[
i_plane
].
i_pitch
;
}
}
}
/*****************************************************************************
* vout_Display: displays previously rendered output
*****************************************************************************
* This function send the currently rendered image to Invert image, waits
* until it is displayed and switch the two rendering buffers, preparing next
* frame.
*****************************************************************************/
static
void
vout_Display
(
vout_thread_t
*
p_vout
,
picture_t
*
p_pic
)
{
;
}
static
void
*
memblend
(
void
*
p_dest
,
const
void
*
p_s1
,
static
void
Merge
(
void
*
p_dest
,
const
void
*
p_s1
,
const
void
*
p_s2
,
size_t
i_bytes
)
{
u8
*
p_end
=
(
u8
*
)
p_dest
+
i_bytes
-
8
;
...
...
@@ -458,7 +620,5 @@ static void *memblend( void *p_dest, const void *p_s1,
{
*
(
u8
*
)
p_dest
++
=
(
(
u16
)(
*
(
u8
*
)
p_s1
++
)
+
(
u16
)(
*
(
u8
*
)
p_s2
++
)
)
>>
1
;
}
return
p_dest
;
}
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