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

Showing the changes to libavcodec (3 of 3 files). Show all

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
632 memset(&s->next_picture, 0, sizeof(s->next_picture));632 memset(&s->next_picture, 0, sizeof(s->next_picture));
633 memset(&s->last_picture, 0, sizeof(s->last_picture));633 memset(&s->last_picture, 0, sizeof(s->last_picture));
634 memset(&s->current_picture, 0, sizeof(s->current_picture));634 memset(&s->current_picture, 0, sizeof(s->current_picture));
635 memset(&s->new_picture, 0, sizeof(s->new_picture));
636 635
637 memset(s->thread_context, 0, sizeof(s->thread_context));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 if (!(s->next_picture.f = av_frame_alloc()) ||720 if (!(s->next_picture.f = av_frame_alloc()) ||
722 !(s->last_picture.f = av_frame_alloc()) ||721 !(s->last_picture.f = av_frame_alloc()) ||
723 !(s->current_picture.f = av_frame_alloc()) ||722 !(s->current_picture.f = av_frame_alloc()))
724 !(s->new_picture = av_frame_alloc()))
725 goto fail_nomem;723 goto fail_nomem;
726 724
727 if ((ret = ff_mpv_init_context_frame(s)))725 if ((ret = ff_mpv_init_context_frame(s)))
@@ -801,7 +799,6 @@ void ff_mpv_common_end(MpegEncContext *s) · 73 unmodified lines
801 ff_mpv_picture_free(s->avctx, &s->last_picture);799 ff_mpv_picture_free(s->avctx, &s->last_picture);
802 ff_mpv_picture_free(s->avctx, &s->current_picture);800 ff_mpv_picture_free(s->avctx, &s->current_picture);
803 ff_mpv_picture_free(s->avctx, &s->next_picture);801 ff_mpv_picture_free(s->avctx, &s->next_picture);
804 av_frame_free(&s->new_picture);
805 802
806 s->context_initialized = 0;803 s->context_initialized = 0;
807 s->context_reinit = 0;804 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
821 !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) ||821 !FF_ALLOCZ_TYPED_ARRAY(s->q_chroma_intra_matrix16, 32) ||
822 !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16, 32) ||822 !FF_ALLOCZ_TYPED_ARRAY(s->q_inter_matrix16, 32) ||
823 !FF_ALLOCZ_TYPED_ARRAY(s->input_picture, MAX_PICTURE_COUNT) ||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 return AVERROR(ENOMEM);826 return AVERROR(ENOMEM);
826 827
827 /* Allocate MV tables; the MV and MB tables will be copied828 /* 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
570 570
571 av_frame_free(&s->current_picture);571 av_frame_free(&s->current_picture);
572 av_frame_free(&s->last_picture);572 av_frame_free(&s->last_picture);
573 av_frame_free(&s->m.new_picture);
573 574
574 return 0;575 return 0;
575}576}
@@ -632,10 +633,11 @@ static av_cold int svq1_encode_init(AVCodecContext *avctx) · 56 unmodified lines
632 s->dummy = av_mallocz((s->y_block_width + 1) *633 s->dummy = av_mallocz((s->y_block_width + 1) *
633 s->y_block_height * sizeof(int32_t));634 s->y_block_height * sizeof(int32_t));
634 s->m.me.map = av_mallocz(2 * ME_MAP_SIZE * sizeof(*s->m.me.map));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 s->svq1encdsp.ssd_int8_vs_int16 = ssd_int8_vs_int16_c;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 ||639 if (!s->m.me.scratchpad || !s->m.me.map ||
638 !s->mb_type || !s->dummy)640 !s->mb_type || !s->dummy || !s->m.new_picture)
639 return AVERROR(ENOMEM);641 return AVERROR(ENOMEM);
640 s->m.me.score_map = s->m.me.map + ME_MAP_SIZE;642 s->m.me.score_map = s->m.me.map + ME_MAP_SIZE;
641 643

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