Use AVVideoScalingModeResizeAspect instead of abusing extended pixels

This not only eliminates the hand-rolled aspect ratio correction (which didn't actually handle scaling),
but it also avoids us having to write to the GPU frames to add padding which improves performance.
This commit is contained in:
Cameron Gutman
2023-10-03 18:44:17 -05:00
parent a29d2e11ea
commit ca041f2934
4 changed files with 12 additions and 91 deletions

View File

@@ -66,11 +66,9 @@ namespace platf {
av_img->pixel_buffer = pixelBuffer;
img_out->data = (uint8_t *) CVPixelBufferGetBaseAddress(pixelBuffer);
size_t extraPixels[4];
CVPixelBufferGetExtendedPixels(pixelBuffer, &extraPixels[0], &extraPixels[1], &extraPixels[2], &extraPixels[3]);
img_out->width = CVPixelBufferGetWidth(pixelBuffer) + extraPixels[0] + extraPixels[1];
img_out->height = CVPixelBufferGetHeight(pixelBuffer) + extraPixels[2] + extraPixels[3];
img_out->width = CVPixelBufferGetWidth(pixelBuffer);
img_out->height = CVPixelBufferGetHeight(pixelBuffer);
img_out->row_pitch = CVPixelBufferGetBytesPerRow(pixelBuffer);
img_out->pixel_pitch = img_out->row_pitch / img_out->width;
@@ -136,11 +134,9 @@ namespace platf {
av_img->pixel_buffer = pixelBuffer;
img->data = (uint8_t *) CVPixelBufferGetBaseAddress(pixelBuffer);
size_t extraPixels[4];
CVPixelBufferGetExtendedPixels(pixelBuffer, &extraPixels[0], &extraPixels[1], &extraPixels[2], &extraPixels[3]);
img->width = CVPixelBufferGetWidth(pixelBuffer) + extraPixels[0] + extraPixels[1];
img->height = CVPixelBufferGetHeight(pixelBuffer) + extraPixels[2] + extraPixels[3];
img->width = CVPixelBufferGetWidth(pixelBuffer);
img->height = CVPixelBufferGetHeight(pixelBuffer);
img->row_pitch = CVPixelBufferGetBytesPerRow(pixelBuffer);
img->pixel_pitch = img->row_pitch / img->width;