aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mjpegdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-07 20:17:50 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-01-09 00:06:23 +0100
commitb1435626392bd05bd3e79a56d9f64c089654afda (patch)
tree4f458f6930a7c709779c7114cdfe98ecd89de868 /libavcodec/mjpegdec.c
parentcd2a27e1e586be5dc68454ecbbfe8c2c3d041c2a (diff)
downloadffmpeg-b1435626392bd05bd3e79a56d9f64c089654afda.tar.gz
ljpegdec: Support MCU in ljpeg_decode_yuv_scan()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mjpegdec.c')
-rw-r--r--libavcodec/mjpegdec.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index c0c4080b48..5423925c8b 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -765,6 +765,8 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point
int i, mb_x, mb_y;
const int nb_components=s->nb_components;
int bits= (s->bits+7)&~7;
+ int resync_mb_y = 0;
+ int resync_mb_x = 0;
point_transform += bits - s->bits;
@@ -772,10 +774,15 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point
for(mb_y = 0; mb_y < s->mb_height; mb_y++) {
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
- if (s->restart_interval && !s->restart_count)
+ if (s->restart_interval && !s->restart_count){
s->restart_count = s->restart_interval;
+ resync_mb_x = mb_x;
+ resync_mb_y = mb_y;
+ }
- if(mb_x==0 || mb_y==0 || s->interlaced){
+ if(!mb_x || mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x || s->interlaced){
+ int toprow = mb_y == resync_mb_y || mb_y == resync_mb_y+1 && mb_x < resync_mb_x;
+ int leftcol = !mb_x || mb_y == resync_mb_y && mb_x == resync_mb_x;
for(i=0;i<nb_components;i++) {
uint8_t *ptr;
uint16_t *ptr16;
@@ -798,14 +805,14 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point
return -1;
if(bits<=8){
ptr = s->picture.data[c] + (linesize * (v * mb_y + y)) + (h * mb_x + x); //FIXME optimize this crap
- if(y==0 && mb_y==0){
- if(x==0 && mb_x==0){
+ if(y==0 && toprow){
+ if(x==0 && leftcol){
pred= 1 << (bits - 1);
}else{
pred= ptr[-1];
}
}else{
- if(x==0 && mb_x==0){
+ if(x==0 && leftcol){
pred= ptr[-linesize];
}else{
PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
@@ -818,14 +825,14 @@ static int ljpeg_decode_yuv_scan(MJpegDecodeContext *s, int predictor, int point
*ptr= pred + (dc << point_transform);
}else{
ptr16 = s->picture.data[c] + 2*(linesize * (v * mb_y + y)) + 2*(h * mb_x + x); //FIXME optimize this crap
- if(y==0 && mb_y==0){
- if(x==0 && mb_x==0){
+ if(y==0 && toprow){
+ if(x==0 && leftcol){
pred= 1 << (bits - 1);
}else{
pred= ptr16[-1];
}
}else{
- if(x==0 && mb_x==0){
+ if(x==0 && leftcol){
pred= ptr16[-linesize];
}else{
PREDICT(pred, ptr16[-linesize-1], ptr16[-linesize], ptr16[-1], predictor);