]> git.sesse.net Git - ffmpeg/blobdiff - libavdevice/dv1394.c
libm: add fallbacks for various single-precision functions
[ffmpeg] / libavdevice / dv1394.c
index 70f928ed806a83a51f38c2a44dd42a5410408e83..4a637683e4a2524612f8ce64c74d1ca53a8447af 100644 (file)
 #include <poll.h>
 #include <sys/ioctl.h>
 #include <sys/mman.h>
-#include <sys/time.h>
-#include <time.h>
-#include <strings.h>
 
+#include "libavutil/log.h"
+#include "libavutil/opt.h"
 #include "libavformat/avformat.h"
-
-#undef DV1394_DEBUG
-
 #include "libavformat/dv.h"
 #include "dv1394.h"
 
 struct dv1394_data {
+    AVClass *class;
     int fd;
     int channel;
     int format;
@@ -82,24 +79,14 @@ static int dv1394_start(struct dv1394_data *dv)
     return 0;
 }
 
-static int dv1394_read_header(AVFormatContext * context, AVFormatParameters * ap)
+static int dv1394_read_header(AVFormatContext * context)
 {
     struct dv1394_data *dv = context->priv_data;
 
-    dv->dv_demux = dv_init_demux(context);
+    dv->dv_demux = avpriv_dv_init_demux(context);
     if (!dv->dv_demux)
         goto failed;
 
-    if (ap->standard && !strcasecmp(ap->standard, "pal"))
-        dv->format = DV1394_PAL;
-    else
-        dv->format = DV1394_NTSC;
-
-    if (ap->channel)
-        dv->channel = ap->channel;
-    else
-        dv->channel = DV1394_DEFAULT_CHANNEL;
-
     /* Open and initialize DV1394 device */
     dv->fd = open(context->filename, O_RDONLY);
     if (dv->fd < 0) {
@@ -134,7 +121,7 @@ static int dv1394_read_packet(AVFormatContext *context, AVPacket *pkt)
     struct dv1394_data *dv = context->priv_data;
     int size;
 
-    size = dv_get_packet(dv->dv_demux, pkt);
+    size = avpriv_dv_get_packet(dv->dv_demux, pkt);
     if (size > 0)
         return size;
 
@@ -172,15 +159,13 @@ restart_poll:
             av_log(context, AV_LOG_ERROR, "Failed to get status: %s\n", strerror(errno));
             return AVERROR(EIO);
         }
-#ifdef DV1394_DEBUG
-        av_log(context, AV_LOG_DEBUG, "DV1394: status\n"
+        av_dlog(context, "DV1394: status\n"
                 "\tactive_frame\t%d\n"
                 "\tfirst_clear_frame\t%d\n"
                 "\tn_clear_frames\t%d\n"
                 "\tdropped_frames\t%d\n",
                 s.active_frame, s.first_clear_frame,
                 s.n_clear_frames, s.dropped_frames);
-#endif
 
         dv->avail = s.n_clear_frames;
         dv->index = s.first_clear_frame;
@@ -195,12 +180,10 @@ restart_poll:
         }
     }
 
-#ifdef DV1394_DEBUG
-    av_log(context, AV_LOG_DEBUG, "index %d, avail %d, done %d\n", dv->index, dv->avail,
+    av_dlog(context, "index %d, avail %d, done %d\n", dv->index, dv->avail,
             dv->done);
-#endif
 
-    size = dv_produce_packet(dv->dv_demux, pkt,
+    size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
                              dv->ring + (dv->index * DV1394_PAL_FRAME_SIZE),
                              DV1394_PAL_FRAME_SIZE);
     dv->index = (dv->index + 1) % DV1394_RING_FRAMES;
@@ -227,6 +210,21 @@ static int dv1394_close(AVFormatContext * context)
     return 0;
 }
 
+static const AVOption options[] = {
+    { "standard", "", offsetof(struct dv1394_data, format), AV_OPT_TYPE_INT, {.i64 = DV1394_NTSC}, DV1394_PAL, DV1394_NTSC, AV_OPT_FLAG_DECODING_PARAM, "standard" },
+    { "PAL",      "", 0, AV_OPT_TYPE_CONST, {.i64 = DV1394_PAL},   0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" },
+    { "NTSC",     "", 0, AV_OPT_TYPE_CONST, {.i64 = DV1394_NTSC},  0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" },
+    { "channel",  "", offsetof(struct dv1394_data, channel), AV_OPT_TYPE_INT, {.i64 = DV1394_DEFAULT_CHANNEL}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+    { NULL },
+};
+
+static const AVClass dv1394_class = {
+    .class_name = "DV1394 indev",
+    .item_name  = av_default_item_name,
+    .option     = options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
 AVInputFormat ff_dv1394_demuxer = {
     .name           = "dv1394",
     .long_name      = NULL_IF_CONFIG_SMALL("DV1394 A/V grab"),
@@ -234,5 +232,6 @@ AVInputFormat ff_dv1394_demuxer = {
     .read_header    = dv1394_read_header,
     .read_packet    = dv1394_read_packet,
     .read_close     = dv1394_close,
-    .flags          = AVFMT_NOFILE
+    .flags          = AVFMT_NOFILE,
+    .priv_class     = &dv1394_class,
 };