It is only used by encoders; this unfortunately necessitated to add separate allocations to the SVQ1 encoder which uses motion estimation without being a full member of mpegvideo.
Showing the changes to libavcodec (3 of 3 files). Show all
Unified · Split
| @@ -632,7 +632,6 @@ static void clear_context(MpegEncContext *s) · 631 unmodified lines | ||
| 632 | 632 | memset(&s->next_picture, 0, sizeof(s->next_picture)); |
| 633 | 633 | memset(&s->last_picture, 0, sizeof(s->last_picture)); |
| 634 | 634 | memset(&s->current_picture, 0, sizeof(s->current_picture)); |
| 635 | − memset(&s->new_picture, 0, sizeof(s->new_picture)); | |
| 636 | 635 | |
| 637 | 636 | memset(s->thread_context, 0, sizeof(s->thread_context)); |
| 638 | 637 | |
| @@ -720,8 +719,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) · 81 unmodified lines | ||
| 720 | 719 | |
| 721 | 720 | if (!(s->next_picture.f = av_frame_alloc()) || |
| 722 | 721 | !(s->last_picture.f = av_frame_alloc()) || |
| 723 | − !(s->current_picture.f = av_frame_alloc()) || | |
| 724 | − !(s->new_picture = av_frame_alloc())) | |
| 722 | + !(s->current_picture.f = av_frame_alloc())) | |
| 725 | 723 | goto fail_nomem; |
| 726 | 724 | |
| 727 | 725 | if ((ret = ff_mpv_init_context_frame(s))) |
| @@ -801,7 +799,6 @@ void ff_mpv_common_end(MpegEncContext *s) · 73 unmodified lines | ||
| 801 | 799 | ff_mpv_picture_free(s->avctx, &s->last_picture); |
| 802 | 800 | ff_mpv_picture_free(s->avctx, &s->current_picture); |
| 803 | 801 | ff_mpv_picture_free(s->avctx, &s->next_picture); |
| 804 | − av_frame_free(&s->new_picture); | |
| 805 | 802 | |
| 806 | 803 | s->context_initialized = 0; |
| 807 | 804 | s->context_reinit = 0; |
| @@ -821,7 +821,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 820 unmodified lines | ||
| 821 | 821 | !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) || |
| 822 | 822 | !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16, 32) || |
| 823 | 823 | !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_PICTURE_COUNT) || |
| 824 | − !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT)) | |
| 824 | + !FF_ALLOCZ_TYPED_ARRAY(s->reordered_input_picture, MAX_PICTURE_COUNT) || | |
| 825 | + !(s->new_picture = av_frame_alloc())) | |
| 825 | 826 | return AVERROR(ENOMEM); |
| 826 | 827 | |
| 827 | 828 | /* Allocate MV tables; the MV and MB tables will be copied |
| @@ -570,6 +570,7 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) · 569 unmodified lines | ||
| 570 | 570 | |
| 571 | 571 | av_frame_free(&s->current_picture); |
| 572 | 572 | av_frame_free(&s->last_picture); |
| 573 | + av_frame_free(&s->m.new_picture); | |
| 573 | 574 | |
| 574 | 575 | return 0; |
| 575 | 576 | } |
| @@ -632,10 +633,11 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) · 56 unmodified lines | ||
| 632 | 633 | s->dummy = av_mallocz((s->y_block_width + 1) * |
| 633 | 634 | s->y_block_height * sizeof(int32_t)); |
| 634 | 635 | s->m.me.map = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->m.me.map)); |
| 636 | + s->m.new_picture = av_frame_alloc(); | |
| 635 | 637 | s->svq1encdsp.ssd_int8_vs_int16 = ssd_int8_vs_int16_c; |
| 636 | 638 | |
| 637 | − if (!s->m.me.temp || !s->m.me.scratchpad || !s->m.me.map || | |
| 638 | − !s->mb_type || !s->dummy) | |
| 639 | + if (!s->m.me.scratchpad || !s->m.me.map || | |
| 640 | + !s->mb_type || !s->dummy || !s->m.new_picture) | |
| 639 | 641 | return AVERROR(ENOMEM); |
| 640 | 642 | s->m.me.score_map = s->m.me.map + ME_MAP_SIZE; |
| 641 | 643 | |