History

avcodec/mpegvideo: Move allocating new_picture to the encoder

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.

Andreas Rheinhardt committed 3 years ago

Commit 4c422de1 parent 27fcc8d3 files · +7 −7Browse files

Unified · Split

3 files
  1. libavcodec/mpegvideo.c +1 −4
  2. libavcodec/mpegvideo_enc.c +2 −1
  3. libavcodec/svq1enc.c +4 −2
libavcodec/mpegvideo.c+1−4
@@ -632,7 +632,6 @@ static void clear_context(MpegEncContext *s) · 631 unmodified lines
632632 memset(&s->next_picture, 0, sizeof(s->next_picture));
633633 memset(&s->last_picture, 0, sizeof(s->last_picture));
634634 memset(&s->current_picture, 0, sizeof(s->current_picture));
635− memset(&s->new_picture, 0, sizeof(s->new_picture));
636635
637636 memset(s->thread_context, 0, sizeof(s->thread_context));
638637
@@ -720,8 +719,7 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) · 81 unmodified lines
720719
721720 if (!(s->next_picture.f = av_frame_alloc()) ||
722721 !(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()))
725723 goto fail_nomem;
726724
727725 if ((ret = ff_mpv_init_context_frame(s)))
@@ -801,7 +799,6 @@ void ff_mpv_common_end(MpegEncContext *s) · 73 unmodified lines
801799 ff_mpv_picture_free(s->avctx, &s->last_picture);
802800 ff_mpv_picture_free(s->avctx, &s->current_picture);
803801 ff_mpv_picture_free(s->avctx, &s->next_picture);
804− av_frame_free(&s->new_picture);
805802
806803 s->context_initialized = 0;
807804 s->context_reinit = 0;
libavcodec/mpegvideo_enc.c+2−1
@@ -821,7 +821,8 @@ av_cold int ff_mpv_encode_init(AVCodecContext *avctx) · 820 unmodified lines
821821 !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) ||
822822 !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16, 32) ||
823823 !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()))
825826 return AVERROR(ENOMEM);
826827
827828 /* Allocate MV tables; the MV and MB tables will be copied
libavcodec/svq1enc.c+4−2
@@ -570,6 +570,7 @@ static av_cold int svq1_encode_end(AVCodecContext *avctx) · 569 unmodified lines
570570
571571 av_frame_free(&s->current_picture);
572572 av_frame_free(&s->last_picture);
573+ av_frame_free(&s->m.new_picture);
573574
574575 return 0;
575576 }
@@ -632,10 +633,11 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) · 56 unmodified lines
632633 s->dummy = av_mallocz((s->y_block_width + 1) *
633634 s->y_block_height * sizeof(int32_t));
634635 s->m.me.map = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->m.me.map));
636+ s->m.new_picture = av_frame_alloc();
635637 s->svq1encdsp.ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
636638
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)
639641 return AVERROR(ENOMEM);
640642 s->m.me.score_map = s->m.me.map + ME_MAP_SIZE;
641643

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