---
 libavdevice/libdc1394.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c
index 4cbed6e..e1ec7e8 100644
--- a/libavdevice/libdc1394.c
+++ b/libavdevice/libdc1394.c
@@ -59,7 +59,8 @@ typedef struct dc1394_data {
     dc1394video_frame_t *frame;
 #endif
     int current_frame;
-    int fps;
+    AVRational fps;             /**< frames per second, set via private 
options */
+    int frame_rate;             /**< fps*1000 */
 
     int width, height;
     char *pix_fmt;
@@ -101,7 +102,6 @@ static inline int dc1394_read_common(AVFormatContext *c, 
AVFormatParameters *ap,
     AVStream* vst;
     struct dc1394_frame_format *fmt;
     struct dc1394_frame_rate *fps;
-    int frame_rate           = !ap->time_base.num ? 30000 : av_rescale(1000, 
ap->time_base.den, ap->time_base.num);
     enum PixelFormat pix_fmt = av_get_pix_fmt(dc1394->pix_fmt);
 
     av_freep(&dc1394->pix_fmt);
@@ -113,19 +113,22 @@ static inline int dc1394_read_common(AVFormatContext *c, 
AVFormatParameters *ap,
         dc1394->height = ap->height;
     if (ap->pix_fmt)
         pix_fmt = ap->pix_fmt;
+    if (ap->time_base.num)
+        dc1394->fps = (AVRational){ap->time_base.den, ap->time_base.num};
 #endif
 
     for (fmt = dc1394_frame_formats; fmt->width; fmt++)
          if (fmt->pix_fmt == pix_fmt && fmt->width == dc1394->width && 
fmt->height == dc1394->height)
              break;
 
+    dc1394->frame_rate = av_rescale(1000, dc1394->fps.num, dc1394->fps.den);
     for (fps = dc1394_frame_rates; fps->frame_rate; fps++)
-         if (fps->frame_rate == frame_rate)
+         if (fps->frame_rate == dc1394->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),
-                                                                               
                 dc1394->width, dc1394->height, frame_rate);
+                                                                               
                 dc1394->width, dc1394->height, dc1394->frame_rate);
         goto out;
     }
 
@@ -136,8 +139,8 @@ static inline int dc1394_read_common(AVFormatContext *c, 
AVFormatParameters *ap,
     av_set_pts_info(vst, 64, 1, 1000);
     vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
     vst->codec->codec_id = CODEC_ID_RAWVIDEO;
-    vst->codec->time_base.den = fps->frame_rate;
-    vst->codec->time_base.num = 1000;
+    vst->codec->time_base.den = dc1394->fps.num;
+    vst->codec->time_base.num = dc1394->fps.den;
     vst->codec->width = fmt->width;
     vst->codec->height = fmt->height;
     vst->codec->pix_fmt = fmt->pix_fmt;
@@ -149,7 +152,6 @@ static inline int dc1394_read_common(AVFormatContext *c, 
AVFormatParameters *ap,
     dc1394->packet.flags |= AV_PKT_FLAG_KEY;
 
     dc1394->current_frame = 0;
-    dc1394->fps = fps->frame_rate;
 
     vst->codec->bit_rate = av_rescale(dc1394->packet.size * 8, 
fps->frame_rate, 1000);
     *select_fps = fps;
@@ -234,7 +236,7 @@ static int dc1394_v1_read_packet(AVFormatContext *c, 
AVPacket *pkt)
 
     if (res == DC1394_SUCCESS) {
         dc1394->packet.data = (uint8_t *)(dc1394->camera.capture_buffer);
-        dc1394->packet.pts = (dc1394->current_frame * 1000000) / dc1394->fps;
+        dc1394->packet.pts = (dc1394->current_frame * 1000000) / 
dc1394->frame_rate;
         res = dc1394->packet.size;
     } else {
         av_log(c, AV_LOG_ERROR, "DMA capture failed\n");
@@ -265,6 +267,7 @@ static const AVOption options[] = {
     { "width",   "", offsetof(dc1394_data, width),   FF_OPT_TYPE_INT, {.dbl = 
320}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { "height",  "", offsetof(dc1394_data, height),  FF_OPT_TYPE_INT, {.dbl = 
240}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { "pixel_format", "", offsetof(dc1394_data, pix_fmt), FF_OPT_TYPE_STRING, 
{.str = "UYVY422" }, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
+    { "framerate",    "", offsetof(dc1394_data, fps),     
FF_OPT_TYPE_RATIONAL, {.dbl = 25}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
     { NULL },
 };
 
-- 
1.7.5.1

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to