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 },
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 },
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);
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);
144
#if FF_API_FORMAT_PARAMETERS
150
pix_fmt = ap->pix_fmt;
151
if (ap->time_base.num)
152
framerate = (AVRational){ap->time_base.den, ap->time_base.num};
154
146
dc1394->frame_rate = av_rescale(1000, framerate.num, framerate.den);
156
148
for (fmt = dc1394_frame_formats; fmt->width; fmt++)
171
163
/* create a video stream */
172
vst = av_new_stream(c, 0);
164
vst = avformat_new_stream(c, NULL);
174
166
ret = AVERROR(ENOMEM);
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)
214
#if FF_API_FORMAT_PARAMETERS
216
dc1394->channel = ap->channel;
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) {
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;
391
378
av_log(c, AV_LOG_ERROR, "DMA capture failed\n");