summaryrefslogtreecommitdiffstats
path: root/audio/aframe.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/aframe.c')
-rw-r--r--audio/aframe.c23
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)
{