Skip to content
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

figure out the correct dimensions masks for codecs #3359

Closed
totaam opened this issue Nov 22, 2021 · 3 comments
Closed

figure out the correct dimensions masks for codecs #3359

totaam opened this issue Nov 22, 2021 · 3 comments
Labels
encoding enhancement New feature or request

Comments

@totaam
Copy link
Collaborator

totaam commented Nov 22, 2021

The lazy approach we use is to clamp the dimensions using:

width_mask=0xFFFE
height_mask=0xFFFE

But some csc modules and video encoders may well be able to handle odd dimensions correctly, especially when handling RGB input directly.

@totaam totaam added enhancement New feature or request encoding labels Nov 22, 2021
@totaam
Copy link
Collaborator Author

totaam commented Nov 22, 2021

The fix above was another lazy fix
Instead, I should have figured out if it was the jpeg encoder or the libyuv csc module that was causing the corrupted image I was seeing when downscaling or subsampling was used with odd input image dimensions.
Modifying the csc modules is the easy part, ie for swscale:

-            self.out_height[i] = (int) (dst_height * dst.height_mult[i])
-            self.out_stride[i] = roundup((int) (dst_width * dst.width_mult[i]), 16)
+            self.out_height[i] = ceil(dst_height * dst.height_mult[i])
+            self.out_stride[i] = roundup(ceil(dst_width * dst.width_mult[i]), 16)

totaam added a commit that referenced this issue Oct 27, 2022
by honouring the rowstride specified,
also prettify the output
@totaam
Copy link
Collaborator Author

totaam commented Oct 27, 2022

As per the commit above, x264 can handle odd heights in all cases and odd widths with non-subsampled input (ie: BGRX or YUV444 - not tested YUV422P yet, probably won't work as it is sumbsampling 2x1).

Still to test:

  • nvenc (swap GPU)
  • ffmpeg encoder with and without libva (might be safer to just leave it as it is?)
  • x265

@totaam
Copy link
Collaborator Author

totaam commented Mar 16, 2023

This may have caused the crashes in #3706 (comment)

@totaam totaam closed this as completed Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
encoding enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant