[FFmpeg-devel] [PATCH 3/6] lavc: add AV_PKT_FLAG_DISCARD.

Nicolas George george at nsup.org
Fri Feb 21 20:50:15 CET 2014


From: Nicolas George <nicolas.george at normalesup.org>

Signed-off-by: Nicolas George <george at nsup.org>
---
 libavcodec/avcodec.h | 5 +++++
 libavcodec/utils.c   | 6 ++++++
 libavformat/utils.c  | 3 +++
 3 files changed, 14 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 5df717c..18b281a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1165,6 +1165,11 @@ typedef struct AVPacket {
 #define AV_PKT_FLAG_KEY     0x0001 ///< The packet contains a keyframe
 #define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted
 
+/**
+ * Decode the packet, but do not return the decoded frame to the application
+ */
+#define AV_PKT_FLAG_DISCARD 0x100000
+
 enum AVSideDataParamChangeFlags {
     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,
     AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 61a72ea..74c12f4 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2165,6 +2165,12 @@ fail:
                 ret = avpkt->size;
         }
 
+        if (*got_picture_ptr &&
+            (av_frame_get_pkt_flags(picture) & AV_PKT_FLAG_DISCARD)) {
+            *got_picture_ptr = 0;
+            av_frame_unref(picture);
+        }
+
         if (*got_picture_ptr) {
             if (!avctx->refcounted_frames) {
                 int err = unrefcount_frame(avci, picture);
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 04c10a0..7290a25 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -1310,6 +1310,9 @@ static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index)
         if (st->parser->key_frame == -1 && st->parser->pict_type ==AV_PICTURE_TYPE_NONE && (pkt->flags&AV_PKT_FLAG_KEY))
             out_pkt.flags |= AV_PKT_FLAG_KEY;
 
+        if (pkt->flags & AV_PKT_FLAG_DISCARD)
+            out_pkt.flags |= AV_PKT_FLAG_DISCARD;
+
         compute_pkt_fields(s, st, st->parser, &out_pkt);
 
         if (out_pkt.data == pkt->data && out_pkt.size == pkt->size) {
-- 
1.8.5.3



More information about the ffmpeg-devel mailing list