aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pthread.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-21 23:11:27 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-01-21 23:11:27 +0100
commitb5a69e79c579e6e15e2019ffd34ef0e09aeab586 (patch)
treebc6b0aa0776ca51a9b8a4800a7f464866221821f /libavcodec/pthread.c
parent9e53f62be1a171eaf9620958c225d42cf5142a30 (diff)
parentad7beb2cac1563e87171a4d044a6d526527d81d9 (diff)
downloadffmpeg-b5a69e79c579e6e15e2019ffd34ef0e09aeab586.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: rtpdec: Use our own SSRC in the SDES field when sending RRs Finalize changelog for 0.8 Release Prepare for 0.8 Release threads: change the default for threads back to 1 threads: update slice_count and slice_offset from user context aviocat: Remove useless includes doc/APIChanges: fill in missing dates and hashes Revert "avserver: fix build after the next bump." mpegaudiodec: switch error detection check to AV_EF_BUFFER lavf: rename fer option and document resulting (f_)err_detect options lavc: rename err_filter option to err_detect and document it mpegvideo: fix invalid memory access for small video dimensions movenc: Reorder entries in the MOVIentry struct, for tigheter packing rtsp: Remove extern declarations for variables that don't exist aviocat: Flush the output before closing Conflicts: Changelog RELEASE libavcodec/mpegaudiodec.c libavcodec/pthread.c libavformat/options.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pthread.c')
-rw-r--r--libavcodec/pthread.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index fe3dbdad5a..e0921e4e06 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -420,7 +420,6 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
dst->has_b_frames = src->has_b_frames;
dst->idct_algo = src->idct_algo;
- dst->slice_count = src->slice_count;
dst->bits_per_coded_sample = src->bits_per_coded_sample;
dst->sample_aspect_ratio = src->sample_aspect_ratio;
@@ -455,8 +454,9 @@ static int update_context_from_thread(AVCodecContext *dst, AVCodecContext *src,
*
* @param dst The destination context.
* @param src The source context.
+ * @return 0 on success, negative error code on failure
*/
-static void update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
+static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
{
#define copy_fields(s, e) memcpy(&dst->s, &src->s, (char*)&dst->e - (char*)&dst->s);
dst->flags = src->flags;
@@ -478,6 +478,22 @@ static void update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
dst->frame_number = src->frame_number;
dst->reordered_opaque = src->reordered_opaque;
dst->thread_safe_callbacks = src->thread_safe_callbacks;
+
+ if (src->slice_count && src->slice_offset) {
+ if (dst->slice_count < src->slice_count) {
+ int *tmp = av_realloc(dst->slice_offset, src->slice_count *
+ sizeof(*dst->slice_offset));
+ if (!tmp) {
+ av_free(dst->slice_offset);
+ return AVERROR(ENOMEM);
+ }
+ dst->slice_offset = tmp;
+ }
+ memcpy(dst->slice_offset, src->slice_offset,
+ src->slice_count * sizeof(*dst->slice_offset));
+ }
+ dst->slice_count = src->slice_count;
+ return 0;
#undef copy_fields
}
@@ -588,7 +604,8 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
*/
p = &fctx->threads[fctx->next_decoding];
- update_context_from_user(p->avctx, avctx);
+ err = update_context_from_user(p->avctx, avctx);
+ if (err) return err;
err = submit_packet(p, avpkt);
if (err) return err;
@@ -764,6 +781,7 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count)
if (i) {
av_freep(&p->avctx->priv_data);
av_freep(&p->avctx->internal);
+ av_freep(&p->avctx->slice_offset);
}
av_freep(&p->avctx);