Mercurial > mplayer.hg
comparison libmpcodecs/vd_qt8bps.c @ 10713:6193f96a04d5
100l fix for paletted 8bpp files, I committed an old version
author | rtognimp |
---|---|
date | Thu, 28 Aug 2003 22:01:44 +0000 |
parents | 03b410c39759 |
children |
comparison
equal
deleted
inserted
replaced
10712:03b410c39759 | 10713:6193f96a04d5 |
---|---|
82 static int init(sh_video_t *sh) | 82 static int init(sh_video_t *sh) |
83 { | 83 { |
84 int vo_ret; // Video output init ret value | 84 int vo_ret; // Video output init ret value |
85 qt8bps_context_t *hc; // Decoder context | 85 qt8bps_context_t *hc; // Decoder context |
86 BITMAPINFOHEADER *bih = sh->bih; | 86 BITMAPINFOHEADER *bih = sh->bih; |
87 int i; | |
88 unsigned char *psrc, *pdest; | |
89 | 87 |
90 if ((hc = malloc(sizeof(qt8bps_context_t))) == NULL) { | 88 if ((hc = malloc(sizeof(qt8bps_context_t))) == NULL) { |
91 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Can't allocate memory for 8BPS decoder context.\n"); | 89 mp_msg(MSGT_DECVIDEO, MSGL_ERR, "Can't allocate memory for 8BPS decoder context.\n"); |
92 return 0; | 90 return 0; |
93 } | 91 } |
97 | 95 |
98 switch (bih->biBitCount) { | 96 switch (bih->biBitCount) { |
99 case 8: | 97 case 8: |
100 hc->planes = 1; | 98 hc->planes = 1; |
101 hc->planemap[0] = 0; // 1st plane is palette indexes | 99 hc->planemap[0] = 0; // 1st plane is palette indexes |
102 if (bih->biSize > sizeof(BITMAPINFOHEADER)) { | 100 if (bih->biSize > sizeof(BITMAPINFOHEADER)) { |
103 psrc = (unsigned char*)bih + sizeof(BITMAPINFOHEADER); | 101 hc->palette = (unsigned char *)malloc(256*4); |
104 pdest = hc->palette = (unsigned char *)malloc(256*3); | 102 memcpy(hc->palette, (unsigned char*)bih + sizeof(BITMAPINFOHEADER), 256*4); |
105 for (i = 0; i < 256; i++) { | 103 } |
106 *pdest++ = *psrc++; | |
107 *pdest++ = *psrc++; | |
108 *pdest++ = *psrc++; | |
109 psrc++; | |
110 } | |
111 } | |
112 break; | 104 break; |
113 case 24: | 105 case 24: |
114 hc->planes = 3; | 106 hc->planes = 3; |
115 hc->planemap[0] = 2; // 1st plane is red | 107 hc->planemap[0] = 2; // 1st plane is red |
116 hc->planemap[1] = 1; // 2nd plane is green | 108 hc->planemap[1] = 1; // 2nd plane is green |