Hi!
The Opus struct RawBitsContext is used in both the decoder and the encoder.
The fact that *position is const avoids warnings in the decoder where
it points into the bitstream. The encoder writes into the same
pointer, attached cast silences the warning on targets where AV_WB32()
does not internally cast the qualifier away.
It is also possible to use a union if anybody prefers this:
diff --git a/libavcodec/opus_rc.h b/libavcodec/opus_rc.h
index 627f832..baad4ce 100644
--- a/libavcodec/opus_rc.h
+++ b/libavcodec/opus_rc.h
@@ -37,9 +37,19 @@ typedef struct RawBitsContext {
uint32_t cacheval;
} RawBitsContext;
+typedef struct RawBitsEncContext {
+ uint8_t *position;
+ uint32_t bytes;
+ uint32_t cachelen;
+ uint32_t cacheval;
+} RawBitsEncContext;
+
typedef struct OpusRangeCoder {
GetBitContext gb;
- RawBitsContext rb;
+ union {
+ RawBitsContext rb;
+ RawBitsEncContext rbe;
+ };
uint32_t range;
uint32_t value;
uint32_t total_bits;
and use rbe in ff_opus_rc_put_raw().
Please comment, Carl Eugen
From 2fe5044a4532f061ef4090fd46f1ec1a3af067b0 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <[email protected]>
Date: Mon, 17 Dec 2018 02:36:26 +0100
Subject: [PATCH] lavc/opus_rc: Cast a const pointer to uint8_t *.
Silences a warning with clang on arm:
libavcodec/opus_rc.c:170:17: warning: passing 'const uint8_t *' (aka 'const unsigned char *') to parameter of type 'void *' discards qualifiers
---
libavcodec/opus_rc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/opus_rc.c b/libavcodec/opus_rc.c
index 3972bb0..c432eb9 100644
--- a/libavcodec/opus_rc.c
+++ b/libavcodec/opus_rc.c
@@ -167,7 +167,7 @@ void ff_opus_rc_put_raw(OpusRangeCoder *rc, uint32_t val, uint32_t count)
rc->rb.cachelen = (rc->rb.cachelen + to_write) % 32;
if (!rc->rb.cachelen && count) {
- AV_WB32(rc->rb.position, rc->rb.cacheval);
+ AV_WB32((uint8_t *)rc->rb.position, rc->rb.cacheval);
rc->rb.bytes += 4;
rc->rb.position -= 4;
rc->rb.cachelen = count - to_write;
--
1.7.10.4
_______________________________________________
ffmpeg-devel mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel