diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2005-01-20 00:30:20 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-01-20 00:30:20 +0000 |
commit | dd4f8a04fe81c2587293a7c89ef8702f54330339 (patch) | |
tree | 056cd23cd263ab90832f443b98eb420db3eb892e /libavcodec/mjpeg.c | |
parent | 827c91bfb795359aa69663411237cb9df40b1c22 (diff) | |
download | ffmpeg-dd4f8a04fe81c2587293a7c89ef8702f54330339.tar.gz |
jpeg style yuv fixes
Originally committed as revision 3852 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/mjpeg.c')
-rw-r--r-- | libavcodec/mjpeg.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c index b09492dc7e..2edd90bd43 100644 --- a/libavcodec/mjpeg.c +++ b/libavcodec/mjpeg.c @@ -400,6 +400,19 @@ static void jpeg_put_comments(MpegEncContext *s) ptr[0] = size >> 8; ptr[1] = size; } + + if( s->avctx->pix_fmt == PIX_FMT_YUV420P + ||s->avctx->pix_fmt == PIX_FMT_YUV422P + ||s->avctx->pix_fmt == PIX_FMT_YUV444P){ + put_marker(p, COM); + flush_put_bits(p); + ptr = pbBufPtr(p); + put_bits(p, 16, 0); /* patched later */ + put_string(p, "CS=ITU601", 1); + size = strlen("CS=ITU601")+3; + ptr[0] = size >> 8; + ptr[1] = size; + } } void mjpeg_picture_header(MpegEncContext *s) @@ -845,6 +858,7 @@ typedef struct MJpegDecodeContext { int restart_count; int buggy_avid; + int cs_itu601; int interlace_polarity; int mjpb_skiptosod; @@ -1133,16 +1147,16 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s) if(s->rgb){ s->avctx->pix_fmt = PIX_FMT_RGBA32; }else if(s->nb_components==3) - s->avctx->pix_fmt = PIX_FMT_YUV444P; + s->avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV444P : PIX_FMT_YUVJ444P; else s->avctx->pix_fmt = PIX_FMT_GRAY8; break; case 0x21: - s->avctx->pix_fmt = PIX_FMT_YUV422P; + s->avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV422P : PIX_FMT_YUVJ422P; break; default: case 0x22: - s->avctx->pix_fmt = PIX_FMT_YUV420P; + s->avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV420P : PIX_FMT_YUVJ420P; break; } @@ -1737,6 +1751,9 @@ static int mjpeg_decode_com(MJpegDecodeContext *s) // if (s->first_picture) // printf("mjpeg: workarounding buggy AVID\n"); } + else if(!strcmp(cbuf, "CS=ITU601")){ + s->cs_itu601= 1; + } av_free(cbuf); } @@ -2172,7 +2189,7 @@ static int sp5x_decode_frame(AVCodecContext *avctx, s->v_max = 2; s->qscale_table = av_mallocz((s->width+15)/16); - avctx->pix_fmt = PIX_FMT_YUV420P; + avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV420P : PIX_FMT_YUVJ420; s->interlaced = 0; s->picture.reference = 0; |