-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LU-3176: optimize getImageDataAtTime #52
Conversation
@stepancar did you check that visual output still makes sense? |
src/backends/beamcoder.ts
Outdated
@@ -476,25 +483,23 @@ export class BeamcoderExtractor extends BaseExtractor implements Extractor { | |||
return packet as Packet; | |||
} | |||
|
|||
_resizeFrameData(frame): Uint8ClampedArray { | |||
_setFrameDataToImageData(frame: beamcoder.Frame, target: Uint8ClampedArray) { | |||
const components = 4; // 4 components: r, g, b and a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: but should components be passed in? I think it's characteristic to the frame and target and doesn't really seem like something this function should be defining?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can read that from the frame object somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added RGBA_PIXEL_SIZE constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stepancar so we could not find the frame component number? from frame
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get we need to. This code works only with RGBA formate. in our logic it's hardcoded. If we want to support other formats - we need to extend public interface too.
But I don't think it makes sense. We use RGBA everywhere in our system
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True.
src/backends/beamcoder.ts
Outdated
let rawData = target; | ||
|
||
if (!target) { | ||
rawData = new Uint8ClampedArray(frame.width * frame.height * 4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably unhardcode the 4
here too. It would make the code more self-explanatory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(const components = /* whatever is needed to extract component number from the frame */;
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@antoineMoPa , I created constant for that
RGBA_PIXEL_SIZE
✅ Linked to Task LU-3176 · Implement outcome from electron exploration |
It's somthing we wanted to do
we wanted to reuse existing buffer for specific video element instead of re allocating it for every frame
we don't need to copy beamcoder.frame, it's enough for us to create a view of typed array if we can guarantee that beamcoder frame will not be detached,
It improves GC