Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-01-15 04:07:00 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-01-15 04:16:54 +0400
commit4640da7e58509996ff03b1a0b018ca8f337391c7 (patch)
tree732195f8bc4987e4974df716789044c7e3db0836 /libavcodec/targa.c
parenta91f2066651416e0f9315e7fb0132587352c75dc (diff)
parent4cd0bdae9a62d1f0366e60603222762af31e5289 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: sgidec: Use bytestream2 functions to prevent buffer overreads. cosmetics: Move static and inline attributes to more standard places. configure: provide libavfilter/version.h header to get_version() swscale: change yuv2yuvX code to use cpuflag(). libx264: Don't leave max_b_frames as -1 if the user didn't set it FATE: convert output to rgba for the targa tests which currently output pal8 fate: add missing reference files for targa tests in 9c2f9b0e2 FATE: enable the 2 remaining targa conformance suite tests targa: add support for rgb555 palette FATE: fix targa tests on big-endian systems Conflicts: libavcodec/sgidec.c libavcodec/targa.c libswscale/x86/output.asm tests/fate/image.mak Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/targa.c')
-rw-r--r--libavcodec/targa.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/libavcodec/targa.c b/libavcodec/targa.c
index 4ab560d960..57a4fee22b 100644
--- a/libavcodec/targa.c
+++ b/libavcodec/targa.c
@@ -178,24 +178,45 @@ static int decode_frame(AVCodecContext *avctx,
}
if(colors){
- size_t pal_size;
+ int pal_size, pal_sample_size;
if((colors + first_clr) > 256){
av_log(avctx, AV_LOG_ERROR, "Incorrect palette: %i colors with offset %i\n", colors, first_clr);
return -1;
}
- if(csize != 24){
+ switch (csize) {
+ case 24: pal_sample_size = 3; break;
+ case 16:
+ case 15: pal_sample_size = 2; break;
+ default:
av_log(avctx, AV_LOG_ERROR, "Palette entry size %i bits is not supported\n", csize);
return -1;
}
- pal_size = colors * ((csize + 1) >> 3);
+ pal_size = colors * pal_sample_size;
CHECK_BUFFER_SIZE(buf, buf_end, pal_size, "color table");
if(avctx->pix_fmt != PIX_FMT_PAL8)//should not occur but skip palette anyway
buf += pal_size;
else{
int t;
- int32_t *pal = ((int32_t*)p->data[1]) + first_clr;
- for(t = 0; t < colors; t++){
- *pal++ = (0xff<<24) | bytestream_get_le24(&buf);
+ uint32_t *pal = ((uint32_t *)p->data[1]) + first_clr;
+
+ switch (pal_sample_size) {
+ case 3:
+ /* RGB24 */
+ for (t = 0; t < colors; t++)
+ *pal++ = (0xffU<<24) | bytestream_get_le24(&buf);
+ break;
+ case 2:
+ /* RGB555 */
+ for (t = 0; t < colors; t++) {
+ uint32_t v = bytestream_get_le16(&buf);
+ v = ((v & 0x7C00) << 9) |
+ ((v & 0x03E0) << 6) |
+ ((v & 0x001F) << 3);
+ /* left bit replication */
+ v |= (v & 0xE0E0E0U) >> 5;
+ *pal++ = (0xffU<<24) | v;
+ }
+ break;
}
p->palette_has_changed = 1;
}