Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
9e4cda92
Commit
9e4cda92
authored
Mar 06, 2014
by
Matthias Keiser
Committed by
Rémi Denis-Courmont
Mar 06, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add transform helper functions.
Signed-off-by:
Rémi Denis-Courmont
<
remi@remlab.net
>
parent
09e5b394
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
225 additions
and
0 deletions
+225
-0
include/vlc_es.h
include/vlc_es.h
+48
-0
src/libvlccore.sym
src/libvlccore.sym
+4
-0
src/misc/es_format.c
src/misc/es_format.c
+173
-0
No files found.
include/vlc_es.h
View file @
9e4cda92
...
@@ -153,6 +153,8 @@ typedef enum video_orientation_t
...
@@ -153,6 +153,8 @@ typedef enum video_orientation_t
ORIENT_RIGHT_BOTTOM
,
/**< Anti-transposed */
ORIENT_RIGHT_BOTTOM
,
/**< Anti-transposed */
ORIENT_NORMAL
=
ORIENT_TOP_LEFT
,
ORIENT_NORMAL
=
ORIENT_TOP_LEFT
,
ORIENT_TRANSPOSED
=
ORIENT_LEFT_TOP
,
ORIENT_ANTI_TRANSPOSED
=
ORIENT_RIGHT_BOTTOM
,
ORIENT_HFLIPPED
=
ORIENT_TOP_RIGHT
,
ORIENT_HFLIPPED
=
ORIENT_TOP_RIGHT
,
ORIENT_VFLIPPED
=
ORIENT_BOTTOM_LEFT
,
ORIENT_VFLIPPED
=
ORIENT_BOTTOM_LEFT
,
ORIENT_ROTATED_180
=
ORIENT_BOTTOM_RIGHT
,
ORIENT_ROTATED_180
=
ORIENT_BOTTOM_RIGHT
,
...
@@ -174,6 +176,18 @@ typedef enum video_orientation_t
...
@@ -174,6 +176,18 @@ typedef enum video_orientation_t
/** Applies horizontal flip to an orientation */
/** Applies horizontal flip to an orientation */
#define ORIENT_ROTATE_180(orient) ((orient) ^ 3)
#define ORIENT_ROTATE_180(orient) ((orient) ^ 3)
typedef
enum
video_transform_t
{
TRANSFORM_IDENTIY
=
ORIENT_NORMAL
,
TRANSFORM_HFLIP
=
ORIENT_HFLIPPED
,
TRANSFORM_VFLIP
=
ORIENT_VFLIPPED
,
TRANSFORM_R180
=
ORIENT_ROTATED_180
,
TRANSFORM_R270
=
ORIENT_ROTATED_270
,
TRANSFORM_R90
=
ORIENT_ROTATED_90
,
TRANSFORM_TRANSPOSE
=
ORIENT_TRANSPOSED
,
TRANSFORM_ANTI_TRANSPOSE
=
ORIENT_ANTI_TRANSPOSED
}
video_transform_t
;
/**
/**
* video format description
* video format description
*/
*/
...
@@ -264,6 +278,28 @@ VLC_API void video_format_CopyCrop( video_format_t *, const video_format_t * );
...
@@ -264,6 +278,28 @@ VLC_API void video_format_CopyCrop( video_format_t *, const video_format_t * );
*/
*/
VLC_API
void
video_format_ScaleCropAr
(
video_format_t
*
,
const
video_format_t
*
);
VLC_API
void
video_format_ScaleCropAr
(
video_format_t
*
,
const
video_format_t
*
);
/**
* This function "normalizes" the formats orientation, by switching the a/r according to the orientation,
* producing a format whose orientation is ORIENT_NORMAL. It makes a shallow copy (pallette is not alloc'ed).
*/
VLC_API
void
video_format_ApplyRotation
(
const
video_format_t
*
restrict
in
,
video_format_t
*
restrict
out
);
/**
* This function applies the transform operation to fmt.
*/
VLC_API
void
video_format_TransformBy
(
video_format_t
*
fmt
,
video_transform_t
transform
);
/**
* This function applies the transforms necessary to fmt so that the resulting fmt
* has the dst_orientation.
*/
VLC_API
void
video_format_TransformTo
(
video_format_t
*
fmt
,
video_orientation_t
dst_orientation
);
/**
* Returns the operation required to transform src into dst.
*/
VLC_API
video_transform_t
video_format_GetTransform
(
video_orientation_t
src
,
video_orientation_t
dst
);
/**
/**
* This function will check if the first video format is similar
* This function will check if the first video format is similar
* to the second one.
* to the second one.
...
@@ -275,6 +311,18 @@ VLC_API bool video_format_IsSimilar( const video_format_t *, const video_format_
...
@@ -275,6 +311,18 @@ VLC_API bool video_format_IsSimilar( const video_format_t *, const video_format_
*/
*/
VLC_API
void
video_format_Print
(
vlc_object_t
*
,
const
char
*
,
const
video_format_t
*
);
VLC_API
void
video_format_Print
(
vlc_object_t
*
,
const
char
*
,
const
video_format_t
*
);
static
inline
video_transform_t
transform_Inverse
(
video_transform_t
transform
)
{
switch
(
transform
)
{
case
TRANSFORM_R90
:
return
TRANSFORM_R270
;
case
TRANSFORM_R270
:
return
TRANSFORM_R90
;
default:
return
transform
;
}
}
/**
/**
* subtitles format description
* subtitles format description
*/
*/
...
...
src/libvlccore.sym
View file @
9e4cda92
...
@@ -467,6 +467,10 @@ var_LocationParse
...
@@ -467,6 +467,10 @@ var_LocationParse
video_format_CopyCrop
video_format_CopyCrop
video_format_ScaleCropAr
video_format_ScaleCropAr
video_format_FixRgb
video_format_FixRgb
video_format_ApplyRotation
video_format_TransformBy
video_format_TransformTo
video_format_GetTransform
video_format_IsSimilar
video_format_IsSimilar
video_format_Setup
video_format_Setup
video_format_Print
video_format_Print
...
...
src/misc/es_format.c
View file @
9e4cda92
...
@@ -244,6 +244,179 @@ void video_format_ScaleCropAr( video_format_t *p_dst, const video_format_t *p_sr
...
@@ -244,6 +244,179 @@ void video_format_ScaleCropAr( video_format_t *p_dst, const video_format_t *p_sr
p_dst
->
i_sar_num
,
p_dst
->
i_sar_den
,
65536
);
p_dst
->
i_sar_num
,
p_dst
->
i_sar_den
,
65536
);
}
}
//Simplify transforms to have something more managable. Order: angle, hflip.
void
transform_GetBasicOps
(
video_transform_t
transform
,
int
*
angle
,
int
*
hflip
)
{
*
angle
=
0
;
*
hflip
=
0
;
switch
(
transform
)
{
case
TRANSFORM_R90
:
*
angle
=
90
;
break
;
case
TRANSFORM_R180
:
*
angle
=
180
;
break
;
case
TRANSFORM_R270
:
*
angle
=
270
;
break
;
case
TRANSFORM_HFLIP
:
*
hflip
=
1
;
break
;
case
TRANSFORM_VFLIP
:
*
angle
=
180
;
*
hflip
=
1
;
break
;
case
TRANSFORM_TRANSPOSE
:
*
angle
=
90
;
*
hflip
=
1
;
break
;
case
TRANSFORM_ANTI_TRANSPOSE
:
*
angle
=
270
;
*
hflip
=
1
;
break
;
}
}
video_transform_t
transform_FromBasicOps
(
int
angle
,
int
hflip
)
{
switch
(
angle
)
{
case
0
:
return
hflip
?
TRANSFORM_HFLIP
:
TRANSFORM_IDENTIY
;
case
90
:
return
hflip
?
TRANSFORM_TRANSPOSE
:
TRANSFORM_R90
;
case
180
:
return
hflip
?
TRANSFORM_VFLIP
:
TRANSFORM_R180
;
case
270
:
return
hflip
?
TRANSFORM_ANTI_TRANSPOSE
:
TRANSFORM_R270
;
default:
return
TRANSFORM_IDENTIY
;
}
}
video_transform_t
video_format_GetTransform
(
video_orientation_t
src
,
video_orientation_t
dst
)
{
int
angle1
=
0
;
int
hflip1
=
0
;
transform_GetBasicOps
(
(
video_transform_t
)
src
,
&
angle1
,
&
hflip1
);
int
angle2
=
0
;
int
hflip2
=
0
;
transform_GetBasicOps
(
transform_Inverse
(
(
video_transform_t
)
dst
),
&
angle2
,
&
hflip2
);
int
angle
=
(
angle1
+
angle2
)
%
360
;
int
hflip
=
(
hflip1
+
hflip2
)
%
2
;
return
transform_FromBasicOps
(
angle
,
hflip
);
}
void
video_format_TransformTo
(
video_format_t
*
fmt
,
video_orientation_t
dst_orientation
)
{
video_transform_t
transform
=
video_format_GetTransform
(
fmt
->
orientation
,
dst_orientation
);
video_format_TransformBy
(
fmt
,
transform
);
}
void
video_format_TransformBy
(
video_format_t
*
fmt
,
video_transform_t
transform
)
{
/* Get destination orientation */
int
angle1
=
0
;
int
hflip1
=
0
;
transform_GetBasicOps
(
transform
,
&
angle1
,
&
hflip1
);
int
angle2
=
0
;
int
hflip2
=
0
;
transform_GetBasicOps
(
(
video_transform_t
)(
fmt
->
orientation
),
&
angle2
,
&
hflip2
);
int
angle
=
(
angle2
-
angle1
+
360
)
%
360
;
int
hflip
=
(
hflip2
-
hflip1
+
2
)
%
2
;
video_orientation_t
dst_orient
=
ORIENT_NORMAL
;
if
(
hflip
)
{
if
(
angle
==
0
)
dst_orient
=
ORIENT_HFLIPPED
;
else
if
(
angle
==
90
)
dst_orient
=
ORIENT_ANTI_TRANSPOSED
;
else
if
(
angle
==
180
)
dst_orient
=
ORIENT_VFLIPPED
;
else
if
(
angle
==
270
)
dst_orient
=
ORIENT_TRANSPOSED
;
}
else
{
if
(
angle
==
90
)
dst_orient
=
ORIENT_ROTATED_90
;
else
if
(
angle
==
180
)
dst_orient
=
ORIENT_ROTATED_180
;
else
if
(
angle
==
270
)
dst_orient
=
ORIENT_ROTATED_270
;
}
/* Apply transform */
video_format_t
scratch
=
*
fmt
;
if
(
ORIENT_IS_SWAP
(
fmt
->
orientation
)
!=
ORIENT_IS_SWAP
(
dst_orient
))
{
fmt
->
i_width
=
scratch
.
i_height
;
fmt
->
i_visible_width
=
scratch
.
i_visible_height
;
fmt
->
i_height
=
scratch
.
i_width
;
fmt
->
i_visible_height
=
scratch
.
i_visible_width
;
fmt
->
i_sar_num
=
scratch
.
i_sar_den
;
fmt
->
i_sar_den
=
scratch
.
i_sar_num
;
}
unsigned
int
delta_y
=
scratch
.
i_height
-
scratch
.
i_visible_height
-
scratch
.
i_y_offset
;
unsigned
int
delta_x
=
scratch
.
i_width
-
scratch
.
i_visible_width
-
scratch
.
i_x_offset
;
switch
(
transform
)
{
case
TRANSFORM_R90
:
fmt
->
i_x_offset
=
delta_y
;
fmt
->
i_y_offset
=
scratch
.
i_x_offset
;
break
;
case
TRANSFORM_R180
:
fmt
->
i_x_offset
=
delta_x
;
fmt
->
i_y_offset
=
delta_y
;
break
;
case
TRANSFORM_R270
:
fmt
->
i_x_offset
=
scratch
.
i_y_offset
;
fmt
->
i_y_offset
=
delta_x
;
break
;
case
TRANSFORM_HFLIP
:
fmt
->
i_x_offset
=
delta_x
;
break
;
case
TRANSFORM_VFLIP
:
fmt
->
i_y_offset
=
delta_y
;
break
;
case
TRANSFORM_TRANSPOSE
:
fmt
->
i_x_offset
=
scratch
.
i_y_offset
;
fmt
->
i_y_offset
=
scratch
.
i_x_offset
;
break
;
case
TRANSFORM_ANTI_TRANSPOSE
:
fmt
->
i_x_offset
=
delta_y
;
fmt
->
i_y_offset
=
delta_x
;
break
;
}
fmt
->
orientation
=
dst_orient
;
}
void
video_format_ApplyRotation
(
const
video_format_t
*
restrict
in
,
video_format_t
*
restrict
out
)
{
*
out
=
*
in
;
video_format_TransformTo
(
out
,
ORIENT_NORMAL
);
}
bool
video_format_IsSimilar
(
const
video_format_t
*
p_fmt1
,
const
video_format_t
*
p_fmt2
)
bool
video_format_IsSimilar
(
const
video_format_t
*
p_fmt1
,
const
video_format_t
*
p_fmt2
)
{
{
video_format_t
v1
=
*
p_fmt1
;
video_format_t
v1
=
*
p_fmt1
;
...
...
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