Browse code

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.

Stefano Sabatini authored on 2011/04/29 19:28:44
Showing 8 changed files
... ...
@@ -907,6 +907,7 @@ int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame,
907 907
 
908 908
     memcpy(frame->data,     picref->data,     sizeof(frame->data));
909 909
     memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize));
910
+    frame->pkt_pos          = picref->pos;
910 911
     frame->interlaced_frame = picref->video->interlaced;
911 912
     frame->top_field_first  = picref->video->top_field_first;
912 913
     frame->key_frame        = picref->video->key_frame;
... ...
@@ -13,6 +13,9 @@ libavutil:   2011-04-18
13 13
 
14 14
 API changes, most recent first:
15 15
 
16
+2011-05-01 - xxxxxxx - lavc 53.2.0 - AVFrame
17
+  Add a pkt_pos field to AVFrame.
18
+
16 19
 2011-04-xx - xxxxxxx - lavu 51.2.0 - mem.h
17 20
   Add av_dynarray_add function for adding
18 21
   an element to a dynamic array.
... ...
@@ -1687,7 +1687,7 @@ static int input_request_frame(AVFilterLink *link)
1687 1687
     av_free_packet(&pkt);
1688 1688
 
1689 1689
     picref->pts = pts;
1690
-    picref->pos = pkt.pos;
1690
+    picref->pos = priv->frame->pkt_pos;
1691 1691
     picref->video->pixel_aspect = priv->is->video_st->codec->sample_aspect_ratio;
1692 1692
     avfilter_start_frame(link, picref);
1693 1693
     avfilter_draw_slice(link, 0, link->h, 1);
... ...
@@ -1004,6 +1004,13 @@ typedef struct AVPanScan{
1004 1004
      * - decoding: set by libavcodec, read by user.\
1005 1005
      */\
1006 1006
     int64_t best_effort_timestamp;\
1007
+\
1008
+    /**\
1009
+     * reordered pos from the last AVPacket that has been input into the decoder\
1010
+     * - encoding: unused\
1011
+     * - decoding: Read by user.\
1012
+     */\
1013
+    int64_t pkt_pos;\
1007 1014
 
1008 1015
 
1009 1016
 #define FF_QSCALE_TYPE_MPEG1 0
... ...
@@ -124,6 +124,7 @@ static int raw_decode(AVCodecContext *avctx,
124 124
     frame->top_field_first = avctx->coded_frame->top_field_first;
125 125
     frame->reordered_opaque = avctx->reordered_opaque;
126 126
     frame->pkt_pts          = avctx->pkt->pts;
127
+    frame->pkt_pos          = avctx->pkt->pos;
127 128
 
128 129
     //2bpp and 4bpp raw in avi and mov (yes this is ugly ...)
129 130
     if (context->buffer) {
... ...
@@ -341,8 +341,13 @@ int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic){
341 341
     }
342 342
     s->internal_buffer_count++;
343 343
 
344
-    if(s->pkt) pic->pkt_pts= s->pkt->pts;
345
-    else       pic->pkt_pts= AV_NOPTS_VALUE;
344
+    if (s->pkt) {
345
+        pic->pkt_pts = s->pkt->pts;
346
+        pic->pkt_pos = s->pkt->pos;
347
+    } else {
348
+        pic->pkt_pts = AV_NOPTS_VALUE;
349
+        pic->pkt_pos = -1;
350
+    }
346 351
     pic->reordered_opaque= s->reordered_opaque;
347 352
 
348 353
     if(s->debug&FF_DEBUG_BUFFERS)
... ...
@@ -448,6 +453,7 @@ void avcodec_get_frame_defaults(AVFrame *pic){
448 448
     memset(pic, 0, sizeof(AVFrame));
449 449
 
450 450
     pic->pts = pic->best_effort_timestamp = AV_NOPTS_VALUE;
451
+    pic->pkt_pos = -1;
451 452
     pic->key_frame= 1;
452 453
 }
453 454
 
... ...
@@ -730,6 +736,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
730 730
             ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
731 731
                               avpkt);
732 732
             picture->pkt_dts= avpkt->dts;
733
+            picture->pkt_pos= avpkt->pos;
733 734
         }
734 735
 
735 736
         emms_c(); //needed to avoid an emms_c() call before every return;
... ...
@@ -21,8 +21,8 @@
21 21
 #define AVCODEC_VERSION_H
22 22
 
23 23
 #define LIBAVCODEC_VERSION_MAJOR 53
24
-#define LIBAVCODEC_VERSION_MINOR  1
25
-#define LIBAVCODEC_VERSION_MICRO  2
24
+#define LIBAVCODEC_VERSION_MINOR  2
25
+#define LIBAVCODEC_VERSION_MICRO  0
26 26
 
27 27
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
28 28
                                                LIBAVCODEC_VERSION_MINOR, \
... ...
@@ -230,7 +230,6 @@ static int movie_get_frame(AVFilterLink *outlink)
230 230
     while ((ret = av_read_frame(movie->format_ctx, &pkt)) >= 0) {
231 231
         // Is this a packet from the video stream?
232 232
         if (pkt.stream_index == movie->stream_index) {
233
-            movie->codec_ctx->reordered_opaque = pkt.pos;
234 233
             avcodec_decode_video2(movie->codec_ctx, movie->frame, &frame_decoded, &pkt);
235 234
 
236 235
             if (frame_decoded) {
... ...
@@ -247,7 +246,7 @@ static int movie_get_frame(AVFilterLink *outlink)
247 247
                 movie->picref->pts = movie->frame->pkt_pts == AV_NOPTS_VALUE ?
248 248
                     movie->frame->pkt_dts : movie->frame->pkt_pts;
249 249
 
250
-                movie->picref->pos                    = movie->frame->reordered_opaque;
250
+                movie->picref->pos                    = movie->frame->pkt_pos;
251 251
                 movie->picref->video->pixel_aspect = st->sample_aspect_ratio.num ?
252 252
                     st->sample_aspect_ratio : movie->codec_ctx->sample_aspect_ratio;
253 253
                 movie->picref->video->interlaced      = movie->frame->interlaced_frame;