diff options
author | Luca Abeni <lucabe72@email.it> | 2006-06-28 12:18:22 +0000 |
---|---|---|
committer | Luca Abeni <lucabe72@email.it> | 2006-06-28 12:18:22 +0000 |
commit | 76a77ff291aac29f4c6df86dfd7db60e1097fee6 (patch) | |
tree | bd561dd6cc115afc6792daa2d29c8b45ef6ef2c6 /libavformat/grab.c | |
parent | b582d7ba4dc8d774fbeab0f5ae9b5aae66d9a4de (diff) | |
download | ffmpeg-76a77ff291aac29f4c6df86dfd7db60e1097fee6.tar.gz |
Properly set the image depth
Originally committed as revision 5538 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/grab.c')
-rw-r--r-- | libavformat/grab.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libavformat/grab.c b/libavformat/grab.c index 79bdf9ddc7..f40571cd22 100644 --- a/libavformat/grab.c +++ b/libavformat/grab.c @@ -62,7 +62,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) int width, height; int video_fd, frame_size; int ret, frame_rate, frame_rate_base; - int desired_palette; + int desired_palette, desired_depth; struct video_tuner tuner; struct video_audio audio; struct video_picture pict; @@ -118,12 +118,16 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) } desired_palette = -1; - if (st->codec->pix_fmt == PIX_FMT_YUV420P) { + desired_depth = -1; + if (ap->pix_fmt == PIX_FMT_YUV420P) { desired_palette = VIDEO_PALETTE_YUV420P; - } else if (st->codec->pix_fmt == PIX_FMT_YUV422) { + desired_depth = 12; + } else if (ap->pix_fmt == PIX_FMT_YUV422) { desired_palette = VIDEO_PALETTE_YUV422; - } else if (st->codec->pix_fmt == PIX_FMT_BGR24) { + desired_depth = 16; + } else if (ap->pix_fmt == PIX_FMT_BGR24) { desired_palette = VIDEO_PALETTE_RGB24; + desired_depth = 24; } /* set tv standard */ @@ -155,14 +159,18 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) #endif /* try to choose a suitable video format */ pict.palette = desired_palette; + pict.depth= desired_depth; if (desired_palette == -1 || (ret = ioctl(video_fd, VIDIOCSPICT, &pict)) < 0) { pict.palette=VIDEO_PALETTE_YUV420P; + pict.depth=12; ret = ioctl(video_fd, VIDIOCSPICT, &pict); if (ret < 0) { pict.palette=VIDEO_PALETTE_YUV422; + pict.depth=16; ret = ioctl(video_fd, VIDIOCSPICT, &pict); if (ret < 0) { pict.palette=VIDEO_PALETTE_RGB24; + pict.depth=24; ret = ioctl(video_fd, VIDIOCSPICT, &pict); if (ret < 0) goto fail1; |