Changeset b5de3a9


Ignore:
Timestamp:
Dec 16, 2018, 7:08:15 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/timestretch, fix/ffmpeg5, master
Children:
4eb48e6
Parents:
b5bd70c
Message:

[io] add helpers to validate input

Location:
src/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/io/ioutils.c

    rb5bd70c rb5de3a9  
    5252  return AUBIO_OK;
    5353}
     54
     55uint_t
     56aubio_sink_validate_input_length(const char_t *kind, const char_t *path,
     57    uint_t max_size, uint_t write_data_length, uint_t write)
     58{
     59  uint_t can_write = write;
     60
     61  if (write > max_size) {
     62    AUBIO_WRN("%s: partial write to %s, trying to write %d frames,"
     63        " at most %d can be written at once\n", kind, path, write, max_size);
     64    can_write = max_size;
     65  }
     66
     67  if (can_write > write_data_length) {
     68    AUBIO_WRN("%s: partial write to %s, trying to write %d frames,"
     69        " but found input of length %d\n", kind, path, write,
     70        write_data_length);
     71    can_write = write_data_length;
     72  }
     73
     74  return can_write;
     75}
     76
     77uint_t
     78aubio_sink_validate_input_channels(const char_t *kind, const char_t *path,
     79    uint_t sink_channels, uint_t write_data_height)
     80{
     81  uint_t channels = sink_channels;
     82  if (write_data_height < sink_channels) {
     83    AUBIO_WRN("%s: partial write to %s, trying to write %d channels,"
     84        " but found input of height %d\n", kind, path, sink_channels,
     85        write_data_height);
     86    channels = write_data_height;
     87  }
     88  return channels;
     89}
  • src/io/ioutils.h

    rb5bd70c rb5de3a9  
    5454    uint_t channels);
    5555
     56/** validate length of input
     57
     58  \param kind       the object kind to report on
     59  \param path       the path to report on
     60  \param max_size   maximum number of frames that can be written
     61  \param write_data_length actual length of input vector/matrix
     62  \param write number of samples asked
     63
     64  \return write or the maximum number of frames that can be written
     65*/
     66uint_t
     67aubio_sink_validate_input_length(const char_t *kind, const char_t *path,
     68    uint_t max_size, uint_t write_data_length, uint_t write);
     69
     70/** validate height of input
     71
     72  \param kind       the object kind to report on
     73  \param path       the path to report on
     74  \param max_size   maximum number of channels that can be written
     75  \param write_data_height actual height of input matrix
     76
     77  \return write_data_height or the maximum number of channels
     78*/
     79uint_t
     80aubio_sink_validate_input_channels(const char_t *kind, const char_t *path,
     81    uint_t sink_channels, uint_t write_data_height);
     82
    5683#ifdef __cplusplus
    5784}
Note: See TracChangeset for help on using the changeset viewer.