From 978ae13f2337f2f5bf4a6f5313dfe3404a79ea54 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 6 Dec 2013 11:55:23 +0100 Subject: [PATCH] avcodec/mjpegenc: move end padding/alignment to ff_mjpeg_escape_FF() Signed-off-by: Michael Niedermayer --- libavcodec/mjpegenc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 34de4bdbd0..423a2f5c23 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -326,10 +326,17 @@ end: void ff_mjpeg_escape_FF(PutBitContext *pb, int start) { - int size = put_bits_count(pb) - start * 8; + int size; int i, ff_count; uint8_t *buf = pb->buf + start; int align= (-(size_t)(buf))&3; + int pad = (-put_bits_count(pb))&7; + + if (pad) + put_bits(pb, pad, (1<>= 3; @@ -381,11 +388,8 @@ void ff_mjpeg_encode_stuffing(MpegEncContext *s) int length, i; PutBitContext *pbc = &s->pb; int mb_y = s->mb_y - !s->mb_x; - length= (-put_bits_count(pbc))&7; - if(length) put_bits(pbc, length, (1<pb); - ff_mjpeg_escape_FF(&s->pb, s->esc_pos); + 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));