~siretart/libav/merge.raring.libav-0.8.6

« back to all changes in this revision

Viewing changes to libavdevice/libdc1394.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-12 22:30:00 UTC
  • mfrom: (1.4.1)
  • mto: (1.3.11 sid) (26.1.1 quantal-security)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: package-import@ubuntu.com-20120112223000-s1reiy1e28hnix42
Tags: upstream-0.8~beta2
ImportĀ upstreamĀ versionĀ 0.8~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "config.h"
24
24
#include "libavformat/avformat.h"
 
25
#include "libavformat/internal.h"
25
26
#include "libavutil/log.h"
 
27
#include "libavutil/mathematics.h"
26
28
#include "libavutil/opt.h"
27
29
#include "libavutil/parseutils.h"
28
30
#include "libavutil/pixdesc.h"
99
101
#define DEC AV_OPT_FLAG_DECODING_PARAM
100
102
static const AVOption options[] = {
101
103
#if HAVE_LIBDC1394_1
102
 
    { "channel", "", offsetof(dc1394_data, channel), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
 
104
    { "channel", "", offsetof(dc1394_data, channel), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
103
105
#endif
104
 
    { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "qvga"}, 0, 0, DEC },
105
 
    { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "uyvy422"}, 0, 0, DEC },
106
 
    { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC },
 
106
    { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "qvga"}, 0, 0, DEC },
 
107
    { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = "uyvy422"}, 0, 0, DEC },
 
108
    { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC },
107
109
    { NULL },
108
110
};
109
111
 
134
136
    }
135
137
 
136
138
    if ((ret = av_parse_video_size(&width, &height, dc1394->video_size)) < 0) {
137
 
        av_log(c, AV_LOG_ERROR, "Couldn't parse video size.\n");
 
139
        av_log(c, AV_LOG_ERROR, "Could not parse video size '%s'.\n", dc1394->video_size);
138
140
        goto out;
139
141
    }
140
142
    if ((ret = av_parse_video_rate(&framerate, dc1394->framerate)) < 0) {
141
 
        av_log(c, AV_LOG_ERROR, "Couldn't parse framerate.\n");
 
143
        av_log(c, AV_LOG_ERROR, "Could not parse framerate '%s'.\n", dc1394->framerate);
142
144
        goto out;
143
145
    }
144
 
#if FF_API_FORMAT_PARAMETERS
145
 
    if (ap->width > 0)
146
 
        width = ap->width;
147
 
    if (ap->height > 0)
148
 
        height = ap->height;
149
 
    if (ap->pix_fmt)
150
 
        pix_fmt = ap->pix_fmt;
151
 
    if (ap->time_base.num)
152
 
        framerate = (AVRational){ap->time_base.den, ap->time_base.num};
153
 
#endif
154
146
    dc1394->frame_rate = av_rescale(1000, framerate.num, framerate.den);
155
147
 
156
148
    for (fmt = dc1394_frame_formats; fmt->width; fmt++)
169
161
    }
170
162
 
171
163
    /* create a video stream */
172
 
    vst = av_new_stream(c, 0);
 
164
    vst = avformat_new_stream(c, NULL);
173
165
    if (!vst) {
174
166
        ret = AVERROR(ENOMEM);
175
167
        goto out;
176
168
    }
177
 
    av_set_pts_info(vst, 64, 1, 1000);
 
169
    avpriv_set_pts_info(vst, 64, 1, 1000);
178
170
    vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
179
171
    vst->codec->codec_id = CODEC_ID_RAWVIDEO;
180
172
    vst->codec->time_base.den = framerate.num;
211
203
    if (dc1394_read_common(c,ap,&fmt,&fps) != 0)
212
204
        return -1;
213
205
 
214
 
#if FF_API_FORMAT_PARAMETERS
215
 
    if (ap->channel)
216
 
        dc1394->channel = ap->channel;
217
 
#endif
218
 
 
219
206
    /* Now let us prep the hardware. */
220
207
    dc1394->handle = dc1394_create_handle(0); /* FIXME: gotta have ap->port */
221
208
    if (!dc1394->handle) {
384
371
 
385
372
    res = dc1394_capture_dequeue(dc1394->camera, DC1394_CAPTURE_POLICY_WAIT, &dc1394->frame);
386
373
    if (res == DC1394_SUCCESS) {
387
 
        dc1394->packet.data = (uint8_t *)(dc1394->frame->image);
388
 
        dc1394->packet.pts = (dc1394->current_frame  * 1000000) / (dc1394->frame_rate);
 
374
        dc1394->packet.data = (uint8_t *) dc1394->frame->image;
 
375
        dc1394->packet.pts  = dc1394->current_frame * 1000000 / dc1394->frame_rate;
389
376
        res = dc1394->frame->image_bytes;
390
377
    } else {
391
378
        av_log(c, AV_LOG_ERROR, "DMA capture failed\n");