transparency support
Originally committed as revision 1808 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
		
							parent
							
								
									7e2e1abf6b
								
							
						
					
					
						commit
						a059da1227
					
				@ -94,7 +94,8 @@ static int gif_video_probe(AVProbeData * pd)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    const uint8_t *p, *p_end;
 | 
					    const uint8_t *p, *p_end;
 | 
				
			||||||
    int bits_per_pixel, has_global_palette, ext_code, ext_len;
 | 
					    int bits_per_pixel, has_global_palette, ext_code, ext_len;
 | 
				
			||||||
    
 | 
					    int gce_flags, gce_disposal;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (pd->buf_size < 24 ||
 | 
					    if (pd->buf_size < 24 ||
 | 
				
			||||||
	memcmp(pd->buf, gif89a_sig, 6) != 0)
 | 
						memcmp(pd->buf, gif89a_sig, 6) != 0)
 | 
				
			||||||
        return 0;
 | 
					        return 0;
 | 
				
			||||||
@ -114,16 +115,28 @@ static int gif_video_probe(AVProbeData * pd)
 | 
				
			|||||||
        if (p >= p_end)
 | 
					        if (p >= p_end)
 | 
				
			||||||
            return 0;
 | 
					            return 0;
 | 
				
			||||||
        ext_code = *p++;
 | 
					        ext_code = *p++;
 | 
				
			||||||
        /* if GCE extension found: it is likely to be an animation */
 | 
					        if (p >= p_end)
 | 
				
			||||||
        if (ext_code == 0xf9)
 | 
					            return 0;
 | 
				
			||||||
            return AVPROBE_SCORE_MAX;
 | 
					        ext_len = *p++;
 | 
				
			||||||
        for(;;) {
 | 
					        if (ext_code == 0xf9) {
 | 
				
			||||||
            if (p >= p_end)
 | 
					            if (p >= p_end)
 | 
				
			||||||
                return 0;
 | 
					                return 0;
 | 
				
			||||||
            ext_len = *p++;
 | 
					            /* if GCE extension found with gce_disposal != 0: it is
 | 
				
			||||||
 | 
					               likely to be an animation */
 | 
				
			||||||
 | 
					            gce_flags = *p++;
 | 
				
			||||||
 | 
					            gce_disposal = (gce_flags >> 2) & 0x7;
 | 
				
			||||||
 | 
					            if (gce_disposal != 0)
 | 
				
			||||||
 | 
					                return AVPROBE_SCORE_MAX;
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        for(;;) {
 | 
				
			||||||
            if (ext_len == 0)
 | 
					            if (ext_len == 0)
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
            p += ext_len;
 | 
					            p += ext_len;
 | 
				
			||||||
 | 
					            if (p >= p_end)
 | 
				
			||||||
 | 
					                return 0;
 | 
				
			||||||
 | 
					            ext_len = *p++;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
@ -320,6 +333,9 @@ static int gif_read_image(GifState *s)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        for(; i < 256; i++)
 | 
					        for(; i < 256; i++)
 | 
				
			||||||
            s->image_palette[i] = (0xff << 24);
 | 
					            s->image_palette[i] = (0xff << 24);
 | 
				
			||||||
 | 
					        /* handle transparency */
 | 
				
			||||||
 | 
					        if (s->transparent_color_index >= 0)
 | 
				
			||||||
 | 
					            s->image_palette[s->transparent_color_index] = 0;
 | 
				
			||||||
        line = NULL;
 | 
					        line = NULL;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user