Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
ecb8f736
Commit
ecb8f736
authored
Oct 31, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: copy_interleave_frame() throws exception on error
parent
17ccfec3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
16 deletions
+14
-16
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+14
-16
No files found.
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
ecb8f736
...
...
@@ -150,12 +150,13 @@ start_time_fallback(const AVStream &stream)
/**
* Copy PCM data from a non-empty AVFrame to an interleaved buffer.
*
* Throws #std::exception on error.
*/
static
ConstBuffer
<
void
>
copy_interleave_frame
(
const
AVCodecContext
&
codec_context
,
const
AVFrame
&
frame
,
FfmpegBuffer
&
global_buffer
,
Error
&
error
)
FfmpegBuffer
&
global_buffer
)
{
assert
(
frame
.
nb_samples
>
0
);
...
...
@@ -166,20 +167,16 @@ copy_interleave_frame(const AVCodecContext &codec_context,
frame
.
nb_samples
,
codec_context
.
sample_fmt
,
1
);
assert
(
data_size
!=
0
);
if
(
data_size
<
0
)
{
SetFfmpegError
(
error
,
data_size
);
return
0
;
}
if
(
data_size
<
0
)
throw
MakeFfmpegError
(
data_size
);
void
*
output_buffer
;
if
(
av_sample_fmt_is_planar
(
codec_context
.
sample_fmt
)
&&
codec_context
.
channels
>
1
)
{
output_buffer
=
global_buffer
.
GetT
<
uint8_t
>
(
data_size
);
if
(
output_buffer
==
nullptr
)
{
if
(
output_buffer
==
nullptr
)
/* Not enough memory - shouldn't happen */
error
.
SetErrno
(
ENOMEM
);
return
0
;
}
throw
std
::
bad_alloc
();
PcmInterleave
(
output_buffer
,
ConstBuffer
<
const
void
*>
((
const
void
*
const
*
)
frame
.
extended_data
,
...
...
@@ -231,13 +228,14 @@ FfmpegSendFrame(Decoder &decoder, InputStream &is,
size_t
&
skip_bytes
,
FfmpegBuffer
&
buffer
)
{
Error
error
;
auto
output_buffer
=
copy_interleave_frame
(
codec_context
,
frame
,
buffer
,
error
);
if
(
output_buffer
.
IsNull
())
{
ConstBuffer
<
void
>
output_buffer
;
try
{
output_buffer
=
copy_interleave_frame
(
codec_context
,
frame
,
buffer
);
}
catch
(
const
std
::
exception
e
)
{
/* this must be a serious error, e.g. OOM */
LogError
(
e
rror
);
LogError
(
e
);
return
DecoderCommand
::
STOP
;
}
...
...
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