diff --git a/panda/src/grutil/openCVTexture.cxx b/panda/src/grutil/openCVTexture.cxx index 6c44b4ba61..1ac0f4e903 100644 --- a/panda/src/grutil/openCVTexture.cxx +++ b/panda/src/grutil/openCVTexture.cxx @@ -98,9 +98,6 @@ from_camera(int camera_index, int z) { return false; } - int width = cvGetCaptureProperty(page._color._capture, CV_CAP_PROP_FRAME_WIDTH); - int height = cvGetCaptureProperty(page._color._capture, CV_CAP_PROP_FRAME_HEIGHT); - if (!reconsider_video_properties(page._color, 3, z)) { page._color.clear(); return false; @@ -269,6 +266,11 @@ reconsider_video_properties(const OpenCVTexture::VideoStream &stream, if (stream.is_from_file()) { frame_rate = cvGetCaptureProperty(stream._capture, CV_CAP_PROP_FPS); num_frames = (int)cvGetCaptureProperty(stream._capture, CV_CAP_PROP_FRAME_COUNT); + if (grutil_cat.is_debug()) { + grutil_cat.debug() + << "Loaded " << stream._filename << ", " << num_frames << " frames at " + << frame_rate << " fps\n"; + } } int width = (int)cvGetCaptureProperty(stream._capture, CV_CAP_PROP_FRAME_WIDTH); int height = (int)cvGetCaptureProperty(stream._capture, CV_CAP_PROP_FRAME_HEIGHT); @@ -281,6 +283,13 @@ reconsider_video_properties(const OpenCVTexture::VideoStream &stream, y_size = up_to_power_2(height); } + if (grutil_cat.is_debug()) { + grutil_cat.debug() + << "Video stream is " << width << " by " << height + << " pixels; fitting in texture " << x_size << " by " + << y_size << " texels.\n"; + } + if (!reconsider_image_properties(x_size, y_size, num_components, T_unsigned_byte, z)) { return false; diff --git a/panda/src/putil/animInterface.I b/panda/src/putil/animInterface.I index 5e455df3d2..83097dcc4f 100644 --- a/panda/src/putil/animInterface.I +++ b/panda/src/putil/animInterface.I @@ -126,6 +126,9 @@ get_num_frames() const { //////////////////////////////////////////////////////////////////// INLINE int AnimInterface:: get_frame() const { + if (get_num_frames() <= 0) { + return 0; + } return cmod(get_full_frame(), get_num_frames()); } diff --git a/panda/src/putil/animInterface.cxx b/panda/src/putil/animInterface.cxx index d711f6e0f3..766afdb87c 100644 --- a/panda/src/putil/animInterface.cxx +++ b/panda/src/putil/animInterface.cxx @@ -252,10 +252,12 @@ get_full_fframe() const { return min(max(get_f(), 0.0), _play_frames) + _start_frame; case PM_loop: + nassertr(_play_frames >= 0.0, 0.0); return cmod(get_f(), _play_frames) + _start_frame; case PM_pingpong: { + nassertr(_play_frames >= 0.0, 0.0); double f = cmod(get_f(), _play_frames * 2.0); if (f > _play_frames) { return (_play_frames * 2.0 - f) + _start_frame;