mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
hey, this time I really found the ffmpeg crash.
This commit is contained in:
parent
b421b037fe
commit
dca824b5de
@ -53,10 +53,12 @@ dec(TVOLATILE AtomicAdjustWin32Impl::Integer &var) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void AtomicAdjustWin32Impl::
|
||||
add(TVOLATILE AtomicAdjustWin32Impl::Integer &var, AtomicAdjustWin32Impl::Integer delta) {
|
||||
AtomicAdjustWin32Impl::Integer orig_value = var;
|
||||
while (compare_and_exchange(var, orig_value, orig_value + delta) != orig_value) {
|
||||
orig_value = var;
|
||||
}
|
||||
assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0);
|
||||
#ifdef _WIN64
|
||||
InterlockedAdd64(&var, delta);
|
||||
#else
|
||||
InterlockedAdd(&var, delta);
|
||||
#endif // _WIN64
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -87,13 +89,12 @@ set(TVOLATILE AtomicAdjustWin32Impl::Integer &var,
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE AtomicAdjustWin32Impl::Integer AtomicAdjustWin32Impl::
|
||||
get(const TVOLATILE AtomicAdjustWin32Impl::Integer &var) {
|
||||
// On Intel platforms, word-aligned loads are atomic (if performed
|
||||
// in a single instruction). We can't guarantee the compiler will
|
||||
// generate a single instruction to load this value, but it
|
||||
// certainly won't happen if its address isn't word-aligned, so make
|
||||
// sure that's the case.
|
||||
assert((((size_t)&var) & (sizeof(Integer) - 1)) == 0);
|
||||
return var;
|
||||
#ifdef _WIN64
|
||||
return InterlockedAdd64((TVOLATILE AtomicAdjustWin32Impl::Integer *)&var, 0);
|
||||
#else
|
||||
return InterlockedAdd((TVOLATILE AtomicAdjustWin32Impl::Integer *)&var, 0);
|
||||
#endif // _WIN64
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -116,13 +117,12 @@ set_ptr(TVOLATILE AtomicAdjustWin32Impl::Pointer &var,
|
||||
// indicated variable. This is the only guaranteed safe
|
||||
// way to retrieve the value that other threads might be
|
||||
// asynchronously setting, incrementing, or decrementing
|
||||
// (via other AtomicAjust methods).
|
||||
// (via other AtomicAdjust methods).
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE AtomicAdjustWin32Impl::Pointer AtomicAdjustWin32Impl::
|
||||
get_ptr(const TVOLATILE AtomicAdjustWin32Impl::Pointer &var) {
|
||||
// As in get(), make sure the address is word-aligned.
|
||||
assert((((size_t)&var) & (sizeof(Pointer) - 1)) == 0);
|
||||
return var;
|
||||
assert(sizeof(Pointer) == sizeof(Integer));
|
||||
return (Pointer)get(*(const TVOLATILE Integer *)&var);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -31,6 +31,10 @@ extern "C" {
|
||||
ReMutex FfmpegVideoCursor::_av_lock;
|
||||
TypeHandle FfmpegVideoCursor::_type_handle;
|
||||
|
||||
PStatCollector FfmpegVideoCursor::_fetch_buffer_pcollector("*:FFMPEG Video Decoding:Fetch");
|
||||
PStatCollector FfmpegVideoCursor::_seek_pcollector("*:FFMPEG Video Decoding:Seek");
|
||||
PStatCollector FfmpegVideoCursor::_export_frame_pcollector("*:FFMPEG Convert Video to BGR");
|
||||
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR < 53
|
||||
#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
|
||||
@ -898,8 +902,7 @@ flip_packets() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FfmpegVideoCursor::
|
||||
fetch_frame(int frame) {
|
||||
static PStatCollector fetch_buffer_pcollector("*:FFMPEG Video Decoding:Fetch");
|
||||
PStatTimer timer(fetch_buffer_pcollector);
|
||||
PStatTimer timer(_fetch_buffer_pcollector);
|
||||
|
||||
int finished = 0;
|
||||
|
||||
@ -918,8 +921,7 @@ fetch_frame(int frame) {
|
||||
return;
|
||||
}
|
||||
while (_packet_frame <= frame) {
|
||||
static PStatCollector seek_pcollector("*:FFMPEG Video Decoding:Seek");
|
||||
PStatTimer timer(seek_pcollector);
|
||||
PStatTimer timer(_seek_pcollector);
|
||||
|
||||
// Decode and discard the previous packet.
|
||||
decode_frame(finished, _packet1);
|
||||
@ -993,8 +995,7 @@ do_decode_frame(int &finished, AVPacket *packet) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FfmpegVideoCursor::
|
||||
seek(int frame, bool backward) {
|
||||
static PStatCollector seek_pcollector("*:FFMPEG Video Decoding:Seek");
|
||||
PStatTimer timer(seek_pcollector);
|
||||
PStatTimer timer(_seek_pcollector);
|
||||
|
||||
if (ffmpeg_support_seek) {
|
||||
if (ffmpeg_global_lock) {
|
||||
@ -1121,8 +1122,7 @@ reset_stream() {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FfmpegVideoCursor::
|
||||
advance_to_frame(int frame) {
|
||||
static PStatCollector fetch_buffer_pcollector("*:FFMPEG Video Decoding:Fetch");
|
||||
PStatTimer timer(fetch_buffer_pcollector);
|
||||
PStatTimer timer(_fetch_buffer_pcollector);
|
||||
|
||||
if (frame < _begin_frame) {
|
||||
// Frame is in the past.
|
||||
@ -1210,8 +1210,7 @@ advance_to_frame(int frame) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void FfmpegVideoCursor::
|
||||
export_frame(FfmpegBuffer *buffer) {
|
||||
static PStatCollector export_frame_collector("*:FFMPEG Convert Video to BGR");
|
||||
PStatTimer timer(export_frame_collector);
|
||||
PStatTimer timer(_export_frame_pcollector);
|
||||
|
||||
if (!_frame_ready) {
|
||||
// No frame data ready, just fill with black.
|
||||
|
@ -155,6 +155,11 @@ private:
|
||||
bool _frame_ready;
|
||||
bool _eof_known;
|
||||
int _eof_frame;
|
||||
|
||||
// PStat collectors.
|
||||
static PStatCollector _fetch_buffer_pcollector;
|
||||
static PStatCollector _seek_pcollector;
|
||||
static PStatCollector _export_frame_pcollector;
|
||||
|
||||
public:
|
||||
static void register_with_read_factory();
|
||||
|
@ -23,7 +23,9 @@
|
||||
#define INCLUDED_SOURCES \
|
||||
config_pstats.cxx pStatClient.cxx pStatClientImpl.cxx \
|
||||
pStatClientVersion.cxx \
|
||||
pStatClientControlMessage.cxx pStatCollectorDef.cxx \
|
||||
pStatClientControlMessage.cxx \
|
||||
pStatCollector.cxx \
|
||||
pStatCollectorDef.cxx \
|
||||
pStatCollectorForward.cxx \
|
||||
pStatFrameData.cxx pStatProperties.cxx \
|
||||
pStatServerControlMessage.cxx \
|
||||
|
@ -472,6 +472,7 @@ is_started(const PStatThread &thread) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void PStatCollector::
|
||||
start(const PStatThread &thread) {
|
||||
nassertv(_client != NULL);
|
||||
_client->start(_index, thread._index);
|
||||
}
|
||||
|
||||
|
15
panda/src/pstatclient/pStatCollector.cxx
Executable file
15
panda/src/pstatclient/pStatCollector.cxx
Executable file
@ -0,0 +1,15 @@
|
||||
// Filename: pStatCollector.cxx
|
||||
// Created by: drose (18Nov11)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) Carnegie Mellon University. All rights reserved.
|
||||
//
|
||||
// All use of this software is subject to the terms of the revised BSD
|
||||
// license. You should have received a copy of this license along
|
||||
// with this source code in a file named "LICENSE."
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pStatCollector.h"
|
@ -4,3 +4,4 @@
|
||||
#include "pStatClientImpl.cxx"
|
||||
#include "pStatClientVersion.cxx"
|
||||
#include "pStatClientControlMessage.cxx"
|
||||
#include "pStatCollector.cxx"
|
||||
|
Loading…
x
Reference in New Issue
Block a user