From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 07/10] avcodec/rl: Don't pretend ff_rl_init() initializes a RLTable twice
Date: Wed, 5 Jan 2022 22:56:07 +0100
Message-ID: <AM7PR03MB6660E3B9271AD6353FF5627B8F4B9@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw)
In-Reply-To: <AM7PR03MB6660E16D4E4345D825454C178F4B9@AM7PR03MB6660.eurprd03.prod.outlook.com>
It can't any longer, because all users of ff_rl_init() are now
behind ff_thread_once() or the global codec lock. Therefore
the check for whether the RLTable is already initialized can be removed;
as can the stack buffers that existed to make sure that nothing is ever
set to a value different from its final value.
Similarly, it is not necessary to check whether the VLCs associated
with the RLTable are already initialized (they aren't).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/rl.c | 20 ++++++--------------
libavcodec/rl.h | 9 +++------
2 files changed, 9 insertions(+), 20 deletions(-)
diff --git a/libavcodec/rl.c b/libavcodec/rl.c
index fab96d63a1..4ce003ccf4 100644
--- a/libavcodec/rl.c
+++ b/libavcodec/rl.c
@@ -27,16 +27,13 @@
av_cold void ff_rl_init(RLTable *rl,
uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
{
- int8_t max_level[MAX_RUN + 1], max_run[MAX_LEVEL + 1];
- uint8_t index_run[MAX_RUN + 1];
int last, run, level, start, end, i;
- /* If rl->max_level[0] is set, this RLTable has already been initialized */
- if (rl->max_level[0])
- return;
-
/* compute max_level[], max_run[] and index_run[] */
for (last = 0; last < 2; last++) {
+ int8_t *max_level = static_store[last];
+ int8_t *max_run = static_store[last] + MAX_RUN + 1;
+ uint8_t *index_run = static_store[last] + MAX_RUN + 1 + MAX_LEVEL + 1;
if (last == 0) {
start = 0;
end = rl->last;
@@ -45,8 +42,6 @@ av_cold void ff_rl_init(RLTable *rl,
end = rl->n;
}
- memset(max_level, 0, MAX_RUN + 1);
- memset(max_run, 0, MAX_LEVEL + 1);
memset(index_run, rl->n, MAX_RUN + 1);
for (i = start; i < end; i++) {
run = rl->table_run[i];
@@ -58,12 +53,9 @@ av_cold void ff_rl_init(RLTable *rl,
if (run > max_run[level])
max_run[level] = run;
}
- rl->max_level[last] = static_store[last];
- memcpy(rl->max_level[last], max_level, MAX_RUN + 1);
- rl->max_run[last] = static_store[last] + MAX_RUN + 1;
- memcpy(rl->max_run[last], max_run, MAX_LEVEL + 1);
- rl->index_run[last] = static_store[last] + MAX_RUN + MAX_LEVEL + 2;
- memcpy(rl->index_run[last], index_run, MAX_RUN + 1);
+ rl->max_level[last] = max_level;
+ rl->max_run[last] = max_run;
+ rl->index_run[last] = index_run;
}
}
diff --git a/libavcodec/rl.h b/libavcodec/rl.h
index 5aae698e31..07e3da5003 100644
--- a/libavcodec/rl.h
+++ b/libavcodec/rl.h
@@ -72,15 +72,12 @@ void ff_rl_init_vlc(RLTable *rl, unsigned static_size);
#define INIT_VLC_RL(rl, static_size)\
{\
- int q;\
static RL_VLC_ELEM rl_vlc_table[32][static_size];\
\
- if(!rl.rl_vlc[0]){\
- for(q=0; q<32; q++)\
- rl.rl_vlc[q]= rl_vlc_table[q];\
+ for (int q = 0; q < 32; q++) \
+ rl.rl_vlc[q] = rl_vlc_table[q]; \
\
- ff_rl_init_vlc(&rl, static_size);\
- }\
+ ff_rl_init_vlc(&rl, static_size); \
}
#define INIT_FIRST_VLC_RL(rl, static_size) \
--
2.32.0
_______________________________________________
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".
next prev parent reply other threads:[~2022-01-05 21:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-05 21:53 [FFmpeg-devel] [PATCH 01/10] avcodec/mpeg12dec: Don't set write-only variable Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 02/10] avcodec/mpegvideo: Don't unnecessarily allocate buffers Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 03/10] avcodec/mpegvideo: Avoid macro/av_calloc for ordinary allocations Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 04/10] avcodec/h263: Move functions only used once to their caller Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 05/10] avcodec/mpeg4video: Skip unneeded element when parsing picture header Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 06/10] avcodec/mpeg4videodec: Fix data race when initializing VLCs Andreas Rheinhardt
2022-01-05 21:56 ` Andreas Rheinhardt [this message]
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 08/10] avcodec/bitstream: Don't pretend VLCs to be initialized concurrently Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 09/10] avcodec: Remove unnecessary h263.h inclusions Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 10/10] avcodec/avcodec: Remove outdated comment Andreas Rheinhardt
2022-01-05 22:21 ` Marvin Scholz
2022-01-06 7:08 ` Andreas Rheinhardt
2022-01-08 13:08 ` [FFmpeg-devel] [PATCH 01/10] avcodec/mpeg12dec: Don't set write-only variable Andreas Rheinhardt
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=AM7PR03MB6660E3B9271AD6353FF5627B8F4B9@AM7PR03MB6660.eurprd03.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