prMALError exSDKGetParamSummary( exportStdParms *stdParmsP, exParamSummaryRec *summaryRecP) { ExportSettings *privateData = reinterpret_cast<ExportSettings*>(summaryRecP->privateData); PrSDKExportParamSuite *paramSuite = privateData->exportParamSuite; std::string summary1, summary2, summary3; csSDK_uint32 exID = summaryRecP->exporterPluginID; csSDK_int32 gIdx = 0; // Standard settings exParamValues width, height, frameRate, alpha; paramSuite->GetParamValue(exID, gIdx, ADBEVideoWidth, &width); paramSuite->GetParamValue(exID, gIdx, ADBEVideoHeight, &height); paramSuite->GetParamValue(exID, gIdx, ADBEVideoFPS, &frameRate); //paramSuite->GetParamValue(exID, mgroupIndex, ADBEVideoAlpha, &alpha); exParamValues sampleRateP, channelTypeP; paramSuite->GetParamValue(exID, gIdx, ADBEAudioRatePerSecond, &sampleRateP); paramSuite->GetParamValue(exID, gIdx, ADBEAudioNumChannels, &channelTypeP); exParamValues codecP, methodP, videoQualityP, videoBitrateP, vidEncodingP; paramSuite->GetParamValue(exID, gIdx, WebMVideoCodec, &codecP); paramSuite->GetParamValue(exID, gIdx, WebMVideoMethod, &methodP); paramSuite->GetParamValue(exID, gIdx, WebMVideoQuality, &videoQualityP); paramSuite->GetParamValue(exID, gIdx, WebMVideoBitrate, &videoBitrateP); paramSuite->GetParamValue(exID, gIdx, WebMVideoEncoding, &vidEncodingP); exParamValues audioMethodP, audioQualityP, audioBitrateP; paramSuite->GetParamValue(exID, gIdx, WebMAudioMethod, &audioMethodP); paramSuite->GetParamValue(exID, gIdx, WebMAudioQuality, &audioQualityP); paramSuite->GetParamValue(exID, gIdx, WebMAudioBitrate, &audioBitrateP); // oh boy, figure out frame rate PrTime frameRates[] = { 10, 15, 23, 24, 25, 29, 30, 50, 59, 60}; PrTime frameRateNumDens[][2] = {{10, 1}, {15, 1}, {24000, 1001}, {24, 1}, {25, 1}, {30000, 1001}, {30, 1}, {50, 1}, {60000, 1001}, {60, 1}}; const char *frameRateStrings[] = { "10", "15", "23.976", "24", "25", "29.97", "30", "50", "59.94", "60"}; PrTime ticksPerSecond = 0; privateData->timeSuite->GetTicksPerSecond(&ticksPerSecond); csSDK_int32 frame_rate_index = -1; for(csSDK_int32 i=0; i < sizeof(frameRates) / sizeof (PrTime); i++) { frameRates[i] = ticksPerSecond / frameRateNumDens[i][0] * frameRateNumDens[i][1]; if(frameRates[i] == frameRate.value.timeValue) frame_rate_index = i; } std::stringstream stream1; stream1 << width.value.intValue << "x" << height.value.intValue; if(frame_rate_index >= 0 && frame_rate_index < 10) stream1 << ", " << frameRateStrings[frame_rate_index] << " fps"; //stream1 << ", " << (alpha.value.intValue ? "Alpha" : "No Alpha"); summary1 = stream1.str(); std::stringstream stream2; stream2 << (int)sampleRateP.value.floatValue << " Hz"; stream2 << ", " << (channelTypeP.value.intValue == kPrAudioChannelType_51 ? "Dolby 5.1" : channelTypeP.value.intValue == kPrAudioChannelType_Mono ? "Mono" : "Stereo"); stream2 << ", "; if(audioMethodP.value.intValue == OGG_BITRATE) { stream2 << audioBitrateP.value.intValue << " kbps"; } else { stream2 << "Quality " << audioQualityP.value.floatValue; } summary2 = stream2.str(); WebM_Video_Method method = (WebM_Video_Method)methodP.value.intValue; std::stringstream stream3; if(method == WEBM_METHOD_QUALITY) { stream3 << "Quality " << videoQualityP.value.intValue; } else { stream3 << videoBitrateP.value.intValue << " kb/s"; if(method == WEBM_METHOD_VBR) stream3 << " VBR"; } stream3 << (codecP.value.intValue == WEBM_CODEC_VP9 ? ", VP9" : ", VP8"); if(vidEncodingP.value.intValue == WEBM_ENCODING_REALTIME) stream3 << ", Realtime"; else if(vidEncodingP.value.intValue == WEBM_ENCODING_BEST) stream3 << ", Best"; summary3 = stream3.str(); utf16ncpy(summaryRecP->Summary1, summary1.c_str(), 255); utf16ncpy(summaryRecP->Summary2, summary2.c_str(), 255); utf16ncpy(summaryRecP->Summary3, summary3.c_str(), 255); return malNoError; }
prMALError exSDKQueryOutputSettings( exportStdParms *stdParmsP, exQueryOutputSettingsRec *outputSettingsP) { prMALError result = malNoError; ExportSettings *privateData = reinterpret_cast<ExportSettings*>(outputSettingsP->privateData); csSDK_uint32 exID = outputSettingsP->exporterPluginID; exParamValues width, height, frameRate, pixelAspectRatio, fieldType, //alpha, methodP, videoQualityP, videoBitrateP, sampleRate, channelType, audioQualityP; PrSDKExportParamSuite *paramSuite = privateData->exportParamSuite; csSDK_int32 mgroupIndex = 0; float fps = 0.0f; PrTime ticksPerSecond = 0; csSDK_uint32 videoBitrate = 0; privateData->timeSuite->GetTicksPerSecond(&ticksPerSecond); fps = (float)ticksPerSecond / (float)frameRate.value.timeValue; if(outputSettingsP->inExportVideo) { paramSuite->GetParamValue(exID, mgroupIndex, ADBEVideoWidth, &width); outputSettingsP->outVideoWidth = width.value.intValue; paramSuite->GetParamValue(exID, mgroupIndex, ADBEVideoHeight, &height); outputSettingsP->outVideoHeight = height.value.intValue; paramSuite->GetParamValue(exID, mgroupIndex, ADBEVideoFPS, &frameRate); outputSettingsP->outVideoFrameRate = frameRate.value.timeValue; paramSuite->GetParamValue(exID, mgroupIndex, ADBEVideoAspect, &pixelAspectRatio); outputSettingsP->outVideoAspectNum = pixelAspectRatio.value.ratioValue.numerator; outputSettingsP->outVideoAspectDen = pixelAspectRatio.value.ratioValue.denominator; paramSuite->GetParamValue(exID, mgroupIndex, ADBEVideoFieldType, &fieldType); outputSettingsP->outVideoFieldType = fieldType.value.intValue; paramSuite->GetParamValue(exID, mgroupIndex, WebMVideoMethod, &methodP); paramSuite->GetParamValue(exID, mgroupIndex, WebMVideoQuality, &videoQualityP); paramSuite->GetParamValue(exID, mgroupIndex, WebMVideoBitrate, &videoBitrateP); paramSuite->GetParamValue(exID, mgroupIndex, WebMAudioQuality, &audioQualityP); if(methodP.value.intValue == WEBM_METHOD_QUALITY) { int bitsPerFrameUncompressed = (width.value.intValue * height.value.intValue) * 3 * 8; int qual = videoQualityP.value.intValue; float qualityMaxMult = 0.5; float qualityMinMult = 0.01; float qualityMult = (((float)qual / 100.0) * (qualityMaxMult - qualityMinMult)) + qualityMinMult; int bitsPerFrame = bitsPerFrameUncompressed * qualityMult; videoBitrate += (bitsPerFrame * fps) / 1024; } else videoBitrate += videoBitrateP.value.intValue; //paramSuite->GetParamValue(exID, mgroupIndex, ADBEVideoAlpha, &alpha); } if(outputSettingsP->inExportAudio) { paramSuite->GetParamValue(exID, mgroupIndex, ADBEAudioRatePerSecond, &sampleRate); outputSettingsP->outAudioSampleRate = sampleRate.value.floatValue; paramSuite->GetParamValue(exID, mgroupIndex, ADBEAudioNumChannels, &channelType); outputSettingsP->outAudioChannelType = (PrAudioChannelType)channelType.value.intValue; outputSettingsP->outAudioSampleType = kPrAudioSampleType_Compressed; const PrAudioChannelType audioFormat = (PrAudioChannelType)channelType.value.intValue; const int audioChannels = (audioFormat == kPrAudioChannelType_51 ? 6 : audioFormat == kPrAudioChannelType_Mono ? 1 : 2); float qualityMult = (audioQualityP.value.floatValue + 0.1) / 1.1; float ogg_mult = (qualityMult * 0.4) + 0.1; videoBitrate += (sampleRate.value.floatValue * audioChannels * 8 * 4 * ogg_mult) / 1024; // IDK } // return outBitratePerSecond in kbps outputSettingsP->outBitratePerSecond = videoBitrate; return result; }
prMALError exSDKValidateParamChanged ( exportStdParms *stdParmsP, exParamChangedRec *validateParamChangedRecP) { ExportSettings *privateData = reinterpret_cast<ExportSettings*>(validateParamChangedRecP->privateData); PrSDKExportParamSuite *paramSuite = privateData->exportParamSuite; csSDK_int32 exID = validateParamChangedRecP->exporterPluginID; csSDK_int32 gIdx = validateParamChangedRecP->multiGroupIndex; std::string param = validateParamChangedRecP->changedParamIdentifier; if(param == ADBEVideoMatchSource) { exParamValues matchSourceP, widthP, heightP, pixelAspectRatioP, fieldTypeP, frameRateP; paramSuite->GetParamValue(exID, gIdx, ADBEVideoMatchSource, &matchSourceP); paramSuite->GetParamValue(exID, gIdx, ADBEVideoWidth, &widthP); paramSuite->GetParamValue(exID, gIdx, ADBEVideoHeight, &heightP); paramSuite->GetParamValue(exID, gIdx, ADBEVideoAspect, &pixelAspectRatioP); paramSuite->GetParamValue(exID, gIdx, ADBEVideoFieldType, &fieldTypeP); paramSuite->GetParamValue(exID, gIdx, ADBEVideoFPS, &frameRateP); bool disabled = (matchSourceP.value.intValue != 0); widthP.disabled = heightP.disabled = pixelAspectRatioP.disabled = fieldTypeP.disabled = frameRateP.disabled = disabled; paramSuite->ChangeParam(exID, gIdx, ADBEVideoWidth, &widthP); paramSuite->ChangeParam(exID, gIdx, ADBEVideoHeight, &heightP); paramSuite->ChangeParam(exID, gIdx, ADBEVideoAspect, &pixelAspectRatioP); paramSuite->ChangeParam(exID, gIdx, ADBEVideoFieldType, &fieldTypeP); paramSuite->ChangeParam(exID, gIdx, ADBEVideoFPS, &frameRateP); } else if(param == WebMVideoMethod) { exParamValues methodValue, videoQualityValue, videoBitrateValue; paramSuite->GetParamValue(exID, gIdx, WebMVideoMethod, &methodValue); paramSuite->GetParamValue(exID, gIdx, WebMVideoQuality, &videoQualityValue); paramSuite->GetParamValue(exID, gIdx, WebMVideoBitrate, &videoBitrateValue); videoQualityValue.hidden = !(methodValue.value.intValue == WEBM_METHOD_QUALITY); videoBitrateValue.hidden = (methodValue.value.intValue == WEBM_METHOD_QUALITY); paramSuite->ChangeParam(exID, gIdx, WebMVideoQuality, &videoQualityValue); paramSuite->ChangeParam(exID, gIdx, WebMVideoBitrate, &videoBitrateValue); } else if(param == WebMAudioMethod) { exParamValues audioMethodP, audioQualityP, audioBitrateP; paramSuite->GetParamValue(exID, gIdx, WebMAudioMethod, &audioMethodP); paramSuite->GetParamValue(exID, gIdx, WebMAudioQuality, &audioQualityP); paramSuite->GetParamValue(exID, gIdx, WebMAudioBitrate, &audioBitrateP); audioQualityP.hidden = (audioMethodP.value.intValue == OGG_BITRATE); audioBitrateP.hidden = !audioQualityP.hidden; paramSuite->ChangeParam(exID, gIdx, WebMAudioQuality, &audioQualityP); paramSuite->ChangeParam(exID, gIdx, WebMAudioBitrate, &audioBitrateP); } return malNoError; }
prMALError exSDKPostProcessParams( exportStdParms *stdParmsP, exPostProcessParamsRec *postProcessParamsRecP) { prMALError result = malNoError; ExportSettings *lRec = reinterpret_cast<ExportSettings *>(postProcessParamsRecP->privateData); PrSDKExportParamSuite *exportParamSuite = lRec->exportParamSuite; //PrSDKExportInfoSuite *exportInfoSuite = lRec->exportInfoSuite; PrSDKTimeSuite *timeSuite = lRec->timeSuite; csSDK_int32 exID = postProcessParamsRecP->exporterPluginID; csSDK_int32 gIdx = 0; prUTF16Char paramString[256]; // Image Settings group utf16ncpy(paramString, "Image Settings", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEBasicVideoGroup, paramString); // Match source utf16ncpy(paramString, "Match source", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEVideoMatchSource, paramString); // width utf16ncpy(paramString, "Width", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEVideoWidth, paramString); exParamValues widthValues; exportParamSuite->GetParamValue(exID, gIdx, ADBEVideoWidth, &widthValues); widthValues.rangeMin.intValue = 16; widthValues.rangeMax.intValue = 8192; exportParamSuite->ChangeParam(exID, gIdx, ADBEVideoWidth, &widthValues); // height utf16ncpy(paramString, "Height", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEVideoHeight, paramString); exParamValues heightValues; exportParamSuite->GetParamValue(exID, gIdx, ADBEVideoHeight, &heightValues); heightValues.rangeMin.intValue = 16; heightValues.rangeMax.intValue = 8192; exportParamSuite->ChangeParam(exID, gIdx, ADBEVideoHeight, &heightValues); // pixel aspect ratio utf16ncpy(paramString, "Pixel Aspect Ratio", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEVideoAspect, paramString); csSDK_int32 PARs[][2] = {{1, 1}, {10, 11}, {40, 33}, {768, 702}, {1024, 702}, {2, 1}, {4, 3}, {3, 2}}; const char *PARStrings[] = {"Square pixels (1.0)", "D1/DV NTSC (0.9091)", "D1/DV NTSC Widescreen 16:9 (1.2121)", "D1/DV PAL (1.0940)", "D1/DV PAL Widescreen 16:9 (1.4587)", "Anamorphic 2:1 (2.0)", "HD Anamorphic 1080 (1.3333)", "DVCPRO HD (1.5)"}; exportParamSuite->ClearConstrainedValues(exID, gIdx, ADBEVideoAspect); exOneParamValueRec tempPAR; for(csSDK_int32 i=0; i < sizeof (PARs) / sizeof(PARs[0]); i++) { tempPAR.ratioValue.numerator = PARs[i][0]; tempPAR.ratioValue.denominator = PARs[i][1]; utf16ncpy(paramString, PARStrings[i], 255); exportParamSuite->AddConstrainedValuePair(exID, gIdx, ADBEVideoAspect, &tempPAR, paramString); } // field type utf16ncpy(paramString, "Field Type", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEVideoFieldType, paramString); csSDK_int32 fieldOrders[] = { prFieldsUpperFirst, prFieldsLowerFirst, prFieldsNone}; const char *fieldOrderStrings[] = { "Upper First", "Lower First", "None"}; exportParamSuite->ClearConstrainedValues(exID, gIdx, ADBEVideoFieldType); exOneParamValueRec tempFieldOrder; for(int i=0; i < 3; i++) { tempFieldOrder.intValue = fieldOrders[i]; utf16ncpy(paramString, fieldOrderStrings[i], 255); exportParamSuite->AddConstrainedValuePair(exID, gIdx, ADBEVideoFieldType, &tempFieldOrder, paramString); } // frame rate utf16ncpy(paramString, "Frame Rate", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEVideoFPS, paramString); PrTime frameRates[] = { 10, 15, 23, 24, 25, 29, 30, 50, 59, 60}; PrTime frameRateNumDens[][2] = {{10, 1}, {15, 1}, {24000, 1001}, {24, 1}, {25, 1}, {30000, 1001}, {30, 1}, {50, 1}, {60000, 1001}, {60, 1}}; const char *frameRateStrings[] = { "10", "15", "23.976", "24", "25 (PAL)", "29.97 (NTSC)", "30", "50", "59.94", "60"}; PrTime ticksPerSecond = 0; timeSuite->GetTicksPerSecond (&ticksPerSecond); for(csSDK_int32 i=0; i < sizeof(frameRates) / sizeof (PrTime); i++) { frameRates[i] = ticksPerSecond / frameRateNumDens[i][0] * frameRateNumDens[i][1]; } exportParamSuite->ClearConstrainedValues(exID, gIdx, ADBEVideoFPS); exOneParamValueRec tempFrameRate; for(csSDK_int32 i=0; i < sizeof(frameRates) / sizeof (PrTime); i++) { tempFrameRate.timeValue = frameRates[i]; utf16ncpy(paramString, frameRateStrings[i], 255); exportParamSuite->AddConstrainedValuePair(exID, gIdx, ADBEVideoFPS, &tempFrameRate, paramString); } // Alpha channel utf16ncpy(paramString, "Include Alpha Channel", 255); //exportParamSuite->SetParamName(exID, gIdx, ADBEVideoAlpha, paramString); // Video codec settings utf16ncpy(paramString, "Codec settings", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEVideoCodecGroup, paramString); // Codec utf16ncpy(paramString, "Codec", 255); exportParamSuite->SetParamName(exID, gIdx, WebMVideoCodec, paramString); WebM_Video_Codec codecs[] = { WEBM_CODEC_VP8, WEBM_CODEC_VP9 }; const char *codecStrings[] = { "VP8", "VP9" }; exportParamSuite->ClearConstrainedValues(exID, gIdx, WebMVideoCodec); exOneParamValueRec tempCodec; for(int i=0; i < 2; i++) { tempCodec.intValue = codecs[i]; utf16ncpy(paramString, codecStrings[i], 255); exportParamSuite->AddConstrainedValuePair(exID, gIdx, WebMVideoCodec, &tempCodec, paramString); } // Method utf16ncpy(paramString, "Method", 255); exportParamSuite->SetParamName(exID, gIdx, WebMVideoMethod, paramString); int vidMethods[] = { WEBM_METHOD_QUALITY, WEBM_METHOD_BITRATE, WEBM_METHOD_VBR }; const char *vidMethodStrings[] = { "Constant Quality", "Constant Bitrate", "Variable Bitrate (2-pass)" }; exportParamSuite->ClearConstrainedValues(exID, gIdx, WebMVideoMethod); exOneParamValueRec tempEncodingMethod; for(int i=0; i < 3; i++) { tempEncodingMethod.intValue = vidMethods[i]; utf16ncpy(paramString, vidMethodStrings[i], 255); exportParamSuite->AddConstrainedValuePair(exID, gIdx, WebMVideoMethod, &tempEncodingMethod, paramString); } // Quality utf16ncpy(paramString, "Quality", 255); exportParamSuite->SetParamName(exID, gIdx, WebMVideoQuality, paramString); exParamValues videoQualityValues; exportParamSuite->GetParamValue(exID, gIdx, WebMVideoQuality, &videoQualityValues); videoQualityValues.rangeMin.intValue = 0; videoQualityValues.rangeMax.intValue = 100; exportParamSuite->ChangeParam(exID, gIdx, WebMVideoQuality, &videoQualityValues); // Bitrate utf16ncpy(paramString, "Bitrate (kb/s)", 255); exportParamSuite->SetParamName(exID, gIdx, WebMVideoBitrate, paramString); exParamValues bitrateValues; exportParamSuite->GetParamValue(exID, gIdx, WebMVideoBitrate, &bitrateValues); bitrateValues.rangeMin.intValue = 1; bitrateValues.rangeMax.intValue = 9999; exportParamSuite->ChangeParam(exID, gIdx, WebMVideoBitrate, &bitrateValues); // Encoding utf16ncpy(paramString, "Encoding", 255); exportParamSuite->SetParamName(exID, gIdx, WebMVideoEncoding, paramString); int vidQualities[] = { WEBM_ENCODING_REALTIME, WEBM_ENCODING_GOOD, WEBM_ENCODING_BEST }; const char *vidQualityStrings[] = { "Realtime", "Good", "Best" }; exportParamSuite->ClearConstrainedValues(exID, gIdx, WebMVideoEncoding); exOneParamValueRec tempEncodingQuality; for(int i=0; i < 3; i++) { tempEncodingQuality.intValue = vidQualities[i]; utf16ncpy(paramString, vidQualityStrings[i], 255); exportParamSuite->AddConstrainedValuePair(exID, gIdx, WebMVideoEncoding, &tempEncodingQuality, paramString); } // Custom settings utf16ncpy(paramString, "Custom settings", 255); exportParamSuite->SetParamName(exID, gIdx, WebMCustomGroup, paramString); utf16ncpy(paramString, "Custom args", 255); exportParamSuite->SetParamName(exID, gIdx, WebMCustomArgs, paramString); // Audio Settings group utf16ncpy(paramString, "Audio Settings", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEBasicAudioGroup, paramString); // Sample rate utf16ncpy(paramString, "Sample Rate", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEAudioRatePerSecond, paramString); float sampleRates[] = { 8000.0f, 16000.0f, 32000.0f, 44100.0f, 48000.0f, 96000.0f }; const char *sampleRateStrings[] = { "8000 Hz", "16000 Hz", "32000 Hz", "44100 Hz", "48000 Hz", "96000 Hz" }; exportParamSuite->ClearConstrainedValues(exID, gIdx, ADBEAudioRatePerSecond); exOneParamValueRec tempSampleRate; for(csSDK_int32 i=0; i < sizeof(sampleRates) / sizeof(float); i++) { tempSampleRate.floatValue = sampleRates[i]; utf16ncpy(paramString, sampleRateStrings[i], 255); exportParamSuite->AddConstrainedValuePair(exID, gIdx, ADBEAudioRatePerSecond, &tempSampleRate, paramString); } // Channels utf16ncpy(paramString, "Channels", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEAudioNumChannels, paramString); csSDK_int32 channelTypes[] = { kPrAudioChannelType_Mono, kPrAudioChannelType_Stereo, kPrAudioChannelType_51 }; const char *channelTypeStrings[] = { "Mono", "Stereo", "Dolby 5.1" }; exportParamSuite->ClearConstrainedValues(exID, gIdx, ADBEAudioNumChannels); exOneParamValueRec tempChannelType; for(csSDK_int32 i=0; i < sizeof(channelTypes) / sizeof(csSDK_int32); i++) { tempChannelType.intValue = channelTypes[i]; utf16ncpy(paramString, channelTypeStrings[i], 255); exportParamSuite->AddConstrainedValuePair(exID, gIdx, ADBEAudioNumChannels, &tempChannelType, paramString); } // Audio codec settings utf16ncpy(paramString, "Vorbis settings", 255); exportParamSuite->SetParamName(exID, gIdx, ADBEAudioCodecGroup, paramString); // Method utf16ncpy(paramString, "Method", 255); exportParamSuite->SetParamName(exID, gIdx, WebMAudioMethod, paramString); int audioMethods[] = { OGG_QUALITY, OGG_BITRATE }; const char *audioMethodStrings[] = { "Quality", "Bitrate" }; exportParamSuite->ClearConstrainedValues(exID, gIdx, WebMAudioMethod); exOneParamValueRec tempAudioEncodingMethod; for(int i=0; i < 2; i++) { tempAudioEncodingMethod.intValue = audioMethods[i]; utf16ncpy(paramString, audioMethodStrings[i], 255); exportParamSuite->AddConstrainedValuePair(exID, gIdx, WebMAudioMethod, &tempAudioEncodingMethod, paramString); } // Quality utf16ncpy(paramString, "Quality", 255); exportParamSuite->SetParamName(exID, gIdx, WebMAudioQuality, paramString); exParamValues qualityValues; exportParamSuite->GetParamValue(exID, gIdx, WebMAudioQuality, &qualityValues); qualityValues.rangeMin.floatValue = -0.1f; qualityValues.rangeMax.floatValue = 1.f; exportParamSuite->ChangeParam(exID, gIdx, WebMAudioQuality, &qualityValues); // Bitrate utf16ncpy(paramString, "Bitrate (kb/s)", 255); exportParamSuite->SetParamName(exID, gIdx, WebMAudioBitrate, paramString); exParamValues audioBitrateValues; exportParamSuite->GetParamValue(exID, gIdx, WebMAudioBitrate, &audioBitrateValues); audioBitrateValues.rangeMin.intValue = 40; audioBitrateValues.rangeMax.intValue = 1000; exportParamSuite->ChangeParam(exID, gIdx, WebMAudioBitrate, &audioBitrateValues); return result; }
// Returns malNoError if successful prMALError RenderAndWriteAllAudio( exDoExportRec *exportInfoP, PrTime exportDuration) { csSDK_int32 resultS = malNoError; csSDK_uint32 exID = exportInfoP->exporterPluginID; ExportSettings *mySettings = reinterpret_cast<ExportSettings*>(exportInfoP->privateData); exParamValues ticksPerFrame, sampleRate, channelType; csSDK_int64 distanceToMove; prInt64 filePtrLocation; PrAudioSample totalAudioSamples = 0, samplesRemaining = 0; csSDK_uint32 audioRenderID = 0; csSDK_int32 maxBlip = 0; csSDK_int32 audioBufferSizeL = 0, samplesRequestedL = 0, audioChannelsL = 0; float * audioBuffer[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; csSDK_uint32 bytesToWriteLu = 0; PrSDKMemoryManagerSuite *memorySuite = mySettings->memorySuite; PrSDKTimeSuite *timeSuite = mySettings->timeSuite; PrTime ticksPerSample = 0; PrSDKExportParamSuite *paramSuite = mySettings->exportParamSuite; paramSuite->GetParamValue(exID, 0, ADBEVideoFPS, &ticksPerFrame); paramSuite->GetParamValue(exID, 0, ADBEAudioRatePerSecond, &sampleRate); paramSuite->GetParamValue(exID, 0, ADBEAudioNumChannels, &channelType); audioChannelsL = GetNumberOfAudioChannels (channelType.value.intValue); timeSuite->GetTicksPerAudioSample ((float)sampleRate.value.floatValue, &ticksPerSample); mySettings->sequenceAudioSuite->MakeAudioRenderer( exID, exportInfoP->startTime, (PrAudioChannelType)channelType.value.intValue, kPrAudioSampleType_32BitFloat, (float)sampleRate.value.floatValue, &audioRenderID); totalAudioSamples = exportDuration / ticksPerSample; samplesRemaining = totalAudioSamples; // Find size of blip to ask for // The lesser of the value returned from GetMaxBlip and number of samples remaining mySettings->sequenceAudioSuite->GetMaxBlip (audioRenderID, ticksPerFrame.value.timeValue, &maxBlip); if (maxBlip < samplesRemaining) { samplesRequestedL = maxBlip; } else { samplesRequestedL = (csSDK_int32) samplesRemaining; } // Set temporary audio buffer size (measured in samples) // to be size of first blip requested audioBufferSizeL = samplesRequestedL; // Allocate audio buffers for (csSDK_int32 bufferIndexL = 0; bufferIndexL < audioChannelsL; bufferIndexL++) { audioBuffer[bufferIndexL] = (float *) memorySuite->NewPtr (audioBufferSizeL * AUDIO_SAMPLE_SIZE); } while(samplesRemaining && (resultS == malNoError)) { // Fill the buffer with audio resultS = mySettings->sequenceAudioSuite->GetAudio( audioRenderID, (csSDK_uint32) samplesRequestedL, audioBuffer, kPrFalse); if (resultS == malNoError) { bytesToWriteLu = samplesRequestedL * AUDIO_SAMPLE_SIZE; // Write out the buffer of audio retrieved for (csSDK_int32 bufferIndexL = 0; bufferIndexL < audioChannelsL; bufferIndexL++) { resultS = mySettings->exportFileSuite->Write( exportInfoP->fileObject, reinterpret_cast<void*>(audioBuffer[bufferIndexL]), (csSDK_int32) bytesToWriteLu); if (bufferIndexL < audioChannelsL - 1) { // Move file pointer to next audio buffer distanceToMove = totalAudioSamples * AUDIO_SAMPLE_SIZE - bytesToWriteLu; resultS = mySettings->exportFileSuite->Seek(exportInfoP->fileObject, distanceToMove, filePtrLocation, fileSeekMode_Current); } else { // Move file pointer back from last to first audio buffer distanceToMove = -totalAudioSamples * AUDIO_SAMPLE_SIZE * (audioChannelsL - 1); resultS = mySettings->exportFileSuite->Seek(exportInfoP->fileObject, distanceToMove, filePtrLocation, fileSeekMode_Current); } } // Calculate remaining audio samplesRemaining -= samplesRequestedL; // Find size of next blip to ask for mySettings->sequenceAudioSuite->GetMaxBlip (audioRenderID, ticksPerFrame.value.timeValue, &maxBlip); if (maxBlip < samplesRemaining) { samplesRequestedL = maxBlip; } else { samplesRequestedL = (csSDK_int32) samplesRemaining; } if (audioBufferSizeL < samplesRequestedL) { samplesRequestedL = audioBufferSizeL; } } } // Free up audioBuffer for (csSDK_int32 bufferIndexL = 0; bufferIndexL < audioChannelsL; bufferIndexL++) { memorySuite->PrDisposePtr ((char *) audioBuffer[bufferIndexL]); } mySettings->sequenceAudioSuite->ReleaseAudioRenderer( exID, audioRenderID); return resultS; }