diff --git a/src/sender.c b/src/sender.c index db6dc3a6d..5a67843e2 100644 --- a/src/sender.c +++ b/src/sender.c @@ -301,9 +301,7 @@ static void *sender_thread(void *arg) { data->send_frame(data->tx_module_state, tx_frame); } - if (tx_frame->dispose) { - tx_frame->dispose(tx_frame); - } + VIDEO_FRAME_DISPOSE(tx_frame); if (data->rxtx_protocol == ULTRAGRID_RTP || data->rxtx_protocol == H264_STD) { struct ultragrid_rtp_state *rtp_state = data->tx_module_state; diff --git a/src/utils/vf_split.cpp b/src/utils/vf_split.cpp index e1048194c..faa8996ea 100644 --- a/src/utils/vf_split.cpp +++ b/src/utils/vf_split.cpp @@ -151,9 +151,7 @@ struct dispose_original_frame_udata { pthread_mutex_lock(&inst->m_lock); inst->m_disposed++; if (inst->m_disposed == inst->m_original_frame->tile_count) { - if (inst->m_original_frame->dispose) { - inst->m_original_frame->dispose(inst->m_original_frame); - } + VIDEO_FRAME_DISPOSE(inst->m_original_frame); pthread_mutex_unlock(&inst->m_lock); delete inst; } diff --git a/src/utils/video_frame_pool.h b/src/utils/video_frame_pool.h index dc844b6cd..e76eded26 100644 --- a/src/utils/video_frame_pool.h +++ b/src/utils/video_frame_pool.h @@ -68,8 +68,7 @@ struct auto_video_frame_disposer { } ~auto_video_frame_disposer() { - if (m_frame->dispose) - m_frame->dispose(m_frame); + VIDEO_FRAME_DISPOSE(m_frame); } struct video_frame *m_frame; diff --git a/src/video_compress.cpp b/src/video_compress.cpp index d9011197c..541ffd59b 100644 --- a/src/video_compress.cpp +++ b/src/video_compress.cpp @@ -591,8 +591,7 @@ static struct video_frame *compress_frame_tiles(struct compress_state_real *s, if (failed) { for(unsigned int i = 0; i < frame->tile_count; ++i) { - if (compressed_tiles[i] && compressed_tiles[i]->dispose) - compressed_tiles[i]->dispose(compressed_tiles[i]); + VIDEO_FRAME_DISPOSE(compressed_tiles[i]); } return NULL; } diff --git a/src/video_compress/cuda_dxt.cpp b/src/video_compress/cuda_dxt.cpp index ee12e952a..47312a9c6 100644 --- a/src/video_compress/cuda_dxt.cpp +++ b/src/video_compress/cuda_dxt.cpp @@ -204,8 +204,6 @@ struct video_frame *cuda_dxt_compress_tile(struct module *mod, struct video_fram s->saved_desc = video_desc_from_frame(tx); } else { fprintf(stderr, "[CUDA DXT] Reconfiguration failed!\n"); - if (tx->dispose) - tx->dispose(tx); return NULL; } } diff --git a/src/video_compress/libavcodec.c b/src/video_compress/libavcodec.c index 1fed510b8..d8964d01e 100644 --- a/src/video_compress/libavcodec.c +++ b/src/video_compress/libavcodec.c @@ -692,14 +692,12 @@ struct video_frame *libavcodec_compress_tile(struct module *mod, struct video_fr platform_spin_unlock(&s->spin); - if (tx->dispose) - tx->dispose(tx); + VIDEO_FRAME_DISPOSE(tx); return out; error: - if (tx->dispose) - tx->dispose(tx); + VIDEO_FRAME_DISPOSE(tx); platform_spin_unlock(&s->spin); return NULL; } diff --git a/src/video_frame.h b/src/video_frame.h index e93383298..4504beea5 100644 --- a/src/video_frame.h +++ b/src/video_frame.h @@ -64,6 +64,9 @@ extern "C" { #define PARAM_TILE_COUNT (1<<6u) /**@}*/ +#define VIDEO_FRAME_DISPOSE(frame) if (frame && frame->dispose) \ + frame->dispose(frame) + /** * @brief Allocates blank video frame * @param count number of allocated tiles