MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / GetOrCreateFrame

Method GetOrCreateFrame

src/FrameMapper.cpp:393–431  ·  view source on GitHub ↗

Get or generate a blank frame

Source from the content-addressed store, hash-verified

391
392// Get or generate a blank frame
393std::shared_ptr<Frame> FrameMapper::GetOrCreateFrame(int64_t number)
394{
395 std::shared_ptr<Frame> new_frame;
396
397 // Init some basic properties about this frame (keep sample rate and # channels the same as the original reader for now)
398 int samples_in_frame = Frame::GetSamplesPerFrame(AdjustFrameNumber(number), target, reader->info.sample_rate, reader->info.channels);
399
400 try {
401 // Debug output
402 ZmqLogger::Instance()->AppendDebugMethod(
403 "FrameMapper::GetOrCreateFrame (from reader)",
404 "number", number,
405 "samples_in_frame", samples_in_frame);
406
407 // Attempt to get a frame (but this could fail if a reader has just been closed)
408 new_frame = reader->GetFrame(number);
409
410 // Return real frame
411 return new_frame;
412
413 } catch (const ReaderClosed & e) {
414 // ...
415 } catch (const OutOfBoundsFrame & e) {
416 // ...
417 }
418
419 // Debug output
420 ZmqLogger::Instance()->AppendDebugMethod(
421 "FrameMapper::GetOrCreateFrame (create blank)",
422 "number", number,
423 "samples_in_frame", samples_in_frame);
424
425 // Create blank frame
426 new_frame = std::make_shared<Frame>(number, info.width, info.height, "#000000", samples_in_frame, reader->info.channels);
427 new_frame->SampleRate(reader->info.sample_rate);
428 new_frame->ChannelsLayout(info.channel_layout);
429 new_frame->AddAudioSilence(samples_in_frame);
430 return new_frame;
431}
432
433// Get an openshot::Frame object for a specific frame number of this reader.
434std::shared_ptr<Frame> FrameMapper::GetFrame(int64_t requested_frame)

Callers

nothing calls this directly

Calls 5

AppendDebugMethodMethod · 0.80
AddAudioSilenceMethod · 0.80
GetFrameMethod · 0.45
SampleRateMethod · 0.45
ChannelsLayoutMethod · 0.45

Tested by

no test coverage detected