Re: [FFmpeg-devel] [PATCH] avcodec/xpmdec: Fix multiple pointer/memory issues
On Sat, May 13, 2017 at 08:38:52AM +0200, wm4 wrote: > On Fri, 12 May 2017 20:55:13 +0200 > Michael Niedermayer wrote: > > > On Fri, May 12, 2017 at 03:29:52PM +0200, Paul B Mahol wrote: > > > On 5/12/17, Michael Niedermayer wrote: > > > > On Thu, May 11, 2017 at 11:17:33AM +0200, Michael Niedermayer wrote: > > > >> On Thu, May 11, 2017 at 09:01:57AM +0200, Paul B Mahol wrote: > > > >> > On 5/11/17, Michael Niedermayer wrote: > > > >> > > Most of these were found through code review in response to > > > >> > > fixing 1466/clusterfuzz-testcase-minimized-5961584419536896 > > > >> > > There is thus no testcase for most of this. > > > >> > > The initial issue was Found-by: continuous fuzzing process > > > >> > > https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg > > > >> > > > > > >> > > Signed-off-by: Michael Niedermayer > > > >> > > --- > > > >> > > libavcodec/xpmdec.c | 37 ++--- > > > >> > > 1 file changed, 30 insertions(+), 7 deletions(-) > > > >> > > > > > >> > > diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c > > > >> > > index 9112d4cb5e..03172e4aad 100644 > > > >> > > --- a/libavcodec/xpmdec.c > > > >> > > +++ b/libavcodec/xpmdec.c > > > >> > > @@ -29,6 +29,8 @@ > > > >> > > typedef struct XPMContext { > > > >> > > uint32_t *pixels; > > > >> > > intpixels_size; > > > >> > > +uint8_t *buf; > > > >> > > +intbuf_size; > > > >> > > } XPMDecContext; > > > >> > > > > > >> > > typedef struct ColorEntry { > > > >> > > @@ -233,6 +235,8 @@ static uint32_t color_string_to_rgba(const char > > > >> > > *p, int > > > >> > > len) > > > >> > > const ColorEntry *entry; > > > >> > > char color_name[100]; > > > >> > > > > > >> > > +len = FFMIN(FFMAX(len, 0), sizeof(color_name) - 1); > > > >> > > + > > > >> > > if (*p == '#') { > > > >> > > p++; > > > >> > > len--; > > > >> > > @@ -299,18 +303,25 @@ static int xpm_decode_frame(AVCodecContext > > > >> > > *avctx, > > > >> > > void *data, > > > >> > > { > > > >> > > XPMDecContext *x = avctx->priv_data; > > > >> > > AVFrame *p=data; > > > >> > > -const uint8_t *end, *ptr = avpkt->data; > > > >> > > +const uint8_t *end, *ptr; > > > >> > > int ncolors, cpp, ret, i, j; > > > >> > > int64_t size; > > > >> > > uint32_t *dst; > > > >> > > > > > >> > > avctx->pix_fmt = AV_PIX_FMT_BGRA; > > > >> > > > > > >> > > -end = avpkt->data + avpkt->size; > > > >> > > -while (memcmp(ptr, "/* XPM */", 9) && ptr < end - 9) > > > >> > > +av_fast_padded_malloc(&x->buf, &x->buf_size, avpkt->size); > > > >> > > +if (!x->buf) > > > >> > > +return AVERROR(ENOMEM); > > > >> > > +memcpy(x->buf, avpkt->data, avpkt->size); > > > >> > > +x->buf[avpkt->size] = 0; > > > >> > > + > > > >> > > +ptr = x->buf; > > > >> > > +end = x->buf + avpkt->size; > > > >> > > +while (end - ptr > 9 && memcmp(ptr, "/* XPM */", 9)) > > > >> > > ptr++; > > > >> > > > > > >> > > -if (ptr >= end) { > > > >> > > +if (end - ptr <= 9) { > > > >> > > av_log(avctx, AV_LOG_ERROR, "missing signature\n"); > > > >> > > return AVERROR_INVALIDDATA; > > > >> > > } > > > >> > > @@ -335,7 +346,7 @@ static int xpm_decode_frame(AVCodecContext > > > >> > > *avctx, > > > >> > > void > > > >> > > *data, > > > >> > > > > > >> > > size = 1; > > > >> > > for (i = 0; i < cpp; i++) > > > >> > > -size *= 94; > > > >> > > +size *= 95; > > > >> > > > > > >> > > if (ncolors <= 0 || ncolors > size) { > > > >> > > av_log(avctx, AV_LOG_ERROR, "invalid number of colors: > > > >> > > %d\n", > > > >> > > ncolors); > > > >> > > @@ -349,12 +360,15 @@ static int xpm_decode_frame(AVCodecContext > > > >> > > *avctx, > > > >> > > void *data, > > > >> > > return AVERROR(ENOMEM); > > > >> > > > > > >> > > ptr += mod_strcspn(ptr, ",") + 1; > > > >> > > +if (end - ptr < 1) > > > >> > > +return AVERROR_INVALIDDATA; > > > >> > > + > > > >> > > for (i = 0; i < ncolors; i++) { > > > >> > > const uint8_t *index; > > > >> > > int len; > > > >> > > > > > >> > > ptr += mod_strcspn(ptr, "\"") + 1; > > > >> > > -if (ptr + cpp > end) > > > >> > > +if (end - ptr < cpp) > > > >> > > return AVERROR_INVALIDDATA; > > > >> > > index = ptr; > > > >> > > ptr += cpp; > > > >> > > @@ -373,14 +387,20 @@ static int xpm_decode_frame(AVCodecContext > > > >> > > *avctx, > > > >> > > void *data, > > > >> > > > > > >> > > x->pixels[ret] = color_string_to_rgba(ptr, len); > > > >> > > ptr += mod_strcspn(ptr, ",") + 1; > > > >> > > +if (end - ptr < 1) > > > >> > > +return AVERROR_INVALIDDATA; > > > >> > > } > > > >> > > > > > >> > > for (i = 0; i < avctx->height; i++) { > > > >> > > dst = (uint32_t *)(p->data[0] + i * p->linesize[0]); > > > >>
Re: [FFmpeg-devel] [PATCH] configure: jni no longer requires -ldl
On Fri, May 12, 2017 at 12:14:20PM -0700, Aaron Levinson wrote: > On 5/12/2017 11:34 AM, Aman Gupta wrote: > > From: Aman Gupta > > > > this dependency was removed in 33d69a90085d30af8a292d9364b835a26565d6b9 > > --- > > configure | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/configure b/configure > > index 5ae5227868..ba33241a45 100755 > > --- a/configure > > +++ b/configure > > @@ -5766,8 +5766,7 @@ enabled decklink && { { check_header > > DeckLinkAPI.h || die "ERROR: DeckL > > enabled frei0r&& { check_header frei0r.h || die "ERROR: > > frei0r.h header not found"; } > > enabled gmp && require gmp gmp.h mpz_export -lgmp > > enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h > > gnutls_global_init > > -enabled jni && { [ $target_os = "android" ] && check_header > > jni.h && enabled pthreads && > > - check_lib jni "dlfcn.h" dlopen -ldl || die > > "ERROR: jni not found"; } > > +enabled jni && { [ $target_os = "android" ] && check_header > > jni.h && enabled pthreads || die "ERROR: jni not found"; } > > enabled ladspa&& { check_header ladspa.h || die "ERROR: > > ladspa.h header not found"; } > > enabled libiec61883 && require libiec61883 libiec61883/iec61883.h > > iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 > > enabled libass&& require_pkg_config libass ass/ass.h > > ass_library_init > > > > LGTM--I see that the use of dl was eliminated in 33d69a9 (at > https://github.com/FFmpeg/FFmpeg/commit/33d69a90085d30af8a292d9364b835a26565d6b9 > ). LGTM too. Matthieu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/wavpack: Fix runtime error: signed integer overflow: 2147483642 + 512 cannot be represented in type 'int'
On Wed, May 10, 2017 at 11:28:21PM +0200, Michael Niedermayer wrote: > Fixed: 1453/clusterfuzz-testcase-minimized-5024976874766336 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/wavpack.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you think the mosad wants you dead since a long time then you are either wrong or dead since a long time. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/aacsbr_template: Do not change bs_num_env before its checked
On Fri, May 12, 2017 at 04:12:15AM +0200, Michael Niedermayer wrote: > Fixes: 1489/clusterfuzz-testcase-minimized-5075102901207040 > Fixes: out of array access > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/aacsbr_template.c | 28 +++- > 1 file changed, 15 insertions(+), 13 deletions(-) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The worst form of inequality is to try to make unequal things equal. -- Aristotle signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avfilter: add multiband compand filter
Signed-off-by: Paul B Mahol --- doc/filters.texi | 16 ++ libavfilter/Makefile | 1 + libavfilter/af_mcompand.c | 672 ++ libavfilter/allfilters.c | 1 + 4 files changed, 690 insertions(+) create mode 100644 libavfilter/af_mcompand.c diff --git a/doc/filters.texi b/doc/filters.texi index 5985db6..189831f 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -3064,6 +3064,22 @@ lowpass=c=LFE @end example @end itemize +@section mcompand +Multiband Compress or expand the audio's dynamic range. + +The input audio is divided into bands using 4th order Linkwitz-Riley IIRs. +This is akin to the crossover of a loudspeaker, and results in flat frequency +response when absent compander action. + +It accepts the following parameters: + +@table @option +@item args +This option syntax is: +attack,decay,{attack,decay..} soft-knee points crossover_frequency [delay [initial_volume [gain]]] | attack,decay ... +For explanation of each item refer to compand filter documentation. +@end table + @anchor{pan} @section pan diff --git a/libavfilter/Makefile b/libavfilter/Makefile index f7dfe8a..8e5a817 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -96,6 +96,7 @@ OBJS-$(CONFIG_JOIN_FILTER) += af_join.o OBJS-$(CONFIG_LADSPA_FILTER) += af_ladspa.o OBJS-$(CONFIG_LOUDNORM_FILTER) += af_loudnorm.o ebur128.o OBJS-$(CONFIG_LOWPASS_FILTER)+= af_biquads.o +OBJS-$(CONFIG_MCOMPAND_FILTER) += af_mcompand.o OBJS-$(CONFIG_PAN_FILTER)+= af_pan.o OBJS-$(CONFIG_REPLAYGAIN_FILTER) += af_replaygain.o OBJS-$(CONFIG_RESAMPLE_FILTER) += af_resample.o diff --git a/libavfilter/af_mcompand.c b/libavfilter/af_mcompand.c new file mode 100644 index 000..0fe135e --- /dev/null +++ b/libavfilter/af_mcompand.c @@ -0,0 +1,672 @@ +/* + * COpyright (c) 2002 Daniel Pouzzner + * Copyright (c) 1999 Chris Bagwell + * Copyright (c) 1999 Nick Bailey + * Copyright (c) 2007 Rob Sykes + * Copyright (c) 2013 Paul B Mahol + * Copyright (c) 2014 Andrew Kelley + * + * 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 + * audio multiband compand filter + */ + +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/ffmath.h" +#include "libavutil/opt.h" +#include "libavutil/samplefmt.h" +#include "audio.h" +#include "avfilter.h" +#include "internal.h" + +typedef struct CompandSegment { +double x, y; +double a, b; +} CompandSegment; + +typedef struct CompandT { +CompandSegment *segments; +int nb_segments; +double in_min_lin; +double out_min_lin; +double curve_dB; +double gain_dB; +} CompandT; + +#define N 4 + +typedef struct PrevCrossover { +double in; +double out_low; +double out_high; +} PrevCrossover[N * 2]; + +typedef struct Crossover { + PrevCrossover *previous; + size_t pos; + double coefs[3 *(N+1)]; +} Crossover; + +typedef struct CompBand { +CompandT transfer_fn; +double *attack_rate; +double *decay_rate; +double *volume; +double delay; +double topfreq; +Crossover filter; +AVFrame *delay_buf; +size_t delay_size; +ptrdiff_t delay_buf_ptr; +size_t delay_buf_cnt; +} CompBand; + +typedef struct MCompandContext { +const AVClass *class; + +char *args; + +int nb_bands; +CompBand *bands; +AVFrame *band_buf1, *band_buf2, *band_buf3; +int band_samples; +size_t delay_buf_size; + +int64_t pts; +} MCompandContext; + +#define OFFSET(x) offsetof(MCompandContext, x) +#define A AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM + +static const AVOption mcompand_options[] = { +{ "args", "set parameters for each band", OFFSET(args), AV_OPT_TYPE_STRING, { .str = "0.3" }, 0, 0, A }, +{ NULL } +}; + +AVFILTER_DEFINE_CLASS(mcompand); + +static av_cold int init(AVFilterContext *ctx) +{ +MCompandContext *s = ctx->priv; +s->pts = AV_NOPTS_VALUE; +return 0; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ +MCompandContext *s = ctx->priv; + +av_freep(&s->band_buf1); +av_freep(&s->band_buf2); +av_freep(&s->band_buf3); +} + +st
Re: [FFmpeg-devel] Patch libavformat/aviobuf.c fixes data loss on named pipe reads
On Fri, May 12, 2017 at 19:13:21 +, Rob Meyers wrote: > Attaching the output of "git diff -p". That will work, but $ git format-patch --signoff is recommended: https://ffmpeg.org/developer.html#Submitting-patches Your method lost the commit message (which was incorrectly worded anyway ;-)). Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Patch libavformat/aviobuf.c fixes data loss on named pipe reads
On 5/13/2017 6:00 PM, Moritz Barsnick wrote: > On Fri, May 12, 2017 at 19:13:21 +, Rob Meyers wrote: >> Attaching the output of "git diff -p". > > That will work, but > $ git format-patch --signoff > is recommended: > https://ffmpeg.org/developer.html#Submitting-patches git format-patch is a minimum. git send-email is encouraged/recommended. > > Your method lost the commit message (which was incorrectly worded > anyway ;-)). > > Moritz > ___ > 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] FFmpeg 3.3.1
Hi all ill make 3.3.1 soon (likely within 24h) and releases from other maintained branches after that (if nothing unexpected happens) If you want to backport something, do it now thx -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avfilter: add multiband compand filter
On Sat, May 13, 2017 at 10:05:35PM +0200, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol > --- > doc/filters.texi | 16 ++ > libavfilter/Makefile | 1 + > libavfilter/af_mcompand.c | 672 > ++ > libavfilter/allfilters.c | 1 + > 4 files changed, 690 insertions(+) > create mode 100644 libavfilter/af_mcompand.c > > diff --git a/doc/filters.texi b/doc/filters.texi > index 5985db6..189831f 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -3064,6 +3064,22 @@ lowpass=c=LFE > @end example > @end itemize > > +@section mcompand > +Multiband Compress or expand the audio's dynamic range. > + > +The input audio is divided into bands using 4th order Linkwitz-Riley IIRs. > +This is akin to the crossover of a loudspeaker, and results in flat frequency > +response when absent compander action. > + > +It accepts the following parameters: > + > +@table @option > +@item args > +This option syntax is: > +attack,decay,{attack,decay..} soft-knee points crossover_frequency [delay > [initial_volume [gain]]] | attack,decay ... > +For explanation of each item refer to compand filter documentation. > +@end table > + > @anchor{pan} > @section pan this fails to build doc/filters.texi:3079: misplaced { doc/filters.texi:3079: misplaced } doc/filters.texi:3079: misplaced { doc/filters.texi:3079: misplaced } make: *** [doc/ffplay-all.html] Error 1 make: *** Waiting for unfinished jobs make: *** [doc/ffprobe-all.html] Error 1 doc/filters.texi:3079: misplaced { doc/filters.texi:3079: misplaced } make: *** [doc/ffserver-all.html] Error 1 doc/filters.texi:3079: misplaced { doc/filters.texi:3079: misplaced } make: *** [doc/ffmpeg-all.html] Error 1 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Modern terrorism, a quick summary: Need oil, start war with country that has oil, kill hundread thousand in war. Let country fall into chaos, be surprised about raise of fundamantalists. Drop more bombs, kill more people, be surprised about them taking revenge and drop even more bombs and strip your own citizens of their rights and freedoms. to be continued signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 3/3] avfilter/scale_cuda: add CUDA scale filter
On Fri, May 12, 2017 at 09:40:16PM +0200, Timo Rothenpieler wrote: > From: Yogender Gupta > > --- > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/vf_scale_cuda.c | 555 > +++ > libavfilter/vf_scale_cuda.cu | 212 + > 4 files changed, 769 insertions(+) > create mode 100644 libavfilter/vf_scale_cuda.c > create mode 100644 libavfilter/vf_scale_cuda.cu > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index f7dfe8ad54..f177fdb42b 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -267,6 +267,7 @@ OBJS-$(CONFIG_REVERSE_FILTER)+= > f_reverse.o > OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o > OBJS-$(CONFIG_SAB_FILTER)+= vf_sab.o > OBJS-$(CONFIG_SCALE_FILTER) += vf_scale.o scale.o > +OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o > vf_scale_cuda.ptx.o > OBJS-$(CONFIG_SCALE_NPP_FILTER) += vf_scale_npp.o scale.o > OBJS-$(CONFIG_SCALE_QSV_FILTER) += vf_scale_qsv.o > OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index cd35ae4c9c..a8939b9094 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -278,6 +278,7 @@ static void register_all(void) > REGISTER_FILTER(ROTATE, rotate, vf); > REGISTER_FILTER(SAB,sab,vf); > REGISTER_FILTER(SCALE, scale, vf); > +REGISTER_FILTER(SCALE_CUDA, scale_cuda, vf); > REGISTER_FILTER(SCALE_NPP, scale_npp, vf); > REGISTER_FILTER(SCALE_QSV, scale_qsv, vf); > REGISTER_FILTER(SCALE_VAAPI,scale_vaapi,vf); > diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c > new file mode 100644 > index 00..1f643197ac > --- /dev/null > +++ b/libavfilter/vf_scale_cuda.c > @@ -0,0 +1,555 @@ > +/* > +* Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. > +* > +* Permission is hereby granted, free of charge, to any person obtaining a > +* copy of this software and associated documentation files (the "Software"), > +* to deal in the Software without restriction, including without limitation > +* the rights to use, copy, modify, merge, publish, distribute, sublicense, > +* and/or sell copies of the Software, and to permit persons to whom the > +* Software is furnished to do so, subject to the following conditions: > +* > +* The above copyright notice and this permission notice shall be included in > +* all copies or substantial portions of the Software. > +* > +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER > +* DEALINGS IN THE SOFTWARE. > +*/ > + > +#include > +#include > +#include > + > +#include "libavutil/avstring.h" > +#include "libavutil/common.h" > +#include "libavutil/hwcontext.h" > +#include "libavutil/hwcontext_cuda_internal.h" > +#include "libavutil/internal.h" > +#include "libavutil/opt.h" > +#include "libavutil/pixdesc.h" > + > +#include "avfilter.h" > +#include "formats.h" > +#include "internal.h" > +#include "scale.h" > +#include "video.h" > + > +static const enum AVPixelFormat supported_formats[] = { > +AV_PIX_FMT_YUV420P, > +AV_PIX_FMT_NV12, > +AV_PIX_FMT_YUV444P, > +AV_PIX_FMT_P010, > +AV_PIX_FMT_P016 > +}; > + > +#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) ) > +#define ALIGN_UP(a, b) ((a + b -1) & ~(b-1)) this is missing () to protect the arguments [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH V3] lavc/vaapi_encode_h264: Enable MB rate control.
V3: - Fix build error with old VAAPI version. V2: - Refine the name/value type to mb_rate_control/bool. - Only supported GEN9+ (SKL/APL/KBL/...) - i965 driver default use frame-level rate control algorithm (generate the QP for each frame), when enable mb_rate_control, it's will enable the MB-level RC algorithm (generate the QP for each MB). - enables MB-level bitrate control that generally improves subjective visual quality, but have negative impact on performance and objective visual quality metric. From 219b06cec04a6c3f719ce80084a98b19456498e0 Mon Sep 17 00:00:00 2001 From: Jun Zhao Date: Tue, 9 May 2017 08:19:16 +0800 Subject: [PATCH V3] lavc/vaapi_encode_h264: Enable MB rate control. Enables macroblock-level bitrate control that generally improves subjective visual quality. It may have a negative impact on performance and objective visual quality metrics. Default is off and can't compatible with Constant QP. Signed-off-by: Jun Zhao --- libavcodec/vaapi_encode_h264.c | 19 ++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 92e29554ed..44223ada55 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -168,6 +168,7 @@ typedef struct VAAPIEncodeH264Options { int qp; int quality; int low_power; +int mb_rate_control; } VAAPIEncodeH264Options; @@ -1133,8 +1134,22 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx) priv->fixed_qp_p = 26; priv->fixed_qp_b = 26; -av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate = %"PRId64" bps.\n", +if (opt->mb_rate_control) { +#if VA_CHECK_VERSION(0, 39, 2) +ctx->rc_params.rc.rc_flags.bits.mb_rate_control = opt->mb_rate_control; +#else +av_log(avctx, AV_LOG_WARNING, "The MB rate control option is not " + "supported with this VAAPI version.\n"); +#endif +} + +av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate %s MB rate control = %"PRId64" bps.\n", ctx->va_rc_mode == VA_RC_CBR ? "constant" : "variable", +#if VA_CHECK_VERSION(0, 39, 2) + opt->mb_rate_control ? "with" : "without", +#else + "without", +#endif avctx->bit_rate); } else { @@ -1283,6 +1298,8 @@ static const AVOption vaapi_encode_h264_options[] = { { "low_power", "Use low-power encoding mode (experimental: only supported " "on some platforms, does not support all features)", OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, +{ "mb_rate_control", "MB level bitrate control (only supported on GEN9+)", + OFFSET(mb_rate_control), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS, "mb_rate_control" }, { NULL }, }; -- 2.11.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel