[FFmpeg-devel,v3,4/5] avcodec/v210enc: make 8bit and 10bit process consistent

Submitted by lance.lmwang@gmail.com on Sept. 1, 2019, 1:20 p.m.

Details

Message ID 20190901132023.28531-4-lance.lmwang@gmail.com
State Accepted
Commit 5c0f80d26d187dd01116ad9968cfe60300d39eab
Headers show

Commit Message

lance.lmwang@gmail.com Sept. 1, 2019, 1:20 p.m.
From: Limin Wang <lance.lmwang@gmail.com>

It's for code factorization in the next patch

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavcodec/v210enc.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 3e6abbe..d078f0a 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -46,7 +46,7 @@  av_cold void ff_v210enc_init(V210EncContext *s)
 {
     s->pack_line_8  = v210_planar_pack_8_c;
     s->pack_line_10 = v210_planar_pack_10_c;
-    s->sample_factor_8  = 1;
+    s->sample_factor_8  = 2;
     s->sample_factor_10 = 1;
 
     if (ARCH_X86)
@@ -121,18 +121,18 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             if (w < avctx->width - 1) {
                 WRITE_PIXELS(u, y, v, 10);
 
-                val = CLIP(*y++, 10);
+                val = CLIP(*y++, 10) << (10-10);
                 if (w == avctx->width - 2) {
                     AV_WL32(dst, val);
                     dst += 4;
                 }
             }
             if (w < avctx->width - 3) {
-                val |= (CLIP(*u++, 10) << 10) | (CLIP(*y++, 10) << 20);
+                val |= (CLIP(*u++, 10) << (20-10)) | (CLIP(*y++, 10) << (30-10));
                 AV_WL32(dst, val);
                 dst += 4;
 
-                val = CLIP(*v++, 10) | (CLIP(*y++, 10) << 10);
+                val = CLIP(*v++, 10) << (10-10) | (CLIP(*y++, 10) << (20-10));
                 AV_WL32(dst, val);
                 dst += 4;
             }
@@ -148,7 +148,7 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
         const uint8_t *u = pic->data[1];
         const uint8_t *v = pic->data[2];
 
-        const int sample_size = 12 * s->sample_factor_8;
+        const int sample_size = 6 * s->sample_factor_8;
         const int sample_w    = avctx->width / sample_size;
 
         for (h = 0; h < avctx->height; h++) {
@@ -159,7 +159,7 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             y += w;
             u += w >> 1;
             v += w >> 1;
-            dst += sample_w * 32 * s->sample_factor_8;
+            dst += sample_w * 16 * s->sample_factor_8;
 
             for (; w < avctx->width - 5; w += 6) {
                 WRITE_PIXELS(u, y, v, 8);
@@ -170,18 +170,18 @@  static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             if (w < avctx->width - 1) {
                 WRITE_PIXELS(u, y, v, 8);
 
-                val = CLIP(*y++, 8) << 2;
+                val = CLIP(*y++, 8) << (10-8);
                 if (w == avctx->width - 2) {
                     AV_WL32(dst, val);
                     dst += 4;
                 }
             }
             if (w < avctx->width - 3) {
-                val |= (CLIP(*u++, 8) << 12) | (CLIP(*y++, 8) << 22);
+                val |= (CLIP(*u++, 8) << (20-8)) | (CLIP(*y++, 8) << (30-8));
                 AV_WL32(dst, val);
                 dst += 4;
 
-                val = (CLIP(*v++, 8) << 2) | (CLIP(*y++, 8) << 12);
+                val = (CLIP(*v++, 8) << (10-8)) | (CLIP(*y++, 8) << (20-8));
                 AV_WL32(dst, val);
                 dst += 4;
             }