Ticket #37833: diff-fix-issue108-ffmpeg-1.1.x-compatibility.patch

File diff-fix-issue108-ffmpeg-1.1.x-compatibility.patch, 15.1 KB (added by andre.dos.anjos@…, 12 years ago)
  • include/bob/daq/Camera.h

    diff --git include/bob/daq/Camera.h include/bob/daq/Camera.h
    index c989732..e40f747 100644
    public: 
    3535  /**
    3636   * Pixel format
    3737   */
    38   enum PixelFormat {
     38  enum CamPixFormat {
    3939    OTHER,
    4040    YUYV,
    4141    MJPEG,
    public: 
    6161     * @param frameNb     frame number
    6262     * @param timestamp   frame timestamp (in seconds)
    6363     */
    64     virtual void imageReceived(unsigned char* image, PixelFormat pixelFormat, int width, int height, int stride, int size, int frameNb, double timestamp) = 0;
     64    virtual void imageReceived(unsigned char* image, CamPixFormat pixelFormat, int width, int height, int stride, int size, int frameNb, double timestamp) = 0;
    6565  };
    6666
    6767  /**
    public: 
    134134   * @param[out] pixelFormats supported pixel formats
    135135   * @return 0 on success
    136136   */
    137   virtual int getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) = 0;
     137  virtual int getSupportedCamPixFormats(std::vector<CamPixFormat>& pixelFormats) = 0;
    138138 
    139139  /**
    140140   * Get the list of supported frame sizes for a pixel format
    public: 
    143143   * @param[out] frameSizes supported frame sizes
    144144   * @return 0 on success
    145145   */
    146   virtual int getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes) = 0;
     146  virtual int getSupportedFrameSizes(CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes) = 0;
    147147 
    148148  /**
    149149   * Get the list of supported frame intervals for a pixel format and a frame size
    public: 
    153153   * @param[out] frameIntervals supported frame intervals
    154154   * @return 0 on success
    155155   */
    156   virtual int getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals) = 0;
     156  virtual int getSupportedFrameIntervals(CamPixFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals) = 0;
    157157
    158   virtual PixelFormat getPixelFormat() const = 0;
    159   virtual void setPixelFormat(PixelFormat pixelFormat) = 0;
     158  virtual CamPixFormat getCamPixFormat() const = 0;
     159  virtual void setCamPixFormat(CamPixFormat pixelFormat) = 0;
    160160 
    161161  virtual FrameSize getFrameSize() const = 0;
    162162  virtual void setFrameSize(FrameSize& frameSize) = 0;
  • include/bob/daq/SimpleController.h

    diff --git include/bob/daq/SimpleController.h include/bob/daq/SimpleController.h
    index ead7fa7..0c22413 100644
    public: 
    3434  virtual ~SimpleController();
    3535 
    3636  virtual void keyPressed(int key);
    37   virtual void imageReceived(unsigned char* image, Camera::PixelFormat pixelformat, int width, int height, int stride, int size, int frameNb, double timestamp);
     37  virtual void imageReceived(unsigned char* image, Camera::CamPixFormat pixelformat, int width, int height, int stride, int size, int frameNb, double timestamp);
    3838
    3939  void stop();
    4040 
  • include/bob/daq/V4LCamera.h

    diff --git include/bob/daq/V4LCamera.h include/bob/daq/V4LCamera.h
    index 5c5e79a..068cbf1 100644
    public: 
    4343  void stop();
    4444  void wait();
    4545
    46   int getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats);
    47   int getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes);
    48   int getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals);
     46  int getSupportedCamPixFormats(std::vector<CamPixFormat>& pixelFormats);
     47  int getSupportedFrameSizes(CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes);
     48  int getSupportedFrameIntervals(CamPixFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals);
    4949
    50   PixelFormat getPixelFormat() const;
    51   void setPixelFormat(PixelFormat pixelFormat);
     50  CamPixFormat getCamPixFormat() const;
     51  void setCamPixFormat(CamPixFormat pixelFormat);
    5252 
    5353  FrameSize getFrameSize() const;
    5454  void setFrameSize(FrameSize& frameSize);
  • include/bob/daq/VideoReaderCamera.h

    diff --git include/bob/daq/VideoReaderCamera.h include/bob/daq/VideoReaderCamera.h
    index a88a0c5..31b597c 100644
    public: 
    4040  void stop();
    4141  void wait();
    4242
    43   int getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats);
    44   int getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes);
    45   int getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals);
     43  int getSupportedCamPixFormats(std::vector<Camera::CamPixFormat>& pixelFormats);
     44  int getSupportedFrameSizes(Camera::CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes);
     45  int getSupportedFrameIntervals(Camera::CamPixFormat pixelFormat, FrameSize& frameSize, std::vector<FrameInterval>& frameIntervals);
    4646
    47   PixelFormat getPixelFormat() const;
    48   void setPixelFormat(PixelFormat pixelFormat);
     47  Camera::CamPixFormat getCamPixFormat() const;
     48  void setCamPixFormat(Camera::CamPixFormat pixelFormat);
    4949 
    5050  FrameSize getFrameSize() const;
    5151  void setFrameSize(FrameSize& frameSize);
  • src/daq/cxx/SimpleController.cc

    diff --git src/daq/cxx/SimpleController.cc src/daq/cxx/SimpleController.cc
    index 9689cb9..3899a59 100644
    static void jpeg_mem_src(j_decompress_ptr cinfo, void* buffer, long nbytes) 
    247247}
    248248//////////////////////////////////////////////////////////////////////////////
    249249
    250 void SimpleController::imageReceived(unsigned char* image, Camera::PixelFormat pixelFormat,
     250void SimpleController::imageReceived(unsigned char* image, Camera::CamPixFormat pixelFormat,
    251251                                    int width, int height, int stride, int size, int frameNb, double timestamp) {
    252252  ControllerCallback::CaptureStatus status;
    253253  status.totalSessionTime = length + recordingDelay;
  • src/daq/cxx/V4LCamera.cc

    diff --git src/daq/cxx/V4LCamera.cc src/daq/cxx/V4LCamera.cc
    index 531b547..6a56e05 100644
    int V4LCamera::open() { 
    292292}
    293293
    294294/**
    295  * Convert v4l2 pixel format to Camera::PixelFormat
     295 * Convert v4l2 pixel format to Camera::CamPixFormat
    296296 */
    297 Camera::PixelFormat convertPixelFormat(unsigned int v4l2_pixelFormat) {
     297Camera::CamPixFormat convertCamPixFormat(unsigned int v4l2_pixelFormat) {
    298298  switch (v4l2_pixelFormat) {
    299299    case V4L2_PIX_FMT_YUYV:
    300300      return Camera::YUYV;
    Camera::PixelFormat convertPixelFormat(unsigned int v4l2_pixelFormat) { 
    308308}
    309309
    310310/**
    311  * Convert Camera::PixelFormat to v4l2 pixel format
     311 * Convert Camera::CamPixFormat to v4l2 pixel format
    312312 */
    313 unsigned int convertPixelFormat(Camera::PixelFormat pixelFormat) {
     313unsigned int convertCamPixFormat(Camera::CamPixFormat pixelFormat) {
    314314  switch (pixelFormat) {
    315315    case Camera::YUYV:
    316316      return V4L2_PIX_FMT_YUYV;
    unsigned int convertPixelFormat(Camera::PixelFormat pixelFormat) { 
    327327  }
    328328}
    329329
    330 int V4LCamera::getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) {
     330int V4LCamera::getSupportedCamPixFormats(std::vector<CamPixFormat>& pixelFormats) {
    331331  if (v4lstruct->opened) {
    332332    pixelFormats.clear();
    333333   
    int V4LCamera::getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) 
    337337    fmtdesc.index = 0;
    338338
    339339    while (xioctl(v4lstruct->device, VIDIOC_ENUM_FMT, &fmtdesc) != -1) {
    340       pixelFormats.push_back(convertPixelFormat(fmtdesc.pixelformat));
     340      pixelFormats.push_back(convertCamPixFormat(fmtdesc.pixelformat));
    341341      fmtdesc.index++;
    342342    }
    343343  }
    int V4LCamera::getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) 
    345345  return 0;
    346346}
    347347
    348 int V4LCamera::getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes) {
     348int V4LCamera::getSupportedFrameSizes(CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes) {
    349349  if (v4lstruct->opened) {
    350350    frameSizes.clear();
    351351   
    352352    v4l2_frmsizeenum frmsizeenum;
    353353    memset(&frmsizeenum, 0, sizeof(v4l2_frmsizeenum));
    354     frmsizeenum.pixel_format = convertPixelFormat(pixelFormat);
     354    frmsizeenum.pixel_format = convertCamPixFormat(pixelFormat);
    355355    frmsizeenum.index = 0;
    356356   
    357357    while (xioctl(v4lstruct->device, VIDIOC_ENUM_FRAMESIZES, &frmsizeenum) != -1) {
    int V4LCamera::getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<Frame 
    369369  return 0;
    370370}
    371371
    372 int V4LCamera::getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize,
     372int V4LCamera::getSupportedFrameIntervals(CamPixFormat pixelFormat, FrameSize& frameSize,
    373373                                         std::vector<FrameInterval>& frameIntervals) {
    374374  if (v4lstruct->opened) {
    375375    v4l2_frmivalenum frmivalenum;
    376376    memset(&frmivalenum, 0, sizeof(v4l2_frmivalenum));
    377     frmivalenum.pixel_format = convertPixelFormat(pixelFormat);
     377    frmivalenum.pixel_format = convertCamPixFormat(pixelFormat);
    378378    frmivalenum.height = frameSize.height;
    379379    frmivalenum.width = frameSize.width;
    380380    frmivalenum.index = 0;
    int V4LCamera::getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& fr 
    394394  return 0;
    395395}
    396396
    397 Camera::PixelFormat V4LCamera::getPixelFormat() const {
     397Camera::CamPixFormat V4LCamera::getCamPixFormat() const {
    398398  if (v4lstruct->opened) {
    399     return convertPixelFormat(v4lstruct->format.pixelformat);
     399    return convertCamPixFormat(v4lstruct->format.pixelformat);
    400400  }
    401401  else {
    402402    return Camera::OTHER;
    403403  }
    404404}
    405405
    406 void V4LCamera::setPixelFormat(PixelFormat pixelFormat) {
     406void V4LCamera::setCamPixFormat(CamPixFormat pixelFormat) {
    407407  if (v4lstruct->opened) {
    408408    v4l2_format format;
    409409    memset(&format, 0, sizeof(v4l2_format));
    410410    format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    411411    format.fmt.pix = v4lstruct->format;
    412412
    413     format.fmt.pix.pixelformat = convertPixelFormat(pixelFormat);
     413    format.fmt.pix.pixelformat = convertCamPixFormat(pixelFormat);
    414414
    415415    if (xioctl(v4lstruct->device, VIDIOC_S_FMT, &format) == -1) {
    416416      perror("Error setting parameters (VIDIOC_S_FMT)");
    int V4LCamera::start() { 
    601601
    602602
    603603void V4LCamera::captureLoop() {
    604   const PixelFormat pixelformat = getPixelFormat();
     604  const CamPixFormat pixelformat = getCamPixFormat();
    605605 
    606606  while(!mustStop) {
    607607    // Select manpage say that we can't trust the value of timeout after
  • src/daq/cxx/VideoReaderCamera.cc

    diff --git src/daq/cxx/VideoReaderCamera.cc src/daq/cxx/VideoReaderCamera.cc
    index f87d5d0..7682a0e 100644
    void VideoReaderCamera::printSummary() { 
    105105  bob::core::info << videoReader->info().c_str() << std::endl;
    106106}
    107107
    108 Camera::PixelFormat VideoReaderCamera::getPixelFormat() const {
    109   return RGB24;
     108Camera::CamPixFormat VideoReaderCamera::getCamPixFormat() const {
     109  return Camera::RGB24;
    110110}
    111111
    112 void VideoReaderCamera::setPixelFormat(Camera::PixelFormat pixelFormat) {
     112void VideoReaderCamera::setCamPixFormat(Camera::CamPixFormat pixelFormat) {
    113113  return;
    114114}
    115115
    void VideoReaderCamera::setFrameInterval(Camera::FrameInterval& frameInterval) { 
    129129  return;
    130130}
    131131
    132 int VideoReaderCamera::getSupportedPixelFormats(std::vector<PixelFormat>& pixelFormats) {
     132int VideoReaderCamera::getSupportedCamPixFormats(std::vector<Camera::CamPixFormat>& pixelFormats) {
    133133  pixelFormats.clear();;
    134   pixelFormats.push_back(getPixelFormat());
     134  pixelFormats.push_back(getCamPixFormat());
    135135
    136136  return 0;
    137137}
    138138
    139 int VideoReaderCamera::getSupportedFrameSizes(PixelFormat pixelFormat, std::vector<FrameSize>& frameSizes) {
     139int VideoReaderCamera::getSupportedFrameSizes(Camera::CamPixFormat pixelFormat, std::vector<FrameSize>& frameSizes) {
    140140  frameSizes.clear();
    141   if (pixelFormat == getPixelFormat()) {
     141  if (pixelFormat == getCamPixFormat()) {
    142142    frameSizes.push_back(getFrameSize());
    143143  }
    144144
    145145  return 0;
    146146}
    147147
    148 int VideoReaderCamera::getSupportedFrameIntervals(PixelFormat pixelFormat, FrameSize& frameSize,
     148int VideoReaderCamera::getSupportedFrameIntervals(Camera::CamPixFormat pixelFormat, FrameSize& frameSize,
    149149                                         std::vector<FrameInterval>& frameIntervals) {
    150150  frameIntervals.clear();
    151   if (pixelFormat == getPixelFormat() && frameSize == getFrameSize()) {
     151  if (pixelFormat == getCamPixFormat() && frameSize == getFrameSize()) {
    152152    frameIntervals.push_back(getFrameInterval());
    153153  }
    154154 
  • src/daq/python/all.cc

    diff --git src/daq/python/all.cc src/daq/python/all.cc
    index 640e47b..3b4c4fa 100644
     
    4545
    4646using namespace bob::daq;
    4747
    48 static boost::python::object getSupportedPixelFormats(Camera& cam) {
    49   std::vector<Camera::PixelFormat> pfs;
    50   cam.getSupportedPixelFormats(pfs);
     48static boost::python::object getSupportedCamPixFormats(Camera& cam) {
     49  std::vector<Camera::CamPixFormat> pfs;
     50  cam.getSupportedCamPixFormats(pfs);
    5151
    5252  boost::python::list l;
    5353
    static boost::python::object getSupportedPixelFormats(Camera& cam) { 
    5858  return l;
    5959}
    6060
    61 static boost::python::object getSupportedFrameSizes(Camera& cam, Camera::PixelFormat pf) {
     61static boost::python::object getSupportedFrameSizes(Camera& cam, Camera::CamPixFormat pf) {
    6262  std::vector<Camera::FrameSize> vec;
    6363  cam.getSupportedFrameSizes(pf, vec);
    6464
    static boost::python::object getSupportedFrameSizes(Camera& cam, Camera::PixelFo 
    7171  return l;
    7272}
    7373
    74 static boost::python::object getSupportedFrameIntervals(Camera& cam, Camera::PixelFormat pf, Camera::FrameSize& fs) {
     74static boost::python::object getSupportedFrameIntervals(Camera& cam, Camera::CamPixFormat pf, Camera::FrameSize& fs) {
    7575  std::vector<Camera::FrameInterval> vec;
    7676  cam.getSupportedFrameIntervals(pf, fs, vec);
    7777
    void bind_daq_all() { 
    169169    .def("on_detection", &FaceLocalizationCallback::onDetection, (arg("boundingbox")));
    170170   
    171171  /// Cameras
    172   enum_<Camera::PixelFormat>("PixelFormat")
     172  enum_<Camera::CamPixFormat>("PixelFormat")
    173173    .value("YUYV", Camera::YUYV)
    174174    .value("MJPEG", Camera::MJPEG)
    175175    .value("RGB24", Camera::RGB24)
    void bind_daq_all() { 
    192192    .def("start", &Camera_start, (arg("self")))
    193193    .def("add_camera_callback", &Camera::addCameraCallback, (arg("self"), arg("callback")))
    194194    .def("remove_camera_callback", &Camera::removeCameraCallback, (arg("self"), arg("callback")))
    195     .def("get_supported_pixel_formats", &getSupportedPixelFormats, (arg("self")), "Get the list of supported pixel formats")
     195    .def("get_supported_pixel_formats", &getSupportedCamPixFormats, (arg("self")), "Get the list of supported pixel formats")
    196196    .def("get_supported_frame_sizes", &getSupportedFrameSizes, (arg("self"), arg("pixel_format")), "Get the list of supported frame sizes for a pixel format")
    197197    .def("get_supported_frame_intervals", &getSupportedFrameIntervals, (arg("self"), arg("pixel_format"), arg("frame_size")), "Get the list of supported frame intervals for a pixel format and a frame size")
    198     .add_property("pixel_format", &Camera::getPixelFormat, &Camera::setPixelFormat)
     198    .add_property("pixel_format", &Camera::getCamPixFormat, &Camera::setCamPixFormat)
    199199    .add_property("frame_size", &Camera::getFrameSize, &Camera::setFrameSize)
    200200    .add_property("frame_interval", &Camera::getFrameInterval, &Camera::setFrameInterval)
    201201    .def("print_summary", &Camera::printSummary, (arg("self")), "Print information about the device");