From 85db15fcf0b7406f590411e9e06d2bc92f51ecda Mon Sep 17 00:00:00 2001 From: romansh Date: Tue, 8 Jan 2008 02:52:05 +0000 Subject: [PATCH] * fixing a bug preventing default values to be set correctly git-svn-id: file:///var/local/repositories/ffmpeg/trunk@11461 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b --- libavdevice/libdc1394.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index 095a35af1..a0f04817b 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -44,7 +44,7 @@ struct dc1394_frame_format { { 320, 240, PIX_FMT_UYVY422, MODE_320x240_YUV422 }, { 640, 480, PIX_FMT_UYYVYY411, MODE_640x480_YUV411 }, { 640, 480, PIX_FMT_UYVY422, MODE_640x480_YUV422 }, - { 0, 0, 0, MODE_320x240_YUV422 } /* default -- gotta be the last one */ + { 0, 0, 0, 0 } /* gotta be the last one */ }; struct dc1394_frame_rate { @@ -57,7 +57,7 @@ struct dc1394_frame_rate { { 15000, FRAMERATE_15 }, { 30000, FRAMERATE_30 }, { 60000, FRAMERATE_60 }, - { 0, FRAMERATE_30 } /* default -- gotta be the last one */ + { 0, 0 } /* gotta be the last one */ }; static int dc1394_read_header(AVFormatContext *c, AVFormatParameters * ap) @@ -68,15 +68,25 @@ static int dc1394_read_header(AVFormatContext *c, AVFormatParameters * ap) int res; struct dc1394_frame_format *fmt; struct dc1394_frame_rate *fps; + enum PixelFormat pix_fmt = ap->pix_fmt == PIX_FMT_NONE ? PIX_FMT_UYVY422 : ap->pix_fmt; /* defaults */ + int width = !ap->width ? 320 : ap->width; + int height = !ap->height ? 240 : ap->height; + int frame_rate = !ap->time_base.num ? 30000 : av_rescale(1000, ap->time_base.den, ap->time_base.num); for (fmt = dc1394_frame_formats; fmt->width; fmt++) - if (fmt->pix_fmt == ap->pix_fmt && fmt->width == ap->width && fmt->height == ap->height) + if (fmt->pix_fmt == pix_fmt && fmt->width == width && fmt->height == height) break; for (fps = dc1394_frame_rates; fps->frame_rate; fps++) - if (fps->frame_rate == av_rescale(1000, ap->time_base.den, ap->time_base.num)) + if (fps->frame_rate == frame_rate) break; + if (!fps->frame_rate || !fmt->width) { + av_log(c, AV_LOG_ERROR, "Can't find matching camera format for %s, %dx%d@%d:1000fps\n", avcodec_get_pix_fmt_name(pix_fmt), + width, height, frame_rate); + goto out; + } + /* create a video stream */ vst = av_new_stream(c, 0); if (!vst) -- 2.39.2