Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
3c254fb7
Unverified
Commit
3c254fb7
authored
Mar 24, 2020
by
Francisco Massa
Committed by
GitHub
Mar 24, 2020
Browse files
Fix C++ lint (#2009)
* Fix C++ lint * More fixes
parent
249f5479
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
34 deletions
+38
-34
torchvision/csrc/cpu/decoder/defs.h
torchvision/csrc/cpu/decoder/defs.h
+6
-3
torchvision/csrc/cpu/decoder/util.cpp
torchvision/csrc/cpu/decoder/util.cpp
+5
-6
torchvision/csrc/cpu/decoder/util_test.cpp
torchvision/csrc/cpu/decoder/util_test.cpp
+27
-25
No files found.
torchvision/csrc/cpu/decoder/defs.h
View file @
3c254fb7
...
@@ -53,9 +53,11 @@ struct VideoFormat {
...
@@ -53,9 +53,11 @@ struct VideoFormat {
When width = 0, height = 0, minDimension = 0, and maxDimension = 0,
When width = 0, height = 0, minDimension = 0, and maxDimension = 0,
keep the orignal frame resolution
keep the orignal frame resolution
When width = 0, height = 0, minDimension != 0, and maxDimension = 0,
When width = 0, height = 0, minDimension != 0, and maxDimension = 0,
keep the aspect ratio and resize the frame so that shorter edge size is minDimension
keep the aspect ratio and resize the frame so that shorter edge size is
minDimension
When width = 0, height = 0, minDimension = 0, and maxDimension != 0,
When width = 0, height = 0, minDimension = 0, and maxDimension != 0,
keep the aspect ratio and resize the frame so that longer edge size is maxDimension
keep the aspect ratio and resize the frame so that longer edge size is
maxDimension
When width = 0, height = 0, minDimension != 0, and maxDimension != 0,
When width = 0, height = 0, minDimension != 0, and maxDimension != 0,
resize the frame so that shorter edge size is minDimension, and
resize the frame so that shorter edge size is minDimension, and
longer edge size is maxDimension. The aspect ratio may not be preserved
longer edge size is maxDimension. The aspect ratio may not be preserved
...
@@ -64,7 +66,8 @@ struct VideoFormat {
...
@@ -64,7 +66,8 @@ struct VideoFormat {
When width != 0, height = 0, minDimension = 0, and maxDimension = 0,
When width != 0, height = 0, minDimension = 0, and maxDimension = 0,
keep the aspect ratio and resize the frame so that frame width is $width
keep the aspect ratio and resize the frame so that frame width is $width
When width != 0, height != 0, minDimension = 0, and maxDimension = 0,
When width != 0, height != 0, minDimension = 0, and maxDimension = 0,
resize the frame so that frame width and height are set to $width and $height,
resize the frame so that frame width and height are set to $width and
$height,
respectively
respectively
*/
*/
size_t
width
{
0
};
// width in pixels
size_t
width
{
0
};
// width in pixels
...
...
torchvision/csrc/cpu/decoder/util.cpp
View file @
3c254fb7
...
@@ -284,6 +284,7 @@ size_t size(const AVSubtitle& sub) {
...
@@ -284,6 +284,7 @@ size_t size(const AVSubtitle& sub) {
}
}
bool
validateVideoFormat
(
const
VideoFormat
&
f
)
{
bool
validateVideoFormat
(
const
VideoFormat
&
f
)
{
// clang-format off
/*
/*
Valid parameters values for decoder
Valid parameters values for decoder
____________________________________________________________________________________
____________________________________________________________________________________
...
@@ -307,6 +308,7 @@ bool validateVideoFormat(const VideoFormat& f) {
...
@@ -307,6 +308,7 @@ bool validateVideoFormat(const VideoFormat& f) {
|_____|_____|______________|______________|___________|____________________________|
|_____|_____|______________|______________|___________|____________________________|
*/
*/
// clang-format on
return
(
f
.
width
==
0
&&
// #1, #6, #7 and #8
return
(
f
.
width
==
0
&&
// #1, #6, #7 and #8
f
.
height
==
0
&&
f
.
cropImage
==
0
)
||
f
.
height
==
0
&&
f
.
cropImage
==
0
)
||
(
f
.
width
!=
0
&&
// #4 and #5
(
f
.
width
!=
0
&&
// #4 and #5
...
@@ -346,8 +348,7 @@ void setFormatDimensions(
...
@@ -346,8 +348,7 @@ void setFormatDimensions(
destW
=
minDimension
;
destW
=
minDimension
;
destH
=
round
(
double
(
srcH
*
minDimension
)
/
srcW
);
destH
=
round
(
double
(
srcH
*
minDimension
)
/
srcW
);
}
}
}
}
else
if
(
minDimension
==
0
&&
maxDimension
>
0
)
{
// #7
else
if
(
minDimension
==
0
&&
maxDimension
>
0
)
{
// #7
if
(
srcW
>
srcH
)
{
if
(
srcW
>
srcH
)
{
// landscape
// landscape
destW
=
maxDimension
;
destW
=
maxDimension
;
...
@@ -357,8 +358,7 @@ void setFormatDimensions(
...
@@ -357,8 +358,7 @@ void setFormatDimensions(
destH
=
maxDimension
;
destH
=
maxDimension
;
destW
=
round
(
double
(
srcW
*
maxDimension
)
/
srcH
);
destW
=
round
(
double
(
srcW
*
maxDimension
)
/
srcH
);
}
}
}
}
else
if
(
minDimension
>
0
&&
maxDimension
>
0
)
{
// #8
else
if
(
minDimension
>
0
&&
maxDimension
>
0
)
{
// #8
if
(
srcW
>
srcH
)
{
if
(
srcW
>
srcH
)
{
// landscape
// landscape
destW
=
maxDimension
;
destW
=
maxDimension
;
...
@@ -368,8 +368,7 @@ void setFormatDimensions(
...
@@ -368,8 +368,7 @@ void setFormatDimensions(
destW
=
minDimension
;
destW
=
minDimension
;
destH
=
maxDimension
;
destH
=
maxDimension
;
}
}
}
}
else
{
// #1
else
{
// #1
destW
=
srcW
;
destW
=
srcW
;
destH
=
srcH
;
destH
=
srcH
;
}
}
...
...
torchvision/csrc/cpu/decoder/util_test.cpp
View file @
3c254fb7
...
@@ -4,30 +4,32 @@
...
@@ -4,30 +4,32 @@
#include "util.h"
#include "util.h"
TEST
(
Util
,
TestSetFormatDimensions
)
{
TEST
(
Util
,
TestSetFormatDimensions
)
{
const
size_t
test_cases
[][
9
]
=
{
// clang-format off
// (userW, userH, srcW, srcH, minDimension, maxDimension, cropImage, destW, destH)
const
size_t
test_cases
[][
9
]
=
{
{
0
,
0
,
172
,
128
,
0
,
0
,
0
,
172
,
128
},
// #1
// (userW, userH, srcW, srcH, minDimension, maxDimension, cropImage, destW, destH)
{
86
,
0
,
172
,
128
,
0
,
0
,
0
,
86
,
64
},
// #2
{
0
,
0
,
172
,
128
,
0
,
0
,
0
,
172
,
128
},
// #1
{
64
,
0
,
128
,
172
,
0
,
0
,
0
,
64
,
86
},
// #2
{
86
,
0
,
172
,
128
,
0
,
0
,
0
,
86
,
64
},
// #2
{
0
,
32
,
172
,
128
,
0
,
0
,
0
,
43
,
32
},
// #3
{
64
,
0
,
128
,
172
,
0
,
0
,
0
,
64
,
86
},
// #2
{
32
,
0
,
128
,
172
,
0
,
0
,
0
,
32
,
43
},
// #3
{
0
,
32
,
172
,
128
,
0
,
0
,
0
,
43
,
32
},
// #3
{
60
,
50
,
172
,
128
,
0
,
0
,
0
,
60
,
50
},
// #4
{
32
,
0
,
128
,
172
,
0
,
0
,
0
,
32
,
43
},
// #3
{
50
,
60
,
128
,
172
,
0
,
0
,
0
,
50
,
60
},
// #4
{
60
,
50
,
172
,
128
,
0
,
0
,
0
,
60
,
50
},
// #4
{
86
,
40
,
172
,
128
,
0
,
0
,
1
,
86
,
64
},
// #5
{
50
,
60
,
128
,
172
,
0
,
0
,
0
,
50
,
60
},
// #4
{
86
,
92
,
172
,
128
,
0
,
0
,
1
,
124
,
92
},
// #5
{
86
,
40
,
172
,
128
,
0
,
0
,
1
,
86
,
64
},
// #5
{
0
,
0
,
172
,
128
,
256
,
0
,
0
,
344
,
256
},
// #6
{
86
,
92
,
172
,
128
,
0
,
0
,
1
,
124
,
92
},
// #5
{
0
,
0
,
128
,
172
,
256
,
0
,
0
,
256
,
344
},
// #6
{
0
,
0
,
172
,
128
,
256
,
0
,
0
,
344
,
256
},
// #6
{
0
,
0
,
128
,
172
,
0
,
344
,
0
,
256
,
344
},
// #7
{
0
,
0
,
128
,
172
,
256
,
0
,
0
,
256
,
344
},
// #6
{
0
,
0
,
172
,
128
,
0
,
344
,
0
,
344
,
256
},
// #7
{
0
,
0
,
128
,
172
,
0
,
344
,
0
,
256
,
344
},
// #7
{
0
,
0
,
172
,
128
,
100
,
344
,
0
,
344
,
100
},
// #8
{
0
,
0
,
172
,
128
,
0
,
344
,
0
,
344
,
256
},
// #7
{
0
,
0
,
128
,
172
,
100
,
344
,
0
,
100
,
344
}
// #8
{
0
,
0
,
172
,
128
,
100
,
344
,
0
,
344
,
100
},
// #8
};
{
0
,
0
,
128
,
172
,
100
,
344
,
0
,
100
,
344
}
// #8
};
// clang-format onn
for
(
const
auto
&
tc
:
test_cases
)
{
for
(
const
auto
&
tc
:
test_cases
)
{
size_t
destW
=
0
;
size_t
destW
=
0
;
size_t
destH
=
0
;
size_t
destH
=
0
;
ffmpeg
::
Util
::
setFormatDimensions
(
destW
,
destH
,
tc
[
0
],
tc
[
1
],
tc
[
2
],
tc
[
3
],
tc
[
4
],
tc
[
5
],
tc
[
6
]);
ffmpeg
::
Util
::
setFormatDimensions
(
destW
,
destH
,
tc
[
0
],
tc
[
1
],
tc
[
2
],
tc
[
3
],
tc
[
4
],
tc
[
5
],
tc
[
6
]);
CHECK
(
destW
==
tc
[
7
]);
CHECK
(
destW
==
tc
[
7
]);
CHECK
(
destH
==
tc
[
8
]);
CHECK
(
destH
==
tc
[
8
]);
}
}
}
}
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