aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/pngdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-03 23:40:22 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-03 23:40:22 +0100
commit9e36d9e4ed2a43c363a54d963eb399a6e9623365 (patch)
tree94f7759ac92ac198d023043eef408e9445b4368e /libavcodec/pngdec.c
parentc5142a95a51320e65d80d6bca0eb69fcff05508f (diff)
downloadandroid_external_ffmpeg-9e36d9e4ed2a43c363a54d963eb399a6e9623365.tar.gz
android_external_ffmpeg-9e36d9e4ed2a43c363a54d963eb399a6e9623365.tar.bz2
android_external_ffmpeg-9e36d9e4ed2a43c363a54d963eb399a6e9623365.zip
pngdec: fix decoding of right column for 2/4bpp
Fixes Ticket1146 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pngdec.c')
-rw-r--r--libavcodec/pngdec.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index eb6e1a6713..21b742c850 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -784,15 +784,22 @@ static int decode_frame(AVCodecContext *avctx,
int i, j;
uint8_t *pd = s->current_picture->data[0];
for(j=0; j < s->height; j++) {
+ i = s->width/4;
if (s->color_type == PNG_COLOR_TYPE_PALETTE){
- for(i=s->width/4-1; i>=0; i--) {
+ if ((s->width&3) >= 3) pd[4*i+2]= (pd[i]>>2)&3;
+ if ((s->width&3) >= 2) pd[4*i+1]= (pd[i]>>4)&3;
+ if ((s->width&3) >= 1) pd[4*i+0]= pd[i]>>6;
+ for(i--; i>=0; i--) {
pd[4*i+3]= pd[i] &3;
pd[4*i+2]= (pd[i]>>2)&3;
pd[4*i+1]= (pd[i]>>4)&3;
pd[4*i+0]= pd[i]>>6;
}
} else {
- for(i=s->width/4-1; i>=0; i--) {
+ if ((s->width&3) >= 3) pd[4*i+2]= ((pd[i]>>2)&3)*0x55;
+ if ((s->width&3) >= 2) pd[4*i+1]= ((pd[i]>>4)&3)*0x55;
+ if ((s->width&3) >= 1) pd[4*i+0]= ( pd[i]>>6 )*0x55;
+ for(i--; i>=0; i--) {
pd[4*i+3]= ( pd[i] &3)*0x55;
pd[4*i+2]= ((pd[i]>>2)&3)*0x55;
pd[4*i+1]= ((pd[i]>>4)&3)*0x55;
@@ -806,13 +813,16 @@ static int decode_frame(AVCodecContext *avctx,
int i, j;
uint8_t *pd = s->current_picture->data[0];
for(j=0; j < s->height; j++) {
+ i=s->width/2;
if (s->color_type == PNG_COLOR_TYPE_PALETTE){
- for(i=s->width/2-1; i>=0; i--) {
+ if (s->width&1) pd[2*i+0]= pd[i]>>4;
+ for(i--; i>=0; i--) {
pd[2*i+1]= pd[i]&15;
pd[2*i+0]= pd[i]>>4;
}
} else {
- for(i=s->width/2-1; i>=0; i--) {
+ if (s->width&1) pd[2*i+0]= (pd[i]>>4)*0x11;
+ for(i--; i>=0; i--) {
pd[2*i+1]= (pd[i]&15)*0x11;
pd[2*i+0]= (pd[i]>>4)*0x11;
}