]> git.sesse.net Git - ffmpeg/commitdiff
lavf: add internal API to append a bsf to a stream's list
authorRodger Combs <rodger.combs@gmail.com>
Thu, 8 Oct 2015 02:10:08 +0000 (21:10 -0500)
committerRodger Combs <rodger.combs@gmail.com>
Mon, 28 Dec 2015 14:40:37 +0000 (08:40 -0600)
libavformat/internal.h
libavformat/utils.c

index 0e59da0c2d00907f8c398b1666e8477dcd4867af..2cb3481f8c33987fb2fca50104dcdb5c70305295 100644 (file)
@@ -464,6 +464,17 @@ enum AVChromaLocation ff_choose_chroma_location(AVFormatContext *s, AVStream *st
  */
 int ff_generate_avci_extradata(AVStream *st);
 
+/**
+ * Add a bitstream filter to a stream.
+ *
+ * @param st output stream to add a filter to
+ * @param name the name of the filter to add
+ * @param args filter-specific argument string
+ * @return  >0 on success;
+ *          AVERROR code on failure
+ */
+int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args);
+
 /**
  * Wrap errno on rename() error.
  *
index 7e101a4fd348e7f7f49b4a3faf5a761a3effbe54..95acbf32518097c31074dd4051af556663e7334d 100644 (file)
@@ -4651,6 +4651,28 @@ uint8_t *av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type,
     return data;
 }
 
+int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args)
+{
+    AVBitStreamFilterContext *bsfc = NULL;
+    AVBitStreamFilterContext **dest = &st->internal->bsfc;
+    while (*dest && (*dest)->next)
+        dest = &(*dest)->next;
+
+    if (!(bsfc = av_bitstream_filter_init(name))) {
+        av_log(NULL, AV_LOG_ERROR, "Unknown bitstream filter '%s'\n", name);
+        return AVERROR(EINVAL);
+    }
+    if (args && !(bsfc->args = av_strdup(args))) {
+        av_bitstream_filter_close(bsfc);
+        return AVERROR(ENOMEM);
+    }
+    av_log(st->codec, AV_LOG_VERBOSE,
+           "Automatically inserted bitstream filter '%s'; args='%s'\n",
+           name, args ? args : "");
+    *dest = bsfc;
+    return 1;
+}
+
 int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt,
                                AVBitStreamFilterContext *bsfc)
 {