@ -41,6 +41,7 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
int i , out_size , ret ;
int i , out_size , ret ;
uint8_t * ptr , * buf ;
uint8_t * ptr , * buf ;
AVFrame * const p = ( AVFrame * ) pict ;
AVFrame * const p = ( AVFrame * ) pict ;
uint32_t pal [ 256 ] ;
pixdepth = av_get_bits_per_pixel ( desc ) ;
pixdepth = av_get_bits_per_pixel ( desc ) ;
if ( desc - > flags & AV_PIX_FMT_FLAG_BE )
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_be32 ( & buf , 0 ) ; // window border width
bytestream_put_buffer ( & buf , WINDOW_NAME , WINDOW_NAME_SIZE ) ;
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 + + ) {
for ( i = 0 ; i < ncolors ; i + + ) {
uint32_t val ;
uint32_t val ;
uint8_t red , green , blue ;
uint8_t red , green , blue ;
val = AV_RN32A ( p - > data [ 1 ] + i * 4 ) ;
val = pal [ i ] ;
red = ( val > > 16 ) & 0xFF ;
red = ( val > > 16 ) & 0xFF ;
green = ( val > > 8 ) & 0xFF ;
green = ( val > > 8 ) & 0xFF ;
blue = val & 0xFF ;
blue = val & 0xFF ;