Re: [FFmpeg-devel] [PATCH] avformat/argo_asf: Use memcpy to copy string without its NUL
Zane van Iperen: > > > On 26/9/21 1:09 pm, Andreas Rheinhardt wrote: >> This avoids a -Wstringop-truncation warning from GCC which takes >> issue with the fact that the destination might not be NUL terminated. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavformat/argo_asf.c | 20 +++- >> 1 file changed, 7 insertions(+), 13 deletions(-) >> >> diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c >> index 5adafb7230..0ef970df8a 100644 >> --- a/libavformat/argo_asf.c >> +++ b/libavformat/argo_asf.c >> @@ -356,25 +356,19 @@ static int argo_asf_write_header(AVFormatContext >> *s) >> .num_chunks = 1, >> .chunk_offset = ASF_FILE_HEADER_SIZE >> }; >> + const char *name = ctx->name, *end; >> + size_t len; >> /* >> * If the user specified a name, use it as is. Otherwise take the >> * basename and lop off the extension (if any). >> */ >> - if (ctx->name) { >> - strncpy(fhdr.name, ctx->name, sizeof(fhdr.name)); >> - } else { >> - const char *start = av_basename(s->url); >> - const char *end = strrchr(start, '.'); >> - size_t len; >> - >> - if (end) >> - len = end - start; >> - else >> - len = strlen(start); >> + if (name || !(end = strrchr(name = av_basename(s->url), '.'))) { >> + len = strlen(name); >> + } else >> + len = end - name; >> - memcpy(fhdr.name, start, FFMIN(len, sizeof(fhdr.name))); >> - } >> + memcpy(fhdr.name, name, FFMIN(len, sizeof(fhdr.name))); >> > > Minor formatting nits: > * The first statement has braces, the second doesn't. > * A set of parentheses around "name = av_basename(s->url)" would make > things clearer. > > Otherwise, lgtm. > Applied with that changes. Thanks for the speedy review. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1] avfilter/vf_avgblur: switch to faster algorithm
Signed-off-by: Paul B Mahol --- libavfilter/vf_avgblur.c | 311 ++ tests/ref/fate/filter-refcmp-psnr-yuv | 80 +++ 2 files changed, 211 insertions(+), 180 deletions(-) diff --git a/libavfilter/vf_avgblur.c b/libavfilter/vf_avgblur.c index 3e222a43fa..a838285bb4 100644 --- a/libavfilter/vf_avgblur.c +++ b/libavfilter/vf_avgblur.c @@ -20,6 +20,7 @@ * SOFTWARE. */ +#include "libavutil/avassert.h" #include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" @@ -36,13 +37,15 @@ typedef struct AverageBlurContext { int planes; int depth; +int max; +int area; int planewidth[4]; int planeheight[4]; -float *buffer; +void *buffer; +uint16_t lut[256 * 256 * 256]; int nb_planes; -int (*filter_horizontally)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); -int (*filter_vertically)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); +int (*filter[2])(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); } AverageBlurContext; #define OFFSET(x) offsetof(AverageBlurContext, x) @@ -60,124 +63,138 @@ AVFILTER_DEFINE_CLASS(avgblur); typedef struct ThreadData { int height; int width; -uint8_t *ptr; -int linesize; +const void *ptr; +void *dptr; +int linesize, dlinesize; } ThreadData; -#define HORIZONTAL_FILTER(name, type) \ -static int filter_horizontally_##name(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)\ -{ \ -AverageBlurContext *s = ctx->priv; \ -ThreadData *td = arg; \ -const int height = td->height; \ -const int width = td->width; \ -const int slice_start = (height * jobnr ) / nb_jobs; \ -const int slice_end = (height * (jobnr+1)) / nb_jobs; \ -const int radius = FFMIN(s->radius, width / 2); \ -const int linesize = td->linesize / sizeof(type); \ -float *buffer = s->buffer; \ -const type *src; \ -float *ptr; \ -int y, x; \ - \ -/* Filter horizontally along each row */ \ -for (y = slice_start; y < slice_end; y++) { \ -float acc = 0; \ -int count = 0; \ - \ -src = (const type *)td->ptr + linesize * y; \ -ptr = buffer + width * y; \ - \ -for (x = 0; x < radius; x++) { \ -acc += src[x]; \ -} \ -count += radius; \ - \ -for (x = 0; x <= radius; x++) { \ -acc += src[x + radius]; \ -count++; \ -ptr[x] = acc / count; \ -} \ - \ -for (; x < width - radius; x++) { \ -acc += src[x + radius] - src[x - radius - 1];
Re: [FFmpeg-devel] [PATCH 3/3] avfilter/formats: Avoid reallocations for video in ff_all_formats()
Andreas Rheinhardt (12021-09-26): > Up until now, the list of pixfmts is reallocated every time an entry > is added to it; there are currently 196 pixel formats, so this matters: > It causes 5541704 calls to av_realloc_array() in a typical FATE run, > which is the majority for said function (8095768 calls) and even > a large chunk of the calls to av_realloc() itself (12589508 calls). > > Fix this by using ff_formats_pixdesc_filter() instead. > > Signed-off-by: Andreas Rheinhardt > --- > libavfilter/formats.c | 6 +- > 1 file changed, 1 insertion(+), 5 deletions(-) All three look good to me, but I have not looked that carefully at each individual change in the second patch. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avfilter/vf_swaprect: Use ff_formats_pixdesc_filter()
lgtm ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avutil/utils: Remove racy check from avutil_version()
avutil_version() currently performs several checks before just returning the version. There is a static int that aims to ensure that these tests are run only once. The reason is that there used to be a slightly expensive check, but it has been removed in 92e3a6fdac73f7e1d69d69717219a7538877d7a0. Today running only once is unnecessary and can be counterproductive: GCC 10 optimizes all the actual checks away, but the checks_done variable and the code setting it has been kept. Given that this check is inherently racy (it uses non-atomic variables), it is best to just remove it. Signed-off-by: Andreas Rheinhardt --- A part of me just wants to nuke all those checks. (We have zero callers of avutil_version() in the codebase and I don't see a reason why external users should call it more often, so all those checks probably don't fulfill their aim.) libavutil/utils.c | 5 - 1 file changed, 5 deletions(-) diff --git a/libavutil/utils.c b/libavutil/utils.c index c1cd452eee..ea9b5097b8 100644 --- a/libavutil/utils.c +++ b/libavutil/utils.c @@ -37,10 +37,6 @@ const char *av_version_info(void) unsigned avutil_version(void) { -static int checks_done; -if (checks_done) -return LIBAVUTIL_VERSION_INT; - av_assert0(AV_SAMPLE_FMT_DBLP == 9); av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4); av_assert0(AV_PICTURE_TYPE_BI == 7); @@ -58,7 +54,6 @@ unsigned avutil_version(void) av_log(NULL, AV_LOG_ERROR, "Libavutil has been linked to a broken llrint()\n"); } -checks_done = 1; return LIBAVUTIL_VERSION_INT; } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avutil/opt: Remove outdated version check
Signed-off-by: Andreas Rheinhardt --- libavutil/opt.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index f05283d610..c7001dbcd3 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1831,10 +1831,7 @@ int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, { int ret; const AVClass *c = *(AVClass**)obj; -int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) = NULL; - -if (c->version > (52 << 16 | 11 << 8)) -callback = c->query_ranges; +int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) = c->query_ranges; if (!callback) callback = av_opt_query_ranges_default; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avutil/tests/opt: Set AVClass.version
Signed-off-by: Andreas Rheinhardt --- libavutil/tests/opt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavutil/tests/opt.c b/libavutil/tests/opt.c index 3134ffd354..e6ea892373 100644 --- a/libavutil/tests/opt.c +++ b/libavutil/tests/opt.c @@ -105,6 +105,7 @@ static const AVClass test_class = { .class_name = "TestContext", .item_name = test_get_name, .option = test_options, +.version= LIBAVUTIL_VERSION_INT, }; static void log_callback_help(void *ptr, int level, const char *fmt, va_list vl) -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avutil/utils: Remove racy check from avutil_version()
lgtm ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] avutil/tests/opt: Set AVClass.version
lgtm ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] avutil/opt: Remove outdated version check
lgtm ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/5] avformat/matroskadec: Parse dvcC/dvvC block additional mapping
On Sat, Sep 25, 2021 at 11:58 PM quietvoid wrote: > > The parsing was implemented in a new dovi_isom file for the > unification of the mov/mpegts DOVI parsing into one function, in a following > patch. > > Most of the Matroska elements implementation was done by Plex developers. > > Signed-off-by: quietvoid > --- > libavformat/Makefile | 2 +- > libavformat/dovi_isom.c | 80 +++ > libavformat/dovi_isom.h | 29 ++ > libavformat/matroskadec.c | 15 > 4 files changed, 125 insertions(+), 1 deletion(-) > create mode 100644 libavformat/dovi_isom.c > create mode 100644 libavformat/dovi_isom.h > > diff --git a/libavformat/Makefile b/libavformat/Makefile > index c45caa3eed..61a1fecf6c 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -313,7 +313,7 @@ OBJS-$(CONFIG_M4V_MUXER) += rawenc.o > OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \ > flac_picture.o isom_tags.o > rmsipr.o \ > oggparsevorbis.o vorbiscomment.o > \ > -qtpalette.o replaygain.o > +qtpalette.o replaygain.o > dovi_isom.o > OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \ > av1.o avc.o hevc.o isom_tags.o \ > flacenc_header.o avlanguage.o \ > diff --git a/libavformat/dovi_isom.c b/libavformat/dovi_isom.c > new file mode 100644 > index 00..2c0a49c993 > --- /dev/null > +++ b/libavformat/dovi_isom.c > @@ -0,0 +1,80 @@ > +/* > + * DOVI ISO Media common code > + * Copyright (c) 2021 quietvoid > + * > + * 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 "libavutil/dovi_meta.h" > + > +#include "avformat.h" > +#include "dovi_isom.h" > + > +int ff_isom_parse_dvcc_dvvc(AVFormatContext *s, AVStream *st, const uint8_t > *buf_ptr, uint64_t size) > +{ > +uint32_t buf; > +AVDOVIDecoderConfigurationRecord *dovi; > +size_t dovi_size; > +int ret; > + > +if (size > (1 << 30) || size < 4) > +return AVERROR_INVALIDDATA; > + > +dovi = av_dovi_alloc(&dovi_size); > +if (!dovi) > +return AVERROR(ENOMEM); > + > +dovi->dv_version_major = *buf_ptr++;// 8 bits > +dovi->dv_version_minor = *buf_ptr++;// 8 bits > + > +buf = *buf_ptr++ << 8; > +buf |= *buf_ptr++; > + > +dovi->dv_profile= (buf >> 9) & 0x7f;// 7 bits > +dovi->dv_level = (buf >> 3) & 0x3f;// 6 bits > +dovi->rpu_present_flag = (buf >> 2) & 0x01;// 1 bit > +dovi->el_present_flag = (buf >> 1) & 0x01;// 1 bit > +dovi->bl_present_flag = buf & 0x01;// 1 bit > + > +// Has enough remaining data > +if (size >= 5) { > +dovi->dv_bl_signal_compatibility_id = ((*buf_ptr++) >> 4) & 0x0f; // > 4 bits > +} else { > +// 0 stands for None > +// Dolby Vision V1.2.93 profiles and levels > +dovi->dv_bl_signal_compatibility_id = 0; > +} > + > +ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, > + (uint8_t *)dovi, dovi_size); > +if (ret < 0) { > +av_free(dovi); > +return ret; > +} > + > +av_log(s, AV_LOG_TRACE, "DOVI, version: %d.%d, profile: %d, level: %d, " > + "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", > + dovi->dv_version_major, dovi->dv_version_minor, > + dovi->dv_profile, dovi->dv_level, > + dovi->rpu_present_flag, > + dovi->el_present_flag, > + dovi->bl_present_flag, > + dovi->dv_bl_signal_compatibility_id > +); > + > +return 0; > +} > diff --git a/libavformat/dovi_isom.h b/libavformat/dovi_isom.h > new file mode 100644 > index 00..4c313046a7 > --- /dev/null > +++ b/libavformat/dovi_isom.h > @@ -0,0 +1,29 @@ > +/* > + * DOVI ISO Media common code > + * Copyright (c) 2021 quietvoid > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or >
Re: [FFmpeg-devel] [PATCH 1] avfilter/vf_avgblur: switch to faster algorithm
On Sun, Sep 26, 2021 at 4:11 PM Paul B Mahol wrote: > > Signed-off-by: Paul B Mahol > --- > libavfilter/vf_avgblur.c | 311 ++ > tests/ref/fate/filter-refcmp-psnr-yuv | 80 +++ > 2 files changed, 211 insertions(+), 180 deletions(-) > > diff --git a/libavfilter/vf_avgblur.c b/libavfilter/vf_avgblur.c > index 3e222a43fa..a838285bb4 100644 > --- a/libavfilter/vf_avgblur.c > +++ b/libavfilter/vf_avgblur.c > @@ -20,6 +20,7 @@ > * SOFTWARE. > */ > > +#include "libavutil/avassert.h" > #include "libavutil/imgutils.h" > #include "libavutil/opt.h" > #include "libavutil/pixdesc.h" > @@ -36,13 +37,15 @@ typedef struct AverageBlurContext { > int planes; > > int depth; > +int max; > +int area; > int planewidth[4]; > int planeheight[4]; > -float *buffer; > +void *buffer; > +uint16_t lut[256 * 256 * 256]; > int nb_planes; > > -int (*filter_horizontally)(AVFilterContext *ctx, void *arg, int jobnr, > int nb_jobs); > -int (*filter_vertically)(AVFilterContext *ctx, void *arg, int jobnr, int > nb_jobs); > +int (*filter[2])(AVFilterContext *ctx, void *arg, int jobnr, int > nb_jobs); > } AverageBlurContext; > > #define OFFSET(x) offsetof(AverageBlurContext, x) > @@ -60,124 +63,138 @@ AVFILTER_DEFINE_CLASS(avgblur); > typedef struct ThreadData { > int height; > int width; > -uint8_t *ptr; > -int linesize; > +const void *ptr; > +void *dptr; > +int linesize, dlinesize; > } ThreadData; > > -#define HORIZONTAL_FILTER(name, type) > \ > -static int filter_horizontally_##name(AVFilterContext *ctx, void *arg, int > jobnr, int nb_jobs)\ > -{ > \ > -AverageBlurContext *s = ctx->priv; > \ > -ThreadData *td = arg; > \ > -const int height = td->height; > \ > -const int width = td->width; > \ > -const int slice_start = (height * jobnr ) / nb_jobs; > \ > -const int slice_end = (height * (jobnr+1)) / nb_jobs; > \ > -const int radius = FFMIN(s->radius, width / 2); > \ > -const int linesize = td->linesize / sizeof(type); > \ > -float *buffer = s->buffer; > \ > -const type *src; > \ > -float *ptr; > \ > -int y, x; > \ > - > \ > -/* Filter horizontally along each row */ > \ > -for (y = slice_start; y < slice_end; y++) { > \ > -float acc = 0; > \ > -int count = 0; > \ > - > \ > -src = (const type *)td->ptr + linesize * y; > \ > -ptr = buffer + width * y; > \ > - > \ > -for (x = 0; x < radius; x++) { > \ > -acc += src[x]; > \ > -} > \ > -count += radius; > \ > - > \ > -for (x = 0; x <= radius; x++) { > \ > -acc += src[x + radius]; > \ > -count++; > \ > -ptr[x] = acc / count; > \ > -} > \ >
Re: [FFmpeg-devel] [PATCH v2 6/6] avcodec/libsvtav1: support constant quality mode
On Sat, Sep 25, 2021 at 8:36 PM Jan Ekström wrote: > > On Thu, Sep 23, 2021 at 6:08 PM wrote: > > > > On Thu, Sep 23, 2021 at 05:11:49PM +0300, Jan Ekström wrote: > > > On Thu, Sep 23, 2021 at 4:46 PM Christopher Degawa > > > wrote: > > > > > > > > On Sun, Sep 19, 2021 at 2:02 PM Christopher Degawa > > > > wrote: > > > > > > > > > > > > > > > > > > > On Fri, Sep 17, 2021 at 9:28 PM wrote: > > > > > > > > > >> From: Limin Wang > > > > >> > > > > >> Signed-off-by: Limin Wang > > > > >> > > > > > As a note, I personally favor this patch over mine since I don't think > > > > > `enable_tpl_la` is worth exposing to the user if its main role is to > > > > > switch > > > > > between crf and cqp > > > > > > > > > > > > > Ping on this patch, this has been requested on SVT-AV1's side as well > > > > > > I think my further comments on the previous version were mostly to > > > move off from the rc option for rate control, which has become more > > > and more seemingly unnecessary (and different from most other encoders > > > for no obvious reason). > > > > > > The only option that with a quick look doesn't match just setting > > > quantizer|bit rate|CRF is "cvbr", but it doesn't seem to be impossible > > > to either rework "rc" for it, or to utilize a separate option for it. > > > > Do you think it's OK to remove the rc option? to match other encoders, > > We can choose the rate control by the related parameters like: > > > > if (crf >= 0) > > choose crf rate control; > > else if (bitrate > 0) > > choose cvbr rate control; > > else if (cqp >=0 ) > > choose cqp rate control; > > > > In general that is the idea, yes (except bit rate would mean either > vbr or cvbr). It would be nice to follow whatever is the default on > SVT-AV1's side by default, and then if the user specifies a rate > control mode that is not the default, his selection is honored. Not > sure what the best way for that is to be honest. Possibly the style of > setting AVCodecDefault a la libx265? > > For the rc option, given how much SVT-AV1 itself is in flux, I would > be OK with removing the option, or making it an option that decides > between cvbr and vbr (essentially making it "VBR bit rate control > mode"). I wish cvbr would instead be something like VBV/HRD elsewhere, > so we could just utilize maxrate&bufsize for controlling it, instead > of having it as another discrete rate control mode. > > As these things change, I also hope that SVT-AV1 will soon get a > key=value style of option API, that way the wrapper will not have to I agree with this part , now FFmpeg SVT-AV1 wrapper needs to update with the SVT-AV1's structural mapping if want to enable a new feature > be updated constantly according to the changes in the library :) . As > I feel SVT-AV1 will be changed quite a bit in the future (due to its > recent age). > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1] avfilter/vf_avgblur: switch to faster algorithm
On Sun, Sep 26, 2021 at 1:27 PM myp...@gmail.com wrote: > On Sun, Sep 26, 2021 at 4:11 PM Paul B Mahol wrote: > > > > Signed-off-by: Paul B Mahol > > --- > > libavfilter/vf_avgblur.c | 311 ++ > > tests/ref/fate/filter-refcmp-psnr-yuv | 80 +++ > > 2 files changed, 211 insertions(+), 180 deletions(-) > > > > diff --git a/libavfilter/vf_avgblur.c b/libavfilter/vf_avgblur.c > > index 3e222a43fa..a838285bb4 100644 > > --- a/libavfilter/vf_avgblur.c > > +++ b/libavfilter/vf_avgblur.c > > @@ -20,6 +20,7 @@ > > * SOFTWARE. > > */ > > > > +#include "libavutil/avassert.h" > > #include "libavutil/imgutils.h" > > #include "libavutil/opt.h" > > #include "libavutil/pixdesc.h" > > @@ -36,13 +37,15 @@ typedef struct AverageBlurContext { > > int planes; > > > > int depth; > > +int max; > > +int area; > > int planewidth[4]; > > int planeheight[4]; > > -float *buffer; > > +void *buffer; > > +uint16_t lut[256 * 256 * 256]; > > int nb_planes; > > > > -int (*filter_horizontally)(AVFilterContext *ctx, void *arg, int > jobnr, int nb_jobs); > > -int (*filter_vertically)(AVFilterContext *ctx, void *arg, int > jobnr, int nb_jobs); > > +int (*filter[2])(AVFilterContext *ctx, void *arg, int jobnr, int > nb_jobs); > > } AverageBlurContext; > > > > #define OFFSET(x) offsetof(AverageBlurContext, x) > > @@ -60,124 +63,138 @@ AVFILTER_DEFINE_CLASS(avgblur); > > typedef struct ThreadData { > > int height; > > int width; > > -uint8_t *ptr; > > -int linesize; > > +const void *ptr; > > +void *dptr; > > +int linesize, dlinesize; > > } ThreadData; > > > > -#define HORIZONTAL_FILTER(name, type) >\ > > -static int filter_horizontally_##name(AVFilterContext *ctx, void *arg, > int jobnr, int nb_jobs)\ > > -{ >\ > > -AverageBlurContext *s = ctx->priv; > \ > > -ThreadData *td = arg; >\ > > -const int height = td->height; > \ > > -const int width = td->width; > \ > > -const int slice_start = (height * jobnr ) / nb_jobs; >\ > > -const int slice_end = (height * (jobnr+1)) / nb_jobs; >\ > > -const int radius = FFMIN(s->radius, width / 2); >\ > > -const int linesize = td->linesize / sizeof(type); >\ > > -float *buffer = s->buffer; > \ > > -const type *src; > \ > > -float *ptr; >\ > > -int y, x; >\ > > - > \ > > -/* Filter horizontally along each row */ > \ > > -for (y = slice_start; y < slice_end; y++) { >\ > > -float acc = 0; > \ > > -int count = 0; > \ > > - > \ > > -src = (const type *)td->ptr + linesize * y; >\ > > -ptr = buffer + width * y; >\ > > - > \ > > -for (x = 0; x < radius; x++) { > \ > > -acc += src[x]; > \ > > -} >\ > > -count += radius; > \ > > - > \ > > -for (x = 0; x <= radius; x++) { >\ > > -acc += src[x + radius]; >\ > > -count++; > \ > > -ptr[x] = acc / count; >\ > > -} >\ > > - > \ > > -for (; x < width - radius; x++) { >\ > > -acc += src[x + radius] - src[x - radius - 1]; >\ > > -ptr[x] = acc / count; >\ > > -} >\ > > - > \ > > -for (; x < width; x++) { > \ > > -acc -= src[x - radius]; >\ > > -count--; > \ > > -ptr[x] = acc / count; >\ > > -} >\ > > -} >\ > > - > \ > > -return 0; >\ > > +#define LUT_DIV(sum, area) (lut[(sum)]) > > +#define SLOW_DIV(sum, area) ((sum) / (area)) > > + > > +#define FILTER(name, type, btype, lutunused, areaunused, lutdiv) > \ > > +static int filter_##name(AVFilterContext *ctx, void *arg, int jobnr, > int nb_jobs) \ > > +{ >\ > > +AverageBlurContext *s = ctx->priv; > \ > > +ThreadData *td = arg; >\ > > +areaunused const int area = s->area; > \ > > +lutu
Re: [FFmpeg-devel] [PATCH v1 1/1] avformat/amr: Return PATCHWELCOME on stereo files
On Thu, Sep 16, 2021 at 11:24 AM sunzhenliang wrote: > > Signed-off-by: sunzhenliang > --- > libavformat/amr.c | 22 ++ > 1 file changed, 18 insertions(+), 4 deletions(-) > > diff --git a/libavformat/amr.c b/libavformat/amr.c > index 836b276fd5..2762010ebe 100644 > --- a/libavformat/amr.c > +++ b/libavformat/amr.c > @@ -36,8 +36,10 @@ typedef struct { > uint64_t block_count; > } AMRContext; > > -static const char AMR_header[] = "#!AMR\n"; > -static const char AMRWB_header[] = "#!AMR-WB\n"; > +static const char AMR_header[] = "#!AMR\n"; > +static const char AMR_MC_header[] = "#!AMR_MC1.0\n"; > +static const char AMRWB_header[]= "#!AMR-WB\n"; > +static const char AMRWB_MC_header[] = "#!AMR-WB_MC1.0\n"; I don't think you need to format the AMR_header[] and AMRWB_header[] in the patch > > static const uint8_t amrnb_packed_size[16] = { > 13, 14, 16, 18, 20, 21, 27, 32, 6, 1, 1, 1, 1, 1, 1, 1 > @@ -82,7 +84,7 @@ static int amr_read_header(AVFormatContext *s) > { > AVIOContext *pb = s->pb; > AVStream *st; > -uint8_t header[9]; > +uint8_t header[15]; > > if (avio_read(pb, header, 6) != 6) > return AVERROR_INVALIDDATA; > @@ -94,7 +96,19 @@ static int amr_read_header(AVFormatContext *s) > if (avio_read(pb, header + 6, 3) != 3) > return AVERROR_INVALIDDATA; > if (memcmp(header, AMRWB_header, 9)) { > -return -1; > +if (avio_read(pb, header + 6 + 3, 3) != 3) > +return AVERROR_INVALIDDATA; > +if (memcmp(header, AMR_MC_header, 12)) { > +if (avio_read(pb, header + 6 + 3 + 3, 3) != 3) > +return AVERROR_INVALIDDATA; > +if (memcmp(header, AMRWB_MC_header, 15)) { > +return -1; > +} > +avpriv_report_missing_feature(s, "multi-channel AMRWB"); > +return AVERROR_PATCHWELCOME; > +} > +avpriv_report_missing_feature(s, "multi-channel AMR"); > +return AVERROR_PATCHWELCOME; > } > > st->codecpar->codec_tag = MKTAG('s', 'a', 'w', 'b'); > -- > 2.25.1 > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1] avfilter/vf_avgblur: switch to faster algorithm
On Sun, Sep 26, 2021 at 8:11 PM Paul B Mahol wrote: > > On Sun, Sep 26, 2021 at 1:27 PM myp...@gmail.com wrote: > > > On Sun, Sep 26, 2021 at 4:11 PM Paul B Mahol wrote: > > > > > > Signed-off-by: Paul B Mahol > > > --- > > > libavfilter/vf_avgblur.c | 311 ++ > > > tests/ref/fate/filter-refcmp-psnr-yuv | 80 +++ > > > 2 files changed, 211 insertions(+), 180 deletions(-) > > > > > > diff --git a/libavfilter/vf_avgblur.c b/libavfilter/vf_avgblur.c > > > index 3e222a43fa..a838285bb4 100644 > > > --- a/libavfilter/vf_avgblur.c > > > +++ b/libavfilter/vf_avgblur.c > > > @@ -20,6 +20,7 @@ > > > * SOFTWARE. > > > */ > > > > > > +#include "libavutil/avassert.h" > > > #include "libavutil/imgutils.h" > > > #include "libavutil/opt.h" > > > #include "libavutil/pixdesc.h" > > > @@ -36,13 +37,15 @@ typedef struct AverageBlurContext { > > > int planes; > > > > > > int depth; > > > +int max; > > > +int area; > > > int planewidth[4]; > > > int planeheight[4]; > > > -float *buffer; > > > +void *buffer; > > > +uint16_t lut[256 * 256 * 256]; > > > int nb_planes; > > > > > > -int (*filter_horizontally)(AVFilterContext *ctx, void *arg, int > > jobnr, int nb_jobs); > > > -int (*filter_vertically)(AVFilterContext *ctx, void *arg, int > > jobnr, int nb_jobs); > > > +int (*filter[2])(AVFilterContext *ctx, void *arg, int jobnr, int > > nb_jobs); > > > } AverageBlurContext; > > > > > > #define OFFSET(x) offsetof(AverageBlurContext, x) > > > @@ -60,124 +63,138 @@ AVFILTER_DEFINE_CLASS(avgblur); > > > typedef struct ThreadData { > > > int height; > > > int width; > > > -uint8_t *ptr; > > > -int linesize; > > > +const void *ptr; > > > +void *dptr; > > > +int linesize, dlinesize; > > > } ThreadData; > > > > > > -#define HORIZONTAL_FILTER(name, type) > >\ > > > -static int filter_horizontally_##name(AVFilterContext *ctx, void *arg, > > int jobnr, int nb_jobs)\ > > > -{ > >\ > > > -AverageBlurContext *s = ctx->priv; > > \ > > > -ThreadData *td = arg; > >\ > > > -const int height = td->height; > > \ > > > -const int width = td->width; > > \ > > > -const int slice_start = (height * jobnr ) / nb_jobs; > >\ > > > -const int slice_end = (height * (jobnr+1)) / nb_jobs; > >\ > > > -const int radius = FFMIN(s->radius, width / 2); > >\ > > > -const int linesize = td->linesize / sizeof(type); > >\ > > > -float *buffer = s->buffer; > > \ > > > -const type *src; > > \ > > > -float *ptr; > >\ > > > -int y, x; > >\ > > > - > > \ > > > -/* Filter horizontally along each row */ > > \ > > > -for (y = slice_start; y < slice_end; y++) { > >\ > > > -float acc = 0; > > \ > > > -int count = 0; > > \ > > > - > > \ > > > -src = (const type *)td->ptr + linesize * y; > >\ > > > -ptr = buffer + width * y; > >\ > > > - > > \ > > > -for (x = 0; x < radius; x++) { > > \ > > > -acc += src[x]; > > \ > > > -} > >\ > > > -count += radius; > > \ > > > - > > \ > > > -for (x = 0; x <= radius; x++) { > >\ > > > -acc += src[x + radius]; > >\ > > > -count++; > > \ > > > -ptr[x] = acc / count; > >\ > > > -} > >\ > > > - > > \ > > > -for (; x < width - radius; x++) { > >\ > > > -acc += src[x + radius] - src[x - radius - 1]; > >\ > > > -ptr[x] = acc / count; > >\ > > > -} > >\ > > > - > > \ > > > -for (; x < width; x++) { > > \ > > > -acc -= src[x - radius]; > >\ > > > -count--; > > \ > > > -ptr[x] = acc / count; > >\ > > > -} > >\ > > > -} > >\ > > > - > > \ > > > -return 0; > >\ > > > +#define LUT_DIV(sum, area) (lut[(sum)]) > > > +#define SLOW_DIV(sum, area) ((sum) / (area)) > > > + > > > +#defi
[FFmpeg-devel] [PATCH] avcodec/videotoolboxenc: Fixes non-B-Frame encoding
Sets vtctx->has_b_frames to 0 if the VideoToolbox compression session will not emit B-frames (and, in consequence, no valid DTSs). Required for the handling of invalid DTSs in 'vtenc_cm_to_avpacket' (line 2018ff) to work correctly and not abort encoding with "DTS is invalid." when no B-frames are generated. Signed-off-by: NoHalfBits --- libavcodec/videotoolboxenc.c | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 8dfd6e3d0c..93c3898fb5 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -1516,7 +1516,10 @@ static av_cold int vtenc_init(AVCodecContext *avctx) if (!status && has_b_frames_cfbool) { //Some devices don't output B-frames for main profile, even if requested. // HEVC has b-pyramid -vtctx->has_b_frames = (CFBooleanGetValue(has_b_frames_cfbool) && avctx->codec_id == AV_CODEC_ID_HEVC) ? 2 : 1; +if (CFBooleanGetValue(has_b_frames_cfbool)) +vtctx->has_b_frames = avctx->codec_id == AV_CODEC_ID_HEVC ? 2 : 1; +else +vtctx->has_b_frames = 0; CFRelease(has_b_frames_cfbool); } avctx->has_b_frames = vtctx->has_b_frames; -- 2.30.1 (Apple Git-130) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avutil/utils: Remove racy check from avutil_version()
On 9/26/2021 6:46 AM, Andreas Rheinhardt wrote: avutil_version() currently performs several checks before just returning the version. There is a static int that aims to ensure that these tests are run only once. The reason is that there used to be a slightly expensive check, but it has been removed in 92e3a6fdac73f7e1d69d69717219a7538877d7a0. Today running only once is unnecessary and can be counterproductive: GCC 10 optimizes all the actual checks away, but the checks_done variable and the code setting it has been kept. Given that this check is inherently racy (it uses non-atomic variables), it is best to just remove it. Signed-off-by: Andreas Rheinhardt --- A part of me just wants to nuke all those checks. (We have zero callers of avutil_version() in the codebase and I don't see a reason why external users should call it more often, so all those checks probably don't fulfill their aim.) We could replace them with C11's _Static_assert (Making sure that for C99 compilers like msvc it just becomes av_assert0). That way they will trigger at compilation time instead, which is more in line to what they were added for. libavutil/utils.c | 5 - 1 file changed, 5 deletions(-) diff --git a/libavutil/utils.c b/libavutil/utils.c index c1cd452eee..ea9b5097b8 100644 --- a/libavutil/utils.c +++ b/libavutil/utils.c @@ -37,10 +37,6 @@ const char *av_version_info(void) unsigned avutil_version(void) { -static int checks_done; -if (checks_done) -return LIBAVUTIL_VERSION_INT; - av_assert0(AV_SAMPLE_FMT_DBLP == 9); av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4); av_assert0(AV_PICTURE_TYPE_BI == 7); @@ -58,7 +54,6 @@ unsigned avutil_version(void) av_log(NULL, AV_LOG_ERROR, "Libavutil has been linked to a broken llrint()\n"); } -checks_done = 1; return LIBAVUTIL_VERSION_INT; } ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avutil/utils: Remove racy check from avutil_version()
James Almer: > On 9/26/2021 6:46 AM, Andreas Rheinhardt wrote: >> avutil_version() currently performs several checks before >> just returning the version. There is a static int that aims >> to ensure that these tests are run only once. The reason is that >> there used to be a slightly expensive check, but it has been removed >> in 92e3a6fdac73f7e1d69d69717219a7538877d7a0. Today running only >> once is unnecessary and can be counterproductive: GCC 10 optimizes >> all the actual checks away, but the checks_done variable and the code >> setting it has been kept. Given that this check is inherently racy >> (it uses non-atomic variables), it is best to just remove it. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> A part of me just wants to nuke all those checks. >> (We have zero callers of avutil_version() in the codebase and >> I don't see a reason why external users should call it more often, >> so all those checks probably don't fulfill their aim.) > > We could replace them with C11's _Static_assert (Making sure that for > C99 compilers like msvc it just becomes av_assert0). That way they will > trigger at compilation time instead, which is more in line to what they > were added for. > It is not guaranteed that this works for the llrint and the av_sat_dadd32 check, because a static assert requires a constant expression; and it makes no sense to ever use av_assert0(0) for those checks that can be done at compile-time, as there already is a way to emulate static asserts in pre-C11 C: Declare an array (a type is enough) with a negative number of elements in case of failure. See AV_CHECK_OFFSET. >> >> libavutil/utils.c | 5 - >> 1 file changed, 5 deletions(-) >> >> diff --git a/libavutil/utils.c b/libavutil/utils.c >> index c1cd452eee..ea9b5097b8 100644 >> --- a/libavutil/utils.c >> +++ b/libavutil/utils.c >> @@ -37,10 +37,6 @@ const char *av_version_info(void) >> unsigned avutil_version(void) >> { >> - static int checks_done; >> - if (checks_done) >> - return LIBAVUTIL_VERSION_INT; >> - >> av_assert0(AV_SAMPLE_FMT_DBLP == 9); >> av_assert0(AVMEDIA_TYPE_ATTACHMENT == 4); >> av_assert0(AV_PICTURE_TYPE_BI == 7); >> @@ -58,7 +54,6 @@ unsigned avutil_version(void) >> av_log(NULL, AV_LOG_ERROR, "Libavutil has been linked to a >> broken llrint()\n"); >> } >> - checks_done = 1; >> return LIBAVUTIL_VERSION_INT; >> } >> ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v3 2/5] avformat/matroskadec: Parse dvcC/dvvC block additional mapping
On 26/09/2021 07.13, myp...@gmail.com wrote: On Sat, Sep 25, 2021 at 11:58 PM quietvoid wrote: The parsing was implemented in a new dovi_isom file for the unification of the mov/mpegts DOVI parsing into one function, in a following patch. Most of the Matroska elements implementation was done by Plex developers. Signed-off-by: quietvoid --- libavformat/Makefile | 2 +- libavformat/dovi_isom.c | 80 +++ libavformat/dovi_isom.h | 29 ++ libavformat/matroskadec.c | 15 4 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 libavformat/dovi_isom.c create mode 100644 libavformat/dovi_isom.h diff --git a/libavformat/Makefile b/libavformat/Makefile index c45caa3eed..61a1fecf6c 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -313,7 +313,7 @@ OBJS-$(CONFIG_M4V_MUXER) += rawenc.o OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \ flac_picture.o isom_tags.o rmsipr.o \ oggparsevorbis.o vorbiscomment.o \ -qtpalette.o replaygain.o +qtpalette.o replaygain.o dovi_isom.o OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \ av1.o avc.o hevc.o isom_tags.o \ flacenc_header.o avlanguage.o \ diff --git a/libavformat/dovi_isom.c b/libavformat/dovi_isom.c new file mode 100644 index 00..2c0a49c993 --- /dev/null +++ b/libavformat/dovi_isom.c @@ -0,0 +1,80 @@ +/* + * DOVI ISO Media common code + * Copyright (c) 2021 quietvoid + * + * 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 "libavutil/dovi_meta.h" + +#include "avformat.h" +#include "dovi_isom.h" + +int ff_isom_parse_dvcc_dvvc(AVFormatContext *s, AVStream *st, const uint8_t *buf_ptr, uint64_t size) +{ +uint32_t buf; +AVDOVIDecoderConfigurationRecord *dovi; +size_t dovi_size; +int ret; + +if (size > (1 << 30) || size < 4) +return AVERROR_INVALIDDATA; + +dovi = av_dovi_alloc(&dovi_size); +if (!dovi) +return AVERROR(ENOMEM); + +dovi->dv_version_major = *buf_ptr++;// 8 bits +dovi->dv_version_minor = *buf_ptr++;// 8 bits + +buf = *buf_ptr++ << 8; +buf |= *buf_ptr++; + +dovi->dv_profile= (buf >> 9) & 0x7f;// 7 bits +dovi->dv_level = (buf >> 3) & 0x3f;// 6 bits +dovi->rpu_present_flag = (buf >> 2) & 0x01;// 1 bit +dovi->el_present_flag = (buf >> 1) & 0x01;// 1 bit +dovi->bl_present_flag = buf & 0x01;// 1 bit + +// Has enough remaining data +if (size >= 5) { +dovi->dv_bl_signal_compatibility_id = ((*buf_ptr++) >> 4) & 0x0f; // 4 bits +} else { +// 0 stands for None +// Dolby Vision V1.2.93 profiles and levels +dovi->dv_bl_signal_compatibility_id = 0; +} + +ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, + (uint8_t *)dovi, dovi_size); +if (ret < 0) { +av_free(dovi); +return ret; +} + +av_log(s, AV_LOG_TRACE, "DOVI, version: %d.%d, profile: %d, level: %d, " + "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", + dovi->dv_version_major, dovi->dv_version_minor, + dovi->dv_profile, dovi->dv_level, + dovi->rpu_present_flag, + dovi->el_present_flag, + dovi->bl_present_flag, + dovi->dv_bl_signal_compatibility_id +); + +return 0; +} diff --git a/libavformat/dovi_isom.h b/libavformat/dovi_isom.h new file mode 100644 index 00..4c313046a7 --- /dev/null +++ b/libavformat/dovi_isom.h @@ -0,0 +1,29 @@ +/* + * DOVI ISO Media common code + * Copyright (c) 2021 quietvoid + * + * 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. + * + * F
Re: [FFmpeg-devel] [PATCH v4 3/3] swscale: add input/output support for X2BGR10LE
On Fri, Sep 24, 2021 at 07:09:15PM -0400, Manuel Stoeckl wrote: > Signed-off-by: Manuel Stoeckl > --- > This is the same as PATCH v3 3/3 of the same name, except with the > filter-pixdesc-x2bgr10le test reference value fixed. (My local ffmpeg > copy sometimes fails to set up and run the filter-pixdesc-* tests, so I > missed this.) > > libswscale/input.c | 15 +-- > libswscale/output.c | 9 - > libswscale/utils.c | 1 + > libswscale/yuv2rgb.c | 9 ++--- > tests/ref/fate/filter-pixdesc-x2bgr10le | 1 + > tests/ref/fate/filter-pixfmts-copy | 1 + > tests/ref/fate/filter-pixfmts-crop | 1 + > tests/ref/fate/filter-pixfmts-field | 1 + > tests/ref/fate/filter-pixfmts-fieldorder | 1 + > tests/ref/fate/filter-pixfmts-hflip | 1 + > tests/ref/fate/filter-pixfmts-il | 1 + > tests/ref/fate/filter-pixfmts-null | 1 + > tests/ref/fate/filter-pixfmts-pad| 1 + > tests/ref/fate/filter-pixfmts-scale | 1 + > tests/ref/fate/filter-pixfmts-transpose | 1 + > tests/ref/fate/filter-pixfmts-vflip | 1 + > 16 files changed, 40 insertions(+), 6 deletions(-) > create mode 100644 tests/ref/fate/filter-pixdesc-x2bgr10le will apply patchset thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The day soldiers stop bringing you their problems is the day you have stopped leading them. They have either lost confidence that you can help or concluded you do not care. Either case is a failure of leadership. - Colin Powell signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] avcodec/utils: ARGO writes 4x4 blocks without regard to the image dimensions
On Fri, Sep 03, 2021 at 08:39:10PM +0200, Michael Niedermayer wrote: > Fixes: out of array access > Fixes: > 37197/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ARGO_fuzzer-5877046382297088 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/utils.c | 6 ++ > 1 file changed, 6 insertions(+) will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 "Used only once"- "Some unspecified defect prevented a second use" "In good condition" - "Can be repaird by experienced expert" "As is" - "You wouldnt want it even if you were payed for it, if you knew ..." signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/3] avcodec/mxpegdec: Check for AVDISCARD_ALL
On Tue, Sep 14, 2021 at 10:58:18PM +0200, Michael Niedermayer wrote: > Fixes: Fixes NULL pointer dereference > Fixes: > 36610/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MXPEG_fuzzer-6052641783283712 > Fixes: > 37907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MXPEG_fuzzer-4725170850365440 > Fixes: > 37904/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MXPEG_fuzzer-6367889262247936 > Fixes: > 38085/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MXPEG_fuzzer-5175270823297024 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/mxpegdec.c | 3 +++ > 1 file changed, 3 insertions(+) will apply patchset [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 5/5] avformat/mov: Fix last mfra check
On Wed, Sep 15, 2021 at 10:00:48PM +0200, Michael Niedermayer wrote: > Fixes: signed integer overflow: 9223372036854775360 + 536870912 cannot be > represented in type 'long' > Fixes: > 37940/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-6095637855207424 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavformat/mov.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/5] tools/target_dec_fuzzer: Adjust threshold for WMV2
On Wed, Sep 15, 2021 at 10:00:45PM +0200, Michael Niedermayer wrote: > Fixes: Timeout > Fixes: > 37737/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV2_fuzzer-4923012999151616 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > tools/target_dec_fuzzer.c | 1 + > 1 file changed, 1 insertion(+) will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When the tyrant has disposed of foreign enemies by conquest or treaty, and there is nothing more to fear from them, then he is always stirring up some war or other, in order that the people may require a leader. -- Plato signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 3/4] avcodec/apedec: Fix integer overflow in filter_fast_3320()
On Fri, Sep 17, 2021 at 09:56:15PM +0200, Michael Niedermayer wrote: > Fixes: signed integer overflow: 2145649668 + 3956526 cannot be represented in > type 'int' > Fixes: > 38351/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-4647077926273024 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/apedec.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) will apply [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Asymptotically faster algorithms should always be preferred if you have asymptotical amounts of data signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/avio{, buf}: introduce public AVIOContext::bytes_read
Such a field can be seen as generally useful in cases where the API user is not implementing custom AVIO callbacks, but still would like to know if data is being read even if AVPackets are not being returned. --- Originally I thought about making an accessor for the private field, to not grow the public struct's size (and have a duplicate field, as well as making sure the value was read-only). But an objection was raised that such accessors should be refrained from as they unnecessarily filled the function symbol space or so. Together with the objection, a proposal of making it a field on the public struct that was only written to was proposed. This patch follows that proposal. doc/APIchanges| 3 +++ libavformat/avio.h| 5 + libavformat/aviobuf.c | 2 ++ libavformat/version.h | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 7b267a79ac..6a8cf8ea15 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-09-26 - xx - lavf 59.6.100 - avio.h + Introduce a public bytes_read statistic field to AVIOContext. + 2021-09-21 - xx - lavu 57.7.100 - pixfmt.h Add AV_PIX_FMT_X2BGR10. diff --git a/libavformat/avio.h b/libavformat/avio.h index a7b56ab667..2cfb548231 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -297,6 +297,11 @@ typedef struct AVIOContext { * used keeping track of already written data for a later flush. */ unsigned char *buf_ptr_max; + +/** + * Read-only statistic of bytes read for this AVIOContext. + */ +int64_t bytes_read; } AVIOContext; /** diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index d79e41ca77..33825ade73 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -572,6 +572,7 @@ static void fill_buffer(AVIOContext *s) s->buf_ptr = dst; s->buf_end = dst + len; ffiocontext(s)->bytes_read += len; +s->bytes_read = ffiocontext(s)->bytes_read; } } @@ -645,6 +646,7 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size) } else { s->pos += len; ffiocontext(s)->bytes_read += len; +s->bytes_read = ffiocontext(s)->bytes_read; size -= len; buf += len; // reset the buffer diff --git a/libavformat/version.h b/libavformat/version.h index 13df244d97..d5dd22059b 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 59 -#define LIBAVFORMAT_VERSION_MINOR 5 +#define LIBAVFORMAT_VERSION_MINOR 6 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ -- 2.31.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/isom: enable TTML demuxing from MP4-likes
As ff_codec_movsubtitle_tags is shared between demuxing and muxing, the muxing parts have to go in before demuxing in order to not generate invalid media, as adding an identifier to this list enables muxing into QTFF/MOV. --- libavformat/isom.c | 2 ++ tests/ref/fate/mov-mp4-ttml-dfxp | 10 ++ tests/ref/fate/mov-mp4-ttml-stpp | 10 ++ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libavformat/isom.c b/libavformat/isom.c index 4df5440023..852d237481 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -77,6 +77,8 @@ const AVCodecTag ff_codec_movsubtitle_tags[] = { { AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'e', 'x', 't') }, { AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'x', '3', 'g') }, { AV_CODEC_ID_EIA_608, MKTAG('c', '6', '0', '8') }, +{ AV_CODEC_ID_TTML, MOV_MP4_TTML_TAG }, +{ AV_CODEC_ID_TTML, MOV_ISMV_TTML_TAG }, { AV_CODEC_ID_NONE, 0 }, }; diff --git a/tests/ref/fate/mov-mp4-ttml-dfxp b/tests/ref/fate/mov-mp4-ttml-dfxp index e24b5d618b..531d6856ec 100644 --- a/tests/ref/fate/mov-mp4-ttml-dfxp +++ b/tests/ref/fate/mov-mp4-ttml-dfxp @@ -1,13 +1,14 @@ 2e7e01c821c111466e7a2844826b7f6d *tests/data/fate/mov-mp4-ttml-dfxp.mp4 8519 tests/data/fate/mov-mp4-ttml-dfxp.mp4 +#extradata 0: 20, 0x1dfc0302 #tb 0: 1/1000 -#media_type 0: data -#codec_id 0: none +#media_type 0: subtitle +#codec_id 0: ttml 0, 0, 0,68500, 7866, 0x456c36b7 { "packets": [ { -"codec_type": "data", +"codec_type": "subtitle", "stream_index": 0, "pts": 0, "pts_time": "0.00", @@ -26,7 +27,8 @@ "streams": [ { "index": 0, -"codec_type": "data", +"codec_name": "ttml", +"codec_type": "subtitle", "codec_tag_string": "dfxp", "codec_tag": "0x70786664", "time_base": "1/1000", diff --git a/tests/ref/fate/mov-mp4-ttml-stpp b/tests/ref/fate/mov-mp4-ttml-stpp index 77bd23b7bf..7c03ef92cc 100644 --- a/tests/ref/fate/mov-mp4-ttml-stpp +++ b/tests/ref/fate/mov-mp4-ttml-stpp @@ -1,13 +1,14 @@ cbd2c7ff864a663b0d893deac5a0caec *tests/data/fate/mov-mp4-ttml-stpp.mp4 8547 tests/data/fate/mov-mp4-ttml-stpp.mp4 +#extradata 0: 48, 0x62100c0d #tb 0: 1/1000 -#media_type 0: data -#codec_id 0: none +#media_type 0: subtitle +#codec_id 0: ttml 0, 0, 0,68500, 7866, 0x456c36b7 { "packets": [ { -"codec_type": "data", +"codec_type": "subtitle", "stream_index": 0, "pts": 0, "pts_time": "0.00", @@ -26,7 +27,8 @@ cbd2c7ff864a663b0d893deac5a0caec *tests/data/fate/mov-mp4-ttml-stpp.mp4 "streams": [ { "index": 0, -"codec_type": "data", +"codec_name": "ttml", +"codec_type": "subtitle", "codec_tag_string": "stpp", "codec_tag": "0x70707473", "time_base": "1/1000", -- 2.31.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avfilter/elbg: Extend filter to include alpha values in the quantization procedure
On Sun, Sep 26, 2021 at 04:57:25AM +, Soft Works wrote: > Usage example: > > ffmpeg -y -loglevel verbose -i "..\fate-suite\apng\o_sample.png" > -filter_complex "elbg=pal8=1:use_alpha=1" -frames:v 1 out.png > > Signed-off-by: softworkz > --- > doc/filters.texi | 4 > libavfilter/vf_elbg.c | 25 - > 2 files changed, 20 insertions(+), 9 deletions(-) will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Those who are best at talking, realize last or never when they are wrong. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avfilter/palettegen, paletteuse: Extend the palette conversion filters to support palettes with alpha
On Sun, Sep 26, 2021 at 12:43:37AM +, Soft Works wrote: > Usage example: > > ffmpeg -y -loglevel verbose -i "..\fate-suite\apng\o_sample.png" > -filter_complex > "split[split1][split2];[split1]palettegen=max_colors=254:use_alpha=1[pal1];[split2][pal1]paletteuse=use_alpha=1" > -frames:v 1 out.png > > Signed-off-by: softworkz > --- > doc/filters.texi| 8 ++ > libavfilter/vf_palettegen.c | 140 ++ > libavfilter/vf_paletteuse.c | 225 +--- > 3 files changed, 233 insertions(+), 140 deletions(-) > > diff --git a/doc/filters.texi b/doc/filters.texi > index 36113e5c4b..7e4806235c 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -16454,6 +16454,9 @@ Compute new histogram for each frame. > @end table > > Default value is @var{full}. > +@item use_alpha > +Create a palette of colors with alpha components. > +Setting this, will automatically disable 'reserve_transparent'. > @end table > > The filter also exports the frame metadata @code{lavfi.color_quant_ratio} > @@ -16532,6 +16535,11 @@ will be treated as completely opaque, and values > below this threshold will be > treated as completely transparent. > > The option must be an integer value in the range [0,255]. Default is > @var{128}. > + > +@item use_alpha > +Apply the palette by taking alpha values into account. Only useful with > +palettes that are containing multiple colors with alpha components. > +Setting this will automatically disable 'alpha_treshold'. > @end table > > @subsection Examples > diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c > index 4c2fbd36d7..7a74a3752f 100644 > --- a/libavfilter/vf_palettegen.c > +++ b/libavfilter/vf_palettegen.c > @@ -59,7 +59,7 @@ enum { > }; > > #define NBITS 5 > -#define HIST_SIZE (1<<(3*NBITS)) > +#define HIST_SIZE (1<<(4*NBITS)) > > typedef struct PaletteGenContext { > const AVClass *class; > @@ -67,6 +67,7 @@ typedef struct PaletteGenContext { > int max_colors; > int reserve_transparent; > int stats_mode; > +int use_alpha; > > AVFrame *prev_frame;// previous frame used for the > diff stats_mode > struct hist_node histogram[HIST_SIZE]; // histogram/hashtable of the > colors > @@ -88,6 +89,7 @@ static const AVOption palettegen_options[] = { > { "full", "compute full frame histograms", 0, AV_OPT_TYPE_CONST, > {.i64=STATS_MODE_ALL_FRAMES}, INT_MIN, INT_MAX, FLAGS, "mode" }, > { "diff", "compute histograms only for the part that differs from > previous frame", 0, AV_OPT_TYPE_CONST, {.i64=STATS_MODE_DIFF_FRAMES}, > INT_MIN, INT_MAX, FLAGS, "mode" }, > { "single", "compute new histogram for each frame", 0, > AV_OPT_TYPE_CONST, {.i64=STATS_MODE_SINGLE_FRAMES}, INT_MIN, INT_MAX, FLAGS, > "mode" }, > +{ "use_alpha", "create a palette including alpha values", > OFFSET(use_alpha), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, > { NULL } > }; > > @@ -113,15 +115,16 @@ static int cmp_##name(const void *pa, const void *pb) > \ > { \ > const struct color_ref * const *a = pa; \ > const struct color_ref * const *b = pb; \ > -return (int)((*a)->color >> (8 * (2 - (pos))) & 0xff) \ > - - (int)((*b)->color >> (8 * (2 - (pos))) & 0xff); \ > +return (int)((*a)->color >> (8 * (3 - (pos))) & 0xff) \ > + - (int)((*b)->color >> (8 * (3 - (pos))) & 0xff); \ > } > > -DECLARE_CMP_FUNC(r, 0) > -DECLARE_CMP_FUNC(g, 1) > -DECLARE_CMP_FUNC(b, 2) > +DECLARE_CMP_FUNC(a, 0) > +DECLARE_CMP_FUNC(r, 1) > +DECLARE_CMP_FUNC(g, 2) > +DECLARE_CMP_FUNC(b, 3) > > -static const cmp_func cmp_funcs[] = {cmp_r, cmp_g, cmp_b}; > +static const cmp_func cmp_funcs[] = {cmp_a, cmp_r, cmp_g, cmp_b}; > > /** > * Simple color comparison for sorting the final palette > @@ -143,6 +146,17 @@ static av_always_inline int diff(const uint32_t a, const > uint32_t b) > return dr*dr + dg*dg + db*db; > } > > +static av_always_inline int diff_alpha(const uint32_t a, const uint32_t b) > +{ > +const uint8_t c1[] = {a >> 24 & 0xff, a >> 16 & 0xff, a >> 8 & 0xff, a & > 0xff}; > +const uint8_t c2[] = {b >> 24 & 0xff, b >> 16 & 0xff, b >> 8 & 0xff, b & > 0xff}; > +const int da = c1[0] - c2[0]; > +const int dr = c1[1] - c2[1]; > +const int dg = c1[2] - c2[2]; > +const int db = c1[3] - c2[3]; > +return da*da + dr*dr + dg*dg + db*db; > +} > + > /** > * Find the next box to split: pick the one with the highest variance > */ > @@ -164,7 +178,10 @@ static int get_next_box_id_to_split(PaletteGenContext *s) > > for (i = 0; i < box->len; i++) { > const struct color_ref *ref = s->refs[box->start + i]; > -variance += diff(ref->color, box->color) * ref->count; > +if (s->use_alpha) > +vari
Re: [FFmpeg-devel] [PATCH] avfilter/palettegen, paletteuse: Extend the palette conversion filters to support palettes with alpha
> -Original Message- > From: ffmpeg-devel On Behalf Of > Michael Niedermayer > Sent: Sunday, 26 September 2021 19:01 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/palettegen, paletteuse: > Extend the palette conversion filters to support palettes with alpha > > > [...] > > -const int s = kd->split; > > +const int split = kd->split; > > also unrelated to the alpha change This change is required due to the newly added parameter 's'. The context is named 's' in all other functions, that's why was required to name the previous local 's' variable. Thanks, softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/2] avfilter/palettegen, paletteuse: Extend the palette conversion filters to support palettes with alpha
Usage example: ffmpeg -y -loglevel verbose -i "..\fate-suite\apng\o_sample.png" -filter_complex "split[split1][split2];[split1]palettegen=max_colors=254:use_alpha=1[pal1];[split2][pal1]paletteuse=use_alpha=1" -frames:v 1 out.png Signed-off-by: softworkz --- doc/filters.texi| 8 ++ libavfilter/vf_palettegen.c | 136 +++--- libavfilter/vf_paletteuse.c | 225 +--- 3 files changed, 231 insertions(+), 138 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 36113e5c4b..7e4806235c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16454,6 +16454,9 @@ Compute new histogram for each frame. @end table Default value is @var{full}. +@item use_alpha +Create a palette of colors with alpha components. +Setting this, will automatically disable 'reserve_transparent'. @end table The filter also exports the frame metadata @code{lavfi.color_quant_ratio} @@ -16532,6 +16535,11 @@ will be treated as completely opaque, and values below this threshold will be treated as completely transparent. The option must be an integer value in the range [0,255]. Default is @var{128}. + +@item use_alpha +Apply the palette by taking alpha values into account. Only useful with +palettes that are containing multiple colors with alpha components. +Setting this will automatically disable 'alpha_treshold'. @end table @subsection Examples diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index 4c2fbd36d7..98dff46fe0 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -59,7 +59,7 @@ enum { }; #define NBITS 5 -#define HIST_SIZE (1<<(3*NBITS)) +#define HIST_SIZE (1<<(4*NBITS)) typedef struct PaletteGenContext { const AVClass *class; @@ -67,6 +67,7 @@ typedef struct PaletteGenContext { int max_colors; int reserve_transparent; int stats_mode; +int use_alpha; AVFrame *prev_frame;// previous frame used for the diff stats_mode struct hist_node histogram[HIST_SIZE]; // histogram/hashtable of the colors @@ -88,6 +89,7 @@ static const AVOption palettegen_options[] = { { "full", "compute full frame histograms", 0, AV_OPT_TYPE_CONST, {.i64=STATS_MODE_ALL_FRAMES}, INT_MIN, INT_MAX, FLAGS, "mode" }, { "diff", "compute histograms only for the part that differs from previous frame", 0, AV_OPT_TYPE_CONST, {.i64=STATS_MODE_DIFF_FRAMES}, INT_MIN, INT_MAX, FLAGS, "mode" }, { "single", "compute new histogram for each frame", 0, AV_OPT_TYPE_CONST, {.i64=STATS_MODE_SINGLE_FRAMES}, INT_MIN, INT_MAX, FLAGS, "mode" }, +{ "use_alpha", "create a palette including alpha values", OFFSET(use_alpha), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, { NULL } }; @@ -113,15 +115,16 @@ static int cmp_##name(const void *pa, const void *pb) \ { \ const struct color_ref * const *a = pa; \ const struct color_ref * const *b = pb; \ -return (int)((*a)->color >> (8 * (2 - (pos))) & 0xff) \ - - (int)((*b)->color >> (8 * (2 - (pos))) & 0xff); \ +return (int)((*a)->color >> (8 * (3 - (pos))) & 0xff) \ + - (int)((*b)->color >> (8 * (3 - (pos))) & 0xff); \ } -DECLARE_CMP_FUNC(r, 0) -DECLARE_CMP_FUNC(g, 1) -DECLARE_CMP_FUNC(b, 2) +DECLARE_CMP_FUNC(a, 0) +DECLARE_CMP_FUNC(r, 1) +DECLARE_CMP_FUNC(g, 2) +DECLARE_CMP_FUNC(b, 3) -static const cmp_func cmp_funcs[] = {cmp_r, cmp_g, cmp_b}; +static const cmp_func cmp_funcs[] = {cmp_a, cmp_r, cmp_g, cmp_b}; /** * Simple color comparison for sorting the final palette @@ -143,6 +146,17 @@ static av_always_inline int diff(const uint32_t a, const uint32_t b) return dr*dr + dg*dg + db*db; } +static av_always_inline int diff_alpha(const uint32_t a, const uint32_t b) +{ +const uint8_t c1[] = {a >> 24 & 0xff, a >> 16 & 0xff, a >> 8 & 0xff, a & 0xff}; +const uint8_t c2[] = {b >> 24 & 0xff, b >> 16 & 0xff, b >> 8 & 0xff, b & 0xff}; +const int da = c1[0] - c2[0]; +const int dr = c1[1] - c2[1]; +const int dg = c1[2] - c2[2]; +const int db = c1[3] - c2[3]; +return da*da + dr*dr + dg*dg + db*db; +} + /** * Find the next box to split: pick the one with the highest variance */ @@ -164,7 +178,10 @@ static int get_next_box_id_to_split(PaletteGenContext *s) for (i = 0; i < box->len; i++) { const struct color_ref *ref = s->refs[box->start + i]; -variance += diff(ref->color, box->color) * ref->count; +if (s->use_alpha) +variance += (int64_t)diff_alpha(ref->color, box->color) * ref->count; +else +variance += (int64_t)diff(ref->color, box->color) * ref->count; } box->variance = variance; } @@ -184,24 +201,31 @@ static int get_next_box_id_to_split(Palett
[FFmpeg-devel] [PATCH v2 2/2] avfilter/palettegen: Cosmetic changes
Signed-off-by: softworkz --- libavfilter/vf_palettegen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c index 98dff46fe0..7a74a3752f 100644 --- a/libavfilter/vf_palettegen.c +++ b/libavfilter/vf_palettegen.c @@ -266,7 +266,7 @@ static void write_palette(AVFilterContext *ctx, AVFrame *out) if (box_id < s->nb_boxes) { pal[x] = s->boxes[box_id++].color; if ((x || y) && pal[x] == last_color) -av_log(ctx, AV_LOG_WARNING, "Dupped color: %08"PRIX32"\n", pal[x]); +av_log(ctx, AV_LOG_WARNING, "Duped color: %08"PRIX32"\n", pal[x]); last_color = pal[x]; } else { pal[x] = last_color; // pad with last color @@ -438,7 +438,7 @@ static inline unsigned color_hash(uint32_t color, int use_alpha) return a << (NBITS * 3) | r << (NBITS * 2) | g << NBITS | b; } -return r<<(NBITS*2) | g
Re: [FFmpeg-devel] [PATCH] avfilter/palettegen, paletteuse: Extend the palette conversion filters to support palettes with alpha
> -Original Message- > From: ffmpeg-devel On Behalf Of > Michael Niedermayer > Sent: Sunday, 26 September 2021 19:01 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/palettegen, paletteuse: > Extend the palette conversion filters to support palettes with alpha > A general coding question on the use of the comma operator: if (dx <= 0) nearer_kd_id = kd->left_id, further_kd_id = kd->right_id; else nearer_kd_id = kd->right_id, further_kd_id = kd->left_id; I was tempted to change this, but I'm not sure how it is considered by the developers here? softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avfilter/elbg: Extend filter to include alpha values in the quantization procedure
> -Original Message- > From: ffmpeg-devel On Behalf Of > Michael Niedermayer > Sent: Sunday, 26 September 2021 18:52 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH] avfilter/elbg: Extend filter to > include alpha values in the quantization procedure > > On Sun, Sep 26, 2021 at 04:57:25AM +, Soft Works wrote: > > Usage example: > > > > ffmpeg -y -loglevel verbose -i "..\fate-suite\apng\o_sample.png" - > filter_complex "elbg=pal8=1:use_alpha=1" -frames:v 1 out.png > > > > Signed-off-by: softworkz > > --- > > doc/filters.texi | 4 > > libavfilter/vf_elbg.c | 25 - > > 2 files changed, 20 insertions(+), 9 deletions(-) > > will apply Thank you. Please allow me another note: I think the naming of this filter is terrible. I've gone through the list of all ffmpeg filters many more times than the typical user, but without the specific pointers I had gotten from you and a few other devs, I would have never identified the "elbg" filter as something that would do what I'm looking for. Given the great results that this algorithm can provide, it's a bit sad when this filter would remain to be a widely unknown hidden gem in the future. No matter whether, 'posterize', 'color_quantize', 'elbg_palettize' - everything would be better than 'elbg'... Kind regards, softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/1] libavformat/rtmp: Implements RTMP reconnect feature
Nowadays when you are streaming to a live platform if the RTMP(s) server needs to restarted for any reason (ex: deploy new version) the RTMP connection is interrupted (probably after some draining time). Facebook will publish a proposal to avoid that by sending a GoAway message in the RTMP protocol. This code is the reference client implementation of that proposal. AFAIK other big live platforms showed their interest in implementing this mechanism. This can be already tested against Facebook live production using the querystring parameter ?ccr_sec=120 (that indicates the backend to send a disconnect signal after those seconds) --- libavformat/rtmppkt.c | 19 +++ libavformat/rtmppkt.h | 10 ++ libavformat/rtmpproto.c | 356 +--- 3 files changed, 359 insertions(+), 26 deletions(-) diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c index 4b97c0833f..84ec72740d 100644 --- a/libavformat/rtmppkt.c +++ b/libavformat/rtmppkt.c @@ -405,6 +405,25 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt, return written; } +int ff_rtmp_packet_clone(RTMPPacket *pkt_dst, const RTMPPacket *pkt_src) +{ +if (pkt_src->size) { +pkt_dst->data = av_realloc(NULL, pkt_src->size); +if (!pkt_dst->data) +return AVERROR(ENOMEM); +else +memcpy(pkt_dst->data, pkt_src->data, pkt_src->size); +} +pkt_dst->size = pkt_src->size; +pkt_dst->channel_id = pkt_src->channel_id; +pkt_dst->type = pkt_src->type; +pkt_dst->timestamp = pkt_src->timestamp; +pkt_dst->extra = pkt_src->extra; +pkt_dst->ts_field = pkt_src->ts_field; + +return 0; +} + int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type, int timestamp, int size) { diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h index a15d2a5773..cdb901df89 100644 --- a/libavformat/rtmppkt.h +++ b/libavformat/rtmppkt.h @@ -59,6 +59,7 @@ typedef enum RTMPPacketType { RTMP_PT_SHARED_OBJ, ///< shared object RTMP_PT_INVOKE, ///< invoke some stream action RTMP_PT_METADATA = 22, ///< FLV metadata +RTMP_PT_GO_AWAY = 32, ///< Indicates please reconnect ASAP, server is about to go down } RTMPPacketType; /** @@ -99,6 +100,15 @@ typedef struct RTMPPacket { int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type, int timestamp, int size); +/** + * Clone RTMP packet + * + * @param pkt_dst packet destination + * @param pkt_src packet source + * @return zero on success, negative value otherwise + */ +int ff_rtmp_packet_clone(RTMPPacket *pkt_dst, const RTMPPacket *pkt_src); + /** * Free RTMP packet. * diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index b14d23b919..ea37b9880a 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -124,11 +124,21 @@ typedef struct RTMPContext { int nb_streamid;///< The next stream id to return on createStream calls doubleduration; ///< Duration of the stream in seconds as returned by the server (only valid if non-zero) int tcp_nodelay;///< Use TCP_NODELAY to disable Nagle's algorithm if set to 1 +int reconnect_interval; ///< Forces a reconnected every Xs (in media time) char username[50]; char password[50]; char auth_params[500]; int do_reconnect; +uint32_t last_reconnect_timestamp; int auth_tried; +int force_reconnection_now; +int go_away_received; +AVDictionary* original_opts; +char original_uri[TCURL_MAX_LENGTH]; +int original_flags; +RTMPPacketlast_avc_seq_header_pkt;///< rtmp packet, used to save last AVC video header, used on reconnection +RTMPPacketlast_aac_seq_header_pkt;///< rtmp packet, used to save last AAC audio header, used on reconnection +RTMPPacketlast_metadata_pkt;///< rtmp packet, used to save last onMetadata info, used on reconnection } RTMPContext; #define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing @@ -224,7 +234,7 @@ static void free_tracked_methods(RTMPContext *rt) rt->nb_tracked_methods = 0; } -static int rtmp_send_packet(RTMPContext *rt, RTMPPacket *pkt, int track) +static int rtmp_send_packet(RTMPContext *rt, RTMPPacket *pkt, int track, int destroy) { int ret; @@ -248,7 +258,9 @@ static int rtmp_send_packet(RTMPContext *rt, RTMPPacket *pkt, int track) ret = ff_rtmp_packet_write(rt->stream, pkt, rt->out_chunk_size, &rt->prev_pkt[1], &rt->nb_prev_pkt[1]); fail: -ff_rtmp_packet_destroy(pkt); +if (destroy) +ff_rtmp_packet_destroy(pkt); + return ret; } @@ -336,6 +348,9 @
Re: [FFmpeg-devel] [PATCH] avformat/isom: enable TTML demuxing from MP4-likes
Jan Ekström: > As ff_codec_movsubtitle_tags is shared between demuxing and muxing, > the muxing parts have to go in before demuxing in order to not > generate invalid media, as adding an identifier to this list enables > muxing into QTFF/MOV. Does this mean that MOV_MP4_TTML_TAG is legal for QTFF/MOV, but MOV_ISMV_TTML_TAG is not? If so, why does the latter have a MOV prefix? Furthermore, you seem to believe that putting MOV_MP4_TTML_TAG earlier in the list ensures that it is not set when muxing mov. Yet this only ensures that it does not get autoselected, but what about the case when the tag is already set (e.g. when remuxing such an ismv ttml stream from a format where this is actually legal)? > --- > libavformat/isom.c | 2 ++ > tests/ref/fate/mov-mp4-ttml-dfxp | 10 ++ > tests/ref/fate/mov-mp4-ttml-stpp | 10 ++ > 3 files changed, 14 insertions(+), 8 deletions(-) > > diff --git a/libavformat/isom.c b/libavformat/isom.c > index 4df5440023..852d237481 100644 > --- a/libavformat/isom.c > +++ b/libavformat/isom.c > @@ -77,6 +77,8 @@ const AVCodecTag ff_codec_movsubtitle_tags[] = { > { AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'e', 'x', 't') }, > { AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'x', '3', 'g') }, > { AV_CODEC_ID_EIA_608, MKTAG('c', '6', '0', '8') }, > +{ AV_CODEC_ID_TTML, MOV_MP4_TTML_TAG }, > +{ AV_CODEC_ID_TTML, MOV_ISMV_TTML_TAG }, > { AV_CODEC_ID_NONE, 0 }, > }; > > diff --git a/tests/ref/fate/mov-mp4-ttml-dfxp > b/tests/ref/fate/mov-mp4-ttml-dfxp > index e24b5d618b..531d6856ec 100644 > --- a/tests/ref/fate/mov-mp4-ttml-dfxp > +++ b/tests/ref/fate/mov-mp4-ttml-dfxp > @@ -1,13 +1,14 @@ > 2e7e01c821c111466e7a2844826b7f6d *tests/data/fate/mov-mp4-ttml-dfxp.mp4 > 8519 tests/data/fate/mov-mp4-ttml-dfxp.mp4 > +#extradata 0: 20, 0x1dfc0302 > #tb 0: 1/1000 > -#media_type 0: data > -#codec_id 0: none > +#media_type 0: subtitle > +#codec_id 0: ttml > 0, 0, 0,68500, 7866, 0x456c36b7 > { > "packets": [ > { > -"codec_type": "data", > +"codec_type": "subtitle", > "stream_index": 0, > "pts": 0, > "pts_time": "0.00", > @@ -26,7 +27,8 @@ > "streams": [ > { > "index": 0, > -"codec_type": "data", > +"codec_name": "ttml", > +"codec_type": "subtitle", > "codec_tag_string": "dfxp", > "codec_tag": "0x70786664", > "time_base": "1/1000", > diff --git a/tests/ref/fate/mov-mp4-ttml-stpp > b/tests/ref/fate/mov-mp4-ttml-stpp > index 77bd23b7bf..7c03ef92cc 100644 > --- a/tests/ref/fate/mov-mp4-ttml-stpp > +++ b/tests/ref/fate/mov-mp4-ttml-stpp > @@ -1,13 +1,14 @@ > cbd2c7ff864a663b0d893deac5a0caec *tests/data/fate/mov-mp4-ttml-stpp.mp4 > 8547 tests/data/fate/mov-mp4-ttml-stpp.mp4 > +#extradata 0: 48, 0x62100c0d > #tb 0: 1/1000 > -#media_type 0: data > -#codec_id 0: none > +#media_type 0: subtitle > +#codec_id 0: ttml > 0, 0, 0,68500, 7866, 0x456c36b7 > { > "packets": [ > { > -"codec_type": "data", > +"codec_type": "subtitle", > "stream_index": 0, > "pts": 0, > "pts_time": "0.00", > @@ -26,7 +27,8 @@ cbd2c7ff864a663b0d893deac5a0caec > *tests/data/fate/mov-mp4-ttml-stpp.mp4 > "streams": [ > { > "index": 0, > -"codec_type": "data", > +"codec_name": "ttml", > +"codec_type": "subtitle", > "codec_tag_string": "stpp", > "codec_tag": "0x70707473", > "time_base": "1/1000", > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1 1/1] avformat/amr: Return PATCHWELCOME on stereo files
在 2021年9月26日 +0800 20:40,myp...@gmail.com ,写道: > On Thu, Sep 16, 2021 at 11:24 AM sunzhenliang > wrote: > > > > Signed-off-by: sunzhenliang > > --- > > libavformat/amr.c | 22 ++ > > 1 file changed, 18 insertions(+), 4 deletions(-) > > > > diff --git a/libavformat/amr.c b/libavformat/amr.c > > index 836b276fd5..2762010ebe 100644 > > --- a/libavformat/amr.c > > +++ b/libavformat/amr.c > > @@ -36,8 +36,10 @@ typedef struct { > > uint64_t block_count; > > } AMRContext; > > > > -static const char AMR_header[] = "#!AMR\n"; > > -static const char AMRWB_header[] = "#!AMR-WB\n"; > > +static const char AMR_header[] = "#!AMR\n"; > > +static const char AMR_MC_header[] = "#!AMR_MC1.0\n"; > > +static const char AMRWB_header[] = "#!AMR-WB\n"; > > +static const char AMRWB_MC_header[] = "#!AMR-WB_MC1.0\n"; > I don't think you need to format the AMR_header[] and AMRWB_header[] > in the patch I just think aligning the equals sign will look neat, which can't be reflected in the email. > > > > static const uint8_t amrnb_packed_size[16] = { > > 13, 14, 16, 18, 20, 21, 27, 32, 6, 1, 1, 1, 1, 1, 1, 1 > > @@ -82,7 +84,7 @@ static int amr_read_header(AVFormatContext *s) > > { > > AVIOContext *pb = s->pb; > > AVStream *st; > > - uint8_t header[9]; > > + uint8_t header[15]; > > > > if (avio_read(pb, header, 6) != 6) > > return AVERROR_INVALIDDATA; > > @@ -94,7 +96,19 @@ static int amr_read_header(AVFormatContext *s) > > if (avio_read(pb, header + 6, 3) != 3) > > return AVERROR_INVALIDDATA; > > if (memcmp(header, AMRWB_header, 9)) { > > - return -1; > > + if (avio_read(pb, header + 6 + 3, 3) != 3) > > + return AVERROR_INVALIDDATA; > > + if (memcmp(header, AMR_MC_header, 12)) { > > + if (avio_read(pb, header + 6 + 3 + 3, 3) != 3) > > + return AVERROR_INVALIDDATA; > > + if (memcmp(header, AMRWB_MC_header, 15)) { > > + return -1; > > + } > > + avpriv_report_missing_feature(s, "multi-channel AMRWB"); > > + return AVERROR_PATCHWELCOME; > > + } > > + avpriv_report_missing_feature(s, "multi-channel AMR"); > > + return AVERROR_PATCHWELCOME; > > } > > > > st->codecpar->codec_tag = MKTAG('s', 'a', 'w', 'b'); > > -- > > 2.25.1 > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 1/4] avformat/dovi_isom Implement Dolby Vision configuration parsing/writing
According to specification "Dolby Vision Stream Within the ISO Base Media File Format Version 2.2" This only adds support for the "Dolby Vision configuration box". Other configuration boxes such as "Dolby Vision enhancement layer configuration box" are not supported. The new functions will be used to implement parsing/writing the DOVI config for Matroska. As well as to refactor MOV/MPEG TS to parse the DOVI box/descriptor using dovi_isom. Signed-off-by: quietvoid --- libavformat/dovi_isom.c | 120 libavformat/dovi_isom.h | 35 2 files changed, 155 insertions(+) create mode 100644 libavformat/dovi_isom.c create mode 100644 libavformat/dovi_isom.h diff --git a/libavformat/dovi_isom.c b/libavformat/dovi_isom.c new file mode 100644 index 00..747ffc8b2c --- /dev/null +++ b/libavformat/dovi_isom.c @@ -0,0 +1,120 @@ +/* + * DOVI ISO Media common code + * Copyright (c) 2021 quietvoid + * + * 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 "libavutil/dovi_meta.h" + +#include "libavcodec/put_bits.h" + +#include "avformat.h" +#include "dovi_isom.h" + +int ff_isom_parse_dvcc_dvvc(AVFormatContext *s, AVStream *st, const uint8_t *buf_ptr, uint64_t size) +{ +uint32_t buf; +AVDOVIDecoderConfigurationRecord *dovi; +size_t dovi_size; +int ret; + +if (size > (1 << 30) || size < 4) +return AVERROR_INVALIDDATA; + +dovi = av_dovi_alloc(&dovi_size); +if (!dovi) +return AVERROR(ENOMEM); + +dovi->dv_version_major = *buf_ptr++;// 8 bits +dovi->dv_version_minor = *buf_ptr++;// 8 bits + +buf = *buf_ptr++ << 8; +buf |= *buf_ptr++; + +dovi->dv_profile= (buf >> 9) & 0x7f;// 7 bits +dovi->dv_level = (buf >> 3) & 0x3f;// 6 bits +dovi->rpu_present_flag = (buf >> 2) & 0x01;// 1 bit +dovi->el_present_flag = (buf >> 1) & 0x01;// 1 bit +dovi->bl_present_flag = buf & 0x01;// 1 bit + +// Has enough remaining data +if (size >= 5) { +dovi->dv_bl_signal_compatibility_id = ((*buf_ptr++) >> 4) & 0x0f; // 4 bits +} else { +// 0 stands for None +// Dolby Vision V1.2.93 profiles and levels +dovi->dv_bl_signal_compatibility_id = 0; +} + +ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, + (uint8_t *)dovi, dovi_size); +if (ret < 0) { +av_free(dovi); +return ret; +} + +av_log(s, AV_LOG_TRACE, "DOVI, version: %d.%d, profile: %d, level: %d, " + "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", + dovi->dv_version_major, dovi->dv_version_minor, + dovi->dv_profile, dovi->dv_level, + dovi->rpu_present_flag, + dovi->el_present_flag, + dovi->bl_present_flag, + dovi->dv_bl_signal_compatibility_id +); + +return 0; +} + +int ff_isom_put_dvcc_dvvc(AVFormatContext *s, uint8_t out[ISOM_DVCC_DVVC_SIZE], uint64_t size, + AVDOVIDecoderConfigurationRecord *dovi) +{ +PutBitContext pb; +init_put_bits(&pb, out, size); + +if (size < ISOM_DVCC_DVVC_SIZE) +return AVERROR(EINVAL); + +put_bits(&pb, 8, dovi->dv_version_major); +put_bits(&pb, 8, dovi->dv_version_minor); +put_bits(&pb, 7, dovi->dv_profile); +put_bits(&pb, 6, dovi->dv_level); +put_bits(&pb, 1, dovi->rpu_present_flag); +put_bits(&pb, 1, dovi->el_present_flag); +put_bits(&pb, 1, dovi->bl_present_flag); +put_bits(&pb, 4, dovi->dv_bl_signal_compatibility_id); + +put_bits(&pb, 28, 0); /* reserved */ +put_bits32(&pb, 0); /* reserved */ +put_bits32(&pb, 0); /* reserved */ +put_bits32(&pb, 0); /* reserved */ +put_bits32(&pb, 0); /* reserved */ +flush_put_bits(&pb); + +av_log(s, AV_LOG_DEBUG, "DOVI in %s box, version: %d.%d, profile: %d, level: %d, " + "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", + dovi->dv_profile > 7 ? "dvvC" : "dvcC", + dovi->dv_version_major, dovi->dv_version_minor, + dovi->dv_profile, dovi->dv_level, + dovi->rpu_present_flag, + dovi->el_present_flag, + dovi->bl_presen
[FFmpeg-devel] [PATCH v4 2/4] avformat/matroska{dec, enc} Parse BlockAdditionMapping elements
Adds handling of dvcC/dvvC block addition mappings. The parsing creates AVDOVIDecoderConfigurationRecord side data for the video track. The configuration block is written when muxing into MKV if DOVI side data is present for the track. In version 2.2 of the Dolby ISOM specification, there is also dvwC but it is not in the Matroska spec. Most of the Matroska element parsing was implemented by Plex developers. Signed-off-by: quietvoid --- libavformat/Makefile | 4 +-- libavformat/matroska.h| 7 + libavformat/matroskadec.c | 59 +-- libavformat/matroskaenc.c | 45 + 4 files changed, 111 insertions(+), 4 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index c45caa3eed..680030014d 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -313,11 +313,11 @@ OBJS-$(CONFIG_M4V_MUXER) += rawenc.o OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \ flac_picture.o isom_tags.o rmsipr.o \ oggparsevorbis.o vorbiscomment.o \ -qtpalette.o replaygain.o +qtpalette.o replaygain.o dovi_isom.o OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \ av1.o avc.o hevc.o isom_tags.o \ flacenc_header.o avlanguage.o \ -vorbiscomment.o wv.o +vorbiscomment.o wv.o dovi_isom.o OBJS-$(CONFIG_MCA_DEMUXER) += mca.o OBJS-$(CONFIG_MCC_DEMUXER) += mccdec.o subtitles.o OBJS-$(CONFIG_MD5_MUXER) += hashenc.o diff --git a/libavformat/matroska.h b/libavformat/matroska.h index 2d04a6838b..4b2a3310a4 100644 --- a/libavformat/matroska.h +++ b/libavformat/matroska.h @@ -111,6 +111,7 @@ #define MATROSKA_ID_TRACKCONTENTENCODING 0x6240 #define MATROSKA_ID_TRACKTIMECODESCALE 0x23314F #define MATROSKA_ID_TRACKMAXBLKADDID 0x55EE +#define MATROSKA_ID_TRACKBLKADDMAPPING 0x41E4 /* IDs in the trackvideo master */ #define MATROSKA_ID_VIDEOFRAMERATE 0x2383E3 @@ -189,6 +190,12 @@ #define MATROSKA_ID_ENCODINGSIGKEYID 0x47E4 #define MATROSKA_ID_ENCODINGSIGNATURE 0x47E3 +/* IDs in the block addition mapping master */ +#define MATROSKA_ID_BLKADDIDVALUE 0x41F0 +#define MATROSKA_ID_BLKADDIDNAME 0x41A4 +#define MATROSKA_ID_BLKADDIDTYPE 0x41E7 +#define MATROSKA_ID_BLKADDIDEXTRADATA 0x41ED + /* ID in the cues master */ #define MATROSKA_ID_POINTENTRY 0xBB diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 500c83ac3a..a50851b8d3 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -51,6 +51,8 @@ #include "libavcodec/mpeg4audio.h" #include "libavcodec/packet_internal.h" +#include "libavformat/dovi_isom.h" + #include "avformat.h" #include "avio_internal.h" #include "internal.h" @@ -239,6 +241,13 @@ typedef struct MatroskaTrackOperation { EbmlList combine_planes; } MatroskaTrackOperation; +typedef struct MatroskaBlockAdditionMapping { +uint64_t value; +char *name; +uint64_t type; +EbmlBin extradata; +} MatroskaBlockAdditionMapping; + typedef struct MatroskaTrack { uint64_t num; uint64_t uid; @@ -269,6 +278,7 @@ typedef struct MatroskaTrack { int ms_compat; int needs_decoding; uint64_t max_block_additional_id; +EbmlList block_addition_mappings; uint32_t palette[AVPALETTE_COUNT]; int has_palette; @@ -419,8 +429,8 @@ typedef struct MatroskaDemuxContext { // incomplete type (6.7.2 in C90, 6.9.2 in C99). // Removing the sizes breaks MSVC. static EbmlSyntax ebml_syntax[3], matroska_segment[9], matroska_track_video_color[15], matroska_track_video[19], - matroska_track[32], matroska_track_encoding[6], matroska_track_encodings[2], - matroska_track_combine_planes[2], matroska_track_operation[2], matroska_tracks[2], + matroska_track[33], matroska_track_encoding[6], matroska_track_encodings[2], + matroska_track_combine_planes[2], matroska_track_operation[2], matroska_block_addition_mapping[5], matroska_tracks[2], matroska_attachments[2], matroska_chapter_entry[9], matroska_chapter[6], matroska_chapters[2], matroska_index_entry[3], matroska_index[2], matroska_tag[3], matroska_tags[2], matroska_seekhead[2], matroska_blockadditions[2], matroska_blockgroup[8], matroska_cluster_parsing[8]; @@ -570,6 +580,14 @@ static EbmlSyntax matroska_track_operation[] = { CHILD_OF(matroska_track) }; +static EbmlSyntax matroska_block_addition_mapping[] = { +{ MATROSKA_ID_BLKADDIDVALUE, EBML_UINT, 0, 0, offsetof(MatroskaBlockAdditionMapping, value) }, +{ MATROSKA
[FFmpeg-devel] [PATCH v4 3/4] avformat/mov: Refactor DOVI box parsing to use ff_isom_parse_dvcc_dvvc
Read at most 24 bytes, but in reality only 5 bytes are used for parsing. The rest of the bytes are reserved in the specification. Signed-off-by: quietvoid --- libavformat/mov.c | 51 ++- 1 file changed, 10 insertions(+), 41 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index d0b8b2595b..e052f7ad96 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -61,6 +61,8 @@ #include "mov_chan.h" #include "replaygain.h" +#include "libavformat/dovi_isom.h" + #if CONFIG_ZLIB #include #endif @@ -6799,58 +6801,25 @@ static int mov_read_dmlp(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; -uint32_t buf; -AVDOVIDecoderConfigurationRecord *dovi; -size_t dovi_size; +uint8_t buf[ISOM_DVCC_DVVC_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; int ret; +int64_t read_size = atom.size; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; -if ((uint64_t)atom.size > (1<<30) || atom.size < 4) -return AVERROR_INVALIDDATA; - -dovi = av_dovi_alloc(&dovi_size); -if (!dovi) -return AVERROR(ENOMEM); - -dovi->dv_version_major = avio_r8(pb); -dovi->dv_version_minor = avio_r8(pb); - -buf = avio_rb16(pb); -dovi->dv_profile= (buf >> 9) & 0x7f;// 7 bits -dovi->dv_level = (buf >> 3) & 0x3f;// 6 bits -dovi->rpu_present_flag = (buf >> 2) & 0x01;// 1 bit -dovi->el_present_flag = (buf >> 1) & 0x01;// 1 bit -dovi->bl_present_flag = buf & 0x01;// 1 bit -if (atom.size >= 24) { // 4 + 4 + 4 * 4 -buf = avio_r8(pb); -dovi->dv_bl_signal_compatibility_id = (buf >> 4) & 0x0f; // 4 bits -} else { -// 0 stands for None -// Dolby Vision V1.2.93 profiles and levels -dovi->dv_bl_signal_compatibility_id = 0; +// At most 24 bytes +if (read_size > ISOM_DVCC_DVVC_SIZE) { +read_size = ISOM_DVCC_DVVC_SIZE; } -ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, - (uint8_t *)dovi, dovi_size); -if (ret < 0) { -av_free(dovi); +if ((ret = ffio_read_size(pb, buf, read_size)) < 0) return ret; -} -av_log(c, AV_LOG_TRACE, "DOVI in dvcC/dvvC box, version: %d.%d, profile: %d, level: %d, " - "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", - dovi->dv_version_major, dovi->dv_version_minor, - dovi->dv_profile, dovi->dv_level, - dovi->rpu_present_flag, - dovi->el_present_flag, - dovi->bl_present_flag, - dovi->dv_bl_signal_compatibility_id -); +read_size = ret; -return 0; +return ff_isom_parse_dvcc_dvvc(c->fc, st, buf, read_size); } static const MOVParseTableEntry mov_default_parse_table[] = { -- 2.33.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 4/4] avformat/mpegts: Refactor DOVI descriptor parsing to use ff_isom_parse_dvcc_dvvc
Also fixes incorrect parsing of dv_bl_signal_compatibility_id, which was often set to zero instead of the actual value, for mpegts only. Signed-off-by: quietvoid --- libavformat/mpegts.c | 44 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index da8eee2414..75ef59d186 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -39,6 +39,9 @@ #include "avio_internal.h" #include "mpeg.h" #include "isom.h" + +#include "libavformat/dovi_isom.h" + #if CONFIG_ICONV #include #endif @@ -2162,49 +2165,10 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type break; case 0xb0: /* DOVI video stream descriptor */ { -uint32_t buf; -AVDOVIDecoderConfigurationRecord *dovi; -size_t dovi_size; int ret; -if (desc_end - *pp < 4) // (8 + 8 + 7 + 6 + 1 + 1 + 1) / 8 -return AVERROR_INVALIDDATA; - -dovi = av_dovi_alloc(&dovi_size); -if (!dovi) -return AVERROR(ENOMEM); -dovi->dv_version_major = get8(pp, desc_end); -dovi->dv_version_minor = get8(pp, desc_end); -buf = get16(pp, desc_end); -dovi->dv_profile= (buf >> 9) & 0x7f;// 7 bits -dovi->dv_level = (buf >> 3) & 0x3f;// 6 bits -dovi->rpu_present_flag = (buf >> 2) & 0x01;// 1 bit -dovi->el_present_flag = (buf >> 1) & 0x01;// 1 bit -dovi->bl_present_flag = buf & 0x01;// 1 bit -if (desc_end - *pp >= 20) { // 4 + 4 * 4 -buf = get8(pp, desc_end); -dovi->dv_bl_signal_compatibility_id = (buf >> 4) & 0x0f; // 4 bits -} else { -// 0 stands for None -// Dolby Vision V1.2.93 profiles and levels -dovi->dv_bl_signal_compatibility_id = 0; -} - -ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, - (uint8_t *)dovi, dovi_size); -if (ret < 0) { -av_free(dovi); +if ((ret = ff_isom_parse_dvcc_dvvc(fc, st, *pp, desc_len)) < 0) return ret; -} - -av_log(fc, AV_LOG_TRACE, "DOVI, version: %d.%d, profile: %d, level: %d, " - "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", - dovi->dv_version_major, dovi->dv_version_minor, - dovi->dv_profile, dovi->dv_level, - dovi->rpu_present_flag, - dovi->el_present_flag, - dovi->bl_present_flag, - dovi->dv_bl_signal_compatibility_id); } break; default: -- 2.33.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/4] avfilter/formats: Don't unnecessarily reget pixfmt descriptor
Signed-off-by: Andreas Rheinhardt --- If I am not mistaken, then the check for chroma is wrong, as there are pixel formats with just luma and alpha. The clean check would probably be desc->nb_components > (1 + !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)), while desc->nb_components > 2 would also just work. Maybe there should be an AV_PIX_FMT_FLAG_CHROMA for this? libavfilter/formats.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 1d2a51c0af..29e318aa3b 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -113,9 +113,9 @@ static int merge_formats_internal(AVFilterFormats *a, AVFilterFormats *b, To avoid that, pretend that there are no common formats to force the insertion of a conversion filter. */ if (type == AVMEDIA_TYPE_VIDEO) -for (i = 0; i < a->nb_formats; i++) +for (i = 0; i < a->nb_formats; i++) { +const AVPixFmtDescriptor *const adesc = av_pix_fmt_desc_get(a->formats[i]); for (j = 0; j < b->nb_formats; j++) { -const AVPixFmtDescriptor *adesc = av_pix_fmt_desc_get(a->formats[i]); const AVPixFmtDescriptor *bdesc = av_pix_fmt_desc_get(b->formats[j]); alpha2 |= adesc->flags & bdesc->flags & AV_PIX_FMT_FLAG_ALPHA; chroma2|= adesc->nb_components > 1 && bdesc->nb_components > 1; @@ -124,6 +124,7 @@ static int merge_formats_internal(AVFilterFormats *a, AVFilterFormats *b, chroma1|= adesc->nb_components > 1; } } +} // If chroma or alpha can be lost through merging then do not merge if (alpha2 > alpha1 || chroma2 > chroma1) -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/4] avfilter/formats: Update outdated comment
Forgotten in 06754f7bbf341062581accc27b5cce353e99fd82. Signed-off-by: Andreas Rheinhardt --- libavfilter/formats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 29e318aa3b..ec3b8ebd8d 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -58,7 +58,7 @@ do { \ * If check is set, nothing is modified and it is only checked whether * the formats are compatible. * If empty_allowed is set and one of a,b->nb is zero, the lists are - * merged; otherwise, it is treated as error. + * merged; otherwise, 0 (for nonmergeability) is returned. */ #define MERGE_FORMATS(a, b, fmts, nb, type, check, empty_allowed) \ do { \ -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/4] avfilter/af_afade: Remove impossible branch
Also don't call ff_inlink_queued_samples() unnecessarily often. Fixes Coverity issue 1427665. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_afade.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c index 3bd0331e77..aecbb44f70 100644 --- a/libavfilter/af_afade.c +++ b/libavfilter/af_afade.c @@ -483,20 +483,18 @@ static int activate(AVFilterContext *ctx) } } -if (ff_inlink_queued_samples(ctx->inputs[0]) > s->nb_samples) { -nb_samples = ff_inlink_queued_samples(ctx->inputs[0]) - s->nb_samples; -if (nb_samples > 0) { -ret = ff_inlink_consume_samples(ctx->inputs[0], nb_samples, nb_samples, &in); -if (ret < 0) { -return ret; -} -} +nb_samples = ff_inlink_queued_samples(ctx->inputs[0]); +if (nb_samples > s->nb_samples) { +nb_samples -= s->nb_samples; +ret = ff_inlink_consume_samples(ctx->inputs[0], nb_samples, nb_samples, &in); +if (ret < 0) +return ret; in->pts = s->pts; s->pts += av_rescale_q(in->nb_samples, (AVRational){ 1, outlink->sample_rate }, outlink->time_base); return ff_filter_frame(outlink, in); -} else if (ff_inlink_queued_samples(ctx->inputs[0]) >= s->nb_samples && - ff_inlink_queued_samples(ctx->inputs[1]) >= s->nb_samples && s->cf0_eof) { +} else if (s->cf0_eof && nb_samples >= s->nb_samples && + ff_inlink_queued_samples(ctx->inputs[1]) >= s->nb_samples) { if (s->overlap) { out = ff_get_audio_buffer(outlink, s->nb_samples); if (!out) -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 4/4] avfilter/preserve_color: Add necessary headers
Fixes checkheaders. Signed-off-by: Andreas Rheinhardt --- Will apply this soon. libavfilter/preserve_color.h | 4 1 file changed, 4 insertions(+) diff --git a/libavfilter/preserve_color.h b/libavfilter/preserve_color.h index ac0587ad1e..158ee226bb 100644 --- a/libavfilter/preserve_color.h +++ b/libavfilter/preserve_color.h @@ -19,6 +19,10 @@ #ifndef AVFILTER_PRESERVE_COLOR_H #define AVFILTER_PRESERVE_COLOR_H +#include + +#include "libavutil/macros.h" + enum { P_NONE, P_LUM, -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 1/4] avformat/dovi_isom Implement Dolby Vision configuration parsing/writing
On Mon, Sep 27, 2021 at 10:57 AM quietvoid wrote: > > According to specification "Dolby Vision Stream Within the ISO Base Media > File Format Version 2.2" > > This only adds support for the "Dolby Vision configuration box". > Other configuration boxes such as "Dolby Vision enhancement layer > configuration box" are not supported. > > The new functions will be used to implement parsing/writing the DOVI config > for Matroska. > As well as to refactor MOV/MPEG TS to parse the DOVI box/descriptor using > dovi_isom. > > Signed-off-by: quietvoid > --- > libavformat/dovi_isom.c | 120 > libavformat/dovi_isom.h | 35 > 2 files changed, 155 insertions(+) > create mode 100644 libavformat/dovi_isom.c > create mode 100644 libavformat/dovi_isom.h > > diff --git a/libavformat/dovi_isom.c b/libavformat/dovi_isom.c > new file mode 100644 > index 00..747ffc8b2c > --- /dev/null > +++ b/libavformat/dovi_isom.c > @@ -0,0 +1,120 @@ > +/* > + * DOVI ISO Media common code > + * Copyright (c) 2021 quietvoid > + * > + * 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 "libavutil/dovi_meta.h" > + > +#include "libavcodec/put_bits.h" > + > +#include "avformat.h" > +#include "dovi_isom.h" > + > +int ff_isom_parse_dvcc_dvvc(AVFormatContext *s, AVStream *st, const uint8_t > *buf_ptr, uint64_t size) > +{ > +uint32_t buf; > +AVDOVIDecoderConfigurationRecord *dovi; > +size_t dovi_size; > +int ret; > + > +if (size > (1 << 30) || size < 4) > +return AVERROR_INVALIDDATA; > + > +dovi = av_dovi_alloc(&dovi_size); > +if (!dovi) > +return AVERROR(ENOMEM); > + > +dovi->dv_version_major = *buf_ptr++;// 8 bits > +dovi->dv_version_minor = *buf_ptr++;// 8 bits > + > +buf = *buf_ptr++ << 8; > +buf |= *buf_ptr++; > + > +dovi->dv_profile= (buf >> 9) & 0x7f;// 7 bits > +dovi->dv_level = (buf >> 3) & 0x3f;// 6 bits > +dovi->rpu_present_flag = (buf >> 2) & 0x01;// 1 bit > +dovi->el_present_flag = (buf >> 1) & 0x01;// 1 bit > +dovi->bl_present_flag = buf & 0x01;// 1 bit > + > +// Has enough remaining data > +if (size >= 5) { > +dovi->dv_bl_signal_compatibility_id = ((*buf_ptr++) >> 4) & 0x0f; // > 4 bits > +} else { > +// 0 stands for None > +// Dolby Vision V1.2.93 profiles and levels > +dovi->dv_bl_signal_compatibility_id = 0; > +} > + > +ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, > + (uint8_t *)dovi, dovi_size); > +if (ret < 0) { > +av_free(dovi); > +return ret; > +} > + > +av_log(s, AV_LOG_TRACE, "DOVI, version: %d.%d, profile: %d, level: %d, " > + "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", > + dovi->dv_version_major, dovi->dv_version_minor, > + dovi->dv_profile, dovi->dv_level, > + dovi->rpu_present_flag, > + dovi->el_present_flag, > + dovi->bl_present_flag, > + dovi->dv_bl_signal_compatibility_id > +); > + > +return 0; > +} > + > +int ff_isom_put_dvcc_dvvc(AVFormatContext *s, uint8_t > out[ISOM_DVCC_DVVC_SIZE], uint64_t size, > + AVDOVIDecoderConfigurationRecord *dovi) > +{ > +PutBitContext pb; > +init_put_bits(&pb, out, size); > + > +if (size < ISOM_DVCC_DVVC_SIZE) > +return AVERROR(EINVAL); > + > +put_bits(&pb, 8, dovi->dv_version_major); > +put_bits(&pb, 8, dovi->dv_version_minor); > +put_bits(&pb, 7, dovi->dv_profile); > +put_bits(&pb, 6, dovi->dv_level); > +put_bits(&pb, 1, dovi->rpu_present_flag); > +put_bits(&pb, 1, dovi->el_present_flag); > +put_bits(&pb, 1, dovi->bl_present_flag); > +put_bits(&pb, 4, dovi->dv_bl_signal_compatibility_id); > + > +put_bits(&pb, 28, 0); /* reserved */ > +put_bits32(&pb, 0); /* reserved */ > +put_bits32(&pb, 0); /* reserved */ > +put_bits32(&pb, 0); /* reserved */ > +put_bits32(&pb, 0); /* reserved */ > +flush_put_bits(&pb); > + > +av_log(s, AV_LOG_DEBUG, "DOVI in %s box, version: %d.%d, profile: %d, > level: %d, " > +
Re: [FFmpeg-devel] [PATCH v4 3/4] avformat/mov: Refactor DOVI box parsing to use ff_isom_parse_dvcc_dvvc
quietvoid: > Read at most 24 bytes, but in reality only 5 bytes are used for parsing. > The rest of the bytes are reserved in the specification. > > Signed-off-by: quietvoid > --- > libavformat/mov.c | 51 ++- > 1 file changed, 10 insertions(+), 41 deletions(-) > > diff --git a/libavformat/mov.c b/libavformat/mov.c > index d0b8b2595b..e052f7ad96 100644 > --- a/libavformat/mov.c > +++ b/libavformat/mov.c > @@ -61,6 +61,8 @@ > #include "mov_chan.h" > #include "replaygain.h" > > +#include "libavformat/dovi_isom.h" > + > #if CONFIG_ZLIB > #include > #endif > @@ -6799,58 +6801,25 @@ static int mov_read_dmlp(MOVContext *c, AVIOContext > *pb, MOVAtom atom) > static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom) > { > AVStream *st; > -uint32_t buf; > -AVDOVIDecoderConfigurationRecord *dovi; > -size_t dovi_size; > +uint8_t buf[ISOM_DVCC_DVVC_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; > int ret; > +int64_t read_size = atom.size; > > if (c->fc->nb_streams < 1) > return 0; > st = c->fc->streams[c->fc->nb_streams-1]; > > -if ((uint64_t)atom.size > (1<<30) || atom.size < 4) > -return AVERROR_INVALIDDATA; > - > -dovi = av_dovi_alloc(&dovi_size); > -if (!dovi) > -return AVERROR(ENOMEM); > - > -dovi->dv_version_major = avio_r8(pb); > -dovi->dv_version_minor = avio_r8(pb); > - > -buf = avio_rb16(pb); > -dovi->dv_profile= (buf >> 9) & 0x7f;// 7 bits > -dovi->dv_level = (buf >> 3) & 0x3f;// 6 bits > -dovi->rpu_present_flag = (buf >> 2) & 0x01;// 1 bit > -dovi->el_present_flag = (buf >> 1) & 0x01;// 1 bit > -dovi->bl_present_flag = buf & 0x01;// 1 bit > -if (atom.size >= 24) { // 4 + 4 + 4 * 4 > -buf = avio_r8(pb); > -dovi->dv_bl_signal_compatibility_id = (buf >> 4) & 0x0f; // 4 bits > -} else { > -// 0 stands for None > -// Dolby Vision V1.2.93 profiles and levels > -dovi->dv_bl_signal_compatibility_id = 0; > +// At most 24 bytes > +if (read_size > ISOM_DVCC_DVVC_SIZE) { > +read_size = ISOM_DVCC_DVVC_SIZE; > } > > -ret = av_stream_add_side_data(st, AV_PKT_DATA_DOVI_CONF, > - (uint8_t *)dovi, dovi_size); > -if (ret < 0) { > -av_free(dovi); > +if ((ret = ffio_read_size(pb, buf, read_size)) < 0) > return ret; > -} > > -av_log(c, AV_LOG_TRACE, "DOVI in dvcC/dvvC box, version: %d.%d, profile: > %d, level: %d, " > - "rpu flag: %d, el flag: %d, bl flag: %d, compatibility id: %d\n", > - dovi->dv_version_major, dovi->dv_version_minor, > - dovi->dv_profile, dovi->dv_level, > - dovi->rpu_present_flag, > - dovi->el_present_flag, > - dovi->bl_present_flag, > - dovi->dv_bl_signal_compatibility_id > -); > +read_size = ret; ffio_read_size always returns an error if it could not read exactly the amount of bytes desired by the caller. If you want to support truncated data, you will have to use avio_read(). > > -return 0; > +return ff_isom_parse_dvcc_dvvc(c->fc, st, buf, read_size); > } > > static const MOVParseTableEntry mov_default_parse_table[] = { > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 2/4] avformat/matroska{dec, enc} Parse BlockAdditionMapping elements
quietvoid: > Adds handling of dvcC/dvvC block addition mappings. > The parsing creates AVDOVIDecoderConfigurationRecord side data for the video > track. > The configuration block is written when muxing into MKV if DOVI side data is > present for the track. > > In version 2.2 of the Dolby ISOM specification, there is also dvwC but it is > not in the Matroska spec. > > Most of the Matroska element parsing was implemented by Plex developers. > > Signed-off-by: quietvoid > --- > libavformat/Makefile | 4 +-- > libavformat/matroska.h| 7 + > libavformat/matroskadec.c | 59 +-- > libavformat/matroskaenc.c | 45 + > 4 files changed, 111 insertions(+), 4 deletions(-) > > diff --git a/libavformat/Makefile b/libavformat/Makefile > index c45caa3eed..680030014d 100644 > --- a/libavformat/Makefile > +++ b/libavformat/Makefile > @@ -313,11 +313,11 @@ OBJS-$(CONFIG_M4V_MUXER) += rawenc.o > OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o \ > flac_picture.o isom_tags.o > rmsipr.o \ > oggparsevorbis.o vorbiscomment.o > \ > -qtpalette.o replaygain.o > +qtpalette.o replaygain.o > dovi_isom.o > OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \ > av1.o avc.o hevc.o isom_tags.o \ > flacenc_header.o avlanguage.o \ > -vorbiscomment.o wv.o > +vorbiscomment.o wv.o dovi_isom.o > OBJS-$(CONFIG_MCA_DEMUXER) += mca.o > OBJS-$(CONFIG_MCC_DEMUXER) += mccdec.o subtitles.o > OBJS-$(CONFIG_MD5_MUXER) += hashenc.o > diff --git a/libavformat/matroska.h b/libavformat/matroska.h > index 2d04a6838b..4b2a3310a4 100644 > --- a/libavformat/matroska.h > +++ b/libavformat/matroska.h > @@ -111,6 +111,7 @@ > #define MATROSKA_ID_TRACKCONTENTENCODING 0x6240 > #define MATROSKA_ID_TRACKTIMECODESCALE 0x23314F > #define MATROSKA_ID_TRACKMAXBLKADDID 0x55EE > +#define MATROSKA_ID_TRACKBLKADDMAPPING 0x41E4 > > /* IDs in the trackvideo master */ > #define MATROSKA_ID_VIDEOFRAMERATE 0x2383E3 > @@ -189,6 +190,12 @@ > #define MATROSKA_ID_ENCODINGSIGKEYID 0x47E4 > #define MATROSKA_ID_ENCODINGSIGNATURE 0x47E3 > > +/* IDs in the block addition mapping master */ > +#define MATROSKA_ID_BLKADDIDVALUE 0x41F0 > +#define MATROSKA_ID_BLKADDIDNAME 0x41A4 > +#define MATROSKA_ID_BLKADDIDTYPE 0x41E7 > +#define MATROSKA_ID_BLKADDIDEXTRADATA 0x41ED > + > /* ID in the cues master */ > #define MATROSKA_ID_POINTENTRY 0xBB > > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c > index 500c83ac3a..a50851b8d3 100644 > --- a/libavformat/matroskadec.c > +++ b/libavformat/matroskadec.c > @@ -51,6 +51,8 @@ > #include "libavcodec/mpeg4audio.h" > #include "libavcodec/packet_internal.h" > > +#include "libavformat/dovi_isom.h" We use relative paths for headers in the same directory; and this inclusion should be added to the headers below, keeping its alphabetical ordering. This goes for lots of headers added by you. > + > #include "avformat.h" > #include "avio_internal.h" > #include "internal.h" > @@ -239,6 +241,13 @@ typedef struct MatroskaTrackOperation { > EbmlList combine_planes; > } MatroskaTrackOperation; > > +typedef struct MatroskaBlockAdditionMapping { > +uint64_t value; > +char *name; > +uint64_t type; > +EbmlBin extradata; > +} MatroskaBlockAdditionMapping; > + > typedef struct MatroskaTrack { > uint64_t num; > uint64_t uid; > @@ -269,6 +278,7 @@ typedef struct MatroskaTrack { > int ms_compat; > int needs_decoding; > uint64_t max_block_additional_id; > +EbmlList block_addition_mappings; > > uint32_t palette[AVPALETTE_COUNT]; > int has_palette; > @@ -419,8 +429,8 @@ typedef struct MatroskaDemuxContext { > // incomplete type (6.7.2 in C90, 6.9.2 in C99). > // Removing the sizes breaks MSVC. > static EbmlSyntax ebml_syntax[3], matroska_segment[9], > matroska_track_video_color[15], matroska_track_video[19], > - matroska_track[32], matroska_track_encoding[6], > matroska_track_encodings[2], > - matroska_track_combine_planes[2], > matroska_track_operation[2], matroska_tracks[2], > + matroska_track[33], matroska_track_encoding[6], > matroska_track_encodings[2], > + matroska_track_combine_planes[2], > matroska_track_operation[2], matroska_block_addition_mapping[5], > matroska_tracks[2], >matroska_attachments[2], matroska_chapter_entry[9], > matroska_chapter[6], matroska_chapters[2], >matroska_index_entry[3], matroska_index[2], >
Re: [FFmpeg-devel] [PATCH 07/27] fate/caf: Add remux tests
Andreas Rheinhardt: > These test both the muxer as well as the demuxer. > > Signed-off-by: Andreas Rheinhardt > --- > tests/fate/caf.mak | 30 +- > tests/ref/fate/caf-alac-remux | 28 > tests/ref/fate/caf-amr_nb-remux| 19 +++ > tests/ref/fate/caf-mace6-remux | 20 > tests/ref/fate/caf-pcm_s24-remux | 23 +++ > tests/ref/fate/caf-pcm_s24le-remux | 23 +++ > tests/ref/fate/caf-qdm2-remux | 12 > 7 files changed, 154 insertions(+), 1 deletion(-) > create mode 100644 tests/ref/fate/caf-alac-remux > create mode 100644 tests/ref/fate/caf-amr_nb-remux > create mode 100644 tests/ref/fate/caf-mace6-remux > create mode 100644 tests/ref/fate/caf-pcm_s24-remux > create mode 100644 tests/ref/fate/caf-pcm_s24le-remux > create mode 100644 tests/ref/fate/caf-qdm2-remux > > diff --git a/tests/fate/caf.mak b/tests/fate/caf.mak > index e921fcc297..581128c670 100644 > --- a/tests/fate/caf.mak > +++ b/tests/fate/caf.mak > @@ -1,5 +1,33 @@ > FATE_CAF_FFMPEG-$(call ALLYES, CAF_DEMUXER CRC_MUXER) += fate-caf-demux > fate-caf-demux: CMD = crc -i $(TARGET_SAMPLES)/caf/caf-pcm16.caf -c copy > > +FATE_CAF_REMUX_FFPROBE-$(CONFIG_MOV_DEMUXER) += fate-caf-alac-remux > +fate-caf-alac-remux: CMD = transcode m4a > $(TARGET_SAMPLES)/lossless-audio/inside.m4a caf "-map 0:a -c copy" "-c copy > -t 0.2" "" "-show_entries format_tags" > + > +FATE_CAF_REMUX-$(CONFIG_AMR_DEMUXER) += fate-caf-amr_nb-remux > +fate-caf-amr_nb-remux: CMD = transcode amr $(TARGET_SAMPLES)/amrnb/4.75k.amr > caf "-c copy" "-c copy -t 0.2" > + > +FATE_CAF_REMUX-$(CONFIG_MOV_DEMUXER) += fate-caf-qdm2-remux > +fate-caf-qdm2-remux: CMD = transcode mov > $(TARGET_SAMPLES)/qt-surge-suite/surge-2-16-B-QDM2.mov caf "-c copy" "-c copy > -t 0.2" > + > +FATE_CAF_REMUX-$(CONFIG_WAV_DEMUXER) += fate-caf-pcm_s24le-remux > +fate-caf-pcm_s24le-remux: CMD = transcode wav > $(TARGET_SAMPLES)/audio-reference/divertimenti_2ch_96kHz_s24.wav caf "-c > copy" "-c copy -t 0.05" > + > +FATE_CAF_REMUX-$(call ALLYES, WAV_DEMUXER PCM_S24LE_DECODER \ > + PCM_S24BE_ENCODER)\ > + += fate-caf-pcm_s24-remux > +fate-caf-pcm_s24-remux: CMD = transcode wav > $(TARGET_SAMPLES)/audio-reference/divertimenti_2ch_96kHz_s24.wav caf "-c > pcm_s24be" "-c copy -t 0.05" > + > +FATE_CAF_REMUX-$(CONFIG_MOV_DEMUXER) += fate-caf-mace6-remux > +fate-caf-mace6-remux: CMD = transcode mov > $(TARGET_SAMPLES)/qtrle/Animation-16Greys.mov caf "-map 0:a -c copy" "-c copy > -t 0.003" > + > +FATE_CAF_FFMPEG-$(call ALLYES, FILE_PROTOCOL CAF_MUXER CAF_DEMUXER \ > + FRAMECRC_MUXER PIPE_PROTOCOL) \ > + += $(FATE_CAF_REMUX-yes) > +FATE_CAF_FFMPEG_FFPROBE-$(call ALLYES, FILE_PROTOCOL CAF_MUXER\ > + CAF_DEMUXER FRAMECRC_MUXER \ > + PIPE_PROTOCOL) \ > + += $(FATE_CAF_REMUX_FFPROBE-yes) > FATE_SAMPLES_FFMPEG += $(FATE_CAF_FFMPEG-yes) > -fate-caf: $(FATE_CAF_FFMPEG-yes) > +FATE_SAMPLES_FFMPEG_FFPROBE += $(FATE_CAF_FFMPEG_FFPROBE-yes) > +fate-caf: $(FATE_CAF_FFMPEG-yes) $(FATE_CAF_FFMPEG_FFPROBE-yes) > diff --git a/tests/ref/fate/caf-alac-remux b/tests/ref/fate/caf-alac-remux > new file mode 100644 > index 00..5c1b2d1eee > --- /dev/null > +++ b/tests/ref/fate/caf-alac-remux > @@ -0,0 +1,28 @@ > +e0a94c78e9680398adce2ac72d682f48 *tests/data/fate/caf-alac-remux.caf > +1292701 tests/data/fate/caf-alac-remux.caf > +#extradata 0: 36, 0x562b05d8 > +#tb 0: 1/44100 > +#media_type 0: audio > +#codec_id 0: alac > +#sample_rate 0: 44100 > +#channel_layout 0: 3 > +#channel_layout_name 0: stereo > +0, 0, 0,0, 32, 0xa0af0dfe > +0, 4096, 4096,0, 6701, 0xa9ddc14e > +0, 8192, 8192,0, 6639, 0x3ccda8d6 > +[FORMAT] > +TAG:major_brand=M4A The commit hocks did not like the trailing whitespace in the above line. I have therefore adapted the test to remove the major_brand metadata completely, thereby also providing coverage for removing metadata on the command line. This was previously uncovered. > +TAG:minor_version=0 > +TAG:compatible_brands=M4A mp42isom > +TAG:disc=1 > +TAG:title=Inside > +TAG:compilation=1 > +TAG:gapless_playback=0 > +TAG:track=5/13 > +TAG:Encoding Params=vers > +TAG:iTunNORM= 04DF 04C2 1E64 1AB3 0FB9 0FB9 6480 > 6480 0FB9 0B52 > +TAG:artist=Maxwell Strait > +TAG:album_artist=Maxwell Strait > +TAG:album=OpenMusic > +TAG:genre=Rock > +[/FORMAT] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmp
Re: [FFmpeg-devel] [PATCH 1/5] avcodec/mlpenc: Set AV_PKT_FLAG_KEY manually
Andreas Rheinhardt: > TrueHD/MLP is one of the audio formats with keyframes. Currently, > the generic encoding code just sets the keyframe flag for all > returned packets, yet this is wrong for these encoders and will > be changed in a future commit. So set the flag here for those > packets that ought to have it. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mlpenc.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libavcodec/mlpenc.c b/libavcodec/mlpenc.c > index ef01c1d282..d8783b6f56 100644 > --- a/libavcodec/mlpenc.c > +++ b/libavcodec/mlpenc.c > @@ -2114,6 +2114,7 @@ static int mlp_encode_frame(AVCodecContext *avctx, > AVPacket *avpkt, > restart_frame = !ctx->frame_index; > > if (restart_frame) { > +avpkt->flags |= AV_PKT_FLAG_KEY; > set_major_params(ctx); > if (ctx->min_restart_interval != ctx->max_restart_interval) > process_major_frame(ctx); > Will apply this patchset (without the now redundant 3/5 tonight unless there are objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] libavfilter/x86/vf_hflip: add ff_flip_byte/short_avx512()
Ping. Jianhua wrote: > > Ping. > > Jianhua wrote: > > From: ffmpeg-devel On Behalf Of > Wu, > > Jianhua > > Sent: Tuesday, September 14, 2021 1:02 PM > > To: FFmpeg development discussions and patches > de...@ffmpeg.org> > > Subject: Re: [FFmpeg-devel] [PATCH 1/4] libavfilter/x86/vf_hflip: add > > ff_flip_byte/short_avx512() > > > > > > It seemed that there is no one with objection over the past two weeks. > > Are the patches able to be applied? > > > Hi there, Looks like one month elapsed. Any update? Thanks, Jianhua ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/4] libavfilter/x86/vf_hflip: add ff_flip_byte/short_avx512()
On Mon, Sep 27, 2021 at 8:48 AM Wu, Jianhua wrote: > Ping. > Jianhua wrote: > > > > Ping. > > > > Jianhua wrote: > > > From: ffmpeg-devel On Behalf Of > > Wu, > > > Jianhua > > > Sent: Tuesday, September 14, 2021 1:02 PM > > > To: FFmpeg development discussions and patches > > de...@ffmpeg.org> > > > Subject: Re: [FFmpeg-devel] [PATCH 1/4] libavfilter/x86/vf_hflip: add > > > ff_flip_byte/short_avx512() > > > > > > > > > It seemed that there is no one with objection over the past two weeks. > > > Are the patches able to be applied? > > > > > > Hi there, > > Looks like one month elapsed. Any update? > No rushing needed. > Thanks, > Jianhua > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".