mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-24 16:22:37 +00:00
jpeg style yuv fixes
Originally committed as revision 3852 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
827c91bfb7
commit
dd4f8a04fe
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -87,12 +87,12 @@ stddev: 7.03 PSNR:31.18 bytes:7602176
|
||||
1037657 ./data/a-mpeg1b.mpg
|
||||
09a77de112e144c562bc1398b111b61b *./data/out.yuv
|
||||
stddev: 6.35 PSNR:32.06 bytes:7602176
|
||||
07042f42b3119c39eb26537a84a451df *./data/a-mjpeg.avi
|
||||
1437768 ./data/a-mjpeg.avi
|
||||
f23a9e50a559e174766ee808c48fea22 *./data/out.yuv
|
||||
stddev: 8.87 PSNR:29.15 bytes:7602176
|
||||
1d565db4a3a054261af95f2483a37cd6 *./data/a-ljpeg.avi
|
||||
6262762 ./data/a-ljpeg.avi
|
||||
8e69394fdcb19995dfe5cb8c562d9441 *./data/a-mjpeg.avi
|
||||
1566544 ./data/a-mjpeg.avi
|
||||
18c3a76f984e717dd886d21fa04355f6 *./data/out.yuv
|
||||
stddev: 7.93 PSNR:30.13 bytes:7602176
|
||||
a534c6fc190682842efc0defda2cd442 *./data/a-ljpeg.avi
|
||||
6263462 ./data/a-ljpeg.avi
|
||||
799d3db687f6cdd7a837ec156efc171f *./data/out.yuv
|
||||
stddev: 0.00 PSNR:99.99 bytes:7602176
|
||||
49c87af74432890cadb28b93da1c653d *./data/a-rv10.rm
|
||||
|
@ -43,7 +43,7 @@ b977a4fedff90a79baf70c8e02986820 *./data/b-libav.yuv4mpeg
|
||||
3801810 ./data/b-libav.yuv4mpeg
|
||||
./data/b-libav%d.pgm CRC=84c09106
|
||||
./data/b-libav%d.ppm CRC=25c06ecf
|
||||
./data/b-libav%d.jpg CRC=afa6eff5
|
||||
./data/b-libav%d.jpg CRC=62328baa
|
||||
b0a8c8063d81921db5d7c8f50a1cc454 *./data/b-libav.wav
|
||||
89132 ./data/b-libav.wav
|
||||
./data/b-libav.wav CRC=2a09519c
|
||||
|
@ -360,7 +360,7 @@ fi
|
||||
if [ -n "$do_mjpeg" ] ; then
|
||||
# mjpeg
|
||||
file=${outfile}mjpeg.avi
|
||||
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg $file
|
||||
do_ffmpeg $file -y -qscale 10 -f pgmyuv -i $raw_src -an -vcodec mjpeg -pix_fmt yuvj420p $file
|
||||
|
||||
# mjpeg decoding
|
||||
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
|
||||
@ -370,7 +370,7 @@ fi
|
||||
if [ -n "$do_ljpeg" ] ; then
|
||||
# ljpeg
|
||||
file=${outfile}ljpeg.avi
|
||||
do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec ljpeg $file
|
||||
do_ffmpeg $file -y -f pgmyuv -i $raw_src -an -vcodec ljpeg -strict -1 $file
|
||||
|
||||
# ljpeg decoding
|
||||
do_ffmpeg $raw_dst -y -i $file -f rawvideo $raw_dst
|
||||
@ -601,7 +601,7 @@ do_ffmpeg_crc $file -i $file
|
||||
|
||||
# jpeg (we do not do md5 on image files yet)
|
||||
file=${outfile}libav%d.jpg
|
||||
$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src -bitexact -dct_algo 1 -idct_algo 2 -f image2 $file
|
||||
$ffmpeg -t 0.5 -y -qscale 10 -f pgmyuv -i $raw_src -bitexact -dct_algo 1 -idct_algo 2 -pix_fmt yuvj420p -f image2 $file
|
||||
do_ffmpeg_crc $file -f image2 -i $file
|
||||
|
||||
####################
|
||||
|
@ -87,12 +87,12 @@ stddev: 4.73 PSNR:34.61 bytes:7602176
|
||||
231306 ./data/a-mpeg1b.mpg
|
||||
c665bd56f8e241f8bf3a5a8f803227c3 *./data/out.yuv
|
||||
stddev: 4.13 PSNR:35.78 bytes:7602176
|
||||
e9218a1db885fe0262e88f9df630307d *./data/a-mjpeg.avi
|
||||
635218 ./data/a-mjpeg.avi
|
||||
a365b4da246ad68caf96b702b7f961a1 *./data/out.yuv
|
||||
stddev: 4.76 PSNR:34.56 bytes:7602176
|
||||
defd90b44bced2772c6ca0d8eb75f668 *./data/a-ljpeg.avi
|
||||
4764822 ./data/a-ljpeg.avi
|
||||
fab9b15954fe07a7d94ea4fa02af1ca2 *./data/a-mjpeg.avi
|
||||
702528 ./data/a-mjpeg.avi
|
||||
b1aa72cfb6f9cc3f525b27abc86a8f51 *./data/out.yuv
|
||||
stddev: 4.38 PSNR:35.28 bytes:7602176
|
||||
29d6f3ca0833ed83cffa279d08e79419 *./data/a-ljpeg.avi
|
||||
4765522 ./data/a-ljpeg.avi
|
||||
dde5895817ad9d219f79a52d0bdfb001 *./data/out.yuv
|
||||
stddev: 0.00 PSNR:99.99 bytes:7602176
|
||||
2123b30d786e6e6e25caf337f24e7834 *./data/a-rv10.rm
|
||||
|
Loading…
Reference in New Issue
Block a user