From 529844be37499a18c76153a7af36557be1f2b7b1 Mon Sep 17 00:00:00 2001 From: Norihiro Kamae Date: Tue, 6 Aug 2024 09:41:36 +0900 Subject: [PATCH] Remove redundant get() call on std::shared_ptr Also fix them. - replaces reference-type of std::shared_ptr with the base pointer type for readability. - Fix `return NULL` where it should be `return false`. --- src/face-tracker-ptz.cpp | 15 ++++++++------- src/face-tracker.cpp | 6 +++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/face-tracker-ptz.cpp b/src/face-tracker-ptz.cpp index 0654bb4..dd6fcec 100644 --- a/src/face-tracker-ptz.cpp +++ b/src/face-tracker-ptz.cpp @@ -900,7 +900,7 @@ static inline bool operator != (const struct video_scale_info &a, const struct v return false; } -static bool scale_set_texture(struct face_tracker_ptz *s, std::shared_ptr &cvtex, struct obs_source_frame *frame) +static bool scale_set_texture(struct face_tracker_ptz *s, texture_object *cvtex, struct obs_source_frame *frame) { const struct video_scale_info scaler_src_info = { frame->format, @@ -946,10 +946,10 @@ static bool scale_set_texture(struct face_tracker_ptz *s, std::shared_ptrscaler, scaled_frame.data, scaled_frame.linesize, frame->data, frame->linesize)) { blog(LOG_ERROR, "video_scaler_scale failed"); - return NULL; + return false; } - cvtex.get()->set_texture_obsframe(&scaled_frame, 1); + cvtex->set_texture_obsframe(&scaled_frame, 1); return true; } @@ -961,13 +961,14 @@ static struct obs_source_frame *ftptz_filter_video(void *data, struct obs_source auto *s = (struct face_tracker_ptz*)data; std::shared_ptr cvtex(new texture_object()); - cvtex.get()->scale = s->ftm->scale; - cvtex.get()->tick = s->ftm->tick_cnt; + cvtex->scale = s->ftm->scale; + cvtex->tick = s->ftm->tick_cnt; if (is_rgb_format(frame->format)) { - cvtex.get()->set_texture_obsframe(frame, s->ftm->scale); + cvtex->set_texture_obsframe(frame, s->ftm->scale); } else { - scale_set_texture(s, cvtex, frame); + if (!scale_set_texture(s, cvtex.get(), frame)) + return frame; } s->known_width = frame->width; diff --git a/src/face-tracker.cpp b/src/face-tracker.cpp index 68393b1..4f727f2 100644 --- a/src/face-tracker.cpp +++ b/src/face-tracker.cpp @@ -742,8 +742,8 @@ static inline std::shared_ptr surface_to_cvtex(struct face_track uint32_t height = gs_stagesurface_get_height(s->stagesurface); std::shared_ptr cvtex(new texture_object); - cvtex.get()->scale = scale; - cvtex.get()->tick = s->ftm->tick_cnt; + cvtex->scale = scale; + cvtex->tick = s->ftm->tick_cnt; struct obs_source_frame frame; memset(&frame, 0, sizeof(frame)); @@ -752,7 +752,7 @@ static inline std::shared_ptr surface_to_cvtex(struct face_track frame.width = width; frame.height = height; frame.format = VIDEO_FORMAT_BGRA; - cvtex.get()->set_texture_obsframe(&frame, 1); + cvtex->set_texture_obsframe(&frame, 1); gs_stagesurface_unmap(s->stagesurface);