[FFmpeg-cvslog] diracdec: add support for 12 bit videos

Rostislav Pehlivanov git at videolan.org
Thu Jan 21 15:48:40 CET 2016


ffmpeg | branch: master | Rostislav Pehlivanov <atomnuker at gmail.com> | Thu Jan 21 14:44:42 2016 +0000| [8248b51e0b94f0151b6a2057ee639d6e0db29f5f] | committer: Rostislav Pehlivanov

diracdec: add support for 12 bit videos

The DSP lacked a function needed to convert signed to unsigned. This was
ignored when originally adding support and templating for bit depths
greater than 8. The 10 bit function was used for 12 bit pictures and
resulted in an improper conversion.

Signed-off-by: Rostislav Pehlivanov <atomnuker at gmail.com>

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

 libavcodec/diracdec.c |    7 +++++--
 libavcodec/diracdsp.c |   18 ++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index ee07ff8..8ab4360 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -1839,9 +1839,12 @@ static int dirac_decode_frame_internal(DiracContext *s)
 
         if (!s->num_refs) { /* intra */
             for (y = 0; y < p->height; y += 16) {
+                int idx = (s->bit_depth - 8) >> 1;
                 ff_spatial_idwt_slice2(&d, y+16); /* decode */
-                s->diracdsp.put_signed_rect_clamped[s->pshift](frame + y*p->stride, p->stride,
-                                                               p->idwt_buf + y*p->idwt_stride, p->idwt_stride, p->width, 16);
+                s->diracdsp.put_signed_rect_clamped[idx](frame + y*p->stride,
+                                                         p->stride,
+                                                         p->idwt_buf + y*p->idwt_stride,
+                                                         p->idwt_stride, p->width, 16);
             }
         } else { /* inter */
             int rowheight = p->ybsep*p->stride;
diff --git a/libavcodec/diracdsp.c b/libavcodec/diracdsp.c
index e82b587..6c75f9a 100644
--- a/libavcodec/diracdsp.c
+++ b/libavcodec/diracdsp.c
@@ -168,6 +168,23 @@ static void put_signed_rect_clamped_10bit_c(uint8_t *_dst, int dst_stride, const
     }
 }
 
+static void put_signed_rect_clamped_12bit_c(uint8_t *_dst, int dst_stride, const uint8_t *_src, int src_stride, int width, int height)
+{
+    int x, y;
+    uint16_t *dst = (uint16_t *)_dst;
+    int32_t *src = (int32_t *)_src;
+    for (y = 0; y < height; y++) {
+        for (x = 0; x < width; x+=4) {
+            dst[x  ] = av_clip(src[x  ] + 2048, 0, (1 << 12) - 1);
+            dst[x+1] = av_clip(src[x+1] + 2048, 0, (1 << 12) - 1);
+            dst[x+2] = av_clip(src[x+2] + 2048, 0, (1 << 12) - 1);
+            dst[x+3] = av_clip(src[x+3] + 2048, 0, (1 << 12) - 1);
+        }
+        dst += dst_stride >> 1;
+        src += src_stride >> 2;
+    }
+}
+
 static void add_rect_clamped_c(uint8_t *dst, const uint16_t *src, int stride,
                                const int16_t *idwt, int idwt_stride,
                                int width, int height)
@@ -197,6 +214,7 @@ av_cold void ff_diracdsp_init(DiracDSPContext *c)
     c->add_rect_clamped = add_rect_clamped_c;
     c->put_signed_rect_clamped[0] = put_signed_rect_clamped_8bit_c;
     c->put_signed_rect_clamped[1] = put_signed_rect_clamped_10bit_c;
+    c->put_signed_rect_clamped[2] = put_signed_rect_clamped_12bit_c;
 
     c->add_dirac_obmc[0] = add_obmc8_c;
     c->add_dirac_obmc[1] = add_obmc16_c;



More information about the ffmpeg-cvslog mailing list