History

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.

Andreas Rheinhardt committed 2 years ago

Commit 99d26931 parent b90b67616 files · +43 −53Browse files

Unified · Split

16 files
  1. libavcodec/flvdec.c +2 −2
  2. libavcodec/h261dec.c +1 −10
  3. libavcodec/h263dec.c +2 −10
  4. libavcodec/h263dec.h +0 −1
  5. libavcodec/intelh263dec.c +1 −1
  6. libavcodec/mpeg12dec.c +1 −2
  7. libavcodec/mpeg4videodec.c +1 −1
  8. libavcodec/mpegvideo_dec.c +8 −0
  9. libavcodec/mpegvideodec.h +1 −0
  10. libavcodec/msmpeg4dec.c +5 −4
  11. libavcodec/rv10.c +2 −10
  12. libavcodec/rv30.c +1 −0
  13. libavcodec/rv34.c +3 −5
  14. libavcodec/rv40.c +1 −0
  15. libavcodec/vc1dec.c +12 −6
  16. libavcodec/wmv2dec.c +2 −1
libavcodec/flvdec.c+2−2
@@ -24,7 +24,7 @@ · 23 unmodified lines
2424 #include "flvdec.h"
2525 #include "h263dec.h"
2626 #include "mpegvideo.h"
27−#include "mpegvideodata.h"
27+#include "mpegvideodec.h"
2828
2929 int ff_flv_decode_picture_header(MpegEncContext *s)
3030 {
@@ -118,8 +118,8 @@ const FFCodec ff_flv_decoder = { · 87 unmodified lines
118118 .p.id = AV_CODEC_ID_FLV1,
119119 .priv_data_size = sizeof(MpegEncContext),
120120 .init = ff_h263_decode_init,
121− .close = ff_h263_decode_end,
122121 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
122+ .close = ff_mpv_decode_close,
123123 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
124124 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
125125 .p.max_lowres = 3,
libavcodec/h261dec.c+1−10
@@ -660,15 +660,6 @@ static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 659 unmodified lines
660660 return get_consumed_bytes(s, buf_size);
661661 }
662662
663−static av_cold int h261_decode_end(AVCodecContext *avctx)
664−{
665− H261DecContext *const h = avctx->priv_data;
666− MpegEncContext *s = &h->s;
667−
668− ff_mpv_common_end(s);
669− return 0;
670−}
671−
672663 const FFCodec ff_h261_decoder = {
673664 .p.name = "h261",
674665 CODEC_LONG_NAME("H.261"),
@@ -676,8 +667,8 @@ const FFCodec ff_h261_decoder = { · 1 unmodified line
676667 .p.id = AV_CODEC_ID_H261,
677668 .priv_data_size = sizeof(H261DecContext),
678669 .init = h261_decode_init,
679− .close = h261_decode_end,
680670 FF_CODEC_DECODE_CB(h261_decode_frame),
671+ .close = ff_mpv_decode_close,
681672 .p.capabilities = AV_CODEC_CAP_DR1,
682673 .p.max_lowres = 3,
683674 };
libavcodec/h263dec.c+2−10
@@ -159,14 +159,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) · 158 unmodified lines
159159 return 0;
160160 }
161161
162−av_cold int ff_h263_decode_end(AVCodecContext *avctx)
163−{
164− MpegEncContext *s = avctx->priv_data;
165−
166− ff_mpv_common_end(s);
167− return 0;
168−}
169−
170162 /**
171163 * Return the number of bytes consumed for building the current frame.
172164 */
@@ -702,8 +694,8 @@ const FFCodec ff_h263_decoder = { · 529 unmodified lines
702694 .p.id = AV_CODEC_ID_H263,
703695 .priv_data_size = sizeof(MpegEncContext),
704696 .init = ff_h263_decode_init,
705− .close = ff_h263_decode_end,
706697 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
698+ .close = ff_mpv_decode_close,
707699 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
708700 AV_CODEC_CAP_DELAY,
709701 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
@@ -719,8 +711,8 @@ const FFCodec ff_h263p_decoder = { · 9 unmodified lines
719711 .p.id = AV_CODEC_ID_H263P,
720712 .priv_data_size = sizeof(MpegEncContext),
721713 .init = ff_h263_decode_init,
722− .close = ff_h263_decode_end,
723714 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
715+ .close = ff_mpv_decode_close,
724716 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
725717 AV_CODEC_CAP_DELAY,
726718 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
libavcodec/h263dec.h+0−1
@@ -47,7 +47,6 @@ int ff_h263_decode_motion(MpegEncContext * s, int pred, int f_code); · 46 unmodified lines
4747 int ff_h263_decode_init(AVCodecContext *avctx);
4848 int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *frame,
4949 int *got_frame, AVPacket *avpkt);
50−int ff_h263_decode_end(AVCodecContext *avctx);
5150 void ff_h263_decode_init_vlc(void);
5251 int ff_h263_decode_picture_header(MpegEncContext *s);
5352 int ff_h263_decode_gob_header(MpegEncContext *s);
libavcodec/intelh263dec.c+1−1
@@ -132,8 +132,8 @@ const FFCodec ff_h263i_decoder = { · 131 unmodified lines
132132 .p.id = AV_CODEC_ID_H263I,
133133 .priv_data_size = sizeof(MpegEncContext),
134134 .init = ff_h263_decode_init,
135− .close = ff_h263_decode_end,
136135 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
136+ .close = ff_mpv_decode_close,
137137 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
138138 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
139139 };
libavcodec/mpeg12dec.c+1−2
@@ -2595,9 +2595,8 @@ static av_cold int mpeg_decode_end(AVCodecContext *avctx) · 2594 unmodified lines
25952595 {
25962596 Mpeg1Context *s = avctx->priv_data;
25972597
2598− ff_mpv_common_end(&s->mpeg_enc_ctx);
25992598 av_buffer_unref(&s->a53_buf_ref);
2600− return 0;
2599+ return ff_mpv_decode_close(avctx);
26012600 }
26022601
26032602 const FFCodec ff_mpeg1video_decoder = {
libavcodec/mpeg4videodec.c+1−1
@@ -3862,8 +3862,8 @@ const FFCodec ff_mpeg4_decoder = { · 3861 unmodified lines
38623862 .p.id = AV_CODEC_ID_MPEG4,
38633863 .priv_data_size = sizeof(Mpeg4DecContext),
38643864 .init = decode_init,
3865− .close = ff_h263_decode_end,
38663865 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
3866+ .close = ff_mpv_decode_close,
38673867 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
38683868 AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS,
38693869 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
libavcodec/mpegvideo_dec.c+8−0
@@ -173,6 +173,14 @@ do {\ · 172 unmodified lines
173173 return 0;
174174 }
175175
176+int ff_mpv_decode_close(AVCodecContext *avctx)
177+{
178+ MpegEncContext *s = avctx->priv_data;
179+
180+ ff_mpv_common_end(s);
181+ return 0;
182+}
183+
176184 int ff_mpv_common_frame_size_change(MpegEncContext *s)
177185 {
178186 int err = 0;
libavcodec/mpegvideodec.h+1−0
@@ -63,6 +63,7 @@ int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f, · 62 unmodified lines
6363 int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src);
6464 void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h);
6565 void ff_mpeg_flush(AVCodecContext *avctx);
66+int ff_mpv_decode_close(AVCodecContext *avctx);
6667
6768 void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict);
6869
libavcodec/msmpeg4dec.c+5−4
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include "codec_internal.h"
2929 #include "mpegutils.h"
3030 #include "mpegvideo.h"
31+#include "mpegvideodec.h"
3132 #include "msmpeg4.h"
3233 #include "msmpeg4dec.h"
3334 #include "libavutil/imgutils.h"
@@ -848,8 +849,8 @@ const FFCodec ff_msmpeg4v1_decoder = { · 814 unmodified lines
848849 .p.id = AV_CODEC_ID_MSMPEG4V1,
849850 .priv_data_size = sizeof(MpegEncContext),
850851 .init = ff_msmpeg4_decode_init,
851− .close = ff_h263_decode_end,
852852 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
853+ .close = ff_mpv_decode_close,
853854 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
854855 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
855856 .p.max_lowres = 3,
@@ -862,8 +863,8 @@ const FFCodec ff_msmpeg4v2_decoder = { · 6 unmodified lines
862863 .p.id = AV_CODEC_ID_MSMPEG4V2,
863864 .priv_data_size = sizeof(MpegEncContext),
864865 .init = ff_msmpeg4_decode_init,
865− .close = ff_h263_decode_end,
866866 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
867+ .close = ff_mpv_decode_close,
867868 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
868869 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
869870 .p.max_lowres = 3,
@@ -876,8 +877,8 @@ const FFCodec ff_msmpeg4v3_decoder = { · 6 unmodified lines
876877 .p.id = AV_CODEC_ID_MSMPEG4V3,
877878 .priv_data_size = sizeof(MpegEncContext),
878879 .init = ff_msmpeg4_decode_init,
879− .close = ff_h263_decode_end,
880880 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
881+ .close = ff_mpv_decode_close,
881882 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
882883 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
883884 .p.max_lowres = 3,
@@ -890,8 +891,8 @@ const FFCodec ff_wmv1_decoder = { · 6 unmodified lines
890891 .p.id = AV_CODEC_ID_WMV1,
891892 .priv_data_size = sizeof(MpegEncContext),
892893 .init = ff_msmpeg4_decode_init,
893− .close = ff_h263_decode_end,
894894 FF_CODEC_DECODE_CB(ff_h263_decode_frame),
895+ .close = ff_mpv_decode_close,
895896 .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
896897 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
897898 .p.max_lowres = 3,
libavcodec/rv10.c+2−10
@@ -416,14 +416,6 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) · 415 unmodified lines
416416 return 0;
417417 }
418418
419−static av_cold int rv10_decode_end(AVCodecContext *avctx)
420−{
421− MpegEncContext *s = avctx->priv_data;
422−
423− ff_mpv_common_end(s);
424− return 0;
425−}
426−
427419 static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
428420 int buf_size, int buf_size2, int whole_size)
429421 {
@@ -666,8 +658,8 @@ const FFCodec ff_rv10_decoder = { · 236 unmodified lines
666658 .p.id = AV_CODEC_ID_RV10,
667659 .priv_data_size = sizeof(RVDecContext),
668660 .init = rv10_decode_init,
669− .close = rv10_decode_end,
670661 FF_CODEC_DECODE_CB(rv10_decode_frame),
662+ .close = ff_mpv_decode_close,
671663 .p.capabilities = AV_CODEC_CAP_DR1,
672664 .p.max_lowres = 3,
673665 };
@@ -679,8 +671,8 @@ const FFCodec ff_rv20_decoder = { · 5 unmodified lines
679671 .p.id = AV_CODEC_ID_RV20,
680672 .priv_data_size = sizeof(RVDecContext),
681673 .init = rv10_decode_init,
682− .close = rv10_decode_end,
683674 FF_CODEC_DECODE_CB(rv10_decode_frame),
675+ .close = ff_mpv_decode_close,
684676 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
685677 .flush = ff_mpeg_flush,
686678 .p.max_lowres = 3,
libavcodec/rv30.c+1−0
@@ -302,6 +302,7 @@ const FFCodec ff_rv30_decoder = { · 301 unmodified lines
302302 FF_CODEC_DECODE_CB(ff_rv34_decode_frame),
303303 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
304304 AV_CODEC_CAP_FRAME_THREADS,
305+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
305306 .flush = ff_mpeg_flush,
306307 UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context),
307308 };
libavcodec/rv34.c+3−5
@@ -1522,10 +1522,9 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) · 1521 unmodified lines
15221522
15231523 ff_h264_pred_init(&r->h, AV_CODEC_ID_RV40, 8, 1);
15241524
1525− if ((ret = rv34_decoder_alloc(r)) < 0) {
1526− ff_mpv_common_end(&r->s);
1525+ ret = rv34_decoder_alloc(r);
1526+ if (ret < 0)
15271527 return ret;
1528− }
15291528
15301529 ff_thread_once(&init_static_once, rv34_init_tables);
15311530
@@ -1823,8 +1822,7 @@ av_cold int ff_rv34_decode_end(AVCodecContext *avctx) · 291 unmodified lines
18231822 {
18241823 RV34DecContext *r = avctx->priv_data;
18251824
1826− ff_mpv_common_end(&r->s);
18271825 rv34_decoder_free(r);
18281826
1829− return 0;
1827+ return ff_mpv_decode_close(avctx);
18301828 }
libavcodec/rv40.c+1−0
@@ -580,6 +580,7 @@ const FFCodec ff_rv40_decoder = { · 579 unmodified lines
580580 FF_CODEC_DECODE_CB(ff_rv34_decode_frame),
581581 .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
582582 AV_CODEC_CAP_FRAME_THREADS,
583+ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
583584 .flush = ff_mpeg_flush,
584585 UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context),
585586 };
libavcodec/vc1dec.c+12−6
@@ -449,6 +449,8 @@ static enum AVPixelFormat vc1_get_format(AVCodecContext *avctx) · 448 unmodified lines
449449 return ff_get_format(avctx, vc1_hwaccel_pixfmt_list_420);
450450 }
451451
452+static void vc1_decode_reset(AVCodecContext *avctx);
453+
452454 av_cold int ff_vc1_decode_init(AVCodecContext *avctx)
453455 {
454456 VC1Context *const v = avctx->priv_data;
@@ -477,7 +479,7 @@ av_cold int ff_vc1_decode_init(AVCodecContext *avctx) · 22 unmodified lines
477479
478480 ret = vc1_decode_init_alloc_tables(v);
479481 if (ret < 0) {
480− ff_vc1_decode_end(avctx);
482+ vc1_decode_reset(avctx);
481483 return ret;
482484 }
483485 return 0;
@@ -774,10 +776,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 290 unmodified lines
774776 return 0;
775777 }
776778
777−/** Close a VC1/WMV3 decoder
778− * @warning Initial try at using MpegEncContext stuff
779− */
780−av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
779+static av_cold void vc1_decode_reset(AVCodecContext *avctx)
781780 {
782781 VC1Context *v = avctx->priv_data;
783782 int i;
@@ -803,9 +802,16 @@ av_cold int ff_vc1_decode_end(AVCodecContext *avctx) · 19 unmodified lines
803802 av_freep(&v->is_intra_base); // FIXME use v->mb_type[]
804803 av_freep(&v->luma_mv_base);
805804 ff_intrax8_common_end(&v->x8);
806− return 0;
807805 }
808806
807+/**
808+ * Close a MSS2/VC1/WMV3 decoder
809+ */
810+av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
811+{
812+ vc1_decode_reset(avctx);
813+ return ff_mpv_decode_close(avctx);
814+}
809815
810816 /** Decode a VC1/WMV3 frame
811817 * @todo TODO: Handle VC-1 IDUs (Transport level?)
libavcodec/wmv2dec.c+2−1
@@ -27,6 +27,7 @@ · 26 unmodified lines
2727 #include "mathops.h"
2828 #include "mpegutils.h"
2929 #include "mpegvideo.h"
30+#include "mpegvideodec.h"
3031 #include "msmpeg4.h"
3132 #include "msmpeg4_vc1_data.h"
3233 #include "msmpeg4dec.h"
@@ -584,7 +585,7 @@ static av_cold int wmv2_decode_end(AVCodecContext *avctx) · 551 unmodified lines
584585 WMV2DecContext *const w = avctx->priv_data;
585586
586587 ff_intrax8_common_end(&w->x8);
587− return ff_h263_decode_end(avctx);
588+ return ff_mpv_decode_close(avctx);
588589 }
589590
590591 const FFCodec ff_wmv2_decoder = {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t