From bd734e2959f5bad5392270216cad0c398981dbcb Mon Sep 17 00:00:00 2001 From: rigaya Date: Sat, 23 Mar 2024 22:50:00 +0900 Subject: [PATCH] =?UTF-8?q?av=5Ffreep=E3=81=AE=E4=BD=BF=E3=81=84=E6=96=B9?= =?UTF-8?q?=E3=81=8C=E8=AA=A4=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NVEncCore/rgy_avutil.h | 10 +++++----- NVEncCore/rgy_input_avcodec.cpp | 8 ++++---- NVEncCore/rgy_input_avcodec.h | 4 ++-- NVEncCore/rgy_output_avcodec.cpp | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/NVEncCore/rgy_avutil.h b/NVEncCore/rgy_avutil.h index 8267f1a3..d69c0081 100644 --- a/NVEncCore/rgy_avutil.h +++ b/NVEncCore/rgy_avutil.h @@ -406,13 +406,13 @@ std::string tagToStr(uint32_t tag); //AVStreamのside data関連 template -std::unique_ptr AVStreamGetSideData(const AVStream *stream, const AVPacketSideDataType type, size_t& side_data_size) { - std::unique_ptr side_data_copy(nullptr, av_freep); +std::unique_ptr> AVStreamGetSideData(const AVStream *stream, const AVPacketSideDataType type, size_t& side_data_size) { + std::unique_ptr> side_data_copy(nullptr, RGYAVDeleter(av_freep)); #if AVCODEC_PAR_CODED_SIDE_DATA_AVAIL auto side_data = av_packet_side_data_get(stream->codecpar->coded_side_data, stream->codecpar->nb_coded_side_data, type); if (side_data) { side_data_size = side_data->size; - side_data_copy = unique_ptr((T *)av_malloc(side_data->size + AV_INPUT_BUFFER_PADDING_SIZE), av_freep); + side_data_copy = unique_ptr>((T *)av_malloc(side_data->size + AV_INPUT_BUFFER_PADDING_SIZE), RGYAVDeleter(av_freep)); memcpy(side_data_copy.get(), side_data, side_data->size); } #else @@ -420,7 +420,7 @@ std::unique_ptr AVStreamGetSideData(const AVStream *stre auto side_data = av_stream_get_side_data(stream, type, &size); side_data_size = size; if (side_data) { - side_data_copy = unique_ptr((T *)av_malloc(side_data_size + AV_INPUT_BUFFER_PADDING_SIZE), av_freep); + side_data_copy = unique_ptr>((T *)av_malloc(side_data_size + AV_INPUT_BUFFER_PADDING_SIZE), RGYAVDeleter(av_freep)); memcpy(side_data_copy.get(), side_data, side_data_size); } #endif @@ -428,7 +428,7 @@ std::unique_ptr AVStreamGetSideData(const AVStream *stre } template -int AVStreamAddSideData(AVStream *stream, const AVPacketSideDataType type, std::unique_ptr& side_data, const size_t side_data_size) { +int AVStreamAddSideData(AVStream *stream, const AVPacketSideDataType type, std::unique_ptr>& side_data, const size_t side_data_size) { #if AVCODEC_PAR_CODED_SIDE_DATA_AVAIL auto ptr = av_packet_side_data_add(&stream->codecpar->coded_side_data, &stream->codecpar->nb_coded_side_data, type, (void *)side_data.get(), side_data_size, 0); int ret = ptr ? 0 : AVERROR(ENOMEM); diff --git a/NVEncCore/rgy_input_avcodec.cpp b/NVEncCore/rgy_input_avcodec.cpp index e874ae19..32550e72 100644 --- a/NVEncCore/rgy_input_avcodec.cpp +++ b/NVEncCore/rgy_input_avcodec.cpp @@ -136,8 +136,8 @@ AVDemuxVideo::AVDemuxVideo() : hevcNaluLengthSize(0), hdr10plusMetadataCopy(false), doviRpuCopy(false), - masteringDisplay(std::unique_ptr(nullptr, av_freep)), - contentLight(std::unique_ptr(nullptr, av_freep)), + masteringDisplay(std::unique_ptr>(nullptr, RGYAVDeleter(av_freep))), + contentLight(std::unique_ptr>(nullptr, RGYAVDeleter(av_freep))), qpTableListRef(nullptr), parse_nal_h264(get_parse_nal_unit_h264_func()), parse_nal_hevc(get_parse_nal_unit_hevc_func()) { @@ -1187,7 +1187,7 @@ RGY_ERR RGYInputAvcodec::parseHDRData() { if (got_frame) { auto side_data = av_frame_get_side_data(frameDec.get(), AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); if (side_data) { - m_Demux.video.masteringDisplay = std::unique_ptr(av_mastering_display_metadata_alloc(), av_freep); + m_Demux.video.masteringDisplay = std::unique_ptr>(av_mastering_display_metadata_alloc(), RGYAVDeleter(av_freep)); memcpy(m_Demux.video.masteringDisplay.get(), side_data->data, sizeof(AVMasteringDisplayMetadata)); AddMessage(RGY_LOG_DEBUG, _T("Mastering Display: R(%f,%f) G(%f,%f) B(%f %f) WP(%f, %f) L(%f,%f)\n"), av_q2d(m_Demux.video.masteringDisplay->display_primaries[0][0]), @@ -1202,7 +1202,7 @@ RGY_ERR RGYInputAvcodec::parseHDRData() { side_data = av_frame_get_side_data(frameDec.get(), AV_FRAME_DATA_CONTENT_LIGHT_LEVEL); if (side_data) { size_t st_size = 0; - m_Demux.video.contentLight = std::unique_ptr(av_content_light_metadata_alloc(&st_size), av_freep); + m_Demux.video.contentLight = std::unique_ptr>(av_content_light_metadata_alloc(&st_size), RGYAVDeleter(av_freep)); memcpy(m_Demux.video.contentLight.get(), side_data->data, st_size); AddMessage(RGY_LOG_DEBUG, _T("MaxCLL=%d, MaxFALL=%d\n"), m_Demux.video.contentLight->MaxCLL, m_Demux.video.contentLight->MaxFALL); } diff --git a/NVEncCore/rgy_input_avcodec.h b/NVEncCore/rgy_input_avcodec.h index 444ea10b..9cc18ab5 100644 --- a/NVEncCore/rgy_input_avcodec.h +++ b/NVEncCore/rgy_input_avcodec.h @@ -741,8 +741,8 @@ struct AVDemuxVideo { bool hdr10plusMetadataCopy; //HDR10plusのメタ情報を取得する bool doviRpuCopy; //dovi rpuのメタ情報を取得する - std::unique_ptr masteringDisplay; //入力ファイルから抽出したHDRメタ情報 - std::unique_ptr contentLight; //入力ファイルから抽出したHDRメタ情報 + std::unique_ptr> masteringDisplay; //入力ファイルから抽出したHDRメタ情報 + std::unique_ptr> contentLight; //入力ファイルから抽出したHDRメタ情報 RGYListRef *qpTableListRef; //qp tableを格納するときのベース構造体 decltype(parse_nal_unit_h264_c) *parse_nal_h264; // H.264用のnal unit分解関数へのポインタ diff --git a/NVEncCore/rgy_output_avcodec.cpp b/NVEncCore/rgy_output_avcodec.cpp index 62c5061f..764cac16 100644 --- a/NVEncCore/rgy_output_avcodec.cpp +++ b/NVEncCore/rgy_output_avcodec.cpp @@ -948,7 +948,7 @@ RGY_ERR RGYOutputAvcodec::InitVideo(const VideoInfo *videoOutputInfo, const Avco const auto HEVCHdrSeiPrm = prm->hdrMetadata->getprm(); if (false && HEVCHdrSeiPrm.masterdisplay_set) { - std::unique_ptr mastering(av_mastering_display_metadata_alloc(), av_freep); + std::unique_ptr> mastering(av_mastering_display_metadata_alloc(), RGYAVDeleter(av_freep)); //streamのside dataとしてmasteringdisplay等を設定する mastering->display_primaries[1][0] = av_make_q(HEVCHdrSeiPrm.masterdisplay[0]); //G @@ -984,7 +984,7 @@ RGY_ERR RGYOutputAvcodec::InitVideo(const VideoInfo *videoOutputInfo, const Avco if (false && HEVCHdrSeiPrm.contentlight_set) { size_t coll_size = 0; - std::unique_ptr coll(av_content_light_metadata_alloc(&coll_size), av_freep); + std::unique_ptr> coll(av_content_light_metadata_alloc(&coll_size), RGYAVDeleter(av_freep)); coll->MaxCLL = HEVCHdrSeiPrm.maxcll; coll->MaxFALL = HEVCHdrSeiPrm.maxfall; AddMessage(RGY_LOG_DEBUG, _T("MaxCLL=%d, MaxFALL=%d\n"),