Skip to content

Commit 4b2863f

Browse files
committed
avcodec: add FF_CODEC_CAP_INIT_CLEANUP for all codecs which use ff_mpv_common_init()
Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
1 parent 42a3850 commit 4b2863f

File tree

10 files changed

+20
-18
lines changed

10 files changed

+20
-18
lines changed

libavcodec/h261dec.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,5 +686,6 @@ AVCodec ff_h261_decoder = {
686686
.close = h261_decode_end,
687687
.decode = h261_decode_frame,
688688
.capabilities = AV_CODEC_CAP_DR1,
689+
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
689690
.max_lowres = 3,
690691
};

libavcodec/h263dec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ AVCodec ff_h263_decoder = {
770770
.decode = ff_h263_decode_frame,
771771
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
772772
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY,
773-
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
773+
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
774774
.flush = ff_mpeg_flush,
775775
.max_lowres = 3,
776776
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,
@@ -788,7 +788,7 @@ AVCodec ff_h263p_decoder = {
788788
.decode = ff_h263_decode_frame,
789789
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
790790
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY,
791-
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
791+
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
792792
.flush = ff_mpeg_flush,
793793
.max_lowres = 3,
794794
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,

libavcodec/mpeg12dec.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,8 +2873,7 @@ static av_cold int mpeg_decode_end(AVCodecContext *avctx)
28732873
{
28742874
Mpeg1Context *s = avctx->priv_data;
28752875

2876-
if (s->mpeg_enc_ctx_allocated)
2877-
ff_mpv_common_end(&s->mpeg_enc_ctx);
2876+
ff_mpv_common_end(&s->mpeg_enc_ctx);
28782877
av_freep(&s->a53_caption);
28792878
return 0;
28802879
}
@@ -2891,7 +2890,7 @@ AVCodec ff_mpeg1video_decoder = {
28912890
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
28922891
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
28932892
AV_CODEC_CAP_SLICE_THREADS,
2894-
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
2893+
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
28952894
.flush = flush,
28962895
.max_lowres = 3,
28972896
.update_thread_context = ONLY_IF_THREADS_ENABLED(mpeg_decode_update_thread_context),
@@ -2924,7 +2923,7 @@ AVCodec ff_mpeg2video_decoder = {
29242923
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 |
29252924
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
29262925
AV_CODEC_CAP_SLICE_THREADS,
2927-
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
2926+
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
29282927
.flush = flush,
29292928
.max_lowres = 3,
29302929
.profiles = NULL_IF_CONFIG_SMALL(ff_mpeg2_video_profiles),
@@ -2968,7 +2967,7 @@ AVCodec ff_mpegvideo_decoder = {
29682967
.close = mpeg_decode_end,
29692968
.decode = mpeg_decode_frame,
29702969
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1 | AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
2971-
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
2970+
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
29722971
.flush = flush,
29732972
.max_lowres = 3,
29742973
};

libavcodec/mpeg4videodec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3594,7 +3594,8 @@ AVCodec ff_mpeg4_decoder = {
35943594
AV_CODEC_CAP_TRUNCATED | AV_CODEC_CAP_DELAY |
35953595
AV_CODEC_CAP_FRAME_THREADS,
35963596
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM |
3597-
FF_CODEC_CAP_ALLOCATE_PROGRESS,
3597+
FF_CODEC_CAP_ALLOCATE_PROGRESS |
3598+
FF_CODEC_CAP_INIT_CLEANUP,
35983599
.flush = ff_mpeg_flush,
35993600
.max_lowres = 3,
36003601
.pix_fmts = ff_h263_hwaccel_pixfmt_list_420,

libavcodec/mpegpicture.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ int ff_mpeg_framesize_alloc(AVCodecContext *avctx, MotionEstContext *me,
9090

9191
return 0;
9292
fail:
93-
av_freep(&sc->edge_emu_buffer);
9493
return AVERROR(ENOMEM);
9594
}
9695

libavcodec/mpegvideo.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,6 @@ av_cold int ff_mpv_common_init(MpegEncContext *s)
991991
fail_nomem:
992992
ret = AVERROR(ENOMEM);
993993
fail:
994-
ff_mpv_common_end(s);
995994
return ret;
996995
}
997996

@@ -1123,7 +1122,6 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s)
11231122

11241123
return 0;
11251124
fail:
1126-
ff_mpv_common_end(s);
11271125
return err;
11281126
}
11291127

@@ -1151,6 +1149,9 @@ void ff_mpv_common_end(MpegEncContext *s)
11511149
av_freep(&s->bitstream_buffer);
11521150
s->allocated_bitstream_buffer_size = 0;
11531151

1152+
if (!s->avctx)
1153+
return;
1154+
11541155
if (s->picture) {
11551156
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
11561157
ff_free_picture_tables(&s->picture[i]);

libavcodec/msmpeg4dec.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ AVCodec ff_msmpeg4v1_decoder = {
888888
.close = ff_h263_decode_end,
889889
.decode = ff_h263_decode_frame,
890890
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
891-
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
891+
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
892892
.max_lowres = 3,
893893
.pix_fmts = (const enum AVPixelFormat[]) {
894894
AV_PIX_FMT_YUV420P,
@@ -906,7 +906,7 @@ AVCodec ff_msmpeg4v2_decoder = {
906906
.close = ff_h263_decode_end,
907907
.decode = ff_h263_decode_frame,
908908
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
909-
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
909+
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
910910
.max_lowres = 3,
911911
.pix_fmts = (const enum AVPixelFormat[]) {
912912
AV_PIX_FMT_YUV420P,
@@ -924,7 +924,7 @@ AVCodec ff_msmpeg4v3_decoder = {
924924
.close = ff_h263_decode_end,
925925
.decode = ff_h263_decode_frame,
926926
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
927-
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
927+
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
928928
.max_lowres = 3,
929929
.pix_fmts = (const enum AVPixelFormat[]) {
930930
AV_PIX_FMT_YUV420P,
@@ -942,7 +942,7 @@ AVCodec ff_wmv1_decoder = {
942942
.close = ff_h263_decode_end,
943943
.decode = ff_h263_decode_frame,
944944
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
945-
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
945+
.caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_INIT_CLEANUP,
946946
.max_lowres = 3,
947947
.pix_fmts = (const enum AVPixelFormat[]) {
948948
AV_PIX_FMT_YUV420P,

libavcodec/rv10.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ AVCodec ff_rv10_decoder = {
801801
.close = rv10_decode_end,
802802
.decode = rv10_decode_frame,
803803
.capabilities = AV_CODEC_CAP_DR1,
804+
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
804805
.max_lowres = 3,
805806
.pix_fmts = (const enum AVPixelFormat[]) {
806807
AV_PIX_FMT_YUV420P,
@@ -818,6 +819,7 @@ AVCodec ff_rv20_decoder = {
818819
.close = rv10_decode_end,
819820
.decode = rv10_decode_frame,
820821
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY,
822+
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
821823
.flush = ff_mpeg_flush,
822824
.max_lowres = 3,
823825
.pix_fmts = (const enum AVPixelFormat[]) {

libavcodec/svq1enc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
529529
s->current_picture = av_frame_alloc();
530530
s->last_picture = av_frame_alloc();
531531
if (!s->current_picture || !s->last_picture) {
532-
svq1_encode_end(avctx);
533532
return AVERROR(ENOMEM);
534533
}
535534

@@ -546,7 +545,6 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
546545
s->m.avctx = avctx;
547546

548547
if ((ret = ff_mpv_common_init(&s->m)) < 0) {
549-
svq1_encode_end(avctx);
550548
return ret;
551549
}
552550

@@ -564,7 +562,6 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx)
564562

565563
if (!s->m.me.temp || !s->m.me.scratchpad || !s->m.me.map ||
566564
!s->m.me.score_map || !s->mb_type || !s->dummy) {
567-
svq1_encode_end(avctx);
568565
return AVERROR(ENOMEM);
569566
}
570567

@@ -692,6 +689,7 @@ AVCodec ff_svq1_encoder = {
692689
.init = svq1_encode_init,
693690
.encode2 = svq1_encode_frame,
694691
.close = svq1_encode_end,
692+
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
695693
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV410P,
696694
AV_PIX_FMT_NONE },
697695
};

libavcodec/wmv2dec.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ AVCodec ff_wmv2_decoder = {
537537
.close = wmv2_decode_end,
538538
.decode = ff_h263_decode_frame,
539539
.capabilities = AV_CODEC_CAP_DRAW_HORIZ_BAND | AV_CODEC_CAP_DR1,
540+
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
540541
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
541542
AV_PIX_FMT_NONE },
542543
};

0 commit comments

Comments
 (0)