[FFmpeg-cvslog] avcodec/loco: Support LOCO reference encoder with odd width

Michael Niedermayer git at videolan.org
Wed Dec 31 05:06:50 CET 2014


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Dec 31 02:41:01 2014 +0100| [d97b94f1af43c280c03e7d16830913911c67e94e] | committer: Michael Niedermayer

avcodec/loco: Support LOCO reference encoder with odd width

Fixes Ticket1221

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d97b94f1af43c280c03e7d16830913911c67e94e
---

 libavcodec/loco.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/libavcodec/loco.c b/libavcodec/loco.c
index bf52c49..88c66d9 100644
--- a/libavcodec/loco.c
+++ b/libavcodec/loco.c
@@ -168,6 +168,23 @@ static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int heigh
     return (get_bits_count(&rc.gb) + 7) >> 3;
 }
 
+static void rotate_faulty_loco(uint8_t *data, int width, int height, int stride, int step)
+{
+    int y;
+
+    for (y=1; y<height; y++) {
+        if (width>=y) {
+            memmove(data + y*stride,
+                    data + y*(stride + step),
+                    step*(width-y));
+            if (y+1 < height)
+                memmove(data + y*stride + step*(width-y),
+                        data + (y+1)*stride,
+                        step*y);
+        }
+    }
+}
+
 static int decode_frame(AVCodecContext *avctx,
                         void *data, int *got_frame,
                         AVPacket *avpkt)
@@ -216,6 +233,8 @@ static int decode_frame(AVCodecContext *avctx,
         ADVANCE_BY_DECODED;
         decoded = loco_decode_plane(l, p->data[0] + p->linesize[0]*(avctx->height-1) + 2, avctx->width, avctx->height,
                                     -p->linesize[0], buf, buf_size, 3);
+        if (avctx->width & 1)
+            rotate_faulty_loco(p->data[0] + p->linesize[0]*(avctx->height-1), avctx->width, avctx->height, -p->linesize[0], 3);
         break;
     case LOCO_CRGBA:
     case LOCO_RGBA:



More information about the ffmpeg-cvslog mailing list