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
4dd2ad9b
Commit
4dd2ad9b
authored
Jun 22, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: check for commands earlier
Improve initial seek by not reading/decoding the first frame before checking for the seek command.
parent
62f73758
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
23 deletions
+22
-23
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+22
-23
No files found.
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
4dd2ad9b
...
...
@@ -478,8 +478,27 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
uint64_t
min_frame
=
0
;
DecoderCommand
cmd
;
do
{
DecoderCommand
cmd
=
decoder_get_command
(
decoder
);
while
(
cmd
!=
DecoderCommand
::
STOP
)
{
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
int64_t
where
=
ToFfmpegTime
(
decoder_seek_time
(
decoder
),
av_stream
.
time_base
)
+
start_time_fallback
(
av_stream
);
/* AVSEEK_FLAG_BACKWARD asks FFmpeg to seek to
the packet boundary before the seek time
stamp, not after */
if
(
av_seek_frame
(
format_context
,
audio_stream
,
where
,
AVSEEK_FLAG_ANY
|
AVSEEK_FLAG_BACKWARD
)
<
0
)
decoder_seek_error
(
decoder
);
else
{
avcodec_flush_buffers
(
codec_context
);
min_frame
=
decoder_seek_where_frame
(
decoder
);
decoder_command_finished
(
decoder
);
}
}
AVPacket
packet
;
if
(
av_read_frame
(
format_context
,
&
packet
)
<
0
)
/* end of file */
...
...
@@ -502,27 +521,7 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
#else
av_free_packet
(
&
packet
);
#endif
if
(
cmd
==
DecoderCommand
::
SEEK
)
{
int64_t
where
=
ToFfmpegTime
(
decoder_seek_time
(
decoder
),
av_stream
.
time_base
)
+
start_time_fallback
(
av_stream
);
/* AVSEEK_FLAG_BACKWARD asks FFmpeg to seek to
the packet boundary before the seek time
stamp, not after */
if
(
av_seek_frame
(
format_context
,
audio_stream
,
where
,
AVSEEK_FLAG_ANY
|
AVSEEK_FLAG_BACKWARD
)
<
0
)
decoder_seek_error
(
decoder
);
else
{
avcodec_flush_buffers
(
codec_context
);
min_frame
=
decoder_seek_where_frame
(
decoder
);
decoder_command_finished
(
decoder
);
}
}
}
while
(
cmd
!=
DecoderCommand
::
STOP
);
}
#if LIBAVUTIL_VERSION_MAJOR >= 53
av_frame_free
(
&
frame
);
...
...
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