Ticket #224: 0001-Remove-support-for-libdc1394-2.0.patch

File 0001-Remove-support-for-libdc1394-2.0.patch, 8.5 KB (added by marlam, 8 years ago)
  • configure

    From 4096bcb4948180d5c42c9e905c8f4fd79daf4f81 Mon Sep 17 00:00:00 2001
    From: Martin Lambers <marlam@marlam.de>
    Date: Mon, 9 May 2011 11:56:52 +0200
    Subject: [PATCH 1/2] Remove support for libdc1394 < 2.0.
    
    Versions >= 2.0 have been around for ages and are even available in Debian *old*stable.
    ---
     configure               |   12 +----
     libavdevice/libdc1394.c |  145 +++--------------------------------------------
     2 files changed, 9 insertions(+), 148 deletions(-)
    
    diff --git a/configure b/configure
    index 165fc26..7a6c4f0 100755
    a b HAVE_LIST=" 
    10771077    isatty
    10781078    kbhit
    10791079    ldbrx
    1080     libdc1394_1
    1081     libdc1394_2
    10821080    llrint
    10831081    llrintf
    10841082    local_aligned_16
    check_mathfunc truncf 
    29012899enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
    29022900enabled libcelt    && require libcelt celt/celt.h celt_decode -lcelt0
    29032901enabled frei0r     && { check_header frei0r.h || die "ERROR: frei0r.h header not found"; }
     2902enabled libdc1394  && require_pkg_config libdc1394-2 dc1394/dc1394.h dc1394_new
    29042903enabled libdirac   && require_pkg_config dirac                          \
    29052904    "libdirac_decoder/dirac_parser.h libdirac_encoder/dirac_encoder.h"  \
    29062905    "dirac_decoder_init dirac_encoder_init"
    enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs 
    29322931enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
    29332932enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
    29342933
    2935 # libdc1394 check
    2936 if enabled libdc1394; then
    2937     { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
    2938         enable libdc1394_2; } ||
    2939     { check_lib libdc1394/dc1394_control.h dc1394_create_handle -ldc1394_control -lraw1394 &&
    2940         enable libdc1394_1; } ||
    2941     die "ERROR: No version of libdc1394 found "
    2942 fi
    2943 
    29442934if check_pkg_config sdl SDL_version.h SDL_Linked_Version; then
    29452935    check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
    29462936    enable sdl &&
  • libavdevice/libdc1394.c

    diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c
    index abd82dc..158db09 100644
    a b  
    22 * IIDC1394 grab interface (uses libdc1394 and libraw1394)
    33 * Copyright (c) 2004 Roman Shaposhnik
    44 * Copyright (c) 2008 Alessandro Sappia
     5 * Copyright (c) 2011 Martin Lambers
    56 *
    67 * This file is part of FFmpeg.
    78 *
     
    2324#include "config.h"
    2425#include "libavformat/avformat.h"
    2526
    26 #if HAVE_LIBDC1394_2
    2727#include <dc1394/dc1394.h>
    28 #elif HAVE_LIBDC1394_1
    29 #include <libraw1394/raw1394.h>
    30 #include <libdc1394/dc1394_control.h>
    31 
    32 #define DC1394_VIDEO_MODE_320x240_YUV422 MODE_320x240_YUV422
    33 #define DC1394_VIDEO_MODE_640x480_YUV411 MODE_640x480_YUV411
    34 #define DC1394_VIDEO_MODE_640x480_YUV422 MODE_640x480_YUV422
    35 #define DC1394_FRAMERATE_1_875 FRAMERATE_1_875
    36 #define DC1394_FRAMERATE_3_75  FRAMERATE_3_75
    37 #define DC1394_FRAMERATE_7_5   FRAMERATE_7_5
    38 #define DC1394_FRAMERATE_15    FRAMERATE_15
    39 #define DC1394_FRAMERATE_30    FRAMERATE_30
    40 #define DC1394_FRAMERATE_60    FRAMERATE_60
    41 #define DC1394_FRAMERATE_120   FRAMERATE_120
    42 #define DC1394_FRAMERATE_240   FRAMERATE_240
    43 #endif
    4428
    4529#undef free
    4630
    4731typedef struct dc1394_data {
    48 #if HAVE_LIBDC1394_1
    49     raw1394handle_t handle;
    50     dc1394_cameracapture camera;
    51 #elif HAVE_LIBDC1394_2
    5232    dc1394_t *d;
    5333    dc1394camera_t *camera;
    5434    dc1394video_frame_t *frame;
    55 #endif
    5635    int current_frame;
    5736    int fps;
    5837
    out: 
    142121    return -1;
    143122}
    144123
    145 #if HAVE_LIBDC1394_1
    146 static int dc1394_v1_read_header(AVFormatContext *c, AVFormatParameters * ap)
    147 {
    148     dc1394_data* dc1394 = c->priv_data;
    149     AVStream* vst;
    150     nodeid_t* camera_nodes;
    151     int res;
    152     struct dc1394_frame_format *fmt = NULL;
    153     struct dc1394_frame_rate *fps = NULL;
    154 
    155     if (dc1394_read_common(c,ap,&fmt,&fps) != 0)
    156         return -1;
    157 
    158     /* Now let us prep the hardware. */
    159     dc1394->handle = dc1394_create_handle(0); /* FIXME: gotta have ap->port */
    160     if (!dc1394->handle) {
    161         av_log(c, AV_LOG_ERROR, "Can't acquire dc1394 handle on port %d\n", 0 /* ap->port */);
    162         goto out;
    163     }
    164     camera_nodes = dc1394_get_camera_nodes(dc1394->handle, &res, 1);
    165     if (!camera_nodes || camera_nodes[ap->channel] == DC1394_NO_CAMERA) {
    166         av_log(c, AV_LOG_ERROR, "There's no IIDC camera on the channel %d\n", ap->channel);
    167         goto out_handle;
    168     }
    169     res = dc1394_dma_setup_capture(dc1394->handle, camera_nodes[ap->channel],
    170                                    0,
    171                                    FORMAT_VGA_NONCOMPRESSED,
    172                                    fmt->frame_size_id,
    173                                    SPEED_400,
    174                                    fps->frame_rate_id, 8, 1,
    175                                    c->filename,
    176                                    &dc1394->camera);
    177     dc1394_free_camera_nodes(camera_nodes);
    178     if (res != DC1394_SUCCESS) {
    179         av_log(c, AV_LOG_ERROR, "Can't prepare camera for the DMA capture\n");
    180         goto out_handle;
    181     }
    182 
    183     res = dc1394_start_iso_transmission(dc1394->handle, dc1394->camera.node);
    184     if (res != DC1394_SUCCESS) {
    185         av_log(c, AV_LOG_ERROR, "Can't start isochronous transmission\n");
    186         goto out_handle_dma;
    187     }
    188 
    189     return 0;
    190 
    191 out_handle_dma:
    192     dc1394_dma_unlisten(dc1394->handle, &dc1394->camera);
    193     dc1394_dma_release_camera(dc1394->handle, &dc1394->camera);
    194 out_handle:
    195     dc1394_destroy_handle(dc1394->handle);
    196 out:
    197     return -1;
    198 }
    199 
    200 static int dc1394_v1_read_packet(AVFormatContext *c, AVPacket *pkt)
    201 {
    202     struct dc1394_data *dc1394 = c->priv_data;
    203     int res;
    204 
    205     /* discard stale frame */
    206     if (dc1394->current_frame++) {
    207         if (dc1394_dma_done_with_buffer(&dc1394->camera) != DC1394_SUCCESS)
    208             av_log(c, AV_LOG_ERROR, "failed to release %d frame\n", dc1394->current_frame);
    209     }
    210 
    211     res = dc1394_dma_single_capture(&dc1394->camera);
    212 
    213     if (res == DC1394_SUCCESS) {
    214         dc1394->packet.data = (uint8_t *)(dc1394->camera.capture_buffer);
    215         dc1394->packet.pts = (dc1394->current_frame * 1000000) / dc1394->fps;
    216         res = dc1394->packet.size;
    217     } else {
    218         av_log(c, AV_LOG_ERROR, "DMA capture failed\n");
    219         dc1394->packet.data = NULL;
    220         res = -1;
    221     }
    222 
    223     *pkt = dc1394->packet;
    224     return res;
    225 }
    226 
    227 static int dc1394_v1_close(AVFormatContext * context)
    228 {
    229     struct dc1394_data *dc1394 = context->priv_data;
    230 
    231     dc1394_stop_iso_transmission(dc1394->handle, dc1394->camera.node);
    232     dc1394_dma_unlisten(dc1394->handle, &dc1394->camera);
    233     dc1394_dma_release_camera(dc1394->handle, &dc1394->camera);
    234     dc1394_destroy_handle(dc1394->handle);
    235 
    236     return 0;
    237 }
    238 
    239 #elif HAVE_LIBDC1394_2
    240 static int dc1394_v2_read_header(AVFormatContext *c, AVFormatParameters * ap)
     124static int dc1394_read_header(AVFormatContext *c, AVFormatParameters * ap)
    241125{
    242126    dc1394_data* dc1394 = c->priv_data;
    243127    dc1394camera_list_t *list;
    out: 
    310194    return -1;
    311195}
    312196
    313 static int dc1394_v2_read_packet(AVFormatContext *c, AVPacket *pkt)
     197static int dc1394_read_packet(AVFormatContext *c, AVPacket *pkt)
    314198{
    315199    struct dc1394_data *dc1394 = c->priv_data;
    316200    int res;
    static int dc1394_v2_read_packet(AVFormatContext *c, AVPacket *pkt) 
    336220    return res;
    337221}
    338222
    339 static int dc1394_v2_close(AVFormatContext * context)
     223static int dc1394_close(AVFormatContext * context)
    340224{
    341225    struct dc1394_data *dc1394 = context->priv_data;
    342226
    static int dc1394_v2_close(AVFormatContext * context) 
    350234
    351235AVInputFormat ff_libdc1394_demuxer = {
    352236    .name           = "libdc1394",
    353     .long_name      = NULL_IF_CONFIG_SMALL("dc1394 v.2 A/V grab"),
    354     .priv_data_size = sizeof(struct dc1394_data),
    355     .read_header    = dc1394_v2_read_header,
    356     .read_packet    = dc1394_v2_read_packet,
    357     .read_close     = dc1394_v2_close,
    358     .flags          = AVFMT_NOFILE
    359 };
    360 
    361 #endif
    362 #if HAVE_LIBDC1394_1
    363 AVInputFormat ff_libdc1394_demuxer = {
    364     .name           = "libdc1394",
    365     .long_name      = NULL_IF_CONFIG_SMALL("dc1394 v.1 A/V grab"),
     237    .long_name      = NULL_IF_CONFIG_SMALL("dc1394 A/V grab"),
    366238    .priv_data_size = sizeof(struct dc1394_data),
    367     .read_header    = dc1394_v1_read_header,
    368     .read_packet    = dc1394_v1_read_packet,
    369     .read_close     = dc1394_v1_close,
     239    .read_header    = dc1394_read_header,
     240    .read_packet    = dc1394_read_packet,
     241    .read_close     = dc1394_close,
    370242    .flags          = AVFMT_NOFILE
    371243};
    372 #endif