aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2005-01-20 00:30:20 +0000
committerMichael Niedermayer <michaelni@gmx.at>2005-01-20 00:30:20 +0000
commitdd4f8a04fe81c2587293a7c89ef8702f54330339 (patch)
tree056cd23cd263ab90832f443b98eb420db3eb892e /libavcodec
parent827c91bfb795359aa69663411237cb9df40b1c22 (diff)
downloadffmpeg-dd4f8a04fe81c2587293a7c89ef8702f54330339.tar.gz
jpeg style yuv fixes
Originally committed as revision 3852 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mjpeg.c25
-rw-r--r--libavcodec/mpegvideo.c19
2 files changed, 38 insertions, 6 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;
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 6a48097a0c..6b5546cd3a 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -892,7 +892,22 @@ int MPV_encode_init(AVCodecContext *avctx)
MPV_encode_defaults(s);
- avctx->pix_fmt = PIX_FMT_YUV420P; // FIXME
+ if(avctx->pix_fmt != PIX_FMT_YUVJ420P && avctx->pix_fmt != PIX_FMT_YUV420P){
+ av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n");
+ return -1;
+ }
+
+ if(avctx->codec_id == CODEC_ID_MJPEG || avctx->codec_id == CODEC_ID_LJPEG){
+ if(avctx->strict_std_compliance>=0 && avctx->pix_fmt != PIX_FMT_YUVJ420P){
+ av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n");
+ return -1;
+ }
+ }else{
+ if(avctx->strict_std_compliance>=0 && avctx->pix_fmt != PIX_FMT_YUV420P){
+ av_log(avctx, AV_LOG_ERROR, "colorspace not supported\n");
+ return -1;
+ }
+ }
s->bit_rate = avctx->bit_rate;
s->width = avctx->width;
@@ -2259,7 +2274,7 @@ int MPV_encode_picture(AVCodecContext *avctx,
AVFrame *pic_arg = data;
int i, stuffing_count;
- if(avctx->pix_fmt != PIX_FMT_YUV420P){
+ if(avctx->pix_fmt != PIX_FMT_YUV420P && avctx->pix_fmt != PIX_FMT_YUVJ420P){
av_log(avctx, AV_LOG_ERROR, "this codec supports only YUV420P\n");
return -1;
}