Panda3D
 All Classes Functions Variables Enumerations
config_ffmpeg.cxx
1 // Filename: config_ffmpeg.cxx
2 // Created by: rdb (23Aug13)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_ffmpeg.h"
16 #include "dconfig.h"
17 #include "ffmpegVideo.h"
18 #include "ffmpegVideoCursor.h"
19 #include "ffmpegAudio.h"
20 #include "ffmpegAudioCursor.h"
21 
22 #include "movieTypeRegistry.h"
23 
24 extern "C" {
25  #include "libavcodec/avcodec.h"
26 }
27 
28 ConfigureDef(config_ffmpeg);
29 NotifyCategoryDef(ffmpeg, "");
30 
31 ConfigureFn(config_ffmpeg) {
32  init_libffmpeg();
33 }
34 
35 ConfigVariableInt ffmpeg_max_readahead_frames
36 ("ffmpeg-max-readahead-frames", 2,
37  PRC_DESC("The maximum number of frames ahead which an ffmpeg decoder thread "
38  "should read in advance of actual playback. Set this to 0 to "
39  "decode ffmpeg videos in the main thread."));
40 
41 ConfigVariableBool ffmpeg_show_seek_frames
42 ("ffmpeg-show-seek-frames", true,
43  PRC_DESC("Set this true to allow showing the intermediate results of seeking "
44  "through the ffmpeg stream to a target frame, or false to hold the "
45  "current frame until the target frame is achieved. This has the "
46  "biggest effect on videos that are too expensive to decode in real "
47  "time: when this is true, the video can be seen to animate at least "
48  "a little bit; when it is false, you may get long periods of one "
49  "held frame."));
50 
51 ConfigVariableBool ffmpeg_support_seek
52 ("ffmpeg-support-seek", true,
53  PRC_DESC("True to use the av_seek_frame() function to seek within ffmpeg "
54  "video files. If this is false, Panda will only seek within a "
55  "file by reading it from the beginning until the desired point, "
56  "which can be much slower. Set this false only if you suspect "
57  "a problem with av_seek_frame()."));
58 
59 ConfigVariableBool ffmpeg_global_lock
60 ("ffmpeg-global-lock", false,
61  PRC_DESC("Set this true to enable a single global mutex across *all* ffmpeg "
62  "operations. Leave this false to use the mutex only for "
63  "the ffmpeg operations that are generally known to be "
64  "not thread-safe. This will negatively affect ffmpeg performance, "
65  "especially when decoding multiple videos at once (including the "
66  "left and right channels of a stereo video). Set this true only "
67  "if you suspect a problem with ffmpeg's own thread-safe nature."));
68 
69 ConfigVariableEnum<ThreadPriority> ffmpeg_thread_priority
70 ("ffmpeg-thread-priority", TP_normal,
71  PRC_DESC("The default thread priority at which to start ffmpeg decoder "
72  "threads."));
73 
74 ConfigVariableInt ffmpeg_read_buffer_size
75 ("ffmpeg-read-buffer-size", 4096,
76  PRC_DESC("The size in bytes of the buffer used when reading input files. "
77  "This is important for performance. A typical size is that of a "
78  "cache page, e.g. 4kb."));
79 
80 ////////////////////////////////////////////////////////////////////
81 // Function: init_libffmpeg
82 // Description: Initializes the library. This must be called at
83 // least once before any of the functions or classes in
84 // this library can be used. Normally it will be
85 // called by the static initializers and need not be
86 // called explicitly, but special cases exist.
87 ////////////////////////////////////////////////////////////////////
88 void
89 init_libffmpeg() {
90  static bool initialized = false;
91  if (initialized) {
92  return;
93  }
94  initialized = true;
95 
97 
98  FfmpegVideo::init_type();
99  FfmpegVideoCursor::init_type();
100  FfmpegAudio::init_type();
101  FfmpegAudioCursor::init_type();
102 
105 
106  // Register ffmpeg as catch-all audio/video type.
108  reg->register_audio_type(&FfmpegAudio::make, "*");
109  reg->register_video_type(&FfmpegVideo::make, "*");
110 }
void register_audio_type(MakeAudioFunc func, const string &extensions)
Registers a MovieAudio type, so that files with any of the given extensions will be loaded as this ty...
void register_video_type(MakeVideoFunc func, const string &extensions)
Registers a MovieVideo type, so that files with any of the given extensions will be loaded as this ty...
This is a convenience class to specialize ConfigVariable as a boolean type.
This class records the different types of MovieAudio and MovieVideo that are available for loading...
static void register_with_read_factory()
Tells the BamReader how to create objects of type FfmpegVideo.
static void register_protocol()
Should be called at startup to attach the appropriate hooks between Panda and FFMpeg.
static void register_with_read_factory()
Tells the BamReader how to create objects of type FfmpegVideo.
Definition: ffmpegVideo.cxx:95
This class specializes ConfigVariable as an enumerated type.
static MovieTypeRegistry * get_global_ptr()
Returns a pointer to the global MovieTypeRegistry instance.
This is a convenience class to specialize ConfigVariable as an integer type.