---
libavformat/avformat.h | 11 +++++++++++
libavformat/utils.c | 8 ++++++++
2 files changed, 19 insertions(+)
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 5b29145..a05403c 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -811,6 +811,17 @@ typedef struct AVStream {
int event_flags;
#define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in
updated metadata.
+ /*
+ * Codec parameters associated with this stream. Allocated and freed by
+ * libavformat in avformat_new_stream() and avformat_free_context()
+ * respectively.
+ *
+ * - demuxing: filled by libavformat on stream creation or in
+ * avformat_find_stream_info()
+ * - muxing: filled by the caller before avformat_write_header()
+ */
+ AVCodecParameters *codecpar;
+
/*****************************************************************
* All fields below this line are not part of the public API. They
* may not be used outside of libavformat and can be changed and
diff --git a/libavformat/utils.c b/libavformat/utils.c
index c936dc6..2691000 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2440,6 +2440,7 @@ static void free_stream(AVStream **pst)
av_free_packet(&st->attached_pic);
av_dict_free(&st->metadata);
+ avcodec_parameters_free(&st->codecpar);
av_freep(&st->probe_data.buf);
av_free(st->index_entries);
av_free(st->codec->extradata);
@@ -2530,6 +2531,10 @@ AVStream *avformat_new_stream(AVFormatContext *s, const
AVCodec *c)
avpriv_set_pts_info(st, 33, 1, 90000);
}
+ st->codecpar = avcodec_parameters_alloc();
+ if (!st->codecpar)
+ goto fail;
+
st->index = s->nb_streams;
st->start_time = AV_NOPTS_VALUE;
st->duration = AV_NOPTS_VALUE;
@@ -2552,6 +2557,9 @@ AVStream *avformat_new_stream(AVFormatContext *s, const
AVCodec *c)
s->streams[s->nb_streams++] = st;
return st;
+fail:
+ free_stream(&st);
+ return NULL;
}
AVProgram *av_new_program(AVFormatContext *ac, int id)
--
2.0.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel