Fix --video-pngs where last frame may not be used
This commit is contained in:
parent
db2d75de06
commit
926269198e
1 changed files with 71 additions and 71 deletions
14
src/video.cc
14
src/video.cc
|
@ -487,9 +487,7 @@ std::tuple<bool, std::vector<AVFrame *>> Video::HandleDecodingPacket(
|
||||||
if (!dithered_image->SaveAsPNG(out_name, true)) {
|
if (!dithered_image->SaveAsPNG(out_name, true)) {
|
||||||
return {false, {}};
|
return {false, {}};
|
||||||
}
|
}
|
||||||
return {true, {}};
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
// convert grayscale/RGBA to YUV444p
|
// convert grayscale/RGBA to YUV444p
|
||||||
if (sws_enc_context_ != nullptr && color_changed) {
|
if (sws_enc_context_ != nullptr && color_changed) {
|
||||||
// switched between grayscale/RGBA, context needs to be recreated
|
// 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;
|
temp_frame->height = frame->height;
|
||||||
return_value = av_frame_get_buffer(temp_frame, 0);
|
return_value = av_frame_get_buffer(temp_frame, 0);
|
||||||
if (return_value != 0) {
|
if (return_value != 0) {
|
||||||
std::cout
|
std::cout << "ERROR: Failed to init temp_frame for conversion from "
|
||||||
<< "ERROR: Failed to init temp_frame for conversion from grayscale"
|
"grayscale"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
av_frame_free(&temp_frame);
|
av_frame_free(&temp_frame);
|
||||||
return {false, {}};
|
return {false, {}};
|
||||||
|
@ -532,7 +530,8 @@ std::tuple<bool, std::vector<AVFrame *>> Video::HandleDecodingPacket(
|
||||||
temp_frame->height = frame->height;
|
temp_frame->height = frame->height;
|
||||||
return_value = av_frame_get_buffer(temp_frame, 0);
|
return_value = av_frame_get_buffer(temp_frame, 0);
|
||||||
if (return_value != 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;
|
<< std::endl;
|
||||||
av_frame_free(&temp_frame);
|
av_frame_free(&temp_frame);
|
||||||
return {false, {}};
|
return {false, {}};
|
||||||
|
@ -570,7 +569,8 @@ std::tuple<bool, std::vector<AVFrame *>> Video::HandleDecodingPacket(
|
||||||
yuv_frame->pts = frame_count_ - 1;
|
yuv_frame->pts = frame_count_ - 1;
|
||||||
yuv_frame->pkt_duration = 1;
|
yuv_frame->pkt_duration = 1;
|
||||||
return_frames.push_back(yuv_frame);
|
return_frames.push_back(yuv_frame);
|
||||||
}
|
} // else (!output_as_pngs)
|
||||||
|
} // while (return_value >= 0)
|
||||||
|
|
||||||
return {true, return_frames};
|
return {true, return_frames};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue