diff options
-rw-r--r-- | src/demuxers/demux_avi.c | 33 | ||||
-rw-r--r-- | src/libxinevdec/msvc.c | 17 | ||||
-rw-r--r-- | src/xine-engine/buffer.h | 22 |
3 files changed, 68 insertions, 4 deletions
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 45247b1d1..9e718b8dd 100644 --- a/src/demuxers/demux_avi.c +++ b/src/demuxers/demux_avi.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_avi.c,v 1.97 2002/06/23 18:35:41 tmattern Exp $ + * $Id: demux_avi.c,v 1.98 2002/06/25 03:37:53 tmmm Exp $ * * demultiplexer for avi streams * @@ -158,6 +158,9 @@ typedef struct video_index_t video_idx; xine_bmiheader bih; off_t movi_start; + + int palette_count; + palette_entry_t palette[256]; } avi_t; typedef struct demux_avi_s { @@ -572,7 +575,7 @@ static void gen_index_show_progress (demux_avi_t *this, int percent) { static avi_t *AVI_init(demux_avi_t *this) { avi_t *AVI; - long i, n, idx_type; + long i, j, n, idx_type; unsigned char *hdrl_data; long hdrl_len=0; off_t ioff; @@ -739,6 +742,19 @@ static avi_t *AVI_init(demux_avi_t *this) { */ vids_strf_seen = 1; + /* load the palette, if there is one */ + AVI->palette_count = AVI->bih.biClrUsed; + if (AVI->palette_count > 256) { + printf ("demux_avi: number of colors exceeded 256 (%d)", + AVI->palette_count); + AVI->palette_count = 256; + } + for (j = 0; j < AVI->palette_count; j++) { + AVI->palette[j].b = *(hdrl_data + i + sizeof(AVI->bih) + j * 4 + 0); + AVI->palette[j].g = *(hdrl_data + i + sizeof(AVI->bih) + j * 4 + 1); + AVI->palette[j].r = *(hdrl_data + i + sizeof(AVI->bih) + j * 4 + 2); + } + } else if(lasttag == 2) { AVI->audio[AVI->n_audio-1]->wavex=(xine_waveformatex *)malloc(n); @@ -1376,6 +1392,19 @@ static int demux_avi_start (demux_plugin_t *this_gen, this->video_fifo->put (this->video_fifo, buf); + /* send off the palette, if there is one */ + if (this->avi->palette_count) { + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf->content = buf->mem; + buf->decoder_flags = BUF_FLAG_SPECIAL; + buf->decoder_info[1] = BUF_SPECIAL_PALETTE; + buf->decoder_info[2] = this->avi->palette_count; + buf->decoder_info[3] = (unsigned int)&this->avi->palette; + buf->size = 0; + buf->type = this->avi->video_type; + this->video_fifo->put (this->video_fifo, buf); + } + if(this->audio_fifo) { for(i=0; i<this->avi->n_audio; i++) { avi_audio_t *a = this->avi->audio[i]; diff --git a/src/libxinevdec/msvc.c b/src/libxinevdec/msvc.c index a592ce2d5..3db4681e8 100644 --- a/src/libxinevdec/msvc.c +++ b/src/libxinevdec/msvc.c @@ -22,7 +22,7 @@ * based on overview of Microsoft Video-1 algorithm * by Mike Melanson: http://www.pcisys.net/~melanson/codecs/video1.txt * - * $Id: msvc.c,v 1.5 2002/06/03 17:31:29 esnel Exp $ + * $Id: msvc.c,v 1.6 2002/06/25 03:37:53 tmmm Exp $ */ #include <stdlib.h> @@ -203,9 +203,24 @@ static void msvc_init (video_decoder_t *this_gen, vo_instance_t *video_out) { static void msvc_decode_data (video_decoder_t *this_gen, buf_element_t *buf) { msvc_decoder_t *this = (msvc_decoder_t *) this_gen; + int i; + palette_entry_t *palette; + if (buf->decoder_flags & BUF_FLAG_PREVIEW) return; + if ((buf->decoder_flags & BUF_FLAG_SPECIAL) && + (buf->decoder_info[1] == BUF_SPECIAL_PALETTE)) { + palette = (palette_entry_t *)buf->decoder_info[3]; + for (i = 0; i < buf->decoder_info[2]; i++) + rgb_to_yuy2( + 32, + (palette[i].r << 16) | + (palette[i].g << 8) | + (palette[i].b << 0), + &this->color_table[i]); + } + if (buf->decoder_flags & BUF_FLAG_HEADER) { xine_bmiheader *bih; diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index 81c10f6f7..7cf623c1e 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: buffer.h,v 1.51 2002/06/19 23:25:15 tmattern Exp $ + * $Id: buffer.h,v 1.52 2002/06/25 03:37:52 tmmm Exp $ * * * contents: @@ -192,6 +192,26 @@ struct buf_element_s { #define BUF_FLAG_END_STREAM 0x0040 #define BUF_FLAG_FRAMERATE 0x0080 #define BUF_FLAG_SEEK 0x0100 +#define BUF_FLAG_SPECIAL 0x0200 + +/* these are the types of special buffers */ +/* + * In a BUF_SPECIAL_PALETTE buffer: + * decoder_info[1] = BUF_SPECIAL_PALETTE + * decoder_info[2] = number of entries in palette table + * decoder_info[3] = pointer to palette table + * A palette table is an array of palette_entry_t structures. A decoder + * should not count on this array to exist for the duration of the + * program's execution and should copy, manipulate, and store the palette + * data privately if it needs the palette information. + */ +#define BUF_SPECIAL_PALETTE 1 + +typedef struct palette_entry_s palette_entry_t; +struct palette_entry_s +{ + unsigned char r, g, b; +} ; typedef struct fifo_buffer_s fifo_buffer_t; struct fifo_buffer_s |