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>
release/7.1
Andreas Rheinhardt 8 months ago
parent b90b676409
commit 99d26939af
  1. 4
      libavcodec/flvdec.c
  2. 11
      libavcodec/h261dec.c
  3. 12
      libavcodec/h263dec.c
  4. 1
      libavcodec/h263dec.h
  5. 2
      libavcodec/intelh263dec.c
  6. 3
      libavcodec/mpeg12dec.c
  7. 2
      libavcodec/mpeg4videodec.c
  8. 8
      libavcodec/mpegvideo_dec.c
  9. 1
      libavcodec/mpegvideodec.h
  10. 9
      libavcodec/msmpeg4dec.c
  11. 12
      libavcodec/rv10.c
  12. 1
      libavcodec/rv30.c
  13. 8
      libavcodec/rv34.c
  14. 1
      libavcodec/rv40.c
  15. 18
      libavcodec/vc1dec.c
  16. 3
      libavcodec/wmv2dec.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,

@ -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,
};

@ -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,

@ -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);

@ -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,
};

@ -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 = {

@ -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,

@ -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;

@ -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);

@ -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,

@ -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,

@ -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),
};

@ -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);
}

@ -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),
};

@ -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?)

@ -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 = {

Loading…
Cancel
Save