diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-12-06 11:55:23 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-12-06 12:01:28 +0100 |
commit | 978ae13f2337f2f5bf4a6f5313dfe3404a79ea54 (patch) | |
tree | 19df80a77d553f79fcda94c733937805b121ceed /libavcodec/mjpegenc.c | |
parent | 9fcd58ab261b166271d286841c0f142e67856011 (diff) | |
download | ffmpeg-978ae13f2337f2f5bf4a6f5313dfe3404a79ea54.tar.gz |
avcodec/mjpegenc: move end padding/alignment to ff_mjpeg_escape_FF()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mjpegenc.c')
-rw-r--r-- | libavcodec/mjpegenc.c | 14 |
1 files 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<<pad)-1); + + flush_put_bits(pb); + size = put_bits_count(pb) - start * 8; av_assert1((size&7) == 0); size >>= 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<<length)-1); - flush_put_bits(&s->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)); |