Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 34 additions & 35 deletions src/components/videoUploading/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import {
NeuralPipelineDescriptor,
} from 'webgpu-neural';

import type { JSX } from 'react';

import { makeSample, SampleInit } from '../SampleLayout';
import CanvasControls from '../CanvasControls';

import fullscreenTexturedQuadWGSL from '../../shaders/fullscreenTexturedQuad.wgsl';
import sampleExternalTextureWGSL from '../../shaders/sampleExternalTexture.frag.wgsl';

import type { JSX } from "react";

type Settings = {
requestFrame: string;
effect: string;
Expand Down Expand Up @@ -99,37 +99,37 @@ const init: SampleInit = async ({
});

function updateVideoFrameTexture() {
//if (video.videoWidth > 0 && video.videoHeight > 0) {
// const currentWidth = video.videoWidth;
// const currentHeight = video.videoHeight;
if (video.videoWidth === 0 || video.videoHeight === 0) {
console.log("Found invalid frame... Skipping...");
return; // Invalid frame, skip
}

if (video.videoWidth !== WIDTH || video.videoHeight !== HEIGHT) {
console.log(`Resolution updated to: ${video.videoWidth}x${video.videoHeight}`);
WIDTH = video.videoWidth;
HEIGHT = video.videoHeight;
videoFrameTexture = device.createTexture({
size: [WIDTH, HEIGHT, 1],
format: 'rgba16float',
usage: GPUTextureUsage.TEXTURE_BINDING
| GPUTextureUsage.COPY_DST
| GPUTextureUsage.RENDER_ATTACHMENT,
});
updatePipeline();
updateRenderBindGroup();
updateCanvasSize();
}
device.queue.copyExternalImageToTexture(
{ source: video },
{ texture: videoFrameTexture },
[video.videoWidth, video.videoHeight],
);
//}
// if (video.videoWidth > 0 && video.videoHeight > 0) {
// const currentWidth = video.videoWidth;
// const currentHeight = video.videoHeight;
Comment on lines +102 to +104
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented code on lines 102-104 and 132 appears to be unused dead code that should be removed entirely rather than kept as comments. The variables currentWidth and currentHeight are declared but never used, and the outer condition check is redundant with the check on line 106.

Copilot uses AI. Check for mistakes.

if (video.videoWidth === 0 || video.videoHeight === 0) {
console.log('Found invalid frame... Skipping...');
return; // Invalid frame, skip
}

if (video.videoWidth !== WIDTH || video.videoHeight !== HEIGHT) {
console.log(`Resolution updated to: ${video.videoWidth}x${video.videoHeight}`);
WIDTH = video.videoWidth;
HEIGHT = video.videoHeight;
videoFrameTexture = device.createTexture({
size: [WIDTH, HEIGHT, 1],
format: 'rgba16float',
usage: GPUTextureUsage.TEXTURE_BINDING
| GPUTextureUsage.COPY_DST
| GPUTextureUsage.RENDER_ATTACHMENT,
});
updatePipeline();
updateRenderBindGroup();
updateCanvasSize();
}

device.queue.copyExternalImageToTexture(
{ source: video },
{ texture: videoFrameTexture },
[video.videoWidth, video.videoHeight],
);
// }
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This closing comment brace on line 132 is part of the dead code that should be removed. It corresponds to the commented opening condition on line 102.

Copilot uses AI. Check for mistakes.
}

// bind 2: compare
Expand Down Expand Up @@ -364,8 +364,7 @@ const init: SampleInit = async ({

updateRenderBindGroup();

effectController.onChange((value) => {
// Unused value
effectController.onChange(() => {
updatePipeline();
updateRenderBindGroup();
updateCanvasSize();
Expand Down
Loading