aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-04-28 17:40:58 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2024-06-12 11:44:13 +0200
commit99d26939af3f0ef80f56debe458006abec3cbc71 (patch)
tree7307014c20860e7ca5b1a4560c0739769b62936e
parentb90b6764093a40d6b2064cdd07c4c715c934ebf1 (diff)
downloadffmpeg-99d26939af3f0ef80f56debe458006abec3cbc71.tar.gz
avcodec/mpegvideo_dec: Add close function for mpegvideo-decoders
Currently identical to the H.261 and H.263 close functions (which it replaces). It will be extended in future commits. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavcodec/flvdec.c4
-rw-r--r--libavcodec/h261dec.c11
-rw-r--r--libavcodec/h263dec.c12
-rw-r--r--libavcodec/h263dec.h1
-rw-r--r--libavcodec/intelh263dec.c2
-rw-r--r--libavcodec/mpeg12dec.c3
-rw-r--r--libavcodec/mpeg4videodec.c2
-rw-r--r--libavcodec/mpegvideo_dec.c8
-rw-r--r--libavcodec/mpegvideodec.h1
-rw-r--r--libavcodec/msmpeg4dec.c9
-rw-r--r--libavcodec/rv10.c12
-rw-r--r--libavcodec/rv30.c1
-rw-r--r--libavcodec/rv34.c8
-rw-r--r--libavcodec/rv40.c1
-rw-r--r--libavcodec/vc1dec.c18
-rw-r--r--libavcodec/wmv2dec.c3
16 files changed, 43 insertions, 53 deletions
diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c
index 8baaed06a8..1bb1b12917 100644
--- a/libavcodec/flvdec.c
+++ b/libavcodec/flvdec.c
@@ -24,7 +24,7 @@
#include "flvdec.h"
#include "h263dec.h"
#include "mpegvideo.h"
-#include "mpegvideodata.h"
+#include "mpegvideodec.h"
int ff_flv_decode_picture_header(MpegEncContext *s)
{
@@ -118,8 +118,8 @@ const FFCodec ff_flv_decoder = {
.p.id = AV_CODEC_ID_FLV1,
.priv_data_size = sizeof(MpegEncContext),
.init = ff_h263_decode_init,
- .close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.p.max_lowres = 3,
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index 9acfd984ee..d8d0dcf3cf 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -660,15 +660,6 @@ static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict,
return get_consumed_bytes(s, buf_size);
}
-static av_cold int h261_decode_end(AVCodecContext *avctx)
-{
- H261DecContext *const h = avctx->priv_data;
- MpegEncContext *s = &h->s;
-
- ff_mpv_common_end(s);
- return 0;
-}
-
const FFCodec ff_h261_decoder = {
.p.name = "h261",
CODEC_LONG_NAME("H.261"),
@@ -676,8 +667,8 @@ const FFCodec ff_h261_decoder = {
.p.id = AV_CODEC_ID_H261,
.priv_data_size = sizeof(H261DecContext),
.init = h261_decode_init,
- .close = h261_decode_end,
FF_CODEC_DECODE_CB(h261_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DR1,
.p.max_lowres = 3,
};
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 4fe4a30000..b8db4ffc98 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -159,14 +159,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx)
return 0;
}
-av_cold int ff_h263_decode_end(AVCodecContext *avctx)
-{
- MpegEncContext *s = avctx->priv_data;
-
- ff_mpv_common_end(s);
- return 0;
-}
-
/**
* Return the number of bytes consumed for building the current frame.
*/
@@ -702,8 +694,8 @@ const FFCodec ff_h263_decoder = {
.p.id = AV_CODEC_ID_H263,
.priv_data_size = sizeof(MpegEncContext),
.init = ff_h263_decode_init,
- .close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
AV_CODEC_CAP_DELAY,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
@@ -719,8 +711,8 @@ const FFCodec ff_h263p_decoder = {
.p.id = AV_CODEC_ID_H263P,
.priv_data_size = sizeof(MpegEncContext),
.init = ff_h263_decode_init,
- .close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
AV_CODEC_CAP_DELAY,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
diff --git a/libavcodec/h263dec.h b/libavcodec/h263dec.h
index a01acc0834..633d4aa577 100644
--- a/libavcodec/h263dec.h
+++ b/libavcodec/h263dec.h
@@ -47,7 +47,6 @@ int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code);
int ff_h263_decode_init(AVCodecContext *avctx);
int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *frame,
int *got_frame, AVPacket *avpkt);
-int ff_h263_decode_end(AVCodecContext *avctx);
void ff_h263_decode_init_vlc(void);
int ff_h263_decode_picture_header(MpegEncContext *s);
int ff_h263_decode_gob_header(MpegEncContext *s);
diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c
index 5d34892ef7..d4051c36f1 100644
--- a/libavcodec/intelh263dec.c
+++ b/libavcodec/intelh263dec.c
@@ -132,8 +132,8 @@ const FFCodec ff_h263i_decoder = {
.p.id = AV_CODEC_ID_H263I,
.priv_data_size = sizeof(MpegEncContext),
.init = ff_h263_decode_init,
- .close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
};
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 3a86896582..ea73d67868 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2595,9 +2595,8 @@ static av_cold int mpeg_decode_end(AVCodecContext *avctx)
{
Mpeg1Context *s = avctx->priv_data;
- ff_mpv_common_end(&s->mpeg_enc_ctx);
av_buffer_unref(&s->a53_buf_ref);
- return 0;
+ return ff_mpv_decode_close(avctx);
}
const FFCodec ff_mpeg1video_decoder = {
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 3518a25621..bab3501ea1 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -3862,8 +3862,8 @@ const FFCodec ff_mpeg4_decoder = {
.p.id = AV_CODEC_ID_MPEG4,
.priv_data_size = sizeof(Mpeg4DecContext),
.init = decode_init,
- .close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
diff --git a/libavcodec/mpegvideo_dec.c b/libavcodec/mpegvideo_dec.c
index 71a6c0ad67..c8952f4831 100644
--- a/libavcodec/mpegvideo_dec.c
+++ b/libavcodec/mpegvideo_dec.c
@@ -173,6 +173,14 @@ do {\
return 0;
}
+int ff_mpv_decode_close(AVCodecContext *avctx)
+{
+ MpegEncContext *s = avctx->priv_data;
+
+ ff_mpv_common_end(s);
+ return 0;
+}
+
int ff_mpv_common_frame_size_change(MpegEncContext *s)
{
int err = 0;
diff --git a/libavcodec/mpegvideodec.h b/libavcodec/mpegvideodec.h
index 4259d5a02d..35e9081d2c 100644
--- a/libavcodec/mpegvideodec.h
+++ b/libavcodec/mpegvideodec.h
@@ -63,6 +63,7 @@ int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f,
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src);
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h);
void ff_mpeg_flush(AVCodecContext *avctx);
+int ff_mpv_decode_close(AVCodecContext *avctx);
void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict);
diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index a7b3fc4603..20d735a152 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -28,6 +28,7 @@
#include "codec_internal.h"
#include "mpegutils.h"
#include "mpegvideo.h"
+#include "mpegvideodec.h"
#include "msmpeg4.h"
#include "msmpeg4dec.h"
#include "libavutil/imgutils.h"
@@ -848,8 +849,8 @@ const FFCodec ff_msmpeg4v1_decoder = {
.p.id = AV_CODEC_ID_MSMPEG4V1,
.priv_data_size = sizeof(MpegEncContext),
.init = ff_msmpeg4_decode_init,
- .close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.p.max_lowres = 3,
@@ -862,8 +863,8 @@ const FFCodec ff_msmpeg4v2_decoder = {
.p.id = AV_CODEC_ID_MSMPEG4V2,
.priv_data_size = sizeof(MpegEncContext),
.init = ff_msmpeg4_decode_init,
- .close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.p.max_lowres = 3,
@@ -876,8 +877,8 @@ const FFCodec ff_msmpeg4v3_decoder = {
.p.id = AV_CODEC_ID_MSMPEG4V3,
.priv_data_size = sizeof(MpegEncContext),
.init = ff_msmpeg4_decode_init,
- .close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.p.max_lowres = 3,
@@ -890,8 +891,8 @@ const FFCodec ff_wmv1_decoder = {
.p.id = AV_CODEC_ID_WMV1,
.priv_data_size = sizeof(MpegEncContext),
.init = ff_msmpeg4_decode_init,
- .close = ff_h263_decode_end,
FF_CODEC_DECODE_CB(ff_h263_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
.p.max_lowres = 3,
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 201e7ed6d0..6ece6a5a25 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -416,14 +416,6 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
return 0;
}
-static av_cold int rv10_decode_end(AVCodecContext *avctx)
-{
- MpegEncContext *s = avctx->priv_data;
-
- ff_mpv_common_end(s);
- return 0;
-}
-
static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
int buf_size, int buf_size2, int whole_size)
{
@@ -666,8 +658,8 @@ const FFCodec ff_rv10_decoder = {
.p.id = AV_CODEC_ID_RV10,
.priv_data_size = sizeof(RVDecContext),
.init = rv10_decode_init,
- .close = rv10_decode_end,
FF_CODEC_DECODE_CB(rv10_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DR1,
.p.max_lowres = 3,
};
@@ -679,8 +671,8 @@ const FFCodec ff_rv20_decoder = {
.p.id = AV_CODEC_ID_RV20,
.priv_data_size = sizeof(RVDecContext),
.init = rv10_decode_init,
- .close = rv10_decode_end,
FF_CODEC_DECODE_CB(rv10_decode_frame),
+ .close = ff_mpv_decode_close,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
.flush = ff_mpeg_flush,
.p.max_lowres = 3,
diff --git a/libavcodec/rv30.c b/libavcodec/rv30.c
index 9c8bb966e9..5e1dd01aa1 100644
--- a/libavcodec/rv30.c
+++ b/libavcodec/rv30.c
@@ -302,6 +302,7 @@ const FFCodec ff_rv30_decoder = {
FF_CODEC_DECODE_CB(ff_rv34_decode_frame),
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_FRAME_THREADS,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.flush = ff_mpeg_flush,
UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context),
};
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 6424c7b982..9e087cb16c 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1522,10 +1522,9 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx)
ff_h264_pred_init(&r->h, AV_CODEC_ID_RV40, 8, 1);
- if ((ret = rv34_decoder_alloc(r)) < 0) {
- ff_mpv_common_end(&r->s);
+ ret = rv34_decoder_alloc(r);
+ if (ret < 0)
return ret;
- }
ff_thread_once(&init_static_once, rv34_init_tables);
@@ -1823,8 +1822,7 @@ av_cold int ff_rv34_decode_end(AVCodecContext *avctx)
{
RV34DecContext *r = avctx->priv_data;
- ff_mpv_common_end(&r->s);
rv34_decoder_free(r);
- return 0;
+ return ff_mpv_decode_close(avctx);
}
diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
index 536bbc9623..0a5136d129 100644
--- a/libavcodec/rv40.c
+++ b/libavcodec/rv40.c
@@ -580,6 +580,7 @@ const FFCodec ff_rv40_decoder = {
FF_CODEC_DECODE_CB(ff_rv34_decode_frame),
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
AV_CODEC_CAP_FRAME_THREADS,
+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
.flush = ff_mpeg_flush,
UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context),
};
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 9b912bec1f..a20facc899 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -449,6 +449,8 @@ static enum AVPixelFormat vc1_get_format(AVCodecContext *avctx)
return ff_get_format(avctx, vc1_hwaccel_pixfmt_list_420);
}
+static void vc1_decode_reset(AVCodecContext *avctx);
+
av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
{
VC1Context *const v = avctx->priv_data;
@@ -477,7 +479,7 @@ av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
ret = vc1_decode_init_alloc_tables(v);
if (ret < 0) {
- ff_vc1_decode_end(avctx);
+ vc1_decode_reset(avctx);
return ret;
}
return 0;
@@ -774,10 +776,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
return 0;
}
-/** Close a VC1/WMV3 decoder
- * @warning Initial try at using MpegEncContext stuff
- */
-av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
+static av_cold void vc1_decode_reset(AVCodecContext *avctx)
{
VC1Context *v = avctx->priv_data;
int i;
@@ -803,9 +802,16 @@ av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
av_freep(&v->is_intra_base); // FIXME use v->mb_type[]
av_freep(&v->luma_mv_base);
ff_intrax8_common_end(&v->x8);
- return 0;
}
+/**
+ * Close a MSS2/VC1/WMV3 decoder
+ */
+av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
+{
+ vc1_decode_reset(avctx);
+ return ff_mpv_decode_close(avctx);
+}
/** Decode a VC1/WMV3 frame
* @todo TODO: Handle VC-1 IDUs (Transport level?)
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index bb3829dcd6..5c91006169 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -27,6 +27,7 @@
#include "mathops.h"
#include "mpegutils.h"
#include "mpegvideo.h"
+#include "mpegvideodec.h"
#include "msmpeg4.h"
#include "msmpeg4_vc1_data.h"
#include "msmpeg4dec.h"
@@ -584,7 +585,7 @@ static av_cold int wmv2_decode_end(AVCodecContext *avctx)
WMV2DecContext *const w = avctx->priv_data;
ff_intrax8_common_end(&w->x8);
- return ff_h263_decode_end(avctx);
+ return ff_mpv_decode_close(avctx);
}
const FFCodec ff_wmv2_decoder = {