Skip to content

Commit a90f36c

Browse files
authored
misc: Code cleanup for WebP encoder. (#230)
1 parent 349c944 commit a90f36c

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

webp.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ size_t webp_encoder_write(webp_encoder e, const opencv_mat src, const int* opt,
527527
WebPAnimEncoderDelete(e->anim);
528528
e->anim = nullptr;
529529
} else {
530-
// Finalize still image using existing WebPMux code
530+
// Finalize still image
531531
WebPData out_mux = { nullptr, 0 };
532532

533533
// Add ICC profile if it exists
@@ -633,8 +633,9 @@ size_t webp_encoder_write(webp_encoder e, const opencv_mat src, const int* opt,
633633
}
634634

635635
// Handle current frame
636+
size_t size = 0;
636637
if (e->is_animation) {
637-
// Add frame to animation
638+
// Add frame to animation being accumulated
638639
WebPPicture frame;
639640
WebPPictureInit(&frame);
640641
frame.width = mat->cols;
@@ -648,7 +649,6 @@ size_t webp_encoder_write(webp_encoder e, const opencv_mat src, const int* opt,
648649
}
649650

650651
// Import the frame
651-
size_t size = 0;
652652
if (mat->channels() == 3) {
653653
size = WebPPictureImportBGR(&frame, mat->data, mat->step);
654654
} else {
@@ -670,8 +670,7 @@ size_t webp_encoder_write(webp_encoder e, const opencv_mat src, const int* opt,
670670
e->timestamp_ms += delay;
671671
WebPPictureFree(&frame);
672672
} else {
673-
// Handle single frame using existing WebPMux code
674-
size_t size = 0;
673+
// Handle single frame
675674
uint8_t* out_picture = nullptr;
676675

677676
if (config.lossless) {
@@ -710,7 +709,7 @@ size_t webp_encoder_write(webp_encoder e, const opencv_mat src, const int* opt,
710709
}
711710

712711
e->frame_count++;
713-
return mat->total() * mat->elemSize(); // Return approximate size of processed data
712+
return size;
714713
}
715714

716715
/**

0 commit comments

Comments
 (0)