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
df4003fd
Unverified
Commit
df4003fd
authored
Dec 01, 2020
by
Francisco Massa
Committed by
GitHub
Dec 01, 2020
Browse files
add UUID in LOG() in decoder (#3080)
* add UUID in LOG() in decoder * Fix lint * More lint
parent
9fc6522d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
15 deletions
+28
-15
torchvision/csrc/cpu/decoder/decoder.cpp
torchvision/csrc/cpu/decoder/decoder.cpp
+28
-15
No files found.
torchvision/csrc/cpu/decoder/decoder.cpp
View file @
df4003fd
...
@@ -149,7 +149,8 @@ bool Decoder::enableLogLevel(int level) const {
...
@@ -149,7 +149,8 @@ bool Decoder::enableLogLevel(int level) const {
}
}
void
Decoder
::
logCallback
(
int
level
,
const
std
::
string
&
message
)
{
void
Decoder
::
logCallback
(
int
level
,
const
std
::
string
&
message
)
{
LOG
(
INFO
)
<<
"Msg, level: "
<<
level
<<
", msg: "
<<
message
;
LOG
(
INFO
)
<<
"Msg, uuid="
<<
params_
.
loggingUuid
<<
" level="
<<
level
<<
" msg="
<<
message
;
}
}
/* static */
/* static */
...
@@ -221,8 +222,9 @@ bool Decoder::init(
...
@@ -221,8 +222,9 @@ bool Decoder::init(
cleanUp
();
cleanUp
();
if
((
params
.
uri
.
empty
()
||
in
)
&&
(
!
params
.
uri
.
empty
()
||
!
in
))
{
if
((
params
.
uri
.
empty
()
||
in
)
&&
(
!
params
.
uri
.
empty
()
||
!
in
))
{
LOG
(
ERROR
)
<<
"Either external URI gets provided"
LOG
(
ERROR
)
<<
" or explicit input callback"
;
<<
"uuid="
<<
params_
.
loggingUuid
<<
" either external URI gets provided or explicit input callback"
;
return
false
;
return
false
;
}
}
...
@@ -230,7 +232,8 @@ bool Decoder::init(
...
@@ -230,7 +232,8 @@ bool Decoder::init(
params_
=
params
;
params_
=
params
;
if
(
!
(
inputCtx_
=
avformat_alloc_context
()))
{
if
(
!
(
inputCtx_
=
avformat_alloc_context
()))
{
LOG
(
ERROR
)
<<
"Cannot allocate format context"
;
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" cannot allocate format context"
;
return
false
;
return
false
;
}
}
...
@@ -243,7 +246,8 @@ bool Decoder::init(
...
@@ -243,7 +246,8 @@ bool Decoder::init(
params_
.
timeoutMs
,
params_
.
timeoutMs
,
params_
.
maxSeekableBytes
,
params_
.
maxSeekableBytes
,
params_
.
isImage
?
&
type
:
nullptr
))
<
0
)
{
params_
.
isImage
?
&
type
:
nullptr
))
<
0
)
{
LOG
(
ERROR
)
<<
"can't initiate seekable buffer"
;
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" can't initiate seekable buffer"
;
cleanUp
();
cleanUp
();
return
false
;
return
false
;
}
}
...
@@ -271,7 +275,8 @@ bool Decoder::init(
...
@@ -271,7 +275,8 @@ bool Decoder::init(
uint8_t
*
avioCtxBuffer
=
uint8_t
*
avioCtxBuffer
=
(
uint8_t
*
)
av_malloc
(
avioCtxBufferSize
+
kIoPaddingSize
);
(
uint8_t
*
)
av_malloc
(
avioCtxBufferSize
+
kIoPaddingSize
);
if
(
!
avioCtxBuffer
)
{
if
(
!
avioCtxBuffer
)
{
LOG
(
ERROR
)
<<
"av_malloc cannot allocate "
<<
avioCtxBufferSize
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" av_malloc cannot allocate "
<<
avioCtxBufferSize
<<
" bytes"
;
<<
" bytes"
;
cleanUp
();
cleanUp
();
return
false
;
return
false
;
...
@@ -285,7 +290,8 @@ bool Decoder::init(
...
@@ -285,7 +290,8 @@ bool Decoder::init(
&
Decoder
::
readFunction
,
&
Decoder
::
readFunction
,
nullptr
,
nullptr
,
result
==
1
?
&
Decoder
::
seekFunction
:
nullptr
)))
{
result
==
1
?
&
Decoder
::
seekFunction
:
nullptr
)))
{
LOG
(
ERROR
)
<<
"avio_alloc_context failed"
;
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" avio_alloc_context failed"
;
av_free
(
avioCtxBuffer
);
av_free
(
avioCtxBuffer
);
cleanUp
();
cleanUp
();
return
false
;
return
false
;
...
@@ -323,7 +329,8 @@ bool Decoder::init(
...
@@ -323,7 +329,8 @@ bool Decoder::init(
guard
=
std
::
make_unique
<
std
::
thread
>
([
&
f
,
this
]()
{
guard
=
std
::
make_unique
<
std
::
thread
>
([
&
f
,
this
]()
{
auto
timeout
=
std
::
chrono
::
milliseconds
(
params_
.
timeoutMs
);
auto
timeout
=
std
::
chrono
::
milliseconds
(
params_
.
timeoutMs
);
if
(
std
::
future_status
::
timeout
==
f
.
wait_for
(
timeout
))
{
if
(
std
::
future_status
::
timeout
==
f
.
wait_for
(
timeout
))
{
LOG
(
ERROR
)
<<
"Cannot open stream within "
<<
params_
.
timeoutMs
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" cannot open stream within "
<<
params_
.
timeoutMs
<<
" ms"
;
<<
" ms"
;
interrupted_
=
true
;
interrupted_
=
true
;
}
}
...
@@ -346,7 +353,8 @@ bool Decoder::init(
...
@@ -346,7 +353,8 @@ bool Decoder::init(
}
}
if
(
result
<
0
||
interrupted_
)
{
if
(
result
<
0
||
interrupted_
)
{
LOG
(
ERROR
)
<<
"avformat_open_input failed, error: "
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" avformat_open_input failed, error="
<<
Util
::
generateErrorDesc
(
result
);
<<
Util
::
generateErrorDesc
(
result
);
cleanUp
();
cleanUp
();
return
false
;
return
false
;
...
@@ -355,14 +363,15 @@ bool Decoder::init(
...
@@ -355,14 +363,15 @@ bool Decoder::init(
result
=
avformat_find_stream_info
(
inputCtx_
,
nullptr
);
result
=
avformat_find_stream_info
(
inputCtx_
,
nullptr
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
LOG
(
ERROR
)
<<
"avformat_find_stream_info failed, error: "
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" avformat_find_stream_info failed, error="
<<
Util
::
generateErrorDesc
(
result
);
<<
Util
::
generateErrorDesc
(
result
);
cleanUp
();
cleanUp
();
return
false
;
return
false
;
}
}
if
(
!
openStreams
(
metadata
))
{
if
(
!
openStreams
(
metadata
))
{
LOG
(
ERROR
)
<<
"
C
annot activate streams"
;
LOG
(
ERROR
)
<<
"
uuid="
<<
params_
.
loggingUuid
<<
" c
annot activate streams"
;
cleanUp
();
cleanUp
();
return
false
;
return
false
;
}
}
...
@@ -418,7 +427,8 @@ bool Decoder::openStreams(std::vector<DecoderMetadata>* metadata) {
...
@@ -418,7 +427,8 @@ bool Decoder::openStreams(std::vector<DecoderMetadata>* metadata) {
params_
.
loggingUuid
);
params_
.
loggingUuid
);
CHECK
(
stream
);
CHECK
(
stream
);
if
(
stream
->
openCodec
(
metadata
)
<
0
)
{
if
(
stream
->
openCodec
(
metadata
)
<
0
)
{
LOG
(
ERROR
)
<<
"Cannot open codec "
<<
i
;
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" open codec failed, stream_idx="
<<
i
;
return
false
;
return
false
;
}
}
streams_
.
emplace
(
i
,
std
::
move
(
stream
));
streams_
.
emplace
(
i
,
std
::
move
(
stream
));
...
@@ -518,13 +528,15 @@ int Decoder::getFrame(size_t workingTimeInMs) {
...
@@ -518,13 +528,15 @@ int Decoder::getFrame(size_t workingTimeInMs) {
bool
hasMsg
=
false
;
bool
hasMsg
=
false
;
// packet either got consumed completely or not at all
// packet either got consumed completely or not at all
if
((
result
=
processPacket
(
stream
,
&
avPacket
,
&
gotFrame
,
&
hasMsg
))
<
0
)
{
if
((
result
=
processPacket
(
stream
,
&
avPacket
,
&
gotFrame
,
&
hasMsg
))
<
0
)
{
LOG
(
ERROR
)
<<
"processPacket failed with code: "
<<
result
;
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" processPacket failed with code="
<<
result
;
break
;
break
;
}
}
if
(
!
gotFrame
&&
params_
.
maxProcessNoBytes
!=
0
&&
if
(
!
gotFrame
&&
params_
.
maxProcessNoBytes
!=
0
&&
++
numConsecutiveNoBytes
>
params_
.
maxProcessNoBytes
)
{
++
numConsecutiveNoBytes
>
params_
.
maxProcessNoBytes
)
{
LOG
(
ERROR
)
<<
"Exceeding max amount of consecutive no bytes"
;
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" exceeding max amount of consecutive no bytes"
;
break
;
break
;
}
}
if
(
result
>
0
)
{
if
(
result
>
0
)
{
...
@@ -538,7 +550,8 @@ int Decoder::getFrame(size_t workingTimeInMs) {
...
@@ -538,7 +550,8 @@ int Decoder::getFrame(size_t workingTimeInMs) {
if
(
result
<
0
)
{
if
(
result
<
0
)
{
if
(
params_
.
maxPackageErrors
!=
0
&&
// check errors
if
(
params_
.
maxPackageErrors
!=
0
&&
// check errors
++
decodingErrors
>=
params_
.
maxPackageErrors
)
{
// reached the limit
++
decodingErrors
>=
params_
.
maxPackageErrors
)
{
// reached the limit
LOG
(
ERROR
)
<<
"Exceeding max amount of consecutive package errors"
;
LOG
(
ERROR
)
<<
"uuid="
<<
params_
.
loggingUuid
<<
" exceeding max amount of consecutive package errors"
;
break
;
break
;
}
}
}
else
{
}
else
{
...
...
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