aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-10-30 16:12:15 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-11-06 17:41:26 +0100
commit835be33ee30f872f6e400cba7bae14d8a1e5f89a (patch)
treec6b3d48980b91cb66bc07782577e4da2f2a81648
parent5a157313b3860887947b6fe51d313aa4d397d3a0 (diff)
downloadffmpeg-835be33ee30f872f6e400cba7bae14d8a1e5f89a.tar.gz
avcodec/vc1dec: Factor (re)initializing code out
This is in preparation for removing the msmpeg4 dependency from VC-1. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavcodec/mss2.c5
-rw-r--r--libavcodec/vc1.h2
-rw-r--r--libavcodec/vc1dec.c25
3 files changed, 21 insertions, 11 deletions
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 14746505f4..2469718c8f 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -29,7 +29,6 @@
#include "error_resilience.h"
#include "mpeg_er.h"
#include "mpegvideodec.h"
-#include "msmpeg4dec.h"
#include "qpeldsp.h"
#include "vc1.h"
#include "wmv2data.h"
@@ -852,8 +851,8 @@ static av_cold int wmv9_init(AVCodecContext *avctx)
ff_vc1_init_transposed_scantables(v);
- if ((ret = ff_msmpeg4_decode_init(avctx)) < 0 ||
- (ret = ff_vc1_decode_init_alloc_tables(v)) < 0)
+ ret = ff_vc1_decode_init(avctx);
+ if (ret < 0)
return ret;
/* error concealment */
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
index 9b25f0872f..3b6be78141 100644
--- a/libavcodec/vc1.h
+++ b/libavcodec/vc1.h
@@ -413,7 +413,7 @@ int ff_vc1_parse_frame_header (VC1Context *v, GetBitContext *gb);
int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb);
void ff_vc1_init_common(VC1Context *v);
-int ff_vc1_decode_init_alloc_tables(VC1Context *v);
+int ff_vc1_decode_init(AVCodecContext *avctx);
void ff_vc1_init_transposed_scantables(VC1Context *v);
int ff_vc1_decode_end(AVCodecContext *avctx);
void ff_vc1_decode_blocks(VC1Context *v);
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 49ecfd8a48..682b39083b 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -329,7 +329,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx)
#endif
-av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
+static av_cold int vc1_decode_init_alloc_tables(VC1Context *v)
{
MpegEncContext *s = &v->s;
int i, ret = AVERROR(ENOMEM);
@@ -404,10 +404,24 @@ av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
return 0;
error:
- ff_vc1_decode_end(s->avctx);
return ret;
}
+av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
+{
+ int ret = ff_msmpeg4_decode_init(avctx);
+ VC1Context *const v = avctx->priv_data;
+ if (ret < 0)
+ return ret;
+
+ ret = vc1_decode_init_alloc_tables(v);
+ if (ret < 0) {
+ ff_vc1_decode_end(avctx);
+ return ret;
+ }
+ return 0;
+}
+
av_cold void ff_vc1_init_transposed_scantables(VC1Context *v)
{
int i;
@@ -947,12 +961,9 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
}
if (!s->context_initialized) {
- if ((ret = ff_msmpeg4_decode_init(avctx)) < 0)
- goto err;
- if ((ret = ff_vc1_decode_init_alloc_tables(v)) < 0) {
- ff_mpv_common_end(s);
+ ret = ff_vc1_decode_init(avctx);
+ if (ret < 0)
goto err;
- }
s->low_delay = !avctx->has_b_frames || v->res_sprite;