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
a688d669
Commit
a688d669
authored
Mar 31, 2010
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
davinci: resizer.c: cleanup
- remove hackish code for direct framebuffer output
parent
3d7b2498
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
164 deletions
+67
-164
modules/codec/davinci/resizer.c
modules/codec/davinci/resizer.c
+54
-151
modules/codec/davinci/resizer.h
modules/codec/davinci/resizer.h
+13
-13
No files found.
modules/codec/davinci/resizer.c
View file @
a688d669
...
@@ -21,11 +21,16 @@
...
@@ -21,11 +21,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
*****************************************************************************/
#undef _FILE_OFFSET_BITS
/* mmap() fails on 64 bits offsets */
#ifdef HAVE_CONFIG_H
#include "davinci.h"
/* DAVINCI_HACK defined here */
# include <config.h>
#endif
#include <vlc_common.h>
#include <vlc_codec.h>
#
ifdef DAVINCI_HACK
#
undef _FILE_OFFSET_BITS
/* mmap() fails on 64 bits offsets */
#include "davinci.h"
#include "resizer.h"
#include "resizer.h"
#include <assert.h>
#include <assert.h>
...
@@ -76,37 +81,6 @@ static void Resize_coeff( decoder_t *p_dec,
...
@@ -76,37 +81,6 @@ static void Resize_coeff( decoder_t *p_dec,
msg_Dbg
(
p_dec
,
"Destination fixed to %dx%d"
,
*
i_width
,
*
i_height
);
msg_Dbg
(
p_dec
,
"Destination fixed to %dx%d"
,
*
i_width
,
*
i_height
);
}
}
/* open() a framebuffer by its name (NOT device path) */
static
int
OpenFB
(
const
char
*
psz_name
)
{
int
i_fd
=
-
1
;
int
i_tries
=
0
;
/* begin with /dev/fb0 */
char
*
psz_device
;
struct
fb_fix_screeninfo
info
;
do
{
if
(
asprintf
(
&
psz_device
,
"/dev/fb%d"
,
i_tries
++
)
==
-
1
)
return
-
1
;
i_fd
=
open
(
psz_device
,
O_RDWR
);
free
(
psz_device
);
if
(
i_fd
==
-
1
)
return
-
1
;
/* check errno */
if
(
ioctl
(
i_fd
,
FBIOGET_FSCREENINFO
,
&
info
)
==
-
1
)
{
close
(
i_fd
);
continue
;
}
if
(
!
strcmp
(
info
.
id
,
psz_name
)
)
return
i_fd
;
close
(
i_fd
);
}
while
(
1
);
}
static
float
bicubic_core
(
float
s
)
static
float
bicubic_core
(
float
s
)
{
{
if
(
s
<
0
)
s
=
-
s
;
if
(
s
<
0
)
s
=
-
s
;
...
@@ -119,7 +93,6 @@ static float bicubic_core( float s )
...
@@ -119,7 +93,6 @@ static float bicubic_core( float s )
return
0
.;
return
0
.;
}
}
static
void
get_coeffs
(
short
coefs
[
32
],
unsigned
int
i_in
,
static
void
get_coeffs
(
short
coefs
[
32
],
unsigned
int
i_in
,
unsigned
int
i_out
)
unsigned
int
i_out
)
{
{
...
@@ -159,6 +132,7 @@ static void get_coeffs( short coefs[32], unsigned int i_in,
...
@@ -159,6 +132,7 @@ static void get_coeffs( short coefs[32], unsigned int i_in,
i_phase_offset
=
4
;
i_phase_offset
=
4
;
}
}
i_winlen
=
i_nphases
*
i_ntaps
;
i_winlen
=
i_nphases
*
i_ntaps
;
/* calculating the cut-off frequency, normalized by fs/2 */
/* calculating the cut-off frequency, normalized by fs/2 */
f_fc
=
(
i_rsz
<
256
)
?
(
1
.
/
i_nphases
)
:
256
.
/
(
i_rsz
*
i_nphases
);
f_fc
=
(
i_rsz
<
256
)
?
(
1
.
/
i_nphases
)
:
256
.
/
(
i_rsz
*
i_nphases
);
...
@@ -169,6 +143,7 @@ static void get_coeffs( short coefs[32], unsigned int i_in,
...
@@ -169,6 +143,7 @@ static void get_coeffs( short coefs[32], unsigned int i_in,
i_nphases
=
8
;
i_nphases
=
8
;
i_ntaps
=
4
;
i_ntaps
=
4
;
i_phase_offset
=
4
;
i_phase_offset
=
4
;
/* calculating the bi-cubic coefficients */
/* calculating the bi-cubic coefficients */
for
(
i
=
0
;
i
<
i_nphases
;
i
++
)
for
(
i
=
0
;
i
<
i_nphases
;
i
++
)
{
{
...
@@ -234,13 +209,19 @@ static void get_coeffs( short coefs[32], unsigned int i_in,
...
@@ -234,13 +209,19 @@ static void get_coeffs( short coefs[32], unsigned int i_in,
}
}
}
}
void
Resize
(
decoder_t
*
p_dec
,
bool
b_scale
,
davinci_resizer_t
*
rsz
,
/*
davinci_fb_t
*
fb
,
XDM_BufDesc
out
)
* Resizer functions
*/
int
Resize
(
decoder_t
*
p_dec
,
davinci_resizer_t
*
rsz
,
bool
b_scale
,
XDM_BufDesc
in
,
XDM_BufDesc
out
)
{
{
if
(
!
rsz
->
i_yuyv
)
assert
(
rsz
);
assert
(
p_dec
);
if
(
rsz
->
i_yuyv
==
0
)
{
{
/* use screen resolution for the buffer, we may be off by a few */
/* use screen resolution for the buffer, we may be off by a few */
rsz
->
i_yuyv
=
fb
->
var_info
.
xres
*
fb
->
var_info
.
yres_virtual
;
rsz
->
i_yuyv
=
rsz
->
i_out_width
*
rsz
->
i_out_height
;
assert
(
rsz
->
i_yuyv
);
assert
(
rsz
->
i_yuyv
);
rsz_reqbufs_t
reqbufs
;
rsz_reqbufs_t
reqbufs
;
...
@@ -255,7 +236,7 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
...
@@ -255,7 +236,7 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
if
(
ioctl
(
rsz
->
i_fd
,
RSZ_REQBUF
,
&
reqbufs
)
)
if
(
ioctl
(
rsz
->
i_fd
,
RSZ_REQBUF
,
&
reqbufs
)
)
{
{
msg_Err
(
p_dec
,
"RSZ_REQBUF failed (%m)"
);
msg_Err
(
p_dec
,
"RSZ_REQBUF failed (%m)"
);
return
;
return
VLC_EGENERIC
;
}
}
buffer
.
buf_type
=
RSZ_BUF_OUT
;
buffer
.
buf_type
=
RSZ_BUF_OUT
;
...
@@ -264,19 +245,19 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
...
@@ -264,19 +245,19 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
if
(
ioctl
(
rsz
->
i_fd
,
RSZ_QUERYBUF
,
&
buffer
)
)
if
(
ioctl
(
rsz
->
i_fd
,
RSZ_QUERYBUF
,
&
buffer
)
)
{
{
msg_Err
(
p_dec
,
"RSZ_QUERYBUF failed (%m)"
);
msg_Err
(
p_dec
,
"RSZ_QUERYBUF failed (%m)"
);
return
;
return
VLC_EGENERIC
;
}
}
rsz
->
offset
=
buffer
.
offset
;
rsz
->
p_yuyv
=
mmap
(
NULL
,
reqbufs
.
size
,
PROT_READ
|
PROT_WRITE
,
rsz
->
p_yuyv
=
mmap
(
NULL
,
reqbufs
.
size
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
rsz
->
i_fd
,
buffer
.
offset
);
MAP_SHARED
,
rsz
->
i_fd
,
buffer
.
offset
);
if
(
rsz
->
p_yuyv
==
MAP_FAILED
)
if
(
rsz
->
p_yuyv
==
MAP_FAILED
)
{
{
rsz
->
i_yuyv
=
0
;
rsz
->
i_yuyv
=
0
;
msg_Err
(
p_dec
,
"mmap resizer to buffer failed (%m)"
);
msg_Err
(
p_dec
,
"mmap resizer to buffer failed (%m)"
);
return
;
return
VLC_EGENERIC
;
}
}
rsz
->
offset
=
buffer
.
offset
;
}
}
/* Sets resizer parameters when video starts or when resolution changes */
/* Sets resizer parameters when video starts or when resolution changes */
...
@@ -295,8 +276,8 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
...
@@ -295,8 +276,8 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
/* Sets the desired maximum destination resolution */
/* Sets the desired maximum destination resolution */
if
(
b_scale
)
if
(
b_scale
)
{
{
rsz_params
.
out_hsize
=
fb
->
var_info
.
xres
;
rsz_params
.
out_hsize
=
rsz
->
i_out_width
;
rsz_params
.
out_vsize
=
fb
->
var_info
.
yres
;
rsz_params
.
out_vsize
=
rsz
->
i_out_height
;
}
}
else
else
{
{
...
@@ -311,8 +292,7 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
...
@@ -311,8 +292,7 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
/* RSZ_PIX_FMT_YUYV is 2 bytes per pixel */
/* RSZ_PIX_FMT_YUYV is 2 bytes per pixel */
rsz_params
.
out_pitch
=
(
rsz_params
.
out_hsize
*
2
+
15
)
&
~
15
;
rsz_params
.
out_pitch
=
(
rsz_params
.
out_hsize
*
2
+
15
)
&
~
15
;
rsz
->
b_direct
=
rsz
->
b_direct
=
((
unsigned
)
rsz_params
.
out_hsize
==
(
unsigned
)
width
);
(
unsigned
)
rsz_params
.
out_hsize
==
(
unsigned
)
fb
->
var_info
.
xres
;
rsz
->
i_out_width
=
rsz_params
.
out_hsize
;
rsz
->
i_out_width
=
rsz_params
.
out_hsize
;
rsz
->
i_out_height
=
rsz_params
.
out_vsize
;
rsz
->
i_out_height
=
rsz_params
.
out_vsize
;
...
@@ -340,18 +320,17 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
...
@@ -340,18 +320,17 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
);
);
rsz
->
i_width
=
rsz
->
i_height
=
0
;
rsz
->
i_width
=
rsz
->
i_height
=
0
;
return
;
return
VLC_EGENERIC
;
}
}
}
}
rsz_resize_t
rszh
;
rsz_resize_t
rszh
;
rszh
.
in_buf
.
index
=
-
1
;
rszh
.
in_buf
.
index
=
-
1
;
rszh
.
in_buf
.
buf_type
=
RSZ_BUF_IN
;
rszh
.
in_buf
.
buf_type
=
RSZ_BUF_IN
;
rszh
.
in_buf
.
size
=
rszh
.
in_buf
.
size
=
p_dec
->
fmt_out
.
video
.
i_height
*
p_dec
->
fmt_out
.
video
.
i_height
*
((
p_dec
->
fmt_out
.
video
.
i_width
*
BPP
/
8
+
31
)
&
~
31
);
((
p_dec
->
fmt_out
.
video
.
i_width
*
BPP
/
8
+
31
)
&
~
31
);
rszh
.
in_buf
.
offset
=
Memory_getBufferPhysicalAddress
(
rszh
.
in_buf
.
offset
=
Memory_getBufferPhysicalAddress
(
out
.
bufs
[
0
],
rszh
.
in_buf
.
size
,
NULL
);
out
.
bufs
[
0
],
rszh
.
in_buf
.
size
,
NULL
);
assert
(
rszh
.
in_buf
.
offset
);
assert
(
rszh
.
in_buf
.
offset
);
rszh
.
out_buf
.
index
=
-
1
;
rszh
.
out_buf
.
index
=
-
1
;
...
@@ -360,8 +339,8 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
...
@@ -360,8 +339,8 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
if
(
b_scale
&&
rsz
->
b_direct
/* output video res is screen res */
)
if
(
b_scale
&&
rsz
->
b_direct
/* output video res is screen res */
)
{
{
/* FIXME: use NUM_BUFFERS if needed */
/* FIXME: use NUM_BUFFERS if needed */
rszh
.
out_buf
.
offset
=
fb
->
p_physbufs
[
0
];
rszh
.
out_buf
.
offset
=
fb
->
p_physbufs
[
0
];
//FIXME:
rszh
.
out_buf
.
size
=
fb
->
var_info
.
xres
*
fb
->
var_info
.
yres_virtual
;
rszh
.
out_buf
.
size
=
rsz
->
i_out_width
*
rsz
->
i_out_height
;
}
}
else
else
{
{
...
@@ -377,120 +356,44 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
...
@@ -377,120 +356,44 @@ void Resize( decoder_t *p_dec, bool b_scale, davinci_resizer_t *rsz,
continue
;
continue
;
msg_Err
(
p_dec
,
"Resizing failed (%m)"
);
msg_Err
(
p_dec
,
"Resizing failed (%m)"
);
return
;
return
VLC_EGENERIC
;
}
}
}
while
(
0
);
}
while
(
0
);
return
VLC_SUCCESS
;
}
}
int
DavinciInit
(
decoder_t
*
p_dec
,
davinci_fb_t
*
fb
,
davinci_resizer_t
*
rsz
)
int
ResizerOpen
(
vlc_object_t
*
p_this
,
davinci_resizer_t
*
rsz
)
{
{
fb
->
i_fd
=
rsz
->
i_fd
=
-
1
;
rsz
->
i_fd
=
-
1
;
/* Open framebuffer */
if
(
(
fb
->
i_fd
=
OpenFB
(
"dm_vid0_fb"
)
)
==
-
1
)
{
msg_Err
(
p_dec
,
"Failed to open framebuffer (%m)"
);
goto
error
;
}
if
(
ioctl
(
fb
->
i_fd
,
FBIOGET_VSCREENINFO
,
&
fb
->
var_info
)
==
-
1
)
{
msg_Err
(
p_dec
,
"Failed to get framebuffer info (%m)"
);
goto
error
;
}
fb
->
var_info
.
yres_virtual
=
fb
->
var_info
.
yres
*
NUM_BUFFERS
;
fb
->
var_info
.
bits_per_pixel
=
BPP
;
if
(
ioctl
(
fb
->
i_fd
,
FBIOPUT_VSCREENINFO
,
&
fb
->
var_info
)
==
-
1
)
{
msg_Err
(
p_dec
,
"Can not set fb info (%m)"
);
goto
error
;
}
if
(
fb
->
var_info
.
bits_per_pixel
!=
BPP
)
{
msg_Err
(
p_dec
,
"Can not use requested size (%dx%d at %d bpp)"
,
fb
->
var_info
.
xres
,
fb
->
var_info
.
yres
,
fb
->
var_info
.
bits_per_pixel
);
goto
error
;
}
if
(
ioctl
(
fb
->
i_fd
,
FBIOGET_FSCREENINFO
,
&
fb
->
fix_info
)
==
-
1
)
{
msg_Err
(
p_dec
,
"Failed to get framebuffer fixed info (%m)"
);
goto
error
;
}
/* Yes, 32bits * 32bits fills 64 bits.
* * Oh and if you find a screen with 16 billions of billions of pixels ...
* * Keep it for yourself. */
uint64_t
i_display_sz
=
fb
->
fix_info
.
line_length
*
fb
->
var_info
.
yres
;
uint64_t
i_display_total_sz
=
fb
->
fix_info
.
line_length
*
fb
->
var_info
.
yres_virtual
;
fb
->
p_map
=
mmap
(
NULL
,
i_display_total_sz
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fb
->
i_fd
,
0
);
if
(
fb
->
p_map
==
MAP_FAILED
)
{
fb
->
p_map
=
NULL
;
/* set to NULL for error handling */
msg_Err
(
p_dec
,
"Memory mapping of framebuffer failed (%m)"
);
goto
error
;
}
/* Clears fb */
unsigned
int
i
;
for
(
i
=
0
;
i
<
i_display_total_sz
/
4
;
i
++
)
((
uint32_t
*
)
fb
->
p_map
)[
i
]
=
0x10801080
;
for
(
i
=
0
;
i
<
NUM_BUFFERS
;
i
++
)
if
(
(
fb
->
p_physbufs
[
i
]
=
Memory_getBufferPhysicalAddress
(
fb
->
p_map
+
i
*
i_display_sz
,
i_display_sz
,
NULL
)
)
==
0
)
{
msg_Err
(
p_dec
,
"Unable to get physical address of buffer "
"%d/%d (%"
PRId64
" bytes)"
,
i
,
NUM_BUFFERS
,
i_display_sz
);
goto
error
;
}
/* Open and setup resizer */
/* Open and setup resizer */
if
(
(
rsz
->
i_fd
=
open
(
"/dev/davinci_resizer"
,
O_RDWR
)
)
==
-
1
)
if
(
(
rsz
->
i_fd
=
open
(
"/dev/davinci_resizer"
,
O_RDWR
)
)
==
-
1
)
{
{
msg_Err
(
p_
dec
,
"Failed to open resizer (%m)"
);
msg_Err
(
p_
this
,
"Failed to open resizer (%m)"
);
goto
error
;
goto
error
;
}
}
rsz
->
p_yuyv
=
NULL
;
rsz
->
p_yuyv
=
MAP_FAILED
;
rsz
->
i_yuyv
=
0
;
rsz
->
i_yuyv
=
0
;
rsz
->
offset
=
0
;
rsz
->
i_height
=
rsz
->
i_width
=
0
;
rsz
->
i_height
=
0
;
rsz
->
i_width
=
0
;
rsz
->
i_out_height
=
0
;
rsz
->
i_out_width
=
0
;
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
error:
error:
DavinciClose
(
fb
,
rsz
);
ResizerClose
(
rsz
);
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
}
}
void
DavinciClose
(
davinci_fb_t
*
fb
,
davinci_resizer_t
*
rsz
)
void
ResizerClose
(
davinci_resizer_t
*
rsz
)
{
{
if
(
fb
->
p_map
)
if
(
rsz
->
i_fd
!=
-
1
)
{
close
(
rsz
->
i_fd
);
/* Clears fb */
if
(
rsz
->
p_yuyv
!=
MAP_FAILED
)
unsigned
int
i
;
munmap
(
rsz
->
p_yuyv
,
rsz
->
offset
);
uint64_t
i_display_size
=
rsz
->
i_fd
=
-
1
;
fb
->
fix_info
.
line_length
*
fb
->
var_info
.
yres_virtual
/
4
;
for
(
i
=
0
;
i
<
i_display_size
;
i
++
)
((
uint32_t
*
)
fb
->
p_map
)[
i
]
=
0x10801080
;
munmap
(
fb
->
p_map
,
i_display_size
);
}
if
(
fb
->
i_fd
!=
-
1
)
close
(
fb
->
i_fd
);
if
(
rsz
->
i_fd
!=
-
1
)
close
(
rsz
->
i_fd
);
rsz
->
i_fd
=
fb
->
i_fd
=
-
1
;
fb
->
p_map
=
NULL
;
}
}
#endif
/* DAVINCI_HACK */
modules/codec/davinci/resizer.h
View file @
a688d669
...
@@ -42,15 +42,6 @@
...
@@ -42,15 +42,6 @@
#define PI 3.1415926535897932384626
#define PI 3.1415926535897932384626
typedef
struct
{
int
i_fd
;
struct
fb_var_screeninfo
var_info
;
struct
fb_fix_screeninfo
fix_info
;
uint8_t
*
p_map
;
UInt32
p_physbufs
[
NUM_BUFFERS
];
}
davinci_fb_t
;
typedef
struct
typedef
struct
{
{
int
i_fd
;
int
i_fd
;
...
@@ -67,9 +58,18 @@ typedef struct
...
@@ -67,9 +58,18 @@ typedef struct
bool
b_direct
;
bool
b_direct
;
}
davinci_resizer_t
;
}
davinci_resizer_t
;
void
Resize
(
decoder_t
*
,
bool
,
davinci_resizer_t
*
,
davinci_fb_t
*
,
/* Resize: resize and/or enhance input picture
XDM_BufDesc
);
* \param p_dec : pointer to decoder_t structure
int
DavinciInit
(
decoder_t
*
,
davinci_fb_t
*
,
davinci_resizer_t
*
);
* \param rsz : pointer to davinci_resizer_t structure
void
DavinciClose
(
davinci_fb_t
*
,
davinci_resizer_t
*
);
* \param b_scale : rescale to output size
* \param in : input buffer as XDM_BufDesc
* \param out : output buffer as XDM_BufDesc
* \return VLC_SUCCESS on success and VLC_EGENERIC on failure
*/
int
Resize
(
decoder_t
*
p_dec
,
davinci_resizer_t
*
rsz
,
bool
b_scale
,
XDM_BufDesc
in
,
XDM_BufDesc
out
);
int
ResizerOpen
(
vlc_object_t
*
p_this
,
davinci_resizer_t
*
rsz
);
void
ResizerClose
(
davinci_resizer_t
*
rsz
);
#endif
/* RESIZER_H */
#endif
/* RESIZER_H */
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