aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-05-25 14:35:35 +0200
committerCarl Eugen Hoyos <cehoyos@ag.or.at>2015-06-19 10:55:06 +0200
commit678a189e5dd0cc409894b71d8d21d7875b5fa315 (patch)
treed0ef350b3bc7801db6bcd8d8113d00dd9d36f535
parente2054a8b55eed7e22600008466559c575018c63e (diff)
downloadffmpeg-678a189e5dd0cc409894b71d8d21d7875b5fa315.tar.gz
avcodec/mjpegenc_common: Use ff_mpv_reallocate_putbitbuffer()
Fixes assertion failure Fixes Ticket4396 Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit c50904fd7899e37516324e711b3b8edfe7214da8)
-rw-r--r--libavcodec/mjpegenc_common.c12
-rw-r--r--libavcodec/mjpegenc_common.h2
2 files changed, 12 insertions, 2 deletions
diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 8a5b99f227..8ff37288a7 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -337,20 +337,30 @@ void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
}
}
-void ff_mjpeg_encode_stuffing(MpegEncContext *s)
+int ff_mjpeg_encode_stuffing(MpegEncContext *s)
{
int i;
PutBitContext *pbc = &s->pb;
int mb_y = s->mb_y - !s->mb_x;
+ int ret = ff_mpv_reallocate_putbitbuffer(s, put_bits_count(&s->pb) / 8 + 100,
+ put_bits_count(&s->pb) / 4 + 1000);
+ if (ret < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "Buffer reallocation failed\n");
+ goto fail;
+ }
+
ff_mjpeg_escape_FF(pbc, s->esc_pos);
if((s->avctx->active_thread_type & FF_THREAD_SLICE) && mb_y < s->mb_height)
put_marker(pbc, RST0 + (mb_y&7));
s->esc_pos = put_bits_count(pbc) >> 3;
+fail:
for(i=0; i<3; i++)
s->last_dc[i] = 128 << s->intra_dc_precision;
+
+ return ret;
}
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
diff --git a/libavcodec/mjpegenc_common.h b/libavcodec/mjpegenc_common.h
index 38b9b3f9f0..87f150550d 100644
--- a/libavcodec/mjpegenc_common.h
+++ b/libavcodec/mjpegenc_common.h
@@ -34,7 +34,7 @@ void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb,
uint16_t chroma_intra_matrix[64]);
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits);
void ff_mjpeg_escape_FF(PutBitContext *pb, int start);
-void ff_mjpeg_encode_stuffing(MpegEncContext *s);
+int ff_mjpeg_encode_stuffing(MpegEncContext *s);
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[3], int vsample[3]);
void ff_mjpeg_encode_dc(PutBitContext *pb, int val,