324 break; |
324 break; |
325 default: |
325 default: |
326 /* We should never get here (caught above) */ |
326 /* We should never get here (caught above) */ |
327 break; |
327 break; |
328 } |
328 } |
329 if ((texture->format & SDL_PIXELFORMAT_YV12 || texture->format & SDL_PIXELFORMAT_IYUV) |
|
330 && texture->w % 16 == 0 && texture->h % 16 == 0) { |
|
331 } |
|
332 } else { |
329 } else { |
333 data->pixels = NULL; |
330 data->pixels = NULL; |
334 data->pixels = SDL_malloc(texture->h * data->pitch); |
331 data->pixels = SDL_malloc(texture->h * data->pitch); |
335 if (!data->pixels) { |
332 if (!data->pixels) { |
336 PS3_DestroyTexture(renderer, texture); |
333 PS3_DestroyTexture(renderer, texture); |
534 deprintf(1, "dstrect->y = %u\n", dstrect->y); |
531 deprintf(1, "dstrect->y = %u\n", dstrect->y); |
535 deprintf(1, "texture->w = %u\n", texture->w); |
532 deprintf(1, "texture->w = %u\n", texture->w); |
536 deprintf(1, "texture->h = %u\n", texture->h); |
533 deprintf(1, "texture->h = %u\n", texture->h); |
537 |
534 |
538 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
535 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { |
539 deprintf(1, "SDL_ISPIXELFORMAT_FOURCC = true\n"); |
536 deprintf(1, "Texture is in a FOURCC format\n"); |
540 if ((texture->format & SDL_PIXELFORMAT_YV12 || texture->format & SDL_PIXELFORMAT_IYUV) |
537 if ((texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) |
541 && texture->w % 8 == 0 && texture->h % 8 == 0 |
538 && texture->w % 8 == 0 && texture->h % 8 == 0 |
542 && dstrect->w % 8 == 0 && dstrect->h % 8 == 0) { |
539 && dstrect->w % 8 == 0 && dstrect->h % 8 == 0) { |
543 deprintf(1, "Use SPE for scaling/converting\n"); |
540 deprintf(1, "Use SPE for scaling/converting\n"); |
544 |
541 |
545 SDL_SW_YUVTexture *swdata = (SDL_SW_YUVTexture *) txdata->yuv; |
542 SDL_SW_YUVTexture *swdata = (SDL_SW_YUVTexture *) txdata->yuv; |
546 Uint8 *lum, *Cr, *Cb; |
543 Uint8 *lum, *Cr, *Cb; |
547 Uint8 *scaler_out = NULL; |
544 Uint8 *scaler_out = NULL; |
548 Uint8 *dstpixels; |
545 Uint8 *dstpixels; |
549 switch (swdata->format) { |
546 switch (texture->format) { |
550 case SDL_PIXELFORMAT_YV12: |
547 case SDL_PIXELFORMAT_YV12: |
551 lum = swdata->planes[0]; |
548 lum = swdata->planes[0]; |
552 Cr = swdata->planes[1]; |
549 Cr = swdata->planes[1]; |
553 Cb = swdata->planes[2]; |
550 Cb = swdata->planes[2]; |
554 break; |
551 break; |
556 lum = swdata->planes[0]; |
553 lum = swdata->planes[0]; |
557 Cr = swdata->planes[2]; |
554 Cr = swdata->planes[2]; |
558 Cb = swdata->planes[1]; |
555 Cb = swdata->planes[1]; |
559 break; |
556 break; |
560 default: |
557 default: |
|
558 /* We should never get here (caught above) */ |
561 return -1; |
559 return -1; |
562 } |
560 } |
563 |
561 |
564 if (srcrect->w != dstrect->w || srcrect->h != dstrect->h) { |
562 if (srcrect->w != dstrect->w || srcrect->h != dstrect->h) { |
|
563 deprintf(1, "We need to scale the texture from %u x %u to %u x %u\n", |
|
564 srcrect->w, srcrect->h, dstrect->w, dstrect->h); |
565 /* Alloc mem for scaled YUV picture */ |
565 /* Alloc mem for scaled YUV picture */ |
566 scaler_out = (Uint8 *) memalign(16, dstrect->w * dstrect->h + ((dstrect->w * dstrect->h) >> 1)); |
566 scaler_out = (Uint8 *) memalign(16, dstrect->w * dstrect->h + ((dstrect->w * dstrect->h) >> 1)); |
567 if (scaler_out == NULL) { |
567 if (scaler_out == NULL) { |
568 SDL_OutOfMemory(); |
568 SDL_OutOfMemory(); |
569 return -1; |
569 return -1; |