mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-03 05:10:03 +02:00
ffplay: add support for rendering yuv images with negative line size
Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
f357104866
commit
493f637d1e
15
ffplay.c
15
ffplay.c
@ -859,13 +859,18 @@ static int upload_texture(SDL_Texture *tex, AVFrame *frame, struct SwsContext **
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
switch (frame->format) {
|
switch (frame->format) {
|
||||||
case AV_PIX_FMT_YUV420P:
|
case AV_PIX_FMT_YUV420P:
|
||||||
if (frame->linesize[0] < 0 || frame->linesize[1] < 0 || frame->linesize[2] < 0) {
|
if (frame->linesize[0] > 0 && frame->linesize[1] > 0 && frame->linesize[2] > 0) {
|
||||||
av_log(NULL, AV_LOG_ERROR, "Negative linesize is not supported for YUV.\n");
|
ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0], frame->linesize[0],
|
||||||
|
frame->data[1], frame->linesize[1],
|
||||||
|
frame->data[2], frame->linesize[2]);
|
||||||
|
} else if (frame->linesize[0] < 0 && frame->linesize[1] < 0 && frame->linesize[2] < 0) {
|
||||||
|
ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0] + frame->linesize[0] * (frame->height - 1), -frame->linesize[0],
|
||||||
|
frame->data[1] + frame->linesize[1] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[1],
|
||||||
|
frame->data[2] + frame->linesize[2] * (AV_CEIL_RSHIFT(frame->height, 1) - 1), -frame->linesize[2]);
|
||||||
|
} else {
|
||||||
|
av_log(NULL, AV_LOG_ERROR, "Mixed negative and positive linesizes are not supported.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0], frame->linesize[0],
|
|
||||||
frame->data[1], frame->linesize[1],
|
|
||||||
frame->data[2], frame->linesize[2]);
|
|
||||||
break;
|
break;
|
||||||
case AV_PIX_FMT_BGRA:
|
case AV_PIX_FMT_BGRA:
|
||||||
if (frame->linesize[0] < 0) {
|
if (frame->linesize[0] < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user