aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-12-06 02:12:11 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-12-06 02:12:59 +0100
commit20b28fc7b0aaa41c1837bf234e599d1714bc4d35 (patch)
tree7374533b7fffbacf2225c62569e82047273612ca
parent2951b7fb1d3be236312e27a6dd6dc1dcfc467841 (diff)
parent1f8eb69079880ef1f394c498dfdf471f91222a06 (diff)
downloadffmpeg-20b28fc7b0aaa41c1837bf234e599d1714bc4d35.tar.gz
Merge commit '1f8eb69079880ef1f394c498dfdf471f91222a06'
* commit '1f8eb69079880ef1f394c498dfdf471f91222a06': mpegvideo: move encoding-only initialization from common_init() to encode_init() Conflicts: libavcodec/mpegvideo.c libavcodec/mpegvideo_enc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/mpegvideo.c24
-rw-r--r--libavcodec/mpegvideo_enc.c28
2 files changed, 28 insertions, 24 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 85e8feb9d1..cef335f601 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1048,30 +1048,6 @@ av_cold int ff_MPV_common_init(MpegEncContext *s)
s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag);
- s->avctx->coded_frame = &s->current_picture.f;
-
- if (s->encoding) {
- if (s->msmpeg4_version) {
- FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
- 2 * 2 * (MAX_LEVEL + 1) *
- (MAX_RUN + 1) * 2 * sizeof(int), fail);
- }
- FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
-
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix, 64 * 32 * sizeof(int), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix, 64 * 32 * sizeof(int), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix, 64 * 32 * sizeof(int), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture *), fail)
- FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture *), fail)
-
- if (s->avctx->noise_reduction) {
- FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail);
- }
- }
-
FF_ALLOCZ_OR_GOTO(s->avctx, s->picture,
MAX_PICTURE_COUNT * sizeof(Picture), fail);
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 1f235fc64c..ff44268f4a 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -837,6 +837,31 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
if (ff_MPV_common_init(s) < 0)
return -1;
+ s->avctx->coded_frame = &s->current_picture.f;
+
+ if (s->msmpeg4_version) {
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats,
+ 2 * 2 * (MAX_LEVEL + 1) *
+ (MAX_RUN + 1) * 2 * sizeof(int), fail);
+ }
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail);
+
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix, 64 * 32 * sizeof(int), fail);
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix, 64 * 32 * sizeof(int), fail);
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix, 64 * 32 * sizeof(int), fail);
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_chroma_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail);
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture,
+ MAX_PICTURE_COUNT * sizeof(Picture *), fail);
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture,
+ MAX_PICTURE_COUNT * sizeof(Picture *), fail);
+
+ if (s->avctx->noise_reduction) {
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset,
+ 2 * 64 * sizeof(uint16_t), fail);
+ }
+
ff_dct_encode_init(s);
if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant)
@@ -916,6 +941,9 @@ av_cold int ff_MPV_encode_init(AVCodecContext *avctx)
}
return 0;
+fail:
+ ff_MPV_encode_end(avctx);
+ return AVERROR_UNKNOWN;
}
av_cold int ff_MPV_encode_end(AVCodecContext *avctx)