* [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call
@ 2022-10-23 19:34 Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 02/17] avformat/mux: Don't call ff_toupper4() unnecessarily Andreas Rheinhardt
` (16 more replies)
0 siblings, 17 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:34 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Redundant since dcb29d37d4ffedc84e44df99f8d22ecf27e0f2cd.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
It is of course only redundant if avctx->codec_tag is not allowed
to change after avcodec_open2(); the corresponding option is not
marked with the AV_OPT_FLAG_RUNTIME_PARAM and the above mentioned
commit also relies on this, so I do, too.
Btw: I wonder whether vcr2_init_sequence() should not simply be called
during init.
libavcodec/mpeg12dec.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 56bf73df11..c942be158e 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2797,7 +2797,6 @@ static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture,
}
#endif
- s2->codec_tag = ff_toupper4(avctx->codec_tag);
if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2")
|| s2->codec_tag == AV_RL32("BW10")
))
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 02/17] avformat/mux: Don't call ff_toupper4() unnecessarily
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
@ 2022-10-23 19:35 ` Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 03/17] avformat/mux: Constify validate_codec_tag() Andreas Rheinhardt
` (15 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/mux.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libavformat/mux.c b/libavformat/mux.c
index 5d89458f82..a7517dae0a 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -148,6 +148,7 @@ static int validate_codec_tag(AVFormatContext *s, AVStream *st)
{
const AVCodecTag *avctag;
enum AVCodecID id = AV_CODEC_ID_NONE;
+ unsigned uppercase_tag = ff_toupper4(st->codecpar->codec_tag);
int64_t tag = -1;
/**
@@ -159,7 +160,7 @@ static int validate_codec_tag(AVFormatContext *s, AVStream *st)
for (int n = 0; s->oformat->codec_tag[n]; n++) {
avctag = s->oformat->codec_tag[n];
while (avctag->id != AV_CODEC_ID_NONE) {
- if (ff_toupper4(avctag->tag) == ff_toupper4(st->codecpar->codec_tag)) {
+ if (ff_toupper4(avctag->tag) == uppercase_tag) {
id = avctag->id;
if (id == st->codecpar->codec_id)
return 1;
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 03/17] avformat/mux: Constify validate_codec_tag()
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 02/17] avformat/mux: Don't call ff_toupper4() unnecessarily Andreas Rheinhardt
@ 2022-10-23 19:35 ` Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 04/17] avcodec/mpeg12: Avoid indirection when accessing rl_vlc tables Andreas Rheinhardt
` (14 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/mux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/mux.c b/libavformat/mux.c
index a7517dae0a..37fe19358d 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -144,7 +144,7 @@ error:
return ret;
}
-static int validate_codec_tag(AVFormatContext *s, AVStream *st)
+static int validate_codec_tag(const AVFormatContext *s, const AVStream *st)
{
const AVCodecTag *avctag;
enum AVCodecID id = AV_CODEC_ID_NONE;
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 04/17] avcodec/mpeg12: Avoid indirection when accessing rl_vlc tables
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 02/17] avformat/mux: Don't call ff_toupper4() unnecessarily Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 03/17] avformat/mux: Constify validate_codec_tag() Andreas Rheinhardt
@ 2022-10-23 19:35 ` Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 05/17] avcodec/mpeg12enc: Avoid unnecessary indirection Andreas Rheinhardt
` (13 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/eamad.c | 3 +--
libavcodec/mdec.c | 3 +--
libavcodec/mpeg12.c | 19 +++++++++++--------
libavcodec/mpeg12dec.c | 28 ++++++++++++----------------
libavcodec/mpeg12vlc.h | 14 +++++++-------
libavcodec/speedhqdec.c | 6 ++++--
6 files changed, 36 insertions(+), 37 deletions(-)
diff --git a/libavcodec/eamad.c b/libavcodec/eamad.c
index 2a5aac912d..20f347f0ab 100644
--- a/libavcodec/eamad.c
+++ b/libavcodec/eamad.c
@@ -134,7 +134,6 @@ static inline void idct_put(MadContext *t, AVFrame *frame, int16_t *block,
static inline int decode_block_intra(MadContext *s, int16_t * block)
{
int level, i, j, run;
- RLTable *rl = &ff_rl_mpeg1;
const uint8_t *scantable = s->scantable.permutated;
int16_t *quant_matrix = s->quant_matrix;
@@ -148,7 +147,7 @@ static inline int decode_block_intra(MadContext *s, int16_t * block)
/* now quantify & encode AC coefficients */
for (;;) {
UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+ GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
index f27cf84122..7116b73b8e 100644
--- a/libavcodec/mdec.c
+++ b/libavcodec/mdec.c
@@ -63,7 +63,6 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
{
int level, diff, i, j, run;
int component;
- RLTable *rl = &ff_rl_mpeg1;
uint8_t * const scantable = a->scantable.permutated;
const uint16_t *quant_matrix = a->quant_matrix;
const int qscale = a->qscale;
@@ -84,7 +83,7 @@ static inline int mdec_decode_block_intra(MDECContext *a, int16_t *block, int n)
/* now quantify & encode AC coefficients */
for (;;) {
UPDATE_CACHE(re, &a->gb);
- GET_RL_VLC(level, run, re, &a->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+ GET_RL_VLC(level, run, re, &a->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index df6aba9d74..351ebf420f 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -63,7 +63,8 @@ static const uint8_t table_mb_btype[11][2] = {
{ 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
};
-av_cold void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags)
+av_cold void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[],
+ unsigned static_size, int flags)
{
int i;
VLCElem table[680] = { 0 };
@@ -94,9 +95,9 @@ av_cold void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags)
level = rl->table_level[code];
}
}
- rl->rl_vlc[0][i].len = len;
- rl->rl_vlc[0][i].level = level;
- rl->rl_vlc[0][i].run = run;
+ rl_vlc[i].len = len;
+ rl_vlc[i].level = level;
+ rl_vlc[i].run = run;
}
}
@@ -122,6 +123,9 @@ VLC ff_mb_ptype_vlc;
VLC ff_mb_btype_vlc;
VLC ff_mb_pat_vlc;
+RL_VLC_ELEM ff_mpeg1_rl_vlc[680];
+RL_VLC_ELEM ff_mpeg2_rl_vlc[674];
+
static av_cold void mpeg12_init_vlcs(void)
{
INIT_VLC_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12,
@@ -147,8 +151,8 @@ static av_cold void mpeg12_init_vlcs(void)
&table_mb_btype[0][1], 2, 1,
&table_mb_btype[0][0], 2, 1, 64);
- INIT_2D_VLC_RL(ff_rl_mpeg1, 680, 0);
- INIT_2D_VLC_RL(ff_rl_mpeg2, 674, 0);
+ INIT_2D_VLC_RL(ff_rl_mpeg1, ff_mpeg1_rl_vlc, 0);
+ INIT_2D_VLC_RL(ff_rl_mpeg2, ff_mpeg2_rl_vlc, 0);
}
av_cold void ff_mpeg12_init_vlcs(void)
@@ -231,7 +235,6 @@ int ff_mpeg1_decode_block_intra(GetBitContext *gb,
int16_t *block, int index, int qscale)
{
int dc, diff, i = 0, component;
- RLTable *rl = &ff_rl_mpeg1;
/* DC coefficient */
component = index <= 3 ? 0 : index - 4 + 1;
@@ -256,7 +259,7 @@ int ff_mpeg1_decode_block_intra(GetBitContext *gb,
while (1) {
int level, run, j;
- GET_RL_VLC(level, run, re, gb, rl->rl_vlc[0],
+ GET_RL_VLC(level, run, re, gb, ff_mpeg1_rl_vlc,
TEX_VLC_BITS, 2, 0);
if (level != 0) {
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index c942be158e..914516bbd9 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -152,7 +152,6 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s,
int16_t *block, int n)
{
int level, i, j, run;
- RLTable *rl = &ff_rl_mpeg1;
uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix = s->inter_matrix;
const int qscale = s->qscale;
@@ -175,7 +174,7 @@ static inline int mpeg1_decode_block_inter(MpegEncContext *s,
}
/* now quantify & encode AC coefficients */
for (;;) {
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc,
TEX_VLC_BITS, 2, 0);
if (level != 0) {
@@ -241,7 +240,6 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s,
int16_t *block, int n)
{
int level, i, j, run;
- RLTable *rl = &ff_rl_mpeg1;
uint8_t *const scantable = s->intra_scantable.permutated;
const int qscale = s->qscale;
@@ -264,7 +262,7 @@ static inline int mpeg1_fast_decode_block_inter(MpegEncContext *s,
/* now quantify & encode AC coefficients */
for (;;) {
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc,
TEX_VLC_BITS, 2, 0);
if (level != 0) {
@@ -326,7 +324,6 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
int16_t *block, int n)
{
int level, i, j, run;
- RLTable *rl = &ff_rl_mpeg1;
uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
@@ -358,7 +355,7 @@ static inline int mpeg2_decode_block_non_intra(MpegEncContext *s,
/* now quantify & encode AC coefficients */
for (;;) {
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc,
TEX_VLC_BITS, 2, 0);
if (level != 0) {
@@ -416,7 +413,6 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
int16_t *block, int n)
{
int level, i, j, run;
- RLTable *rl = &ff_rl_mpeg1;
uint8_t *const scantable = s->intra_scantable.permutated;
const int qscale = s->qscale;
OPEN_READER(re, &s->gb);
@@ -437,7 +433,7 @@ static inline int mpeg2_fast_decode_block_non_intra(MpegEncContext *s,
/* now quantify & encode AC coefficients */
for (;;) {
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0], TEX_VLC_BITS, 2, 0);
+ GET_RL_VLC(level, run, re, &s->gb, ff_mpeg1_rl_vlc, TEX_VLC_BITS, 2, 0);
if (level != 0) {
i += run;
@@ -489,7 +485,7 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
{
int level, dc, diff, i, j, run;
int component;
- RLTable *rl;
+ const RL_VLC_ELEM *rl_vlc;
uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
@@ -512,16 +508,16 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s,
mismatch = block[0] ^ 1;
i = 0;
if (s->intra_vlc_format)
- rl = &ff_rl_mpeg2;
+ rl_vlc = ff_mpeg2_rl_vlc;
else
- rl = &ff_rl_mpeg1;
+ rl_vlc = ff_mpeg1_rl_vlc;
{
OPEN_READER(re, &s->gb);
/* now quantify & encode AC coefficients */
for (;;) {
UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ GET_RL_VLC(level, run, re, &s->gb, rl_vlc,
TEX_VLC_BITS, 2, 0);
if (level == 127) {
@@ -575,7 +571,7 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s,
{
int level, dc, diff, i, j, run;
int component;
- RLTable *rl;
+ const RL_VLC_ELEM *rl_vlc;
uint8_t *const scantable = s->intra_scantable.permutated;
const uint16_t *quant_matrix;
const int qscale = s->qscale;
@@ -595,16 +591,16 @@ static inline int mpeg2_fast_decode_block_intra(MpegEncContext *s,
block[0] = dc * (1 << (3 - s->intra_dc_precision));
i = 0;
if (s->intra_vlc_format)
- rl = &ff_rl_mpeg2;
+ rl_vlc = ff_mpeg2_rl_vlc;
else
- rl = &ff_rl_mpeg1;
+ rl_vlc = ff_mpeg1_rl_vlc;
{
OPEN_READER(re, &s->gb);
/* now quantify & encode AC coefficients */
for (;;) {
UPDATE_CACHE(re, &s->gb);
- GET_RL_VLC(level, run, re, &s->gb, rl->rl_vlc[0],
+ GET_RL_VLC(level, run, re, &s->gb, rl_vlc,
TEX_VLC_BITS, 2, 0);
if (level >= 64 || i > 63) {
diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h
index 4fb19371f0..d0083f1124 100644
--- a/libavcodec/mpeg12vlc.h
+++ b/libavcodec/mpeg12vlc.h
@@ -50,17 +50,17 @@ extern VLC ff_mv_vlc;
void ff_mpeg12_init_vlcs(void);
-#define INIT_2D_VLC_RL(rl, static_size, flags)\
-{\
- static RL_VLC_ELEM rl_vlc_table[static_size];\
- rl.rl_vlc[0] = rl_vlc_table;\
- ff_init_2d_vlc_rl(&rl, static_size, flags);\
-}
+#define INIT_2D_VLC_RL(rl, rl_vlc, flags)\
+ ff_init_2d_vlc_rl(&rl, rl_vlc, FF_ARRAY_ELEMS(rl_vlc), flags)
extern RLTable ff_rl_mpeg1;
extern RLTable ff_rl_mpeg2;
-void ff_init_2d_vlc_rl(RLTable *rl, unsigned static_size, int flags);
+extern RL_VLC_ELEM ff_mpeg1_rl_vlc[];
+extern RL_VLC_ELEM ff_mpeg2_rl_vlc[];
+
+void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[],
+ unsigned static_size, int flags);
void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len);
diff --git a/libavcodec/speedhqdec.c b/libavcodec/speedhqdec.c
index acca437bd5..7cb5ff03cc 100644
--- a/libavcodec/speedhqdec.c
+++ b/libavcodec/speedhqdec.c
@@ -77,6 +77,8 @@ static VLC dc_chroma_vlc_le;
static VLC dc_alpha_run_vlc_le;
static VLC dc_alpha_level_vlc_le;
+static RL_VLC_ELEM speedhq_rl_vlc[674];
+
static inline int decode_dc_le(GetBitContext *gb, int component)
{
int code, diff;
@@ -154,7 +156,7 @@ static inline int decode_dct_block(const SHQContext *s, GetBitContext *gb, int l
for ( ;; ) {
int level, run;
UPDATE_CACHE_LE(re, gb);
- GET_RL_VLC(level, run, re, gb, ff_rl_speedhq.rl_vlc[0],
+ GET_RL_VLC(level, run, re, gb, speedhq_rl_vlc,
TEX_VLC_BITS, 2, 0);
if (level == 127) {
break;
@@ -564,7 +566,7 @@ static av_cold void speedhq_static_init(void)
ff_mpeg12_vlc_dc_chroma_code, 2, 2,
INIT_VLC_OUTPUT_LE, 514);
- INIT_2D_VLC_RL(ff_rl_speedhq, 674, INIT_VLC_LE);
+ INIT_2D_VLC_RL(ff_rl_speedhq, speedhq_rl_vlc, INIT_VLC_LE);
compute_alpha_vlcs();
}
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 05/17] avcodec/mpeg12enc: Avoid unnecessary indirection
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (2 preceding siblings ...)
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 04/17] avcodec/mpeg12: Avoid indirection when accessing rl_vlc tables Andreas Rheinhardt
@ 2022-10-23 19:35 ` Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 06/17] avcodec/speedhqenc: " Andreas Rheinhardt
` (12 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12data.c | 8 ++++----
libavcodec/mpeg12enc.c | 4 ++--
libavcodec/mpeg12vlc.h | 5 +++++
3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/libavcodec/mpeg12data.c b/libavcodec/mpeg12data.c
index e301310b9f..398f70dd8a 100644
--- a/libavcodec/mpeg12data.c
+++ b/libavcodec/mpeg12data.c
@@ -64,7 +64,7 @@ const unsigned char ff_mpeg12_vlc_dc_chroma_bits[12] = {
2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10,
};
-static const uint16_t mpeg1_vlc[113][2] = {
+const uint16_t ff_mpeg1_vlc_table[MPEG12_RL_NB_ELEMS + 2][2] = {
{ 0x3, 2 }, { 0x4, 4 }, { 0x5, 5 }, { 0x6, 7 },
{ 0x26, 8 }, { 0x21, 8 }, { 0xa, 10 }, { 0x1d, 12 },
{ 0x18, 12 }, { 0x13, 12 }, { 0x10, 12 }, { 0x1a, 13 },
@@ -97,7 +97,7 @@ static const uint16_t mpeg1_vlc[113][2] = {
{ 0x2, 2 }, /* EOB */
};
-static const uint16_t mpeg2_vlc[113][2] = {
+const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2] = {
{0x02, 2}, {0x06, 3}, {0x07, 4}, {0x1c, 5},
{0x1d, 5}, {0x05, 6}, {0x04, 6}, {0x7b, 7},
{0x7c, 7}, {0x23, 8}, {0x22, 8}, {0xfa, 8},
@@ -167,7 +167,7 @@ static const int8_t mpeg1_run[111] = {
RLTable ff_rl_mpeg1 = {
111,
111,
- mpeg1_vlc,
+ ff_mpeg1_vlc_table,
mpeg1_run,
mpeg1_level,
};
@@ -175,7 +175,7 @@ RLTable ff_rl_mpeg1 = {
RLTable ff_rl_mpeg2 = {
111,
111,
- mpeg2_vlc,
+ ff_mpeg2_vlc_table,
mpeg1_run,
mpeg1_level,
};
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index c3df924b64..5d991ac99e 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -709,7 +709,7 @@ static void mpeg1_encode_block(MpegEncContext *s, int16_t *block, int n)
{
int alevel, level, last_non_zero, dc, diff, i, j, run, last_index, sign;
int code, component;
- const uint16_t (*table_vlc)[2] = ff_rl_mpeg1.table_vlc;
+ const uint16_t (*table_vlc)[2] = ff_mpeg1_vlc_table;
last_index = s->block_last_index[n];
@@ -722,7 +722,7 @@ static void mpeg1_encode_block(MpegEncContext *s, int16_t *block, int n)
s->last_dc[component] = dc;
i = 1;
if (s->intra_vlc_format)
- table_vlc = ff_rl_mpeg2.table_vlc;
+ table_vlc = ff_mpeg2_vlc_table;
} else {
/* encode the first coefficient: needs to be done here because
* it is handled slightly differently */
diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h
index d0083f1124..c810697370 100644
--- a/libavcodec/mpeg12vlc.h
+++ b/libavcodec/mpeg12vlc.h
@@ -53,9 +53,14 @@ void ff_mpeg12_init_vlcs(void);
#define INIT_2D_VLC_RL(rl, rl_vlc, flags)\
ff_init_2d_vlc_rl(&rl, rl_vlc, FF_ARRAY_ELEMS(rl_vlc), flags)
+#define MPEG12_RL_NB_ELEMS 111
+
extern RLTable ff_rl_mpeg1;
extern RLTable ff_rl_mpeg2;
+extern const uint16_t ff_mpeg1_vlc_table[MPEG12_RL_NB_ELEMS + 2][2];
+extern const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2];
+
extern RL_VLC_ELEM ff_mpeg1_rl_vlc[];
extern RL_VLC_ELEM ff_mpeg2_rl_vlc[];
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 06/17] avcodec/speedhqenc: Avoid unnecessary indirection
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (3 preceding siblings ...)
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 05/17] avcodec/mpeg12enc: Avoid unnecessary indirection Andreas Rheinhardt
@ 2022-10-23 19:35 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 07/17] avcodec/mpeg12enc: Pass tables explicitly in ff_mpeg1_init_uni_ac_vlc Andreas Rheinhardt
` (11 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:35 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/speedhq.c | 4 ++--
libavcodec/speedhq.h | 7 +++++++
libavcodec/speedhqenc.c | 8 ++++----
3 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c
index ee37573789..2d6e8ca949 100644
--- a/libavcodec/speedhq.c
+++ b/libavcodec/speedhq.c
@@ -24,7 +24,7 @@
#include "speedhq.h"
/* AC codes: Very similar but not identical to MPEG-2. */
-static const uint16_t speedhq_vlc[123][2] = {
+const uint16_t ff_speedhq_vlc_table[SPEEDHQ_RL_NB_ELEMS + 2][2] = {
{0x0001, 2}, {0x0003, 3}, {0x000E, 4}, {0x0007, 5},
{0x0017, 5}, {0x0028, 6}, {0x0008, 6}, {0x006F, 7},
{0x001F, 7}, {0x00C4, 8}, {0x0044, 8}, {0x005F, 8},
@@ -101,7 +101,7 @@ static const uint8_t speedhq_run[121] = {
RLTable ff_rl_speedhq = {
121,
121,
- speedhq_vlc,
+ ff_speedhq_vlc_table,
speedhq_run,
speedhq_level,
};
diff --git a/libavcodec/speedhq.h b/libavcodec/speedhq.h
index 94879eda65..78f11ac6ab 100644
--- a/libavcodec/speedhq.h
+++ b/libavcodec/speedhq.h
@@ -21,9 +21,16 @@
#ifndef AVCODEC_SPEEDHQ_H
#define AVCODEC_SPEEDHQ_H
+#include <stdint.h>
#include "rl.h"
#include "libavutil/attributes_internal.h"
+#define SPEEDHQ_RL_NB_ELEMS 121
+
+FF_VISIBILITY_PUSH_HIDDEN
+extern const uint16_t ff_speedhq_vlc_table[SPEEDHQ_RL_NB_ELEMS + 2][2];
+
extern RLTable attribute_visibility_hidden ff_rl_speedhq;
+FF_VISIBILITY_POP_HIDDEN
#endif /* AVCODEC_SPEEDHQ_H */
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 6cf40aac2d..58b5e858a8 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -222,11 +222,11 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n)
if (alevel <= ff_rl_speedhq.max_level[0][run]) {
code = ff_rl_speedhq.index_run[0][run] + alevel - 1;
/* store the VLC & sign at once */
- put_bits_le(&s->pb, ff_rl_speedhq.table_vlc[code][1] + 1,
- ff_rl_speedhq.table_vlc[code][0] + (sign << ff_rl_speedhq.table_vlc[code][1]));
+ put_bits_le(&s->pb, ff_speedhq_vlc_table[code][1] + 1,
+ ff_speedhq_vlc_table[code][0] | (sign << ff_speedhq_vlc_table[code][1]));
} else {
/* escape seems to be pretty rare <5% so I do not optimize it;
- * the values correspond to ff_rl_speedhq.table_vlc[121] */
+ * the values correspond to ff_speedhq_vlc_table[121] */
put_bits_le(&s->pb, 6, 32);
/* escape: only clip in this case */
put_bits_le(&s->pb, 6, run);
@@ -235,7 +235,7 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n)
last_non_zero = i;
}
}
- /* end of block; the values correspond to ff_rl_speedhq.table_vlc[122] */
+ /* end of block; the values correspond to ff_speedhq_vlc_table[122] */
put_bits_le(&s->pb, 4, 6);
}
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 07/17] avcodec/mpeg12enc: Pass tables explicitly in ff_mpeg1_init_uni_ac_vlc
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (4 preceding siblings ...)
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 06/17] avcodec/speedhqenc: " Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 08/17] avcodec/mpeg12enc: Don't initialize ff_rl_mpeg2 unnecessarily Andreas Rheinhardt
` (10 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This will allow to remove ff_rl_mpeg2 soon and remove
all uses of RLTable in MPEG-1/2/SpeedHQ later.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 19 ++++++++++++-------
libavcodec/mpeg12vlc.h | 3 ++-
libavcodec/speedhqenc.c | 3 ++-
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 5d991ac99e..e0775d6b96 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -94,7 +94,10 @@ typedef struct MPEG12EncContext {
#define A53_MAX_CC_COUNT 0x1f
#endif /* CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER */
-av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len)
+av_cold void ff_mpeg1_init_uni_ac_vlc(const int8_t max_level[],
+ const uint8_t index_run[],
+ const uint16_t table_vlc[][2],
+ uint8_t uni_ac_vlc_len[])
{
int i;
@@ -107,16 +110,16 @@ av_cold void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len
int len, code;
int alevel = FFABS(level);
- if (alevel > rl->max_level[0][run])
+ if (alevel > max_level[run])
code = 111; /* rl->n */
else
- code = rl->index_run[0][run] + alevel - 1;
+ code = index_run[run] + alevel - 1;
if (code < 111) { /* rl->n */
/* length of VLC and sign */
- len = rl->table_vlc[code][1] + 1;
+ len = table_vlc[code][1] + 1;
} else {
- len = rl->table_vlc[111 /* rl->n */][1] + 6;
+ len = table_vlc[MPEG12_RL_NB_ELEMS][1] + 6;
if (alevel < 128)
len += 8;
@@ -1078,8 +1081,10 @@ static av_cold void mpeg12_encode_init_static(void)
ff_rl_init(&ff_rl_mpeg1, mpeg12_static_rl_table_store[0]);
ff_rl_init(&ff_rl_mpeg2, mpeg12_static_rl_table_store[1]);
- ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg1, uni_mpeg1_ac_vlc_len);
- ff_mpeg1_init_uni_ac_vlc(&ff_rl_mpeg2, uni_mpeg2_ac_vlc_len);
+ ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg1.max_level[0], ff_rl_mpeg1.index_run[0],
+ ff_mpeg1_vlc_table, uni_mpeg1_ac_vlc_len);
+ ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg2.max_level[0], ff_rl_mpeg2.index_run[0],
+ ff_mpeg2_vlc_table, uni_mpeg2_ac_vlc_len);
/* build unified dc encoding tables */
for (int i = -255; i < 256; i++) {
diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h
index c810697370..5a04834bee 100644
--- a/libavcodec/mpeg12vlc.h
+++ b/libavcodec/mpeg12vlc.h
@@ -67,6 +67,7 @@ extern RL_VLC_ELEM ff_mpeg2_rl_vlc[];
void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[],
unsigned static_size, int flags);
-void ff_mpeg1_init_uni_ac_vlc(const RLTable *rl, uint8_t *uni_ac_vlc_len);
+void ff_mpeg1_init_uni_ac_vlc(const int8_t max_level[], const uint8_t index_run[],
+ const uint16_t table_vlc[][2], uint8_t uni_ac_vlc_len[]);
#endif /* AVCODEC_MPEG12VLC_H */
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 58b5e858a8..44ee62b9c2 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -88,7 +88,8 @@ static av_cold void speedhq_init_static_data(void)
speedhq_chr_dc_uni[i + 255] = bits + (code << 8);
}
- ff_mpeg1_init_uni_ac_vlc(&ff_rl_speedhq, uni_speedhq_ac_vlc_len);
+ ff_mpeg1_init_uni_ac_vlc(ff_rl_speedhq.max_level[0], ff_rl_speedhq.index_run[0],
+ ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len);
}
av_cold int ff_speedhq_encode_init(MpegEncContext *s)
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 08/17] avcodec/mpeg12enc: Don't initialize ff_rl_mpeg2 unnecessarily
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (5 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 07/17] avcodec/mpeg12enc: Pass tables explicitly in ff_mpeg1_init_uni_ac_vlc Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 09/17] avcodec/mpeg12: Pass parameters explicitly in ff_init_2d_vlc_rl() Andreas Rheinhardt
` (9 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
ff_rl_mpeg1 and ff_rl_mpeg2 differ only in RLTable.table_vlc,
which ff_rl_init() does not use to initialize RLTable.max_level,
RLTable.max_run and RLTable.index_run. This implies
that these tables agree for ff_rl_mpeg1 and ff_rl_mpeg2;
hence one can just use one of them and avoid calling ff_rl_init()
ff_rl_mpeg2 alltogether.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index e0775d6b96..4d10b42bf2 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1076,14 +1076,13 @@ void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],
static av_cold void mpeg12_encode_init_static(void)
{
- static uint8_t mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
+ static uint8_t mpeg12_static_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3];
- ff_rl_init(&ff_rl_mpeg1, mpeg12_static_rl_table_store[0]);
- ff_rl_init(&ff_rl_mpeg2, mpeg12_static_rl_table_store[1]);
+ ff_rl_init(&ff_rl_mpeg1, mpeg12_static_rl_table_store);
ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg1.max_level[0], ff_rl_mpeg1.index_run[0],
ff_mpeg1_vlc_table, uni_mpeg1_ac_vlc_len);
- ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg2.max_level[0], ff_rl_mpeg2.index_run[0],
+ ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg1.max_level[0], ff_rl_mpeg1.index_run[0],
ff_mpeg2_vlc_table, uni_mpeg2_ac_vlc_len);
/* build unified dc encoding tables */
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 09/17] avcodec/mpeg12: Pass parameters explicitly in ff_init_2d_vlc_rl()
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (6 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 08/17] avcodec/mpeg12enc: Don't initialize ff_rl_mpeg2 unnecessarily Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 10/17] avcodec/mpeg12data: Remove unused ff_rl_mpeg2 Andreas Rheinhardt
` (8 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This allows to exploit that ff_rl_mpeg1 and ff_rl_mpeg2
only differ in their VLC table.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12.c | 23 ++++++++++++++---------
libavcodec/mpeg12vlc.h | 8 +++-----
libavcodec/speedhqdec.c | 4 +++-
3 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 351ebf420f..282e473700 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -63,14 +63,15 @@ static const uint8_t table_mb_btype[11][2] = {
{ 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
};
-av_cold void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[],
- unsigned static_size, int flags)
+av_cold void ff_init_2d_vlc_rl(const uint16_t table_vlc[][2], RL_VLC_ELEM rl_vlc[],
+ const int8_t table_run[], const uint8_t table_level[],
+ int n, unsigned static_size, int flags)
{
int i;
VLCElem table[680] = { 0 };
VLC vlc = { .table = table, .table_allocated = static_size };
av_assert0(static_size <= FF_ARRAY_ELEMS(table));
- init_vlc(&vlc, TEX_VLC_BITS, rl->n + 2, &rl->table_vlc[0][1], 4, 2, &rl->table_vlc[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | flags);
+ init_vlc(&vlc, TEX_VLC_BITS, n + 2, &table_vlc[0][1], 4, 2, &table_vlc[0][0], 4, 2, INIT_VLC_USE_NEW_STATIC | flags);
for (i = 0; i < vlc.table_size; i++) {
int code = vlc.table[i].sym;
@@ -84,15 +85,15 @@ av_cold void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[],
run = 0;
level = code;
} else {
- if (code == rl->n) { //esc
+ if (code == n) { //esc
run = 65;
level = 0;
- } else if (code == rl->n+1) { //eob
+ } else if (code == n + 1) { //eob
run = 0;
level = 127;
} else {
- run = rl->table_run [code] + 1;
- level = rl->table_level[code];
+ run = table_run [code] + 1;
+ level = table_level[code];
}
}
rl_vlc[i].len = len;
@@ -151,8 +152,12 @@ static av_cold void mpeg12_init_vlcs(void)
&table_mb_btype[0][1], 2, 1,
&table_mb_btype[0][0], 2, 1, 64);
- INIT_2D_VLC_RL(ff_rl_mpeg1, ff_mpeg1_rl_vlc, 0);
- INIT_2D_VLC_RL(ff_rl_mpeg2, ff_mpeg2_rl_vlc, 0);
+ ff_init_2d_vlc_rl(ff_mpeg1_vlc_table, ff_mpeg1_rl_vlc, ff_rl_mpeg1.table_run,
+ ff_rl_mpeg1.table_level, ff_rl_mpeg1.n,
+ FF_ARRAY_ELEMS(ff_mpeg1_rl_vlc), 0);
+ ff_init_2d_vlc_rl(ff_mpeg2_vlc_table, ff_mpeg2_rl_vlc, ff_rl_mpeg1.table_run,
+ ff_rl_mpeg1.table_level, ff_rl_mpeg1.n,
+ FF_ARRAY_ELEMS(ff_mpeg2_rl_vlc), 0);
}
av_cold void ff_mpeg12_init_vlcs(void)
diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h
index 5a04834bee..dc7f0269bf 100644
--- a/libavcodec/mpeg12vlc.h
+++ b/libavcodec/mpeg12vlc.h
@@ -50,9 +50,6 @@ extern VLC ff_mv_vlc;
void ff_mpeg12_init_vlcs(void);
-#define INIT_2D_VLC_RL(rl, rl_vlc, flags)\
- ff_init_2d_vlc_rl(&rl, rl_vlc, FF_ARRAY_ELEMS(rl_vlc), flags)
-
#define MPEG12_RL_NB_ELEMS 111
extern RLTable ff_rl_mpeg1;
@@ -64,8 +61,9 @@ extern const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2];
extern RL_VLC_ELEM ff_mpeg1_rl_vlc[];
extern RL_VLC_ELEM ff_mpeg2_rl_vlc[];
-void ff_init_2d_vlc_rl(const RLTable *rl, RL_VLC_ELEM rl_vlc[],
- unsigned static_size, int flags);
+void ff_init_2d_vlc_rl(const uint16_t table_vlc[][2], RL_VLC_ELEM rl_vlc[],
+ const int8_t table_run[], const uint8_t table_level[],
+ int n, unsigned static_size, int flags);
void ff_mpeg1_init_uni_ac_vlc(const int8_t max_level[], const uint8_t index_run[],
const uint16_t table_vlc[][2], uint8_t uni_ac_vlc_len[]);
diff --git a/libavcodec/speedhqdec.c b/libavcodec/speedhqdec.c
index 7cb5ff03cc..3a5b0eab05 100644
--- a/libavcodec/speedhqdec.c
+++ b/libavcodec/speedhqdec.c
@@ -566,7 +566,9 @@ static av_cold void speedhq_static_init(void)
ff_mpeg12_vlc_dc_chroma_code, 2, 2,
INIT_VLC_OUTPUT_LE, 514);
- INIT_2D_VLC_RL(ff_rl_speedhq, speedhq_rl_vlc, INIT_VLC_LE);
+ ff_init_2d_vlc_rl(ff_speedhq_vlc_table, speedhq_rl_vlc, ff_rl_speedhq.table_run,
+ ff_rl_speedhq.table_level, ff_rl_speedhq.n,
+ FF_ARRAY_ELEMS(speedhq_rl_vlc), INIT_VLC_LE);
compute_alpha_vlcs();
}
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 10/17] avcodec/mpeg12data: Remove unused ff_rl_mpeg2
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (7 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 09/17] avcodec/mpeg12: Pass parameters explicitly in ff_init_2d_vlc_rl() Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 11/17] avcodec/mpeg12: Use ff_rl_mpeg1.table_(run|level) directly Andreas Rheinhardt
` (7 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12data.c | 8 --------
libavcodec/mpeg12vlc.h | 1 -
2 files changed, 9 deletions(-)
diff --git a/libavcodec/mpeg12data.c b/libavcodec/mpeg12data.c
index 398f70dd8a..5803999153 100644
--- a/libavcodec/mpeg12data.c
+++ b/libavcodec/mpeg12data.c
@@ -172,14 +172,6 @@ RLTable ff_rl_mpeg1 = {
mpeg1_level,
};
-RLTable ff_rl_mpeg2 = {
- 111,
- 111,
- ff_mpeg2_vlc_table,
- mpeg1_run,
- mpeg1_level,
-};
-
const uint8_t ff_mpeg12_mbAddrIncrTable[36][2] = {
{0x1, 1},
{0x3, 3},
diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h
index dc7f0269bf..71027d468f 100644
--- a/libavcodec/mpeg12vlc.h
+++ b/libavcodec/mpeg12vlc.h
@@ -53,7 +53,6 @@ void ff_mpeg12_init_vlcs(void);
#define MPEG12_RL_NB_ELEMS 111
extern RLTable ff_rl_mpeg1;
-extern RLTable ff_rl_mpeg2;
extern const uint16_t ff_mpeg1_vlc_table[MPEG12_RL_NB_ELEMS + 2][2];
extern const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2];
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 11/17] avcodec/mpeg12: Use ff_rl_mpeg1.table_(run|level) directly
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (8 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 10/17] avcodec/mpeg12data: Remove unused ff_rl_mpeg2 Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 12/17] avcodec/speedhqdec: Use ff_rl_speedhq.table_(run|level) directly Andreas Rheinhardt
` (6 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12.c | 8 ++++----
libavcodec/mpeg12data.c | 8 ++++----
libavcodec/mpeg12vlc.h | 3 +++
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 282e473700..b0e638bfcd 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -152,11 +152,11 @@ static av_cold void mpeg12_init_vlcs(void)
&table_mb_btype[0][1], 2, 1,
&table_mb_btype[0][0], 2, 1, 64);
- ff_init_2d_vlc_rl(ff_mpeg1_vlc_table, ff_mpeg1_rl_vlc, ff_rl_mpeg1.table_run,
- ff_rl_mpeg1.table_level, ff_rl_mpeg1.n,
+ ff_init_2d_vlc_rl(ff_mpeg1_vlc_table, ff_mpeg1_rl_vlc, ff_mpeg12_run,
+ ff_mpeg12_level, MPEG12_RL_NB_ELEMS,
FF_ARRAY_ELEMS(ff_mpeg1_rl_vlc), 0);
- ff_init_2d_vlc_rl(ff_mpeg2_vlc_table, ff_mpeg2_rl_vlc, ff_rl_mpeg1.table_run,
- ff_rl_mpeg1.table_level, ff_rl_mpeg1.n,
+ ff_init_2d_vlc_rl(ff_mpeg2_vlc_table, ff_mpeg2_rl_vlc, ff_mpeg12_run,
+ ff_mpeg12_level, MPEG12_RL_NB_ELEMS,
FF_ARRAY_ELEMS(ff_mpeg2_rl_vlc), 0);
}
diff --git a/libavcodec/mpeg12data.c b/libavcodec/mpeg12data.c
index 5803999153..1e3410bf2f 100644
--- a/libavcodec/mpeg12data.c
+++ b/libavcodec/mpeg12data.c
@@ -130,7 +130,7 @@ const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2] = {
{0x06,4}, /* EOB */
};
-static const int8_t mpeg1_level[111] = {
+const int8_t ff_mpeg12_level[MPEG12_RL_NB_ELEMS] = {
1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24,
@@ -147,7 +147,7 @@ static const int8_t mpeg1_level[111] = {
1, 1, 1, 1, 1, 1, 1,
};
-static const int8_t mpeg1_run[111] = {
+const int8_t ff_mpeg12_run[MPEG12_RL_NB_ELEMS] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -168,8 +168,8 @@ RLTable ff_rl_mpeg1 = {
111,
111,
ff_mpeg1_vlc_table,
- mpeg1_run,
- mpeg1_level,
+ ff_mpeg12_run,
+ ff_mpeg12_level,
};
const uint8_t ff_mpeg12_mbAddrIncrTable[36][2] = {
diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h
index 71027d468f..15275c5269 100644
--- a/libavcodec/mpeg12vlc.h
+++ b/libavcodec/mpeg12vlc.h
@@ -54,6 +54,9 @@ void ff_mpeg12_init_vlcs(void);
extern RLTable ff_rl_mpeg1;
+extern const int8_t ff_mpeg12_level[MPEG12_RL_NB_ELEMS];
+extern const int8_t ff_mpeg12_run[MPEG12_RL_NB_ELEMS];
+
extern const uint16_t ff_mpeg1_vlc_table[MPEG12_RL_NB_ELEMS + 2][2];
extern const uint16_t ff_mpeg2_vlc_table[MPEG12_RL_NB_ELEMS + 2][2];
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 12/17] avcodec/speedhqdec: Use ff_rl_speedhq.table_(run|level) directly
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (9 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 11/17] avcodec/mpeg12: Use ff_rl_mpeg1.table_(run|level) directly Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 13/17] avcodec/rl: Add analogue for ff_rl_init() without RLTable Andreas Rheinhardt
` (5 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/speedhq.c | 8 ++++----
libavcodec/speedhq.h | 2 ++
libavcodec/speedhqdec.c | 4 ++--
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c
index 2d6e8ca949..46ff0cfc53 100644
--- a/libavcodec/speedhq.c
+++ b/libavcodec/speedhq.c
@@ -60,7 +60,7 @@ const uint16_t ff_speedhq_vlc_table[SPEEDHQ_RL_NB_ELEMS + 2][2] = {
{0x0006, 4} /* EOB */
};
-static const uint8_t speedhq_level[121] = {
+const uint8_t ff_speedhq_level[121] = {
1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24,
@@ -79,7 +79,7 @@ static const uint8_t speedhq_level[121] = {
1,
};
-static const uint8_t speedhq_run[121] = {
+const uint8_t ff_speedhq_run[121] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
@@ -102,6 +102,6 @@ RLTable ff_rl_speedhq = {
121,
121,
ff_speedhq_vlc_table,
- speedhq_run,
- speedhq_level,
+ ff_speedhq_run,
+ ff_speedhq_level,
};
diff --git a/libavcodec/speedhq.h b/libavcodec/speedhq.h
index 78f11ac6ab..8bc22ab0d7 100644
--- a/libavcodec/speedhq.h
+++ b/libavcodec/speedhq.h
@@ -28,6 +28,8 @@
#define SPEEDHQ_RL_NB_ELEMS 121
FF_VISIBILITY_PUSH_HIDDEN
+extern const uint8_t ff_speedhq_run[SPEEDHQ_RL_NB_ELEMS];
+extern const uint8_t ff_speedhq_level[SPEEDHQ_RL_NB_ELEMS];
extern const uint16_t ff_speedhq_vlc_table[SPEEDHQ_RL_NB_ELEMS + 2][2];
extern RLTable attribute_visibility_hidden ff_rl_speedhq;
diff --git a/libavcodec/speedhqdec.c b/libavcodec/speedhqdec.c
index 3a5b0eab05..0c5942e677 100644
--- a/libavcodec/speedhqdec.c
+++ b/libavcodec/speedhqdec.c
@@ -566,8 +566,8 @@ static av_cold void speedhq_static_init(void)
ff_mpeg12_vlc_dc_chroma_code, 2, 2,
INIT_VLC_OUTPUT_LE, 514);
- ff_init_2d_vlc_rl(ff_speedhq_vlc_table, speedhq_rl_vlc, ff_rl_speedhq.table_run,
- ff_rl_speedhq.table_level, ff_rl_speedhq.n,
+ ff_init_2d_vlc_rl(ff_speedhq_vlc_table, speedhq_rl_vlc, ff_speedhq_run,
+ ff_speedhq_level, SPEEDHQ_RL_NB_ELEMS,
FF_ARRAY_ELEMS(speedhq_rl_vlc), INIT_VLC_LE);
compute_alpha_vlcs();
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 13/17] avcodec/rl: Add analogue for ff_rl_init() without RLTable
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (10 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 12/17] avcodec/speedhqdec: Use ff_rl_speedhq.table_(run|level) directly Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 14/17] avcodec/mpeg12enc: Don't initialize unused parts of RLTable Andreas Rheinhardt
` (4 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/rl.c | 17 +++++++++++++++++
libavcodec/rl.h | 10 ++++++++++
2 files changed, 27 insertions(+)
diff --git a/libavcodec/rl.c b/libavcodec/rl.c
index 645a5362f7..3f8271d37e 100644
--- a/libavcodec/rl.c
+++ b/libavcodec/rl.c
@@ -24,6 +24,23 @@
#include "rl.h"
+av_cold void ff_rl_init_level_run(uint8_t max_level[MAX_LEVEL + 1],
+ uint8_t index_run[MAX_RUN + 1],
+ const uint8_t table_run[/* n */],
+ const uint8_t table_level[/* n*/],
+ int n)
+{
+ memset(index_run, n, MAX_RUN + 1);
+ for (int i = 0; i < n; i++) {
+ int run = table_run[i];
+ int level = table_level[i];
+ if (index_run[run] == n)
+ index_run[run] = i;
+ if (level > max_level[run])
+ max_level[run] = level;
+ }
+}
+
av_cold void ff_rl_init(RLTable *rl,
uint8_t static_store[2][2 * MAX_RUN + MAX_LEVEL + 3])
{
diff --git a/libavcodec/rl.h b/libavcodec/rl.h
index 07e3da5003..4380fda272 100644
--- a/libavcodec/rl.h
+++ b/libavcodec/rl.h
@@ -48,6 +48,16 @@ typedef struct RLTable {
RL_VLC_ELEM *rl_vlc[32]; ///< decoding only
} RLTable;
+/**
+ * Initialize max_level and index_run from table_run and table_level;
+ * this is equivalent to initializing RLTable.max_level[0] and
+ * RLTable.index_run[0] with ff_rl_init().
+ */
+void ff_rl_init_level_run(uint8_t max_level[MAX_LEVEL + 1],
+ uint8_t index_run[MAX_RUN + 1],
+ const uint8_t table_run[/* n */],
+ const uint8_t table_level[/* n*/], int n);
+
/**
* Initialize index_run, max_level and max_run from n, last, table_vlc,
* table_run and table_level.
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 14/17] avcodec/mpeg12enc: Don't initialize unused parts of RLTable
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (11 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 13/17] avcodec/rl: Add analogue for ff_rl_init() without RLTable Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 15/17] avcodec/mpeg12data: Remove ff_rl_mpeg1 Andreas Rheinhardt
` (3 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
ff_rl_init() initializes RLTable.(max_level|max_run|index_run);
max_run is unused by the MPEG-1/2 encoders (as well as SpeedHQ).
Furthermore, it initializes these things twice (for two passes),
but the second half of this is never used.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12enc.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 4d10b42bf2..2db1d93d0e 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -49,6 +49,7 @@
#include "mpegvideodata.h"
#include "mpegvideoenc.h"
#include "profiles.h"
+#include "rl.h"
#if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
static const uint8_t svcd_scan_offset_placeholder[] = {
@@ -62,6 +63,9 @@ static uint8_t fcode_tab[MAX_MV * 2 + 1];
static uint8_t uni_mpeg1_ac_vlc_len[64 * 64 * 2];
static uint8_t uni_mpeg2_ac_vlc_len[64 * 64 * 2];
+static uint8_t mpeg12_max_level[MAX_LEVEL + 1];
+static uint8_t mpeg12_index_run[MAX_RUN + 1];
+
/* simple include everything table for dc, first byte is bits
* number next 3 are code */
static uint32_t mpeg1_lum_dc_uni[512];
@@ -757,8 +761,8 @@ next_coef:
MASK_ABS(sign, alevel);
sign &= 1;
- if (alevel <= ff_rl_mpeg1.max_level[0][run]) {
- code = ff_rl_mpeg1.index_run[0][run] + alevel - 1;
+ if (alevel <= mpeg12_max_level[run]) {
+ code = mpeg12_index_run[run] + alevel - 1;
/* store the VLC & sign at once */
put_bits(&s->pb, table_vlc[code][1] + 1,
(table_vlc[code][0] << 1) + sign);
@@ -1076,13 +1080,12 @@ void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64],
static av_cold void mpeg12_encode_init_static(void)
{
- static uint8_t mpeg12_static_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3];
-
- ff_rl_init(&ff_rl_mpeg1, mpeg12_static_rl_table_store);
+ ff_rl_init_level_run(mpeg12_max_level, mpeg12_index_run,
+ ff_mpeg12_run, ff_mpeg12_level, MPEG12_RL_NB_ELEMS);
- ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg1.max_level[0], ff_rl_mpeg1.index_run[0],
+ ff_mpeg1_init_uni_ac_vlc(mpeg12_max_level, mpeg12_index_run,
ff_mpeg1_vlc_table, uni_mpeg1_ac_vlc_len);
- ff_mpeg1_init_uni_ac_vlc(ff_rl_mpeg1.max_level[0], ff_rl_mpeg1.index_run[0],
+ ff_mpeg1_init_uni_ac_vlc(mpeg12_max_level, mpeg12_index_run,
ff_mpeg2_vlc_table, uni_mpeg2_ac_vlc_len);
/* build unified dc encoding tables */
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 15/17] avcodec/mpeg12data: Remove ff_rl_mpeg1
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (12 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 14/17] avcodec/mpeg12enc: Don't initialize unused parts of RLTable Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 16/17] avcodec/speedhqenc: Don't initialize unused parts of RLTable Andreas Rheinhardt
` (2 subsequent siblings)
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
No longer used anywhere.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/mpeg12.c | 1 +
libavcodec/mpeg12data.c | 8 --------
libavcodec/mpeg12vlc.h | 3 ---
3 files changed, 1 insertion(+), 11 deletions(-)
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index b0e638bfcd..5d5f39388f 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -37,6 +37,7 @@
#include "mpeg12codecs.h"
#include "mpeg12data.h"
#include "mpeg12dec.h"
+#include "rl.h"
#include "startcode.h"
static const uint8_t table_mb_ptype[7][2] = {
diff --git a/libavcodec/mpeg12data.c b/libavcodec/mpeg12data.c
index 1e3410bf2f..a55fa463a4 100644
--- a/libavcodec/mpeg12data.c
+++ b/libavcodec/mpeg12data.c
@@ -164,14 +164,6 @@ const int8_t ff_mpeg12_run[MPEG12_RL_NB_ELEMS] = {
25, 26, 27, 28, 29, 30, 31,
};
-RLTable ff_rl_mpeg1 = {
- 111,
- 111,
- ff_mpeg1_vlc_table,
- ff_mpeg12_run,
- ff_mpeg12_level,
-};
-
const uint8_t ff_mpeg12_mbAddrIncrTable[36][2] = {
{0x1, 1},
{0x3, 3},
diff --git a/libavcodec/mpeg12vlc.h b/libavcodec/mpeg12vlc.h
index 15275c5269..3ed35968f6 100644
--- a/libavcodec/mpeg12vlc.h
+++ b/libavcodec/mpeg12vlc.h
@@ -28,7 +28,6 @@
#ifndef AVCODEC_MPEG12VLC_H
#define AVCODEC_MPEG12VLC_H
-#include "rl.h"
#include "vlc.h"
#define DC_VLC_BITS 9
@@ -52,8 +51,6 @@ void ff_mpeg12_init_vlcs(void);
#define MPEG12_RL_NB_ELEMS 111
-extern RLTable ff_rl_mpeg1;
-
extern const int8_t ff_mpeg12_level[MPEG12_RL_NB_ELEMS];
extern const int8_t ff_mpeg12_run[MPEG12_RL_NB_ELEMS];
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 16/17] avcodec/speedhqenc: Don't initialize unused parts of RLTable
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (13 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 15/17] avcodec/mpeg12data: Remove ff_rl_mpeg1 Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 17/17] avcodec/speedhq: Remove unused ff_rl_speedhq Andreas Rheinhardt
2022-10-25 21:39 ` [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
ff_rl_init() initializes RLTable.(max_level|max_run|index_run);
max_run is unused by the SpeedHQ encoder (as well as MPEG-1/2).
Furthermore, it initializes these things twice (for two passes),
but the second half of this is never used.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/speedhqenc.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/libavcodec/speedhqenc.c b/libavcodec/speedhqenc.c
index 44ee62b9c2..65e66afae4 100644
--- a/libavcodec/speedhqenc.c
+++ b/libavcodec/speedhqenc.c
@@ -36,10 +36,12 @@
#include "mpegvideo.h"
#include "mpegvideodata.h"
#include "mpegvideoenc.h"
+#include "rl.h"
#include "speedhq.h"
#include "speedhqenc.h"
-static uint8_t speedhq_static_rl_table_store[2][2*MAX_RUN + MAX_LEVEL + 3];
+static uint8_t speedhq_max_level[MAX_LEVEL + 1];
+static uint8_t speedhq_index_run[MAX_RUN + 1];
/* Exactly the same as MPEG-2, except little-endian. */
static const uint16_t mpeg12_vlc_dc_lum_code_reversed[12] = {
@@ -64,7 +66,8 @@ typedef struct SpeedHQEncContext {
static av_cold void speedhq_init_static_data(void)
{
- ff_rl_init(&ff_rl_speedhq, speedhq_static_rl_table_store);
+ ff_rl_init_level_run(speedhq_max_level, speedhq_index_run,
+ ff_speedhq_run, ff_speedhq_level, SPEEDHQ_RL_NB_ELEMS);
/* build unified dc encoding tables */
for (int i = -255; i < 256; i++) {
@@ -88,7 +91,7 @@ static av_cold void speedhq_init_static_data(void)
speedhq_chr_dc_uni[i + 255] = bits + (code << 8);
}
- ff_mpeg1_init_uni_ac_vlc(ff_rl_speedhq.max_level[0], ff_rl_speedhq.index_run[0],
+ ff_mpeg1_init_uni_ac_vlc(speedhq_max_level, speedhq_index_run,
ff_speedhq_vlc_table, uni_speedhq_ac_vlc_len);
}
@@ -220,8 +223,8 @@ static void encode_block(MpegEncContext *s, int16_t *block, int n)
MASK_ABS(sign, alevel);
sign &= 1;
- if (alevel <= ff_rl_speedhq.max_level[0][run]) {
- code = ff_rl_speedhq.index_run[0][run] + alevel - 1;
+ if (alevel <= speedhq_max_level[run]) {
+ code = speedhq_index_run[run] + alevel - 1;
/* store the VLC & sign at once */
put_bits_le(&s->pb, ff_speedhq_vlc_table[code][1] + 1,
ff_speedhq_vlc_table[code][0] | (sign << ff_speedhq_vlc_table[code][1]));
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* [FFmpeg-devel] [PATCH 17/17] avcodec/speedhq: Remove unused ff_rl_speedhq
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (14 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 16/17] avcodec/speedhqenc: Don't initialize unused parts of RLTable Andreas Rheinhardt
@ 2022-10-23 19:36 ` Andreas Rheinhardt
2022-10-25 21:39 ` [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-23 19:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/speedhq.c | 9 ---------
libavcodec/speedhq.h | 3 ---
libavcodec/speedhqdec.c | 1 -
3 files changed, 13 deletions(-)
diff --git a/libavcodec/speedhq.c b/libavcodec/speedhq.c
index 46ff0cfc53..eb7de03116 100644
--- a/libavcodec/speedhq.c
+++ b/libavcodec/speedhq.c
@@ -20,7 +20,6 @@
*/
#include <stdint.h>
-#include "rl.h"
#include "speedhq.h"
/* AC codes: Very similar but not identical to MPEG-2. */
@@ -97,11 +96,3 @@ const uint8_t ff_speedhq_run[121] = {
23, 24, 25, 26, 27, 28, 29, 30,
31,
};
-
-RLTable ff_rl_speedhq = {
- 121,
- 121,
- ff_speedhq_vlc_table,
- ff_speedhq_run,
- ff_speedhq_level,
-};
diff --git a/libavcodec/speedhq.h b/libavcodec/speedhq.h
index 8bc22ab0d7..c40991b8b5 100644
--- a/libavcodec/speedhq.h
+++ b/libavcodec/speedhq.h
@@ -22,7 +22,6 @@
#define AVCODEC_SPEEDHQ_H
#include <stdint.h>
-#include "rl.h"
#include "libavutil/attributes_internal.h"
#define SPEEDHQ_RL_NB_ELEMS 121
@@ -31,8 +30,6 @@ FF_VISIBILITY_PUSH_HIDDEN
extern const uint8_t ff_speedhq_run[SPEEDHQ_RL_NB_ELEMS];
extern const uint8_t ff_speedhq_level[SPEEDHQ_RL_NB_ELEMS];
extern const uint16_t ff_speedhq_vlc_table[SPEEDHQ_RL_NB_ELEMS + 2][2];
-
-extern RLTable attribute_visibility_hidden ff_rl_speedhq;
FF_VISIBILITY_POP_HIDDEN
#endif /* AVCODEC_SPEEDHQ_H */
diff --git a/libavcodec/speedhqdec.c b/libavcodec/speedhqdec.c
index 0c5942e677..623fa340d5 100644
--- a/libavcodec/speedhqdec.c
+++ b/libavcodec/speedhqdec.c
@@ -39,7 +39,6 @@
#include "mathops.h"
#include "mpeg12data.h"
#include "mpeg12vlc.h"
-#include "rl.h"
#include "speedhq.h"
#define MAX_INDEX (64 - 1)
--
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
` (15 preceding siblings ...)
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 17/17] avcodec/speedhq: Remove unused ff_rl_speedhq Andreas Rheinhardt
@ 2022-10-25 21:39 ` Andreas Rheinhardt
16 siblings, 0 replies; 18+ messages in thread
From: Andreas Rheinhardt @ 2022-10-25 21:39 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> Redundant since dcb29d37d4ffedc84e44df99f8d22ecf27e0f2cd.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> It is of course only redundant if avctx->codec_tag is not allowed
> to change after avcodec_open2(); the corresponding option is not
> marked with the AV_OPT_FLAG_RUNTIME_PARAM and the above mentioned
> commit also relies on this, so I do, too.
> Btw: I wonder whether vcr2_init_sequence() should not simply be called
> during init.
>
> libavcodec/mpeg12dec.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
> index 56bf73df11..c942be158e 100644
> --- a/libavcodec/mpeg12dec.c
> +++ b/libavcodec/mpeg12dec.c
> @@ -2797,7 +2797,6 @@ static int mpeg_decode_frame(AVCodecContext *avctx, AVFrame *picture,
> }
> #endif
>
> - s2->codec_tag = ff_toupper4(avctx->codec_tag);
> if (s->mpeg_enc_ctx_allocated == 0 && ( s2->codec_tag == AV_RL32("VCR2")
> || s2->codec_tag == AV_RL32("BW10")
> ))
Will apply this patchset tomorrow unless there are objections.
- Andreas
_______________________________________________
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".
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2022-10-25 21:39 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-23 19:34 [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 02/17] avformat/mux: Don't call ff_toupper4() unnecessarily Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 03/17] avformat/mux: Constify validate_codec_tag() Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 04/17] avcodec/mpeg12: Avoid indirection when accessing rl_vlc tables Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 05/17] avcodec/mpeg12enc: Avoid unnecessary indirection Andreas Rheinhardt
2022-10-23 19:35 ` [FFmpeg-devel] [PATCH 06/17] avcodec/speedhqenc: " Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 07/17] avcodec/mpeg12enc: Pass tables explicitly in ff_mpeg1_init_uni_ac_vlc Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 08/17] avcodec/mpeg12enc: Don't initialize ff_rl_mpeg2 unnecessarily Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 09/17] avcodec/mpeg12: Pass parameters explicitly in ff_init_2d_vlc_rl() Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 10/17] avcodec/mpeg12data: Remove unused ff_rl_mpeg2 Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 11/17] avcodec/mpeg12: Use ff_rl_mpeg1.table_(run|level) directly Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 12/17] avcodec/speedhqdec: Use ff_rl_speedhq.table_(run|level) directly Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 13/17] avcodec/rl: Add analogue for ff_rl_init() without RLTable Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 14/17] avcodec/mpeg12enc: Don't initialize unused parts of RLTable Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 15/17] avcodec/mpeg12data: Remove ff_rl_mpeg1 Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 16/17] avcodec/speedhqenc: Don't initialize unused parts of RLTable Andreas Rheinhardt
2022-10-23 19:36 ` [FFmpeg-devel] [PATCH 17/17] avcodec/speedhq: Remove unused ff_rl_speedhq Andreas Rheinhardt
2022-10-25 21:39 ` [FFmpeg-devel] [PATCH 01/17] avcodec/mpeg12dec: Remove redundant function call Andreas Rheinhardt
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