diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-06 21:16:10 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-06 22:47:50 +0200 |
commit | f30a7d9861af884f352ec2484820a75d79a4e0e2 (patch) | |
tree | 2df5dc1edfa6c57b31b25c31fe5f1f08e2c0b11b /libavcodec/mpegvideo.c | |
parent | 7e4661174ae11f95cb3527a9f58f1a71d297359c (diff) | |
download | ffmpeg-f30a7d9861af884f352ec2484820a75d79a4e0e2.tar.gz |
avcodec/mpegvideo: Merge thread context initialization loops
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r-- | libavcodec/mpegvideo.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 57d9620062..6b5463198e 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1287,12 +1287,11 @@ av_cold int ff_mpv_common_init(MpegEncContext *s) // if (s->width && s->height) { if (nb_slices > 1) { - for (i = 1; i < nb_slices; i++) { - s->thread_context[i] = av_malloc(sizeof(MpegEncContext)); - memcpy(s->thread_context[i], s, sizeof(MpegEncContext)); - } - for (i = 0; i < nb_slices; i++) { + if (i) { + s->thread_context[i] = av_malloc(sizeof(MpegEncContext)); + memcpy(s->thread_context[i], s, sizeof(MpegEncContext)); + } if (init_duplicate_context(s->thread_context[i]) < 0) goto fail; s->thread_context[i]->start_mb_y = @@ -1415,12 +1414,11 @@ int ff_mpv_common_frame_size_change(MpegEncContext *s) if (s->width && s->height) { int nb_slices = s->slice_context_count; if (nb_slices > 1) { - for (i = 1; i < nb_slices; i++) { - s->thread_context[i] = av_malloc(sizeof(MpegEncContext)); - memcpy(s->thread_context[i], s, sizeof(MpegEncContext)); - } - for (i = 0; i < nb_slices; i++) { + if (i) { + s->thread_context[i] = av_malloc(sizeof(MpegEncContext)); + memcpy(s->thread_context[i], s, sizeof(MpegEncContext)); + } if ((err = init_duplicate_context(s->thread_context[i])) < 0) goto fail; s->thread_context[i]->start_mb_y = |