Fix --video-pngs where last frame may not be used

This commit is contained in:
Stephen Seo 2021-12-06 15:20:06 +09:00
parent db2d75de06
commit 926269198e

View file

@ -487,9 +487,7 @@ std::tuple<bool, std::vector<AVFrame *>> Video::HandleDecodingPacket(
if (!dithered_image->SaveAsPNG(out_name, true)) {
return {false, {}};
}
return {true, {}};
}
} else {
// convert grayscale/RGBA to YUV444p
if (sws_enc_context_ != nullptr && color_changed) {
// switched between grayscale/RGBA, context needs to be recreated
@ -518,8 +516,8 @@ std::tuple<bool, std::vector<AVFrame *>> Video::HandleDecodingPacket(
temp_frame->height = frame->height;
return_value = av_frame_get_buffer(temp_frame, 0);
if (return_value != 0) {
std::cout
<< "ERROR: Failed to init temp_frame for conversion from grayscale"
std::cout << "ERROR: Failed to init temp_frame for conversion from "
"grayscale"
<< std::endl;
av_frame_free(&temp_frame);
return {false, {}};
@ -532,7 +530,8 @@ std::tuple<bool, std::vector<AVFrame *>> Video::HandleDecodingPacket(
temp_frame->height = frame->height;
return_value = av_frame_get_buffer(temp_frame, 0);
if (return_value != 0) {
std::cout << "ERROR: Failed to init temp_frame for conversion from RGBA"
std::cout
<< "ERROR: Failed to init temp_frame for conversion from RGBA"
<< std::endl;
av_frame_free(&temp_frame);
return {false, {}};
@ -570,7 +569,8 @@ std::tuple<bool, std::vector<AVFrame *>> Video::HandleDecodingPacket(
yuv_frame->pts = frame_count_ - 1;
yuv_frame->pkt_duration = 1;
return_frames.push_back(yuv_frame);
}
} // else (!output_as_pngs)
} // while (return_value >= 0)
return {true, return_frames};
}