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
41 int i, out_size, ret;41 int i, out_size, ret;
42 uint8_t *ptr, *buf;42 uint8_t *ptr, *buf;
43 AVFrame * const p = (AVFrame *)pict;43 AVFrame * const p = (AVFrame *)pict;
44 uint32_t pal[256];
44 45
45 pixdepth = av_get_bits_per_pixel(desc);46 pixdepth = av_get_bits_per_pixel(desc);
46 if (desc->flags & AV_PIX_FMT_FLAG_BE)47 if (desc->flags & AV_PIX_FMT_FLAG_BE)
@@ -180,11 +181,17 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, · 133 unmodified lines
180 bytestream_put_be32(&buf, 0); // window border width181 bytestream_put_be32(&buf, 0); // window border width
181 bytestream_put_buffer(&buf, WINDOW_NAME, WINDOW_NAME_SIZE);182 bytestream_put_buffer(&buf, WINDOW_NAME, WINDOW_NAME_SIZE);
182 183
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
183 for (i = 0; i < ncolors; i++) {190 for (i = 0; i < ncolors; i++) {
184 uint32_t val;191 uint32_t val;
185 uint8_t red, green, blue;192 uint8_t red, green, blue;
186 193
187 val = AV_RN32A(p->data[1] + i * 4);194 val = pal[i];
188 red = (val >> 16) & 0xFF;195 red = (val >> 16) & 0xFF;
189 green = (val >> 8) & 0xFF;196 green = (val >> 8) & 0xFF;
190 blue = val & 0xFF;197 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