diff mbox

[FFmpeg-devel] lavc/arbc: Use AV_WB24() where applicable

Message ID CAB0OVGp7igv4h2kh13VMP9VdbCK2eE5=oqPPw1PeqLS0UN0d8A@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Jan. 27, 2019, 2:18 p.m. UTC
Hi!

Minimal simplification attached.

Please comment, Carl Eugen

Comments

Carl Eugen Hoyos Feb. 14, 2019, 9:01 p.m. UTC | #1
2019-01-27 15:18 GMT+01:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:
> Hi!
>
> Minimal simplification attached.

Ping.

Carl Eugen
Carl Eugen Hoyos March 20, 2019, 5:03 p.m. UTC | #2
2019-01-27 15:18 GMT+01:00, Carl Eugen Hoyos <ceffmpeg@gmail.com>:

> Minimal simplification attached.

Patch applied.

Carl Eugen
diff mbox

Patch

From e767b19ed1f87758ab777b70b6bb08ad44a6cf33 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Sun, 27 Jan 2019 15:10:04 +0100
Subject: [PATCH] lavc/arbc: Use AV_WB24() where applicable.

---
 libavcodec/arbc.c |   20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/libavcodec/arbc.c b/libavcodec/arbc.c
index 01a146f..d2d109e 100644
--- a/libavcodec/arbc.c
+++ b/libavcodec/arbc.c
@@ -38,7 +38,7 @@  typedef struct ARBCContext {
     AVFrame *prev_frame;
 } ARBCContext;
 
-static void fill_tile4(AVCodecContext *avctx, uint8_t *color, AVFrame *frame)
+static void fill_tile4(AVCodecContext *avctx, int color, AVFrame *frame)
 {
     ARBCContext *s = avctx->priv_data;
     GetByteContext *gb = &s->gb;
@@ -59,9 +59,7 @@  static void fill_tile4(AVCodecContext *avctx, uint8_t *color, AVFrame *frame)
                         mask = mask << 1;
                         continue;
                     }
-                    frame->data[0][frame->linesize[0] * (h - j) + 3 * k + 0] = color[0];
-                    frame->data[0][frame->linesize[0] * (h - j) + 3 * k + 1] = color[1];
-                    frame->data[0][frame->linesize[0] * (h - j) + 3 * k + 2] = color[2];
+                    AV_WB24(&frame->data[0][frame->linesize[0] * (h - j) + 3 * k], color);
                 }
                 mask = mask << 1;
             }
@@ -70,7 +68,7 @@  static void fill_tile4(AVCodecContext *avctx, uint8_t *color, AVFrame *frame)
 }
 
 static void fill_tileX(AVCodecContext *avctx, int tile_width, int tile_height,
-                       uint8_t *color, AVFrame *frame)
+                       int color, AVFrame *frame)
 {
     ARBCContext *s = avctx->priv_data;
     GetByteContext *gb = &s->gb;
@@ -93,9 +91,7 @@  static void fill_tileX(AVCodecContext *avctx, int tile_width, int tile_height,
                         for (int n = 0; n < step_w; n++) {
                             if (j + m >= avctx->height || k + n >= avctx->width)
                                 continue;
-                            frame->data[0][frame->linesize[0] * (h - (j + m)) + 3 * (k + n) + 0] = color[0];
-                            frame->data[0][frame->linesize[0] * (h - (j + m)) + 3 * (k + n) + 1] = color[1];
-                            frame->data[0][frame->linesize[0] * (h - (j + m)) + 3 * (k + n) + 2] = color[2];
+                            AV_WB24(&frame->data[0][frame->linesize[0] * (h - (j + m)) + 3 * (k + n)], color);
                         }
                     }
                 }
@@ -132,16 +128,16 @@  static int decode_frame(AVCodecContext *avctx, void *data,
 
     for (int i = 0; i < nb_segments; i++) {
         int resolution_flag;
-        uint8_t fill[3];
+        int fill;
 
         if (bytestream2_get_bytes_left(&s->gb) <= 0)
             return AVERROR_INVALIDDATA;
 
-        fill[0] = bytestream2_get_byte(&s->gb);
+        fill = bytestream2_get_byte(&s->gb) << 16;
         bytestream2_skip(&s->gb, 1);
-        fill[1] = bytestream2_get_byte(&s->gb);
+        fill |= bytestream2_get_byte(&s->gb) << 8;
         bytestream2_skip(&s->gb, 1);
-        fill[2] = bytestream2_get_byte(&s->gb);
+        fill |= bytestream2_get_byte(&s->gb) << 0;
         bytestream2_skip(&s->gb, 1);
         resolution_flag = bytestream2_get_byte(&s->gb);
 
-- 
1.7.10.4