[FFmpeg-cvslog] avformat: add ff_get_extradata()
Michael Niedermayer
git at videolan.org
Wed Dec 25 17:48:52 CET 2013
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Dec 25 16:34:46 2013 +0100| [ee4e8050931250f609a37f300a1d1831a44ecb1b] | committer: Michael Niedermayer
avformat: add ff_get_extradata()
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee4e8050931250f609a37f300a1d1831a44ecb1b
---
libavformat/internal.h | 9 +++++++++
libavformat/utils.c | 16 ++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index edc6a11..1560e9f 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -372,6 +372,15 @@ int ff_generate_avci_extradata(AVStream *st);
int ff_alloc_extradata(AVCodecContext *avctx, int size);
/**
+ * Allocate extradata with additional FF_INPUT_BUFFER_PADDING_SIZE at end
+ * which is always set to 0 and fill it from pb.
+ *
+ * @param size size of extradata
+ * @return >= 0 if OK, AVERROR_xxx on error
+ */
+int ff_get_extradata(AVCodecContext *avctx, AVIOContext *pb, int size);
+
+/**
* add frame for rfps calculation.
*
* @param dts timestamp of the i-th frame
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 7f19abc..40d886f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2701,6 +2701,22 @@ int ff_alloc_extradata(AVCodecContext *avctx, int size)
return ret;
}
+int ff_get_extradata(AVCodecContext *avctx, AVIOContext *pb, int size)
+{
+ int ret = ff_alloc_extradata(avctx, size);
+ if (ret < 0)
+ return ret;
+ ret = avio_read(pb, avctx->extradata, size);
+ if (ret != size) {
+ av_freep(&avctx->extradata);
+ avctx->extradata_size = 0;
+ av_log(avctx, AV_LOG_ERROR, "Failed to read extradata of size %d\n", size);
+ return ret < 0 ? ret : AVERROR_INVALIDDATA;
+ }
+
+ return ret;
+}
+
int ff_rfps_add_frame(AVFormatContext *ic, AVStream *st, int64_t ts)
{
int i, j;
More information about the ffmpeg-cvslog
mailing list