26 #include <dc1394/dc1394.h>
27 #elif HAVE_LIBDC1394_1
28 #include <libraw1394/raw1394.h>
29 #include <libdc1394/dc1394_control.h>
31 #define DC1394_VIDEO_MODE_320x240_YUV422 MODE_320x240_YUV422
32 #define DC1394_VIDEO_MODE_640x480_YUV411 MODE_640x480_YUV411
33 #define DC1394_VIDEO_MODE_640x480_YUV422 MODE_640x480_YUV422
34 #define DC1394_FRAMERATE_1_875 FRAMERATE_1_875
35 #define DC1394_FRAMERATE_3_75 FRAMERATE_3_75
36 #define DC1394_FRAMERATE_7_5 FRAMERATE_7_5
37 #define DC1394_FRAMERATE_15 FRAMERATE_15
38 #define DC1394_FRAMERATE_30 FRAMERATE_30
39 #define DC1394_FRAMERATE_60 FRAMERATE_60
40 #define DC1394_FRAMERATE_120 FRAMERATE_120
41 #define DC1394_FRAMERATE_240 FRAMERATE_240
57 raw1394handle_t handle;
58 dc1394_cameracapture camera;
60 #elif HAVE_LIBDC1394_2
62 dc1394camera_t *camera;
63 dc1394video_frame_t *
frame;
91 { 1875, DC1394_FRAMERATE_1_875 },
92 { 3750, DC1394_FRAMERATE_3_75 },
93 { 7500, DC1394_FRAMERATE_7_5 },
94 { 15000, DC1394_FRAMERATE_15 },
95 { 30000, DC1394_FRAMERATE_30 },
96 { 60000, DC1394_FRAMERATE_60 },
97 {120000, DC1394_FRAMERATE_120 },
98 {240000, DC1394_FRAMERATE_240 },
102 #define OFFSET(x) offsetof(dc1394_data, x)
103 #define DEC AV_OPT_FLAG_DECODING_PARAM
108 {
"video_size",
"A string describing frame size, such as 640x480 or hd720.",
OFFSET(video_size),
AV_OPT_TYPE_STRING, {.str =
"qvga"}, 0, 0,
DEC },
201 nodeid_t* camera_nodes;
210 dc1394->handle = dc1394_create_handle(0);
211 if (!dc1394->handle) {
215 camera_nodes = dc1394_get_camera_nodes(dc1394->handle, &res, 1);
216 if (!camera_nodes || camera_nodes[dc1394->channel] == DC1394_NO_CAMERA) {
217 av_log(c,
AV_LOG_ERROR,
"There's no IIDC camera on the channel %d\n", dc1394->channel);
220 res = dc1394_dma_setup_capture(dc1394->handle, camera_nodes[dc1394->channel],
222 FORMAT_VGA_NONCOMPRESSED,
228 dc1394_free_camera_nodes(camera_nodes);
229 if (res != DC1394_SUCCESS) {
234 res = dc1394_start_iso_transmission(dc1394->handle, dc1394->camera.node);
235 if (res != DC1394_SUCCESS) {
243 dc1394_dma_unlisten(dc1394->handle, &dc1394->camera);
244 dc1394_dma_release_camera(dc1394->handle, &dc1394->camera);
246 dc1394_destroy_handle(dc1394->handle);
258 if (dc1394_dma_done_with_buffer(&dc1394->camera) != DC1394_SUCCESS)
262 res = dc1394_dma_single_capture(&dc1394->camera);
264 if (res == DC1394_SUCCESS) {
282 dc1394_stop_iso_transmission(dc1394->handle, dc1394->camera.node);
283 dc1394_dma_unlisten(dc1394->handle, &dc1394->camera);
284 dc1394_dma_release_camera(dc1394->handle, &dc1394->camera);
285 dc1394_destroy_handle(dc1394->handle);
290 #elif HAVE_LIBDC1394_2
294 dc1394camera_list_t *list;
303 dc1394->d = dc1394_new();
304 dc1394_camera_enumerate (dc1394->d, &list);
305 if ( !list || list->num == 0) {
311 dc1394->camera = dc1394_camera_new (dc1394->d, list->ids[0].guid);
317 dc1394_camera_free_list (list);
320 if (dc1394->camera->bmode_capable>0) {
321 dc1394_video_set_operation_mode(dc1394->camera, DC1394_OPERATION_MODE_1394B);
322 i = DC1394_ISO_SPEED_800;
324 i = DC1394_ISO_SPEED_400;
327 for (res = DC1394_FAILURE; i >= DC1394_ISO_SPEED_MIN && res != DC1394_SUCCESS; i--) {
328 res=dc1394_video_set_iso_speed(dc1394->camera, i);
330 if (res != DC1394_SUCCESS) {
335 if (dc1394_video_set_mode(dc1394->camera, fmt->
frame_size_id) != DC1394_SUCCESS) {
340 if (dc1394_video_set_framerate(dc1394->camera,fps->
frame_rate_id) != DC1394_SUCCESS) {
344 if (dc1394_capture_setup(dc1394->camera, 10, DC1394_CAPTURE_FLAGS_DEFAULT)!=DC1394_SUCCESS) {
349 if (dc1394_video_set_transmission(dc1394->camera, DC1394_ON) !=DC1394_SUCCESS) {
356 dc1394_capture_stop(dc1394->camera);
357 dc1394_video_set_transmission(dc1394->camera, DC1394_OFF);
358 dc1394_camera_free (dc1394->camera);
360 dc1394_free(dc1394->d);
371 if (dc1394_capture_enqueue(dc1394->camera, dc1394->frame) != DC1394_SUCCESS)
375 res = dc1394_capture_dequeue(dc1394->camera, DC1394_CAPTURE_POLICY_WAIT, &dc1394->frame);
376 if (res == DC1394_SUCCESS) {
379 res = dc1394->frame->image_bytes;
394 dc1394_video_set_transmission(dc1394->camera, DC1394_OFF);
395 dc1394_capture_stop(dc1394->camera);
396 dc1394_camera_free(dc1394->camera);
397 dc1394_free(dc1394->d);
407 .read_packet = dc1394_v2_read_packet,
408 .read_close = dc1394_v2_close,
420 .read_packet = dc1394_v1_read_packet,
421 .read_close = dc1394_v1_close,
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
static enum AVPixelFormat pix_fmt
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
#define LIBAVUTIL_VERSION_INT
int index
stream index in AVFormatContext
static const struct dc1394_frame_format dc1394_frame_formats[]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
char * framerate
Set by a private option.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static const struct dc1394_frame_rate dc1394_frame_rates[]
int flags
A combination of AV_PKT_FLAG values.
AVCodecContext * codec
Codec context associated with this stream.
common internal API header
int bit_rate
the average bitrate
char filename[1024]
input or output filename
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int width
picture width / height.
static int read_header(FFV1Context *f)
char * pixel_format
Set by a private option.
#define AV_LOG_INFO
Standard information.
enum AVMediaType codec_type
static const AVOption options[]
static int dc1394_read_common(AVFormatContext *c, struct dc1394_frame_format **select_fmt, struct dc1394_frame_rate **select_fps)
static const AVClass libdc1394_class
BYTE int const BYTE int int int height
Describe the class of an AVClass context structure.
rational number numerator/denominator
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int frame_rate
frames per 1000 seconds (fps * 1000)
char * video_size
String describing video size, set by a private option.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
void * priv_data
Format private data.
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
Calculate the size in bytes that a picture of the given width and height would occupy if stored in th...
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
AVPixelFormat
Pixel format.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...