[FFmpeg-cvslog] avcodec/mjpegenc: move end padding/alignment to ff_mjpeg_escape_FF()
Michael Niedermayer
git at videolan.org
Fri Dec 6 12:11:48 CET 2013
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Dec 6 11:55:23 2013 +0100| [978ae13f2337f2f5bf4a6f5313dfe3404a79ea54] | committer: Michael Niedermayer
avcodec/mjpegenc: move end padding/alignment to ff_mjpeg_escape_FF()
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=978ae13f2337f2f5bf4a6f5313dfe3404a79ea54
---
libavcodec/mjpegenc.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 34de4bd..423a2f5 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));
More information about the ffmpeg-cvslog
mailing list