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
2b9246c6
Commit
2b9246c6
authored
Jul 27, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: use avcodec_send_packet() and avcodec_receive_frame() on FFmpeg 3.1
parent
a9edb4de
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
0 deletions
+79
-0
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+79
-0
No files found.
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
2b9246c6
...
...
@@ -251,6 +251,54 @@ FfmpegSendFrame(Decoder &decoder, InputStream &is,
codec_context
.
bit_rate
/
1000
);
}
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 0)
static
DecoderCommand
FfmpegReceiveFrames
(
Decoder
&
decoder
,
InputStream
&
is
,
AVCodecContext
&
codec_context
,
AVFrame
&
frame
,
size_t
&
skip_bytes
,
FfmpegBuffer
&
buffer
,
bool
&
eof
)
{
while
(
true
)
{
DecoderCommand
cmd
;
int
err
=
avcodec_receive_frame
(
&
codec_context
,
&
frame
);
switch
(
err
)
{
case
0
:
cmd
=
FfmpegSendFrame
(
decoder
,
is
,
codec_context
,
frame
,
skip_bytes
,
buffer
);
if
(
cmd
!=
DecoderCommand
::
NONE
)
return
cmd
;
break
;
case
AVERROR_EOF
:
eof
=
true
;
return
DecoderCommand
::
NONE
;
case
AVERROR
(
EAGAIN
):
/* need to call avcodec_send_packet() */
return
DecoderCommand
::
NONE
;
default
:
{
char
msg
[
256
];
av_strerror
(
err
,
msg
,
sizeof
(
msg
));
FormatWarning
(
ffmpeg_domain
,
"avcodec_send_packet() failed: %s"
,
msg
);
}
return
DecoderCommand
::
STOP
;
}
}
}
#endif
/**
* Decode an #AVPacket and send the resulting PCM data to the decoder
* API.
...
...
@@ -283,6 +331,36 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
stream
.
time_base
));
}
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 0)
bool
eof
=
false
;
int
err
=
avcodec_send_packet
(
&
codec_context
,
&
packet
);
switch
(
err
)
{
case
0
:
break
;
case
AVERROR_EOF
:
eof
=
true
;
break
;
default
:
{
char
msg
[
256
];
av_strerror
(
err
,
msg
,
sizeof
(
msg
));
FormatWarning
(
ffmpeg_domain
,
"avcodec_send_packet() failed: %s"
,
msg
);
}
return
DecoderCommand
::
NONE
;
}
auto
cmd
=
FfmpegReceiveFrames
(
decoder
,
is
,
codec_context
,
frame
,
skip_bytes
,
buffer
,
eof
);
if
(
eof
)
cmd
=
DecoderCommand
::
STOP
;
#else
DecoderCommand
cmd
=
DecoderCommand
::
NONE
;
while
(
packet
.
size
>
0
&&
cmd
==
DecoderCommand
::
NONE
)
{
int
got_frame
=
0
;
...
...
@@ -305,6 +383,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
frame
,
skip_bytes
,
buffer
);
}
#endif
return
cmd
;
}
...
...
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