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
70986bc1
Commit
70986bc1
authored
8 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: move code to FfmpegSendFrame()
parent
f31fe8b8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
26 deletions
+40
-26
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+40
-26
No files found.
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
70986bc1
...
...
@@ -174,6 +174,43 @@ PtsToPcmFrame(uint64_t pts, const AVStream &stream,
}
/**
* Invoke decoder_data() with the contents of an #AVFrame.
*/
static
DecoderCommand
FfmpegSendFrame
(
Decoder
&
decoder
,
InputStream
&
is
,
AVCodecContext
&
codec_context
,
const
AVFrame
&
frame
,
size_t
&
skip_bytes
,
FfmpegBuffer
&
buffer
)
{
Error
error
;
auto
output_buffer
=
copy_interleave_frame
(
codec_context
,
frame
,
buffer
,
error
);
if
(
output_buffer
.
IsNull
())
{
/* this must be a serious error, e.g. OOM */
LogError
(
error
);
return
DecoderCommand
::
STOP
;
}
if
(
skip_bytes
>
0
)
{
if
(
skip_bytes
>=
output_buffer
.
size
)
{
skip_bytes
-=
output_buffer
.
size
;
return
DecoderCommand
::
NONE
;
}
output_buffer
.
data
=
(
const
uint8_t
*
)
output_buffer
.
data
+
skip_bytes
;
output_buffer
.
size
-=
skip_bytes
;
skip_bytes
=
0
;
}
return
decoder_data
(
decoder
,
is
,
output_buffer
.
data
,
output_buffer
.
size
,
codec_context
.
bit_rate
/
1000
);
}
/**
* Decode an #AVPacket and send the resulting PCM data to the decoder
* API.
*
...
...
@@ -205,8 +242,6 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
stream
.
time_base
));
}
Error
error
;
DecoderCommand
cmd
=
DecoderCommand
::
NONE
;
while
(
packet
.
size
>
0
&&
cmd
==
DecoderCommand
::
NONE
)
{
int
got_frame
=
0
;
...
...
@@ -225,32 +260,11 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
if
(
!
got_frame
||
frame
.
nb_samples
<=
0
)
continue
;
auto
output_buffer
=
copy_interleave_frame
(
codec_context
,
frame
,
buffer
,
error
);
if
(
output_buffer
.
IsNull
())
{
/* this must be a serious error,
e.g. OOM */
LogError
(
error
);
return
DecoderCommand
::
STOP
;
}
if
(
skip_bytes
>
0
)
{
if
(
skip_bytes
>=
output_buffer
.
size
)
{
skip_bytes
-=
output_buffer
.
size
;
continue
;
}
output_buffer
.
data
=
(
const
uint8_t
*
)
output_buffer
.
data
+
skip_bytes
;
output_buffer
.
size
-=
skip_bytes
;
skip_bytes
=
0
;
cmd
=
FfmpegSendFrame
(
decoder
,
is
,
codec_context
,
frame
,
skip_bytes
,
buffer
);
}
cmd
=
decoder_data
(
decoder
,
is
,
output_buffer
.
data
,
output_buffer
.
size
,
codec_context
.
bit_rate
/
1000
);
}
return
cmd
;
}
...
...
This diff is collapsed.
Click to expand it.
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