summaryrefslogtreecommitdiff
path: root/libavcodec/avcodec.h
diff options
context:
space:
mode:
authorClément Bœsch <ubitux@gmail.com>2012-10-16 23:49:03 +0200
committerClément Bœsch <ubitux@gmail.com>2012-10-21 17:29:10 +0200
commit6fb2fd895e858ab93f46e656a322778ee181c307 (patch)
treeff4ea436ee889f9d526f5c527fafea4110152535 /libavcodec/avcodec.h
parentd7b8a9a589d94550d2eb2ce4147e69311d6c5745 (diff)
lavc: add lavfi metadata support.
This commit introduces a new AVPacket side data type: AV_PKT_DATA_STRINGS_METADATA. Its main goal is to provide a way to transmit the metadata from the AVFilterBufferRef up to the AVFrame. This is at the moment "only" useful for lavfi input from libavdevice: lavd/lavfi only outputs packets, and the metadata from the buffer ref kept in its context needs to be transmitted from the packet to the frame by the decoders. The buffer ref can be destroyed at any time (along with the metadata), and a duplication of the AVPacket needs to duplicate the metadata as well, so the choice of using the side data to store them was selected. Making sure lavd/lavfi raises the metadata is useful to allow tools like ffprobe to access the filters metadata (it is at the moment the only way); ffprobe will now automatically show the AVFrame metadata in any customizable output format for users. API users will also be able to access the AVFrame->metadata pointer the same way ffprobe does (av_frame_get_metadata). All the changes are done in this single commit to avoid some memory leaks: for instances, the changes in lavfi/avcodec.c are meant to duplicate the metadata from the buffer ref into the AVFrame. Unless we have an internal way of freeing the AVFrame->metadata automatically, it will leak in most of the user apps. To fix this problem, we introduce AVCodecContext->metadata and link avctx->metadata to the current frame->metadata and free it at each decode frame call (and in the codec closing callback for the last one). But doing this also means to update the way the tiff decoder already handles the AVFrame->metadata (it's the only one decoder with frame metadata at the moment), by making sure it is not trying to free a pointer already freed by the lavc internals. The lavfi/avcodec.c buffer ref code is based on an old Thomas Kühnel work, the rest of the code belongs to the commit author. Signed-off-by: Thomas Kühnel <kuehnelth@googlemail.com> Signed-off-by: Clément Bœsch <ubitux@gmail.com>
Diffstat (limited to 'libavcodec/avcodec.h')
-rw-r--r--libavcodec/avcodec.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0b3a19af19..3936d5e1c0 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -942,6 +942,12 @@ enum AVPacketSideDataType {
* @endcode
*/
AV_PKT_DATA_JP_DUALMONO,
+
+ /**
+ * A list of zero terminated key/value strings. There is no end marker for
+ * the list, so it is required to rely on the side data size to stop.
+ */
+ AV_PKT_DATA_STRINGS_METADATA,
};
typedef struct AVPacket {
@@ -3091,6 +3097,13 @@ typedef struct AVCodecContext {
int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far
int64_t pts_correction_last_pts; /// PTS of the last frame
int64_t pts_correction_last_dts; /// DTS of the last frame
+
+ /**
+ * Current frame metadata.
+ * - decoding: maintained and used by libavcodec, not intended to be used by user apps
+ * - encoding: unused
+ */
+ AVDictionary *metadata;
} AVCodecContext;
AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx);