|
Krita Source Code Documentation
|
#include "KisMLTProducerKrita.h"#include <framework/mlt.h>#include <limits.h>#include <math.h>#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "kis_assert.h"#include <framework/mlt_factory.h>#include <framework/mlt_frame.h>#include <framework/mlt_producer.h>#include <framework/mlt_property.h>#include <framework/mlt_service.h>Go to the source code of this file.
Classes | |
| struct | private_data |
Functions | |
| static int | is_valid_range (const int frame_start, const int frame_end) |
| static void | producer_close (mlt_producer producer) |
| static int | producer_generate_silent_audio (mlt_frame frame, void **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples) |
| static int | producer_get_audio (mlt_frame frame, void **buffer, mlt_audio_format *format, int *frequency, int *channels, int *samples) |
| static int | producer_get_frame (mlt_producer producer, mlt_frame_ptr frame, int index) |
| void * | producer_krita_init (mlt_profile profile, mlt_service_type type, const char *id, const void *arg) |
| static void | producer_property_changed (mlt_service owner, mlt_producer self, mlt_event_data event_data) |
| static int | producer_seek (mlt_producer producer, mlt_position position) |
| void | registerKritaMLTProducer (Mlt::Repository *repository) |
| static int | restrict_range (int index, int min, int max) |
| void | scale_audio_frequency (mlt_producer producer, mlt_audio audio) |
|
static |
Definition at line 55 of file KisMLTProducerKrita.cpp.
|
static |
Definition at line 257 of file KisMLTProducerKrita.cpp.
References private_data::producer_internal.
|
static |
Save the generated audio into the frame itself, since this overloaded function will not be called on the further calls to mlt_frame_get_audio (the pointer to the function was placed on the stack, which has already been taken)
Definition at line 124 of file KisMLTProducerKrita.cpp.
References private_data::audio_sample_rate, and scale_audio_frequency().
|
static |
MLT doesn't reset the requested frequency on every call, that is, if the underlying producer just passes through the frequency, it will eventually drop to zero and crash. AVformat resets the frequency every time to the value of the underlying media. Count producer doesn't reset the frequency by default, so we should reset it manually by passing negative values.
Definition at line 85 of file KisMLTProducerKrita.cpp.
References private_data::force_reset_audio_frequency_for_frames, and scale_audio_frequency().
|
static |
Generate a slowed-down silence frame and reset the test_audio flag
When the data stream ends, the AVformat library returns and empty frame, flagged with "test_audio" tag. Later on, when the consumer reads this frame, mlt_frame_get_audio() generates a frame of silence with 48kHz resolution. We cannot use this variant of silence, since it is not scaled. We need to generate our own version of silence, which is scaled according to our format.
Definition at line 176 of file KisMLTProducerKrita.cpp.
References is_valid_range(), producer_generate_silent_audio(), producer_get_audio(), private_data::producer_internal, and restrict_range().
| void * producer_krita_init | ( | mlt_profile | profile, |
| mlt_service_type | type, | ||
| const char * | id, | ||
| const void * | arg ) |
Constructor for the producer.
We permanently set the EOF mode to "continue", because other modes have weird effects, like clipping the data when seeking or resetting the producer speed to null.
Disable caching of frames in avformat producer
Caching in MLT library is broken. When a frame is taken from the cache its "audio" property is not restored. It breaks the work of "read-ahead" consumer thread, which also temporarily stores this frame.
Fetch media sample rate to be able to generate correct silence stream
Definition at line 273 of file KisMLTProducerKrita.cpp.
References private_data::audio_sample_rate, private_data::force_reset_audio_frequency_for_frames, KIS_SAFE_ASSERT_RECOVER_NOOP, producer_close(), producer_get_frame(), private_data::producer_internal, producer_property_changed(), and producer_seek().
|
static |
We don't use MLT's "speed" value for anything, but some MLT's functions may adjust the speed of the producer, e.g. when seeking. So we should keep the two values in sync.
Definition at line 221 of file KisMLTProducerKrita.cpp.
References private_data::producer_internal.
|
static |
Update the position values of the parent producer
Definition at line 238 of file KisMLTProducerKrita.cpp.
References private_data::producer_internal.
| void registerKritaMLTProducer | ( | Mlt::Repository * | repository | ) |
Definition at line 371 of file KisMLTProducerKrita.cpp.
References producer_krita_init().
|
static |
Restricts frame index to within range by modulus wrapping (not clamping).
Definition at line 49 of file KisMLTProducerKrita.cpp.
References MAX.
| void scale_audio_frequency | ( | mlt_producer | producer, |
| mlt_audio | audio ) |
Definition at line 63 of file KisMLTProducerKrita.cpp.
References KIS_SAFE_ASSERT_RECOVER, and qFuzzyIsNull().