* [FFmpeg-devel] [PATCH 3/6] avcodec/vp6: Avoid allocation for alpha_context
[not found] ` <20220211085101.1588296-1-andreas.rheinhardt@outlook.com>
@ 2022-02-11 8:50 ` Andreas Rheinhardt
2022-02-11 17:45 ` Michael Niedermayer
2022-02-11 8:50 ` [FFmpeg-devel] [PATCH 4/6] avcodec/vp6: Avoid code duplication when initializing VP56 contexts Andreas Rheinhardt
` (2 subsequent siblings)
3 siblings, 1 reply; 8+ messages in thread
From: Andreas Rheinhardt @ 2022-02-11 8:50 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/vp6.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index 6bcbbce47b..3acca16f3c 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -652,10 +652,8 @@ static av_cold int vp6_decode_init(AVCodecContext *avctx)
vp6_decode_init_context(s);
if (s->has_alpha) {
- s->alpha_context = av_mallocz(sizeof(VP56Context));
- if (!s->alpha_context) {
- return AVERROR(ENOMEM);
- }
+ /* Can only happen for ff_vp6a_decoder */
+ s->alpha_context = &s[1];
ret = ff_vp56_init_context(avctx, s->alpha_context,
s->flip == -1, s->has_alpha);
if (ret < 0)
@@ -691,7 +689,7 @@ static av_cold int vp6_decode_free(AVCodecContext *avctx)
if (s->alpha_context) {
ff_vp56_free_context(s->alpha_context);
vp6_decode_free_context(s->alpha_context);
- av_freep(&s->alpha_context);
+ s->alpha_context = NULL;
}
return 0;
@@ -743,7 +741,7 @@ const AVCodec ff_vp6a_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("On2 VP6 (Flash version, with alpha channel)"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_VP6A,
- .priv_data_size = sizeof(VP56Context),
+ .priv_data_size = 2 /* Main context + alpha context */ * sizeof(VP56Context),
.init = vp6_decode_init,
.close = vp6_decode_free,
.decode = ff_vp56_decode_frame,
--
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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/6] avcodec/vp6: Avoid allocation for alpha_context
2022-02-11 8:50 ` [FFmpeg-devel] [PATCH 3/6] avcodec/vp6: Avoid allocation for alpha_context Andreas Rheinhardt
@ 2022-02-11 17:45 ` Michael Niedermayer
0 siblings, 0 replies; 8+ messages in thread
From: Michael Niedermayer @ 2022-02-11 17:45 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 414 bytes --]
On Fri, Feb 11, 2022 at 09:50:58AM +0100, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/vp6.c | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
nice
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: 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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH 4/6] avcodec/vp6: Avoid code duplication when initializing VP56 contexts
[not found] ` <20220211085101.1588296-1-andreas.rheinhardt@outlook.com>
2022-02-11 8:50 ` [FFmpeg-devel] [PATCH 3/6] avcodec/vp6: Avoid allocation for alpha_context Andreas Rheinhardt
@ 2022-02-11 8:50 ` Andreas Rheinhardt
2022-02-11 8:51 ` [FFmpeg-devel] [PATCH 5/6] avcodec/vp56: Avoid functions with only one caller Andreas Rheinhardt
2022-02-11 8:51 ` [FFmpeg-devel] [PATCH 6/6] avcodec/vp[56]: Mark decoders as init-threadsafe Andreas Rheinhardt
3 siblings, 0 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2022-02-11 8:50 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/vp6.c | 51 +++++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 24 deletions(-)
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index 3acca16f3c..ae8e223349 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -637,57 +637,58 @@ static void vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src,
}
}
-static av_cold void vp6_decode_init_context(VP56Context *s);
+static av_cold int vp6_decode_init_context(AVCodecContext *avctx,
+ VP56Context *s, int flip, int has_alpha)
+{
+ int ret = ff_vp56_init_context(avctx, s, flip, has_alpha);
+ if (ret < 0)
+ return ret;
+
+ ff_vp6dsp_init(&s->vp56dsp);
+
+ s->deblock_filtering = 0;
+ s->vp56_coord_div = vp6_coord_div;
+ s->parse_vector_adjustment = vp6_parse_vector_adjustment;
+ s->filter = vp6_filter;
+ s->default_models_init = vp6_default_models_init;
+ s->parse_vector_models = vp6_parse_vector_models;
+ s->parse_coeff_models = vp6_parse_coeff_models;
+ s->parse_header = vp6_parse_header;
+
+ return 0;
+}
static av_cold int vp6_decode_init(AVCodecContext *avctx)
{
VP56Context *s = avctx->priv_data;
int ret;
- if ((ret = ff_vp56_init(avctx, avctx->codec->id == AV_CODEC_ID_VP6,
- avctx->codec->id == AV_CODEC_ID_VP6A)) < 0)
+ ret = vp6_decode_init_context(avctx, s, avctx->codec_id == AV_CODEC_ID_VP6,
+ avctx->codec_id == AV_CODEC_ID_VP6A);
+ if (ret < 0)
return ret;
- ff_vp6dsp_init(&s->vp56dsp);
-
- vp6_decode_init_context(s);
if (s->has_alpha) {
/* Can only happen for ff_vp6a_decoder */
s->alpha_context = &s[1];
- ret = ff_vp56_init_context(avctx, s->alpha_context,
- s->flip == -1, s->has_alpha);
+ ret = vp6_decode_init_context(avctx, s->alpha_context,
+ s->flip == -1, s->has_alpha);
if (ret < 0)
return ret;
- ff_vp6dsp_init(&s->alpha_context->vp56dsp);
- vp6_decode_init_context(s->alpha_context);
}
return 0;
}
-static av_cold void vp6_decode_init_context(VP56Context *s)
-{
- s->deblock_filtering = 0;
- s->vp56_coord_div = vp6_coord_div;
- s->parse_vector_adjustment = vp6_parse_vector_adjustment;
- s->filter = vp6_filter;
- s->default_models_init = vp6_default_models_init;
- s->parse_vector_models = vp6_parse_vector_models;
- s->parse_coeff_models = vp6_parse_coeff_models;
- s->parse_header = vp6_parse_header;
-}
-
static av_cold void vp6_decode_free_context(VP56Context *s);
static av_cold int vp6_decode_free(AVCodecContext *avctx)
{
VP56Context *s = avctx->priv_data;
- ff_vp56_free(avctx);
vp6_decode_free_context(s);
if (s->alpha_context) {
- ff_vp56_free_context(s->alpha_context);
vp6_decode_free_context(s->alpha_context);
s->alpha_context = NULL;
}
@@ -699,6 +700,8 @@ static av_cold void vp6_decode_free_context(VP56Context *s)
{
int pt, ct, cg;
+ ff_vp56_free_context(s);
+
for (pt=0; pt<2; pt++) {
ff_free_vlc(&s->dccv_vlc[pt]);
ff_free_vlc(&s->runv_vlc[pt]);
--
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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH 5/6] avcodec/vp56: Avoid functions with only one caller
[not found] ` <20220211085101.1588296-1-andreas.rheinhardt@outlook.com>
2022-02-11 8:50 ` [FFmpeg-devel] [PATCH 3/6] avcodec/vp6: Avoid allocation for alpha_context Andreas Rheinhardt
2022-02-11 8:50 ` [FFmpeg-devel] [PATCH 4/6] avcodec/vp6: Avoid code duplication when initializing VP56 contexts Andreas Rheinhardt
@ 2022-02-11 8:51 ` Andreas Rheinhardt
2022-02-11 8:51 ` [FFmpeg-devel] [PATCH 6/6] avcodec/vp[56]: Mark decoders as init-threadsafe Andreas Rheinhardt
3 siblings, 0 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2022-02-11 8:51 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/vp5.c | 10 ++++++++--
libavcodec/vp56.c | 12 ------------
libavcodec/vp56.h | 2 --
3 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c
index a3c3da7ba6..dc24f5b096 100644
--- a/libavcodec/vp5.c
+++ b/libavcodec/vp5.c
@@ -282,7 +282,7 @@ static av_cold int vp5_decode_init(AVCodecContext *avctx)
VP56Context *s = avctx->priv_data;
int ret;
- if ((ret = ff_vp56_init(avctx, 1, 0)) < 0)
+ if ((ret = ff_vp56_init_context(avctx, s, 1, 0)) < 0)
return ret;
ff_vp5dsp_init(&s->vp56dsp);
s->vp56_coord_div = vp5_coord_div;
@@ -296,6 +296,12 @@ static av_cold int vp5_decode_init(AVCodecContext *avctx)
return 0;
}
+static av_cold int vp56_free(AVCodecContext *avctx)
+{
+ VP56Context *const s = avctx->priv_data;
+ return ff_vp56_free_context(s);
+}
+
const AVCodec ff_vp5_decoder = {
.name = "vp5",
.long_name = NULL_IF_CONFIG_SMALL("On2 VP5"),
@@ -303,7 +309,7 @@ const AVCodec ff_vp5_decoder = {
.id = AV_CODEC_ID_VP5,
.priv_data_size = sizeof(VP56Context),
.init = vp5_decode_init,
- .close = ff_vp56_free,
+ .close = vp56_free,
.decode = ff_vp56_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
diff --git a/libavcodec/vp56.c b/libavcodec/vp56.c
index d4184f59b4..9819393447 100644
--- a/libavcodec/vp56.c
+++ b/libavcodec/vp56.c
@@ -773,12 +773,6 @@ next:
return 0;
}
-av_cold int ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
-{
- VP56Context *s = avctx->priv_data;
- return ff_vp56_init_context(avctx, s, flip, has_alpha);
-}
-
av_cold int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s,
int flip, int has_alpha)
{
@@ -830,12 +824,6 @@ av_cold int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s,
return 0;
}
-av_cold int ff_vp56_free(AVCodecContext *avctx)
-{
- VP56Context *s = avctx->priv_data;
- return ff_vp56_free_context(s);
-}
-
av_cold int ff_vp56_free_context(VP56Context *s)
{
int i;
diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h
index 0a9eebc7ea..e0dfaa8981 100644
--- a/libavcodec/vp56.h
+++ b/libavcodec/vp56.h
@@ -216,14 +216,12 @@ struct vp56_context {
};
-int ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha);
/**
* Initializes an VP56Context. Expects its caller to clean up
* in case of error.
*/
int ff_vp56_init_context(AVCodecContext *avctx, VP56Context *s,
int flip, int has_alpha);
-int ff_vp56_free(AVCodecContext *avctx);
int ff_vp56_free_context(VP56Context *s);
void ff_vp56_init_dequant(VP56Context *s, int quantizer);
int ff_vp56_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
--
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".
^ permalink raw reply [flat|nested] 8+ messages in thread
* [FFmpeg-devel] [PATCH 6/6] avcodec/vp[56]: Mark decoders as init-threadsafe
[not found] ` <20220211085101.1588296-1-andreas.rheinhardt@outlook.com>
` (2 preceding siblings ...)
2022-02-11 8:51 ` [FFmpeg-devel] [PATCH 5/6] avcodec/vp56: Avoid functions with only one caller Andreas Rheinhardt
@ 2022-02-11 8:51 ` Andreas Rheinhardt
3 siblings, 0 replies; 8+ messages in thread
From: Andreas Rheinhardt @ 2022-02-11 8:51 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Nothing with static storage duration is initialized by these codecs.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/vp5.c | 2 +-
libavcodec/vp6.c | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c
index dc24f5b096..6146fbbc3a 100644
--- a/libavcodec/vp5.c
+++ b/libavcodec/vp5.c
@@ -312,5 +312,5 @@ const AVCodec ff_vp5_decoder = {
.close = vp56_free,
.decode = ff_vp56_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
};
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index ae8e223349..40d266916e 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -721,7 +721,7 @@ const AVCodec ff_vp6_decoder = {
.close = vp6_decode_free,
.decode = ff_vp56_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
};
/* flash version, not flipped upside-down */
@@ -735,7 +735,7 @@ const AVCodec ff_vp6f_decoder = {
.close = vp6_decode_free,
.decode = ff_vp56_decode_frame,
.capabilities = AV_CODEC_CAP_DR1,
- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
};
/* flash version, not flipped upside-down, with alpha channel */
@@ -749,5 +749,5 @@ const AVCodec ff_vp6a_decoder = {
.close = vp6_decode_free,
.decode = ff_vp56_decode_frame,
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS,
- .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
+ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP,
};
--
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".
^ permalink raw reply [flat|nested] 8+ messages in thread