diff mbox

[FFmpeg-devel,1/3] ffplay: add support for rendering yuv images with negative line size

Message ID 20170806190921.10897-1-cus@passwd.hu
State Accepted
Commit 493f637d1e933ebdd9f63528a7782d3617c442cb
Headers show

Commit Message

Marton Balint Aug. 6, 2017, 7:09 p.m. UTC
Signed-off-by: Marton Balint <cus@passwd.hu>
---
 ffplay.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

Comments

Marton Balint Aug. 10, 2017, 8:27 p.m. UTC | #1
On Sun, 6 Aug 2017, Marton Balint wrote:

> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> ffplay.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>

Pushed the series.

Regards,
Marton
diff mbox

Patch

diff --git a/ffplay.c b/ffplay.c
index 7cc5ab1644..ee3d1628e8 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -859,13 +859,18 @@  static int upload_texture(SDL_Texture *tex, AVFrame *frame, struct SwsContext **
     int ret = 0;
     switch (frame->format) {
         case AV_PIX_FMT_YUV420P:
-            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");
+            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->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;
             }
-            ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0], frame->linesize[0],
-                                                  frame->data[1], frame->linesize[1],
-                                                  frame->data[2], frame->linesize[2]);
             break;
         case AV_PIX_FMT_BGRA:
             if (frame->linesize[0] < 0) {