gst-libs/gst/video/video.c: YV12 is I420 with swapped components 1 and 2, so the offset of component 1 for I420 shoul...

Original commit message from CVS:
* gst-libs/gst/video/video.c: (gst_video_format_get_component_offset):
YV12 is I420 with swapped components 1 and 2, so the offset of
component 1 for I420 should be the offset for component 2 for YV12
and vice versa.
This commit is contained in:
Tim-Philipp Müller 2008-03-02 18:07:10 +00:00
parent fac95d0eed
commit d3273657f0
2 changed files with 26 additions and 11 deletions

View file

@ -1,3 +1,10 @@
2008-03-02 Tim-Philipp Müller <tim at centricular dot net>
* gst-libs/gst/video/video.c: (gst_video_format_get_component_offset):
YV12 is I420 with swapped components 1 and 2, so the offset of
component 1 for I420 should be the offset for component 2 for YV12
and vice versa.
2008-02-29 Rene Stadler <mail@renestadler.de>
* sys/v4l/gstv4lelement.c:

View file

@ -904,19 +904,27 @@ gst_video_format_get_component_offset (GstVideoFormat format, int component,
{
switch (format) {
case GST_VIDEO_FORMAT_I420:
case GST_VIDEO_FORMAT_YV12:
if (component == 0) {
if (component == 0)
return 0;
} else {
int offset;
offset = GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
if (component == 2) {
offset += GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
(GST_ROUND_UP_2 (height) / 2);
}
return offset;
if (component == 1)
return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
if (component == 2) {
return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) +
GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
(GST_ROUND_UP_2 (height) / 2);
}
return 0;
case GST_VIDEO_FORMAT_YV12: /* same as I420, but components 1+2 swapped */
if (component == 0)
return 0;
if (component == 2)
return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height);
if (component == 1) {
return GST_ROUND_UP_4 (width) * GST_ROUND_UP_2 (height) +
GST_ROUND_UP_4 (GST_ROUND_UP_2 (width) / 2) *
(GST_ROUND_UP_2 (height) / 2);
}
return 0;
case GST_VIDEO_FORMAT_YUY2:
if (component == 0)
return 0;