[SCM] libav/experimental: * fixing a bug preventing default values to be set correctly

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:11:31 UTC 2013


The following commit has been merged in the experimental branch:
commit 43d1a1c05a51dfa340c95319be2608df98e6c3f4
Author: Roman Shaposhnik <roman at shaposhnik.org>
Date:   Tue Jan 8 02:52:05 2008 +0000

      * fixing a bug preventing default values to be set correctly
    
    Originally committed as revision 11461 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c
index 095a35a..a0f0481 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)

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list