From aa0c3143672efb1a0550eb3ec88de752793983d0 Mon Sep 17 00:00:00 2001
From: Kieran Kunhya <kieran@kunhya.com>
Date: Sun, 10 Apr 2011 22:51:41 +0100
Subject: [PATCH] Allow custom stride in V210

---
 libavcodec/avcodec.h |    7 +++++++
 libavcodec/v210dec.c |   11 +++++++++--
 libavcodec/version.h |    2 +-
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 7eb8b52..b93146b 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2894,6 +2894,13 @@ typedef struct AVCodecContext {
      * - decoding: Set by libavcodec.
      */
     enum AVAudioServiceType audio_service_type;
+
+    /**
+     * Custom stride.
+     * - encoding: unused.
+     * - decoding: Set by libavcodec.
+     */
+    int custom_stride;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 420bc47..0123d76 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -45,8 +45,15 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     AVFrame *pic = avctx->coded_frame;
     const uint8_t *psrc = avpkt->data;
     uint16_t *y, *u, *v;
-    int aligned_width = ((avctx->width + 47) / 48) * 48;
-    int stride = aligned_width * 8 / 3;
+    int stride;
+
+    if (!avctx->custom_stride ) {
+        int aligned_width = ((avctx->width + 47) / 48) * 48;
+        stride = aligned_width * 8 / 3;
+    }
+    else {
+        stride = avctx->custom_stride;
+    }
 
     if (pic->data[0])
         avctx->release_buffer(avctx, pic);
diff --git a/libavcodec/version.h b/libavcodec/version.h
index e40d4e5..7a2e175 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -21,7 +21,7 @@
 #define AVCODEC_VERSION_H
 
 #define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 117
+#define LIBAVCODEC_VERSION_MINOR 118
 #define LIBAVCODEC_VERSION_MICRO  1
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
-- 
1.7.4

