History

lavfi: add avfilter_fill_frame_from_{audio_,}buffer_ref().

Clément Bœsch committed 14 years ago

Commit a67d9cf1 parent a84851b4 files · +50 −2Browse files

Showing the changes to libavfilter (3 of 4 files). Show all

Unified · Split

3 files
  1. libavfilter/avcodec.c +23 −0
  2. libavfilter/avcodec.h +22 −0
  3. libavfilter/version.h +2 −2
libavfilter/avcodec.c+23−0
@@ -56,6 +56,20 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame · 55 unmodified lines
5656 return picref;
5757 }
5858
59+int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
60+ const AVFilterBufferRef *samplesref)
61+{
62+ if (!samplesref || !samplesref->audio || !frame)
63+ return AVERROR(EINVAL);
64+
65+ memcpy(frame->data, samplesref->data, sizeof(frame->data));
66+ frame->pkt_pos = samplesref->pos;
67+ frame->format = samplesref->format;
68+ frame->nb_samples = samplesref->audio->nb_samples;
69+
70+ return 0;
71+}
72+
5973 int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
6074 const AVFilterBufferRef *picref)
6175 {
@@ -73,3 +87,12 @@ int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame, · 11 unmodified lines
7387
7488 return 0;
7589 }
90+
91+int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
92+ const AVFilterBufferRef *ref)
93+{
94+ if (!ref)
95+ return AVERROR(EINVAL);
96+ return ref->video ? avfilter_fill_frame_from_video_buffer_ref(frame, ref)
97+ : avfilter_fill_frame_from_audio_buffer_ref(frame, ref);
98+}
libavfilter/avcodec.h+22−0
@@ -46,6 +46,17 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src); · 45 unmodified lines
4646 */
4747 AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame, int perms);
4848
49+/**
50+ * Fill an AVFrame with the information stored in samplesref.
51+ *
52+ * @param frame an already allocated AVFrame
53+ * @param samplesref an audio buffer reference
54+ * @return 0 in case of success, a negative AVERROR code in case of
55+ * failure
56+ */
57+int avfilter_fill_frame_from_audio_buffer_ref(AVFrame *frame,
58+ const AVFilterBufferRef *samplesref);
59+
4960 /**
5061 * Fill an AVFrame with the information stored in picref.
5162 *
@@ -57,6 +68,17 @@ AVFilterBufferRef *avfilter_get_video_buffer_ref_from_frame(const AVFrame *frame · 5 unmodified lines
5768 int avfilter_fill_frame_from_video_buffer_ref(AVFrame *frame,
5869 const AVFilterBufferRef *picref);
5970
71+/**
72+ * Fill an AVFrame with information stored in ref.
73+ *
74+ * @param frame an already allocated AVFrame
75+ * @param ref a video or audio buffer reference
76+ * @return 0 in case of success, a negative AVERROR code in case of
77+ * failure
78+ */
79+int avfilter_fill_frame_from_buffer_ref(AVFrame *frame,
80+ const AVFilterBufferRef *ref);
81+
6082 /**
6183 * Add frame data to buffer_src.
6284 *
libavfilter/version.h+2−2
@@ -29,8 +29,8 @@ · 28 unmodified lines
2929 #include "libavutil/avutil.h"
3030
3131 #define LIBAVFILTER_VERSION_MAJOR 2
32−#define LIBAVFILTER_VERSION_MINOR 65
33−#define LIBAVFILTER_VERSION_MICRO 102
32+#define LIBAVFILTER_VERSION_MINOR 66
33+#define LIBAVFILTER_VERSION_MICRO 100
3434
3535 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
3636 LIBAVFILTER_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t