Skip to content

Commit 03988ce

Browse files
committed
fix SDL output of 4:2:2 video
1 parent a1e7f92 commit 03988ce

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

dec265/sdl.cc

+18-16
Original file line numberDiff line numberDiff line change
@@ -184,26 +184,28 @@ void SDL_YUV_Display::display400(const unsigned char *Y, int stride)
184184
}
185185

186186

187-
void SDL_YUV_Display::display422(const unsigned char *Y,
188-
const unsigned char *U,
189-
const unsigned char *V,
187+
void SDL_YUV_Display::display422(const unsigned char* Y,
188+
const unsigned char* U,
189+
const unsigned char* V,
190190
int stride, int chroma_stride)
191191
{
192-
for (int y=0;y<rect.h;y++)
193-
{
194-
unsigned char* p = mPixels + y*mStride *2;
192+
for (int y = 0; y < rect.h; y++) {
193+
unsigned char* dstY = mPixels + y * mStride;
194+
const unsigned char* Yp = Y + y * stride;
195195

196-
const unsigned char* Yp = Y + y*stride;
197-
const unsigned char* Up = U + y*chroma_stride;
198-
const unsigned char* Vp = V + y*chroma_stride;
196+
memcpy(dstY, Yp, rect.w);
197+
}
199198

200-
for (int x=0;x<rect.w;x+=2) {
201-
*p++ = Yp[x];
202-
*p++ = Up[x/2];
203-
*p++ = Yp[x+1];
204-
*p++ = Vp[x/2];
205-
}
206-
}
199+
for (int y = 0; y < rect.h; y += 2) {
200+
unsigned char* dstV = mPixels + (y / 2) * mStride / 2 + rect.w * rect.h;
201+
unsigned char* dstU = mPixels + (y / 2) * mStride / 2 + rect.w * rect.h + rect.w * rect.h / 4;
202+
203+
const unsigned char* Up = U + y * chroma_stride;
204+
const unsigned char* Vp = V + y * chroma_stride;
205+
206+
memcpy(dstU, Up, rect.w / 2);
207+
memcpy(dstV, Vp, rect.w / 2);
208+
}
207209
}
208210

209211

0 commit comments

Comments
 (0)