[g3dvl] add some more PIPE_VIDEO_CAPs
authorChristian König <deathsimple@vodafone.de>
Mon, 11 Jul 2011 22:12:12 +0000 (00:12 +0200)
committerChristian König <deathsimple@vodafone.de>
Mon, 11 Jul 2011 22:12:12 +0000 (00:12 +0200)
src/gallium/auxiliary/vl/vl_decoder.c
src/gallium/auxiliary/vl/vl_decoder.h
src/gallium/auxiliary/vl/vl_video_buffer.c
src/gallium/auxiliary/vl/vl_video_buffer.h
src/gallium/drivers/nvfx/nvfx_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/state_trackers/vdpau/query.c

index 2be5c17ed3e7a7d76a5a46e54a2085ee2a7eb7da..fac03359a0f3292a916195046ba29ec861f9f3df 100644 (file)
 #include "vl_decoder.h"
 #include "vl_mpeg12_decoder.h"
 
+bool
+vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile)
+{
+   assert(screen);
+   switch (u_reduce_video_profile(profile)) {
+      case PIPE_VIDEO_CODEC_MPEG12:
+         return true;
+      default:
+         return false;
+   }
+}
+
 struct pipe_video_decoder *
 vl_create_decoder(struct pipe_context *pipe,
                   enum pipe_video_profile profile,
index 440f5ecfb049b76537c881a4163da09b251d0cb3..0e9280dbfa20bb84e7ea68837974d77ac21d1c12 100644 (file)
 
 #include <pipe/p_video_decoder.h>
 
+/**
+ * check if a given profile is supported with shader based decoding
+ */
+bool
+vl_profile_supported(struct pipe_screen *screen, enum pipe_video_profile profile);
+
 /**
  * standard implementation of pipe->create_video_decoder
  */
index 8b05749659f935c725230fe66e7637f0b170d148..4d8b6649dd25704d39d8d0e3163e86cd409e9349 100644 (file)
@@ -88,6 +88,16 @@ vl_video_buffer_is_format_supported(struct pipe_screen *screen,
    return true;
 }
 
+unsigned
+vl_video_buffer_max_size(struct pipe_screen *screen)
+{
+   uint32_t max_2d_texture_level;
+
+   max_2d_texture_level = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
+
+   return 1 << (max_2d_texture_level-1);
+}
+
 static void
 vl_video_buffer_destroy(struct pipe_video_buffer *buffer)
 {
index 78aac3fa0f22ac8518339af072b150e30182cfc1..291d15c1e9d0b09c2ed69a0d14bf561c8b6dcf80 100644 (file)
@@ -54,6 +54,12 @@ struct vl_video_buffer
 const enum pipe_format *
 vl_video_buffer_formats(struct pipe_screen *screen, enum pipe_format format);
 
+/**
+ * get maximum size of video buffers
+ */
+unsigned
+vl_video_buffer_max_size(struct pipe_screen *screen);
+
 /**
  * check if video buffer format is supported for a codec/profile
  * can be used as default implementation of screen->is_video_format_supported
index 4901e3b2bf76ee3d35f25e45118facaa9bc316c4..d85c0a6da4140e06069e6fdcb060582c1b0956ac 100644 (file)
@@ -3,6 +3,7 @@
 #include "util/u_format.h"
 #include "util/u_format_s3tc.h"
 #include "util/u_simple_screen.h"
+#include "vl/vl_decoder.h"
 #include "vl/vl_video_buffer.h"
 
 #include "nouveau/nouveau_screen.h"
@@ -213,8 +214,13 @@ nvfx_screen_get_video_param(struct pipe_screen *screen,
                                enum pipe_video_cap param)
 {
        switch (param) {
+       case PIPE_VIDEO_CAP_SUPPORTED:
+               return vl_profile_supported(screen, profile);
        case PIPE_VIDEO_CAP_NPOT_TEXTURES:
                return 0;
+       case PIPE_VIDEO_CAP_MAX_WIDTH:
+       case PIPE_VIDEO_CAP_MAX_HEIGHT:
+               return vl_video_buffer_max_size(screen);
        default:
                return 0;
        }
index 19b273f4f492b73ad219aa1c937f61da65739232..c8df45fb3e7a12984a0edd34b5b2ab9a070bb407 100644 (file)
@@ -25,6 +25,7 @@
 #include "util/u_format_s3tc.h"
 #include "util/u_memory.h"
 #include "os/os_time.h"
+#include "vl/vl_decoder.h"
 #include "vl/vl_video_buffer.h"
 
 #include "r300_context.h"
@@ -307,12 +308,17 @@ static int r300_get_video_param(struct pipe_screen *screen,
                                enum pipe_video_profile profile,
                                enum pipe_video_cap param)
 {
-       switch (param) {
-       case PIPE_VIDEO_CAP_NPOT_TEXTURES:
-               return 0;
-       default:
-               return 0;
-       }
+   switch (param) {
+      case PIPE_VIDEO_CAP_SUPPORTED:
+         return vl_profile_supported(screen, profile);
+      case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+         return 0;
+      case PIPE_VIDEO_CAP_MAX_WIDTH:
+      case PIPE_VIDEO_CAP_MAX_HEIGHT:
+         return vl_video_buffer_max_size(screen);
+      default:
+         return 0;
+   }
 }
 
 static boolean r300_is_format_supported(struct pipe_screen* screen,
index 8e492787235caf9170e771dc7a727957e9c37ea6..65b12de79b1bc334b3b0249781cea15692b94455 100644 (file)
@@ -491,8 +491,13 @@ static int r600_get_video_param(struct pipe_screen *screen,
                                enum pipe_video_cap param)
 {
        switch (param) {
+       case PIPE_VIDEO_CAP_SUPPORTED:
+               return vl_profile_supported(screen, profile);
        case PIPE_VIDEO_CAP_NPOT_TEXTURES:
                return 1;
+       case PIPE_VIDEO_CAP_MAX_WIDTH:
+       case PIPE_VIDEO_CAP_MAX_HEIGHT:
+               return vl_video_buffer_max_size(screen);
        default:
                return 0;
        }
index f952e6046f05263da4bdb2ebf8f0e55f0d1d536b..1e58d27be88ac4fb24d4d19d7c7878bf67ec3216 100644 (file)
@@ -33,6 +33,7 @@
 #include "pipe/p_defines.h"
 #include "pipe/p_screen.h"
 #include "draw/draw_context.h"
+#include "vl/vl_decoder.h"
 #include "vl/vl_video_buffer.h"
 
 #include "state_tracker/sw_winsys.h"
@@ -177,8 +178,13 @@ softpipe_get_video_param(struct pipe_screen *screen,
                          enum pipe_video_cap param)
 {
    switch (param) {
+   case PIPE_VIDEO_CAP_SUPPORTED:
+       return vl_profile_supported(screen, profile);
    case PIPE_VIDEO_CAP_NPOT_TEXTURES:
       return 0;
+   case PIPE_VIDEO_CAP_MAX_WIDTH:
+   case PIPE_VIDEO_CAP_MAX_HEIGHT:
+      return vl_video_buffer_max_size(screen);
    default:
       return 0;
    }
index d8b1a9e171f2296ad531c032c09f7d554b4da747..7f1bf0dee6827111e50ee92c880df3fc2abae572 100644 (file)
@@ -496,7 +496,10 @@ enum pipe_shader_cap
 /* Video caps, can be different for each codec/profile */
 enum pipe_video_cap
 {
-   PIPE_VIDEO_CAP_NPOT_TEXTURES = 0,
+   PIPE_VIDEO_CAP_SUPPORTED = 0,
+   PIPE_VIDEO_CAP_NPOT_TEXTURES = 1,
+   PIPE_VIDEO_CAP_MAX_WIDTH = 2,
+   PIPE_VIDEO_CAP_MAX_HEIGHT = 3,
 };
 
 enum pipe_video_codec
index a32fd406bf54857ce7ba8229005af5075d2a776d..ec17e59118fa487b67c6ca8987c560c58251acb9 100644 (file)
@@ -128,11 +128,7 @@ vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile,
 {
    vlVdpDevice *dev;
    struct pipe_screen *pscreen;
-
    enum pipe_video_profile p_profile;
-   uint32_t max_decode_width;
-   uint32_t max_decode_height;
-   uint32_t max_2d_texture_level;
 
    VDPAU_MSG(VDPAU_TRACE, "[VDPAU] Querying decoder\n");
 
@@ -152,24 +148,20 @@ vlVdpDecoderQueryCapabilities(VdpDevice device, VdpDecoderProfile profile,
       *is_supported = false;
       return VDP_STATUS_OK;
    }
-
-   if (p_profile != PIPE_VIDEO_PROFILE_MPEG2_SIMPLE && p_profile != PIPE_VIDEO_PROFILE_MPEG2_MAIN)  {
-      *is_supported = false;
-      return VDP_STATUS_OK;
+   
+   *is_supported = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_SUPPORTED);
+   if (*is_supported) {
+      *max_width = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_WIDTH); 
+      *max_height = pscreen->get_video_param(pscreen, p_profile, PIPE_VIDEO_CAP_MAX_HEIGHT);
+      *max_level = 16;
+      *max_macroblocks = (*max_width/16)*(*max_height/16);
+   } else {
+      *max_width = 0;
+      *max_height = 0;
+      *max_level = 0;
+      *max_macroblocks = 0;
    }
 
-   /* XXX hack, need to implement something more sane when the decoders have been implemented */
-   max_2d_texture_level = pscreen->get_param(pscreen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
-   max_decode_width = max_decode_height = pow(2,max_2d_texture_level-2);
-   if (!(max_decode_width && max_decode_height))
-      return VDP_STATUS_RESOURCES;
-
-   *is_supported = true;
-   *max_width = max_decode_width;
-   *max_height = max_decode_height;
-   *max_level = 16;
-   *max_macroblocks = (max_decode_width/16) * (max_decode_height/16);
-
    return VDP_STATUS_OK;
 }