summaryrefslogtreecommitdiff
path: root/libavcodec/pnmenc.c
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2022-08-10 01:00:56 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2022-08-19 22:09:36 +0200
commitf3fb528cd5bfecec6835a3951c75903a194ae1ad (patch)
treea2d67c75082a009f1c299dfb319fd54a9357e4a4 /libavcodec/pnmenc.c
parentcb8ad005bb73b1adf0d36eeb794c4c375fd3ee12 (diff)
avutil/half2float: move tables to header-internal structs
Having to put the knowledge of the size of those arrays into a multitude of places is rather smelly.
Diffstat (limited to 'libavcodec/pnmenc.c')
-rw-r--r--libavcodec/pnmenc.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index 7ce534d06e..38a5d8172d 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -30,8 +30,7 @@
#include "encode.h"
typedef struct PHMEncContext {
- uint16_t basetable[512];
- uint8_t shifttable[512];
+ Float2HalfTables f2h_tables;
} PHMEncContext;
static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
@@ -169,9 +168,9 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
for (int i = 0; i < avctx->height; i++) {
for (int j = 0; j < avctx->width; j++) {
- AV_WN16(bytestream + 0, float2half(av_float2int(r[j]), s->basetable, s->shifttable));
- AV_WN16(bytestream + 2, float2half(av_float2int(g[j]), s->basetable, s->shifttable));
- AV_WN16(bytestream + 4, float2half(av_float2int(b[j]), s->basetable, s->shifttable));
+ AV_WN16(bytestream + 0, float2half(av_float2int(r[j]), &s->f2h_tables));
+ AV_WN16(bytestream + 2, float2half(av_float2int(g[j]), &s->f2h_tables));
+ AV_WN16(bytestream + 4, float2half(av_float2int(b[j]), &s->f2h_tables));
bytestream += 6;
}
@@ -184,7 +183,7 @@ static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
for (int i = 0; i < avctx->height; i++) {
for (int j = 0; j < avctx->width; j++) {
- AV_WN16(bytestream, float2half(av_float2int(g[j]), s->basetable, s->shifttable));
+ AV_WN16(bytestream, float2half(av_float2int(g[j]), &s->f2h_tables));
bytestream += 2;
}
@@ -295,7 +294,7 @@ static av_cold int phm_enc_init(AVCodecContext *avctx)
{
PHMEncContext *s = avctx->priv_data;
- float2half_tables(s->basetable, s->shifttable);
+ init_float2half_tables(&s->f2h_tables);
return 0;
}