Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ static int catch_uref(struct uprobe *uprobe, struct upipe *upipe,
if (dump_size) {
size_t size = 0, vsize = 0;
uint8_t sample_size = 0;
uint16_t sound_sample_size = 0;
if (ubase_check(uref_block_size(uref, &size)))
upipe_dbg_va(upipe, "block size %zu", size);
else if (ubase_check(uref_sound_size(uref, &size, &sample_size)))
upipe_dbg_va(upipe, "sound size %zu (sample %u)", size, sample_size);
else if (ubase_check(uref_sound_size(uref, &size, &sound_sample_size)))
upipe_dbg_va(upipe, "sound size %zu (sample %u)", size, sound_sample_size);
else if (ubase_check(uref_pic_size(uref, &size, &vsize, &sample_size)))
upipe_dbg_va(upipe, "pic size %zux%zu (sample %u)",
size, vsize, sample_size);
Expand Down
8 changes: 4 additions & 4 deletions include/upipe/ubuf_sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static inline struct ubuf *ubuf_sound_alloc(struct ubuf_mgr *mgr, int size)
* @return an error code
*/
static inline int ubuf_sound_size(struct ubuf *ubuf, size_t *size_p,
uint8_t *sample_size_p)
uint16_t *sample_size_p)
{
return ubuf_control(ubuf, UBUF_SIZE_SOUND, size_p, sample_size_p);
}
Expand Down Expand Up @@ -266,7 +266,7 @@ static inline struct ubuf *ubuf_sound_copy(struct ubuf_mgr *mgr,
int skip, int new_size)
{
size_t ubuf_size;
uint8_t sample_size;
uint16_t sample_size;
if (unlikely(!ubase_check(ubuf_sound_size(ubuf, &ubuf_size, &sample_size))
|| skip >= (int)ubuf_size))
return NULL;
Expand All @@ -281,7 +281,7 @@ static inline struct ubuf *ubuf_sound_copy(struct ubuf_mgr *mgr,
if (unlikely(new_ubuf == NULL))
return NULL;

uint8_t new_sample_size;
uint16_t new_sample_size;
int extract_offset, extract_skip;
int extract_size;
if (unlikely(!ubase_check(ubuf_sound_size(new_ubuf, NULL,
Expand Down Expand Up @@ -345,7 +345,7 @@ static inline struct ubuf *ubuf_sound_copy(struct ubuf_mgr *mgr,
*/
static inline int ubuf_sound_interleave(struct ubuf *ubuf, uint8_t *buf,
int offset, int samples,
uint8_t sample_size, uint8_t planes)
uint16_t sample_size, uint8_t planes)
{
int i, j, k;
const uint8_t *buffers_p[planes];
Expand Down
6 changes: 3 additions & 3 deletions include/upipe/ubuf_sound_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct ubuf_sound_common_mgr_plane {
* members, common to sound managers. */
struct ubuf_sound_common_mgr {
/** number of octets per plane in a sample */
uint8_t sample_size;
uint16_t sample_size;
/** number of planes to allocate */
uint8_t nb_planes;
/** planes description */
Expand Down Expand Up @@ -178,7 +178,7 @@ int ubuf_sound_common_plane_dup(struct ubuf *ubuf, struct ubuf *new_ubuf,
* @return an error code
*/
int ubuf_sound_common_size(struct ubuf *ubuf, size_t *size_p,
uint8_t *sample_size_p);
uint16_t *sample_size_p);

/** @This iterates on sound planes channel types. Start by initializing
* *channel_p to NULL. If *channel_p is NULL after running this function, there
Expand Down Expand Up @@ -232,7 +232,7 @@ void ubuf_sound_common_mgr_clean(struct ubuf_mgr *mgr);
* ubuf_sound_common_mgr
* @param sample_size size in octets of a sample
*/
void ubuf_sound_common_mgr_init(struct ubuf_mgr *mgr, uint8_t sample_size);
void ubuf_sound_common_mgr_init(struct ubuf_mgr *mgr, uint16_t sample_size);

/** @This adds a new plane to a ubuf manager for sound formats.
*
Expand Down
2 changes: 1 addition & 1 deletion include/upipe/ubuf_sound_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static inline int ubuf_sound_mem_get_shared(struct ubuf *ubuf,
struct ubuf_mgr *ubuf_sound_mem_mgr_alloc(uint16_t ubuf_pool_depth,
uint16_t shared_pool_depth,
struct umem_mgr *umem_mgr,
uint8_t sample_size,
uint16_t sample_size,
uint64_t align);

/** @This adds a new plane to a ubuf manager for sound formats using umem.
Expand Down
4 changes: 2 additions & 2 deletions include/upipe/uref_sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static inline struct uref *uref_sound_alloc(struct uref_mgr *uref_mgr,

/** @see ubuf_sound_size */
static inline int uref_sound_size(struct uref *uref, size_t *size_p,
uint8_t *sample_size_p)
uint16_t *sample_size_p)
{
if (uref->ubuf == NULL)
return UBASE_ERR_INVALID;
Expand Down Expand Up @@ -159,7 +159,7 @@ static inline int uref_sound_resize(struct uref *uref, int skip, int new_size)
/** @see ubuf_sound_interleave */
static inline int uref_sound_interleave(struct uref *uref, uint8_t *buf,
int offset, int samples,
uint8_t sample_size, uint8_t planes)
uint16_t sample_size, uint8_t planes)
{
if (uref->ubuf == NULL)
return UBASE_ERR_INVALID;
Expand Down
51 changes: 48 additions & 3 deletions include/upipe/uref_sound_flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,52 @@ UREF_ATTR_SMALL_UNSIGNED(sound_flow, planes, "s.planes", number of planes)
UREF_ATTR_STRING_VA(sound_flow, channel, "s.channel[%" PRIu8"]",
channel type, uint8_t plane, plane)
UREF_ATTR_SMALL_UNSIGNED(sound_flow, channels, "s.channels", number of channels)
UREF_ATTR_SMALL_UNSIGNED(sound_flow, sample_size, "s.sample_size",
UREF_ATTR_UNSIGNED(sound_flow, sample_size_storage, "s.sample_size",
size in octets of a sample of an audio plane)
static inline int uref_sound_flow_get_sample_size(struct uref *uref,
uint16_t *p)
{
uint64_t v;
UBASE_RETURN(uref_sound_flow_get_sample_size_storage(uref, &v));
*p = (uint16_t)v;
return UBASE_ERR_NONE;
}
static inline int uref_sound_flow_set_sample_size(struct uref *uref,
uint16_t v)
{
return uref_sound_flow_set_sample_size_storage(uref, v);
}
static UBASE_UNUSED inline int
uref_sound_flow_delete_sample_size(struct uref *uref)
{
return uref_sound_flow_delete_sample_size_storage(uref);
}
static UBASE_UNUSED inline int
uref_sound_flow_copy_sample_size(struct uref *uref, struct uref *uref_src)
{
return uref_sound_flow_copy_sample_size_storage(uref, uref_src);
}
static UBASE_UNUSED inline int
uref_sound_flow_match_sample_size(struct uref *uref,
uint16_t min, uint16_t max)
{
uint64_t v;
UBASE_RETURN(uref_sound_flow_get_sample_size_storage(uref, &v));
return (v >= min) && (v <= max) ? UBASE_ERR_NONE : UBASE_ERR_INVALID;
}
static UBASE_UNUSED inline int
uref_sound_flow_cmp_sample_size(struct uref *uref1, struct uref *uref2)
{
uint64_t v1 = 0, v2 = 0;
int err1 = uref_sound_flow_get_sample_size_storage(uref1, &v1);
int err2 = uref_sound_flow_get_sample_size_storage(uref2, &v2);
if (!ubase_check(err1) && !ubase_check(err2))
return 0;
if (!ubase_check(err1) || !ubase_check(err2))
return -1;
return (int64_t)v1 - (int64_t)v2 < 0 ? -1 :
(int64_t)v1 - (int64_t)v2 > 0 ? 1 : 0;
}
UREF_ATTR_SMALL_UNSIGNED(sound_flow, raw_sample_size, "s.sample_bits",
size in bits of an audio sample)
UREF_ATTR_UNSIGNED(sound_flow, rate, "s.rate", samples per second)
Expand All @@ -51,7 +95,7 @@ UREF_ATTR_SMALL_UNSIGNED(sound_flow, channel_idx, "s.channel_index", index of fi
static inline struct uref *uref_sound_flow_alloc_def(struct uref_mgr *mgr,
const char *format,
uint8_t channels,
uint8_t sample_size)
uint16_t sample_size)
{
struct uref *uref = uref_alloc_control(mgr);
if (unlikely(uref == NULL)) return NULL;
Expand Down Expand Up @@ -135,7 +179,8 @@ static inline int uref_sound_flow_copy_format(struct uref *uref_dst,
struct uref *uref_src)
{
const char *def;
uint8_t planes, sample_size;
uint8_t planes;
uint16_t sample_size;
UBASE_RETURN(uref_flow_get_def(uref_src, &def))
UBASE_RETURN(uref_flow_set_def(uref_dst, def))
UBASE_RETURN(uref_sound_flow_get_sample_size(uref_src, &sample_size))
Expand Down
2 changes: 1 addition & 1 deletion include/upipe/uref_sound_flow_formats.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct uref_sound_flow_format {
/** name */
const char *name;
/** sample size */
uint8_t sample_size;
uint16_t sample_size;
/** format is planar? */
bool planar;
};
Expand Down
12 changes: 6 additions & 6 deletions lib/upipe-av/ubuf_av.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,11 @@ static int ubuf_pic_av_plane_unmap(struct ubuf *ubuf,
* @return an error code
*/
static int ubuf_sound_av_sample_size(struct ubuf *ubuf,
uint8_t *sample_size_p)
uint16_t *sample_size_p)
{
struct ubuf_av *ubuf_av = ubuf_av_from_ubuf(ubuf);
struct ubuf_sound_av *ubuf_sound_av = ubuf_av_to_ubuf_sound_av(ubuf_av);
uint8_t sample_size = ubuf_sound_av->flow_format->sample_size;
uint16_t sample_size = ubuf_sound_av->flow_format->sample_size;

if (!ubuf_sound_av->flow_format->planar)
sample_size *= ubuf_av->frame->ch_layout.nb_channels;
Expand All @@ -650,7 +650,7 @@ static int ubuf_sound_av_sample_size(struct ubuf *ubuf,
*/
static int ubuf_sound_av_size(struct ubuf *ubuf,
size_t *size_p,
uint8_t *sample_size_p)
uint16_t *sample_size_p)
{
struct ubuf_av *ubuf_av = ubuf_av_from_ubuf(ubuf);
struct ubuf_sound_av *ubuf_sound_av = ubuf_av_to_ubuf_sound_av(ubuf_av);
Expand Down Expand Up @@ -709,7 +709,7 @@ static int ubuf_sound_av_resize(struct ubuf *ubuf, int offset, int new_size)
AVFrame *frame = ubuf_av->frame;

size_t size;
uint8_t sample_size;
uint16_t sample_size;
UBASE_RETURN(ubuf_sound_av_size(ubuf, &size, &sample_size));

if (offset < 0) {
Expand Down Expand Up @@ -796,7 +796,7 @@ static int ubuf_sound_av_plane_map(struct ubuf *ubuf, const char *channel,
UBASE_RETURN(ubuf_sound_av_get_channel_id(ubuf, channel, &channel_id));

size_t samples;
uint8_t sample_size;
uint16_t sample_size;
UBASE_RETURN(ubuf_sound_av_size(ubuf, &samples, &sample_size));

if (offset < 0)
Expand Down Expand Up @@ -923,7 +923,7 @@ static int ubuf_av_control(struct ubuf *ubuf, int command, va_list args)

case UBUF_SIZE_SOUND: {
size_t *size_p = va_arg(args, size_t *);
uint8_t *sample_size_p = va_arg(args, uint8_t *);
uint16_t *sample_size_p = va_arg(args, uint16_t *);
return ubuf_sound_av_size(ubuf, size_p, sample_size_p);
}
case UBUF_ITERATE_SOUND_PLANE: {
Expand Down
2 changes: 1 addition & 1 deletion lib/upipe-av/upipe_avfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ static int upipe_avfilt_avframe_from_uref_sound(struct upipe *upipe,
goto inval;

size_t size;
uint8_t sample_size;
uint16_t sample_size;
UBASE_RETURN(uref_sound_size(uref, &size, &sample_size));

unsigned i = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/upipe-blackmagic/ubuf_sound_blackmagic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static int ubuf_sound_bmd_control(struct ubuf *ubuf, int command, va_list args)
}
case UBUF_SIZE_SOUND: {
size_t *size_p = va_arg(args, size_t *);
uint8_t *sample_size_p = va_arg(args, uint8_t *);
uint16_t *sample_size_p = va_arg(args, uint16_t *);
return ubuf_sound_common_size(ubuf, size_p, sample_size_p);
}
case UBUF_ITERATE_SOUND_PLANE: {
Expand Down
2 changes: 1 addition & 1 deletion lib/upipe-ebur128/upipe_ebur128.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static void upipe_ebur128_input(struct upipe *upipe, struct uref *uref,
}

size_t samples;
uint8_t sample_size;
uint16_t sample_size;
if (unlikely(!ubase_check(uref_sound_size(uref, &samples, &sample_size)))) {
upipe_warn(upipe, "invalid sound buffer");
uref_free(uref);
Expand Down
3 changes: 2 additions & 1 deletion lib/upipe-filters/upipe_audio_max.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ static int upipe_amax_provide_flow_format(struct upipe *upipe,
struct uref *flow = uref_dup(request->uref);
UBASE_ALLOC_RETURN(flow);

uint8_t planes, channels, sample_size;
uint8_t planes, channels;
uint16_t sample_size;
const char *channels_names;
if (ubase_check(uref_sound_flow_get_planes(request->uref, &planes)) &&
ubase_check(uref_sound_flow_get_channels(request->uref, &channels)) &&
Expand Down
5 changes: 3 additions & 2 deletions lib/upipe-modules/upipe_audio_blank.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ static void upipe_ablk_free(struct upipe *upipe)
static int upipe_ablk_check_flow_def(struct upipe *upipe,
struct uref *flow_def)
{
uint8_t planes, sample_size, channels;
uint8_t planes, channels;
uint16_t sample_size;
uint64_t rate, samples;

UBASE_RETURN(uref_flow_match_def(flow_def, UREF_SOUND_FLOW_DEF));
Expand Down Expand Up @@ -186,7 +187,7 @@ static void upipe_ablk_input(struct upipe *upipe,
upipe_verbose(upipe, "allocate blank sound");

uint64_t samples = 0;
uint8_t sample_size = 0;
uint16_t sample_size = 0;
uref_sound_flow_get_samples(flow_def, &samples);
uref_sound_flow_get_sample_size(flow_def, &sample_size);

Expand Down
8 changes: 4 additions & 4 deletions lib/upipe-modules/upipe_audio_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct upipe_audio_copy {
/** input sample rate */
uint64_t samplerate;
/** sample size */
uint8_t sample_size;
uint16_t sample_size;
/** input planes */
uint8_t planes;
/** remain from previous output */
Expand Down Expand Up @@ -228,7 +228,7 @@ static int upipe_audio_copy_set_flow_def_real(struct upipe *upipe,

uint64_t rate = 0;
uint8_t planes = 0;
uint8_t sample_size = 0;
uint16_t sample_size = 0;
uint64_t input_latency = 0;
uref_sound_flow_get_rate(flow_def, &rate);
uref_sound_flow_get_planes(flow_def, &planes);
Expand Down Expand Up @@ -447,7 +447,7 @@ static bool upipe_audio_copy_handle(struct upipe *upipe,
struct upipe_audio_copy *upipe_audio_copy =
upipe_audio_copy_from_upipe(upipe);
size_t size;
uint8_t sample_size;
uint16_t sample_size;

if (unlikely(ubase_check(uref_flow_get_def(uref, NULL)))) {
upipe_audio_copy_set_flow_def_real(upipe, uref);
Expand Down Expand Up @@ -510,7 +510,7 @@ static int upipe_audio_copy_set_flow_def(struct upipe *upipe,
{
uint64_t rate = 0;
uint8_t planes = 0;
uint8_t sample_size = 0;
uint16_t sample_size = 0;

UBASE_RETURN(uref_flow_match_def(flow_def, EXPECTED_FLOW_DEF));
UBASE_RETURN(uref_sound_flow_get_rate(flow_def, &rate));
Expand Down
10 changes: 5 additions & 5 deletions lib/upipe-modules/upipe_audio_merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ static void upipe_audio_merge_copy_to_output(struct upipe *upipe, uint8_t **out_
upipe_err(upipe, "error reading subpipe audio, skipping");
else {
size_t samples = 0;
uint8_t sample_size = 0;
uint16_t sample_size = 0;
UBASE_ERROR(upipe, uref_sound_size(upipe_audio_merge_sub->uref, &samples, &sample_size));

int index;
Expand Down Expand Up @@ -315,9 +315,9 @@ static void upipe_audio_merge_copy_to_output_interleaved(struct upipe *upipe,

uint8_t output_channels = 0;
UBASE_ERROR(upipe, uref_sound_flow_get_channels(upipe_audio_merge->flow_def, &output_channels));
uint8_t output_sample_size = 0;
uint16_t output_sample_size = 0;
UBASE_ERROR(upipe, uref_sound_flow_get_sample_size(upipe_audio_merge->flow_def, &output_sample_size));
uint8_t real_sample_size = output_sample_size / output_channels;
uint16_t real_sample_size = output_sample_size / output_channels;

uint8_t cur_channel = 0;
ulist_foreach (&upipe_audio_merge->inputs, uchain) {
Expand All @@ -331,7 +331,7 @@ static void upipe_audio_merge_copy_to_output_interleaved(struct upipe *upipe,
upipe_err(upipe, "error reading subpipe audio, skipping");
} else {
size_t samples = 0;
uint8_t sample_size = 0;
uint16_t sample_size = 0;
UBASE_ERROR(upipe, uref_sound_size(upipe_audio_merge_sub->uref, &samples, &sample_size));

int index;
Expand Down Expand Up @@ -403,7 +403,7 @@ static void upipe_audio_merge_produce_output(struct upipe *upipe, struct upump *
return;
}

uint8_t output_sample_size = 0;
uint16_t output_sample_size = 0;
UBASE_ERROR(upipe, uref_sound_flow_get_sample_size(upipe_audio_merge->flow_def, &output_sample_size));

uint8_t output_planes = 0;
Expand Down
6 changes: 3 additions & 3 deletions lib/upipe-modules/upipe_audio_split.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ struct upipe_audio_split {
/** flow definition packet */
struct uref *flow_def;
/** sample size in octets */
uint8_t sample_size;
uint16_t sample_size;
/** sample size in octets for 1 channel */
uint8_t channel_sample_size;
uint16_t channel_sample_size;
/** number of channels */
uint8_t channels;

Expand Down Expand Up @@ -97,7 +97,7 @@ struct upipe_audio_split_sub {
/** bit field of channels to copy */
uint64_t bitfield;
/** sample size in octets */
uint8_t sample_size;
uint16_t sample_size;

/** public upipe structure */
struct upipe upipe;
Expand Down
Loading
Loading