diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 544f1a1cef334..36b2c2c33d635 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -847,7 +847,6 @@ static void output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof) { int ret = 0; - /* apply the output bitstream filters, if any */ if (ost->nb_bitstream_filters) { int idx; @@ -1291,6 +1290,8 @@ static void do_video_out(OutputFile *of, while (1) { ret = avcodec_receive_packet(enc, &pkt); + if (pkt.duration <= 0) + pkt.duration = av_rescale_q(in_picture->pkt_duration, ost->mux_timebase, enc->time_base); update_benchmark("encode_video %d.%d", ost->file_index, ost->index); if (ret == AVERROR(EAGAIN)) break; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 0ce22ec4fadc5..8ac8feadf925b 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1376,6 +1376,12 @@ enum AVPacketSideDataType { */ AV_PKT_DATA_A53_CC, + /** + * The disposal method that should be used with the frame. If missing, + * the frame will not be disposed. This contains exactly one byte. + */ + AV_PKT_DATA_GIF_FRAME_DISPOSAL, + /** * This side data is encryption initialization data. * The format is not part of ABI, use av_encryption_init_info_* methods to diff --git a/libavcodec/gif.c b/libavcodec/gif.c index 9f2f30d86318b..6bf656a589a55 100644 --- a/libavcodec/gif.c +++ b/libavcodec/gif.c @@ -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) { 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, -}; +}; \ No newline at end of file diff --git a/libavdevice/indev_list.c b/libavdevice/indev_list.c new file mode 100644 index 0000000000000..979b1216ee11f --- /dev/null +++ b/libavdevice/indev_list.c @@ -0,0 +1,4 @@ +static const AVInputFormat * const indev_list[] = { + &ff_avfoundation_demuxer, + &ff_lavfi_demuxer, + NULL }; diff --git a/libavdevice/outdev_list.c b/libavdevice/outdev_list.c new file mode 100644 index 0000000000000..d1b87ed7b5d56 --- /dev/null +++ b/libavdevice/outdev_list.c @@ -0,0 +1,2 @@ +static const AVOutputFormat * const outdev_list[] = { + NULL }; diff --git a/libavformat/gif.c b/libavformat/gif.c index 7916ba1e6b2a9..f8619e1cf6288 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -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; return gif->duration; }