Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths
@ 2022-06-12 17:18 Marton Balint
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 2/7] avcodec/v210dec: factorize row decoding Marton Balint
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Marton Balint @ 2022-06-12 17:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

Fixes ticket #5195.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavcodec/v210dec.c | 49 +++++++++++++++++++++++++++++---------------
 1 file changed, 33 insertions(+), 16 deletions(-)

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 6c10ef6a7c..48ebe57100 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -60,14 +60,16 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th
     int slice_start = (avctx->height *  jobnr) / s->thread_count;
     int slice_end = (avctx->height * (jobnr+1)) / s->thread_count;
     uint8_t *psrc = td->buf + stride * slice_start;
-    uint16_t *y, *u, *v;
+    int16_t *py = (uint16_t*)frame->data[0] + slice_start * frame->linesize[0] / 2;
+    int16_t *pu = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2;
+    int16_t *pv = (uint16_t*)frame->data[2] + slice_start * frame->linesize[2] / 2;
 
-    y = (uint16_t*)frame->data[0] + slice_start * frame->linesize[0] / 2;
-    u = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2;
-    v = (uint16_t*)frame->data[2] + slice_start * frame->linesize[2] / 2;
     for (h = slice_start; h < slice_end; h++) {
         const uint32_t *src = (const uint32_t*)psrc;
         uint32_t val;
+        uint16_t *y = py;
+        uint16_t *u = pu;
+        uint16_t *v = pv;
 
         w = (avctx->width / 12) * 12;
         s->unpack_frame(src, y, u, v, w);
@@ -85,25 +87,40 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th
             w += 6;
         }
 
-        if (w < avctx->width - 1) {
+        if (w++ < avctx->width) {
             READ_PIXELS(u, y, v);
 
-            val  = av_le2ne32(*src++);
-            *y++ =  val & 0x3FF;
-            if (w < avctx->width - 3) {
-                *u++ = (val >> 10) & 0x3FF;
-                *y++ = (val >> 20) & 0x3FF;
-
+            if (w++ < avctx->width) {
                 val  = av_le2ne32(*src++);
-                *v++ =  val & 0x3FF;
-                *y++ = (val >> 10) & 0x3FF;
+                *y++ =  val & 0x3FF;
+
+                if (w++ < avctx->width) {
+                    *u++ = (val >> 10) & 0x3FF;
+                    *y++ = (val >> 20) & 0x3FF;
+                    val  = av_le2ne32(*src++);
+                    *v++ =  val & 0x3FF;
+
+                    if (w++ < avctx->width) {
+                        *y++ = (val >> 10) & 0x3FF;
+
+                        if (w++ < avctx->width) {
+                            *u++ = (val >> 20) & 0x3FF;
+                            val  = av_le2ne32(*src++);
+                            *y++ =  val & 0x3FF;
+                            *v++ = (val >> 10) & 0x3FF;
+
+                            if (w++ < avctx->width)
+                                *y++ = (val >> 20) & 0x3FF;
+                        }
+                    }
+                }
             }
         }
 
         psrc += stride;
-        y += frame->linesize[0] / 2 - avctx->width + (avctx->width & 1);
-        u += frame->linesize[1] / 2 - avctx->width / 2;
-        v += frame->linesize[2] / 2 - avctx->width / 2;
+        py += frame->linesize[0] / 2;
+        pu += frame->linesize[1] / 2;
+        pv += frame->linesize[2] / 2;
     }
 
     return 0;
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 2/7] avcodec/v210dec: factorize row decoding
  2022-06-12 17:18 [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
@ 2022-06-12 17:18 ` Marton Balint
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 3/7] avcodec/v210dec: disallow negative custom stride Marton Balint
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marton Balint @ 2022-06-12 17:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavcodec/v210dec.c | 108 +++++++++++++++++++++----------------------
 1 file changed, 54 insertions(+), 54 deletions(-)

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 48ebe57100..c89440658f 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -50,10 +50,61 @@ static av_cold int decode_init(AVCodecContext *avctx)
     return 0;
 }
 
+static void decode_row(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, const int width,
+                       void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width))
+{
+    uint32_t val;
+    int w = (width / 12) * 12;
+
+    unpack_frame(src, y, u, v, w);
+
+    y += w;
+    u += w >> 1;
+    v += w >> 1;
+    src += (w << 1) / 3;
+
+    if (w < width - 5) {
+        READ_PIXELS(u, y, v);
+        READ_PIXELS(y, u, y);
+        READ_PIXELS(v, y, u);
+        READ_PIXELS(y, v, y);
+        w += 6;
+    }
+
+    if (w++ < width) {
+        READ_PIXELS(u, y, v);
+
+        if (w++ < width) {
+            val  = av_le2ne32(*src++);
+            *y++ =  val & 0x3FF;
+
+            if (w++ < width) {
+                *u++ = (val >> 10) & 0x3FF;
+                *y++ = (val >> 20) & 0x3FF;
+                val  = av_le2ne32(*src++);
+                *v++ =  val & 0x3FF;
+
+                if (w++ < width) {
+                    *y++ = (val >> 10) & 0x3FF;
+
+                    if (w++ < width) {
+                        *u++ = (val >> 20) & 0x3FF;
+                        val  = av_le2ne32(*src++);
+                        *y++ =  val & 0x3FF;
+                        *v++ = (val >> 10) & 0x3FF;
+
+                        if (w++ < width)
+                            *y++ = (val >> 20) & 0x3FF;
+                    }
+                }
+            }
+        }
+    }
+}
+
 static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int threadnr)
 {
     V210DecContext *s = avctx->priv_data;
-    int h, w;
     ThreadData *td = arg;
     AVFrame *frame = td->frame;
     int stride = td->stride;
@@ -64,59 +115,8 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th
     int16_t *pu = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2;
     int16_t *pv = (uint16_t*)frame->data[2] + slice_start * frame->linesize[2] / 2;
 
-    for (h = slice_start; h < slice_end; h++) {
-        const uint32_t *src = (const uint32_t*)psrc;
-        uint32_t val;
-        uint16_t *y = py;
-        uint16_t *u = pu;
-        uint16_t *v = pv;
-
-        w = (avctx->width / 12) * 12;
-        s->unpack_frame(src, y, u, v, w);
-
-        y += w;
-        u += w >> 1;
-        v += w >> 1;
-        src += (w << 1) / 3;
-
-        if (w < avctx->width - 5) {
-            READ_PIXELS(u, y, v);
-            READ_PIXELS(y, u, y);
-            READ_PIXELS(v, y, u);
-            READ_PIXELS(y, v, y);
-            w += 6;
-        }
-
-        if (w++ < avctx->width) {
-            READ_PIXELS(u, y, v);
-
-            if (w++ < avctx->width) {
-                val  = av_le2ne32(*src++);
-                *y++ =  val & 0x3FF;
-
-                if (w++ < avctx->width) {
-                    *u++ = (val >> 10) & 0x3FF;
-                    *y++ = (val >> 20) & 0x3FF;
-                    val  = av_le2ne32(*src++);
-                    *v++ =  val & 0x3FF;
-
-                    if (w++ < avctx->width) {
-                        *y++ = (val >> 10) & 0x3FF;
-
-                        if (w++ < avctx->width) {
-                            *u++ = (val >> 20) & 0x3FF;
-                            val  = av_le2ne32(*src++);
-                            *y++ =  val & 0x3FF;
-                            *v++ = (val >> 10) & 0x3FF;
-
-                            if (w++ < avctx->width)
-                                *y++ = (val >> 20) & 0x3FF;
-                        }
-                    }
-                }
-            }
-        }
-
+    for (int h = slice_start; h < slice_end; h++) {
+        decode_row((const uint32_t *)psrc, py, pu, pv, avctx->width, s->unpack_frame);
         psrc += stride;
         py += frame->linesize[0] / 2;
         pu += frame->linesize[1] / 2;
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 3/7] avcodec/v210dec: disallow negative custom stride
  2022-06-12 17:18 [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 2/7] avcodec/v210dec: factorize row decoding Marton Balint
@ 2022-06-12 17:18 ` Marton Balint
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 4/7] avcodec/v210dec: do not use accelerated code for the last pixels of a row Marton Balint
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marton Balint @ 2022-06-12 17:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

Also make sure a big custom stride does not overflow size check.

Avoids segfaults.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavcodec/v210dec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index c89440658f..e97f43a8e6 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -141,7 +141,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
         stride = aligned_width * 8 / 3;
     }
 
-    if (avpkt->size < stride * avctx->height) {
+    if (avpkt->size < (int64_t)stride * avctx->height) {
         if ((((avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) {
             stride = avpkt->size / avctx->height;
             if (!s->stride_warning_shown)
@@ -190,7 +190,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
 #define V210DEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption v210dec_options[] = {
     {"custom_stride", "Custom V210 stride", offsetof(V210DecContext, custom_stride), AV_OPT_TYPE_INT,
-     {.i64 = 0}, INT_MIN, INT_MAX, V210DEC_FLAGS},
+     {.i64 = 0}, 0, INT_MAX, V210DEC_FLAGS},
     {NULL}
 };
 
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 4/7] avcodec/v210dec: do not use accelerated code for the last pixels of a row
  2022-06-12 17:18 [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 2/7] avcodec/v210dec: factorize row decoding Marton Balint
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 3/7] avcodec/v210dec: disallow negative custom stride Marton Balint
@ 2022-06-12 17:18 ` Marton Balint
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 5/7] avcodec/v210dec: add support for invalid paddings up to 16 bytes Marton Balint
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marton Balint @ 2022-06-12 17:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

ASM code tends to overwrite the buffers by 2-4 bytes and it can cause issues
with slice threads.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavcodec/v210dec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index e97f43a8e6..4268b5b748 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -54,7 +54,7 @@ static void decode_row(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *
                        void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width))
 {
     uint32_t val;
-    int w = (width / 12) * 12;
+    int w = (FFMAX(0, width - 12) / 12) * 12;
 
     unpack_frame(src, y, u, v, w);
 
@@ -63,7 +63,7 @@ static void decode_row(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *
     v += w >> 1;
     src += (w << 1) / 3;
 
-    if (w < width - 5) {
+    while (w < width - 5) {
         READ_PIXELS(u, y, v);
         READ_PIXELS(y, u, y);
         READ_PIXELS(v, y, u);
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 5/7] avcodec/v210dec: add support for invalid paddings up to 16 bytes
  2022-06-12 17:18 [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
                   ` (2 preceding siblings ...)
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 4/7] avcodec/v210dec: do not use accelerated code for the last pixels of a row Marton Balint
@ 2022-06-12 17:18 ` Marton Balint
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 6/7] avcodec/v210dec: add support for strideless v210 as in BOXX files Marton Balint
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Marton Balint @ 2022-06-12 17:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

Fixes ticket #1528.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavcodec/v210dec.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index 4268b5b748..ba48bb6fe4 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -126,6 +126,11 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th
     return 0;
 }
 
+static int v210_stride(int width, int align) {
+    int aligned_width = ((width + align - 1) / align) * align;
+    return aligned_width * 8 / 3;
+}
+
 static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
                         int *got_frame, AVPacket *avpkt)
 {
@@ -137,20 +142,25 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
     if (s->custom_stride )
         stride = s->custom_stride;
     else {
-        int aligned_width = ((avctx->width + 47) / 48) * 48;
-        stride = aligned_width * 8 / 3;
+        stride = v210_stride(avctx->width, 48);
+        if (avpkt->size < stride * avctx->height) {
+            int align;
+            for (align = 24; align >= 6; align >>= 1) {
+                int small_stride = v210_stride(avctx->width, align);
+                if (avpkt->size == small_stride * avctx->height) {
+                    stride = small_stride;
+                    if (!s->stride_warning_shown)
+                        av_log(avctx, AV_LOG_WARNING, "Broken v210 with too small padding (%d byte) detected\n", align * 8 / 3);
+                    s->stride_warning_shown = 1;
+                    break;
+                }
+            }
+        }
     }
 
     if (avpkt->size < (int64_t)stride * avctx->height) {
-        if ((((avctx->width + 23) / 24) * 24 * 8) / 3 * avctx->height == avpkt->size) {
-            stride = avpkt->size / avctx->height;
-            if (!s->stride_warning_shown)
-                av_log(avctx, AV_LOG_WARNING, "Broken v210 with too small padding (64 byte) detected\n");
-            s->stride_warning_shown = 1;
-        } else {
-            av_log(avctx, AV_LOG_ERROR, "packet too small\n");
-            return AVERROR_INVALIDDATA;
-        }
+        av_log(avctx, AV_LOG_ERROR, "packet too small\n");
+        return AVERROR_INVALIDDATA;
     }
     td.stride = stride;
     if (   avctx->codec_tag == MKTAG('C', '2', '1', '0')
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 6/7] avcodec/v210dec: add support for strideless v210 as in BOXX files
  2022-06-12 17:18 [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
                   ` (3 preceding siblings ...)
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 5/7] avcodec/v210dec: add support for invalid paddings up to 16 bytes Marton Balint
@ 2022-06-12 17:18 ` Marton Balint
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 7/7] doc/decoders: add docs for v210 decoder Marton Balint
  2022-06-20 21:06 ` [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
  6 siblings, 0 replies; 8+ messages in thread
From: Marton Balint @ 2022-06-12 17:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

Fixes ticket #1838.

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 libavcodec/v210dec.c | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
index ba48bb6fe4..bf84cd4428 100644
--- a/libavcodec/v210dec.c
+++ b/libavcodec/v210dec.c
@@ -26,6 +26,7 @@
 #include "v210dec.h"
 #include "v210dec_init.h"
 #include "libavutil/bswap.h"
+#include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/intreadwrite.h"
 #include "thread.h"
@@ -140,7 +141,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
     const uint8_t *psrc = avpkt->data;
 
     if (s->custom_stride )
-        stride = s->custom_stride;
+        stride = s->custom_stride > 0 ? s->custom_stride : 0;
     else {
         stride = v210_stride(avctx->width, 48);
         if (avpkt->size < stride * avctx->height) {
@@ -155,14 +156,21 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
                     break;
                 }
             }
+            if (align < 6 && avctx->codec_tag == MKTAG('b', 'x', 'y', '2'))
+                stride = 0;
         }
     }
 
-    if (avpkt->size < (int64_t)stride * avctx->height) {
+    if (stride == 0 && ((avctx->width & 1) || (int64_t)avctx->width * avctx->height > INT_MAX / 6)) {
+        av_log(avctx, AV_LOG_ERROR, "Strideless v210 is not supported for size %dx%d\n", avctx->width, avctx->height);
+        return AVERROR_INVALIDDATA;
+    }
+
+    if (stride  > 0 && avpkt->size < (int64_t)stride * avctx->height ||
+        stride == 0 && avpkt->size < v210_stride(avctx->width * avctx->height, 6)) {
         av_log(avctx, AV_LOG_ERROR, "packet too small\n");
         return AVERROR_INVALIDDATA;
     }
-    td.stride = stride;
     if (   avctx->codec_tag == MKTAG('C', '2', '1', '0')
         && avpkt->size > 64
         && AV_RN32(psrc) == AV_RN32("INFO")
@@ -181,9 +189,21 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
     pic->pict_type = AV_PICTURE_TYPE_I;
     pic->key_frame = 1;
 
-    td.buf = (uint8_t*)psrc;
-    td.frame = pic;
-    avctx->execute2(avctx, v210_decode_slice, &td, NULL, s->thread_count);
+    if (stride) {
+        td.stride = stride;
+        td.buf = (uint8_t*)psrc;
+        td.frame = pic;
+        avctx->execute2(avctx, v210_decode_slice, &td, NULL, s->thread_count);
+    } else {
+        uint8_t *pointers[4];
+        int linesizes[4];
+        int ret = av_image_alloc(pointers, linesizes, avctx->width, avctx->height, avctx->pix_fmt, 1);
+        if (ret < 0)
+            return ret;
+        decode_row((const uint32_t *)psrc, (uint16_t *)pointers[0], (uint16_t *)pointers[1], (uint16_t *)pointers[2], avctx->width * avctx->height, s->unpack_frame);
+        av_image_copy(pic->data, pic->linesize, (const uint8_t **)pointers, linesizes, avctx->pix_fmt, avctx->width, avctx->height);
+        av_freep(&pointers[0]);
+    }
 
     if (avctx->field_order > AV_FIELD_PROGRESSIVE) {
         /* we have interlaced material flagged in container */
@@ -200,7 +220,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *pic,
 #define V210DEC_FLAGS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM
 static const AVOption v210dec_options[] = {
     {"custom_stride", "Custom V210 stride", offsetof(V210DecContext, custom_stride), AV_OPT_TYPE_INT,
-     {.i64 = 0}, 0, INT_MAX, V210DEC_FLAGS},
+     {.i64 = 0}, -1, INT_MAX, V210DEC_FLAGS},
     {NULL}
 };
 
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 7/7] doc/decoders: add docs for v210 decoder
  2022-06-12 17:18 [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
                   ` (4 preceding siblings ...)
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 6/7] avcodec/v210dec: add support for strideless v210 as in BOXX files Marton Balint
@ 2022-06-12 17:18 ` Marton Balint
  2022-06-20 21:06 ` [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
  6 siblings, 0 replies; 8+ messages in thread
From: Marton Balint @ 2022-06-12 17:18 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Marton Balint

Signed-off-by: Marton Balint <cus@passwd.hu>
---
 doc/decoders.texi | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/doc/decoders.texi b/doc/decoders.texi
index de2429abba..e2fcbf5dc9 100644
--- a/doc/decoders.texi
+++ b/doc/decoders.texi
@@ -168,6 +168,21 @@ A :-separate list of hexadecimal plugin UIDs to load in an internal session
 
 @end table
 
+@section v210
+
+Uncompressed 4:2:2 10-bit decoder.
+
+@subsection Options
+
+@table @option
+
+@item custom_stride
+Set the line size of the v210 data in bytes. The default value is 0
+(autodetect). You can use the special -1 value for a strideless v210 as seen in
+BOXX files.
+
+@end table
+
 @c man end VIDEO DECODERS
 
 @chapter Audio Decoders
-- 
2.34.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths
  2022-06-12 17:18 [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
                   ` (5 preceding siblings ...)
  2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 7/7] doc/decoders: add docs for v210 decoder Marton Balint
@ 2022-06-20 21:06 ` Marton Balint
  6 siblings, 0 replies; 8+ messages in thread
From: Marton Balint @ 2022-06-20 21:06 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



On Sun, 12 Jun 2022, Marton Balint wrote:

> Fixes ticket #5195.
>
> Signed-off-by: Marton Balint <cus@passwd.hu>
> ---
> libavcodec/v210dec.c | 49 +++++++++++++++++++++++++++++---------------
> 1 file changed, 33 insertions(+), 16 deletions(-)

Will apply the series.

Regards,
Marton

>
> diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c
> index 6c10ef6a7c..48ebe57100 100644
> --- a/libavcodec/v210dec.c
> +++ b/libavcodec/v210dec.c
> @@ -60,14 +60,16 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th
>     int slice_start = (avctx->height *  jobnr) / s->thread_count;
>     int slice_end = (avctx->height * (jobnr+1)) / s->thread_count;
>     uint8_t *psrc = td->buf + stride * slice_start;
> -    uint16_t *y, *u, *v;
> +    int16_t *py = (uint16_t*)frame->data[0] + slice_start * frame->linesize[0] / 2;
> +    int16_t *pu = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2;
> +    int16_t *pv = (uint16_t*)frame->data[2] + slice_start * frame->linesize[2] / 2;
>
> -    y = (uint16_t*)frame->data[0] + slice_start * frame->linesize[0] / 2;
> -    u = (uint16_t*)frame->data[1] + slice_start * frame->linesize[1] / 2;
> -    v = (uint16_t*)frame->data[2] + slice_start * frame->linesize[2] / 2;
>     for (h = slice_start; h < slice_end; h++) {
>         const uint32_t *src = (const uint32_t*)psrc;
>         uint32_t val;
> +        uint16_t *y = py;
> +        uint16_t *u = pu;
> +        uint16_t *v = pv;
>
>         w = (avctx->width / 12) * 12;
>         s->unpack_frame(src, y, u, v, w);
> @@ -85,25 +87,40 @@ static int v210_decode_slice(AVCodecContext *avctx, void *arg, int jobnr, int th
>             w += 6;
>         }
>
> -        if (w < avctx->width - 1) {
> +        if (w++ < avctx->width) {
>             READ_PIXELS(u, y, v);
>
> -            val  = av_le2ne32(*src++);
> -            *y++ =  val & 0x3FF;
> -            if (w < avctx->width - 3) {
> -                *u++ = (val >> 10) & 0x3FF;
> -                *y++ = (val >> 20) & 0x3FF;
> -
> +            if (w++ < avctx->width) {
>                 val  = av_le2ne32(*src++);
> -                *v++ =  val & 0x3FF;
> -                *y++ = (val >> 10) & 0x3FF;
> +                *y++ =  val & 0x3FF;
> +
> +                if (w++ < avctx->width) {
> +                    *u++ = (val >> 10) & 0x3FF;
> +                    *y++ = (val >> 20) & 0x3FF;
> +                    val  = av_le2ne32(*src++);
> +                    *v++ =  val & 0x3FF;
> +
> +                    if (w++ < avctx->width) {
> +                        *y++ = (val >> 10) & 0x3FF;
> +
> +                        if (w++ < avctx->width) {
> +                            *u++ = (val >> 20) & 0x3FF;
> +                            val  = av_le2ne32(*src++);
> +                            *y++ =  val & 0x3FF;
> +                            *v++ = (val >> 10) & 0x3FF;
> +
> +                            if (w++ < avctx->width)
> +                                *y++ = (val >> 20) & 0x3FF;
> +                        }
> +                    }
> +                }
>             }
>         }
>
>         psrc += stride;
> -        y += frame->linesize[0] / 2 - avctx->width + (avctx->width & 1);
> -        u += frame->linesize[1] / 2 - avctx->width / 2;
> -        v += frame->linesize[2] / 2 - avctx->width / 2;
> +        py += frame->linesize[0] / 2;
> +        pu += frame->linesize[1] / 2;
> +        pv += frame->linesize[2] / 2;
>     }
>
>     return 0;
> -- 
> 2.34.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-20 21:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-12 17:18 [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 2/7] avcodec/v210dec: factorize row decoding Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 3/7] avcodec/v210dec: disallow negative custom stride Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 4/7] avcodec/v210dec: do not use accelerated code for the last pixels of a row Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 5/7] avcodec/v210dec: add support for invalid paddings up to 16 bytes Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 6/7] avcodec/v210dec: add support for strideless v210 as in BOXX files Marton Balint
2022-06-12 17:18 ` [FFmpeg-devel] [PATCH 7/7] doc/decoders: add docs for v210 decoder Marton Balint
2022-06-20 21:06 ` [FFmpeg-devel] [PATCH 1/7] avcodec/v210dec: properly support odd widths Marton Balint

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git