This commit is contained in:
Isaac Connor 2021-05-21 10:38:55 -04:00
parent 4fcdeb7287
commit a0df6aacaf
1 changed files with 14 additions and 8 deletions

View File

@ -128,11 +128,11 @@ int SWScale::Convert(
in_buffer, in_buffer_size, out_buffer, out_buffer_size, width, height, new_width, new_height,
in_pf, out_pf);
/* Parameter checking */
if ( in_buffer == nullptr ) {
if (in_buffer == nullptr) {
Error("NULL Input buffer");
return -1;
}
if ( out_buffer == nullptr ) {
if (out_buffer == nullptr) {
Error("NULL output buffer");
return -1;
}
@ -140,7 +140,7 @@ int SWScale::Convert(
// Error("Invalid input or output pixel formats");
// return -2;
// }
if ( !width || !height || !new_height || !new_width ) {
if (!width || !height || !new_height || !new_width) {
Error("Invalid width or height");
return -3;
}
@ -149,11 +149,11 @@ int SWScale::Convert(
#if LIBSWSCALE_VERSION_CHECK(0, 8, 0, 8, 0)
/* Warn if the input or output pixelformat is not supported */
if ( !sws_isSupportedInput(in_pf) ) {
if (!sws_isSupportedInput(in_pf)) {
Warning("swscale does not support the input format: %c%c%c%c",
(in_pf)&0xff,((in_pf)&0xff),((in_pf>>16)&0xff),((in_pf>>24)&0xff));
}
if ( !sws_isSupportedOutput(out_pf) ) {
if (!sws_isSupportedOutput(out_pf)) {
Warning("swscale does not support the output format: %c%c%c%c",
(out_pf)&0xff,((out_pf>>8)&0xff),((out_pf>>16)&0xff),((out_pf>>24)&0xff));
}
@ -184,11 +184,19 @@ int SWScale::Convert(
width, height, in_pf,
new_width, new_height, out_pf,
SWS_FAST_BILINEAR, nullptr, nullptr, nullptr);
if ( swscale_ctx == nullptr ) {
if (swscale_ctx == nullptr) {
Error("Failed getting swscale context");
return -6;
}
/*
input_avframe->format = in_pf;
input_avframe->width = width;
input_avframe->height = height;
output_avframe->format = out_pf;
output_avframe->width = new_width;
output_avframe->height = new_height;
*/
/* Fill in the buffers */
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
if (av_image_fill_arrays(input_avframe->data, input_avframe->linesize,
@ -200,7 +208,6 @@ int SWScale::Convert(
Error("Failed filling input frame with input buffer");
return -7;
}
zm_dump_frame(input_avframe, "convert in frame");
#if LIBAVUTIL_VERSION_CHECK(54, 6, 0, 6, 0)
if (av_image_fill_arrays(output_avframe->data, output_avframe->linesize,
out_buffer, out_pf, new_width, new_height, alignment) <= 0) {
@ -211,7 +218,6 @@ int SWScale::Convert(
Error("Failed filling output frame with output buffer");
return -8;
}
zm_dump_frame(output_avframe, "convert out frame");
/* Do the conversion */
if ( !sws_scale(swscale_ctx,