MCPcopy Create free account
hub / github.com/audacity/audacity / Process

Method Process

modules/import-export/mod-wavpack/ExportWavPack.cpp:505–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503}
504
505ExportResult WavPackExportProcessor::Process(ExportProcessorDelegate& delegate)
506{
507 delegate.SetStatusString(context.status);
508
509 const size_t bufferSize = SAMPLES_PER_RUN * context.numChannels;
510
511 ArrayOf<int32_t> wavpackBuffer{ bufferSize };
512
513 auto exportResult = ExportResult::Success;
514 {
515
516 while (exportResult == ExportResult::Success) {
517 auto samplesThisRun = context.mixer->Process();
518
519 if (samplesThisRun == 0)
520 break;
521
522 const auto bytesPerSample = context.bytesPerSample;
523 auto& md5 = context.md5;
524 const auto updateMd5 = [&](uint32_t sampleValue) {
525 unsigned char sampleBytes[4];
526 sampleBytes[0] = static_cast<unsigned char>(sampleValue & 0xFF);
527 sampleBytes[1]
528 = static_cast<unsigned char>((sampleValue >> 8) & 0xFF);
529 sampleBytes[2]
530 = static_cast<unsigned char>((sampleValue >> 16) & 0xFF);
531 sampleBytes[3]
532 = static_cast<unsigned char>((sampleValue >> 24) & 0xFF);
533 md5.Update(sampleBytes, bytesPerSample);
534 };
535
536 if (context.format == int16Sample) {
537 const int16_t *mixed = reinterpret_cast<const int16_t*>(context.mixer->GetBuffer());
538 for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) {
539 for (size_t i = 0; i < context.numChannels; i++) {
540 const auto sampleValue = (static_cast<int32_t>(*mixed++) * 65536) >> 16;
541 wavpackBuffer[j*context.numChannels + i] = sampleValue;
542 updateMd5(sampleValue);
543 }
544 }
545 } else {
546 const int *mixed = reinterpret_cast<const int*>(context.mixer->GetBuffer());
547 for (decltype(samplesThisRun) j = 0; j < samplesThisRun; j++) {
548 for (size_t i = 0; i < context.numChannels; i++) {
549 const auto sampleValue = *mixed++;
550 wavpackBuffer[j*context.numChannels + i] = sampleValue;
551 updateMd5(sampleValue);
552 }
553 }
554 }
555
556 if (!WavpackPackSamples(context.wpc, wavpackBuffer.get(), samplesThisRun)) {
557 throw ExportErrorException(WavpackGetErrorMessage(context.wpc));
558 }
559 exportResult = ExportPluginHelpers::UpdateProgress(
560 delegate, *context.mixer, context.t0, context.t1);
561 }
562 }

Callers

nothing calls this directly

Calls 12

GetRangeMethod · 0.80
SetStatusStringMethod · 0.45
UpdateMethod · 0.45
GetBufferMethod · 0.45
getMethod · 0.45
FinalizeMethod · 0.45
dataMethod · 0.45
CloseMethod · 0.45
OpenMethod · 0.45
ReadMethod · 0.45
SeekMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected