diff options
author | wm4 <nfxjfg@googlemail.com> | 2018-03-29 16:10:15 +0300 |
---|---|---|
committer | wm4 <nfxjfg@googlemail.com> | 2018-04-03 18:52:06 +0300 |
commit | e53d3348d10feda300a4d906c136a4ce438369eb (patch) | |
tree | 6c1f2fcfd0b1e38fe664913cbf5efabd4a192968 | |
parent | be3a051ca8fe012e394dfb14f9274b84e0fdd207 (diff) |
avcodec/xwdenc: do not rely on AV_PIX_FMT_FLAG_PSEUDOPAL palettes
This is the only code I found within FFmpeg that still inherently
requires AV_PIX_FMT_FLAG_PSEUDOPAL. It's easily changed not to require
it.
Preparation for the next patch.
-rw-r--r-- | libavcodec/xwdenc.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c index 43bca89033..81cca6c963 100644 --- a/libavcodec/xwdenc.c +++ b/libavcodec/xwdenc.c @@ -41,6 +41,7 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int i, out_size, ret; uint8_t *ptr, *buf; AVFrame * const p = (AVFrame *)pict; + uint32_t pal[256]; pixdepth = av_get_bits_per_pixel(desc); if (desc->flags & AV_PIX_FMT_FLAG_BE) @@ -180,11 +181,17 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytestream_put_be32(&buf, 0); // window border width bytestream_put_buffer(&buf, WINDOW_NAME, WINDOW_NAME_SIZE); + if (pix_fmt == AV_PIX_FMT_PAL8) { + memcpy(pal, p->data[1], sizeof(pal)); + } else { + avpriv_set_systematic_pal2(pal, pix_fmt); + } + for (i = 0; i < ncolors; i++) { uint32_t val; uint8_t red, green, blue; - val = AV_RN32A(p->data[1] + i * 4); + val = pal[i]; red = (val >> 16) & 0xFF; green = (val >> 8) & 0xFF; blue = val & 0xFF; |