[FFmpeg-cvslog] lavc: add pkt_duration field to AVFrame

Stefano Sabatini git at videolan.org
Tue Jun 5 18:45:37 CEST 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Thu Mar  8 15:22:53 2012 +0100| [62b39d41cdec2be4e4722aefbd7789305e4ab2ad] | committer: Stefano Sabatini

lavc: add pkt_duration field to AVFrame

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62b39d41cdec2be4e4722aefbd7789305e4ab2ad
---

 doc/APIchanges       |    3 +++
 libavcodec/avcodec.h |   11 +++++++++++
 libavcodec/utils.c   |    8 ++++++++
 libavcodec/version.h |    2 +-
 4 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 0b70c21..2da438f 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2011-04-18
 
 API changes, most recent first:
 
+2012-06-05 - xxxxxxx - lavc 54.24.100
+  Add pkt_duration field to AVFrame.
+
 2012-06-04 - xxxxxxx - lafi 2.78.100
   Add avfilter_default_filter_name() function in avfilter.h.
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 96ca401..e61aabc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1277,6 +1277,15 @@ typedef struct AVFrame {
      */
     int64_t pkt_pos;
 
+    /**
+     * duration of the corresponding packet, expressed in
+     * AVStream->time_base units, 0 if unknown.
+     * Code outside libavcodec should access this field using:
+     * av_frame_get_pkt_duration(frame)
+     * - encoding: unused
+     * - decoding: Read by user.
+     */
+    int64_t pkt_duration;
 } AVFrame;
 
 /**
@@ -1285,10 +1294,12 @@ typedef struct AVFrame {
  * they should not be accessed directly outside libavcodec.
  */
 int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame);
+int64_t av_frame_get_pkt_duration         (const AVFrame *frame);
 int64_t av_frame_get_pkt_pos              (const AVFrame *frame);
 int64_t av_frame_get_channel_layout       (const AVFrame *frame);
 int     av_frame_get_sample_rate          (const AVFrame *frame);
 void    av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val);
+void    av_frame_set_pkt_duration         (AVFrame *frame, int64_t val);
 void    av_frame_set_pkt_pos              (AVFrame *frame, int64_t val);
 void    av_frame_set_channel_layout       (AVFrame *frame, int64_t val);
 void    av_frame_set_sample_rate          (AVFrame *frame, int     val);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 5d3fafe..d427a92 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -265,9 +265,11 @@ void ff_init_buffer_info(AVCodecContext *s, AVFrame *pic)
     if (s->pkt) {
         pic->pkt_pts = s->pkt->pts;
         pic->pkt_pos = s->pkt->pos;
+        pic->pkt_duration = s->pkt->duration;
     } else {
         pic->pkt_pts = AV_NOPTS_VALUE;
         pic->pkt_pos = -1;
+        pic->pkt_duration = 0;
     }
     pic->reordered_opaque= s->reordered_opaque;
     pic->sample_aspect_ratio = s->sample_aspect_ratio;
@@ -384,9 +386,11 @@ static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
     if (avctx->pkt) {
         frame->pkt_pts = avctx->pkt->pts;
         frame->pkt_pos = avctx->pkt->pos;
+        frame->pkt_duration = avctx->pkt->duration;
     } else {
         frame->pkt_pts = AV_NOPTS_VALUE;
         frame->pkt_pos = -1;
+        frame->pkt_duration = 0;
     }
 
     frame->reordered_opaque = avctx->reordered_opaque;
@@ -521,9 +525,11 @@ static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
     if (s->pkt) {
         pic->pkt_pts = s->pkt->pts;
         pic->pkt_pos = s->pkt->pos;
+        pic->pkt_duration = s->pkt->duration;
     } else {
         pic->pkt_pts = AV_NOPTS_VALUE;
         pic->pkt_pos = -1;
+        pic->pkt_duration = 0;
     }
     pic->reordered_opaque= s->reordered_opaque;
     pic->sample_aspect_ratio = s->sample_aspect_ratio;
@@ -661,6 +667,7 @@ void avcodec_get_frame_defaults(AVFrame *pic){
     memset(pic, 0, sizeof(AVFrame));
 
     pic->pts = pic->pkt_dts = pic->pkt_pts = pic->best_effort_timestamp = AV_NOPTS_VALUE;
+    pic->pkt_duration = 0;
     pic->pkt_pos = -1;
     pic->key_frame= 1;
     pic->sample_aspect_ratio = (AVRational){0, 1};
@@ -682,6 +689,7 @@ AVFrame *avcodec_alloc_frame(void){
     void av_##name##_set_##field(str *s, type v) { s->field = v; }
 
 MAKE_ACCESSORS(AVFrame, frame, int64_t, best_effort_timestamp)
+MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_duration)
 MAKE_ACCESSORS(AVFrame, frame, int64_t, pkt_pos)
 MAKE_ACCESSORS(AVFrame, frame, int64_t, channel_layout)
 MAKE_ACCESSORS(AVFrame, frame, int,     sample_rate)
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 3c588d7..a9e1f75 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -27,7 +27,7 @@
  */
 
 #define LIBAVCODEC_VERSION_MAJOR 54
-#define LIBAVCODEC_VERSION_MINOR  23
+#define LIBAVCODEC_VERSION_MINOR  24
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \



More information about the ffmpeg-cvslog mailing list