diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-19 16:46:06 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2015-08-20 14:38:25 +0200 |
commit | e588252a429ca60408813191350891680e848dfd (patch) | |
tree | 299e0e93c5844f40166c1d2ca2ab2870be17a0f8 /libavcodec/dpxenc.c | |
parent | 7de7d81ee55adbe77650f61831fa8b0c3e4159fa (diff) | |
download | ffmpeg-e588252a429ca60408813191350891680e848dfd.tar.gz |
avcodec/dpxenc: implement write16/32 as functions
Fixes undefined behavior and segfault
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 8edc17b639c4ac47913c467107ffb43c67c64890)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/dpxenc.c')
-rw-r--r-- | libavcodec/dpxenc.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c index aca745bb58..76aa0cc473 100644 --- a/libavcodec/dpxenc.c +++ b/libavcodec/dpxenc.c @@ -75,17 +75,20 @@ static av_cold int encode_init(AVCodecContext *avctx) return 0; } -#define write16(p, value) \ -do { \ - if (s->big_endian) AV_WB16(p, value); \ - else AV_WL16(p, value); \ -} while(0) +static av_always_inline void write16_internal(int big_endian, void *p, int value) +{ + if (big_endian) AV_WB16(p, value); + else AV_WL16(p, value); +} + +static av_always_inline void write32_internal(int big_endian, void *p, int value) +{ + if (big_endian) AV_WB32(p, value); + else AV_WL32(p, value); +} -#define write32(p, value) \ -do { \ - if (s->big_endian) AV_WB32(p, value); \ - else AV_WL32(p, value); \ -} while(0) +#define write16(p, value) write16_internal(s->big_endian, p, value) +#define write32(p, value) write32_internal(s->big_endian, p, value) static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst) { |