Re: [FFmpeg-devel] [PATCH] lavf/utils: change truncating packet log to a warning
On Sun, 30 Sep 2018 at 06:08, Rostislav Pehlivanov wrote: > Some scene files do this intentionally for the sake of having a nice > checksum. > --- > libavformat/utils.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/utils.c b/libavformat/utils.c > index c973a7e0c5..924b99f6d4 100644 > --- a/libavformat/utils.c > +++ b/libavformat/utils.c > @@ -257,7 +257,7 @@ int ffio_limit(AVIOContext *s, int size) > } > > if (s->maxsize>= 0 && remaining+1 < size) { > -av_log(NULL, remaining ? AV_LOG_ERROR : AV_LOG_DEBUG, > "Truncating packet of size %d to %"PRId64"\n", size, remaining+1); > +av_log(NULL, remaining ? AV_LOG_WARNING : AV_LOG_DEBUG, > "Truncating packet of size %d to %"PRId64"\n", size, remaining+1); > size = remaining+1; > } > } > -- > 2.19.0 > > Ping? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 3/3] avcodec/rasc: unref both frames on reinit
On Tue, Oct 02, 2018 at 09:27:40AM +0200, Paul B Mahol wrote: > On 10/2/18, Michael Niedermayer wrote: > > Fixes: integer overflow > > Fixes: inconsistent frame dimensions > > Fixes: > > 10454/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-5656301162463232 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > LGTM applied thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/rasc: Fix off by 1 error in vertical coordinate
On Tue, Oct 02, 2018 at 09:52:31AM +0200, Paul B Mahol wrote: > On 10/2/18, Michael Niedermayer wrote: > > Fixes: out of array read > > Fixes: > > 10311/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RASC_fuzzer-4856330905452544 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > LGTM applied thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Take away the freedom of one citizen and you will be jailed, take away the freedom of all citizens and you will be congratulated by your peers in Parliament. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/tiff: check remaining packet size for strips
On Tue, Oct 02, 2018 at 09:53:16AM +0200, Paul B Mahol wrote: > On 10/2/18, Michael Niedermayer wrote: > > Fixes: Timeout > > Fixes: > > 10280/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5676217211027456 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/tiff.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > LGTM applied thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Democracy is the form of government in which you can choose your dictator signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavf/utils: change truncating packet log to a warning
On Sun, Sep 30, 2018 at 06:08:47AM +0100, Rostislav Pehlivanov wrote: > Some scene files do this intentionally for the sake of having a nice checksum. I think this is a bit terse and hard to understand what is meant exactly maybe you can expand this commit message a bit thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Does the universe only have a finite lifespan? No, its going to go on forever, its just that you wont like living in it. -- Hiranya Peiri signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avfilter/af_headphone: use lavfi internal queue instead
On 10/2/18, Paul B Mahol wrote: > On 10/2/18, Paul B Mahol wrote: >> Signed-off-by: Paul B Mahol >> --- >> libavfilter/af_headphone.c | 46 -- >> 1 file changed, 9 insertions(+), 37 deletions(-) >> > > Unfortunately this asserts for unexplained reason. > > Is there way with filters with multiple inputs to not hang when not > consuming > all frames from some inputs? > Found it! ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/4] avfilter: add ff_inlink_queued_samples()
Signed-off-by: Paul B Mahol --- libavfilter/avfilter.c | 5 + libavfilter/filters.h | 7 +++ 2 files changed, 12 insertions(+) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 85eff0aa1d..49046f4ede 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -1453,6 +1453,11 @@ int ff_inlink_check_available_frame(AVFilterLink *link) return ff_framequeue_queued_frames(&link->fifo) > 0; } +int ff_inlink_queued_samples(AVFilterLink *link) +{ +return ff_framequeue_queued_samples(&link->fifo); +} + int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min) { uint64_t samples = ff_framequeue_queued_samples(&link->fifo); diff --git a/libavfilter/filters.h b/libavfilter/filters.h index 4e2652ebe5..18a65e91fc 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -66,6 +66,13 @@ int ff_inlink_evaluate_timeline_at_frame(AVFilterLink *link, const AVFrame *fram */ int ff_inlink_check_available_frame(AVFilterLink *link); + +/*** + * Get the number of samples available on the link. + * @return the numer of samples available on the link. + */ +int ff_inlink_queued_samples(AVFilterLink *link); + /** * Test if enough samples are available on the link. * @return >0 if enough samples are available -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 4/4] avfilter/af_afir: use internal lavfi queue
Signed-off-by: Paul B Mahol --- libavfilter/af_afir.c | 46 --- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index bdca9033cf..a36f1881e3 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -25,7 +25,6 @@ #include -#include "libavutil/audio_fifo.h" #include "libavutil/common.h" #include "libavutil/float_dsp.h" #include "libavutil/intreadwrite.h" @@ -279,9 +278,9 @@ end: static int convert_coeffs(AVFilterContext *ctx) { AudioFIRContext *s = ctx->priv; -int i, ch, n, N; +int ret, i, ch, n, N; -s->nb_taps = av_audio_fifo_size(s->fifo); +s->nb_taps = ff_inlink_queued_samples(ctx->inputs[1]); if (s->nb_taps <= 0) return AVERROR(EINVAL); @@ -320,15 +319,15 @@ static int convert_coeffs(AVFilterContext *ctx) return AVERROR(ENOMEM); } -s->in[1] = ff_get_audio_buffer(ctx->inputs[1], s->nb_taps); -if (!s->in[1]) -return AVERROR(ENOMEM); - s->buffer = ff_get_audio_buffer(ctx->inputs[0], s->part_size * 3); if (!s->buffer) return AVERROR(ENOMEM); -av_audio_fifo_read(s->fifo, (void **)s->in[1]->extended_data, s->nb_taps); +ret = ff_inlink_consume_samples(ctx->inputs[1], s->nb_taps, s->nb_taps, &s->in[1]); +if (ret < 0) +return ret; +if (ret == 0) +return AVERROR_BUG; if (s->response) draw_response(ctx, s->video); @@ -394,19 +393,13 @@ static int convert_coeffs(AVFilterContext *ctx) return 0; } -static int read_ir(AVFilterLink *link, AVFrame *frame) +static int check_ir(AVFilterLink *link, AVFrame *frame) { AVFilterContext *ctx = link->dst; AudioFIRContext *s = ctx->priv; -int nb_taps, max_nb_taps, ret; +int nb_taps, max_nb_taps; -ret = av_audio_fifo_write(s->fifo, (void **)frame->extended_data, - frame->nb_samples); -av_frame_free(&frame); -if (ret < 0) -return ret; - -nb_taps = av_audio_fifo_size(s->fifo); +nb_taps = ff_inlink_queued_samples(link); max_nb_taps = s->max_ir_len * ctx->outputs[0]->sample_rate; if (nb_taps > max_nb_taps) { av_log(ctx, AV_LOG_ERROR, "Too big number of coefficients: %d > %d.\n", nb_taps, max_nb_taps); @@ -430,19 +423,12 @@ static int activate(AVFilterContext *ctx) if (!s->eof_coeffs) { AVFrame *ir = NULL; -if ((ret = ff_inlink_consume_frame(ctx->inputs[1], &ir)) > 0) { -ret = read_ir(ctx->inputs[1], ir); -if (ret < 0) -return ret; -} +ret = check_ir(ctx->inputs[1], ir); if (ret < 0) return ret; -if (ff_inlink_acknowledge_status(ctx->inputs[1], &status, &pts)) { -if (status == AVERROR_EOF) { -s->eof_coeffs = 1; -} -} +if (ff_outlink_get_status(ctx->inputs[1]) == AVERROR_EOF) +s->eof_coeffs = 1; if (!s->eof_coeffs) { if (ff_outlink_frame_wanted(ctx->outputs[0])) @@ -566,10 +552,6 @@ static int config_output(AVFilterLink *outlink) outlink->channel_layout = ctx->inputs[0]->channel_layout; outlink->channels = ctx->inputs[0]->channels; -s->fifo = av_audio_fifo_alloc(ctx->inputs[1]->format, ctx->inputs[1]->channels, 1024); -if (!s->fifo) -return AVERROR(ENOMEM); - s->sum = av_calloc(outlink->channels, sizeof(*s->sum)); s->coeff = av_calloc(ctx->inputs[1]->channels, sizeof(*s->coeff)); s->block = av_calloc(ctx->inputs[0]->channels, sizeof(*s->block)); @@ -630,8 +612,6 @@ static av_cold void uninit(AVFilterContext *ctx) av_frame_free(&s->in[1]); av_frame_free(&s->buffer); -av_audio_fifo_free(s->fifo); - av_freep(&s->fdsp); for (int i = 0; i < ctx->nb_outputs; i++) -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/4] avfilter/af_asetnsamples: use lavfi internal queue
Signed-off-by: Paul B Mahol --- libavfilter/af_asetnsamples.c | 156 +- 1 file changed, 42 insertions(+), 114 deletions(-) diff --git a/libavfilter/af_asetnsamples.c b/libavfilter/af_asetnsamples.c index ecb76e64db..6efa6f3f69 100644 --- a/libavfilter/af_asetnsamples.c +++ b/libavfilter/af_asetnsamples.c @@ -24,20 +24,18 @@ * Filter that changes number of samples on single output operation */ -#include "libavutil/audio_fifo.h" #include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavutil/opt.h" #include "avfilter.h" #include "audio.h" +#include "filters.h" #include "internal.h" #include "formats.h" typedef struct ASNSContext { const AVClass *class; int nb_out_samples; ///< how many samples to output -AVAudioFifo *fifo; ///< samples are queued here -int64_t next_out_pts; int pad; } ASNSContext; @@ -54,134 +52,65 @@ static const AVOption asetnsamples_options[] = { AVFILTER_DEFINE_CLASS(asetnsamples); -static av_cold int init(AVFilterContext *ctx) +static int activate(AVFilterContext *ctx) { -ASNSContext *asns = ctx->priv; - -asns->next_out_pts = AV_NOPTS_VALUE; -av_log(ctx, AV_LOG_VERBOSE, "nb_out_samples:%d pad:%d\n", asns->nb_out_samples, asns->pad); - -return 0; -} - -static av_cold void uninit(AVFilterContext *ctx) -{ -ASNSContext *asns = ctx->priv; -av_audio_fifo_free(asns->fifo); -} - -static int config_props_output(AVFilterLink *outlink) -{ -ASNSContext *asns = outlink->src->priv; - -asns->fifo = av_audio_fifo_alloc(outlink->format, outlink->channels, asns->nb_out_samples); -if (!asns->fifo) -return AVERROR(ENOMEM); - -return 0; -} - -static int push_samples(AVFilterLink *outlink) -{ -ASNSContext *asns = outlink->src->priv; -AVFrame *outsamples = NULL; -int ret, nb_out_samples, nb_pad_samples; - -if (asns->pad) { -nb_out_samples = av_audio_fifo_size(asns->fifo) ? asns->nb_out_samples : 0; -nb_pad_samples = nb_out_samples - FFMIN(nb_out_samples, av_audio_fifo_size(asns->fifo)); -} else { -nb_out_samples = FFMIN(asns->nb_out_samples, av_audio_fifo_size(asns->fifo)); -nb_pad_samples = 0; -} - -if (!nb_out_samples) -return 0; - -outsamples = ff_get_audio_buffer(outlink, nb_out_samples); -if (!outsamples) -return AVERROR(ENOMEM); - -av_audio_fifo_read(asns->fifo, - (void **)outsamples->extended_data, nb_out_samples); - -if (nb_pad_samples) -av_samples_set_silence(outsamples->extended_data, nb_out_samples - nb_pad_samples, - nb_pad_samples, outlink->channels, - outlink->format); -outsamples->nb_samples = nb_out_samples; -outsamples->channel_layout = outlink->channel_layout; -outsamples->sample_rate= outlink->sample_rate; -outsamples->pts = asns->next_out_pts; - -if (asns->next_out_pts != AV_NOPTS_VALUE) -asns->next_out_pts += av_rescale_q(nb_out_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base); - -ret = ff_filter_frame(outlink, outsamples); -if (ret < 0) -return ret; -return nb_out_samples; -} - -static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) -{ -AVFilterContext *ctx = inlink->dst; -ASNSContext *asns = ctx->priv; +AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; +ASNSContext *s = ctx->priv; +AVFrame *frame = NULL; int ret; -int nb_samples = insamples->nb_samples; - -if (av_audio_fifo_space(asns->fifo) < nb_samples) { -av_log(ctx, AV_LOG_DEBUG, "No space for %d samples, stretching audio fifo\n", nb_samples); -ret = av_audio_fifo_realloc(asns->fifo, av_audio_fifo_size(asns->fifo) + nb_samples); -if (ret < 0) { -av_log(ctx, AV_LOG_ERROR, - "Stretching audio fifo failed, discarded %d samples\n", nb_samples); -return -1; -} -} -ret = av_audio_fifo_write(asns->fifo, (void **)insamples->extended_data, nb_samples); -if (ret > 0 && asns->next_out_pts == AV_NOPTS_VALUE) -asns->next_out_pts = insamples->pts; -av_frame_free(&insamples); -if (ret < 0) -return ret; +FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); -while (av_audio_fifo_size(asns->fifo) >= asns->nb_out_samples) -push_samples(outlink); -return 0; -} +if (ff_inlink_queued_samples(inlink) >= s->nb_out_samples) { +ret = ff_inlink_consume_samples(inlink, s->nb_out_samples, s->nb_out_samples, &frame); +if (ret > 0) +ret = ff_filter_frame(outlink, frame); +return ret; +} -static int request_frame(AVFilterLink *outlink) -{ -AVFilterLink *inlink = outlink->src->inputs[0]; -int ret; +if (ff_outlink_get_status(inlink) == AVERROR_EOF) { +AVFrame *pad_frame; + +
[FFmpeg-devel] [PATCH 3/4] avfilter/af_headphone: use lavfi internal queue instead
Signed-off-by: Paul B Mahol --- libavfilter/af_headphone.c | 56 -- 1 file changed, 12 insertions(+), 44 deletions(-) diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c index 6b210e1436..760b97b733 100644 --- a/libavfilter/af_headphone.c +++ b/libavfilter/af_headphone.c @@ -20,7 +20,6 @@ #include -#include "libavutil/audio_fifo.h" #include "libavutil/avstring.h" #include "libavutil/channel_layout.h" #include "libavutil/float_dsp.h" @@ -79,7 +78,6 @@ typedef struct HeadphoneContext { AVFloatDSPContext *fdsp; struct headphone_inputs { -AVAudioFifo *fifo; AVFrame *frame; int ir_len; int delay_l; @@ -328,20 +326,13 @@ static int headphone_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr, return 0; } -static int read_ir(AVFilterLink *inlink, int input_number, AVFrame *frame) +static int check_ir(AVFilterLink *inlink, int input_number) { AVFilterContext *ctx = inlink->dst; HeadphoneContext *s = ctx->priv; -int ir_len, max_ir_len, ret; +int ir_len, max_ir_len; -ret = av_audio_fifo_write(s->in[input_number].fifo, (void **)frame->extended_data, - frame->nb_samples); -av_frame_free(&frame); - -if (ret < 0) -return ret; - -ir_len = av_audio_fifo_size(s->in[input_number].fifo); +ir_len = ff_inlink_queued_samples(inlink); max_ir_len = 65536; if (ir_len > max_ir_len) { av_log(ctx, AV_LOG_ERROR, "Too big length of IRs: %d > %d.\n", ir_len, max_ir_len); @@ -457,14 +448,6 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) goto fail; } -for (i = 0; i < s->nb_inputs - 1; i++) { -s->in[i + 1].frame = ff_get_audio_buffer(ctx->inputs[i + 1], s->ir_len); -if (!s->in[i + 1].frame) { -ret = AVERROR(ENOMEM); -goto fail; -} -} - if (s->type == TIME_DOMAIN) { s->temp_src[0] = av_calloc(FFALIGN(ir_len, 16), sizeof(float)); s->temp_src[1] = av_calloc(FFALIGN(ir_len, 16), sizeof(float)); @@ -490,7 +473,9 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) int delay_r = s->in[i + 1].delay_r; float *ptr; -av_audio_fifo_read(s->in[i + 1].fifo, (void **)s->in[i + 1].frame->extended_data, len); +ret = ff_inlink_consume_samples(ctx->inputs[i + 1], len, len, &s->in[i + 1].frame); +if (ret < 0) +return ret; ptr = (float *)s->in[i + 1].frame->extended_data[0]; if (s->hrir_fmt == HRIR_STEREO) { @@ -577,6 +562,8 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink) } } } + +av_frame_free(&s->in[i + 1].frame); } if (s->type == TIME_DOMAIN) { @@ -623,27 +610,15 @@ static int activate(AVFilterContext *ctx) FF_FILTER_FORWARD_STATUS_BACK_ALL(ctx->outputs[0], ctx); if (!s->eof_hrirs) { for (i = 1; i < s->nb_inputs; i++) { -AVFrame *ir = NULL; -int64_t pts; -int status; - if (s->in[i].eof) continue; -if ((ret = ff_inlink_consume_frame(ctx->inputs[i], &ir)) > 0) { -ret = read_ir(ctx->inputs[i], i, ir); -if (ret < 0) -return ret; -} -if (ret < 0) +if ((ret = check_ir(ctx->inputs[i], i)) < 0) return ret; if (!s->in[i].eof) { -if (ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts)) { -if (status == AVERROR_EOF) { -s->in[i].eof = 1; -} -} +if (ff_outlink_get_status(ctx->inputs[i]) == AVERROR_EOF) +s->in[i].eof = 1; } } @@ -659,6 +634,7 @@ static int activate(AVFilterContext *ctx) ff_inlink_request_frame(ctx->inputs[i]); } } + return 0; } else { s->eof_hrirs = 1; @@ -803,7 +779,6 @@ static int config_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; HeadphoneContext *s = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; -int i; if (s->hrir_fmt == HRIR_MULTI) { AVFilterLink *hrir_link = ctx->inputs[1]; @@ -814,11 +789,6 @@ static int config_output(AVFilterLink *outlink) } } -for (i = 0; i < s->nb_inputs; i++) { -s->in[i].fifo = av_audio_fifo_alloc(ctx->inputs[i]->format, ctx->inputs[i]->channels, 1024); -if (!s->in[i].fifo) -return AVERROR(ENOMEM); -} s->gain_lfe = expf((s->gain - 3 * inlink->channels - 6 + s->lfe_gain) / 20 * M_LN10); return 0; @@ -848,8 +818,6 @@ static av_cold void uninit(AVFilterContext *ctx) av_freep(&s->fdsp);
Re: [FFmpeg-devel] [PATCH] lavf/utils: change truncating packet log to a warning
On Wed, Oct 3, 2018 at 11:55 AM Michael Niedermayer wrote: > > On Sun, Sep 30, 2018 at 06:08:47AM +0100, Rostislav Pehlivanov wrote: > > Some scene files do this intentionally for the sake of having a nice > > checksum. > > I think this is a bit terse and hard to understand what is meant exactly > maybe you can expand this commit message a bit > Also, just because someone creates intentionally malformed files doesn't make them any less malformed. - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2] avcodec: add an AV1 parser
Hi, Apologies if you've covered any of these comments before. On 03/10/2018 02:44, James Almer wrote: > Simple parser to set keyframes, frame type, structure, width, height, and > pixel > format, plus stream profile and level. > > Signed-off-by: James Almer > --- > Missing Changelog entry and version bump still. [...] > +if (avctx->extradata_size && !s->parsed_extradata) { > +s->parsed_extradata = 1; Shouldn't this be set at the bottom of this block (since parsing can fail)? > +} > + > +avctx->profile = seq->seq_profile; > +avctx->level = seq->seq_level_idx[0]; > + > +switch (frame_type) { > +case AV1_FRAME_KEY: > +case AV1_FRAME_INTRA_ONLY: > +ctx->pict_type = AV_PICTURE_TYPE_I; > +break; Not strictly related to this patch, and not a blocker, but is it not about time the API gains the ability to mark frames with more clarity than just "I"? H.264, HEVC, etc. also have this issue (e.g. I vs IDR, and HEVC's many times of RAPs). AV_PICTURE_TYPE_SI is kinda related, I guess, but not exactly what I mean. > +case AV1_FRAME_INTER: > +ctx->pict_type = AV_PICTURE_TYPE_P; > +break; > +case AV1_FRAME_SWITCH: > +ctx->pict_type = AV_PICTURE_TYPE_SP; > +break; > +} I assume we're not going to mark alt-refs in any special way since they're combined in one packet with a visible frame? > +ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME; Any reason we just don't always set this at the top of the function? > +switch (av1->bit_depth) { > +case 8: > +ctx->format = color->mono_chrome ? AV_PIX_FMT_GRAY8 > + : pix_fmts_8bit > [color->subsampling_x][color->subsampling_y]; > +break; > +case 10: > +ctx->format = color->mono_chrome ? AV_PIX_FMT_GRAY10 > + : > pix_fmts_10bit[color->subsampling_x][color->subsampling_y]; > +break; > +case 12: > +ctx->format = color->mono_chrome ? AV_PIX_FMT_GRAY12 > + : > pix_fmts_12bit[color->subsampling_x][color->subsampling_y]; > +break; > +} Won't this break horribly on e.g. 4:4:0? > +av_assert2(ctx->format != AV_PIX_FMT_NONE); I assume ctx->bit_depth will always be set to something valid. - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2] avcodec: add an AV1 parser
On 03/10/2018 13:53, Derek Buitenhuis wrote: > Won't this break horribly on e.g. 4:4:0? Woops, there's no such thing in AV1. - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2] avcodec: add an AV1 parser
On 10/3/2018 9:53 AM, Derek Buitenhuis wrote: > Hi, > > Apologies if you've covered any of these comments before. > > On 03/10/2018 02:44, James Almer wrote: >> Simple parser to set keyframes, frame type, structure, width, height, and >> pixel >> format, plus stream profile and level. >> >> Signed-off-by: James Almer >> --- >> Missing Changelog entry and version bump still. > > [...] > >> +if (avctx->extradata_size && !s->parsed_extradata) { >> +s->parsed_extradata = 1; > > Shouldn't this be set at the bottom of this block (since parsing can fail)? If extradata parsing fails and we bail out without setting this first, no packet will ever be parsed since this runs first thing every time. A better API would allow us to check it during init(), like in the decoder and bitstream filter ones, but that's not the case here. > > >> +} >> + >> +avctx->profile = seq->seq_profile; >> +avctx->level = seq->seq_level_idx[0]; >> + >> +switch (frame_type) { >> +case AV1_FRAME_KEY: >> +case AV1_FRAME_INTRA_ONLY: >> +ctx->pict_type = AV_PICTURE_TYPE_I; >> +break; > > Not strictly related to this patch, and not a blocker, but is it not > about time the API gains the ability to mark frames with more clarity > than just "I"? H.264, HEVC, etc. also have this issue (e.g. I vs IDR, > and HEVC's many times of RAPs). AV_PICTURE_TYPE_SI is kinda related, > I guess, but not exactly what I mean. > >> +case AV1_FRAME_INTER: >> +ctx->pict_type = AV_PICTURE_TYPE_P; >> +break; >> +case AV1_FRAME_SWITCH: >> +ctx->pict_type = AV_PICTURE_TYPE_SP; >> +break; >> +} > > I assume we're not going to mark alt-refs in any special way since > they're combined in one packet with a visible frame? Exactly. They are handled in the following packets, when the visible frame is a show_existing_frame one pointing to them. > >> +ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME; > > Any reason we just don't always set this at the top of the function? Because the parsing can fail, and i figured it was nicer to keep it as the default AV_PICTURE_STRUCTURE_UNKNOWN in those cases. > >> +switch (av1->bit_depth) { >> +case 8: >> +ctx->format = color->mono_chrome ? AV_PIX_FMT_GRAY8 >> + : pix_fmts_8bit >> [color->subsampling_x][color->subsampling_y]; >> +break; >> +case 10: >> +ctx->format = color->mono_chrome ? AV_PIX_FMT_GRAY10 >> + : >> pix_fmts_10bit[color->subsampling_x][color->subsampling_y]; >> +break; >> +case 12: >> +ctx->format = color->mono_chrome ? AV_PIX_FMT_GRAY12 >> + : >> pix_fmts_12bit[color->subsampling_x][color->subsampling_y]; >> +break; >> +} > > Won't this break horribly on e.g. 4:4:0? Fortunately, AV1 got rid of 4:4:0 :p > >> +av_assert2(ctx->format != AV_PIX_FMT_NONE); > > I assume ctx->bit_depth will always be set to something valid. If you look at how i set ctx->format, it depends on the values of color->subsampling_x and color->subsampling_y. If for whatever reason cbs_av1 wrongly sets the former as 0 and the latter as 1 (which is invalid), the lookup table will return AV_PIX_FMT_NONE. This assert is to make sure that doesn't happen, as it'd be an internal bug. I can remove it if you prefer, but by being av_assert2 it will not run outside of builds purposely enabling level 2 asserts. > > - Derek > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2] avcodec: add an AV1 parser
On 03/10/2018 14:26, James Almer wrote: >> Shouldn't this be set at the bottom of this block (since parsing can fail)? > > If extradata parsing fails and we bail out without setting this first, > no packet will ever be parsed since this runs first thing every time. > > A better API would allow us to check it during init(), like in the > decoder and bitstream filter ones, but that's not the case here. OK, yeah, that's a bit meh, but I see the point. >> Not strictly related to this patch, and not a blocker, but is it not >> about time the API gains the ability to mark frames with more clarity >> than just "I"? H.264, HEVC, etc. also have this issue (e.g. I vs IDR, >> and HEVC's many times of RAPs). AV_PICTURE_TYPE_SI is kinda related, >> I guess, but not exactly what I mean. [...] >> I assume we're not going to mark alt-refs in any special way since >> they're combined in one packet with a visible frame? > > Exactly. They are handled in the following packets, when the visible > frame is a show_existing_frame one pointing to them. [...] >>> +ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME; >> >> Any reason we just don't always set this at the top of the function? > > Because the parsing can fail, and i figured it was nicer to keep it as > the default AV_PICTURE_STRUCTURE_UNKNOWN in those cases. Fair enough. >>> +av_assert2(ctx->format != AV_PIX_FMT_NONE); >> >> I assume ctx->bit_depth will always be set to something valid. > > If you look at how i set ctx->format, it depends on the values of > color->subsampling_x and color->subsampling_y. If for whatever reason > cbs_av1 wrongly sets the former as 0 and the latter as 1 (which is > invalid), the lookup table will return AV_PIX_FMT_NONE. This assert is > to make sure that doesn't happen, as it'd be an internal bug. > > I can remove it if you prefer, but by being av_assert2 it will not run > outside of builds purposely enabling level 2 asserts. I have no strong opinon. As an aside, where does HDR metadata fit into all of this? - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2] avcodec: add an AV1 parser
On 10/3/2018 10:38 AM, Derek Buitenhuis wrote: > On 03/10/2018 14:26, James Almer wrote: >>> Shouldn't this be set at the bottom of this block (since parsing can fail)? >> >> If extradata parsing fails and we bail out without setting this first, >> no packet will ever be parsed since this runs first thing every time. >> >> A better API would allow us to check it during init(), like in the >> decoder and bitstream filter ones, but that's not the case here. > > OK, yeah, that's a bit meh, but I see the point. > >>> Not strictly related to this patch, and not a blocker, but is it not >>> about time the API gains the ability to mark frames with more clarity >>> than just "I"? H.264, HEVC, etc. also have this issue (e.g. I vs IDR, >>> and HEVC's many times of RAPs). AV_PICTURE_TYPE_SI is kinda related, >>> I guess, but not exactly what I mean. > > [...] > >>> I assume we're not going to mark alt-refs in any special way since >>> they're combined in one packet with a visible frame? >> >> Exactly. They are handled in the following packets, when the visible >> frame is a show_existing_frame one pointing to them. > > [...] > +ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME; >>> >>> Any reason we just don't always set this at the top of the function? >> >> Because the parsing can fail, and i figured it was nicer to keep it as >> the default AV_PICTURE_STRUCTURE_UNKNOWN in those cases. > > Fair enough. +av_assert2(ctx->format != AV_PIX_FMT_NONE); >>> >>> I assume ctx->bit_depth will always be set to something valid. >> >> If you look at how i set ctx->format, it depends on the values of >> color->subsampling_x and color->subsampling_y. If for whatever reason >> cbs_av1 wrongly sets the former as 0 and the latter as 1 (which is >> invalid), the lookup table will return AV_PIX_FMT_NONE. This assert is >> to make sure that doesn't happen, as it'd be an internal bug. >> >> I can remove it if you prefer, but by being av_assert2 it will not run >> outside of builds purposely enabling level 2 asserts. > > I have no strong opinon. > > As an aside, where does HDR metadata fit into all of this? That's in Metadata OBUs and/or in container defined structures. It's meant to be propagated internally as stream/packet/frame side data, which the parser API can't handle. The demuxer and/or the decoder are the ones that need to handle that. > > - Derek > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2] avcodec: add an AV1 parser
On 03/10/2018 14:43, James Almer wrote: > That's in Metadata OBUs and/or in container defined structures. It's > meant to be propagated internally as stream/packet/frame side data, > which the parser API can't handle. > > The demuxer and/or the decoder are the ones that need to handle that. OK. - Derek ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/4] avfilter/af_asetnsamples: use lavfi internal queue
Paul B Mahol (2018-10-03): > Signed-off-by: Paul B Mahol > --- > libavfilter/af_asetnsamples.c | 156 +- > 1 file changed, 42 insertions(+), 114 deletions(-) > > diff --git a/libavfilter/af_asetnsamples.c b/libavfilter/af_asetnsamples.c > index ecb76e64db..6efa6f3f69 100644 > --- a/libavfilter/af_asetnsamples.c > +++ b/libavfilter/af_asetnsamples.c > @@ -24,20 +24,18 @@ > * Filter that changes number of samples on single output operation > */ > > -#include "libavutil/audio_fifo.h" > #include "libavutil/avassert.h" > #include "libavutil/channel_layout.h" > #include "libavutil/opt.h" > #include "avfilter.h" > #include "audio.h" > +#include "filters.h" > #include "internal.h" > #include "formats.h" > > typedef struct ASNSContext { > const AVClass *class; > int nb_out_samples; ///< how many samples to output > -AVAudioFifo *fifo; ///< samples are queued here > -int64_t next_out_pts; > int pad; > } ASNSContext; > > @@ -54,134 +52,65 @@ static const AVOption asetnsamples_options[] = { > > AVFILTER_DEFINE_CLASS(asetnsamples); > > -static av_cold int init(AVFilterContext *ctx) > +static int activate(AVFilterContext *ctx) > { > -ASNSContext *asns = ctx->priv; > - > -asns->next_out_pts = AV_NOPTS_VALUE; > -av_log(ctx, AV_LOG_VERBOSE, "nb_out_samples:%d pad:%d\n", > asns->nb_out_samples, asns->pad); > - > -return 0; > -} > - > -static av_cold void uninit(AVFilterContext *ctx) > -{ > -ASNSContext *asns = ctx->priv; > -av_audio_fifo_free(asns->fifo); > -} > - > -static int config_props_output(AVFilterLink *outlink) > -{ > -ASNSContext *asns = outlink->src->priv; > - > -asns->fifo = av_audio_fifo_alloc(outlink->format, outlink->channels, > asns->nb_out_samples); > -if (!asns->fifo) > -return AVERROR(ENOMEM); > - > -return 0; > -} > - > -static int push_samples(AVFilterLink *outlink) > -{ > -ASNSContext *asns = outlink->src->priv; > -AVFrame *outsamples = NULL; > -int ret, nb_out_samples, nb_pad_samples; > - > -if (asns->pad) { > -nb_out_samples = av_audio_fifo_size(asns->fifo) ? > asns->nb_out_samples : 0; > -nb_pad_samples = nb_out_samples - FFMIN(nb_out_samples, > av_audio_fifo_size(asns->fifo)); > -} else { > -nb_out_samples = FFMIN(asns->nb_out_samples, > av_audio_fifo_size(asns->fifo)); > -nb_pad_samples = 0; > -} > - > -if (!nb_out_samples) > -return 0; > - > -outsamples = ff_get_audio_buffer(outlink, nb_out_samples); > -if (!outsamples) > -return AVERROR(ENOMEM); > - > -av_audio_fifo_read(asns->fifo, > - (void **)outsamples->extended_data, nb_out_samples); > - > -if (nb_pad_samples) > -av_samples_set_silence(outsamples->extended_data, nb_out_samples - > nb_pad_samples, > - nb_pad_samples, outlink->channels, > - outlink->format); > -outsamples->nb_samples = nb_out_samples; > -outsamples->channel_layout = outlink->channel_layout; > -outsamples->sample_rate= outlink->sample_rate; > -outsamples->pts = asns->next_out_pts; > - > -if (asns->next_out_pts != AV_NOPTS_VALUE) > -asns->next_out_pts += av_rescale_q(nb_out_samples, (AVRational){1, > outlink->sample_rate}, outlink->time_base); > - > -ret = ff_filter_frame(outlink, outsamples); > -if (ret < 0) > -return ret; > -return nb_out_samples; > -} > - > -static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) > -{ > -AVFilterContext *ctx = inlink->dst; > -ASNSContext *asns = ctx->priv; > +AVFilterLink *inlink = ctx->inputs[0]; > AVFilterLink *outlink = ctx->outputs[0]; > +ASNSContext *s = ctx->priv; > +AVFrame *frame = NULL; > int ret; > -int nb_samples = insamples->nb_samples; > - > -if (av_audio_fifo_space(asns->fifo) < nb_samples) { > -av_log(ctx, AV_LOG_DEBUG, "No space for %d samples, stretching audio > fifo\n", nb_samples); > -ret = av_audio_fifo_realloc(asns->fifo, > av_audio_fifo_size(asns->fifo) + nb_samples); > -if (ret < 0) { > -av_log(ctx, AV_LOG_ERROR, > - "Stretching audio fifo failed, discarded %d samples\n", > nb_samples); > -return -1; > -} > -} > -ret = av_audio_fifo_write(asns->fifo, (void **)insamples->extended_data, > nb_samples); > -if (ret > 0 && asns->next_out_pts == AV_NOPTS_VALUE) > -asns->next_out_pts = insamples->pts; > -av_frame_free(&insamples); > > -if (ret < 0) > -return ret; > +FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); > > -while (av_audio_fifo_size(asns->fifo) >= asns->nb_out_samples) > -push_samples(outlink); > -return 0; > -} > +if (ff_inlink_queued_samples(inlink) >= s->nb_out_samples) { This test is not needed, just check the return value of ff_inlink_consume_samples(
Re: [FFmpeg-devel] [PATCH 1/4] avfilter: add ff_inlink_queued_samples()
Paul B Mahol (2018-10-03): > Signed-off-by: Paul B Mahol > --- > libavfilter/avfilter.c | 5 + > libavfilter/filters.h | 7 +++ > 2 files changed, 12 insertions(+) LGTM. Please coordinate with Marton so that this function and the ones he is about to add are in a logical order. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavfi/atempo: fix range check if tempo is set by command
From: wang-bin --- libavfilter/af_atempo.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c index 52f15f2769..1a004212a7 100644 --- a/libavfilter/af_atempo.c +++ b/libavfilter/af_atempo.c @@ -331,9 +331,10 @@ static int yae_set_tempo(AVFilterContext *ctx, const char *arg_tempo) return AVERROR(EINVAL); } -if (tempo < 0.5 || tempo > 2.0) { -av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [0.5, 2.0] range\n", - tempo); +const AVOption *o = av_opt_find(&atempo->class, "tempo", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ); +if (tempo < o->min || tempo > o->max) { +av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [%.1f, %.1f] range\n", + tempo, o->min, o->max); return AVERROR(EINVAL); } @@ -439,8 +440,8 @@ static int yae_load_data(ATempoContext *atempo, return 0; } -// samples are not expected to be skipped, unless tempo is greater than 2: -av_assert0(read_size <= atempo->ring || atempo->tempo > 2.0); +// samples are not expected to be skipped: +av_assert0(read_size <= atempo->ring); while (atempo->position[0] < stop_here && src < src_end) { int src_samples = (src_end - src) / atempo->stride; -- 2.17.1 (Apple Git-112) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi/atempo: fix range check if tempo is set by command
wbse...@gmail.com (2018-10-03): > From: wang-bin > > --- > libavfilter/af_atempo.c | 11 ++- > 1 file changed, 6 insertions(+), 5 deletions(-) > > diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c > index 52f15f2769..1a004212a7 100644 > --- a/libavfilter/af_atempo.c > +++ b/libavfilter/af_atempo.c > @@ -331,9 +331,10 @@ static int yae_set_tempo(AVFilterContext *ctx, const > char *arg_tempo) > return AVERROR(EINVAL); > } > > -if (tempo < 0.5 || tempo > 2.0) { > -av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [0.5, 2.0] > range\n", > - tempo); > +const AVOption *o = av_opt_find(&atempo->class, "tempo", NULL, 0, > AV_OPT_SEARCH_FAKE_OBJ); > +if (tempo < o->min || tempo > o->max) { The option is defined in the very same file and the min and max values are hardcoded there. There is no need for a fragile lookup. > +av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [%.1f, %.1f] > range\n", > + tempo, o->min, o->max); > return AVERROR(EINVAL); > } > > @@ -439,8 +440,8 @@ static int yae_load_data(ATempoContext *atempo, > return 0; > } > > -// samples are not expected to be skipped, unless tempo is greater than > 2: > -av_assert0(read_size <= atempo->ring || atempo->tempo > 2.0); > +// samples are not expected to be skipped: > +av_assert0(read_size <= atempo->ring); Looks unrelated. Can you explain? > > while (atempo->position[0] < stop_here && src < src_end) { > int src_samples = (src_end - src) / atempo->stride; Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] libavdevice: allow cropping avfoundation screen capture
> I've developed a patch to add an option to allow cropping of the > avfoundation screen capture. > Note that if the captured width is not a multiple of 16 then > https://trac.ffmpeg.org/ticket/5654 will be triggered. Is there anything more I need to do to get this patch applied? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi/atempo: fix range check if tempo is set by command
Nicolas George 于2018年10月3日周三 下午11:05写道: > wbse...@gmail.com (2018-10-03): > > From: wang-bin > > > > --- > > libavfilter/af_atempo.c | 11 ++- > > 1 file changed, 6 insertions(+), 5 deletions(-) > > > > diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c > > index 52f15f2769..1a004212a7 100644 > > --- a/libavfilter/af_atempo.c > > +++ b/libavfilter/af_atempo.c > > @@ -331,9 +331,10 @@ static int yae_set_tempo(AVFilterContext *ctx, > const char *arg_tempo) > > return AVERROR(EINVAL); > > } > > > > -if (tempo < 0.5 || tempo > 2.0) { > > -av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [0.5, 2.0] > range\n", > > - tempo); > > > +const AVOption *o = av_opt_find(&atempo->class, "tempo", NULL, 0, > AV_OPT_SEARCH_FAKE_OBJ); > > +if (tempo < o->min || tempo > o->max) { > > The option is defined in the very same file and the min and max values > are hardcoded there. There is no need for a fragile lookup. > > Less mistakes. For example the author forgot to change this line. This function is not frequently called. > > +av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [%.1f, %.1f] > range\n", > > + tempo, o->min, o->max); > > return AVERROR(EINVAL); > > } > > > > @@ -439,8 +440,8 @@ static int yae_load_data(ATempoContext *atempo, > > return 0; > > } > > > > > -// samples are not expected to be skipped, unless tempo is greater > than 2: > > -av_assert0(read_size <= atempo->ring || atempo->tempo > 2.0); > > +// samples are not expected to be skipped: > > +av_assert0(read_size <= atempo->ring); > > Looks unrelated. Can you explain? > av_opt_set or avfilter_process_command already returns error if out of range. So no need to check it again. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi/atempo: fix range check if tempo is set by command
Wang Bin (2018-10-03): > Less mistakes. For example the author forgot to change this line. This > function is not frequently called. The consistency must be ensured, but it must be static, not dynamic by looking up the option. Just use two constant macros. > av_opt_set or avfilter_process_command already returns error if out of > range. So no need to check it again. And you are changing the bound. It should be checked with Pavel, but I think this change is wrong. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/4] avfilter/af_asetnsamples: use lavfi internal queue
Signed-off-by: Paul B Mahol --- libavfilter/af_asetnsamples.c | 146 -- 1 file changed, 32 insertions(+), 114 deletions(-) diff --git a/libavfilter/af_asetnsamples.c b/libavfilter/af_asetnsamples.c index ecb76e64db..30fabede26 100644 --- a/libavfilter/af_asetnsamples.c +++ b/libavfilter/af_asetnsamples.c @@ -24,20 +24,18 @@ * Filter that changes number of samples on single output operation */ -#include "libavutil/audio_fifo.h" #include "libavutil/avassert.h" #include "libavutil/channel_layout.h" #include "libavutil/opt.h" #include "avfilter.h" #include "audio.h" +#include "filters.h" #include "internal.h" #include "formats.h" typedef struct ASNSContext { const AVClass *class; int nb_out_samples; ///< how many samples to output -AVAudioFifo *fifo; ///< samples are queued here -int64_t next_out_pts; int pad; } ASNSContext; @@ -54,134 +52,55 @@ static const AVOption asetnsamples_options[] = { AVFILTER_DEFINE_CLASS(asetnsamples); -static av_cold int init(AVFilterContext *ctx) +static int activate(AVFilterContext *ctx) { -ASNSContext *asns = ctx->priv; - -asns->next_out_pts = AV_NOPTS_VALUE; -av_log(ctx, AV_LOG_VERBOSE, "nb_out_samples:%d pad:%d\n", asns->nb_out_samples, asns->pad); - -return 0; -} - -static av_cold void uninit(AVFilterContext *ctx) -{ -ASNSContext *asns = ctx->priv; -av_audio_fifo_free(asns->fifo); -} - -static int config_props_output(AVFilterLink *outlink) -{ -ASNSContext *asns = outlink->src->priv; - -asns->fifo = av_audio_fifo_alloc(outlink->format, outlink->channels, asns->nb_out_samples); -if (!asns->fifo) -return AVERROR(ENOMEM); - -return 0; -} - -static int push_samples(AVFilterLink *outlink) -{ -ASNSContext *asns = outlink->src->priv; -AVFrame *outsamples = NULL; -int ret, nb_out_samples, nb_pad_samples; - -if (asns->pad) { -nb_out_samples = av_audio_fifo_size(asns->fifo) ? asns->nb_out_samples : 0; -nb_pad_samples = nb_out_samples - FFMIN(nb_out_samples, av_audio_fifo_size(asns->fifo)); -} else { -nb_out_samples = FFMIN(asns->nb_out_samples, av_audio_fifo_size(asns->fifo)); -nb_pad_samples = 0; -} - -if (!nb_out_samples) -return 0; - -outsamples = ff_get_audio_buffer(outlink, nb_out_samples); -if (!outsamples) -return AVERROR(ENOMEM); - -av_audio_fifo_read(asns->fifo, - (void **)outsamples->extended_data, nb_out_samples); - -if (nb_pad_samples) -av_samples_set_silence(outsamples->extended_data, nb_out_samples - nb_pad_samples, - nb_pad_samples, outlink->channels, - outlink->format); -outsamples->nb_samples = nb_out_samples; -outsamples->channel_layout = outlink->channel_layout; -outsamples->sample_rate= outlink->sample_rate; -outsamples->pts = asns->next_out_pts; - -if (asns->next_out_pts != AV_NOPTS_VALUE) -asns->next_out_pts += av_rescale_q(nb_out_samples, (AVRational){1, outlink->sample_rate}, outlink->time_base); - -ret = ff_filter_frame(outlink, outsamples); -if (ret < 0) -return ret; -return nb_out_samples; -} - -static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) -{ -AVFilterContext *ctx = inlink->dst; -ASNSContext *asns = ctx->priv; +AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; +ASNSContext *s = ctx->priv; +AVFrame *frame = NULL, *pad_frame; int ret; -int nb_samples = insamples->nb_samples; - -if (av_audio_fifo_space(asns->fifo) < nb_samples) { -av_log(ctx, AV_LOG_DEBUG, "No space for %d samples, stretching audio fifo\n", nb_samples); -ret = av_audio_fifo_realloc(asns->fifo, av_audio_fifo_size(asns->fifo) + nb_samples); -if (ret < 0) { -av_log(ctx, AV_LOG_ERROR, - "Stretching audio fifo failed, discarded %d samples\n", nb_samples); -return -1; -} -} -ret = av_audio_fifo_write(asns->fifo, (void **)insamples->extended_data, nb_samples); -if (ret > 0 && asns->next_out_pts == AV_NOPTS_VALUE) -asns->next_out_pts = insamples->pts; -av_frame_free(&insamples); +FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); + +ret = ff_inlink_consume_samples(inlink, s->nb_out_samples, s->nb_out_samples, &frame); if (ret < 0) return ret; -while (av_audio_fifo_size(asns->fifo) >= asns->nb_out_samples) -push_samples(outlink); -return 0; -} - -static int request_frame(AVFilterLink *outlink) -{ -AVFilterLink *inlink = outlink->src->inputs[0]; -int ret; - -ret = ff_request_frame(inlink); -if (ret == AVERROR_EOF) { -ret = push_samples(outlink); -return ret < 0 ? ret : ret > 0 ? 0 : AVERROR_EOF; +if (ret > 0) { +if ((!s->pad || (s->pad && frame->nb_samples == s->nb
Re: [FFmpeg-devel] [PATCHv2 1/2] avfilter/filters: add ff_inlink_peek_frame and ff_inlink_queued_frames to access frames in the inlink fifo
On 10/1/18, Marton Balint wrote: > Signed-off-by: Marton Balint > --- > libavfilter/avfilter.c | 10 ++ > libavfilter/filters.h | 13 + > 2 files changed, 23 insertions(+) > Probably ok. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCHv2 1/2] avfilter/filters: add ff_inlink_peek_frame and ff_inlink_queued_frames to access frames in the inlink fifo
Marton Balint (2018-10-01): > Signed-off-by: Marton Balint > --- > libavfilter/avfilter.c | 10 ++ > libavfilter/filters.h | 13 + > 2 files changed, 23 insertions(+) LGTM, thanks. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec/vp9_parser: export profile and pixel format
Signed-off-by: James Almer --- libavcodec/vp9_parser.c | 82 - 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c index 9531f34a32..d4110f20bf 100644 --- a/libavcodec/vp9_parser.c +++ b/libavcodec/vp9_parser.c @@ -23,36 +23,114 @@ #include "libavutil/intreadwrite.h" #include "libavcodec/get_bits.h" +#include "libavcodec/internal.h" #include "parser.h" +#define VP9_SYNCCODE 0x498342 + +static int read_colorspace_details(AVCodecParserContext *ctx, AVCodecContext *avctx, + GetBitContext *gb) +{ +static const enum AVColorSpace colorspaces[8] = { +AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_BT470BG, AVCOL_SPC_BT709, AVCOL_SPC_SMPTE170M, +AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED, AVCOL_SPC_RGB, +}; +int colorspace, bits = avctx->profile <= 1 ? 0 : 1 + get_bits1(gb); // 0:8, 1:10, 2:12 + +colorspace = colorspaces[get_bits(gb, 3)]; +if (colorspace == AVCOL_SPC_RGB) { // RGB = profile 1 +static const enum AVPixelFormat pix_fmt_rgb[3] = { +AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12 +}; +if (avctx->profile & 1) { +if (get_bits1(gb)) // reserved bit +return AVERROR_INVALIDDATA; +} else +return AVERROR_INVALIDDATA; +ctx->format = pix_fmt_rgb[bits]; +} else { +static const enum AVPixelFormat pix_fmt_for_ss[3][2 /* v */][2 /* h */] = { +{ { AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV422P }, + { AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV420P } }, +{ { AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV422P10 }, + { AV_PIX_FMT_YUV440P10, AV_PIX_FMT_YUV420P10 } }, +{ { AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV422P12 }, + { AV_PIX_FMT_YUV440P12, AV_PIX_FMT_YUV420P12 } } +}; +if (avctx->profile & 1) { +int ss_h, ss_v, format; + +ss_h = get_bits1(gb); +ss_v = get_bits1(gb); +format = pix_fmt_for_ss[bits][ss_v][ss_h]; +if (format == AV_PIX_FMT_YUV420P) +// YUV 4:2:0 not supported in profiles 1 and 3 +return AVERROR_INVALIDDATA; +else if (get_bits1(gb)) // color details reserved bit +return AVERROR_INVALIDDATA; +ctx->format = format; +} else { +ctx->format = pix_fmt_for_ss[bits][1][1]; +} +} + +return 0; +} + static int parse(AVCodecParserContext *ctx, AVCodecContext *avctx, const uint8_t **out_data, int *out_size, const uint8_t *data, int size) { GetBitContext gb; -int res, profile, keyframe; +int res, profile, keyframe, invisible, errorres; *out_data = data; *out_size = size; -if ((res = init_get_bits8(&gb, data, size)) < 0) +if (!size || (res = init_get_bits8(&gb, data, size)) < 0) return size; // parsers can't return errors get_bits(&gb, 2); // frame marker profile = get_bits1(&gb); profile |= get_bits1(&gb) << 1; if (profile == 3) profile += get_bits1(&gb); +if (profile > 3) +return size; +avctx->profile = profile; if (get_bits1(&gb)) { keyframe = 0; +skip_bits(&gb, 3); } else { keyframe = !get_bits1(&gb); } +invisible = !get_bits1(&gb); +errorres = get_bits1(&gb); + if (!keyframe) { +int intraonly = invisible ? get_bits1(&gb) : 0; +if (!errorres) +skip_bits(&gb, 2); +if (intraonly) { +if (get_bits_long(&gb, 24) != VP9_SYNCCODE) // synccode +return size; +if (profile >= 1) { +if ((read_colorspace_details(ctx, avctx, &gb)) < 0) +return size; +} else { +ctx->format = AV_PIX_FMT_YUV420P; +} +} + ctx->pict_type = AV_PICTURE_TYPE_P; ctx->key_frame = 0; } else { +if (get_bits_long(&gb, 24) != VP9_SYNCCODE) // synccode +return size; +if (read_colorspace_details(ctx, avctx, &gb) < 0) +return size; + ctx->pict_type = AV_PICTURE_TYPE_I; ctx->key_frame = 1; } -- 2.19.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCHv2 1/7] avformat/ip: factorize some IP filtering and resolving functions to a new file
On Sun, 30 Sep 2018, Marton Balint wrote: On Mon, 24 Sep 2018, Michael Niedermayer wrote: On Mon, Sep 24, 2018 at 08:49:27AM +0200, Marton Balint wrote: These are based on the very similar UDP and RTP protocol functions. Signed-off-by: Marton Balint --- libavformat/ip.c | 159 +++ libavformat/ip.h | 72 + 2 files changed, 231 insertions(+) create mode 100644 libavformat/ip.c create mode 100644 libavformat/ip.h [...] + * Parses the address[,address] source block list in buf and adds it to the + * filters in the IPSourceFilters structure. + * @return 0 on success, < 0 AVERROR code on error. + */ +int ff_ip_parse_blocks(void *log_ctx, const char *buf, IPSourceFilters *filters); Thanks Ping for the whole series... Pushed the patchset. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCHv2 1/2] avfilter/filters: add ff_inlink_peek_frame and ff_inlink_queued_frames to access frames in the inlink fifo
On Wed, 3 Oct 2018, Nicolas George wrote: Marton Balint (2018-10-01): Signed-off-by: Marton Balint --- libavfilter/avfilter.c | 10 ++ libavfilter/filters.h | 13 + 2 files changed, 23 insertions(+) LGTM, thanks. Thanks, pushed the series. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/xwma: fix WMAv2 with incorrect bit rate
From: bnnm Fixes trac issue #7215 Output for files created by xWMAEncode and various videogames is correct now. 1ch 32000hz files are still broken, would need fixes in WMA decoder. Signed-off-by: bnnm --- libavformat/xwma.c | 38 +++--- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/libavformat/xwma.c b/libavformat/xwma.c index 1c18772928..f357c3e881 100644 --- a/libavformat/xwma.c +++ b/libavformat/xwma.c @@ -80,19 +80,43 @@ static int xwma_read_header(AVFormatContext *s) return ret; st->need_parsing = AVSTREAM_PARSE_NONE; -/* All xWMA files I have seen contained WMAv2 data. If there are files - * using WMA Pro or some other codec, then we need to figure out the right - * extradata for that. Thus, ask the user for feedback, but try to go on - * anyway. - */ +/* XWMA encoder only allows a few channel/sample rate/bitrate combinations, + * but some create identical files with fake bitrate (1ch 22050hz at + * 20/48/192kbps are all 20kbps, with the exact same codec data). + * Decoder needs correct bitrate to work, so it's normalized here. */ +if (st->codecpar->codec_id == AV_CODEC_ID_WMAV2) { +int ch = st->codecpar->channels; +int sr = st->codecpar->sample_rate; +int br = st->codecpar->bit_rate; + +if (ch == 1) { +if (sr == 22050 && (br==48000 || br==192000)) +br = 2; +else if (sr == 32000 && (br==48000 || br==192000)) +br = 2; +else if (sr == 44100 && (br==96000 || br==192000)) +br = 48000; +} +else if (ch == 2) { +if (sr == 22050 && (br==48000 || br==192000)) +br = 32000; +else if (sr == 32000 && (br==192000)) +br = 48000; +} + +st->codecpar->bit_rate = br; +} + +/* Normally xWMA can only contain WMAv2 with 1/2 channels, + * and WMAPRO with 6 channels. */ if (st->codecpar->codec_id != AV_CODEC_ID_WMAV2 && st->codecpar->codec_id != AV_CODEC_ID_WMAPRO) { avpriv_request_sample(s, "Unexpected codec (tag %s; id %d)", av_fourcc2str(st->codecpar->codec_tag), st->codecpar->codec_id); } else { -/* In all xWMA files I have seen, there is no extradata. But the WMA - * codecs require extradata, so we provide our own fake extradata. +/* xWMA shouldn't have extradata. But the WMA codecs require it, + * so we provide our own fake extradata. * * First, check that there really was no extradata in the header. If * there was, then try to use it, after asking the user to provide a -- 2.11.0.windows.3 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2] avcodec: libdav1d AV1 decoder wrapper.
On Mon, 1 Oct 2018 at 01:08, James Almer wrote: > From: Ronald S. Bultje > > Originally written by Ronald S. Bultje, with fixes, optimizations and > improvements by James Almer. > > Signed-off-by: James Almer > --- > Updated with some refactoring and to use a few new public facing fields > recently introduced. > > The API is unstable and in constant development, and it's not going to be > frozen until a release is made, so I'm not sure if it's a good idea to push > this before ffmpeg 4.1 is tagged. > > configure | 4 + > libavcodec/Makefile| 1 + > libavcodec/allcodecs.c | 1 + > libavcodec/libdav1d.c | 273 + > 4 files changed, 279 insertions(+) > create mode 100644 libavcodec/libdav1d.c > > diff --git a/configure b/configure > index fdca47cf2c..8cd8fbd353 100755 > --- a/configure > +++ b/configure > @@ -226,6 +226,7 @@ External library support: >--enable-libcelt enable CELT decoding via libcelt [no] >--enable-libcdio enable audio CD grabbing with libcdio [no] >--enable-libcodec2 enable codec2 en/decoding using libcodec2 [no] > + --enable-libdav1denable AV1 decoding via libdav1d [no] >--enable-libdavs2enable AVS2 decoding via libdavs2 [no] >--enable-libdc1394 enable IIDC-1394 grabbing using libdc1394 > and libraw1394 [no] > @@ -1712,6 +1713,7 @@ EXTERNAL_LIBRARY_LIST=" > libcaca > libcelt > libcodec2 > +libdav1d > libdc1394 > libdrm > libflite > @@ -3087,6 +3089,7 @@ libaom_av1_encoder_select="extract_extradata_bsf" > libcelt_decoder_deps="libcelt" > libcodec2_decoder_deps="libcodec2" > libcodec2_encoder_deps="libcodec2" > +libdav1d_decoder_deps="libdav1d" > libdavs2_decoder_deps="libdavs2" > libfdk_aac_decoder_deps="libfdk_aac" > libfdk_aac_encoder_deps="libfdk_aac" > @@ -6062,6 +6065,7 @@ enabled libcelt && require libcelt > celt/celt.h celt_decode -lcelt0 && > die "ERROR: libcelt must be installed and > version must be >= 0.11.0."; } > enabled libcaca && require_pkg_config libcaca caca caca.h > caca_create_canvas > enabled libcodec2 && require libcodec2 codec2/codec2.h > codec2_create -lcodec2 > +enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.0.1" > "dav1d/dav1d.h" dav1d_version > enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= > 1.5.115" davs2.h davs2_decoder_open > enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 > dc1394/dc1394.h dc1394_new > enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h > drmGetVersion > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index b9cc20b5ef..6cfbfbcff6 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -954,6 +954,7 @@ OBJS-$(CONFIG_LIBAOM_AV1_ENCODER) += > libaomenc.o > OBJS-$(CONFIG_LIBCELT_DECODER)+= libcelt_dec.o > OBJS-$(CONFIG_LIBCODEC2_DECODER) += libcodec2.o codec2utils.o > OBJS-$(CONFIG_LIBCODEC2_ENCODER) += libcodec2.o codec2utils.o > +OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o > OBJS-$(CONFIG_LIBDAVS2_DECODER) += libdavs2.o > OBJS-$(CONFIG_LIBFDK_AAC_DECODER) += libfdk-aacdec.o > OBJS-$(CONFIG_LIBFDK_AAC_ENCODER) += libfdk-aacenc.o > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index c0b4d56d0d..d2628df620 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -674,6 +674,7 @@ extern AVCodec ff_libaom_av1_encoder; > extern AVCodec ff_libcelt_decoder; > extern AVCodec ff_libcodec2_encoder; > extern AVCodec ff_libcodec2_decoder; > +extern AVCodec ff_libdav1d_decoder; > extern AVCodec ff_libdavs2_decoder; > extern AVCodec ff_libfdk_aac_encoder; > extern AVCodec ff_libfdk_aac_decoder; > diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c > new file mode 100644 > index 00..82431f1b47 > --- /dev/null > +++ b/libavcodec/libdav1d.c > @@ -0,0 +1,273 @@ > +/* > + * Copyright (c) 2018 Ronald S. Bultje > + * Copyright (c) 2018 James Almer > + * > + * 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 > + */ > + > +#include >
[FFmpeg-devel] [PATCHv2 1/2] ffplay: options to specify window position
Thanks Marton for comments. Here is a revision to the first patch. From 3fe6a9e5279a280af9a06843621737ddc44529cc Mon Sep 17 00:00:00 2001 From: Dave Rice Date: Mon, 1 Oct 2018 17:07:44 -0400 Subject: [PATCHv2 1/2] ffplay: options to specify window position --- doc/ffplay.texi | 4 fftools/ffplay.c | 6 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/ffplay.texi b/doc/ffplay.texi index dcb86ce13c..a3da2cd570 100644 --- a/doc/ffplay.texi +++ b/doc/ffplay.texi @@ -74,6 +74,10 @@ as 100. Force format. @item -window_title @var{title} Set window title (default is the input filename). +@item -screen_left @var{title} +Set the x position for the left of the window (default is a centered window). +@item -screen_top @var{title} +Set the y position for the top of the window (default is a centered window). @item -loop @var{number} Loops movie playback times. 0 means forever. @item -showmode @var{mode} diff --git a/fftools/ffplay.c b/fftools/ffplay.c index e375a32ec2..6cc59b4d33 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -314,6 +314,8 @@ static int default_width = 640; static int default_height = 480; static int screen_width = 0; static int screen_height = 0; +static int left = SDL_WINDOWPOS_CENTERED; +static int top = SDL_WINDOWPOS_CENTERED; static int audio_disable; static int video_disable; static int subtitle_disable; @@ -1346,7 +1348,7 @@ static int video_open(VideoState *is) SDL_SetWindowTitle(window, window_title); SDL_SetWindowSize(window, w, h); -SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); +SDL_SetWindowPosition(window, left, top); if (is_full_screen) SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); SDL_ShowWindow(window); @@ -3602,6 +3604,8 @@ static const OptionDef options[] = { { "framedrop", OPT_BOOL | OPT_EXPERT, { &framedrop }, "drop frames when cpu is too slow", "" }, { "infbuf", OPT_BOOL | OPT_EXPERT, { &infinite_buffer }, "don't limit the input buffer size (useful with realtime streams)", "" }, { "window_title", OPT_STRING | HAS_ARG, { &window_title }, "set window title", "window title" }, +{ "left", OPT_INT | HAS_ARG | OPT_EXPERT, { &left }, "set the x position for the left of the window", "x pos" }, +{ "top", OPT_INT | HAS_ARG | OPT_EXPERT, { &top }, "set the y position for the top of the window", "y pos" }, #if CONFIG_AVFILTER { "vf", OPT_EXPERT | HAS_ARG, { .func_arg = opt_add_vfilter }, "set video filters", "filter_graph" }, { "af", OPT_STRING | HAS_ARG, { &afilters }, "set audio filters", "filter_graph" }, -- 2.19.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avdevice/sdl2 : add option to set window position
> On Oct 2, 2018, at 1:32 AM, Gyan wrote: > > On Tue, Oct 2, 2018 at 2:47 AM Dave Rice wrote: > >> Allows arrangement of multiple windows such as: >> ffmpeg -re -f lavfi -i mandelbrot -f sdl -window_x 1 -window_y 1 >> mandelbrot -vf waveform,format=yuv420p -f sdl -window_x 641 -window_y 1 >> waveform -vf vectorscope,format=yuv420p -f sdl -window_x 1 -window_y 481 >> vectorscop >> >> From 00438983c96b5db227b9975a2c160fc6aac5219d Mon Sep 17 00:00:00 2001 >> From: Dave Rice >> Date: Mon, 1 Oct 2018 17:08:35 -0400 >> Subject: [PATCH 2/2] avdevice/sdl2 : add option to set window position >> >> +if (!sdl->window_x) >> +sdl->window_x = SDL_WINDOWPOS_CENTERED; >> +if (!sdl->window_y) >> +sdl->window_y = SDL_WINDOWPOS_CENTERED; >> +SDL_SetWindowPosition(sdl->window, sdl->window_x, sdl->window_y); >> > > What happens if the user value implies fully or partially out-of-canvas > rendering? I attempted to add an error message but am uncertain how to access the width and height of the canvas used. Any advice? > For the former case, we may want to print a warning and reposition the > window. > If a partial window is drawable, then negative values can be valid and the > lower range bound should be INT_MIN > Also, the user can't position a window at top-left (0,0), so the default > should probably be INT_MAX. > > Gyan > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec/wmaprodec: improve WMAPRO/XMA gapless output
From: bnnm Improves trac issue #6722. Fixes truncated XMA output (was missing 128 samples) and applies bitstream gapless info (partially for XMA, fully for WMAPRO). Applying XMA end_skip would require some extra changes in the XMA multi-stream handling, so end samples are slightly bigger than what should be. Compared to MS's decoders, WMAPRO in XWMA are correct, while in ASF (.wma) don't seem to read the last frame, so output is around 128~512 samples smaller (this happens even with gapless disabled and affects other ASF codecs). Signed-off-by: bnnm --- libavcodec/wmaprodec.c | 92 -- 1 file changed, 66 insertions(+), 26 deletions(-) diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c index 9439bfa771..e9cc5d4ed9 100644 --- a/libavcodec/wmaprodec.c +++ b/libavcodec/wmaprodec.c @@ -216,9 +216,9 @@ typedef struct WMAProDecodeCtx { GetBitContextgb;///< bitstream reader context int buf_bit_size; ///< buffer size in bits uint8_t drc_gain; ///< gain for the DRC tool -int8_t skip_frame;///< skip output step int8_t parsed_all_subframes; ///< all subframes decoded? uint8_t skip_packets; ///< packets to skip to find next packet in a stream (XMA1/2) +int8_t eof_done; ///< set when EOF reached and extra subframe is written (XMA1/2) /* subframe/block decode state */ int16_t subframe_len; ///< current subframe length @@ -379,12 +379,6 @@ static av_cold int decode_init(WMAProDecodeCtx *s, AVCodecContext *avctx, int nu return AVERROR_PATCHWELCOME; } -/** frame info */ -if (avctx->codec_id != AV_CODEC_ID_WMAPRO) -s->skip_frame = 0; -else -s->skip_frame = 1; /* skip first frame */ - s->packet_loss = 1; s->len_prefix = (s->decode_flags & 0x40); @@ -1450,21 +1444,34 @@ static int decode_frame(WMAProDecodeCtx *s, AVFrame *frame, int *got_frame_ptr) ff_dlog(s->avctx, "drc_gain %i\n", s->drc_gain); } -/** no idea what these are for, might be the number of samples -that need to be skipped at the beginning or end of a stream */ +/** read encoder delay/padding (gapless) info */ if (get_bits1(gb)) { -int av_unused skip; +int start_skip, end_skip; + -/** usually true for the first frame */ +/** usually true for the first frame and equal to 1 frame */ if (get_bits1(gb)) { -skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); -ff_dlog(s->avctx, "start skip: %i\n", skip); +start_skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); +start_skip = FFMIN(start_skip, s->samples_per_frame); + +/* must add for XMA to respect starting skip_samples */ +s->avctx->internal->skip_samples += start_skip; } -/** sometimes true for the last frame */ +/** usually true for the last frame and less than 1 frame */ if (get_bits1(gb)) { -skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); -ff_dlog(s->avctx, "end skip: %i\n", skip); +end_skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); +end_skip = FFMIN(end_skip, s->samples_per_frame); + +if (s->avctx->codec_id == AV_CODEC_ID_WMAPRO) { +frame->nb_samples = s->samples_per_frame - end_skip; +} + +//TODO XMA end skip (needs changes in multistream's handling) +/* for XMA this skip seems to consider last frame + extra subframe, + * and (unlike WMAPRO?) files may have only 1 packet. Last packet + * nb_samples would be: 512 + 128 - start_skip - end_skip + * (theoretically skips happen anywhere, test more_frames too) */ } } @@ -1500,13 +1507,9 @@ static int decode_frame(WMAProDecodeCtx *s, AVFrame *frame, int *got_frame_ptr) s->samples_per_frame * sizeof(*s->channel[i].out) >> 1); } -if (s->skip_frame) { -s->skip_frame = 0; -*got_frame_ptr = 0; -av_frame_unref(frame); -} else { -*got_frame_ptr = 1; -} +/** frame may be partially discarded with gapless info in the bitstream */ +*got_frame_ptr = 1; + if (s->len_prefix) { if (len != (get_bits_count(gb) - s->frame_offset) + 2) { @@ -1609,7 +1612,33 @@ static int decode_packet(AVCodecContext *avctx, WMAProDecodeCtx *s, *got_frame_ptr = 0; -if (s->packet_done || s->packet_loss) { +if (!buf_size) { +AVFrame *frame = data; +int i; + +/** XMA must output one extra subframe after stream end with + * remaining samples (WMAPRO encoder adds padding instead). */ +s->packet_done
Re: [FFmpeg-devel] [PATCH 1/2] avcodec/av1_metadata: add an option to insert and remove Temporal Delimiter OBUs
On 03/10/18 01:18, James Almer wrote: > Signed-off-by: James Almer > --- > libavcodec/av1_metadata_bsf.c | 37 ++- > 1 file changed, 36 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c > index ed2f018fb6..20c3a39da7 100644 > --- a/libavcodec/av1_metadata_bsf.c > +++ b/libavcodec/av1_metadata_bsf.c > @@ -23,12 +23,20 @@ > #include "cbs.h" > #include "cbs_av1.h" > > +enum { > +PASS, > +INSERT, > +REMOVE, > +}; > + > typedef struct AV1MetadataContext { > const AVClass *class; > > CodedBitstreamContext *cbc; > CodedBitstreamFragment access_unit; > > +int td; > + > int color_primaries; > int transfer_characteristics; > int matrix_coefficients; > @@ -115,7 +123,7 @@ static int av1_metadata_filter(AVBSFContext *bsf, > AVPacket *out) > AV1MetadataContext *ctx = bsf->priv_data; > AVPacket *in = NULL; > CodedBitstreamFragment *frag = &ctx->access_unit; > -AV1RawOBU *obu; > +AV1RawOBU td, *obu; > int err, i; > > err = ff_bsf_get_packet(bsf, &in); > @@ -137,6 +145,23 @@ static int av1_metadata_filter(AVBSFContext *bsf, > AVPacket *out) > } > } > > +// If a Temporal Delimiter is present, it must be the first OBU. > +if (frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) { > +if (ctx->td == REMOVE) > +ff_cbs_delete_unit(ctx->cbc, frag, 0); > +} else if (ctx->td == INSERT) { > +td = (AV1RawOBU) { > +.header.obu_type = AV1_OBU_TEMPORAL_DELIMITER, > +}; > + > +err = ff_cbs_insert_unit_content(ctx->cbc, frag, 0, > AV1_OBU_TEMPORAL_DELIMITER, > + &td, NULL); > +if (err < 0) { > +av_log(bsf, AV_LOG_ERROR, "Failed to insert Temporal > Delimiter.\n"); > +goto fail; > +} > +} > + > err = ff_cbs_write_packet(ctx->cbc, out, frag); > if (err < 0) { > av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); > @@ -207,6 +232,16 @@ static void av1_metadata_close(AVBSFContext *bsf) > #define OFFSET(x) offsetof(AV1MetadataContext, x) > #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_BSF_PARAM) > static const AVOption av1_metadata_options[] = { > +{ "td", "Temporal Delimiter OBU", > +OFFSET(td), AV_OPT_TYPE_INT, > +{ .i64 = PASS }, PASS, REMOVE, FLAGS, "td" }, > +{ "pass", NULL, 0, AV_OPT_TYPE_CONST, > +{ .i64 = PASS }, .flags = FLAGS, .unit = "td" }, > +{ "insert", NULL, 0, AV_OPT_TYPE_CONST, > +{ .i64 = INSERT }, .flags = FLAGS, .unit = "td" }, > +{ "remove", NULL, 0, AV_OPT_TYPE_CONST, > +{ .i64 = REMOVE }, .flags = FLAGS, .unit = "td" }, > + > { "color_primaries", "Set color primaries (section 6.4.2)", > OFFSET(color_primaries), AV_OPT_TYPE_INT, > { .i64 = -1 }, -1, 255, FLAGS }, > LGTM. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat/ivfenc: use the av1_metadata bsf to insert Temporal Delimiter OBUs if needed
On 03/10/18 01:18, James Almer wrote: > Signed-off-by: James Almer > --- > libavformat/ivfenc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c > index 66441a2a43..adf72117e9 100644 > --- a/libavformat/ivfenc.c > +++ b/libavformat/ivfenc.c > @@ -97,6 +97,8 @@ static int ivf_check_bitstream(struct AVFormatContext *s, > const AVPacket *pkt) > > if (st->codecpar->codec_id == AV_CODEC_ID_VP9) > ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL); > +else if (st->codecpar->codec_id == AV_CODEC_ID_AV1) > +ret = ff_stream_add_bitstream_filter(st, "av1_metadata", > "td=insert"); > > return ret; > } > I'm not quite seeing why this is wanted - could you explain it a bit further? (Since IVF is packetised into temporal units already, it seems to me that having TDs or not in the file won't change anything from the point of view of the consumer.) Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/2] avformat/ivfenc: use the av1_metadata bsf to insert Temporal Delimiter OBUs if needed
On 10/3/2018 8:01 PM, Mark Thompson wrote: > On 03/10/18 01:18, James Almer wrote: >> Signed-off-by: James Almer >> --- >> libavformat/ivfenc.c | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c >> index 66441a2a43..adf72117e9 100644 >> --- a/libavformat/ivfenc.c >> +++ b/libavformat/ivfenc.c >> @@ -97,6 +97,8 @@ static int ivf_check_bitstream(struct AVFormatContext *s, >> const AVPacket *pkt) >> >> if (st->codecpar->codec_id == AV_CODEC_ID_VP9) >> ret = ff_stream_add_bitstream_filter(st, "vp9_superframe", NULL); >> +else if (st->codecpar->codec_id == AV_CODEC_ID_AV1) >> +ret = ff_stream_add_bitstream_filter(st, "av1_metadata", >> "td=insert"); >> >> return ret; >> } >> > > I'm not quite seeing why this is wanted - could you explain it a bit further? > > (Since IVF is packetised into temporal units already, it seems to me that > having TDs or not in the file won't change anything from the point of view of > the consumer.) No, but ivf afaik doesn't suggest or mandate the removal of TDs, unlike mp4 and matroska, so i figured it would be best to put them back in place for such remuxing scenarios. I don't mind dropping this patch. > > Thanks, > > - Mark > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v2] avcodec: add an AV1 parser
On 03/10/18 02:44, James Almer wrote: > Simple parser to set keyframes, frame type, structure, width, height, and > pixel > format, plus stream profile and level. > > Signed-off-by: James Almer > --- > Missing Changelog entry and version bump still. > > configure | 1 + > libavcodec/Makefile | 1 + > libavcodec/av1_parser.c | 226 > libavcodec/parsers.c| 1 + > 4 files changed, 229 insertions(+) > create mode 100644 libavcodec/av1_parser.c Looks good, and tested a bit (+1 for it removing the annoying need for -copyinkf when messing with BSFs in stream copy from raw IVF files). One very minor nitpick below, then no more from me :) Thanks, - Mark > ... > diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c > new file mode 100644 > index 00..0dee3e9d2e > --- /dev/null > +++ b/libavcodec/av1_parser.c > ... > + > +static int av1_parser_parse(AVCodecParserContext *ctx, > +AVCodecContext *avctx, > +const uint8_t **out_data, int *out_size, > +const uint8_t *data, int size) > +{ > +AV1ParseContext *s = ctx->priv_data; > +CodedBitstreamFragment *td = &s->temporal_unit; > +CodedBitstreamAV1Context *av1 = s->cbc->priv_data; > +int ret; > + > +*out_data = data; > +*out_size = size; > + > +ctx->key_frame = -1; > +ctx->pict_type = AV_PICTURE_TYPE_NONE; > +ctx->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; > + > +s->cbc->log_ctx = avctx; I think this should be unset at the end of the function as well. While I don't see a way for it to do so currently, some later call like the ff_cbs_close() could in theory attempt to use the logging context and then invoke undefined behaviour because the AVCodecContext assigned here need not still be accessible. > + > +if (avctx->extradata_size && !s->parsed_extradata) { > +s->parsed_extradata = 1; > + > +ret = ff_cbs_read(s->cbc, td, avctx->extradata, > avctx->extradata_size); > +if (ret < 0) { > +av_log(avctx, AV_LOG_ERROR, "Failed to parse extradata.\n"); > +return size; > +} > + > +ff_cbs_fragment_uninit(s->cbc, td); > +} > + > +ret = ff_cbs_read(s->cbc, td, data, size); > +if (ret < 0) { > +av_log(avctx, AV_LOG_ERROR, "Failed to parse temporal unit.\n"); > +return size; > +} > + > +if (!av1->sequence_header) { > +av_log(avctx, AV_LOG_ERROR, "No sequence header available\n"); > +goto end; > +} > + > +for (int i = 0; i < td->nb_units; i++) { > +CodedBitstreamUnit *unit = &td->units[i]; > +AV1RawOBU *obu = unit->content; > +AV1RawSequenceHeader *seq = av1->sequence_header; > +AV1RawColorConfig *color = &seq->color_config; > +AV1RawFrameHeader *frame; > +int frame_type; > + > +if (unit->type == AV1_OBU_FRAME) > +frame = &obu->obu.frame.header; > +else if (unit->type == AV1_OBU_FRAME_HEADER) > +frame = &obu->obu.frame_header; > +else > +continue; > + > +if (frame->show_existing_frame) { > +AV1ReferenceFrameState *ref = > &av1->ref[frame->frame_to_show_map_idx]; > + > +if (!ref->valid) { > +av_log(avctx, AV_LOG_ERROR, "Invalid reference frame\n"); > +goto end; > +} > + > +ctx->width = ref->frame_width; > +ctx->height = ref->frame_height; > +frame_type = ref->frame_type; > + > +ctx->key_frame = 0; > +} else if (!frame->show_frame) { > +continue; > +} else { > +ctx->width = av1->frame_width; > +ctx->height = av1->frame_height; > +frame_type = frame->frame_type; > + > +ctx->key_frame = frame_type == AV1_FRAME_KEY; > +} > + > +avctx->profile = seq->seq_profile; > +avctx->level = seq->seq_level_idx[0]; > + > +switch (frame_type) { > +case AV1_FRAME_KEY: > +case AV1_FRAME_INTRA_ONLY: > +ctx->pict_type = AV_PICTURE_TYPE_I; > +break; > +case AV1_FRAME_INTER: > +ctx->pict_type = AV_PICTURE_TYPE_P; > +break; > +case AV1_FRAME_SWITCH: > +ctx->pict_type = AV_PICTURE_TYPE_SP; > +break; > +} > +ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME; > + > +switch (av1->bit_depth) { > +case 8: > +ctx->format = color->mono_chrome ? AV_PIX_FMT_GRAY8 > + : pix_fmts_8bit > [color->subsampling_x][color->subsampling_y]; > +break; > +case 10: > +ctx->format = color->mono_chrome ? AV_PIX_FMT_GRAY10 > + : > pix_fmts_10bit[color->subsamplin
Re: [FFmpeg-devel] [PATCH v2] avcodec: add an AV1 parser
On 10/3/2018 8:26 PM, Mark Thompson wrote: > On 03/10/18 02:44, James Almer wrote: >> Simple parser to set keyframes, frame type, structure, width, height, and >> pixel >> format, plus stream profile and level. >> >> Signed-off-by: James Almer >> --- >> Missing Changelog entry and version bump still. >> >> configure | 1 + >> libavcodec/Makefile | 1 + >> libavcodec/av1_parser.c | 226 >> libavcodec/parsers.c| 1 + >> 4 files changed, 229 insertions(+) >> create mode 100644 libavcodec/av1_parser.c > > Looks good, and tested a bit (+1 for it removing the annoying need for > -copyinkf when messing with BSFs in stream copy from raw IVF files). > > One very minor nitpick below, then no more from me :) > > Thanks, > > - Mark > > >> ... >> diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c >> new file mode 100644 >> index 00..0dee3e9d2e >> --- /dev/null >> +++ b/libavcodec/av1_parser.c >> ... >> + >> +static int av1_parser_parse(AVCodecParserContext *ctx, >> +AVCodecContext *avctx, >> +const uint8_t **out_data, int *out_size, >> +const uint8_t *data, int size) >> +{ >> +AV1ParseContext *s = ctx->priv_data; >> +CodedBitstreamFragment *td = &s->temporal_unit; >> +CodedBitstreamAV1Context *av1 = s->cbc->priv_data; >> +int ret; >> + >> +*out_data = data; >> +*out_size = size; >> + >> +ctx->key_frame = -1; >> +ctx->pict_type = AV_PICTURE_TYPE_NONE; >> +ctx->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN; >> + >> +s->cbc->log_ctx = avctx; > > I think this should be unset at the end of the function as well. While I > don't see a way for it to do so currently, some later call like the > ff_cbs_close() could in theory attempt to use the logging context and then > invoke undefined behaviour because the AVCodecContext assigned here need not > still be accessible. Yeah, good catch. Changed and pushed, thanks! We may need to start planning on a replacement parser API. The fact it still uses raw bitstreams instead of AVPackets is a real handicap. Just by having to use ff_cbs_read() instead of ff_cbs_read_packet() this parser is slower than it should, because of the data memcpy. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavfi/atempo: fix tempo range limit inconsistency
yae_set_tempo was overlooked when max tempo limit was raised to 100. tested with: ./ffmpeg_g -i Delerium/SemanticSpaces/Gateway.mp3 \ -af asendcmd=f=asendcmd.cfg,atempo=1.0 -y /tmp/asendcmd-atempo.wav where asendcmd.cfg was: 15.0-45.0 [enter] atempo tempo 2.0, [leave] atempo tempo 0.5; 60.0-300.0 [enter] atempo tempo 4.0, [leave] atempo tempo 1.0; --- libavfilter/af_atempo.c | 13 + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libavfilter/af_atempo.c b/libavfilter/af_atempo.c index 52f15f2769..bfdad7d76b 100644 --- a/libavfilter/af_atempo.c +++ b/libavfilter/af_atempo.c @@ -149,11 +149,16 @@ typedef struct ATempoContext { uint64_t nsamples_out; } ATempoContext; +#define YAE_ATEMPO_MIN 0.5 +#define YAE_ATEMPO_MAX 100.0 + #define OFFSET(x) offsetof(ATempoContext, x) static const AVOption atempo_options[] = { { "tempo", "set tempo scale factor", - OFFSET(tempo), AV_OPT_TYPE_DOUBLE, { .dbl = 1.0 }, 0.5, 100.0, + OFFSET(tempo), AV_OPT_TYPE_DOUBLE, { .dbl = 1.0 }, + YAE_ATEMPO_MIN, + YAE_ATEMPO_MAX, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM }, { NULL } }; @@ -331,9 +336,9 @@ static int yae_set_tempo(AVFilterContext *ctx, const char *arg_tempo) return AVERROR(EINVAL); } -if (tempo < 0.5 || tempo > 2.0) { -av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [0.5, 2.0] range\n", - tempo); +if (tempo < YAE_ATEMPO_MIN || tempo > YAE_ATEMPO_MAX) { +av_log(ctx, AV_LOG_ERROR, "Tempo value %f exceeds [%f, %f] range\n", + tempo, YAE_ATEMPO_MIN, YAE_ATEMPO_MAX); return AVERROR(EINVAL); } -- 2.17.1 (Apple Git-112) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel