You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-14 22:15:12 +02:00
Simplify tiff decoder by merging two functions.
This commit is contained in:
@ -106,21 +106,19 @@ static void av_always_inline horizontal_fill(unsigned int bpp, uint8_t* dst,
|
|||||||
int usePtr, const uint8_t *src,
|
int usePtr, const uint8_t *src,
|
||||||
uint8_t c, int width, int offset)
|
uint8_t c, int width, int offset)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
switch (bpp) {
|
switch (bpp) {
|
||||||
case 2:
|
case 2:
|
||||||
for (i = 0; i < width; i++) {
|
while (--width >= 0) {
|
||||||
dst[(i+offset)*4+0] = (usePtr ? src[i] : c) >> 6;
|
dst[(width+offset)*4+3] = (usePtr ? src[width] : c) & 0x3;
|
||||||
dst[(i+offset)*4+1] = (usePtr ? src[i] : c) >> 4 & 0x3;
|
dst[(width+offset)*4+2] = (usePtr ? src[width] : c) >> 2 & 0x3;
|
||||||
dst[(i+offset)*4+2] = (usePtr ? src[i] : c) >> 2 & 0x3;
|
dst[(width+offset)*4+1] = (usePtr ? src[width] : c) >> 4 & 0x3;
|
||||||
dst[(i+offset)*4+3] = (usePtr ? src[i] : c) & 0x3;
|
dst[(width+offset)*4+0] = (usePtr ? src[width] : c) >> 6;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
for (i = 0; i < width; i++) {
|
while (--width >= 0) {
|
||||||
dst[(i+offset)*2+0] = (usePtr ? src[i] : c) >> 4;
|
dst[(width+offset)*2+1] = (usePtr ? src[width] : c) & 0xF;
|
||||||
dst[(i+offset)*2+1] = (usePtr ? src[i] : c) & 0xF;
|
dst[(width+offset)*2+0] = (usePtr ? src[width] : c) >> 4;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -132,16 +130,6 @@ static void av_always_inline horizontal_fill(unsigned int bpp, uint8_t* dst,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void av_always_inline split_nibbles(uint8_t *dst, const uint8_t *src,
|
|
||||||
int width)
|
|
||||||
{
|
|
||||||
while (--width >= 0) {
|
|
||||||
// src == dst for LZW
|
|
||||||
dst[width * 2 + 1] = src[width] & 0xF;
|
|
||||||
dst[width * 2 + 0] = src[width] >> 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){
|
static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){
|
||||||
int c, line, pixels, code;
|
int c, line, pixels, code;
|
||||||
const uint8_t *ssrc = src;
|
const uint8_t *ssrc = src;
|
||||||
@ -162,7 +150,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
|
|||||||
src = zbuf;
|
src = zbuf;
|
||||||
for(line = 0; line < lines; line++){
|
for(line = 0; line < lines; line++){
|
||||||
if(s->bpp == 4){
|
if(s->bpp == 4){
|
||||||
split_nibbles(dst, src, width);
|
horizontal_fill(s->bpp, dst, 1, src, 0, width, 0);
|
||||||
}else{
|
}else{
|
||||||
memcpy(dst, src, width);
|
memcpy(dst, src, width);
|
||||||
}
|
}
|
||||||
@ -258,7 +246,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(s->bpp == 4)
|
if(s->bpp == 4)
|
||||||
split_nibbles(dst, dst, width);
|
horizontal_fill(s->bpp, dst, 1, dst, 0, width, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dst += stride;
|
dst += stride;
|
||||||
|
Reference in New Issue
Block a user