forked from FFmpeg/FFmpeg
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gif transparency fix #3
Open
jagraff
wants to merge
26
commits into
master
Choose a base branch
from
gif-transparency-fix
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ada564c
fix for transparencies in animated gifs
bejayoharen 88a7c75
bugfixes for edge and 2nd frame artifacts
bejayoharen 77cd1d0
fixes for corrupt gifs
bejayoharen e8f1d7d
Merge remote-tracking branch 'upstream/master'
cyburgee 9e5c00c
Merge remote-tracking branch 'upstream/master'
cyburgee 6e06057
actually fix conflict
cyburgee e6bd543
Merge remote-tracking branch 'upstream/master'
cyburgee 2e5e052
Merge remote-tracking branch 'upstream/master'
cyburgee 8f5485b
Merge remote-tracking branch 'upstream/master'
cyburgee 5eaaf8e
CR-1266: Fix infinite loop bug on transparent optimization
jagraff a35311a
Merge pull request #1 from Giphy/CR-1266
jagraff 6e3b807
Merge remote-tracking branch 'upstream/master'
cyburgee 5cfb22c
fix conflict res issue
cyburgee 2fc69e5
Merge pull request #2 from Giphy/upstream-merge-03-14-19-v2
cyburgee c6180f3
fix transparent crop
cyburgee d69c4cf
Update gif.c
cyburgee 8376342
Fix bug with transparent gif cropping
jagraff 561517b
Optimize
jagraff d199ea7
Remove extra logging
jagraff 9f697ed
Fix disposal method issue
jagraff 9ecadad
Fix for duration bug
jagraff 1647406
Don't need to specify prop
jagraff f837eeb
Change get delay function
jagraff b3f31a3
Change get delay function
jagraff 4f1587a
Spacing
jagraff f2b8cce
Remove incorrect AV_NOPTS_VALUE check
jagraff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,7 @@ static void gif_crop_translucent(AVCodecContext *avctx, | |
while (*y_start < y_end) { | ||
int is_trans = 1; | ||
for (int i = 0; i < w; i++) { | ||
if (buf[w * *y_start + i] != trans) { | ||
if (buf[linesize * *y_start + i] != trans) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (ignoring this file as it's already mostly been accepted in mainline) |
||
is_trans = 0; | ||
break; | ||
} | ||
|
@@ -148,10 +148,10 @@ static void gif_crop_translucent(AVCodecContext *avctx, | |
} | ||
|
||
// crop bottom | ||
while (y_end < h) { | ||
while (y_end > *y_start) { | ||
int is_trans = 1; | ||
for (int i = 0; i < w; i++) { | ||
if (buf[w * y_end + i] != trans) { | ||
if (buf[linesize * y_end + i] != trans) { | ||
is_trans = 0; | ||
break; | ||
} | ||
|
@@ -165,7 +165,7 @@ static void gif_crop_translucent(AVCodecContext *avctx, | |
while (*x_start < x_end) { | ||
int is_trans = 1; | ||
for (int i = *y_start; i < y_end; i++) { | ||
if (buf[w * i + *x_start] != trans) { | ||
if (buf[linesize * i + *x_start] != trans) { | ||
is_trans = 0; | ||
break; | ||
} | ||
|
@@ -176,10 +176,10 @@ static void gif_crop_translucent(AVCodecContext *avctx, | |
} | ||
|
||
// crop right | ||
while (x_end < w) { | ||
while (x_end > *x_start) { | ||
int is_trans = 1; | ||
for (int i = *y_start; i < y_end; i++) { | ||
if (buf[w * i + x_end] != trans) { | ||
if (buf[linesize * i + x_end] != trans) { | ||
is_trans = 0; | ||
break; | ||
} | ||
|
@@ -191,6 +191,7 @@ static void gif_crop_translucent(AVCodecContext *avctx, | |
|
||
*height = y_end + 1 - *y_start; | ||
*width = x_end + 1 - *x_start; | ||
|
||
av_log(avctx, AV_LOG_DEBUG,"%dx%d image at pos (%d;%d) [area:%dx%d]\n", | ||
*width, *height, *x_start, *y_start, avctx->width, avctx->height); | ||
} | ||
|
@@ -267,7 +268,7 @@ static int gif_image_write_image(AVCodecContext *avctx, | |
int bcid = -1, honor_transparency = (s->flags & GF_TRANSDIFF) && s->last_frame && !palette; | ||
const uint8_t *ptr; | ||
|
||
if (!s->image && avctx->frame_number && is_image_translucent(avctx, buf, linesize)) { | ||
if (!s->image && is_image_translucent(avctx, buf, linesize)) { | ||
gif_crop_translucent(avctx, buf, linesize, &width, &height, &x_start, &y_start); | ||
honor_transparency = 0; | ||
disposal = GCE_DISPOSAL_BACKGROUND; | ||
|
@@ -497,4 +498,4 @@ AVCodec ff_gif_encoder = { | |
AV_PIX_FMT_GRAY8, AV_PIX_FMT_PAL8, AV_PIX_FMT_NONE | ||
}, | ||
.priv_class = &gif_class, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
static const AVInputFormat * const indev_list[] = { | ||
&ff_avfoundation_demuxer, | ||
&ff_lavfi_demuxer, | ||
NULL }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
static const AVOutputFormat * const outdev_list[] = { | ||
NULL }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,8 @@ static int gif_get_delay(GIFContext *gif, AVPacket *prev, AVPacket *new) | |
gif->duration = av_clip_uint16(new->pts - prev->pts); | ||
else if (!new && gif->last_delay >= 0) | ||
gif->duration = gif->last_delay; | ||
else | ||
gif->duration = prev->duration; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense |
||
|
||
return gif->duration; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[from IRL discussion] jagraff explained to me that this is probably not the 'right' way to copy the duration between frames (since it's probably better to figure out why the duration isn't copied over and fix that). So this is unlikely to be merged into mainline - but I think it's fine to use this for GIPHY's purposes.