summaryrefslogtreecommitdiffstats
path: root/audio/audio.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-07-24 19:06:00 +0200
committerwm4 <wm4@nowhere>2016-07-24 19:06:00 +0200
commit3623cec7d2753ec7e7bf1ca73580203acb3347c8 (patch)
tree2563ead45b6b86ae6889f76b3e9095da68703301 /audio/audio.c
parentd60db967bda3e9910ec6bc78d0d0cb284f5d68fa (diff)
downloadmpv-3623cec7d2753ec7e7bf1ca73580203acb3347c8.tar.bz2
mpv-3623cec7d2753ec7e7bf1ca73580203acb3347c8.tar.xz
af_lavcac3enc: use common code for AVFrame setup
Diffstat (limited to 'audio/audio.c')
-rw-r--r--audio/audio.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/audio/audio.c b/audio/audio.c
index 306401b5a4..710cc03193 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -394,12 +394,9 @@ fail:
return NULL;
}
-// Returns NULL on failure. The input is always unreffed.
-struct AVFrame *mp_audio_to_avframe_and_unref(struct mp_audio *frame)
+int mp_audio_to_avframe(struct mp_audio *frame, struct AVFrame *avframe)
{
- struct AVFrame *avframe = av_frame_alloc();
- if (!avframe)
- goto fail;
+ av_frame_unref(avframe);
avframe->nb_samples = frame->samples;
avframe->format = af_to_avformat(frame->format);
@@ -457,6 +454,23 @@ struct AVFrame *mp_audio_to_avframe_and_unref(struct mp_audio *frame)
avframe = tmp;
}
+ return 0;
+
+fail:
+ av_frame_unref(avframe);
+ return -1;
+}
+
+// Returns NULL on failure. The input is always unreffed.
+struct AVFrame *mp_audio_to_avframe_and_unref(struct mp_audio *frame)
+{
+ struct AVFrame *avframe = av_frame_alloc();
+ if (!avframe)
+ goto fail;
+
+ if (mp_audio_to_avframe(frame, avframe) < 0)
+ goto fail;
+
talloc_free(frame);
return avframe;