[FFmpeg-devel] [PATCH] ljpegdec: support non zero MCU for RGB.
Michael Niedermayer
michaelni at gmx.at
Fri Jan 6 19:06:29 CET 2012
Fixes Ticket875
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavcodec/mjpegdec.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 7c27f5d..be7ad83 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -684,24 +684,28 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
int left[3], top[3], topleft[3];
const int linesize= s->linesize[0];
const int mask= (1<<s->bits)-1;
+ int resync_mb_y= 0;
+ int resync_mb_x= 0;
av_fast_malloc(&s->ljpeg_buffer, &s->ljpeg_buffer_size, (unsigned)s->mb_width * 4 * sizeof(s->ljpeg_buffer[0][0]));
buffer= s->ljpeg_buffer;
- for(i=0; i<3; i++){
- buffer[0][i]= 1 << (s->bits - 1);
- }
for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
- const int modified_predictor= mb_y ? predictor : 1;
uint8_t *ptr = s->picture.data[0] + (linesize * mb_y);
if (s->interlaced && s->bottom_field)
ptr += linesize >> 1;
for(i=0; i<3; i++){
+ if(mb_y == resync_mb_y || mb_y == resync_mb_y+1 && 0 < resync_mb_x)
+ buffer[0][i]= 1 << (s->bits - 1);
top[i]= left[i]= topleft[i]= buffer[0][i];
}
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
+ int modified_predictor = predictor;
+ if(mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x)
+ modified_predictor = 1;
+
if (s->restart_interval && !s->restart_count)
s->restart_count = s->restart_interval;
@@ -724,6 +728,11 @@ static int ljpeg_decode_rgb_scan(MJpegDecodeContext *s, int nb_components, int p
if (s->restart_interval && !--s->restart_count) {
align_get_bits(&s->gb);
skip_bits(&s->gb, 16); /* skip RSTn */
+ resync_mb_x = mb_x;
+ resync_mb_y = mb_y;
+ for(i=0; i<3; i++){
+ top[i]= left[i]= topleft[i]= 1 << (s->bits - 1);
+ }
}
}
--
1.7.5.4
More information about the ffmpeg-devel
mailing list