[FFmpeg-devel] [PATCH] lavc: add pkt_size field to AVFrame

Stefano Sabatini stefasab at gmail.com
Fri Dec 14 17:52:16 CET 2012


TODO: add APIchanges entry, bump minor
---
 libavcodec/avcodec.h |   12 ++++++++++++
 libavcodec/utils.c   |    4 ++++
 2 files changed, 16 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e432040..2c8288b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1467,6 +1467,16 @@ typedef struct AVFrame {
      * - decoding: Read by user.
      */
     int64_t channels;
+
+    /**
+     * size of the corresponding packet, containing the compressed
+     * size of the frame, only relevant for video. It must be accessed
+     * using av_frame_get_pkt_size() and av_frame_set_pkt_size().
+     * It is set to -1 if unknown.
+     * - encoding: unused
+     * - decoding: set by libavcodec, read by user.
+     */
+    int pkt_size;
 } AVFrame;
 
 /**
@@ -1490,6 +1500,8 @@ AVDictionary *av_frame_get_metadata       (const AVFrame *frame);
 void          av_frame_set_metadata       (AVFrame *frame, AVDictionary *val);
 int     av_frame_get_decode_error_flags   (const AVFrame *frame);
 void    av_frame_set_decode_error_flags   (AVFrame *frame, int     val);
+int     av_frame_get_pkt_size(const AVFrame *frame);
+void    av_frame_set_pkt_size(AVFrame *frame, int val);
 
 struct AVCodecInternal;
 
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 5ec99d0..24cb9fa 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -512,10 +512,12 @@ void ff_init_buffer_info(AVCodecContext *s, AVFrame *frame)
         frame->pkt_pts = s->pkt->pts;
         frame->pkt_pos = s->pkt->pos;
         frame->pkt_duration = s->pkt->duration;
+        frame->pkt_size = s->pkt->size;
     } else {
         frame->pkt_pts = AV_NOPTS_VALUE;
         frame->pkt_pos = -1;
         frame->pkt_duration = 0;
+        frame->pkt_size = -1;
     }
     frame->reordered_opaque = s->reordered_opaque;
 
@@ -677,6 +679,7 @@ void avcodec_get_frame_defaults(AVFrame *frame)
     frame->best_effort_timestamp = AV_NOPTS_VALUE;
     frame->pkt_duration        = 0;
     frame->pkt_pos             = -1;
+    frame->pkt_size            = -1;
     frame->key_frame           = 1;
     frame->sample_aspect_ratio = (AVRational) {0, 1 };
     frame->format              = -1; /* unknown */
@@ -723,6 +726,7 @@ MAKE_ACCESSORS(AVFrame, frame, int,     channels)
 MAKE_ACCESSORS(AVFrame, frame, int,     sample_rate)
 MAKE_ACCESSORS(AVFrame, frame, AVDictionary *, metadata)
 MAKE_ACCESSORS(AVFrame, frame, int,     decode_error_flags)
+MAKE_ACCESSORS(AVFrame, frame, int,     pkt_size)
 
 MAKE_ACCESSORS(AVCodecContext, codec, AVRational, pkt_timebase)
 MAKE_ACCESSORS(AVCodecContext, codec, const AVCodecDescriptor *, codec_descriptor)
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list