[MPlayer-cvslog] r28550 - in trunk/libmpcodecs: mp_image.h vf.c vf.h

reimar subversion at mplayerhq.hu
Sat Feb 14 09:22:50 CET 2009


Author: reimar
Date: Sat Feb 14 09:22:49 2009
New Revision: 28550

Log:
Add MP_IMGTYPE_NUMBERED which gives access to the kind of mp_image_t that
are numbered and have a "in use" flag which is necessary for proper
buffer management as e.g. H.264 direct-rendering needs and is already used
successfully for the -vo vdpau work-in-progress.

Modified:
   trunk/libmpcodecs/mp_image.h
   trunk/libmpcodecs/vf.c
   trunk/libmpcodecs/vf.h

Modified: trunk/libmpcodecs/mp_image.h
==============================================================================
--- trunk/libmpcodecs/mp_image.h	Thu Feb 12 21:22:02 2009	(r28549)
+++ trunk/libmpcodecs/mp_image.h	Sat Feb 14 09:22:49 2009	(r28550)
@@ -53,6 +53,8 @@
 
 // buffer type was printed (do NOT set this flag - it's for INTERNAL USE!!!)
 #define MP_IMGFLAG_TYPE_DISPLAYED 0x8000
+// set if it can not be reused yet (for MP_IMGTYPE_NUMBERED)
+#define MP_IMGFLAG_IN_USE 0x10000
 
 // codec doesn't support any form of direct rendering - it has own buffer
 // allocation. so we just export its buffer pointers:
@@ -65,6 +67,8 @@
 #define MP_IMGTYPE_IP 3
 // I+P+B type, requires 2+ independent static R/W and 1+ temp WO buffers
 #define MP_IMGTYPE_IPB 4
+// Upper 16 bits give desired buffer number, -1 means get next available
+#define MP_IMGTYPE_NUMBERED 5
 
 #define MP_MAX_PLANES	4
 
@@ -76,8 +80,9 @@
 #define MP_IMGFIELD_INTERLACED 0x20
 
 typedef struct mp_image_s {
-    unsigned short flags;
+    unsigned int flags;
     unsigned char type;
+    int number;
     unsigned char bpp;  // bits/pixel. NOT depth! for RGB it will be n*8
     unsigned int imgfmt;
     int width,height;  // stored dimensions

Modified: trunk/libmpcodecs/vf.c
==============================================================================
--- trunk/libmpcodecs/vf.c	Thu Feb 12 21:22:02 2009	(r28549)
+++ trunk/libmpcodecs/vf.c	Sat Feb 14 09:22:49 2009	(r28550)
@@ -253,6 +253,7 @@ void vf_mpi_clear(mp_image_t* mpi,int x0
 mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){
   mp_image_t* mpi=NULL;
   int w2;
+  int number = mp_imgtype >> 16;
 
 #ifdef MP_DEBUG
   assert(w == -1 || w >= vf->w);
@@ -275,7 +276,7 @@ mp_image_t* vf_get_image(vf_instance_t* 
   
   // Note: we should call libvo first to check if it supports direct rendering
   // and if not, then fallback to software buffers:
-  switch(mp_imgtype){
+  switch(mp_imgtype & 0xff){
   case MP_IMGTYPE_EXPORT:
     if(!vf->imgctx.export_images[0]) vf->imgctx.export_images[0]=new_mp_image(w2,h);
     mpi=vf->imgctx.export_images[0];
@@ -299,6 +300,19 @@ mp_image_t* vf_get_image(vf_instance_t* 
     mpi=vf->imgctx.static_images[vf->imgctx.static_idx];
     vf->imgctx.static_idx^=1;
     break;
+  case MP_IMGTYPE_NUMBERED:
+    if (number == -1) {
+      int i;
+      for (i = 0; i < NUM_NUMBERED_MPI; i++)
+        if (!vf->imgctx.numbered_images[i] || !(vf->imgctx.numbered_images[i]->flags & MP_IMGFLAG_IN_USE))
+          break;
+      number = i;
+    }
+    if (number < 0 || number >= NUM_NUMBERED_MPI) return NULL;
+    if (!vf->imgctx.numbered_images[number]) vf->imgctx.numbered_images[number] = new_mp_image(w2,h);
+    mpi = vf->imgctx.numbered_images[number];
+    mpi->number = number;
+    break;
   }
   if(mpi){
     mpi->type=mp_imgtype;
@@ -306,6 +320,7 @@ mp_image_t* vf_get_image(vf_instance_t* 
     // keep buffer allocation status & color flags only:
 //    mpi->flags&=~(MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE|MP_IMGFLAG_DIRECT);
     mpi->flags&=MP_IMGFLAG_ALLOCATED|MP_IMGFLAG_TYPE_DISPLAYED|MP_IMGFLAGMASK_COLORS;
+    mpi->flags |= MP_IMGFLAG_IN_USE;
     // accept restrictions & draw_slice flags only:
     mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK);
     if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;

Modified: trunk/libmpcodecs/vf.h
==============================================================================
--- trunk/libmpcodecs/vf.h	Thu Feb 12 21:22:02 2009	(r28549)
+++ trunk/libmpcodecs/vf.h	Sat Feb 14 09:22:49 2009	(r28550)
@@ -16,10 +16,13 @@ typedef struct vf_info_s {
     const void* opts;
 } vf_info_t;
 
+#define NUM_NUMBERED_MPI 50
+
 typedef struct vf_image_context_s {
     mp_image_t* static_images[2];
     mp_image_t* temp_images[1];
     mp_image_t* export_images[1];
+    mp_image_t* numbered_images[NUM_NUMBERED_MPI];
     int static_idx;
 } vf_image_context_t;
 



More information about the MPlayer-cvslog mailing list