Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
- index 992122c..5903d5c 100644
- --- a/libavcodec/libvpxenc.c
- +++ b/libavcodec/libvpxenc.c
- @@ -898,8 +898,10 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt,
- flags |= VPX_EFLAG_FORCE_KF;
- }
- + av_log(avctx, AV_LOG_WARNING, "duration: (%d)\n", frame->pkt_duration);
- res = vpx_codec_encode(&ctx->encoder, rawimg, timestamp,
- - avctx->ticks_per_frame, flags, ctx->deadline);
- + frame->pkt_duration || avctx->ticks_per_frame,
- + flags, ctx->deadline);
- if (res != VPX_CODEC_OK) {
- log_encoder_error(avctx, "Error encoding frame");
- return AVERROR_INVALIDDATA;
- diff --git a/libavfilter/Makefile b/libavfilter/Makefile
- index a095a10..95cc658 100644
- --- a/libavfilter/Makefile
- +++ b/libavfilter/Makefile
- @@ -131,6 +131,7 @@ OBJS-$(CONFIG_DRAWBOX_FILTER) += vf_drawbox.o
- OBJS-$(CONFIG_DRAWGRAPH_FILTER) += f_drawgraph.o
- OBJS-$(CONFIG_DRAWGRID_FILTER) += vf_drawbox.o
- OBJS-$(CONFIG_DRAWTEXT_FILTER) += vf_drawtext.o
- +OBJS-$(CONFIG_DURATION_FILTER) += vf_duration.o
- OBJS-$(CONFIG_ELBG_FILTER) += vf_elbg.o
- OBJS-$(CONFIG_EDGEDETECT_FILTER) += vf_edgedetect.o
- OBJS-$(CONFIG_EQ_FILTER) += vf_eq.o
- diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
- index 3ab9a48..91c8ad5 100644
- --- a/libavfilter/allfilters.c
- +++ b/libavfilter/allfilters.c
- @@ -153,6 +153,7 @@ void avfilter_register_all(void)
- REGISTER_FILTER(DRAWGRAPH, drawgraph, vf);
- REGISTER_FILTER(DRAWGRID, drawgrid, vf);
- REGISTER_FILTER(DRAWTEXT, drawtext, vf);
- + REGISTER_FILTER(DURATION, duration, vf);
- REGISTER_FILTER(EDGEDETECT, edgedetect, vf);
- REGISTER_FILTER(ELBG, elbg, vf);
- REGISTER_FILTER(EQ, eq, vf);
- diff --git a/libavfilter/vf_duration.c b/libavfilter/vf_duration.c
- new file mode 100644
- index 0000000..bbc40b7
- --- /dev/null
- +++ b/libavfilter/vf_duration.c
- @@ -0,0 +1,105 @@
- +/*
- + * This file is part of FFmpeg.
- + *
- + * FFmpeg is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU Lesser General Public
- + * License as published by the Free Software Foundation; either
- + * version 2.1 of the License, or (at your option) any later version.
- + *
- + * FFmpeg is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * Lesser General Public License for more details.
- + *
- + * You should have received a copy of the GNU Lesser General Public
- + * License along with FFmpeg; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- + */
- +
- +/**
- + * @file vf_duration filter, fill frame->pkt_duration field
- + */
- +
- +#include "libavutil/internal.h"
- +#include "avfilter.h"
- +#include "internal.h"
- +#include "video.h"
- +
- +typedef struct {
- + const AVClass *class;
- + AVFrame *prev;
- +} DurationContext;
- +
- +static const AVFilterPad avfilter_vf_duration_inputs[] = {
- + {
- + .name = "default",
- + .type = AVMEDIA_TYPE_VIDEO,
- + },
- + { NULL }
- +};
- +
- +static const AVFilterPad avfilter_vf_duration_outputs[] = {
- + {
- + .name = "default",
- + .type = AVMEDIA_TYPE_VIDEO,
- + },
- + { NULL }
- +};
- +
- +static av_cold void init(AVFilterContext *ctx)
- +{
- + DurationContext *duration = ctx->priv;
- + duration->prev = 0;
- + //return ff_filter_frame(outlink, duration->prev);
- + return 0;
- +};
- +
- +static av_cold void uninit(AVFilterContext *ctx)
- +{
- + DurationContext *duration = ctx->priv;
- + //return ff_filter_frame(outlink, duration->prev);
- + return 0;
- +};
- +
- +static int filter_frame(AVFilterLink *inlink, AVFrame *in)
- +{
- + DurationContext *duration = inlink->dst->priv;
- + int ret;
- +
- + if (duration->prev) {
- + AVFilterLink *outlink = inlink->dst->outputs[0];
- + AVFrame *out = ff_get_video_buffer(outlink, in->width, in->height);
- + if (!out) {
- + av_frame_free(&duration->prev);
- + av_frame_free(&in);
- + return AVERROR(ENOMEM);
- + }
- + av_frame_copy_props(out, duration->prev);
- + av_frame_copy(out, duration->prev);
- + out->pkt_duration = in->pts - out->pts;
- + av_frame_free(&duration->prev);
- + duration->prev = in;
- + return ff_filter_frame(outlink, out);
- + };
- + duration->prev = in;
- + return 0;
- +};
- +
- +static const AVFilterPad duration_inputs[] = {
- + {
- + .name = "default",
- + .type = AVMEDIA_TYPE_VIDEO,
- + .filter_frame = filter_frame,
- + },
- + { NULL }
- +};
- +
- +AVFilter ff_vf_duration = {
- + .name = "duration",
- + .description = NULL_IF_CONFIG_SMALL("Fill frame display duraion field."),
- + .init = init,
- + .uninit = uninit,
- + .priv_size = sizeof(DurationContext),
- + .inputs = duration_inputs,
- + .outputs = avfilter_vf_duration_outputs,
- +};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement