summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2001-08-06 01:54:05 +0000
committerFabrice Bellard <fabrice@bellard.org>2001-08-06 01:54:05 +0000
commitb182e68ac5842e797f7f120f347c7b69a2f73658 (patch)
treeb27d5bae8cf3b627590a53478ff562833e6bd06e /libavcodec
parentd9fea0b588801581851cf9f7dc3647cb1cd9d962 (diff)
added 422P and 444P support - fixed block parsing error
Originally committed as revision 39 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mjpeg.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c
index 1dcc9ac48d..ed0d770e2f 100644
--- a/libavcodec/mjpeg.c
+++ b/libavcodec/mjpeg.c
@@ -583,12 +583,6 @@ static int mjpeg_decode_sof0(MJpegDecodeContext *s,
s->h_max = s->h_count[i];
if (s->v_count[i] > s->v_max)
s->v_max = s->v_count[i];
-#if 1
- /* XXX: only 420 is accepted */
- if ((i == 0 && (s->h_count[i] != 2 || s->v_count[i] != 2)) ||
- (i != 0 && (s->h_count[i] != 1 || s->v_count[i] != 1)))
- return -1;
-#endif
s->quant_index[i] = get_bits(&s->gb, 8);
if (s->quant_index[i] >= 4)
return -1;
@@ -659,7 +653,6 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
val = val * quant_matrix[0] + s->last_dc[component];
s->last_dc[component] = val;
block[0] = val;
-
/* AC coefs */
ac_vlc = &s->vlcs[1][ac_index];
i = 1;
@@ -688,6 +681,8 @@ static int decode_block(MJpegDecodeContext *s, DCTELEM *block,
j = zigzag_direct[i];
block[j] = level * quant_matrix[j];
i++;
+ if (i >= 64)
+ break;
}
}
return 0;
@@ -727,7 +722,7 @@ static int mjpeg_decode_sos(MJpegDecodeContext *s,
nb_blocks[i] = s->h_count[index] * s->v_count[index];
h_count[i] = s->h_count[index];
v_count[i] = s->v_count[index];
-
+
dc_index[i] = get_bits(&s->gb, 4);
if (dc_index[i] >= 4)
return -1;
@@ -882,7 +877,6 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
case SOS:
mjpeg_decode_sos(s, s->buffer, input_size);
if (s->start_code == EOI) {
- /* XXX: YUV420 hardcoded */
for(i=0;i<3;i++) {
picture->data[i] = s->current_picture[i];
picture->linesize[i] = s->linesize[i];
@@ -890,7 +884,19 @@ static int mjpeg_decode_frame(AVCodecContext *avctx,
*data_size = sizeof(AVPicture);
avctx->height = s->height;
avctx->width = s->width;
- avctx->pix_fmt = PIX_FMT_YUV420P;
+ /* XXX: not complete test ! */
+ switch((s->h_count[0] << 4) | s->v_count[0]) {
+ case 0x11:
+ avctx->pix_fmt = PIX_FMT_YUV444P;
+ break;
+ case 0x21:
+ avctx->pix_fmt = PIX_FMT_YUV422P;
+ break;
+ default:
+ case 0x22:
+ avctx->pix_fmt = PIX_FMT_YUV420P;
+ break;
+ }
goto the_end;
}
break;