nv vpe video decoder
Subsystems (3)
Hello,
I have my work on the nv vpe video decoder in a functional state. In case you didn't know this decoder accelerates mpeg2 video at the idct/mc level. I have verified that it works on nv40 hardware. I believe it works on nv30 hardware (and maybe some earlier hardware), but I cannot verify since I have none.
I will reply with patches against the kernel, drm, ddx and mesa for your review. Any comments are welcome.
An important note is that the performance isn't that great in my opinion. There is something preventing the nv vpe engine from rendering cmds at the same rate as the blob. Either caching or whatever.
Jimmy Rentz
A message that is not in the archive (sent off-list or not yet received): 20100805223618.1cdcbb08-bEIzoA7YQWm4miubQJdzGGS2/mPcPMSI/[email protected]
PATCH 1/4 kernel: nv vpe
This patch includes all the relevant nv vpe kernel support. This patch applies against the latest nouveau-linux-2.6. Though, the makefile might need adjusting.
Some notes about the decoder engine:
* It is composed of the mmio control registers, fifo and the output surfaces.
* The fifo pushbuffer can be allocated from vram or agp. AGP is not working right now but it should in theory.
* Output surfaces for the luma+chroma data can be only be allocated from vram.
* Since only one set of mmio control registers exist only one client app can use the engine at a time. I suppose it might be possible to support context switching but that might be too slow to be useful.
Client usage:
* Client app calls the vpe channel create ioctl to setup the hw and fifo pushbuffer.
* Client app creates all the output surfaces via buffer objects.
* Client apps writes a set of cmds to the pushbuffer then calls the fire ioctl to kick of a decode of a cmd sequence.
* Client app calls the query ioctl to see when an output surface is done rendering.
Some notes about the kernel implementation:
* Both user and kernel submission of pushbuffers is supported. I originally implemented the kernel submission via a copy of the pushbuffer. The user-space pushbuffer was added later for performance reaons. Though, you still need to call the kernel to fire since mmio access is not allowed for user-mode.
* The output surface must be pinned in memory until the rendering is done. A sequence type fence exists that lets you query when a given output surface is done decoding. This would make it possible to free a surface if you want. The kernel would then automatically unpin the surface if you replace it later. Realistically, it wouldn't be smart for performance reasons to free these surfaces.
drivers/gpu/drm/nouveau/Makefile +1 -1
@@ -23,7 +23,7 @@ nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \ nv04_dac.o nv04_dfp.o nv04_tv.o nv17_tv.o nv17_tv_modes.o \ nv04_crtc.o nv04_display.o nv04_cursor.o nv04_fbcon.o \ nv10_gpio.o nv50_gpio.o \ - nv50_calc.o + nv50_calc.o nouveau_vd_vpe.o nouveau-$(CONFIG_DRM_NOUVEAU_DEBUG) += nouveau_debugfs.o nouveau-$(CONFIG_COMPAT) += nouveau_ioc32.o
drivers/gpu/drm/nouveau/nouveau_channel.c +17 -0
@@ -336,6 +336,15 @@ nouveau_channel_cleanup(struct drm_device *dev, struct drm_file *file_priv)if (chan && chan->file_priv == file_priv)nouveau_channel_free (chan); } + +if (dev_priv->vpe_channel) { +NV_DEBUG (dev,"clearing VPE channel from file_priv\n" ); +struct nouveau_vd_vpe_channel *vpe_channel; + vpe_channel = dev_priv->vpe_channel; + +if (vpe_channel->file_priv == file_priv) +nouveau_vpe_channel_free (vpe_channel); + } }int
@@ -437,6 +446,14 @@ struct drm_ioctl_desc nouveau_ioctls[] = {DRM_IOCTL_DEF (DRM_NOUVEAU_GEM_CPU_PREP , nouveau_gem_ioctl_cpu_prep,DRM_AUTH ),DRM_IOCTL_DEF (DRM_NOUVEAU_GEM_CPU_FINI , nouveau_gem_ioctl_cpu_fini,DRM_AUTH ),DRM_IOCTL_DEF (DRM_NOUVEAU_GEM_INFO , nouveau_gem_ioctl_info,DRM_AUTH ), +DRM_IOCTL_DEF (DRM_NOUVEAU_VD_VPE_CHANNEL_ALLOC , + nouveau_vd_vpe_ioctl_channel_alloc,DRM_AUTH ), +DRM_IOCTL_DEF (DRM_NOUVEAU_VD_VPE_CHANNEL_FREE , + nouveau_vd_vpe_ioctl_channel_free,DRM_AUTH ), +DRM_IOCTL_DEF (DRM_NOUVEAU_VD_VPE_PUSHBUF_FIRE , + nouveau_vd_vpe_ioctl_pushbuf_fire,DRM_AUTH ), +DRM_IOCTL_DEF (DRM_NOUVEAU_VD_VPE_SURFACE_QUERY , + nouveau_vd_vpe_ioctl_surface_query, DRM_AUTH), };int nouveau_max_ioctl =DRM_ARRAY_SIZE (nouveau_ioctls);
drivers/gpu/drm/nouveau/nouveau_debugfs.c +111 -0
117 lines not on this page · raw message
drivers/gpu/drm/nouveau/nouveau_drv.h +69 -0
109 lines not on this page · raw message
drivers/gpu/drm/nouveau/nouveau_reg.h +31 -0
@@ -176,6 +176,37 @@#define NV04_PTIMER_TIME_1 0x00009410#define NV04_PTIMER_ALARM_0 0x00009420 +/* The NV VPE MPEG2 control registers that exist on NV40 and NV30 and +* some other older boards possibly.*/ +#define NV_VPE_MPEG2_ENGINE_CONFIG_1 0x0000B0E0 +#define NV_VPE_MPEG2_ENGINE_CONFIG_2 0x0000B0E8 +#define NV_VPE_MPEG2_ENGINE_SETUP_1 0x0000B100 +#define NV_VPE_MPEG2_ENGINE_SETUP_2 0x0000B140 +#define NV_VPE_MPEG2_ENGINE_STATUS 0x0000B200 +#define NV_VPE_MPEG2_ENGINE_READER_CONFIG 0x0000B204 +#define NV_VPE_MPEG2_USER_CONFIG 0x0000B300 +# define NV_VPE_MPEG2_USER_NOT_PRESENT 0x020F0200 +# define NV_VPE_MPEG2_USER_PRESENT 0x02001ec1 +# define NV_VPE_MPEG2_USER_VRAM (0 << 16) +# define NV_VPE_MPEG2_USER_AGP_OR_PCI (1 << 16) +# define NV_VPE_MPEG2_USER_AGP_OR_PCI_READY (2 << 16) +/* Complete guess here about pcie.*/ +# define NV_VPE_MPEG2_USER_PCIE (8 << 16) +#define NV_VPE_MPEG2_UNKNOWN_SETUP_3 0x0000B314 +#define NV_VPE_MPEG2_USER_OFFSET 0x0000B320 +#define NV_VPE_MPEG2_USER_SIZE 0x0000B324 +#define NV_VPE_MPEG2_USER_PUT 0x0000B328 +#define NV_VPE_MPEG2_USER_GET 0x0000B330 +#define NV_VPE_MPEG2_ENGINE_CONTROL 0x0000B32C +# define NV_VPE_MPEG2_ENGINE_STOP 0 +# define NV_VPE_MPEG2_ENGINE_START 1 +#define NV_VPE_MPEG2_SEQUENCE_GET 0x0000B340 +#define NV_VPE_MPEG2_SURFACE_INFO 0x0000B378 +#define NV_VPE_MPEG2_CONTEXT_DIMENSIONS 0x0000B37C +#define NV_VPE_MPEG2_LUMA_SURFACE_OFFSET_GET (s) (0x0000B450 + (s * 8)) +#define NV_VPE_MPEG2_CHROMA_SURFACE_OFFSET_GET (s) (0x0000B454 + (s * 8)) +#define NV_VPE_MPEG2_ENGINE_STATUS_1 0x0000B848 +#define NV04_PGRAPH_DEBUG_0 0x00400080#define NV04_PGRAPH_DEBUG_1 0x00400084#define NV04_PGRAPH_DEBUG_2 0x00400088
drivers/gpu/drm/nouveau/nouveau_vd_vpe.c new file +1218 -0
1,218 lines not on this page · raw message
drivers/gpu/drm/nouveau/nouveau_vpe_hw.h new file +153 -0
153 lines not on this page · raw message
include/drm/nouveau_drm.h +50 -0
61 lines not on this page · raw message
PATCH 2/4 drm: nv vpe
In reply to a message not in the archiveThis patch includes all the relevant nv vpe drm support. This patch applies against the latest drm.
The drm portion has a couple of classes that interface with the kernel vpe layer:
* nouveau_vpe_channel class - Manages the drm vpe channel. This includes open the vpe channel in the kernel, setting up the pushbuf and each output surface. Right now I force the pushbuffer to be allocated/managed from user-mode. This is performance reaons. However, the kernel can always decline this.
* nouveau_vpe_pushbuf class - Manages the pushbuf.
This includes starting/ending cmd sequences, writing the cmds to the pushbuf and firing.
include/drm/nouveau_drm.h +51 -0
@@ -79,6 +79,7 @@ struct drm_nouveau_gpuobj_free {#define NOUVEAU_GETPARAM_CHIPSET_ID 11#define NOUVEAU_GETPARAM_VM_VRAM_BASE 12#define NOUVEAU_GETPARAM_GRAPH_UNITS 13 +#define NOUVEAU_GETPARAM_PTIMER_TIME 14struct drm_nouveau_getparam {uint64_t param;uint64_t value;
@@ -183,6 +184,52 @@ enum nouveau_bus_type {struct drm_nouveau_sarea { }; +/* VPE Supports mpeg2 only.*/ +struct drm_nouveau_vd_vpe_channel_alloc { +uint32_t width; +uint32_t height; +/* Used for user pushbuf access. +* mmio access is not allowed so you still need to fire as normal.*/ +uint32_t pushbuf_handle; +}; + +struct drm_nouveau_vd_vpe_channel_free { +}; + +#define NOUVEAU_VD_VPE_PUSHBUF_FIRE_FLAG_END_SEQUENCE 0x00000001 +#define NOUVEAU_VD_VPE_PUSHBUF_FIRE_FLAG_UPDATE_DMA_POS 0x00000002 +/* structure for surface.*/ +struct drm_nouveau_vd_vpe_surface { +uint32_t luma_handle; +uint32_t chroma_handle; +uint32_t surface_index; +}; + +/* This flag lets you turn off firing for a specific batch. +* This is needed in some cases to avoid locking up the decoder.*/ +#define NOUVEAU_VD_VPE_PUSHBUF_FIRE_BATCH_DO_NOT_FIRE 0x10000000 +struct drm_nouveau_vd_vpe_pushbuf_fire { +/* [in] */ +uint32_t nr_dwords; +uint64_t dwords; +uint32_t nr_batches; +uint64_t batches; +/* Surface[0] is always the target.*/ +uint32_t nr_surfaces; +uint64_t surfaces; +uint32_t flags; +/* Needed when writing to the hw pushbuf from user space. +* This also will perform a fire.*/ +uint32_t dma_cur; +/* [out] */ +uint32_t dma_free; +}; + +struct drm_nouveau_vd_vpe_surface_query { +uint32_t surface_index; +uint32_t is_busy; +}; +#define DRM_NOUVEAU_GETPARAM 0x00#define DRM_NOUVEAU_SETPARAM 0x01#define DRM_NOUVEAU_CHANNEL_ALLOC 0x02
@@ -195,5 +242,9 @@ struct drm_nouveau_sarea {#define DRM_NOUVEAU_GEM_CPU_PREP 0x42#define DRM_NOUVEAU_GEM_CPU_FINI 0x43#define DRM_NOUVEAU_GEM_INFO 0x44 +#define DRM_NOUVEAU_VD_VPE_CHANNEL_ALLOC 0x49 +#define DRM_NOUVEAU_VD_VPE_CHANNEL_FREE 0x50 +#define DRM_NOUVEAU_VD_VPE_PUSHBUF_FIRE 0x51 +#define DRM_NOUVEAU_VD_VPE_SURFACE_QUERY 0x52#endif /* __NOUVEAU_DRM_H__ */
nouveau/Makefile.am +7 -2
@@ -19,7 +19,9 @@ libdrm_nouveau_la_SOURCES = \ nouveau_bo.c \ nouveau_resource.c \ nouveau_private.h \ - nouveau_reloc.c + nouveau_reloc.c \ + nouveau_vpe_channel.c \ + nouveau_vpe_pushbuf.c libdrm_nouveaucommonincludedir = ${includedir}/nouveau libdrm_nouveaucommoninclude_HEADERS = \
@@ -30,7 +32,10 @@ libdrm_nouveaucommoninclude_HEADERS = \ nouveau_pushbuf.h \ nouveau_bo.h \ nouveau_resource.h \ - nouveau_reloc.h + nouveau_reloc.h \ + nouveau_vpe_channel.h \ + nouveau_vpe_pushbuf.h \ + nouveau_vpe_hw.h libdrm_nouveauincludedir = ${includedir}/libdrm
nouveau/nouveau_vpe_channel.c new file +301 -0
301 lines not on this page · raw message
nouveau/nouveau_vpe_channel.h new file +72 -0
72 lines not on this page · raw message
nouveau/nouveau_vpe_hw.h new file +153 -0
153 lines not on this page · raw message
nouveau/nouveau_vpe_pushbuf.c new file +429 -0
429 lines not on this page · raw message
nouveau/nouveau_vpe_pushbuf.h new file +89 -0
89 lines not on this page · raw message
PATCH 3/4 ddx: nv vpe
In reply to a message not in the archiveThis patch includes all the relevant nv vpe ddx support. This patch applies against the latest xf86-video-nouveau.
This is hooks up the XV blit adapter to be used for XvMC IDCT on NV30/NV40 cards. This makes it possible to fallback to g3dvl XvMC if nv vpe is in use.
src/nouveau_xv.c +1 -0
@@ -2062,6 +2062,7 @@ NVInitVideo(ScreenPtr pScreen)XF86VideoAdaptorPtr blitAdaptor =NULL ;XF86VideoAdaptorPtr textureAdaptor[2 ] = {NULL ,NULL };int num_adaptors; +bool create_vpe_xvmc = false;/* * Driving the blitter requires the DMA FIFO. Using the FIFO
@@ -2140,14 +2141,28 @@ NVInitVideo(ScreenPtr pScreen)* associate with any/all adapters since VL doesn't depend on
Xv for color conversion. */
if (textureAdaptor[0]) {
- XF86MCAdaptorPtr *adaptorsXvMC =
xalloc(sizeof(XF86MCAdaptorPtr));
+ if (blitAdaptor && ( (pNv->Architecture == NV_ARCH_30)
||
+ (pNv->Architecture == NV_ARCH_40) ) ) {
+ create_vpe_xvmc = true;
+ num_adaptors = 2;+ }
+ else
+ num_adaptors = 1;
+
+ XF86MCAdaptorPtr *adaptorsXvMC = xalloc(num_adaptors *
sizeof(XF86MCAdaptorPtr));
if (adaptorsXvMC) {
adaptorsXvMC[0] = vlCreateAdaptorXvMC(pScreen,
textureAdaptor[0]->name);
+ if (create_vpe_xvmc)
+ adaptorsXvMC[1] =vlCreateAdaptorXvMCVPE(pScreen, blitAdaptor->name);
+
if (adaptorsXvMC[0]) {
- vlInitXvMC(pScreen, 1, adaptorsXvMC);
+ vlInitXvMC(pScreen, num_adaptors,
adaptorsXvMC); vlDestroyAdaptorXvMC(adaptorsXvMC[0]);
+
+ if (num_adaptors > 1)
+vlDestroyAdaptorXvMC(adaptorsXvMC[1]); }
xfree(adaptorsXvMC);
src/vl_hwmc.c +34 -0
@@ -58,11 +58,30 @@ static XF86MCSurfaceInfoRec yv12_mpeg2_surface = &subpicture_list }; +static XF86MCSurfaceInfoRec yv12_mpeg2_vpe_surface = +{ +FOURCC_YV12 , +XVMC_CHROMA_FORMAT_420 , +0 , +2032 , +2032 , +2048 , +2048 , +XVMC_IDCT |XVMC_MPEG_2 , +XVMC_SUBPICTURE_INDEPENDENT_SCALING |XVMC_BACKEND_SUBPICTURE , + &subpicture_list +}; +static XF86MCSurfaceInfoPtr surfaces[] = { (XF86MCSurfaceInfoPtr)&yv12_mpeg2_surface }; +static XF86MCSurfaceInfoPtr vpe_surfaces[] = +{ + (XF86MCSurfaceInfoPtr)&yv12_mpeg2_vpe_surface +}; +static XF86ImageRec rgb_subpicture =XVIMAGE_RGB ; static XF86ImagePtr subpictures[] =
@@ -85,6 +104,21 @@ static XF86MCAdaptorRec adaptor_template = (xf86XvMCDestroySubpictureProcPtr )NULL }; +static XF86MCAdaptorRec vpe_adaptor_template = +{ +"" , +1 , + vpe_surfaces, +1 , + subpictures, + (xf86XvMCCreateContextProcPtr )NULL , + (xf86XvMCDestroyContextProcPtr )NULL , + (xf86XvMCCreateSurfaceProcPtr )NULL , + (xf86XvMCDestroySurfaceProcPtr )NULL , + (xf86XvMCCreateSubpictureProcPtr )NULL , + (xf86XvMCDestroySubpictureProcPtr )NULL +}; + XF86MCAdaptorPtr vlCreateAdaptorXvMC(ScreenPtr pScreen, char
*xv_adaptor_name) {
XF86MCAdaptorPtr adaptor;
@@ -110,6 +144,31 @@ XF86MCAdaptorPtr vlCreateAdaptorXvMC(ScreenPtr pScreen, char *xv_adaptor_name) return adaptor;
}
+XF86MCAdaptorPtr vlCreateAdaptorXvMCVPE(ScreenPtr pScreen, char *xv_adaptor_name) +{
+ XF86MCAdaptorPtr adaptor;
+ ScrnInfoPtr pScrn;
+
+ assert(pScreen);
+ assert(xv_adaptor_name);
+
+ pScrn = xf86Screens[pScreen->myNum];
+ adaptor = xf86XvMCCreateAdaptorRec();
+
+ if (!adaptor)
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[XvMC.VPE]
Memory allocation failed.\n");
+ return NULL;
+ }
+
+ *adaptor = vpe_adaptor_template;
+ adaptor->name = xv_adaptor_name;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[XvMC.VPE] Associated
with %s.\n", xv_adaptor_name);
+
+ return adaptor;
+}
+
void vlDestroyAdaptorXvMC(XF86MCAdaptorPtr adaptor)
{
assert(adaptor);
src/vl_hwmc.h +0 -0
@@ -4,6 +4,7 @@#include <xf86xvmc.h> XF86MCAdaptorPtr vlCreateAdaptorXvMC(ScreenPtr pScreen, char
*xv_adaptor_name); +XF86MCAdaptorPtr vlCreateAdaptorXvMCVPE(ScreenPtr pScreen, char *xv_adaptor_name); void vlDestroyAdaptorXvMC(XF86MCAdaptorPtr adaptor); void vlInitXvMC(ScreenPtr pScreen, unsigned int num_adaptors, XF86MCAdaptorPtr *adaptors);
PATCH 4/4 mesa: nv vpe
In reply to a message not in the archiveThis patch includes all the relevant nv vpe mesa support. This patch applies against the latest mesa.pipe-video branch.
This is where all the real nv vpe work is done.
There are several changes required:
* Modify the existing pipe-video arch to support nv vpe -
1. Push decode verifiction down into each context creation method.
2. Add some new decode flags into the context creation method.
3. Add some surface init/query methods -
This includes a full XVMCQuerySurface/XVMCSyncSurface support.
* Modify the pipe-video vl compositor to support nv12 surfaces. This means the frag shader/renderer needs to deal with 2 luma+chroma surfaces.
* Add the nv vpe video context - This uses the nv vpe video renderer for render and the vl compositor for display.
Since the render output is nv12 the pipe video surface is actually made up of 2 surfaces. One for luma (R8) and one for chroma (G8B8 and 1/2 luma).
* Add the nv vpe video renderer -
This includes:
* Open/close vpe channel.
* Allocate/free vpe output surface from a buffer object.
* Query vpe output surface status.
* MB render.
* Hookup the nv vpe video context in the nvfx video context chain.
* Add the G8B8_UNORM pipe texture format.
This is required for the luma portion of the nv12 format for component swizziling purposes.
* Add nv40 fragtex texture mapping for R8_UNORM and G8B8_UNORM with the correct component swizzles.
src/gallium/auxiliary/util/u_format.csv +1 -0
@@ -201,6 +201,7 @@ PIPE_FORMAT_R16G16B16_SSCALED , plain, 1, 1, s16 , s16 , s16 , , xyz1, r PIPE_FORMAT_R16G16B16A16_SSCALED , plain, 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb PIPE_FORMAT_R8_UNORM , plain, 1, 1, un8 , , , , x001, rgb PIPE_FORMAT_R8G8_UNORM , plain, 1, 1, un8 , un8 , , , xy01, rgb +PIPE_FORMAT_G8B8_UNORM , plain, 1, 1, un8 , un8 , , , yxyx, rgb PIPE_FORMAT_R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , , xyz1, rgb PIPE_FORMAT_R8G8B8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, rgb PIPE_FORMAT_R8_USCALED , plain, 1, 1, u8 , , , , x001, rgb
src/gallium/auxiliary/vl/vl_compositor.c +208 -10
275 lines not on this page · raw message
src/gallium/auxiliary/vl/vl_compositor.h +17 -2
@@ -42,9 +42,10 @@ struct vl_compositor {struct pipe_context *pipe; +enum pipe_format src_surface_format;struct pipe_framebuffer_state fb_state;struct vertex2f fb_inv_size; -void *sampler; +void *sampler[2 ];struct pipe_sampler_view *sampler_view;void *vertex_shader; struct
@@ -68,7 +69,8 @@ struct vl_compositorstruct keymap *texview_map; }; -bool vl_compositor_init (struct vl_compositor *compositor,struct pipe_context *pipe); +bool vl_compositor_init (struct vl_compositor *compositor,struct pipe_context *pipe, +enum pipe_format src_surface_format);void vl_compositor_cleanup (struct vl_compositor *compositor);
@@ -92,6 +94,19 @@ void vl_compositor_render(struct vl_compositor *compositor,struct pipe_surface *dst_surface, struct pipe_video_rect *dst_area, struct pipe_fence_handle **fence); + +void vl_compositor_render_nv12 (struct vl_compositor *compositor, +struct pipe_surface *src_luma_surface, +struct pipe_surface *src_chroma_surface, +enum pipe_mpeg12_picture_type picture_type, +/*unsigned num_past_surfaces, +struct pipe_surface *past_surfaces, +unsigned num_future_surfaces, +struct pipe_surface *future_surfaces,*/ +struct pipe_video_rect *src_area, +struct pipe_surface *dst_surface, +struct pipe_video_rect *dst_area, +struct pipe_fence_handle **fence);void vl_compositor_set_csc_matrix (struct vl_compositor *compositor,const float *mat);
src/gallium/drivers/nouveau/nouveau_winsys.h +3 -0
@@ -12,6 +12,9 @@#include "nouveau/nouveau_notifier.h" #include "nouveau/nouveau_resource.h" #include "nouveau/nouveau_pushbuf.h" +#include "nouveau/nouveau_vpe_hw.h" +#include "nouveau/nouveau_vpe_channel.h" +#include "nouveau/nouveau_vpe_pushbuf.h" static inline uint32_t nouveau_screen_transfer_flags (unsigned pipe)
src/gallium/drivers/nvfx/Makefile +3 -1
@@ -30,7 +30,9 @@ C_SOURCES = \ nvfx_transfer.c \ nvfx_vbo.c \ nvfx_vertprog.c \ - nvfx_video_context.c + nvfx_video_context.c \ + nvfx_vpe_video_context.c \ + nvfx_vpe_mpeg2_mc_renderer.c LIBRARY_INCLUDES = \ -I$(TOP)/src/gallium/drivers/nouveau/include
src/gallium/drivers/nvfx/nv40_fragtex.c +2 -0
@@ -87,6 +87,8 @@ nv40_texture_formats[] = {_ (DXT1_RGBA ,DXT1 ,S1 ,S1 ,S1 ,S1 ,X ,Y ,Z ,W ,0 ,0 ,0 ,0 ),_ (DXT3_RGBA ,DXT3 ,S1 ,S1 ,S1 ,S1 ,X ,Y ,Z ,W ,0 ,0 ,0 ,0 ),_ (DXT5_RGBA ,DXT5 ,S1 ,S1 ,S1 ,S1 ,X ,Y ,Z ,W ,0 ,0 ,0 ,0 ), +_ (R8_UNORM ,L8 ,S1 ,S1 ,S1 ,S1 ,X ,X ,X ,X ,0 ,0 ,0 ,0 ), + _(G8B8_UNORM , A8L8 , S1, S1, S1, S1, Y, X, Y, X, 0, 0, 0, 0), {}, };
src/gallium/drivers/nvfx/nvfx_video_context.c +13 -2
@@ -26,24 +26,35 @@**************************************************************************/ #include "nvfx_video_context.h" +#include "nvfx_vpe_video_context.h" #include <softpipe/sp_video_context.h> struct pipe_video_context *nvfx_video_create (struct pipe_screen *screen,enum pipe_video_profile profile,enum pipe_video_chroma_format chroma_format, +enum pipe_video_entry_point entry_point, +unsigned decode_flags,unsigned width,unsigned height,void *priv) {struct pipe_context *pipe; +struct pipe_video_context *pvctx;assert (screen); pipe = screen->context_create (screen, priv);if (!pipe)return NULL ; - -return sp_video_create_ex (pipe, profile, chroma_format, width, height, + +/* Try to create vpe context first.*/ + pvctx =nv_vpe_video_create (pipe, profile, chroma_format, entry_point, + decode_flags, width, height, priv); + +if (!pvctx) + pvctx =sp_video_create_ex (pipe, profile, chroma_format, entry_point, + decode_flags, width, height,VL_MPEG12_MC_RENDERER_BUFFER_PICTURE ,VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE , true,PIPE_FORMAT_VUYX ); +return pvctx; }
src/gallium/drivers/nvfx/nvfx_video_context.h +3 -1
@@ -29,10 +29,12 @@#define __NVFX_VIDEO_CONTEXT_H__#include <pipe/p_video_context.h> - +struct pipe_video_context *nvfx_video_create (struct pipe_screen *screen,enum pipe_video_profile profile,enum pipe_video_chroma_format chroma_format, +enum pipe_video_entry_point entry_point, +unsigned decode_flags,unsigned width,unsigned height,void *priv);#endif
src/gallium/drivers/nvfx/nvfx_vpe_mpeg2_mc_renderer.c new file +1053 -0
1,053 lines not on this page · raw message
src/gallium/drivers/nvfx/nvfx_vpe_mpeg2_mc_renderer.h new file +63 -0
63 lines not on this page · raw message
src/gallium/drivers/nvfx/nvfx_vpe_video_context.c new file +532 -0
532 lines not on this page · raw message
src/gallium/drivers/nvfx/nvfx_vpe_video_context.h new file +89 -0
89 lines not on this page · raw message
src/gallium/drivers/softpipe/sp_video_context.c +117 -1
195 lines not on this page · raw message
src/gallium/drivers/softpipe/sp_video_context.h +5 -1
@@ -53,13 +53,17 @@ struct sp_mpeg12_contextstruct pipe_video_context *sp_video_create (struct pipe_screen *screen,enum pipe_video_profile profile,enum pipe_video_chroma_format chroma_format, -unsigned width,unsigned height,void *priv); +enum pipe_video_entry_point entry_point, +unsigned decode_flags,unsigned width,unsigned height, +void *priv);/* Other drivers can call this function in their pipe_video_context constructors and pass it an accelerated pipe_context along with suitable buffering modes, etc */ struct pipe_video_context * sp_video_create_ex(struct pipe_context *pipe, enum pipe_video_profile profile, enum pipe_video_chroma_format chroma_format, + enum pipe_video_entry_point entry_point, + unsigned decode_flags, unsigned width, unsigned height, enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode, enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling,
src/gallium/include/pipe/p_defines.h +10 -0
@@ -487,6 +487,16 @@ enum pipe_video_profilePIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH }; +enum pipe_video_entry_point +{ +PIPE_VIDEO_ENTRY_POINT_CSC , +PIPE_VIDEO_ENTRY_POINT_MC , +PIPE_VIDEO_ENTRY_POINT_IDCT , +PIPE_VIDEO_ENTRY_POINT_BS +}; + +#define PIPE_VIDEO_DECODE_FLAG_MB_INTRA_UNSIGNED 1 + #ifdef __cplusplus }
src/gallium/include/pipe/p_format.h +1 -0
@@ -199,6 +199,7 @@ enum pipe_format {PIPE_FORMAT_VUYX =PIPE_FORMAT_B8G8R8X8_UNORM ,PIPE_FORMAT_IA44 =141 ,PIPE_FORMAT_AI44 =142 , +PIPE_FORMAT_G8B8_UNORM =143 , PIPE_FORMAT_COUNT };
src/gallium/include/pipe/p_screen.h +2 -0
@@ -93,6 +93,8 @@ struct pipe_screen {struct pipe_video_context * (*video_context_create)(struct pipe_screen *screen,enum pipe_video_profile profile,enum pipe_video_chroma_format chroma_format, +enum pipe_video_entry_point entry_point, +unsigned decode_flags,unsigned width,unsigned height,void *priv );/**
src/gallium/include/pipe/p_video_context.h +14 -0
@@ -52,6 +52,8 @@ struct pipe_video_contextstruct pipe_screen *screen;enum pipe_video_profile profile;enum pipe_video_chroma_format chroma_format; +enum pipe_video_entry_point entry_point; +unsigned decode_flags;unsigned width;unsigned height;
@@ -73,6 +75,17 @@ struct pipe_video_context unsigned geom);void (*destroy)(struct pipe_video_context *vpipe); + +/** +* Decoder surface creation/destruction/query +*/ +void (*create_decoder_surface)(struct pipe_video_context *vpipe, +struct pipe_surface **surface); +void (*destroy_decoder_surface)(struct pipe_video_context *vpipe, +struct pipe_surface **surface); +void (*query_decoder_surface)(struct pipe_video_context *vpipe, +struct pipe_surface *surface, +enum pipe_video_surface_status *status);/** * Picture decoding and displaying
@@ -85,6 +98,7 @@ struct pipe_video_contextvoid (*decode_macroblocks)(struct pipe_video_context *vpipe,struct pipe_surface *past,struct pipe_surface *future, +enum pipe_mpeg12_picture_type picture_type,unsigned num_macroblocks,struct pipe_macroblock *macroblocks,struct pipe_fence_handle **fence);
src/gallium/include/pipe/p_video_state.h +14 -0
@@ -38,6 +38,13 @@extern "C" {#endif +enum pipe_video_surface_status +{ +PIPE_VIDEO_SURFACE_STATUS_FREE , +PIPE_VIDEO_SURFACE_STATUS_RENDERING , +PIPE_VIDEO_SURFACE_STATUS_DISPLAYING +}; +struct pipe_video_rect {unsigned x, y, w, h;
@@ -79,6 +86,12 @@ struct pipe_macroblockenum pipe_video_codec codec; }; +/* Same motion_field_select from xvmc.*/ +#define PIPE_VIDEO_MOTION_VERTICAL_FIELD_SELECT_FIRST_FORWARD 0x1 +#define PIPE_VIDEO_MOTION_VERTICAL_FIELD_SELECT_FIRST_BACKWARD 0x2 +#define PIPE_VIDEO_MOTION_VERTICAL_FIELD_SELECT_SECOND_FORWARD 0x4 +#define PIPE_VIDEO_MOTION_VERTICAL_FIELD_SELECT_SECOND_BACKWARD 0x8 +struct pipe_mpeg12_macroblock {struct pipe_macroblock base;
@@ -88,6 +101,7 @@ struct pipe_mpeg12_macroblockenum pipe_mpeg12_macroblock_type mb_type;enum pipe_mpeg12_motion_type mo_type;enum pipe_mpeg12_dct_type dct_type; +unsigned motion_vertical_field_select;signed pmv[2 ][2 ][2 ];unsigned cbp;short *blocks;
src/gallium/state_trackers/xorg/xvmc/context.c +24 -15
@@ -172,6 +172,28 @@ static enum pipe_video_chroma_format FormatToPipe(int xvmc_format)return -1 ; } +static enum pipe_video_entry_point EntryPointToPipe (int xvmc_mc_type) +{ +if (xvmc_mc_type &XVMC_IDCT ) +return PIPE_VIDEO_ENTRY_POINT_IDCT ; +if ((xvmc_mc_type &XVMC_MOCOMP ) ==XVMC_MOCOMP ) +return PIPE_VIDEO_ENTRY_POINT_MC ; + +assert (0 ); + +return -1 ; +} + +static unsigned SurfaceFlagsToPipe (int surface_flags) +{ +unsigned flags =0 ; + +if (surface_flags &XVMC_INTRA_UNSIGNED ) + flags |=PIPE_VIDEO_DECODE_FLAG_MB_INTRA_UNSIGNED ; + +return flags; +} +PUBLIC Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,int width,int height,int flags,XvMCContext *context)
@@ -204,20 +226,6 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,if (ret != Success || !found_port)return ret; -/* XXX: Current limits */ -if (chroma_format !=XVMC_CHROMA_FORMAT_420 ) { -XVMC_MSG (XVMC_ERR ,"[XvMC] Cannot decode requested surface type. Unsupported chroma format.\n" ); -return BadImplementation; - } -if (mc_type != (XVMC_MOCOMP |XVMC_MPEG_2 )) { -XVMC_MSG (XVMC_ERR ,"[XvMC] Cannot decode requested surface type. Non-MPEG2/Mocomp acceleration unsupported.\n" ); -return BadImplementation; - } -if (!(surface_flags &XVMC_INTRA_UNSIGNED )) { -XVMC_MSG (XVMC_ERR ,"[XvMC] Cannot decode requested surface type. Signed intra unsupported.\n" ); -return BadImplementation; - } - context_priv =CALLOC (1 ,sizeof (XvMCContextPrivate));if (!context_priv)return BadAlloc;
@@ -232,7 +240,8 @@ Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id, } vctx =vl_video_create (vscreen,ProfileToPipe (mc_type), -FormatToPipe (chroma_format), width, height); +FormatToPipe (chroma_format),EntryPointToPipe (mc_type), +SurfaceFlagsToPipe (surface_flags), width, height);if (!vctx) {XVMC_MSG (XVMC_ERR ,"[XvMC] Could not create VL context.\n" );
src/gallium/state_trackers/xorg/xvmc/surface.c +50 -37
147 lines not on this page · raw message
src/gallium/winsys/g3dvl/dri/dri_winsys.c +4 -0
@@ -240,6 +240,8 @@ struct vl_context* vl_video_create(struct vl_screen *vscreen, enum pipe_video_profile profile, enum pipe_video_chroma_format chroma_format, + enum pipe_video_entry_point entry_point, + unsigned decode_flags, unsigned width, unsigned height) { struct vl_dri_screen *vl_dri_scrn = (struct vl_dri_screen*)vscreen;
@@ -258,6 +260,8 @@ vl_video_create(struct vl_screen *vscreen, vl_dri_ctx->base.vpipe = vscreen->pscreen->video_context_create (vscreen->pscreen, profile, chroma_format, + entry_point, + decode_flags, width, height, vl_dri_ctx);
src/gallium/winsys/g3dvl/vl_winsys.h +2 -0
@@ -56,6 +56,8 @@ struct vl_context* vl_video_create(struct vl_screen *vscreen, enum pipe_video_profile profile, enum pipe_video_chroma_format chroma_format, + enum pipe_video_entry_point entry_point, + unsigned decode_flags, unsigned width, unsigned height);void vl_video_destroy (struct vl_context *vctx);
src/gallium/winsys/g3dvl/xlib/xsp_winsys.c +4 -0
@@ -164,6 +164,8 @@ struct vl_context* vl_video_create(struct vl_screen *vscreen, enum pipe_video_profile profile, enum pipe_video_chroma_format chroma_format, + enum pipe_video_entry_point entry_point, + unsigned decode_flags, unsigned width, unsigned height) { struct pipe_video_context *vpipe;
@@ -176,6 +178,8 @@ vl_video_create(struct vl_screen *vscreen, vpipe = vscreen->pscreen->video_context_create (vscreen->pscreen, profile, chroma_format, + entry_point, + decode_flags, width, height,NULL );if (!vpipe)return NULL ;