This is a mirror of official site: http://jasper-net.blogspot.com/

Video Shadering with Direct3D

| Wednesday, June 15, 2011
Introduction

This project started as a testing application for another project I am developing and since I needed some code for rendering YUV420 pixel data and was curious about how Direct3D could be used for 2D graphics - I decided to give it a try. But before I jump into the video implementation details, I will briefly describe some background of 2D graphics with a low-level 3D API. I assume you have a basic knowledge of Direct3D 9 API and HLSL programming.

2D Graphics with Direct3D API

Direct3D is around since 1995 and for a long time was considered a gaming playground. With the rise of the GPU processing power, more and more applications started to take advantage of Direct3D API to facilitate the capabilities of parallel processing and floating point calculations - areas where the GPU outperforms CPU. Image and video processing is one of these areas where GPU may dramatically improve performance and user experience.

Direct3D is a low level API which allows you to design your application by exact needs of your business - therefore, as a developer, you have to write more code and take care of all the rendering details which are usually not trivial to understand. By the way, with the release of Windows 7, Microsoft introduced a new 2D API called, not surprisingly, Direct2D. It is also a GPU accelerated API and much easier to use, however it does not include (for now) support for YUV surfaces and is therefore less suitable for video rendering. Nevertheless, I recently wrote a video rendering implementation with Direct2D which can be found here.

Pixel Formats

Video decoders usually output frames in YUV pixel format which is more suitable for video processing since it divides each video frame into luminance - the black and white data, and into chrominance - the colored data. The most used formats are I420 (also called IYUV) and YV12, both belong to YUV420 type which means each frame has W(width) x H(height) number of luma bytes followed by W x H / 2 chroma bytes. Direct3D allows you to convert those frames into RGB format using graphics device, thus saving CPU power and boosting performance.

Read more: Codeproject

Posted via email from Jasper-net

0 comments: