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
aa61f219
Commit
aa61f219
authored
Jul 28, 2010
by
Laurent Aimar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed invalid assumption about picture pitches in rotate filter.
It may segfault or create a broken image.
parent
4907ca61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
29 deletions
+30
-29
modules/video_filter/rotate.c
modules/video_filter/rotate.c
+30
-29
No files found.
modules/video_filter/rotate.c
View file @
aa61f219
...
@@ -187,10 +187,11 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
...
@@ -187,10 +187,11 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
for
(
int
i_plane
=
0
;
i_plane
<
p_pic
->
i_planes
;
i_plane
++
)
for
(
int
i_plane
=
0
;
i_plane
<
p_pic
->
i_planes
;
i_plane
++
)
{
{
const
int
i_visible_lines
=
p_pic
->
p
[
i_plane
].
i_visible_lines
;
plane_t
*
p_srcp
=
&
p_pic
->
p
[
i_plane
];
const
int
i_visible_pitch
=
p_pic
->
p
[
i_plane
].
i_visible_pitch
;
plane_t
*
p_dstp
=
&
p_outpic
->
p
[
i_plane
];
const
int
i_pitch
=
p_pic
->
p
[
i_plane
].
i_pitch
;
const
int
i_hidden_pitch
=
i_pitch
-
i_visible_pitch
;
const
int
i_visible_lines
=
p_srcp
->
i_visible_lines
;
const
int
i_visible_pitch
=
p_srcp
->
i_visible_pitch
;
const
int
i_aspect
=
__MAX
(
1
,
(
i_visible_lines
*
p_pic
->
p
[
Y_PLANE
].
i_visible_pitch
)
/
(
p_pic
->
p
[
Y_PLANE
].
i_visible_lines
*
i_visible_pitch
));
const
int
i_aspect
=
__MAX
(
1
,
(
i_visible_lines
*
p_pic
->
p
[
Y_PLANE
].
i_visible_pitch
)
/
(
p_pic
->
p
[
Y_PLANE
].
i_visible_lines
*
i_visible_pitch
));
/* = 2 for U and V planes in YUV 4:2:2, = 1 otherwise */
/* = 2 for U and V planes in YUV 4:2:2, = 1 otherwise */
...
@@ -198,11 +199,6 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
...
@@ -198,11 +199,6 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
const
int
i_line_center
=
i_visible_lines
>>
1
;
const
int
i_line_center
=
i_visible_lines
>>
1
;
const
int
i_col_center
=
i_visible_pitch
>>
1
;
const
int
i_col_center
=
i_visible_pitch
>>
1
;
const
uint8_t
*
p_in
=
p_pic
->
p
[
i_plane
].
p_pixels
;
uint8_t
*
p_out
=
p_outpic
->
p
[
i_plane
].
p_pixels
;
uint8_t
*
p_outendline
=
p_out
+
i_visible_pitch
;
const
uint8_t
*
p_outend
=
p_out
+
i_visible_lines
*
i_pitch
;
const
uint8_t
black_pixel
=
(
i_plane
==
Y_PLANE
)
?
0x00
:
0x80
;
const
uint8_t
black_pixel
=
(
i_plane
==
Y_PLANE
)
?
0x00
:
0x80
;
const
int
i_line_next
=
i_cos
/
i_aspect
-
i_sin
*
i_visible_pitch
;
const
int
i_line_next
=
i_cos
/
i_aspect
-
i_sin
*
i_visible_pitch
;
...
@@ -211,17 +207,15 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
...
@@ -211,17 +207,15 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
-
i_sin
*
i_col_center
+
(
1
<<
11
)
);
-
i_sin
*
i_col_center
+
(
1
<<
11
)
);
int
i_col_orig0
=
i_sin
*
i_line_center
/
i_aspect
int
i_col_orig0
=
i_sin
*
i_line_center
/
i_aspect
-
i_cos
*
i_col_center
+
(
1
<<
11
);
-
i_cos
*
i_col_center
+
(
1
<<
11
);
for
(
;
p_outendline
<
p_outend
;
for
(
int
y
=
0
;
y
<
i_visible_lines
;
y
++
)
p_out
+=
i_hidden_pitch
,
p_outendline
+=
i_pitch
,
i_line_orig0
+=
i_line_next
,
i_col_orig0
+=
i_col_next
)
{
{
for
(
;
p_out
<
p_outendline
;
uint8_t
*
p_out
=
&
p_dstp
->
p_pixels
[
y
*
p_dstp
->
i_pitch
];
p_out
++
,
i_line_orig0
+=
i_sin
,
i_col_orig0
+=
i_cos
)
for
(
int
x
=
0
;
x
<
i_visible_pitch
;
x
++
,
p_out
++
)
{
{
const
int
i_line_orig
=
(
i_line_orig0
>>
12
)
*
i_aspect
+
i_line_center
;
const
int
i_line_orig
=
(
i_line_orig0
>>
12
)
*
i_aspect
+
i_line_center
;
const
int
i_col_orig
=
(
i_col_orig0
>>
12
)
+
i_col_center
;
const
int
i_col_orig
=
(
i_col_orig0
>>
12
)
+
i_col_center
;
const
uint8_t
*
p_orig_offset
=
p_in
+
i_line_orig
*
i_pitch
const
uint8_t
*
p_orig_offset
=
&
p_srcp
->
p_pixels
[
i_line_orig
*
p_srcp
->
i_pitch
+
i_col_orig
];
+
i_col_orig
;
const
uint8_t
i_line_percent
=
(
i_line_orig0
>>
4
)
&
255
;
const
uint8_t
i_line_percent
=
(
i_line_orig0
>>
4
)
&
255
;
const
uint8_t
i_col_percent
=
(
i_col_orig0
>>
4
)
&
255
;
const
uint8_t
i_col_percent
=
(
i_col_orig0
>>
4
)
&
255
;
...
@@ -246,7 +240,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
...
@@ -246,7 +240,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
&&
(
i_line_orig
>=
0
)
)
&&
(
i_line_orig
>=
0
)
)
i_colpix
=
*
p_orig_offset
;
i_colpix
=
*
p_orig_offset
;
p_orig_offset
+=
i_pitch
;
p_orig_offset
+=
p_srcp
->
i_pitch
;
if
(
(
i_line_orig
<
i_visible_lines
-
1
)
if
(
(
i_line_orig
<
i_visible_lines
-
1
)
&&
(
i_col_orig
<
i_visible_pitch
-
1
)
)
&&
(
i_col_orig
<
i_visible_pitch
-
1
)
)
i_nexpix
=
*
p_orig_offset
;
i_nexpix
=
*
p_orig_offset
;
...
@@ -280,7 +274,13 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
...
@@ -280,7 +274,13 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
{
{
*
p_out
=
black_pixel
;
*
p_out
=
black_pixel
;
}
}
i_line_orig0
+=
i_sin
;
i_col_orig0
+=
i_cos
;
}
}
i_line_orig0
+=
i_line_next
;
i_col_orig0
+=
i_col_next
;
}
}
}
}
...
@@ -315,17 +315,18 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
...
@@ -315,17 +315,18 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
return
NULL
;
return
NULL
;
}
}
const
int
i_visible_pitch
=
p_pic
->
p
->
i_visible_pitch
>>
1
;
/* In fact it's i_visible_pixels */
const
int
i_visible_lines
=
p_pic
->
p
->
i_visible_lines
;
const
uint8_t
*
p_in
=
p_pic
->
p
->
p_pixels
+
i_y_offset
;
const
uint8_t
*
p_in
=
p_pic
->
p
->
p_pixels
+
i_y_offset
;
const
uint8_t
*
p_in_u
=
p_pic
->
p
->
p_pixels
+
i_u_offset
;
const
uint8_t
*
p_in_u
=
p_pic
->
p
->
p_pixels
+
i_u_offset
;
const
uint8_t
*
p_in_v
=
p_pic
->
p
->
p_pixels
+
i_v_offset
;
const
uint8_t
*
p_in_v
=
p_pic
->
p
->
p_pixels
+
i_v_offset
;
const
int
i_in_pitch
=
p_pic
->
p
->
i_pitch
;
const
int
i_pitch
=
p_pic
->
p
->
i_pitch
;
const
int
i_visible_pitch
=
p_pic
->
p
->
i_visible_pitch
>>
1
;
/* In fact it's i_visible_pixels */
const
int
i_visible_lines
=
p_pic
->
p
->
i_visible_lines
;
uint8_t
*
p_out
=
p_outpic
->
p
->
p_pixels
+
i_y_offset
;
uint8_t
*
p_out
=
p_outpic
->
p
->
p_pixels
+
i_y_offset
;
uint8_t
*
p_out_u
=
p_outpic
->
p
->
p_pixels
+
i_u_offset
;
uint8_t
*
p_out_u
=
p_outpic
->
p
->
p_pixels
+
i_u_offset
;
uint8_t
*
p_out_v
=
p_outpic
->
p
->
p_pixels
+
i_v_offset
;
uint8_t
*
p_out_v
=
p_outpic
->
p
->
p_pixels
+
i_v_offset
;
const
int
i_out_pitch
=
p_outpic
->
p
->
i_pitch
;
const
int
i_line_center
=
i_visible_lines
>>
1
;
const
int
i_line_center
=
i_visible_lines
>>
1
;
const
int
i_col_center
=
i_visible_pitch
>>
1
;
const
int
i_col_center
=
i_visible_pitch
>>
1
;
...
@@ -352,16 +353,16 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
...
@@ -352,16 +353,16 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
if
(
0
<=
i_col_orig
&&
i_col_orig
<
i_visible_pitch
if
(
0
<=
i_col_orig
&&
i_col_orig
<
i_visible_pitch
&&
0
<=
i_line_orig
&&
i_line_orig
<
i_visible_lines
)
&&
0
<=
i_line_orig
&&
i_line_orig
<
i_visible_lines
)
{
{
p_out
[
i_line
*
i_
pitch
+
2
*
i_col
]
=
p_in
[
i_line_orig
*
i
_pitch
+
2
*
i_col_orig
];
p_out
[
i_line
*
i_
out_pitch
+
2
*
i_col
]
=
p_in
[
i_line_orig
*
i_in
_pitch
+
2
*
i_col_orig
];
i_col_orig
/=
2
;
i_col_orig
/=
2
;
p_out_u
[
i_line
*
i_
pitch
+
2
*
i_col
]
=
p_in_u
[
i_line_orig
*
i
_pitch
+
4
*
i_col_orig
];
p_out_u
[
i_line
*
i_
out_pitch
+
2
*
i_col
]
=
p_in_u
[
i_line_orig
*
i_in
_pitch
+
4
*
i_col_orig
];
p_out_v
[
i_line
*
i_
pitch
+
2
*
i_col
]
=
p_in_v
[
i_line_orig
*
i
_pitch
+
4
*
i_col_orig
];
p_out_v
[
i_line
*
i_
out_pitch
+
2
*
i_col
]
=
p_in_v
[
i_line_orig
*
i_in
_pitch
+
4
*
i_col_orig
];
}
}
else
else
{
{
p_out
[
i_line
*
i_pitch
+
2
*
i_col
]
=
0x00
;
p_out
[
i_line
*
i_
out_
pitch
+
2
*
i_col
]
=
0x00
;
p_out_u
[
i_line
*
i_pitch
+
2
*
i_col
]
=
0x80
;
p_out_u
[
i_line
*
i_
out_
pitch
+
2
*
i_col
]
=
0x80
;
p_out_v
[
i_line
*
i_pitch
+
2
*
i_col
]
=
0x80
;
p_out_v
[
i_line
*
i_
out_
pitch
+
2
*
i_col
]
=
0x80
;
}
}
/* Handle "2nd Y" */
/* Handle "2nd Y" */
...
@@ -378,11 +379,11 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
...
@@ -378,11 +379,11 @@ static picture_t *FilterPacked( filter_t *p_filter, picture_t *p_pic )
if
(
0
<=
i_col_orig
&&
i_col_orig
<
i_visible_pitch
if
(
0
<=
i_col_orig
&&
i_col_orig
<
i_visible_pitch
&&
0
<=
i_line_orig
&&
i_line_orig
<
i_visible_lines
)
&&
0
<=
i_line_orig
&&
i_line_orig
<
i_visible_lines
)
{
{
p_out
[
i_line
*
i_
pitch
+
2
*
i_col
]
=
p_in
[
i_line_orig
*
i
_pitch
+
2
*
i_col_orig
];
p_out
[
i_line
*
i_
out_pitch
+
2
*
i_col
]
=
p_in
[
i_line_orig
*
i_in
_pitch
+
2
*
i_col_orig
];
}
}
else
else
{
{
p_out
[
i_line
*
i_pitch
+
2
*
i_col
]
=
0x00
;
p_out
[
i_line
*
i_
out_
pitch
+
2
*
i_col
]
=
0x00
;
}
}
}
}
}
}
...
...
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