From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 2/6] avcodec/mpegvideodata: Join mpeg1/2 dc scale tables
Date: Fri, 28 Oct 2022 16:49:42 +0200
Message-ID: <AS8P250MB07445D58BEB537DB691CF1108F329@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB074477D545EEBC518DE29CB48F329@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>
Avoids relocations.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 2 +-
libavcodec/mpegvideo_enc.c | 4 ++--
libavcodec/mpegvideodata.c | 26 +++++++++-----------------
libavcodec/mpegvideodata.h | 4 ++--
libavcodec/speedhqenc.c | 2 +-
5 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 2db1d93d0e..3ad1cd84a1 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1148,7 +1148,7 @@ av_cold void ff_mpeg1_encode_init(MpegEncContext *s)
static AVOnce init_static_once = AV_ONCE_INIT;
s->y_dc_scale_table =
- s->c_dc_scale_table = ff_mpeg2_dc_scale_table[s->intra_dc_precision];
+ s->c_dc_scale_table = ff_mpeg12_dc_scale_table[s->intra_dc_precision];
s->me.mv_penalty = mv_penalty;
s->fcode_tab = fcode_tab;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index ce363a585d..46be4aad26 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -3736,9 +3736,9 @@ static int encode_picture(MpegEncContext *s, int picture_number)
s-> intra_matrix[j] = av_clip_uint8(( luma_matrix[i] * s->qscale) >> 3);
}
s->y_dc_scale_table=
- s->c_dc_scale_table= ff_mpeg2_dc_scale_table[s->intra_dc_precision];
+ s->c_dc_scale_table = ff_mpeg12_dc_scale_table[s->intra_dc_precision];
s->chroma_intra_matrix[0] =
- s->intra_matrix[0] = ff_mpeg2_dc_scale_table[s->intra_dc_precision][8];
+ s->intra_matrix[0] = ff_mpeg12_dc_scale_table[s->intra_dc_precision][8];
ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16,
s->intra_matrix, s->intra_quant_bias, 8, 8, 1);
ff_convert_matrix(s, s->q_chroma_intra_matrix, s->q_chroma_intra_matrix16,
diff --git a/libavcodec/mpegvideodata.c b/libavcodec/mpegvideodata.c
index b98e90cf43..68ad84276e 100644
--- a/libavcodec/mpegvideodata.c
+++ b/libavcodec/mpegvideodata.c
@@ -30,31 +30,23 @@ const uint8_t ff_mpeg2_non_linear_qscale[32] = {
56, 64, 72, 80, 88, 96, 104, 112,
};
-const uint8_t ff_mpeg1_dc_scale_table[32] = {
+const uint8_t ff_mpeg12_dc_scale_table[4][32] = {
+{
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
-};
-
-static const uint8_t mpeg2_dc_scale_table1[32] = {
+},
+{
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
-};
-
-static const uint8_t mpeg2_dc_scale_table2[32] = {
+},
+{
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-};
-
-static const uint8_t mpeg2_dc_scale_table3[32] = {
+},
+{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-};
-
-const uint8_t *const ff_mpeg2_dc_scale_table[4] = {
- ff_mpeg1_dc_scale_table,
- mpeg2_dc_scale_table1,
- mpeg2_dc_scale_table2,
- mpeg2_dc_scale_table3,
+},
};
const uint8_t ff_alternate_horizontal_scan[64] = {
diff --git a/libavcodec/mpegvideodata.h b/libavcodec/mpegvideodata.h
index cf783ef31c..7264b434ae 100644
--- a/libavcodec/mpegvideodata.h
+++ b/libavcodec/mpegvideodata.h
@@ -25,8 +25,8 @@
extern const uint8_t ff_alternate_horizontal_scan[64];
extern const uint8_t ff_alternate_vertical_scan[64];
-extern const uint8_t ff_mpeg1_dc_scale_table[32];
-extern const uint8_t * const ff_mpeg2_dc_scale_table[4];
+extern const uint8_t ff_mpeg12_dc_scale_table[4][32];
+static const uint8_t *const ff_mpeg1_dc_scale_table = ff_mpeg12_dc_scale_table[0];
extern const uint8_t ff_mpeg2_non_linear_qscale[32];
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 65e66afae4..7269e345d3 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -115,7 +115,7 @@ av_cold int ff_speedhq_encode_init(MpegEncContext *s)
s->intra_chroma_ac_vlc_last_length = uni_speedhq_ac_vlc_len;
s->y_dc_scale_table =
- s->c_dc_scale_table = ff_mpeg2_dc_scale_table[3];
+ s->c_dc_scale_table = ff_mpeg12_dc_scale_table[3];
switch (s->avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
--
2.34.1
_______________________________________________
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-10-28 14:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 14:48 [FFmpeg-devel] [PATCH 1/6] avcodec/mpegvideodata: Make DC scale tables smaller Andreas Rheinhardt
2022-10-28 14:49 ` Andreas Rheinhardt [this message]
2022-10-28 14:49 ` [FFmpeg-devel] [PATCH 3/6] avcodec/mpegvideodata: Mark tables as hidden Andreas Rheinhardt
2022-10-28 14:49 ` [FFmpeg-devel] [PATCH 4/6] avcodec/flvdec, intelh263dec: Remove redundant assignments Andreas Rheinhardt
2022-10-28 14:49 ` [FFmpeg-devel] [PATCH 5/6] avcodec/rv34: Remove always-true/false checks Andreas Rheinhardt
2022-10-28 14:49 ` [FFmpeg-devel] [PATCH 6/6] avcodec/vc1data: Mark tables as hidden Andreas Rheinhardt
2022-10-30 11:13 ` [FFmpeg-devel] [PATCH 1/6] avcodec/mpegvideodata: Make DC scale tables smaller 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=AS8P250MB07445D58BEB537DB691CF1108F329@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