Skip to content

Commit

Permalink
vvcデコーダを有効化。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed May 12, 2024
1 parent 1098bb7 commit 6c3113c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NVEnc/NVEnc_readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ NVIDIA グラフィックドライバ 551.23
今後の更新で設定ファイルの互換性がなくなるかもしれません。

【メモ】
2024.05.11 (7.53)
2024.05.12 (7.53)
- ffmpeg 7.0に更新。(Windows版)
- ffmpeg 6.1 -> 7.0
- libpng 1.4.0 -> 1.4.3
Expand Down
15 changes: 15 additions & 0 deletions NVEncCore/rgy_avutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ struct RGYAVDeleter {
std::function<void(T**)> deleter;
};

struct StreamInfoOptDeleter {
int streamCount;
StreamInfoOptDeleter(int streamCount_) : streamCount(streamCount_) {};
void operator()(AVDictionary **dictArray) const {
if (dictArray) {
for (int i = 0; i < streamCount; i++) {
if (dictArray[i]) {
av_dict_free(&dictArray[i]);
}
}
av_freep(&dictArray);
}
}
};

#define RGYPOOLAV_DEBUG 0
#define RGYPOOLAV_COUNT 0

Expand Down
28 changes: 27 additions & 1 deletion NVEncCore/rgy_input_avcodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1415,10 +1415,22 @@ RGY_ERR RGYInputAvcodec::initFormatCtx(const TCHAR *strFileName, const RGYInputA
}

m_Demux.format.formatCtx->flags |= AVFMT_FLAG_NONBLOCK; // ffmpeg_opt.cのopen_input_file()と同様にフラグを立てる
if (avformat_find_stream_info(m_Demux.format.formatCtx, nullptr) < 0) {
// experimentalなコーデックを許可するために必要
auto findStreamInfoOpt = std::unique_ptr<AVDictionary *, StreamInfoOptDeleter>(
(AVDictionary **)av_calloc(m_Demux.format.formatCtx->nb_streams, sizeof(AVDictionary*)), StreamInfoOptDeleter(m_Demux.format.formatCtx->nb_streams));
for (uint32_t i = 0; i < m_Demux.format.formatCtx->nb_streams; i++) {
if (0 > (ret = av_dict_set_int(&findStreamInfoOpt.get()[i], "strict", FF_COMPLIANCE_EXPERIMENTAL, 0))) {
AddMessage(RGY_LOG_ERROR, _T("Failed to set strict %d for avformat_find_stream_info (stream #%d, codec: %s): %s\n"), FF_COMPLIANCE_EXPERIMENTAL,
i, char_to_tstring(avcodec_get_name(m_Demux.format.formatCtx->streams[i]->codecpar->codec_id)).c_str(), qsv_av_err2str(ret).c_str());
return RGY_ERR_UNKNOWN;
}
}
if (avformat_find_stream_info(m_Demux.format.formatCtx, findStreamInfoOpt.get()) < 0) {
AddMessage(RGY_LOG_ERROR, _T("error finding stream information.\n"));
return RGY_ERR_UNKNOWN; // Couldn't find stream information
}
findStreamInfoOpt.reset();

AddMessage(RGY_LOG_DEBUG, _T("got stream information.\n"));
av_dump_format(m_Demux.format.formatCtx, 0, filename_char.c_str(), 0);
//dump_format(dec.formatCtx, 0, argv[1], 0);
Expand Down Expand Up @@ -2090,6 +2102,20 @@ RGY_ERR RGYInputAvcodec::Init(const TCHAR *strFileName, VideoInfo *inputInfo, co
}
av_dict_free(&pDict);
}
if ((m_Demux.video.codecDecode->capabilities & AV_CODEC_CAP_EXPERIMENTAL)) {
AVDictionary *pDict = nullptr;
if (0 > (ret = av_dict_set_int(&pDict, "strict", FF_COMPLIANCE_EXPERIMENTAL, 0))) {
AddMessage(RGY_LOG_ERROR, _T("Failed to set opt strict %d for decode (codec: %s): %s\n"), FF_COMPLIANCE_EXPERIMENTAL,
char_to_tstring(avcodec_get_name(m_Demux.video.stream->codecpar->codec_id)).c_str(), qsv_av_err2str(ret).c_str());
return RGY_ERR_UNKNOWN;
}
if (0 > (ret = av_opt_set_dict(m_Demux.video.codecCtxDecode, &pDict))) {
AddMessage(RGY_LOG_ERROR, _T("Failed to set opt strict for decode (codec: %s): %s\n"),
char_to_tstring(avcodec_get_name(m_Demux.video.stream->codecpar->codec_id)).c_str(), qsv_av_err2str(ret).c_str());
return RGY_ERR_UNKNOWN;
}
av_dict_free(&pDict);
}
m_Demux.video.codecCtxDecode->time_base = av_stream_get_codec_timebase(m_Demux.video.stream);
m_Demux.video.codecCtxDecode->pkt_timebase = m_Demux.video.stream->time_base;
if (0 > (ret = avcodec_open2(m_Demux.video.codecCtxDecode, m_Demux.video.codecDecode, nullptr))) {
Expand Down

0 comments on commit 6c3113c

Please sign in to comment.