Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avcodec/pthread*: Mark init, free, flush functions as av_cold
Date: Sun, 9 Mar 2025 20:41:46 +0100
Message-ID: <AS8P250MB0744F76C13BF097E64F5B72F8FD72@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)

[-- Attachment #1: Type: text/plain, Size: 27 bytes --]

Patch attached.

- Andreas

[-- Attachment #2: 0001-avcodec-pthread-Mark-init-free-flush-functions-as-av.patch --]
[-- Type: text/x-patch, Size: 5043 bytes --]

From a191274eb48dd03752ba637e7e50efaa53992c36 Mon Sep 17 00:00:00 2001
From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Date: Sun, 9 Mar 2025 20:39:25 +0100
Subject: [PATCH] avcodec/pthread*: Mark init, free, flush functions as av_cold

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/pthread.c       |  8 ++++----
 libavcodec/pthread_frame.c | 10 +++++-----
 libavcodec/pthread_slice.c | 11 ++++-------
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index d32e56de0d..6d604566e3 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -29,13 +29,13 @@
  * @see doc/multithreading.txt
  */
 
+#include "libavutil/attributes.h"
 #include "libavutil/thread.h"
 
 #include "avcodec.h"
 #include "avcodec_internal.h"
 #include "codec_internal.h"
 #include "pthread_internal.h"
-#include "thread.h"
 
 /**
  * Set the threading algorithms used.
@@ -46,7 +46,7 @@
  *
  * @param avctx The context.
  */
-static void validate_thread_parameters(AVCodecContext *avctx)
+static av_cold void validate_thread_parameters(AVCodecContext *avctx)
 {
     int frame_threading_supported = (avctx->codec->capabilities & AV_CODEC_CAP_FRAME_THREADS)
                                 && !(avctx->flags  & AV_CODEC_FLAG_LOW_DELAY)
@@ -69,7 +69,7 @@ static void validate_thread_parameters(AVCodecContext *avctx)
                avctx->thread_count, MAX_AUTO_THREADS);
 }
 
-int ff_thread_init(AVCodecContext *avctx)
+av_cold int ff_thread_init(AVCodecContext *avctx)
 {
     validate_thread_parameters(avctx);
 
@@ -81,7 +81,7 @@ int ff_thread_init(AVCodecContext *avctx)
     return 0;
 }
 
-void ff_thread_free(AVCodecContext *avctx)
+av_cold void ff_thread_free(AVCodecContext *avctx)
 {
     if (avctx->active_thread_type&FF_THREAD_FRAME)
         ff_frame_thread_free(avctx, avctx->thread_count);
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index d9df0d62a8..b982315f4e 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -718,7 +718,7 @@ void ff_thread_finish_setup(AVCodecContext *avctx) {
 }
 
 /// Waits for all threads to finish.
-static void park_frame_worker_threads(FrameThreadContext *fctx, int thread_count)
+static av_cold void park_frame_worker_threads(FrameThreadContext *fctx, int thread_count)
 {
     int i;
 
@@ -750,7 +750,7 @@ DEFINE_OFFSET_ARRAY(PerThreadContext, per_thread, pthread_init_cnt,
                     (OFF(input_cond), OFF(progress_cond), OFF(output_cond)));
 #undef OFF
 
-void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
+av_cold void ff_frame_thread_free(AVCodecContext *avctx, int thread_count)
 {
     FrameThreadContext *fctx = avctx->internal->thread_ctx;
     const FFCodec *codec = ffcodec(avctx->codec);
@@ -922,7 +922,7 @@ static av_cold int init_thread(PerThreadContext *p, int *threads_to_free,
     return 0;
 }
 
-int ff_frame_thread_init(AVCodecContext *avctx)
+av_cold int ff_frame_thread_init(AVCodecContext *avctx)
 {
     int thread_count = avctx->thread_count;
     const FFCodec *codec = ffcodec(avctx->codec);
@@ -985,7 +985,7 @@ error:
     return err;
 }
 
-void ff_thread_flush(AVCodecContext *avctx)
+av_cold void ff_thread_flush(AVCodecContext *avctx)
 {
     int i;
     FrameThreadContext *fctx = avctx->internal->thread_ctx;
@@ -1087,7 +1087,7 @@ void ff_thread_release_ext_buffer(ThreadFrame *f)
         av_frame_unref(f->f);
 }
 
-enum ThreadingStatus ff_thread_sync_ref(AVCodecContext *avctx, size_t offset)
+av_cold enum ThreadingStatus ff_thread_sync_ref(AVCodecContext *avctx, size_t offset)
 {
     PerThreadContext *p;
     const void *ref;
diff --git a/libavcodec/pthread_slice.c b/libavcodec/pthread_slice.c
index ac455e48ed..83d5c1b16a 100644
--- a/libavcodec/pthread_slice.c
+++ b/libavcodec/pthread_slice.c
@@ -22,19 +22,16 @@
  * @see doc/multithreading.txt
  */
 
-#include "config.h"
-
 #include "avcodec.h"
 #include "codec_internal.h"
 #include "internal.h"
 #include "pthread_internal.h"
 #include "thread.h"
 
-#include "libavutil/avassert.h"
-#include "libavutil/common.h"
+#include "libavutil/attributes.h"
 #include "libavutil/cpu.h"
+#include "libavutil/macros.h"
 #include "libavutil/mem.h"
-#include "libavutil/thread.h"
 #include "libavutil/slicethread.h"
 
 typedef int (action_func)(AVCodecContext *c, void *arg);
@@ -69,7 +66,7 @@ static void worker_func(void *priv, int jobnr, int threadnr, int nb_jobs, int nb
         c->rets[jobnr] = ret;
 }
 
-void ff_slice_thread_free(AVCodecContext *avctx)
+av_cold void ff_slice_thread_free(AVCodecContext *avctx)
 {
     SliceThreadContext *c = avctx->internal->thread_ctx;
 
@@ -112,7 +109,7 @@ int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, action_func2* f
     return thread_execute(avctx, NULL, arg, ret, job_count, 0);
 }
 
-int ff_slice_thread_init(AVCodecContext *avctx)
+av_cold int ff_slice_thread_init(AVCodecContext *avctx)
 {
     SliceThreadContext *c;
     int thread_count = avctx->thread_count;
-- 
2.45.2


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

                 reply	other threads:[~2025-03-09 19:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AS8P250MB0744F76C13BF097E64F5B72F8FD72@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
    --to=andreas.rheinhardt@outlook.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git