Учебник по ffmpeg и SDL Урок 2: Вывод на экран | Participants
|
- Statistics
- Participants
- Translate into Russian
- Translation result
- Translated in draft, editing and proof-reading required. Completed: 48%.
If you do not want to register an account, you can sign in with OpenID.
An ffmpeg and SDL Tutorial Tutorial 02: Outputting to the Screen | ||
SDL and Video | ||
To draw to the screen, we're going to use SDL. SDL stands for Simple Direct Layer, and is an excellent library for multimedia, is cross-platform, and is used in several projects. You can get the library at the official website or you can download the development package for your operating system if there is one. You'll need the libraries to compile the code for this tutorial (and for the rest of them, too). | Для вывода на экран мы будем использовать SDL. SDL аббревиатура для Simple Direct Layer и это отличная мультимедиа библиотека — кросплатформенная, используемая во многих проектах. Вы можете взять её с оффициального web-сайта или скачать пакет разработки для своей операционной системы. Вам необходима данная библиотека для компиляции кода из этого урока (и последующих). | |
SDL has many methods for drawing images to the screen, and it has one in particular that is meant for displaying movies on the screen - what it calls a YUV overlay. YUV (technically not YUV but YCbCr) * A note: There is a great deal of annoyance from some people at the convention of calling "YCbCr" "YUV". Generally speaking, YUV is an analog format and YCbCr is a digital format. ffmpeg and SDL both refer to YCbCr as YUV in their code and macros. is a way of storing raw image data like RGB. Roughly speaking, Y is the brightness (or "luma") component, and U and V are the color components. (It's more complicated than RGB because some of the color information is discarded, and you might have only 1 U and V sample for every 2 Y samples.) SDL's YUV overlay takes in a raw array of YUV data and displays it. It accepts 4 different kinds of YUV formats, but YV12 is the fastest. There is another YUV format called YUV420P that is the same as YV12, except the U and V arrays are switched. The 420 means it is subsampled at a ratio of 4:2:0, basically meaning there is 1 color sample for every 4 luma samples, so the color information is quartered. This is a good way of saving bandwidth, as the human eye does not percieve this change. The "P" in the name means that the format is "planar" — simply meaning that the Y, U, and V components are in separate arrays. ffmpeg can convert images to YUV420P, with the added bonus that many video streams are in that format already, or are easily converted to that format. | SDL имеет много методов для вывода изображений на экран, и в частности для отображения видео, для этой цели используется так называемый YUV оверлей. YUV (с технической точки зрения точнее сказать не YUV, а YCbCr) - это способ хранения исходных данных изображения способом, похожим на RGB. Грубо говоря, Y- компонент содержит значение яркости, U и V - цветовые компоненты. (Это более сложная модель, чем RGB, потому что информация о некоторых цветах отбрасывается, и вы можете иметь только по 1 U и V компоненту на каждые 2 Y образца.) SDL YUV оверлей берет исходный массив YUV данных и отображает его. Он принимает 4 различных видов YUV форматов, из которых самый быстрый - YV12. существует ещё один формат - YUV420P, во многом схожий с YV12, за исключением того, что массивы U и V переставлены. 420 означает, что это компоненты находятся в соотношении 4:2:0, то есть 1 значение цвета приходится на 4 значения яркости, таким образом информация о цвете разделенна на четыер значения. Это хороший способ экономии места, так как человеческий глаз не замечает это изменение. "P" в названии означает, что формат "плоский" , то есть значения Y, U и V компонентов содержаться в виде отдельных массивов. ffmpeg в качестве дополнительной возможности может конвертировать изображения в YUV420P, хотя многие видео потоки уже имеют этот формат, или легко могут быть к нему приведены. |
© Copyright (c) 2003 Fabrice Bellard, and a tutorial by Martin Bohme.. License: Creative Commons Attribution-Share Alike 2.5
