History

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.

wm4 committed 8 years ago

Commit e53d3341 parent be3a0511 file · +8 −1Browse files

Unified · Split

libavcodec/xwdenc.c+8−1
@@ -41,6 +41,7 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 40 unmodified lines
4141 int i, out_size, ret;
4242 uint8_t *ptr, *buf;
4343 AVFrame * const p = (AVFrame *)pict;
44+ uint32_t pal[256];
4445
4546 pixdepth = av_get_bits_per_pixel(desc);
4647 if (desc->flags & AV_PIX_FMT_FLAG_BE)
@@ -180,11 +181,17 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 133 unmodified lines
180181 bytestream_put_be32(&buf, 0); // window border width
181182 bytestream_put_buffer(&buf, WINDOW_NAME, WINDOW_NAME_SIZE);
182183
184+ if (pix_fmt == AV_PIX_FMT_PAL8) {
185+ memcpy(pal, p->data[1], sizeof(pal));
186+ } else {
187+ avpriv_set_systematic_pal2(pal, pix_fmt);
188+ }
189+
183190 for (i = 0; i < ncolors; i++) {
184191 uint32_t val;
185192 uint8_t red, green, blue;
186193
187− val = AV_RN32A(p->data[1] + i * 4);
194+ val = pal[i];
188195 red = (val >> 16) & 0xFF;
189196 green = (val >> 8) & 0xFF;
190197 blue = val & 0xFF;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t