[FFmpeg-cvslog] lavc: add a pkt_pos field to AVFrame

Stefano Sabatini git at videolan.org
Sun May 1 14:20:21 CEST 2011


ffmpeg | branch: master | Stefano Sabatini <stefano.sabatini-lala at poste.it> | Fri Apr 29 12:28:44 2011 +0200| [1ba57272429fc6c86e39cd236e2b32ac545e1488] | committer: Stefano Sabatini

lavc: add a pkt_pos field to AVFrame

This is similar to what was done with pkt_pts. This simplifies the
operation of extracting the pos information from the AVPacket, and
allows further simplifications.

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

 cmdutils.c               |    1 +
 doc/APIchanges           |    3 +++
 ffplay.c                 |    2 +-
 libavcodec/avcodec.h     |    7 +++++++
 libavcodec/rawdec.c      |    1 +
 libavcodec/utils.c       |   11 +++++++++--
 libavcodec/version.h     |    4 ++--
 libavfilter/vsrc_movie.c |    3 +--
 8 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/cmdutils.c b/cmdutils.c
index 4363e8a..7989e06 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -907,6 +907,7 @@ int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
 
     memcpy(frame->data,     picref->data,     sizeof(frame->data));
     memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
+    frame->pkt_pos          = picref->pos;
     frame->interlaced_frame = picref->video->interlaced;
     frame->top_field_first  = picref->video->top_field_first;
     frame->key_frame        = picref->video->key_frame;
diff --git a/doc/APIchanges b/doc/APIchanges
index 9933cbf..5286e5d 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
 
 API changes, most recent first:
 
+2011-05-01 - xxxxxxx - lavc 53.2.0 - AVFrame
+  Add a pkt_pos field to AVFrame.
+
 2011-04-xx - xxxxxxx - lavu 51.2.0 - mem.h
   Add av_dynarray_add function for adding
   an element to a dynamic array.
diff --git a/ffplay.c b/ffplay.c
index 3cd3c3f..35500d0 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -1687,7 +1687,7 @@ static int input_request_frame(AVFilterLink *link)
     av_free_packet(&pkt);
 
     picref->pts = pts;
-    picref->pos = pkt.pos;
+    picref->pos = priv->frame->pkt_pos;
     picref->video->pixel_aspect = priv->is->video_st->codec->sample_aspect_ratio;
     avfilter_start_frame(link, picref);
     avfilter_draw_slice(link, 0, link->h, 1);
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b69230f..251a038 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1004,6 +1004,13 @@ typedef struct AVPanScan{
      * - decoding: set by libavcodec, read by user.\
      */\
     int64_t best_effort_timestamp;\
+\
+    /**\
+     * reordered pos from the last AVPacket that has been input into the decoder\
+     * - encoding: unused\
+     * - decoding: Read by user.\
+     */\
+    int64_t pkt_pos;\
 
 
 #define FF_QSCALE_TYPE_MPEG1 0
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index d9993c0..029bee2 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -124,6 +124,7 @@ static int raw_decode(AVCodecContext *avctx,
     frame->top_field_first = avctx->coded_frame->top_field_first;
     frame->reordered_opaque = avctx->reordered_opaque;
     frame->pkt_pts          = avctx->pkt->pts;
+    frame->pkt_pos          = avctx->pkt->pos;
 
     //2bpp and 4bpp raw in avi and mov (yes this is ugly ...)
     if (context->buffer) {
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index ce33c4f..0993d52 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -341,8 +341,13 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
     }
     s->internal_buffer_count++;
 
-    if(s->pkt) pic->pkt_pts= s->pkt->pts;
-    else       pic->pkt_pts= AV_NOPTS_VALUE;
+    if (s->pkt) {
+        pic->pkt_pts = s->pkt->pts;
+        pic->pkt_pos = s->pkt->pos;
+    } else {
+        pic->pkt_pts = AV_NOPTS_VALUE;
+        pic->pkt_pos = -1;
+    }
     pic->reordered_opaque= s->reordered_opaque;
 
     if(s->debug&FF_DEBUG_BUFFERS)
@@ -448,6 +453,7 @@ void avcodec_get_frame_defaults(AVFrame *pic){
     memset(pic, 0, sizeof(AVFrame));
 
     pic->pts = pic->best_effort_timestamp = AV_NOPTS_VALUE;
+    pic->pkt_pos = -1;
     pic->key_frame= 1;
 }
 
@@ -730,6 +736,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
             ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
                               avpkt);
             picture->pkt_dts= avpkt->dts;
+            picture->pkt_pos= avpkt->pos;
         }
 
         emms_c(); //needed to avoid an emms_c() call before every return;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 7eba7d2..c7c7456 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -21,8 +21,8 @@
 #define AVCODEC_VERSION_H
 
 #define LIBAVCODEC_VERSION_MAJOR 53
-#define LIBAVCODEC_VERSION_MINOR  1
-#define LIBAVCODEC_VERSION_MICRO  2
+#define LIBAVCODEC_VERSION_MINOR  2
+#define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavfilter/vsrc_movie.c b/libavfilter/vsrc_movie.c
index f0adc25..e6b5085 100644
--- a/libavfilter/vsrc_movie.c
+++ b/libavfilter/vsrc_movie.c
@@ -230,7 +230,6 @@ static int movie_get_frame(AVFilterLink *outlink)
     while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
         // Is this a packet from the video stream?
         if (pkt.stream_index == movie->stream_index) {
-            movie->codec_ctx->reordered_opaque = pkt.pos;
             avcodec_decode_video2(movie->codec_ctx, movie->frame, &frame_decoded, &pkt);
 
             if (frame_decoded) {
@@ -247,7 +246,7 @@ static int movie_get_frame(AVFilterLink *outlink)
                 movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?
                     movie->frame->pkt_dts : movie->frame->pkt_pts;
 
-                movie->picref->pos                    = movie->frame->reordered_opaque;
+                movie->picref->pos                    = movie->frame->pkt_pos;
                 movie->picref->video->pixel_aspect = st->sample_aspect_ratio.num ?
                     st->sample_aspect_ratio : movie->codec_ctx->sample_aspect_ratio;
                 movie->picref->video->interlaced      = movie->frame->interlaced_frame;



More information about the ffmpeg-cvslog mailing list