minor tweaks

This commit is contained in:
David Rose 2011-11-17 02:23:56 +00:00
parent f6a0af6f8d
commit 3a05c89924
3 changed files with 58 additions and 39 deletions

View File

@ -997,10 +997,30 @@ seek(int frame, bool backward) {
PStatTimer timer(seek_pcollector);
if (ffmpeg_support_seek) {
// Protect the call to av_seek_frame() in a global lock, just to be
// paranoid.
if (ffmpeg_global_lock) {
ReMutexHolder av_holder(_av_lock);
do_seek(frame, backward);
} else {
do_seek(frame, backward);
}
} else {
// If seeking isn't supported, close-and-reopen.
if (backward) {
reset_stream();
}
}
}
////////////////////////////////////////////////////////////////////
// Function: FfmpegVideoCursor::do_seek
// Access: Private
// Description: As above, with the ffmpeg global lock held (if
// configured on). Also only if ffmpeg-support-seek is
// on.
////////////////////////////////////////////////////////////////////
void FfmpegVideoCursor::
do_seek(int frame, bool backward) {
PN_int64 target_ts = (PN_int64)frame;
if (target_ts < (PN_int64)(_initial_dts)) {
// Attempts to seek before the first packet will fail.
@ -1037,13 +1057,6 @@ seek(int frame, bool backward) {
fetch_packet(0);
fetch_frame(-1);
} else {
// If seeking isn't supported, close-and-reopen.
if (backward) {
reset_stream();
}
}
}
////////////////////////////////////////////////////////////////////

View File

@ -130,6 +130,7 @@ private:
void decode_frame(int &finished, AVPacket *packet);
void do_decode_frame(int &finished, AVPacket *packet);
void seek(int frame, bool backward);
void do_seek(int frame, bool backward);
int binary_seek(int min_frame, int max_frame, int target_frame, int num_iterations);
void advance_to_frame(int frame);
void reset_stream();

View File

@ -217,6 +217,11 @@ register_protocol() {
// function.
av_register_all();
// And this one.
#if LIBAVFORMAT_VERSION_INT >= 0x351400
avformat_network_init();
#endif
static URLProtocol protocol;
protocol.name = "pandavfs";
protocol.url_open = pandavfs_open;