diff options
author | wm4 <wm4@nowhere> | 2017-09-21 11:07:02 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-09-21 12:42:09 +0200 |
commit | 3a2d5e68acb2ac0f8b09b896907a692b1c48c6b3 (patch) | |
tree | 13a7e321ce6accceca720fb654cdf7ea8eee0afc /audio/aframe.c | |
parent | caaa1189ba75a7df9a4d02f7747d6c0bf3b05012 (diff) | |
download | mpv-3a2d5e68acb2ac0f8b09b896907a692b1c48c6b3.tar.bz2 mpv-3a2d5e68acb2ac0f8b09b896907a692b1c48c6b3.tar.xz |
audio: move libswresample wrapper out of audio filter code
Move it from af_lavrresample.c to a new aconverter.c file, which is
independent from the filter chain code. It also doesn't use mp_audio,
and thus has no GPL dependencies.
Preparation for later commits. Not particularly well tested, so have
fun.
Diffstat (limited to 'audio/aframe.c')
-rw-r--r-- | audio/aframe.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/audio/aframe.c b/audio/aframe.c index cf785f6657..4168f92124 100644 --- a/audio/aframe.c +++ b/audio/aframe.c @@ -166,10 +166,9 @@ void mp_aframe_config_copy(struct mp_aframe *dst, struct mp_aframe *src) dst->chmap = src->chmap; dst->format = src->format; - dst->pts = src->pts; - if (av_frame_copy_props(dst->av_frame, src->av_frame) < 0) - abort(); + mp_aframe_copy_attributes(dst, src); + dst->av_frame->format = src->av_frame->format; dst->av_frame->channel_layout = src->av_frame->channel_layout; #if LIBAVUTIL_VERSION_MICRO >= 100 @@ -178,6 +177,16 @@ void mp_aframe_config_copy(struct mp_aframe *dst, struct mp_aframe *src) #endif } +// Copy "soft" attributes from src to dst, excluding things which affect +// frame allocation and organization. +void mp_aframe_copy_attributes(struct mp_aframe *dst, struct mp_aframe *src) +{ + dst->pts = src->pts; + + if (av_frame_copy_props(dst->av_frame, src->av_frame) < 0) + abort(); +} + // Return whether a and b use the same physical audio format. Extra metadata // such as PTS, per-frame signalling, and AVFrame side data is not compared. bool mp_aframe_config_equals(struct mp_aframe *a, struct mp_aframe *b) @@ -317,6 +326,14 @@ size_t mp_aframe_get_sstride(struct mp_aframe *frame) (af_fmt_is_planar(format) ? 1 : mp_aframe_get_channels(frame)); } +// Return total number of samples on each plane. +int mp_aframe_get_total_plane_samples(struct mp_aframe *frame) +{ + return frame->av_frame->nb_samples * + (af_fmt_is_planar(mp_aframe_get_format(frame)) + ? 1 : mp_aframe_get_channels(frame)); +} + // Set data to the audio after the given number of samples (i.e. slice it). void mp_aframe_skip_samples(struct mp_aframe *f, int samples) { |