Skip to content

Commit

Permalink
Merge pull request #15 from HolyWu/patch/extra_hw_frames
Browse files Browse the repository at this point in the history
Fix potential corrupted frame from hardware decoding for h264
  • Loading branch information
myrsloik authored Jul 2, 2023
2 parents 1cffbbf + e3c0d63 commit 71d1d02
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/videosource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,13 @@ void LWVideoDecoder::OpenFile(const std::string &SourceFile, const std::string &
}

// Full explanation by more clever person available here: https://github.com/Nevcairiel/LAVFilters/issues/113
if (CodecContext->codec_id == AV_CODEC_ID_H264 && CodecContext->has_b_frames)
if (CodecContext->codec_id == AV_CODEC_ID_H264 && CodecContext->has_b_frames) {
CodecContext->has_b_frames = 15; // the maximum possible value for h264

if (HWMode)
CodecContext->extra_hw_frames = 7;
}

if (HWMode) {
CodecContext->pix_fmt = hw_pix_fmt;
if (av_hwdevice_ctx_create(&HWDeviceContext, Type, nullptr, nullptr, 0) < 0)
Expand Down

0 comments on commit 71d1d02

Please sign in to comment.