You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Adding new settings class to be used for changing realtime settings used by libopenshot, such as scaling mode for preview vs final render, or hardware decode, etc...
This commit is contained in:
@@ -38,7 +38,7 @@ FFmpegReader::FFmpegReader(string path)
|
||||
check_fps(false), enable_seek(true), is_open(false), seek_audio_frame_found(0), seek_video_frame_found(0),
|
||||
prev_samples(0), prev_pts(0), pts_total(0), pts_counter(0), is_duration_known(false), largest_frame_processed(0),
|
||||
current_video_frame(0), has_missing_frames(false), num_packets_since_video_frame(0), num_checks_since_final(0),
|
||||
packet(NULL), use_omp_threads(true) {
|
||||
packet(NULL) {
|
||||
|
||||
// Initialize FFMpeg, and register all formats and codecs
|
||||
AV_REGISTER_ALL
|
||||
@@ -60,7 +60,7 @@ FFmpegReader::FFmpegReader(string path, bool inspect_reader)
|
||||
check_fps(false), enable_seek(true), is_open(false), seek_audio_frame_found(0), seek_video_frame_found(0),
|
||||
prev_samples(0), prev_pts(0), pts_total(0), pts_counter(0), is_duration_known(false), largest_frame_processed(0),
|
||||
current_video_frame(0), has_missing_frames(false), num_packets_since_video_frame(0), num_checks_since_final(0),
|
||||
packet(NULL), use_omp_threads(true) {
|
||||
packet(NULL) {
|
||||
|
||||
// Initialize FFMpeg, and register all formats and codecs
|
||||
AV_REGISTER_ALL
|
||||
@@ -229,9 +229,6 @@ void FFmpegReader::Open()
|
||||
missing_frames.SetMaxBytesFromInfo(OPEN_MP_NUM_PROCESSORS * 2, info.width, info.height, info.sample_rate, info.channels);
|
||||
final_cache.SetMaxBytesFromInfo(OPEN_MP_NUM_PROCESSORS * 2, info.width, info.height, info.sample_rate, info.channels);
|
||||
|
||||
// Initialize OMP threading support
|
||||
use_omp_threads = openshot::IsOMPEnabled();
|
||||
|
||||
// Mark as "open"
|
||||
is_open = true;
|
||||
}
|
||||
@@ -613,7 +610,7 @@ std::shared_ptr<Frame> FFmpegReader::ReadStream(int64_t requested_frame)
|
||||
// Process Video Packet
|
||||
ProcessVideoPacket(requested_frame);
|
||||
|
||||
if (!use_omp_threads) {
|
||||
if (openshot::Settings::Instance()->WAIT_FOR_VIDEO_PROCESSING_TASK) {
|
||||
// Wait on each OMP task to complete before moving on to the next one. This slows
|
||||
// down processing considerably, but might be more stable on some systems.
|
||||
#pragma omp taskwait
|
||||
@@ -628,16 +625,16 @@ std::shared_ptr<Frame> FFmpegReader::ReadStream(int64_t requested_frame)
|
||||
num_packets_since_video_frame++;
|
||||
|
||||
// Check the status of a seek (if any)
|
||||
if (is_seeking)
|
||||
#pragma omp critical (openshot_seek)
|
||||
check_seek = CheckSeek(false);
|
||||
else
|
||||
check_seek = false;
|
||||
if (is_seeking)
|
||||
#pragma omp critical (openshot_seek)
|
||||
check_seek = CheckSeek(false);
|
||||
else
|
||||
check_seek = false;
|
||||
|
||||
if (check_seek) {
|
||||
// Jump to the next iteration of this loop
|
||||
continue;
|
||||
}
|
||||
if (check_seek) {
|
||||
// Jump to the next iteration of this loop
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update PTS / Frame Offset (if any)
|
||||
UpdatePTSOffset(false);
|
||||
@@ -919,8 +916,12 @@ void FFmpegReader::ProcessVideoPacket(int64_t requested_frame)
|
||||
// Copy picture data from one AVFrame (or AVPicture) to another one.
|
||||
AV_COPY_PICTURE_DATA(pFrameRGB, buffer, PIX_FMT_RGBA, width, height);
|
||||
|
||||
int scale_mode = SWS_FAST_BILINEAR;
|
||||
if (openshot::Settings::Instance()->HIGH_QUALITY_SCALING) {
|
||||
scale_mode = SWS_LANCZOS;
|
||||
}
|
||||
SwsContext *img_convert_ctx = sws_getContext(info.width, info.height, AV_GET_CODEC_PIXEL_FORMAT(pStream, pCodecCtx), width,
|
||||
height, PIX_FMT_RGBA, SWS_LANCZOS, NULL, NULL, NULL);
|
||||
height, PIX_FMT_RGBA, scale_mode, NULL, NULL, NULL);
|
||||
|
||||
// Resize / Convert to RGB
|
||||
sws_scale(img_convert_ctx, my_frame->data, my_frame->linesize, 0,
|
||||
|
||||
Reference in New Issue
Block a user