diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-12-06 03:04:32 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-12-06 03:12:10 +0100 |
commit | 08667c26780dcdf2ef9ce410b2c78931a1e94e83 (patch) | |
tree | fe3224f5d4fcd36b3afc3d843e90d2d5aa62761a | |
parent | e3b7f0e184a0f21ef7e5c78e180fef258f9c73aa (diff) | |
parent | 0b0a7a751de02464a33717e70352f696372ba1c4 (diff) | |
download | ffmpeg-08667c26780dcdf2ef9ce410b2c78931a1e94e83.tar.gz |
Merge commit '0b0a7a751de02464a33717e70352f696372ba1c4'
* commit '0b0a7a751de02464a33717e70352f696372ba1c4':
mpegvideo: move encode-only parts of common_end() to encode_end()
Conflicts:
libavcodec/mpegvideo.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/mpegvideo.c | 37 | ||||
-rw-r--r-- | libavcodec/mpegvideo.h | 1 | ||||
-rw-r--r-- | libavcodec/mpegvideo_enc.c | 18 |
3 files changed, 29 insertions, 27 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 726a943f11..97bb0dc392 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -285,7 +285,7 @@ static int alloc_frame_buffer(MpegEncContext *s, Picture *pic) return 0; } -static void free_picture_tables(Picture *pic) +void ff_free_picture_tables(Picture *pic) { int i; @@ -382,7 +382,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) if (pic->qscale_table_buf) if ( pic->alloc_mb_width != s->mb_width || pic->alloc_mb_height != s->mb_height) - free_picture_tables(pic); + ff_free_picture_tables(pic); if (shared) { av_assert0(pic->f.data[0]); @@ -425,7 +425,7 @@ int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared) fail: av_log(s->avctx, AV_LOG_ERROR, "Error allocating a picture.\n"); ff_mpeg_unref_picture(s, pic); - free_picture_tables(pic); + ff_free_picture_tables(pic); return AVERROR(ENOMEM); } @@ -449,7 +449,7 @@ void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic) av_buffer_unref(&pic->hwaccel_priv_buf); if (pic->needs_realloc) - free_picture_tables(pic); + ff_free_picture_tables(pic); memset((uint8_t*)pic + off, 0, sizeof(*pic) - off); } @@ -465,7 +465,7 @@ do {\ av_buffer_unref(&dst->table);\ dst->table = av_buffer_ref(src->table);\ if (!dst->table) {\ - free_picture_tables(dst);\ + ff_free_picture_tables(dst);\ return AVERROR(ENOMEM);\ }\ }\ @@ -1244,36 +1244,19 @@ void ff_MPV_common_end(MpegEncContext *s) av_freep(&s->bitstream_buffer); s->allocated_bitstream_buffer_size = 0; - av_freep(&s->avctx->stats_out); - av_freep(&s->ac_stats); - - if(s->q_chroma_intra_matrix != s->q_intra_matrix ) av_freep(&s->q_chroma_intra_matrix); - if(s->q_chroma_intra_matrix16 != s->q_intra_matrix16) av_freep(&s->q_chroma_intra_matrix16); - s->q_chroma_intra_matrix= NULL; - s->q_chroma_intra_matrix16= NULL; - av_freep(&s->q_intra_matrix); - av_freep(&s->q_inter_matrix); - av_freep(&s->q_intra_matrix16); - av_freep(&s->q_inter_matrix16); - av_freep(&s->input_picture); - av_freep(&s->reordered_input_picture); - av_freep(&s->dct_offset); - if (s->picture) { for (i = 0; i < MAX_PICTURE_COUNT; i++) { - free_picture_tables(&s->picture[i]); + ff_free_picture_tables(&s->picture[i]); ff_mpeg_unref_picture(s, &s->picture[i]); } } av_freep(&s->picture); - free_picture_tables(&s->last_picture); + ff_free_picture_tables(&s->last_picture); ff_mpeg_unref_picture(s, &s->last_picture); - free_picture_tables(&s->current_picture); + ff_free_picture_tables(&s->current_picture); ff_mpeg_unref_picture(s, &s->current_picture); - free_picture_tables(&s->next_picture); + ff_free_picture_tables(&s->next_picture); ff_mpeg_unref_picture(s, &s->next_picture); - free_picture_tables(&s->new_picture); - ff_mpeg_unref_picture(s, &s->new_picture); free_context_frame(s); @@ -1440,7 +1423,7 @@ int ff_find_unused_picture(MpegEncContext *s, int shared) if (ret >= 0 && ret < MAX_PICTURE_COUNT) { if (s->picture[ret].needs_realloc) { s->picture[ret].needs_realloc = 0; - free_picture_tables(&s->picture[ret]); + ff_free_picture_tables(&s->picture[ret]); ff_mpeg_unref_picture(s, &s->picture[ret]); avcodec_get_frame_defaults(&s->picture[ret].f); } diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 14f0a09cd8..030ba837da 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -957,6 +957,7 @@ void ff_wmv2_encode_mb(MpegEncContext * s, int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src); void ff_mpeg_unref_picture(MpegEncContext *s, Picture *picture); +void ff_free_picture_tables(Picture *pic); #endif /* AVCODEC_MPEGVIDEO_H */ diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 4806db1d14..9e0193a02a 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -963,6 +963,24 @@ av_cold int ff_MPV_encode_end(AVCodecContext *avctx) for (i = 0; i < FF_ARRAY_ELEMS(s->tmp_frames); i++) av_frame_free(&s->tmp_frames[i]); + ff_free_picture_tables(&s->new_picture); + ff_mpeg_unref_picture(s, &s->new_picture); + + av_freep(&s->avctx->stats_out); + av_freep(&s->ac_stats); + + if(s->q_chroma_intra_matrix != s->q_intra_matrix ) av_freep(&s->q_chroma_intra_matrix); + if(s->q_chroma_intra_matrix16 != s->q_intra_matrix16) av_freep(&s->q_chroma_intra_matrix16); + s->q_chroma_intra_matrix= NULL; + s->q_chroma_intra_matrix16= NULL; + av_freep(&s->q_intra_matrix); + av_freep(&s->q_inter_matrix); + av_freep(&s->q_intra_matrix16); + av_freep(&s->q_inter_matrix16); + av_freep(&s->input_picture); + av_freep(&s->reordered_input_picture); + av_freep(&s->dct_offset); + return 0; } |