248 lines
11 KiB
TypeScript
248 lines
11 KiB
TypeScript
/* Metro module 4683; source: modules/media_uploads/native/VideoUploadUtils.tsx; dependencies: [6, 7, 1312, 3, 2] */
|
|
function _fun40537(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#40537, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4861:6, offset: 0x01103edc, size: 542 bytes, params: 8, frame: 21
|
|
var object2;
|
|
const closure = calculateTargetDimensions;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_1 = importDefault(6) /* metro dependency 6 */;
|
|
const env0_2 = importDefault(7) /* metro dependency 7 */;
|
|
const env0_3 = (require(1312) /* metro dependency 1312: UnsyncedUserSettingsStore */).VideoCompressionQuality;
|
|
let value = importDefault(3) /* metro dependency 3: Logger */;
|
|
value = new value('VideoUploadUtils.tsx');
|
|
value = _fun40539();
|
|
const value3 = Object.create(value.prototype, {constructor: {value: value}});
|
|
const value4 = new value('very_low', 360, 800000);
|
|
value.VERY_LOW = value4 instanceof Object ? value4 : value3;
|
|
const value6 = Object.create(value.prototype, {constructor: {value: value}});
|
|
const value7 = new value('low', 360, 1200000);
|
|
value.LOW = value7 instanceof Object ? value7 : value6;
|
|
const value9 = Object.create(value.prototype, {constructor: {value: value}});
|
|
const value10 = new value('medium', 480, 1800000);
|
|
value.MEDIUM = value10 instanceof Object ? value10 : value9;
|
|
const value12 = Object.create(value.prototype, {constructor: {value: value}});
|
|
const value13 = new value('high', 720, 2250000);
|
|
value.HIGH = value13 instanceof Object ? value13 : value12;
|
|
const value15 = Object.create(value.prototype, {constructor: {value: value}});
|
|
const value16 = new value('very_high', 1080, 7000000);
|
|
value.VERY_HIGH = value16 instanceof Object ? value16 : value15;
|
|
value.fromCompressionQuality = fromCompressionQuality;
|
|
object2 = {'bitrateFloor': 300000, 'createHDR': false, 'frameRate': 30, 'keyFrameIntervalSeconds': 2,
|
|
'rotationDegrees': 0, 'skipVideoTranscode': false, 'targetBitrate': null, 'targetHeight': 480,
|
|
'targetWidth': 640, 'useHEVC': false, 'videoQuality': null, 'hevcIsSupported': false,
|
|
'useTranscodedVideoForMovSources': true, 'transmuxLivePhotos': true, 'progressUpdateGranularity': 10};
|
|
let MEDIUM = value.MEDIUM;
|
|
object2.targetBitrate = MEDIUM.targetBitrate;
|
|
MEDIUM = value.MEDIUM;
|
|
object2.videoQuality = MEDIUM;
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/media_uploads/native/VideoUploadUtils.tsx');
|
|
exports.VideoQualityTarget = value;
|
|
exports.DEFAULT_VIDEO_ENCODING_CONFIG = object2;
|
|
exports.calculateTargetDimensions = closure;
|
|
exports.canSkipVideoTranscode = canSkipVideoTranscode;
|
|
exports.logSourceMetadata = logSourceMetadata;
|
|
exports.logEncoderSettings = logEncoderSettings;
|
|
exports.calculateOptimalBitrate = function({bitRate}, a1, a2) {
|
|
var Math = global.Math;
|
|
return global.Math.min(Math.max(bitRate, a2), a1.targetBitrate);
|
|
};
|
|
exports.shouldUseHEVC = function(a0, a1, a2, a3, a4) {
|
|
var r2;
|
|
var r1;
|
|
var r0;
|
|
var value = a3;
|
|
r2 = a1 ? !a2 : !a1;
|
|
if (r2) {
|
|
r0 = !r2;
|
|
} else {
|
|
r1 = value && a0.rotationDegrees !== 0;
|
|
r1 = r1 && !a4;
|
|
value = !r1;
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
};
|
|
}
|
|
|
|
function calculateTargetDimensions(a0, a1) { // fn#40538, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4861:1177, offset: 0x011040fa, size: 186 bytes, params: 3, frame: 17
|
|
var r3;
|
|
var r6;
|
|
var Math;
|
|
var value2;
|
|
var value3;
|
|
let value = a0.width / a0.height;
|
|
if (a0.width > a0.height) {
|
|
Math = global.Math;
|
|
value3 = Math.min(a1, a0.height);
|
|
Math = global.Math;
|
|
value = Math.round(value3 * value);
|
|
r3 = value3;
|
|
r6 = value;
|
|
} else {
|
|
Math = global.Math;
|
|
value2 = Math.min(a1, a0.width);
|
|
Math = global.Math;
|
|
value = Math.round(value2 / value);
|
|
r3 = value;
|
|
r6 = value2;
|
|
}
|
|
return {width: r6 % 2 === 0 ? r6 : r6 + 1, height: r3 % 2 === 0 ? r3 : r3 + 1};
|
|
}
|
|
|
|
function _fun40539() { // fn#40539, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4861:197, offset: 0x011041b4, size: 55 bytes, params: 1, frame: 14
|
|
return env0_2(VideoQualityTarget, [{key: 'toString', value: function() {
|
|
return this.value;
|
|
}}]);
|
|
}
|
|
|
|
function fromCompressionQuality(a0) { // fn#40542, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4861:598, offset: 0x01104221, size: 194 bytes, params: 2, frame: 13
|
|
const VERY_LOW = VideoCompressionQuality.VERY_LOW;
|
|
if (VERY_LOW === a0) {
|
|
return env0_0.VERY_LOW;
|
|
}
|
|
const LOW = VideoCompressionQuality.LOW;
|
|
if (LOW === a0) {
|
|
return env0_0.LOW;
|
|
}
|
|
const MEDIUM = VideoCompressionQuality.MEDIUM;
|
|
if (MEDIUM === a0) {
|
|
return env0_0.MEDIUM;
|
|
}
|
|
const HIGH = VideoCompressionQuality.HIGH;
|
|
if (HIGH === a0) {
|
|
return env0_0.HIGH;
|
|
}
|
|
const VERY_HIGH = VideoCompressionQuality.VERY_HIGH;
|
|
if (VERY_HIGH === a0) {
|
|
return env0_0.VERY_HIGH;
|
|
}
|
|
const Error = global.Error;
|
|
const value = 'Unknown compression quality: ' + a0;
|
|
const value2 = Object.create(Error.prototype, {constructor: {value: Error}});
|
|
const error = new Error();
|
|
throw error instanceof Object ? error : value2;
|
|
}
|
|
|
|
function canSkipVideoTranscode(a0, a1, a2, a3) { // fn#40543, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4861:1616, offset: 0x011042e3, size: 198 bytes, params: 5, frame: 17
|
|
var r4;
|
|
var r0;
|
|
var value;
|
|
var Math;
|
|
var round;
|
|
var width;
|
|
var value2;
|
|
var value3;
|
|
var value4;
|
|
if (a2 == null) {
|
|
value = calculateTargetDimensions(a1, a0.targetResolution);
|
|
Math = global.Math;
|
|
round = Math.round;
|
|
width = a1.width;
|
|
value2 = Reflect.apply(round, Math, [width]);
|
|
Math = global.Math;
|
|
value3 = Math.round(a1.height);
|
|
width = value.width;
|
|
value4 = value2 <= width;
|
|
} else {
|
|
if (a3 == null) {
|
|
value = calculateTargetDimensions(a1, a0.targetResolution);
|
|
Math = global.Math;
|
|
round = Math.round;
|
|
width = a1.width;
|
|
value2 = Reflect.apply(round, Math, [width]);
|
|
Math = global.Math;
|
|
value3 = Math.round(a1.height);
|
|
width = value.width;
|
|
r4 = value2 <= width && value3 <= value.height;
|
|
value = a1.bitRate <= a0.targetBitrate;
|
|
r0 = r4 ? !value : !r4;
|
|
r0 = !r0 ? a1.format == null : r0;
|
|
r0 = !r0 ? a1.format.match(RegExp('(avc1|hvc1|video\\/(avc|hevc))', 'i')) === null : r0;
|
|
return !r0;
|
|
}
|
|
if (a2 > a3) {
|
|
return false;
|
|
}
|
|
value = calculateTargetDimensions(a1, a0.targetResolution);
|
|
Math = global.Math;
|
|
value2 = Math.round(a1.width);
|
|
Math = global.Math;
|
|
value3 = Math.round(a1.height);
|
|
value4 = value2 <= value.width;
|
|
}
|
|
r4 = value4 && value3 <= value.height;
|
|
r0 = r4 ? !(a1.bitRate <= a0.targetBitrate) : !r4;
|
|
r0 = !r0 ? a1.format == null : r0;
|
|
r0 = !r0 ? a1.format.match(RegExp('(avc1|hvc1|video\\/(avc|hevc))', 'i')) === null : r0;
|
|
return !r0;
|
|
}
|
|
|
|
function logSourceMetadata(a0) { // fn#40544, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4861:1954, offset: 0x011043a9, size: 469 bytes, params: 2, frame: 20
|
|
const r7 = a0.format != null ? ({'hvc1': 'hvc1 (HEVC)', 'avc1': 'avc1 (H.264)'})[a0.format] ?? a0.format : 'unknown';
|
|
let binding = env0_4;
|
|
binding.info('Video Source Metadata:');
|
|
binding.info('- Codec: ' + r7);
|
|
binding.info('- Dimensions: ' + a0.width + 'x' + a0.height);
|
|
binding.info('- Bitrate: ' + a0.bitRate + ' bps');
|
|
binding.info('- Frame Rate: ' + a0.frameRate + ' fps');
|
|
binding.info('- HDR: ' + (a0.isHDRContent ? 'Yes' : 'No'));
|
|
binding = env0_4;
|
|
binding.info('- Rotation Degrees: ' + a0.rotationDegrees);
|
|
binding.info('- Profile: ' + a0.sourceProfile);
|
|
binding.info('- Level: ' + a0.sourceLevel);
|
|
binding.info('- Duration: ' + a0.durationMs + ' ms');
|
|
}
|
|
|
|
function logEncoderSettings(a0) { // fn#40545, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4861:2510, offset: 0x0110457e, size: 666 bytes, params: 2, frame: 24
|
|
var createHDR;
|
|
var value6;
|
|
let binding = env0_4;
|
|
let info = binding.info;
|
|
Reflect.apply(info, binding, ['Encoder Video Quality Settings:']);
|
|
info = binding.info;
|
|
let videoQuality = a0.videoQuality;
|
|
const value2 = undefined;
|
|
Reflect.apply(info, binding,
|
|
['- Compression Quality: ' + (videoQuality == null ? value2 : videoQuality.toString())]);
|
|
binding = env0_4;
|
|
info = binding.info;
|
|
videoQuality = a0.videoQuality;
|
|
Reflect.apply(info, binding,
|
|
['- Compression Quality Target Resolution: ' + (videoQuality == null ? value2 : videoQuality.targetResolution) + 'p']);
|
|
binding = env0_4;
|
|
info = binding.info;
|
|
videoQuality = a0.videoQuality;
|
|
Reflect.apply(info, binding,
|
|
['- Compression Quality Max Bitrate: ' + (videoQuality == null ? value2 : videoQuality.targetBitrate) + ' bps']);
|
|
env0_4.info('Encoder Video Transcoding Settings:');
|
|
const skipVideoTranscode = a0.skipVideoTranscode;
|
|
info = env0_4.info;
|
|
if (skipVideoTranscode) {
|
|
Reflect.apply(info, binding, ['- Skip Video Transcode: Yes']);
|
|
} else {
|
|
Reflect.apply(info, binding, ['- Codec: ' + (a0.useHEVC ? 'hvc1 (HEVC)' : 'avc1 (H.264)')]);
|
|
binding = env0_4;
|
|
binding.info('- Dimensions: ' + a0.targetWidth + 'x' + a0.targetHeight);
|
|
binding.info('- Bitrate: ' + a0.targetBitrate + ' bps');
|
|
binding.info('- Frame Rate: ' + a0.frameRate + ' fps');
|
|
binding.info('- Key Frame Interval: ' + a0.keyFrameIntervalSeconds + ' seconds');
|
|
info = binding.info;
|
|
createHDR = a0.createHDR;
|
|
value6 = 'No';
|
|
Reflect.apply(info, binding, ['- Create HDR: ' + (createHDR ? 'Yes' : value6)]);
|
|
binding = env0_4;
|
|
binding.info('- Rotation Degrees: ' + a0.rotationDegrees);
|
|
binding.info('- HEVC Supported: ' + (a0.hevcIsSupported ? 'Yes' : value6));
|
|
binding = env0_4;
|
|
binding.info('- Progress Update Granularity: ' + a0.progressUpdateGranularity);
|
|
}
|
|
return value2;
|
|
}
|
|
|
|
function VideoQualityTarget(a0, a1, a2) { // fn#40540, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4861:218, offset: 0x011041eb, size: 54 bytes, params: 4, frame: 13
|
|
env1_1(this, VideoQualityTarget);
|
|
this.value = a0;
|
|
this.targetResolution = a1;
|
|
this.targetBitrate = a2;
|
|
}
|
|
|