[FFmpeg-soc] [soc]: r413 - in libavfilter: avfilter.c avfilter.h filter_test.c vo_sdl.c vsrc_dummy.c vsrc_ppm.c

koorogi subversion at mplayerhq.hu
Sat Jul 14 19:31:41 CEST 2007


Author: koorogi
Date: Sat Jul 14 19:31:40 2007
New Revision: 413

Log:
Add pts to frame references


Modified:
   libavfilter/avfilter.c
   libavfilter/avfilter.h
   libavfilter/filter_test.c
   libavfilter/vo_sdl.c
   libavfilter/vsrc_dummy.c
   libavfilter/vsrc_ppm.c

Modified: libavfilter/avfilter.c
==============================================================================
--- libavfilter/avfilter.c	(original)
+++ libavfilter/avfilter.c	Sat Jul 14 19:31:40 2007
@@ -70,6 +70,7 @@ void avfilter_default_start_frame(AVFilt
 
     if(out) {
         out->outpic  = avfilter_get_video_buffer(out, AV_PERM_WRITE);
+        out->outpic->pts = picref->pts;
         avfilter_start_frame(out, avfilter_ref_pic(out->outpic, ~0));
     }
 }

Modified: libavfilter/avfilter.h
==============================================================================
--- libavfilter/avfilter.h	(original)
+++ libavfilter/avfilter.h	Sat Jul 14 19:31:40 2007
@@ -53,7 +53,7 @@ typedef struct AVFilterPic
  * and dimensions are per-reference properties.  Linesize is also useful for
  * image flipping, frame to field filters, etc, and so is also per-reference.
  *
- * TODO: add pts, and anything necessary for frame reordering
+ * TODO: add anything necessary for frame reordering
  */
 typedef struct AVFilterPicRef
 {
@@ -62,6 +62,8 @@ typedef struct AVFilterPicRef
     int linesize[4];
     int w, h;
 
+    int64_t pts;                ///< presentation timestamp in milliseconds
+
     int perms;                  ///< permissions
 #define AV_PERM_READ     0x01   ///< can read from the buffer
 #define AV_PERM_WRITE    0x02   ///< can write to the buffer

Modified: libavfilter/filter_test.c
==============================================================================
--- libavfilter/filter_test.c	(original)
+++ libavfilter/filter_test.c	Sat Jul 14 19:31:40 2007
@@ -24,7 +24,7 @@
 
 #include "avfilter.h"
 
-void sdl_display(AVFilterContext *ctx);
+int64_t sdl_display(AVFilterContext *ctx);
 
 AVFilterContext *create_filter(char *argv)
 {
@@ -58,6 +58,7 @@ int main(int argc, char **argv)
 {
     int i;
     int ret = -1;
+    int64_t pts = 0, newpts;
     AVFilterContext **filters;
 
     if(argc < 3) {
@@ -77,9 +78,10 @@ int main(int argc, char **argv)
         }
     }
 
-    for(i = 0; i < 10; i ++) {
-        sdl_display(filters[argc-2]);
-        sleep(1);
+    while(pts < 5000) {
+        newpts = sdl_display(filters[argc-2]);
+        usleep(newpts - pts);
+        pts = newpts;
     }
 
     ret = 0;

Modified: libavfilter/vo_sdl.c
==============================================================================
--- libavfilter/vo_sdl.c	(original)
+++ libavfilter/vo_sdl.c	Sat Jul 14 19:31:40 2007
@@ -28,6 +28,7 @@
 typedef struct
 {
     SDL_Surface *surface;
+    int64_t pts;
 } SDLContext;
 
 static int init(AVFilterContext *ctx, const char *args)
@@ -69,6 +70,7 @@ static void start_frame(AVFilterLink *li
 {
     SDLContext *sdl = link->dst->priv;
     avfilter_default_start_frame(link, picref);
+    sdl->pts = picref->pts;
     SDL_LockSurface(sdl->surface);
 
     av_log(link->dst, AV_LOG_INFO, "start_frame()\n");
@@ -104,12 +106,13 @@ static void end_frame(AVFilterLink *link
 }
 
 /* XXX: this is a hack.  should provide a proper vout interface */
-void sdl_display(AVFilterContext *ctx)
+int64_t sdl_display(AVFilterContext *ctx)
 {
     SDLContext *sdl = ctx->priv;
 
     SDL_Flip(sdl->surface);
     avfilter_request_frame(ctx->inputs[0]);
+    return sdl->pts;
 }
 
 AVFilter vo_sdl =

Modified: libavfilter/vsrc_dummy.c
==============================================================================
--- libavfilter/vsrc_dummy.c	(original)
+++ libavfilter/vsrc_dummy.c	Sat Jul 14 19:31:40 2007
@@ -27,6 +27,10 @@
 #define GREEN   0x60
 #define BLUE    0xC0
 
+typedef struct {
+    int64_t pts;
+} DummyContext;
+
 static int *query_formats(AVFilterLink *link)
 {
     return avfilter_make_format_list(1, PIX_FMT_RGB24);
@@ -42,12 +46,15 @@ static int config_props(AVFilterLink *li
 
 static void request_frame(AVFilterLink *link)
 {
+    DummyContext *ctx = link->src->priv;
     AVFilterPicRef *pic;
 
     int x, y;
     uint8_t *row, *cur;
 
     pic = avfilter_get_video_buffer(link, AV_PERM_WRITE);
+    pic->pts  =
+    ctx->pts += 30;
     avfilter_start_frame(link, avfilter_ref_pic(pic, ~0));
 
     row = pic->data[0];
@@ -71,7 +78,7 @@ AVFilter vsrc_dummy =
 {
     .name      = "dummy",
     .author    = "Bobby Bingham",
-    .priv_size = 0,
+    .priv_size = sizeof(DummyContext),
 
     .inputs    = (AVFilterPad[]) {{ .name = NULL }},
     .outputs   = (AVFilterPad[]) {{ .name            = "default",

Modified: libavfilter/vsrc_ppm.c
==============================================================================
--- libavfilter/vsrc_ppm.c	(original)
+++ libavfilter/vsrc_ppm.c	Sat Jul 14 19:31:40 2007
@@ -24,6 +24,7 @@
 #include "avfilter.h"
 
 typedef struct {
+    int64_t pts;
     int w, h;
     FILE *in;
     AVFilterPicRef *pic;
@@ -89,6 +90,8 @@ static void request_frame(AVFilterLink *
     }
 
     out = avfilter_ref_pic(ppm->pic, ~AV_PERM_WRITE);
+    out->pts  =
+    ppm->pts += 30;
     avfilter_start_frame(link, out);
     avfilter_draw_slice(link, out->data, 0, out->h);
     avfilter_end_frame(link);



More information about the FFmpeg-soc mailing list