Commit f96b17c5 authored by Roine Gustafsson's avatar Roine Gustafsson Committed by Michael Niedermayer

add luma only support to yuv4mpeg patch by (Roine Gustafsson <roine users.sourceforge net>)

Originally committed as revision 3846 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 2c656386
...@@ -49,6 +49,9 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) ...@@ -49,6 +49,9 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
} }
switch(st->codec.pix_fmt) { switch(st->codec.pix_fmt) {
case PIX_FMT_GRAY8:
colorspace = " Cmono";
break;
case PIX_FMT_YUV411P: case PIX_FMT_YUV411P:
colorspace = " C411 XYSCSS=411"; colorspace = " C411 XYSCSS=411";
break; break;
...@@ -115,6 +118,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -115,6 +118,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
ptr += picture->linesize[0]; ptr += picture->linesize[0];
} }
if (st->codec.pix_fmt != PIX_FMT_GRAY8){
// Adjust for smaller Cb and Cr planes // Adjust for smaller Cb and Cr planes
avcodec_get_chroma_sub_sample(st->codec.pix_fmt, &h_chroma_shift, &v_chroma_shift); avcodec_get_chroma_sub_sample(st->codec.pix_fmt, &h_chroma_shift, &v_chroma_shift);
width >>= h_chroma_shift; width >>= h_chroma_shift;
...@@ -130,6 +134,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -130,6 +134,7 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
put_buffer(pb, ptr2, width); put_buffer(pb, ptr2, width);
ptr2 += picture->linesize[2]; ptr2 += picture->linesize[2];
} }
}
put_flush_packet(pb); put_flush_packet(pb);
return 0; return 0;
} }
...@@ -146,8 +151,9 @@ static int yuv4_write_header(AVFormatContext *s) ...@@ -146,8 +151,9 @@ static int yuv4_write_header(AVFormatContext *s)
} }
else if ((s->streams[0]->codec.pix_fmt != PIX_FMT_YUV420P) && else if ((s->streams[0]->codec.pix_fmt != PIX_FMT_YUV420P) &&
(s->streams[0]->codec.pix_fmt != PIX_FMT_YUV422P) && (s->streams[0]->codec.pix_fmt != PIX_FMT_YUV422P) &&
(s->streams[0]->codec.pix_fmt != PIX_FMT_GRAY8) &&
(s->streams[0]->codec.pix_fmt != PIX_FMT_YUV444P)) { (s->streams[0]->codec.pix_fmt != PIX_FMT_YUV444P)) {
av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles 4:4:4, 4:2:2, 4:2:0 and 4:1:1 planar YUV data. Use -pix_fmt to select one.\n"); av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles yuv444p, yuv422p, yuv420p, yuv411p and gray pixel formats. Use -pix_fmt to select one.\n");
return AVERROR_IO; return AVERROR_IO;
} }
...@@ -229,8 +235,7 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -229,8 +235,7 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap)
} else if (strncmp("444", tokstart, 3)==0) } else if (strncmp("444", tokstart, 3)==0)
pix_fmt = PIX_FMT_YUV444P; pix_fmt = PIX_FMT_YUV444P;
else if (strncmp("mono",tokstart, 4)==0) { else if (strncmp("mono",tokstart, 4)==0) {
av_log(s, AV_LOG_ERROR, "Cannot handle luma only YUV4MPEG stream.\n"); pix_fmt = PIX_FMT_GRAY8;
return -1;
} else { } else {
av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown pixel format.\n"); av_log(s, AV_LOG_ERROR, "YUV4MPEG stream contains an unknown pixel format.\n");
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment