Currently identical to the H.261 and H.263 close functions (which it replaces). It will be extended in future commits.
Unified · Split
| @@ -24,7 +24,7 @@ · 23 unmodified lines | ||
| 24 | 24 | #include "flvdec.h" |
| 25 | 25 | #include "h263dec.h" |
| 26 | 26 | #include "mpegvideo.h" |
| 27 | −#include "mpegvideodata.h" | |
| 27 | +#include "mpegvideodec.h" | |
| 28 | 28 | |
| 29 | 29 | int ff_flv_decode_picture_header(MpegEncContext *s) |
| 30 | 30 | { |
| @@ -118,8 +118,8 @@ const FFCodec ff_flv_decoder = { · 87 unmodified lines | ||
| 118 | 118 | .p.id = AV_CODEC_ID_FLV1, |
| 119 | 119 | .priv_data_size = sizeof(MpegEncContext), |
| 120 | 120 | .init = ff_h263_decode_init, |
| 121 | − .close = ff_h263_decode_end, | |
| 122 | 121 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), |
| 122 | + .close = ff_mpv_decode_close, | |
| 123 | 123 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, |
| 124 | 124 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
| 125 | 125 | .p.max_lowres = 3, |
| @@ -660,15 +660,6 @@ static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict, · 659 unmodified lines | ||
| 660 | 660 | return get_consumed_bytes(s, buf_size); |
| 661 | 661 | } |
| 662 | 662 | |
| 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 | − | |
| 672 | 663 | const FFCodec ff_h261_decoder = { |
| 673 | 664 | .p.name = "h261", |
| 674 | 665 | CODEC_LONG_NAME("H.261"), |
| @@ -676,8 +667,8 @@ const FFCodec ff_h261_decoder = { · 1 unmodified line | ||
| 676 | 667 | .p.id = AV_CODEC_ID_H261, |
| 677 | 668 | .priv_data_size = sizeof(H261DecContext), |
| 678 | 669 | .init = h261_decode_init, |
| 679 | − .close = h261_decode_end, | |
| 680 | 670 | FF_CODEC_DECODE_CB(h261_decode_frame), |
| 671 | + .close = ff_mpv_decode_close, | |
| 681 | 672 | .p.capabilities = AV_CODEC_CAP_DR1, |
| 682 | 673 | .p.max_lowres = 3, |
| 683 | 674 | }; |
| @@ -159,14 +159,6 @@ av_cold int ff_h263_decode_init(AVCodecContext *avctx) · 158 unmodified lines | ||
| 159 | 159 | return 0; |
| 160 | 160 | } |
| 161 | 161 | |
| 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 | − | |
| 170 | 162 | /** |
| 171 | 163 | * Return the number of bytes consumed for building the current frame. |
| 172 | 164 | */ |
| @@ -702,8 +694,8 @@ const FFCodec ff_h263_decoder = { · 529 unmodified lines | ||
| 702 | 694 | .p.id = AV_CODEC_ID_H263, |
| 703 | 695 | .priv_data_size = sizeof(MpegEncContext), |
| 704 | 696 | .init = ff_h263_decode_init, |
| 705 | − .close = ff_h263_decode_end, | |
| 706 | 697 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), |
| 698 | + .close = ff_mpv_decode_close, | |
| 707 | 699 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | |
| 708 | 700 | AV_CODEC_CAP_DELAY, |
| 709 | 701 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
| @@ -719,8 +711,8 @@ const FFCodec ff_h263p_decoder = { · 9 unmodified lines | ||
| 719 | 711 | .p.id = AV_CODEC_ID_H263P, |
| 720 | 712 | .priv_data_size = sizeof(MpegEncContext), |
| 721 | 713 | .init = ff_h263_decode_init, |
| 722 | − .close = ff_h263_decode_end, | |
| 723 | 714 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), |
| 715 | + .close = ff_mpv_decode_close, | |
| 724 | 716 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | |
| 725 | 717 | AV_CODEC_CAP_DELAY, |
| 726 | 718 | .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); · 46 unmodified lines | ||
| 47 | 47 | int ff_h263_decode_init(AVCodecContext *avctx); |
| 48 | 48 | int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *frame, |
| 49 | 49 | int *got_frame, AVPacket *avpkt); |
| 50 | −int ff_h263_decode_end(AVCodecContext *avctx); | |
| 51 | 50 | void ff_h263_decode_init_vlc(void); |
| 52 | 51 | int ff_h263_decode_picture_header(MpegEncContext *s); |
| 53 | 52 | int ff_h263_decode_gob_header(MpegEncContext *s); |
| @@ -132,8 +132,8 @@ const FFCodec ff_h263i_decoder = { · 131 unmodified lines | ||
| 132 | 132 | .p.id = AV_CODEC_ID_H263I, |
| 133 | 133 | .priv_data_size = sizeof(MpegEncContext), |
| 134 | 134 | .init = ff_h263_decode_init, |
| 135 | − .close = ff_h263_decode_end, | |
| 136 | 135 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), |
| 136 | + .close = ff_mpv_decode_close, | |
| 137 | 137 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, |
| 138 | 138 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
| 139 | 139 | }; |
| @@ -2595,9 +2595,8 @@ static av_cold int mpeg_decode_end(AVCodecContext *avctx) · 2594 unmodified lines | ||
| 2595 | 2595 | { |
| 2596 | 2596 | Mpeg1Context *s = avctx->priv_data; |
| 2597 | 2597 | |
| 2598 | − ff_mpv_common_end(&s->mpeg_enc_ctx); | |
| 2599 | 2598 | av_buffer_unref(&s->a53_buf_ref); |
| 2600 | − return 0; | |
| 2599 | + return ff_mpv_decode_close(avctx); | |
| 2601 | 2600 | } |
| 2602 | 2601 | |
| 2603 | 2602 | const FFCodec ff_mpeg1video_decoder = { |
| @@ -3862,8 +3862,8 @@ const FFCodec ff_mpeg4_decoder = { · 3861 unmodified lines | ||
| 3862 | 3862 | .p.id = AV_CODEC_ID_MPEG4, |
| 3863 | 3863 | .priv_data_size = sizeof(Mpeg4DecContext), |
| 3864 | 3864 | .init = decode_init, |
| 3865 | − .close = ff_h263_decode_end, | |
| 3866 | 3865 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), |
| 3866 | + .close = ff_mpv_decode_close, | |
| 3867 | 3867 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | |
| 3868 | 3868 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS, |
| 3869 | 3869 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
| @@ -173,6 +173,14 @@ do {\ · 172 unmodified lines | ||
| 173 | 173 | return 0; |
| 174 | 174 | } |
| 175 | 175 | |
| 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 | + | |
| 176 | 184 | int ff_mpv_common_frame_size_change(MpegEncContext *s) |
| 177 | 185 | { |
| 178 | 186 | int err = 0; |
| @@ -63,6 +63,7 @@ int ff_mpv_export_qp_table(const MpegEncContext *s, AVFrame *f, · 62 unmodified lines | ||
| 63 | 63 | int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); |
| 64 | 64 | void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h); |
| 65 | 65 | void ff_mpeg_flush(AVCodecContext *avctx); |
| 66 | +int ff_mpv_decode_close(AVCodecContext *avctx); | |
| 66 | 67 | |
| 67 | 68 | void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict); |
| 68 | 69 | |
| @@ -28,6 +28,7 @@ · 27 unmodified lines | ||
| 28 | 28 | #include "codec_internal.h" |
| 29 | 29 | #include "mpegutils.h" |
| 30 | 30 | #include "mpegvideo.h" |
| 31 | +#include "mpegvideodec.h" | |
| 31 | 32 | #include "msmpeg4.h" |
| 32 | 33 | #include "msmpeg4dec.h" |
| 33 | 34 | #include "libavutil/imgutils.h" |
| @@ -848,8 +849,8 @@ const FFCodec ff_msmpeg4v1_decoder = { · 814 unmodified lines | ||
| 848 | 849 | .p.id = AV_CODEC_ID_MSMPEG4V1, |
| 849 | 850 | .priv_data_size = sizeof(MpegEncContext), |
| 850 | 851 | .init = ff_msmpeg4_decode_init, |
| 851 | − .close = ff_h263_decode_end, | |
| 852 | 852 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), |
| 853 | + .close = ff_mpv_decode_close, | |
| 853 | 854 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, |
| 854 | 855 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
| 855 | 856 | .p.max_lowres = 3, |
| @@ -862,8 +863,8 @@ const FFCodec ff_msmpeg4v2_decoder = { · 6 unmodified lines | ||
| 862 | 863 | .p.id = AV_CODEC_ID_MSMPEG4V2, |
| 863 | 864 | .priv_data_size = sizeof(MpegEncContext), |
| 864 | 865 | .init = ff_msmpeg4_decode_init, |
| 865 | − .close = ff_h263_decode_end, | |
| 866 | 866 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), |
| 867 | + .close = ff_mpv_decode_close, | |
| 867 | 868 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, |
| 868 | 869 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
| 869 | 870 | .p.max_lowres = 3, |
| @@ -876,8 +877,8 @@ const FFCodec ff_msmpeg4v3_decoder = { · 6 unmodified lines | ||
| 876 | 877 | .p.id = AV_CODEC_ID_MSMPEG4V3, |
| 877 | 878 | .priv_data_size = sizeof(MpegEncContext), |
| 878 | 879 | .init = ff_msmpeg4_decode_init, |
| 879 | − .close = ff_h263_decode_end, | |
| 880 | 880 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), |
| 881 | + .close = ff_mpv_decode_close, | |
| 881 | 882 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, |
| 882 | 883 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
| 883 | 884 | .p.max_lowres = 3, |
| @@ -890,8 +891,8 @@ const FFCodec ff_wmv1_decoder = { · 6 unmodified lines | ||
| 890 | 891 | .p.id = AV_CODEC_ID_WMV1, |
| 891 | 892 | .priv_data_size = sizeof(MpegEncContext), |
| 892 | 893 | .init = ff_msmpeg4_decode_init, |
| 893 | − .close = ff_h263_decode_end, | |
| 894 | 894 | FF_CODEC_DECODE_CB(ff_h263_decode_frame), |
| 895 | + .close = ff_mpv_decode_close, | |
| 895 | 896 | .p.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1, |
| 896 | 897 | .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM, |
| 897 | 898 | .p.max_lowres = 3, |
| @@ -416,14 +416,6 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx) · 415 unmodified lines | ||
| 416 | 416 | return 0; |
| 417 | 417 | } |
| 418 | 418 | |
| 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 | − | |
| 427 | 419 | static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, |
| 428 | 420 | int buf_size, int buf_size2, int whole_size) |
| 429 | 421 | { |
| @@ -666,8 +658,8 @@ const FFCodec ff_rv10_decoder = { · 236 unmodified lines | ||
| 666 | 658 | .p.id = AV_CODEC_ID_RV10, |
| 667 | 659 | .priv_data_size = sizeof(RVDecContext), |
| 668 | 660 | .init = rv10_decode_init, |
| 669 | − .close = rv10_decode_end, | |
| 670 | 661 | FF_CODEC_DECODE_CB(rv10_decode_frame), |
| 662 | + .close = ff_mpv_decode_close, | |
| 671 | 663 | .p.capabilities = AV_CODEC_CAP_DR1, |
| 672 | 664 | .p.max_lowres = 3, |
| 673 | 665 | }; |
| @@ -679,8 +671,8 @@ const FFCodec ff_rv20_decoder = { · 5 unmodified lines | ||
| 679 | 671 | .p.id = AV_CODEC_ID_RV20, |
| 680 | 672 | .priv_data_size = sizeof(RVDecContext), |
| 681 | 673 | .init = rv10_decode_init, |
| 682 | − .close = rv10_decode_end, | |
| 683 | 674 | FF_CODEC_DECODE_CB(rv10_decode_frame), |
| 675 | + .close = ff_mpv_decode_close, | |
| 684 | 676 | .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, |
| 685 | 677 | .flush = ff_mpeg_flush, |
| 686 | 678 | .p.max_lowres = 3, |
| @@ -302,6 +302,7 @@ const FFCodec ff_rv30_decoder = { · 301 unmodified lines | ||
| 302 | 302 | FF_CODEC_DECODE_CB(ff_rv34_decode_frame), |
| 303 | 303 | .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | |
| 304 | 304 | AV_CODEC_CAP_FRAME_THREADS, |
| 305 | + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, | |
| 305 | 306 | .flush = ff_mpeg_flush, |
| 306 | 307 | UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context), |
| 307 | 308 | }; |
| @@ -1522,10 +1522,9 @@ av_cold int ff_rv34_decode_init(AVCodecContext *avctx) · 1521 unmodified lines | ||
| 1522 | 1522 | |
| 1523 | 1523 | ff_h264_pred_init(&r->h, AV_CODEC_ID_RV40, 8, 1); |
| 1524 | 1524 | |
| 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) | |
| 1527 | 1527 | return ret; |
| 1528 | − } | |
| 1529 | 1528 | |
| 1530 | 1529 | ff_thread_once(&init_static_once, rv34_init_tables); |
| 1531 | 1530 | |
| @@ -1823,8 +1822,7 @@ av_cold int ff_rv34_decode_end(AVCodecContext *avctx) · 291 unmodified lines | ||
| 1823 | 1822 | { |
| 1824 | 1823 | RV34DecContext *r = avctx->priv_data; |
| 1825 | 1824 | |
| 1826 | − ff_mpv_common_end(&r->s); | |
| 1827 | 1825 | rv34_decoder_free(r); |
| 1828 | 1826 | |
| 1829 | − return 0; | |
| 1827 | + return ff_mpv_decode_close(avctx); | |
| 1830 | 1828 | } |
| @@ -580,6 +580,7 @@ const FFCodec ff_rv40_decoder = { · 579 unmodified lines | ||
| 580 | 580 | FF_CODEC_DECODE_CB(ff_rv34_decode_frame), |
| 581 | 581 | .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | |
| 582 | 582 | AV_CODEC_CAP_FRAME_THREADS, |
| 583 | + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, | |
| 583 | 584 | .flush = ff_mpeg_flush, |
| 584 | 585 | UPDATE_THREAD_CONTEXT(ff_rv34_decode_update_thread_context), |
| 585 | 586 | }; |
| @@ -449,6 +449,8 @@ static enum AVPixelFormat vc1_get_format(AVCodecContext *avctx) · 448 unmodified lines | ||
| 449 | 449 | return ff_get_format(avctx, vc1_hwaccel_pixfmt_list_420); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | +static void vc1_decode_reset(AVCodecContext *avctx); | |
| 453 | + | |
| 452 | 454 | av_cold int ff_vc1_decode_init(AVCodecContext *avctx) |
| 453 | 455 | { |
| 454 | 456 | VC1Context *const v = avctx->priv_data; |
| @@ -477,7 +479,7 @@ av_cold int ff_vc1_decode_init(AVCodecContext *avctx) · 22 unmodified lines | ||
| 477 | 479 | |
| 478 | 480 | ret = vc1_decode_init_alloc_tables(v); |
| 479 | 481 | if (ret < 0) { |
| 480 | − ff_vc1_decode_end(avctx); | |
| 482 | + vc1_decode_reset(avctx); | |
| 481 | 483 | return ret; |
| 482 | 484 | } |
| 483 | 485 | return 0; |
| @@ -774,10 +776,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 290 unmodified lines | ||
| 774 | 776 | return 0; |
| 775 | 777 | } |
| 776 | 778 | |
| 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) | |
| 781 | 780 | { |
| 782 | 781 | VC1Context *v = avctx->priv_data; |
| 783 | 782 | int i; |
| @@ -803,9 +802,16 @@ av_cold int ff_vc1_decode_end(AVCodecContext *avctx) · 19 unmodified lines | ||
| 803 | 802 | av_freep(&v->is_intra_base); // FIXME use v->mb_type[] |
| 804 | 803 | av_freep(&v->luma_mv_base); |
| 805 | 804 | ff_intrax8_common_end(&v->x8); |
| 806 | − return 0; | |
| 807 | 805 | } |
| 808 | 806 | |
| 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 | +} | |
| 809 | 815 | |
| 810 | 816 | /** Decode a VC1/WMV3 frame |
| 811 | 817 | * @todo TODO: Handle VC-1 IDUs (Transport level?) |
| @@ -27,6 +27,7 @@ · 26 unmodified lines | ||
| 27 | 27 | #include "mathops.h" |
| 28 | 28 | #include "mpegutils.h" |
| 29 | 29 | #include "mpegvideo.h" |
| 30 | +#include "mpegvideodec.h" | |
| 30 | 31 | #include "msmpeg4.h" |
| 31 | 32 | #include "msmpeg4_vc1_data.h" |
| 32 | 33 | #include "msmpeg4dec.h" |
| @@ -584,7 +585,7 @@ static av_cold int wmv2_decode_end(AVCodecContext *avctx) · 551 unmodified lines | ||
| 584 | 585 | WMV2DecContext *const w = avctx->priv_data; |
| 585 | 586 | |
| 586 | 587 | ff_intrax8_common_end(&w->x8); |
| 587 | − return ff_h263_decode_end(avctx); | |
| 588 | + return ff_mpv_decode_close(avctx); | |
| 588 | 589 | } |
| 589 | 590 | |
| 590 | 591 | const FFCodec ff_wmv2_decoder = { |