[FFmpeg-devel] [PATCH] configure: arm: Don't add -march= to the compiler if no preference was passed
If no --cpu= option was passed to configure, we detect what the compiler defaults to. This detected value was then fed back to the rest of the configure logic, as if it was an explicit choice. This breaks on Ubuntu 21.10 with GCC 11.1. Since GCC 8, it's possible to add configure extra features via the -march option, like e.g. -march=armv7-a+neon. If the -mfpu= option is configured to default to 'auto', the fpu setting gets taken from the -march option. GCC 11.1 in Ubuntu seems to be configured to use -mfpu=auto. This has the effect of breaking any compilation command that specifies -march=armv7-a, because the driver implicitly also adds -mfloat-abi=hard, and that combination results in this error: cc1: error: ‘-mfloat-abi=hard’: selected processor lacks an FPU Therefore, restructure configure. If no specific preference was set (and the 'cpu' configure variable was set as the output of probe_arm_arch), the value we tried to set via -march= was the same value that we just tried to detect as the compiler default. So instead, just try to detect what the compiler defaults to, with to allow setting other configure settings (such as 'fast_unaligned'), but don't try to spell out the compiler's default via the -march flag. Signed-off-by: Martin Storsjö --- configure | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 9249254b70..3a05b8294b 100755 --- a/configure +++ b/configure @@ -5009,9 +5009,11 @@ elif enabled arm; then fi } -[ "$cpu" = generic ] && cpu=$(probe_arm_arch) case $cpu in +generic) +subarch=$(probe_arm_arch | sed 's/[^a-z0-9]//g') +;; armv*) cpuflags="-march=$cpu" subarch=$(echo $cpu | sed 's/[^a-z0-9]//g') -- 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 2/2] avcodec/mlpenc: fix encoding stereo single stream in TrueHD
Quoting Paul B Mahol (2021-09-18 19:21:05) > Signed-off-by: Paul B Mahol > --- > libavcodec/mlpenc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Sure would be nice to have tests. -- Anton Khirnov ___ 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 v2 1/2] avformat/utils: Add av_stream_get_codec_properties()
Quoting Soft Works (2021-09-19 00:08:18) > Signed-off-by: softworkz > --- > doc/APIchanges | 3 +++ > libavformat/avformat.h | 9 + > libavformat/utils.c| 5 + > libavformat/version.h | 2 +- > 4 files changed, 18 insertions(+), 1 deletion(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index cf6105c99e..fee94ccadd 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -14,6 +14,9 @@ libavutil: 2021-04-27 > > API changes, most recent first: > > +2021-04-27 - xx - lavf 59.6.100 - avformat.h > + Add av_stream_get_codec_properties() > + > 2021-09-17 - xx - lavu 57.5.101 - buffer.h >Constified the input parameters in av_buffer_replace(), av_buffer_ref(), >and av_buffer_pool_buffer_get_opaque(). > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 3a5bc8a06d..89ed984d1d 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -2763,6 +2763,15 @@ int > avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt, > */ > AVRational av_stream_get_codec_timebase(const AVStream *st); > > +/** > + * Get the internal codec properties from a stream. This is a bad idea. We do not want to hardcode "internal codec properties" into the API. -- Anton Khirnov ___ 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 v2 2/2] ffprobe: Fix incorrect display of closed_captions property
Quoting James Almer (2021-09-19 15:04:11) > > Yes, something like that could be forced (ReadInterval in ffprobe). > > > > > What you're essentially suggesting is more or less a duplication > > of avformat_find_stream_info() and to run it right after > > avformat_find_stream_info() has just been run. > > > > I'm sure we can find a better solution :-) > > We could always not print codec level information, like the presence of > closed captions in a bitstream, when container level information is > requested, as is the case of show_streams. > It is in fact a per-frame property. One could even not show up until > halfways into the video and then not even avformat_find_stream_info() > would reflect it. And this flag is essentially a "The decoder found a CC > at some point" event flag rather than a stream parameter. > > The fact ffprobe looks at the decoder context to print stream values to > begin with is questionable, and as mentioned, its output is not even > guaranteed and depends on external factors, like other user-provided > runtime options. I agree. ffprobe should stop printing that field as a part of the global stream information, it simply cannot work reliably. Print it as a part of the frame data instead. -- Anton Khirnov ___ 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] avcodec: add native Speex decoder
Quoting Paul B Mahol (2021-09-19 12:01:06) > Signed-off-by: Paul B Mahol > --- > libavcodec/Makefile|1 + > libavcodec/allcodecs.c |1 + > libavcodec/speexdata.h | 764 > libavcodec/speexdec.c | 1538 > tests/ref/fate/source |2 + > 5 files changed, 2306 insertions(+) > create mode 100644 libavcodec/speexdata.h > create mode 100644 libavcodec/speexdec.c This needs a test. -- Anton Khirnov ___ 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] avcodec/cbs_h265_syntax_template: Limit sps_num_palette_predictor_initializer_minus1 to 127
On 9/19/2021 5:35 PM, Michael Niedermayer wrote: Fixes: index 128 out of bounds for type 'uint16_t [128]' Fixes: 38651/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6296416058736640 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/cbs_h265_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 67bc77f9751..fb8ac4a4a77 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -728,7 +728,7 @@ static int FUNC(sps_scc_extension)(CodedBitstreamContext *ctx, RWContext *rw, flag(sps_palette_predictor_initializer_present_flag); if (current->sps_palette_predictor_initializer_present_flag) { -ue(sps_num_palette_predictor_initializer_minus1, 0, 128); +ue(sps_num_palette_predictor_initializer_minus1, 0, 127); for (comp = 0; comp < (current->chroma_format_idc ? 3 : 1); comp++) { int bit_depth = comp == 0 ? current->bit_depth_luma_minus8 + 8 : current->bit_depth_chroma_minus8 + 8; sps_num_palette_predictor_initializer_minus1 plus 1 must be at most 128, so 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 v2 2/2] ffprobe: Fix incorrect display of closed_captions property
> -Original Message- > From: ffmpeg-devel On Behalf Of Anton > Khirnov > Sent: Monday, 20 September 2021 13:07 > To: James Almer ; ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v2 2/2] ffprobe: Fix incorrect display of > closed_captions property > > Quoting James Almer (2021-09-19 15:04:11) > > > > Yes, something like that could be forced (ReadInterval in ffprobe). > > > > > > > > What you're essentially suggesting is more or less a duplication > > > of avformat_find_stream_info() and to run it right after > > > avformat_find_stream_info() has just been run. > > > > > > I'm sure we can find a better solution :-) > > > > We could always not print codec level information, like the presence of > > closed captions in a bitstream, when container level information is > > requested, as is the case of show_streams. > > It is in fact a per-frame property. One could even not show up until > > halfways into the video and then not even avformat_find_stream_info() > > would reflect it. And this flag is essentially a "The decoder found a CC > > at some point" event flag rather than a stream parameter. > > > > The fact ffprobe looks at the decoder context to print stream values to > > begin with is questionable, and as mentioned, its output is not even > > guaranteed and depends on external factors, like other user-provided > > runtime options. > > I agree. ffprobe should stop printing that field as a part of the global > stream information, it simply cannot work reliably. Well, but that's what the concept of "probing" is all about: Take a selected amount of a subject (the "probe") and generate an aggregated summary result from that probe. It's not only the small detail of closed_captions - many other essential other information (like available streams and details) can (depending on the container) be subject to that procedure. Without relying on those results, ffmpeg couldn't work like it does. From practical experience, I can says that the closed_captions information that ffmpeg/ffprobe gathers when executing avformat_find_stream_info() is sufficiently reliable. That's exactly the information that we need (further downstream as a consumer of ffmpeg/ffprobe) - plus: that's the information that ffmpeg has available internally. For being able to properly interoperate with ffmpeg, it's important that the information that we get from ffprobe is exactly matching what ffmpeg has internally (given that the probesize and analyzeduration used for ffprobe and ffmpeg are equal). That’s why I think that there exists a legitimate interest for a consumer to be able to access this information, without needing to repeat and duplicate the probing procedure that has already been run. 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".
Re: [FFmpeg-devel] [PATCH v2 2/2] ffprobe: Fix incorrect display of closed_captions property
> -Original Message- > From: ffmpeg-devel On Behalf Of Anton > Khirnov > Sent: Monday, 20 September 2021 13:07 > To: James Almer ; ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v2 2/2] ffprobe: Fix incorrect display of > closed_captions property > > Quoting James Almer (2021-09-19 15:04:11) > > > > Yes, something like that could be forced (ReadInterval in ffprobe). > > > > > > > > What you're essentially suggesting is more or less a duplication > > > of avformat_find_stream_info() and to run it right after > > > avformat_find_stream_info() has just been run. > > > > > > I'm sure we can find a better solution :-) > > > > We could always not print codec level information, like the presence of > > closed captions in a bitstream, when container level information is > > requested, as is the case of show_streams. > > It is in fact a per-frame property. One could even not show up until > > halfways into the video and then not even avformat_find_stream_info() > > would reflect it. And this flag is essentially a "The decoder found a CC > > at some point" event flag rather than a stream parameter. > > > > The fact ffprobe looks at the decoder context to print stream values to > > begin with is questionable, and as mentioned, its output is not even > > guaranteed and depends on external factors, like other user-provided > > runtime options. > > I agree. ffprobe should stop printing that field as a part of the global > stream information, it simply cannot work reliably. > > Print it as a part of the frame data instead. There's also a very practical new use case associated to that subject: My latest patchset regarding subtitle filtering includes a new filter named 'split_cc'. It has a video input and output and a second output providing subtitle data, which can be processed in many ways that haven't been available yet. Users need an easy and direct indication to know whether CC data is available and it makes sense to use the filter. Removing that information from the codec string would rather be counter-productive in this regard. 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 v3 3/5] avformat/{aviobuf, avio_internal}: add max_len argument to ff_read_string_to_bprint_overwrite
From: Jan Ekström This is especially useful when reading things such as null-terminated strings from MOV/MP4-likes, where the size of the box is known, but not the exact size of the string. Signed-off-by: Jan Ekström --- libavformat/avio_internal.h | 13 ++--- libavformat/aviobuf.c | 23 +++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 3b3ed3b619..e40adc944e 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -247,14 +247,21 @@ int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, struct AVBPrint *bp); /** * Read a whole null-terminated string of text from AVIOContext to an AVBPrint - * buffer overwriting its contents. Stop reading after reaching a \\0 or - * EOF. + * buffer overwriting its contents. Stop reading after reaching the maximum + * length, a \\0 or EOF. * * @param s the read-only AVIOContext * @param bp the AVBPrint buffer + * @param max_len the maximum length to be read from the AVIOContext. + *Negative (< 0) values signal that there is no known maximum + *length applicable. A maximum length of zero means that the + *AVIOContext is not touched, and the function returns + *with a read length of zero. In all cases the AVBprint + *is cleared. * @return the length of the read string not including the terminating null, * negative on error, or if the buffer becomes truncated. */ -int64_t ff_read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp); +int64_t ff_read_string_to_bprint_overwrite(AVIOContext *s, struct AVBPrint *bp, + int64_t max_len); #endif /* AVFORMAT_AVIO_INTERNAL_H */ diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 3b6f9aed42..b43b24302b 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -809,13 +809,17 @@ typedef enum FFBPrintReadStringMode { } FFBPrintReadStringMode; static int64_t read_string_to_bprint(AVIOContext *s, AVBPrint *bp, - FFBPrintReadStringMode mode) + FFBPrintReadStringMode mode, + int64_t max_len) { int len, end; int64_t read = 0; char tmp[1024]; char c; +if (!max_len) +return 0; + do { len = 0; do { @@ -824,10 +828,11 @@ static int64_t read_string_to_bprint(AVIOContext *s, AVBPrint *bp, c == '\0'); if (!end) tmp[len++] = c; -} while (!end && len < sizeof(tmp)); +} while (!end && len < sizeof(tmp) && + ((max_len < 0) || (read + len < max_len))); av_bprint_append_data(bp, tmp, len); read += len; -} while (!end); +} while (!end && ((max_len < 0) || (read < max_len))); if (mode == FFBPrintReadLine && c == '\r' && avio_r8(s) != '\n' && !avio_feof(s)) @@ -843,12 +848,13 @@ static int64_t read_string_to_bprint(AVIOContext *s, AVBPrint *bp, } static int64_t read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp, - FFBPrintReadStringMode mode) + FFBPrintReadStringMode mode, + int64_t max_len) { int64_t ret; av_bprint_clear(bp); -ret = read_string_to_bprint(s, bp, mode); +ret = read_string_to_bprint(s, bp, mode, max_len); if (ret < 0) return ret; @@ -860,12 +866,13 @@ static int64_t read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp, int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp) { -return read_string_to_bprint_overwrite(s, bp, FFBPrintReadLine); +return read_string_to_bprint_overwrite(s, bp, FFBPrintReadLine, -1); } -int64_t ff_read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp) +int64_t ff_read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp, + int64_t max_len) { -return read_string_to_bprint_overwrite(s, bp, FFBPrintReadString); +return read_string_to_bprint_overwrite(s, bp, FFBPrintReadString, max_len); } int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) -- 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 v3 5/5] avformat/{isom, movenc}: add kind box compatibility mode for Unified Origin
From: Jan Ekström Unfortunately the current production versions of this software do not 100% adhere to the CMAF specification, and have decided to utilize the HTML5 media track identifier for audio descriptions. This way the default mode of operation is according to the CMAF specification, but it is also possible to output streams with which this piece of software is capable of interoperating with. Signed-off-by: Jan Ekström --- libavformat/isom.c| 23 -- libavformat/isom.h| 7 ++ libavformat/movenc.c | 12 ++- libavformat/movenc.h | 2 + tests/fate/mov.mak| 8 ++ ...p4-disposition-unified-origin-mpegts-remux | 81 +++ 6 files changed, 125 insertions(+), 8 deletions(-) create mode 100644 tests/ref/fate/mov-mp4-disposition-unified-origin-mpegts-remux diff --git a/libavformat/isom.c b/libavformat/isom.c index 300ba927c2..512ffba651 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -433,19 +433,32 @@ void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout) static const struct MP4TrackKindValueMapping dash_role_map[] = { { AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_CAPTIONS, -"caption" }, +"caption", +KindWritingModeCMAF | KindWritingModeUnifiedOrigin }, { AV_DISPOSITION_COMMENT, -"commentary" }, +"commentary", +KindWritingModeCMAF | KindWritingModeUnifiedOrigin }, { AV_DISPOSITION_VISUAL_IMPAIRED|AV_DISPOSITION_DESCRIPTIONS, -"description" }, +"description", +KindWritingModeCMAF }, { AV_DISPOSITION_DUB, -"dub" }, +"dub", +KindWritingModeCMAF | KindWritingModeUnifiedOrigin }, { AV_DISPOSITION_FORCED, -"forced-subtitle" }, +"forced-subtitle", +KindWritingModeCMAF | KindWritingModeUnifiedOrigin }, +{ 0, NULL } +}; + +static const struct MP4TrackKindValueMapping html_kind_map[] = { +{ AV_DISPOSITION_VISUAL_IMPAIRED|AV_DISPOSITION_DESCRIPTIONS, +"main-desc", + KindWritingModeUnifiedOrigin }, { 0, NULL } }; const struct MP4TrackKindMapping ff_mov_track_kind_table[] = { { "urn:mpeg:dash:role:2011", dash_role_map }, +{ "about:html-kind", html_kind_map }, { 0, NULL } }; diff --git a/libavformat/isom.h b/libavformat/isom.h index c62fcf2bfe..f0381e9a8e 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -390,9 +390,16 @@ static inline enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags) #define MOV_ISMV_TTML_TAG MKTAG('d', 'f', 'x', 'p') #define MOV_MP4_TTML_TAG MKTAG('s', 't', 'p', 'p') +enum MP4TrackKindWritingMode { +KindWritingModeCMAF = (1 << 0), +KindWritingModeUnifiedOrigin = (1 << 1), +KindWritingModeNB, +}; + struct MP4TrackKindValueMapping { int disposition; const char *value; +uint32_twriting_modes; }; struct MP4TrackKindMapping { diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 0c4a24c313..1550bdd16f 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -111,6 +111,9 @@ static const AVOption options[] = { { "pts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MOV_PRFT_SRC_PTS}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM, "prft"}, { "empty_hdlr_name", "write zero-length name string in hdlr atoms within mdia and minf atoms", offsetof(MOVMuxContext, empty_hdlr_name), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, { "movie_timescale", "set movie timescale", offsetof(MOVMuxContext, movie_timescale), AV_OPT_TYPE_INT, {.i64 = MOV_TIMESCALE}, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, +{ "kind_writing_mode", "set kind box writing mode", offsetof(MOVMuxContext, kind_writing_mode), AV_OPT_TYPE_INT, {.i64 = KindWritingModeCMAF}, KindWritingModeCMAF, KindWritingModeNB - 1, AV_OPT_FLAG_ENCODING_PARAM, "kind_writing_mode"}, +{ "cmaf", "CMAF writing mode", 0, AV_OPT_TYPE_CONST, {.i64 = KindWritingModeCMAF}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "kind_writing_mode"}, +{ "unified_origin", "Compatibility mode for Unified Origin (all DASH except for audio description)", 0, AV_OPT_TYPE_CONST, {.i64 = KindWritingModeUnifiedOrigin}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "kind_writing_mode"}, { NULL }, }; @@ -3355,7 +3358,8 @@ static int mov_write_track_kind(AVIOContext *pb, const char *scheme_uri, return update_size(pb, pos); } -static int mov_write_track_kinds(AVIOContext *pb, AVStream *st) +static int mov_write_track_kinds(AVIOContext *pb, AVStream *st, + enum MP4TrackKindWritingMode mode) { int ret = AVERROR_BUG; @@ -3364,7 +3368,8 @@ static int mov_write_track_kinds(AVIOContext *pb, AVStream *st) for (int j = 0; map.value_maps[j].disposition; j++) { const struct MP4TrackKindValueMapping value_map = map.val
[FFmpeg-devel] [PATCH v3 2/5] avformat/{aviobuf, avio_internal}: add ff_read_string_to_bprint_overwrite
From: Jan Ekström For now, same as ff_read_line_to_bprint_overwrite, but reads until the end of a null-terminated string. Signed-off-by: Jan Ekström --- libavformat/avio_internal.h | 12 libavformat/aviobuf.c | 5 + 2 files changed, 17 insertions(+) diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 8b9e048f73..3b3ed3b619 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -245,4 +245,16 @@ struct AVBPrint; */ int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, struct AVBPrint *bp); +/** + * Read a whole null-terminated string of text from AVIOContext to an AVBPrint + * buffer overwriting its contents. Stop reading after reaching a \\0 or + * EOF. + * + * @param s the read-only AVIOContext + * @param bp the AVBPrint buffer + * @return the length of the read string not including the terminating null, + * negative on error, or if the buffer becomes truncated. + */ +int64_t ff_read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp); + #endif /* AVFORMAT_AVIO_INTERNAL_H */ diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index f24a3b0fe2..3b6f9aed42 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -863,6 +863,11 @@ int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp) return read_string_to_bprint_overwrite(s, bp, FFBPrintReadLine); } +int64_t ff_read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp) +{ +return read_string_to_bprint_overwrite(s, bp, FFBPrintReadString); +} + int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) { int i; -- 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 v3 1/5] avformat/aviobuf: add a full string reading mode to read_line_to_bprint
From: Jan Ekström Additionally: * rename it to read_string_to_bprint * split most of ff_read_line_to_bprint_overwrite into an internal function which can then be utilized to implement other functionality without duplicating code. Signed-off-by: Jan Ekström --- libavformat/aviobuf.c | 24 +++- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 28db2c7dbd..f24a3b0fe2 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -803,7 +803,13 @@ int ff_get_chomp_line(AVIOContext *s, char *buf, int maxlen) return len; } -static int64_t read_line_to_bprint(AVIOContext *s, AVBPrint *bp) +typedef enum FFBPrintReadStringMode { +FFBPrintReadString = 0, +FFBPrintReadLine = 1, +} FFBPrintReadStringMode; + +static int64_t read_string_to_bprint(AVIOContext *s, AVBPrint *bp, + FFBPrintReadStringMode mode) { int len, end; int64_t read = 0; @@ -814,7 +820,8 @@ static int64_t read_line_to_bprint(AVIOContext *s, AVBPrint *bp) len = 0; do { c = avio_r8(s); -end = (c == '\r' || c == '\n' || c == '\0'); +end = ((mode == FFBPrintReadLine && (c == '\r' || c == '\n')) || + c == '\0'); if (!end) tmp[len++] = c; } while (!end && len < sizeof(tmp)); @@ -822,7 +829,8 @@ static int64_t read_line_to_bprint(AVIOContext *s, AVBPrint *bp) read += len; } while (!end); -if (c == '\r' && avio_r8(s) != '\n' && !avio_feof(s)) +if (mode == FFBPrintReadLine && +c == '\r' && avio_r8(s) != '\n' && !avio_feof(s)) avio_skip(s, -1); if (!c && s->error) @@ -834,12 +842,13 @@ static int64_t read_line_to_bprint(AVIOContext *s, AVBPrint *bp) return read; } -int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp) +static int64_t read_string_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp, + FFBPrintReadStringMode mode) { int64_t ret; av_bprint_clear(bp); -ret = read_line_to_bprint(s, bp); +ret = read_string_to_bprint(s, bp, mode); if (ret < 0) return ret; @@ -849,6 +858,11 @@ int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp) return bp->len; } +int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp) +{ +return read_string_to_bprint_overwrite(s, bp, FFBPrintReadLine); +} + int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) { int i; -- 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 v3 0/5] Support for stream dispositions in MP4
Compared to v2: * aviobuf changes to make a function useful in MP4 null-delimited string parsing into AVBPrint. ** Extended read_line_to_bprint to be a more generic read_string_to_bprint. ** Added a maximum length argument to read_string_to_bprint. ** Added a new function ff_read_string_to_bprint_overwrite. * Switched from buffers with hard-coded sizes in avformat/mov to AVBPrint based parsing with ff_read_string_to_bprint_overwrite. * Minor changes to the actual primary changes of the patch set: ** avformat/isom: "KindWritingModeCMAF | KindWritingModeUnifiedOrigin" now has spaces between the bitmasks for better readability. ** avformat/{isom,movenc}: add and utilize KindWritingModeNB for the maximum value limit in the AVOption definition. First patch implements the CMAF specified way of flagging what in FFmpeg are are called stream dispositions. Other identifiers such as HTML media track kinds are allowed, but if there is a DASH identifier for something, it should be utilized in stead. Second patch is a compatibility patch for one of the vendors that supports this feature. If this is considered a too bad of a hack, we can drop it from being upstreamed, but at least I wanted to bring it up :) . The compatibility mode is not the default, so it should also not proliferate such behavior. Best regards, Jan Jan Ekström (5): avformat/aviobuf: add a full string reading mode to read_line_to_bprint avformat/{aviobuf,avio_internal}: add ff_read_string_to_bprint_overwrite avformat/{aviobuf,avio_internal}: add max_len argument to ff_read_string_to_bprint_overwrite avformat/{isom,mov,movenc}: add support for CMAF DASH roles avformat/{isom,movenc}: add kind box compatibility mode for Unified Origin libavformat/avio_internal.h | 19 libavformat/aviobuf.c | 40 ++-- libavformat/isom.c| 32 +++ libavformat/isom.h| 19 libavformat/mov.c | 91 +++ libavformat/movenc.c | 57 libavformat/movenc.h | 2 + tests/fate/mov.mak| 17 .../ref/fate/mov-mp4-disposition-mpegts-remux | 81 + ...p4-disposition-unified-origin-mpegts-remux | 81 + 10 files changed, 432 insertions(+), 7 deletions(-) create mode 100644 tests/ref/fate/mov-mp4-disposition-mpegts-remux create mode 100644 tests/ref/fate/mov-mp4-disposition-unified-origin-mpegts-remux -- 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 v3 4/5] avformat/{isom, mov, movenc}: add support for CMAF DASH roles
From: Jan Ekström This information is coded in a standard MP4 KindBox and utilizes the scheme and values as per the DASH role scheme defined in MPEG-DASH. Other schemes are technically allowed, but where multiple schemes define the same concepts, the DASH scheme should be utilized. Such flagging is additionally utilized by the DASH-IF CMAF ingest specification, enabling an encoder to inform the following component of the roles of the incoming media streams. A test is added for this functionality in a similar manner to the matroska test. Signed-off-by: Jan Ekström --- libavformat/isom.c| 19 libavformat/isom.h| 12 +++ libavformat/mov.c | 91 +++ libavformat/movenc.c | 51 +++ tests/fate/mov.mak| 9 ++ .../ref/fate/mov-mp4-disposition-mpegts-remux | 81 + 6 files changed, 263 insertions(+) create mode 100644 tests/ref/fate/mov-mp4-disposition-mpegts-remux diff --git a/libavformat/isom.c b/libavformat/isom.c index 4df5440023..300ba927c2 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -430,3 +430,22 @@ void ff_mov_write_chan(AVIOContext *pb, int64_t channel_layout) } avio_wb32(pb, 0); // mNumberChannelDescriptions } + +static const struct MP4TrackKindValueMapping dash_role_map[] = { +{ AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_CAPTIONS, +"caption" }, +{ AV_DISPOSITION_COMMENT, +"commentary" }, +{ AV_DISPOSITION_VISUAL_IMPAIRED|AV_DISPOSITION_DESCRIPTIONS, +"description" }, +{ AV_DISPOSITION_DUB, +"dub" }, +{ AV_DISPOSITION_FORCED, +"forced-subtitle" }, +{ 0, NULL } +}; + +const struct MP4TrackKindMapping ff_mov_track_kind_table[] = { +{ "urn:mpeg:dash:role:2011", dash_role_map }, +{ 0, NULL } +}; diff --git a/libavformat/isom.h b/libavformat/isom.h index 34a58c79b7..c62fcf2bfe 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -390,4 +390,16 @@ static inline enum AVCodecID ff_mov_get_lpcm_codec_id(int bps, int flags) #define MOV_ISMV_TTML_TAG MKTAG('d', 'f', 'x', 'p') #define MOV_MP4_TTML_TAG MKTAG('s', 't', 'p', 'p') +struct MP4TrackKindValueMapping { +int disposition; +const char *value; +}; + +struct MP4TrackKindMapping { +const char *scheme_uri; +const struct MP4TrackKindValueMapping *value_maps; +}; + +extern const struct MP4TrackKindMapping ff_mov_track_kind_table[]; + #endif /* AVFORMAT_ISOM_H */ diff --git a/libavformat/mov.c b/libavformat/mov.c index ca14646a38..81e8d3bac9 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -28,6 +28,7 @@ #include #include "libavutil/attributes.h" +#include "libavutil/bprint.h" #include "libavutil/channel_layout.h" #include "libavutil/internal.h" #include "libavutil/intreadwrite.h" @@ -6851,6 +6852,95 @@ static int mov_read_dvcc_dvvc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } +static int mov_read_kind(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ +AVFormatContext *ctx = c->fc; +AVStream *st = NULL; +AVBPrint scheme_buf, value_buf; +int64_t scheme_str_len = 0, value_str_len = 0; +int version, flags, ret = AVERROR_BUG; +int64_t size = atom.size; + +if (atom.size < 6) +// 4 bytes for version + flags, 2x 1 byte for null +return AVERROR_INVALIDDATA; + +if (c->fc->nb_streams < 1) +return 0; +st = c->fc->streams[c->fc->nb_streams-1]; + +version = avio_r8(pb); +flags = avio_rb24(pb); +size -= 4; + +if (version != 0 || flags != 0) { +av_log(ctx, AV_LOG_ERROR, + "Unsupported 'kind' box with version %d, flags: %x", + version, flags); +return AVERROR_INVALIDDATA; +} + +av_bprint_init(&scheme_buf, 0, AV_BPRINT_SIZE_UNLIMITED); +av_bprint_init(&value_buf, 0, AV_BPRINT_SIZE_UNLIMITED); + +if ((scheme_str_len = ff_read_string_to_bprint_overwrite(pb, &scheme_buf, + size)) < 0) { +ret = scheme_str_len; +goto cleanup; +} + +if (scheme_str_len + 1 >= size) { +// we need to have another string, even if nullptr. +// we check with + 1 since we expect that if size was not hit, +// an additional null was read. +ret = AVERROR_INVALIDDATA; +goto cleanup; +} + +size -= scheme_str_len + 1; + +if ((value_str_len = ff_read_string_to_bprint_overwrite(pb, &value_buf, +size)) < 0) { +ret = value_str_len; +goto cleanup; +} + +if (value_str_len == size) { +// in case of no trailing null, box is not valid. +ret = AVERROR_INVALIDDATA; +goto cleanup; +} + +av_log(ctx, AV_LOG_TRACE, + "%s stream %d KindBox(scheme: %s, value: %s)
[FFmpeg-devel] [PATCH] avfilter: add morpho filter
Signed-off-by: Paul B Mahol --- doc/filters.texi | 32 ++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_morpho.c | 865 +++ 4 files changed, 899 insertions(+) create mode 100644 libavfilter/vf_morpho.c diff --git a/doc/filters.texi b/doc/filters.texi index 0c45fb710d..b46556c12c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10225,6 +10225,7 @@ A number representing position of the first frame with respect to the telecine pattern. This is to be used if the stream is cut. The default value is @code{0}. @end table +@anchor{dilation} @section dilation Apply dilation effect to the video. @@ -11541,6 +11542,7 @@ value. @end table +@anchor{erosion} @section erosion Apply erosion effect to the video. @@ -15316,6 +15318,36 @@ Default value is 0. This filter supports the all above options as @ref{commands}. +@section morpho + +This filter allows to apply main morphological grayscale transforms, +erode and dilate with arbitrary structures set in second input stream. + +Unlike naive implementation and much slower performance in @ref{erosion} +and @ref{dilation} filters, when speed is critical @code{morpho} filter +should be used instead. + +A description of accepted options follows, + +@table @option +@item mode +Set morphological transform to apply, can be @code{erode} or @code{dilate}. +Default is @code{erode}. + +@item planes +Set planes to filter, by default all planes except alpha are filtered. + +@item structure +Set which structure video frames will be processed from second input stream, +can be @var{first} or @var{all}. Default is @var{all}. +@end table + +The @code{morpho} filter also supports the @ref{framesync} options. + +@subsection Commands + +This filter supports same @ref{commands} as options. + @section mpdecimate Drop frames that do not differ greatly from the previous frame in diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 272f876c07..06e01da38e 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -350,6 +350,7 @@ OBJS-$(CONFIG_MIDEQUALIZER_FILTER) += vf_midequalizer.o framesync.o OBJS-$(CONFIG_MINTERPOLATE_FILTER) += vf_minterpolate.o motion_estimation.o OBJS-$(CONFIG_MIX_FILTER)+= vf_mix.o framesync.o OBJS-$(CONFIG_MONOCHROME_FILTER) += vf_monochrome.o +OBJS-$(CONFIG_MORPHO_FILTER) += vf_morpho.o OBJS-$(CONFIG_MPDECIMATE_FILTER) += vf_mpdecimate.o OBJS-$(CONFIG_NEGATE_FILTER) += vf_lut.o OBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 1283d124b8..10dfe72131 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -335,6 +335,7 @@ extern const AVFilter ff_vf_midequalizer; extern const AVFilter ff_vf_minterpolate; extern const AVFilter ff_vf_mix; extern const AVFilter ff_vf_monochrome; +extern const AVFilter ff_vf_morpho; extern const AVFilter ff_vf_mpdecimate; extern const AVFilter ff_vf_msad; extern const AVFilter ff_vf_negate; diff --git a/libavfilter/vf_morpho.c b/libavfilter/vf_morpho.c new file mode 100644 index 00..46c641c4b9 --- /dev/null +++ b/libavfilter/vf_morpho.c @@ -0,0 +1,865 @@ +/* + * Copyright (c) 2016 ReneBrals + * Copyright (c) 2021 Paul B Mahol + * + * This file is part of FFmpeg. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "avfilter.h" +#include "formats.h" +#include "internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/imgutils.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "video.h" +#include "framesync.h" + +typedef struct IPlane { +uint8_t **img; +size_t W; +size_t H; +size_t range; +int type_size; + +void (*max)(uint8_t *c, uint8_t *a, uint8_t *b, size_t x); +void (*min)(uint8_t *c, uint8_t
Re: [FFmpeg-devel] [PATCH 2/2] avcodec/mlpenc: fix encoding stereo single stream in TrueHD
On Mon, Sep 20, 2021 at 12:56 PM Anton Khirnov wrote: > Quoting Paul B Mahol (2021-09-18 19:21:05) > > Signed-off-by: Paul B Mahol > > --- > > libavcodec/mlpenc.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > Sure would be nice to have tests. > Too soon, encoder is still experimental. > -- > Anton Khirnov > ___ 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: add morpho filter
Paul B Mahol: > Signed-off-by: Paul B Mahol > --- > +static int query_formats(AVFilterContext *ctx) > +{ > +static const enum AVPixelFormat pix_fmts[] = { > +AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P, > +AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, > +AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVA420P, > AV_PIX_FMT_YUV420P, > +AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ420P, > +AV_PIX_FMT_YUVJ411P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, > +AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GRAY8, > AV_PIX_FMT_GRAY9, > +AV_PIX_FMT_YUV420P9, AV_PIX_FMT_YUV422P9, AV_PIX_FMT_YUV444P9, > AV_PIX_FMT_GBRP9, > +AV_PIX_FMT_YUVA420P9, AV_PIX_FMT_YUVA422P9, AV_PIX_FMT_YUVA444P9, > +AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, > +AV_PIX_FMT_YUV420P12, AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV444P12, > AV_PIX_FMT_YUV440P12, > +AV_PIX_FMT_YUV420P14, AV_PIX_FMT_YUV422P14, AV_PIX_FMT_YUV444P14, > +AV_PIX_FMT_YUV420P16, AV_PIX_FMT_YUV422P16, AV_PIX_FMT_YUV444P16, > +AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_YUVA444P10, > +AV_PIX_FMT_YUVA422P12, AV_PIX_FMT_YUVA444P12, > +AV_PIX_FMT_YUVA420P16, AV_PIX_FMT_YUVA422P16, AV_PIX_FMT_YUVA444P16, > +AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, AV_PIX_FMT_GBRP14, > AV_PIX_FMT_GBRP16, > +AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16, > +AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, > AV_PIX_FMT_GRAY16, > +AV_PIX_FMT_NONE > +}; > + > +return ff_set_common_formats_from_list(ctx, pix_fmts); > +} > + [...] > + > +static int config_input_structure(AVFilterLink *inlink) > +{ > +AVFilterContext *ctx = inlink->dst; > +const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > +MorphoContext *s = inlink->dst->priv; > + > +if (ctx->inputs[0]->format != ctx->inputs[1]->format) { > +av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n"); > +return AVERROR(EINVAL); > +} Isn't this redundant? After all, query_formats uses ff_set_common_formats_from_list() which ensures that the formats of the inputs and the output isn't set independently; instead it is always set to the same format. > + > +s->splanewidth[1] = s->splanewidth[2] = AV_CEIL_RSHIFT(inlink->w, > desc->log2_chroma_w); > +s->splanewidth[0] = s->splanewidth[3] = inlink->w; > +s->splaneheight[1] = s->splaneheight[2] = AV_CEIL_RSHIFT(inlink->h, > desc->log2_chroma_h); > +s->splaneheight[0] = s->splaneheight[3] = inlink->h; > + > +return 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] Westwood VQA3 demuxer additions
Greetings! This small patch is required for high color 15-bit Westwood VQA3 videos to be decoded properly. It just saves an offset of a VQFL chunk when it sees one and then concatenates it with the packet of a later VQFR chunk that contains full frame data. This way the (yet-to-be-merged) VQA3 decoder can apply the updated codebook before rendering a new frame and each packet contains a standalone frame, as expected. This change was already added by Adam Iglewski as part of GSoC 2009: https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2009-May/075047.html However that patch had a memory leak with the dynamically allocated memory: https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2009-May/075154.html Here that problem is avoided because no heap allocation is done. One question though: is it a problem that I use avio_seek() to rewind the stream? ___ 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/westwood_vqa: Store VQFL codebook chunks
High color 15-bit VQA3 video streams contain high level chunks with only codebook updates that shouldn't be considered new frames. Now the demuxer stores a reference to such VQFL chunks and returns them later along with a VQFR chunk with full frame data. --- libavformat/westwood_vqa.c | 49 ++ 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/libavformat/westwood_vqa.c b/libavformat/westwood_vqa.c index 77df007c11..587626ea67 100644 --- a/libavformat/westwood_vqa.c +++ b/libavformat/westwood_vqa.c @@ -1,6 +1,7 @@ /* * Westwood Studios VQA Format Demuxer - * Copyright (c) 2003 The FFmpeg project + * Copyright (c) 2003 Mike Melanson + * Copyright (c) 2021 Pekka Väänänen * * This file is part of FFmpeg. * @@ -40,6 +41,7 @@ #define SND1_TAG MKBETAG('S', 'N', 'D', '1') #define SND2_TAG MKBETAG('S', 'N', 'D', '2') #define VQFR_TAG MKBETAG('V', 'Q', 'F', 'R') +#define VQFL_TAG MKBETAG('V', 'Q', 'F', 'L') /* don't know what these tags are for, but acknowledge their existence */ #define CINF_TAG MKBETAG('C', 'I', 'N', 'F') @@ -60,6 +62,8 @@ typedef struct WsVqaDemuxContext { int sample_rate; int audio_stream_index; int video_stream_index; +int64_t vqfl_chunk_pos; +int vqfl_chunk_size; } WsVqaDemuxContext; static int wsvqa_probe(const AVProbeData *p) @@ -120,6 +124,8 @@ static int wsvqa_read_header(AVFormatContext *s) wsvqa->channels = header[26]; wsvqa->bps = header[27]; wsvqa->audio_stream_index = -1; +wsvqa->vqfl_chunk_pos = 0; +wsvqa->vqfl_chunk_size= 0; s->ctx_flags |= AVFMTCTX_NOHEADER; @@ -172,11 +178,21 @@ static int wsvqa_read_packet(AVFormatContext *s, skip_byte = chunk_size & 0x01; -if ((chunk_type == SND0_TAG) || (chunk_type == SND1_TAG) || +if (chunk_type == VQFL_TAG) { +/* Each VQFL chunk carries only a codebook update inside which must be applied + * before the next VQFR is rendered. That's why we stash the VQFL offset here + * so it can be combined with the next VQFR packet. This way each packet + * includes a whole frame as expected. */ +wsvqa->vqfl_chunk_pos = avio_tell(pb); +wsvqa->vqfl_chunk_size = (int)chunk_size; +avio_skip(pb, chunk_size + skip_byte); +continue; +} else if ((chunk_type == SND0_TAG) || (chunk_type == SND1_TAG) || (chunk_type == SND2_TAG) || (chunk_type == VQFR_TAG)) { -ret= av_get_packet(pb, pkt, chunk_size); -if (ret<0) +ret = av_get_packet(pb, pkt, chunk_size); + +if (ret < 0) return AVERROR(EIO); switch (chunk_type) { @@ -235,6 +251,31 @@ static int wsvqa_read_packet(AVFormatContext *s, } break; case VQFR_TAG: +/* if a new codebook is available inside an earlier a VQFL chunk then + * prepend it to 'pkt' */ +if (wsvqa->vqfl_chunk_size > 0) { +int64_t current_pos = pkt->pos; +int current_size = pkt->size; + +if (avio_seek(pb, wsvqa->vqfl_chunk_pos, SEEK_SET) < 0) +return AVERROR(EIO); + +/* the decoder expects chunks to be 16-bit aligned */ +if (wsvqa->vqfl_chunk_size % 2 == 1) +wsvqa->vqfl_chunk_size++; + +if (av_get_packet(pb, pkt, wsvqa->vqfl_chunk_size) < 0) +return AVERROR(EIO); + +if (avio_seek(pb, current_pos, SEEK_SET) < 0) +return AVERROR(EIO); + +ret = av_append_packet(pb, pkt, current_size); + +wsvqa->vqfl_chunk_pos = 0; +wsvqa->vqfl_chunk_size = 0; +} + pkt->stream_index = wsvqa->video_stream_index; pkt->duration = 1; break; -- 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] configure: arm: Don't add -march= to the compiler if no preference was passed
Hello, thanks! this fixes nicely my problem, and makes useless the two patches I posted here: please remove and drop: https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=4892 https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=4890 and accept this one whenever possible! thanks Gianfranco Il giorno lun 20 set 2021 alle ore 12:00 Martin Storsjö ha scritto: > If no --cpu= option was passed to configure, we detect what the > compiler defaults to. This detected value was then fed back to the > rest of the configure logic, as if it was an explicit choice. > > This breaks on Ubuntu 21.10 with GCC 11.1. > > Since GCC 8, it's possible to add configure extra features via the > -march option, like e.g. -march=armv7-a+neon. If the -mfpu= option > is configured to default to 'auto', the fpu setting gets taken > from the -march option. > > GCC 11.1 in Ubuntu seems to be configured to use -mfpu=auto. This > has the effect of breaking any compilation command that specifies > -march=armv7-a, because the driver implicitly also adds -mfloat-abi=hard, > and that combination results in this error: > > cc1: error: ‘-mfloat-abi=hard’: selected processor lacks an FPU > > Therefore, restructure configure. If no specific preference was set > (and the 'cpu' configure variable was set as the output of > probe_arm_arch), the value we tried to set via -march= was the same > value that we just tried to detect as the compiler default. > > So instead, just try to detect what the compiler defaults to, with > to allow setting other configure settings (such as 'fast_unaligned'), > but don't try to spell out the compiler's default via the -march flag. > > Signed-off-by: Martin Storsjö > --- > configure | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/configure b/configure > index 9249254b70..3a05b8294b 100755 > --- a/configure > +++ b/configure > @@ -5009,9 +5009,11 @@ elif enabled arm; then > fi > } > > -[ "$cpu" = generic ] && cpu=$(probe_arm_arch) > > case $cpu in > +generic) > +subarch=$(probe_arm_arch | sed 's/[^a-z0-9]//g') > +;; > armv*) > cpuflags="-march=$cpu" > subarch=$(echo $cpu | sed 's/[^a-z0-9]//g') > -- > 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] 15-bit Westwood VQA3 decoding
Hello, This patch adds support for 15-bit VQA3 files that are used in Westwood Studios' video games such as Command & Conquer: Tiberian Sun and Blade Runner. I have tested this change with all VQA files available at http://samples.mplayerhq.hu/game-formats/vqa/ and every video except those in kyrandia/ is now decoded correctly. This patch is dependent on demuxer changes submitted as a separate patch "avformat/westwood_vqa: Store VQFL codebook chunks": https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2021-September/285682.html I noticed VQA3 support had been already submitted by Adam Iglewski as part of Google Summer of Code 2009 but the patch set was never finished nor merged: https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2009-May/074719.html https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2009-May/074958.html I did some changes based on that 2009 thread but otherwise this is an independent implementation. The changes in the demuxer side in westwood_vqa.c are there to silence log spam about ignored chunk types. Anyway, as this is my first change, I have some questions. 1. Is it possible to preserve the pixels of a frame for easy delta updates? In that 2009 patch set they used an old "FF_BUFFER_HINTS_PRESERVE" flag that doesn't exist anymore. 2. Is it problematic to dereference 16-bit values like this: uint16_t code = *(uint16_t*)stream; stream += 2; because the old code used code = bytestream_get_le16(&src); instead. Endianess shouldn't be a problem since the bytes are just copied as-is. Does it make sense to create a 'bytestream' object just to read from a statically allocated array (s->decode_buffer)? 3. I presume Adam Iglewski should be credited in the copyright headers for the few lines I took from his patches? :) ___ 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] avcodec/vqavideo: Decode 15-bit VQA3 files
Adds support for 15-bit VQA3 videos used in Westwood Studios' games. Signed-off-by: Pekka Väänänen --- libavcodec/vqavideo.c | 279 + libavformat/westwood_vqa.c | 12 +- 2 files changed, 262 insertions(+), 29 deletions(-) diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index 12698dc2e8..e9db6b80a5 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -1,6 +1,7 @@ /* * Westwood Studios VQA Video Decoder - * Copyright (C) 2003 The FFmpeg project + * Copyright (c) 2003 Mike Melanson + * Copyright (c) 2021 Pekka Väänänen * * This file is part of FFmpeg. * @@ -61,6 +62,11 @@ * together and the 8-bit pieces together. If most of the vectors are * clustered into one group of 256 vectors, most of the 4-bit index pieces * should be the same. + * + * VQA3 introduces a 15-bit high color codebook, delta coding, replaces + * the above "split byte" scheme with RLE compression, and extends the + * "format80" compression with relative references. In VQA3 the whole + * codebook is always updated as a whole without splitting it into pieces. */ #include @@ -81,7 +87,7 @@ #define MAX_CODEBOOK_VECTORS 0xFF00 #define SOLID_PIXEL_VECTORS 0x100 #define MAX_VECTORS (MAX_CODEBOOK_VECTORS + SOLID_PIXEL_VECTORS) -#define MAX_CODEBOOK_SIZE (MAX_VECTORS * 4 * 4) +#define MAX_CODEBOOK_SIZE (MAX_VECTORS * 4 * 4 * sizeof(uint16_t)) #define CBF0_TAG MKBETAG('C', 'B', 'F', '0') #define CBFZ_TAG MKBETAG('C', 'B', 'F', 'Z') @@ -90,6 +96,8 @@ #define CPL0_TAG MKBETAG('C', 'P', 'L', '0') #define CPLZ_TAG MKBETAG('C', 'P', 'L', 'Z') #define VPTZ_TAG MKBETAG('V', 'P', 'T', 'Z') +#define VPTR_TAG MKBETAG('V', 'P', 'T', 'R') +#define VPRZ_TAG MKBETAG('V', 'P', 'R', 'Z') typedef struct VqaContext { @@ -104,9 +112,12 @@ typedef struct VqaContext { int vector_height; /* height of individual vector */ int vqa_version; /* this should be either 1, 2 or 3 */ -unsigned char *codebook; /* the current codebook */ +uint16_t *framebuffer; /* current frame's pixels for 15-bit videos */ +int framebuffer_size; + +unsigned char *codebook; /* the current codebook */ int codebook_size; -unsigned char *next_codebook_buffer; /* accumulator for next codebook */ +unsigned char *next_codebook_buffer; /* accumulator for next codebook */ int next_codebook_buffer_index; unsigned char *decode_buffer; @@ -115,16 +126,15 @@ typedef struct VqaContext { /* number of frames to go before replacing codebook */ int partial_countdown; int partial_count; - } VqaContext; static av_cold int vqa_decode_init(AVCodecContext *avctx) { VqaContext *s = avctx->priv_data; int i, j, codebook_index, ret; +int colors; s->avctx = avctx; -avctx->pix_fmt = AV_PIX_FMT_PAL8; /* make sure the extradata made it */ if (s->avctx->extradata_size != VQA_HEADER_SIZE) { @@ -134,17 +144,12 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) /* load up the VQA parameters from the header */ s->vqa_version = s->avctx->extradata[0]; -switch (s->vqa_version) { -case 1: -case 2: -break; -case 3: -avpriv_report_missing_feature(avctx, "VQA Version %d", s->vqa_version); -return AVERROR_PATCHWELCOME; -default: + +if (s->vqa_version < 1 || s->vqa_version > 3) { avpriv_request_sample(avctx, "VQA Version %i", s->vqa_version); -return AVERROR_PATCHWELCOME; +return AVERROR_INVALIDDATA; } + s->width = AV_RL16(&s->avctx->extradata[6]); s->height = AV_RL16(&s->avctx->extradata[8]); if ((ret = ff_set_dimensions(avctx, s->width, s->height)) < 0) { @@ -155,6 +160,14 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) s->vector_height = s->avctx->extradata[11]; s->partial_count = s->partial_countdown = s->avctx->extradata[13]; +colors = (s->avctx->extradata[14] << 8) | s->avctx->extradata[15]; + +if (colors > 0) { +avctx->pix_fmt = AV_PIX_FMT_PAL8; +} else { +avctx->pix_fmt = AV_PIX_FMT_RGB555LE; +} + /* the vector dimensions have to meet very stringent requirements */ if ((s->vector_width != 4) || ((s->vector_height != 2) && (s->vector_height != 4))) { @@ -167,6 +180,12 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } +/* allocate the framebuffer */ +s->framebuffer_size = s->width * s->height * sizeof(s->framebuffer[0]); +s->framebuffer = av_mallocz(s->framebuffer_size); +if (!s->framebuffer) +return AVERROR(ENOMEM); + /* allocate codebooks */ s->codebook_size = MAX_CODEBOOK_SIZE; s->codebook = av_malloc(s->codebook_size); @@ -225,6 +244,7 @@ static int decode_format80(VqaContext *s, int src_size, int src_pos; unsigned char color; int i; +int relative = 0; if (src_size < 0 || src_size > bytestream2_get_byt
Re: [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_h265_syntax_template: Limit sps_num_palette_predictor_initializer_minus1 to 127
On Mon, Sep 20, 2021 at 09:57:02AM -0300, James Almer wrote: > On 9/19/2021 5:35 PM, Michael Niedermayer wrote: > > Fixes: index 128 out of bounds for type 'uint16_t [128]' > > Fixes: > > 38651/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-6296416058736640 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/cbs_h265_syntax_template.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/libavcodec/cbs_h265_syntax_template.c > > b/libavcodec/cbs_h265_syntax_template.c > > index 67bc77f9751..fb8ac4a4a77 100644 > > --- a/libavcodec/cbs_h265_syntax_template.c > > +++ b/libavcodec/cbs_h265_syntax_template.c > > @@ -728,7 +728,7 @@ static int > > FUNC(sps_scc_extension)(CodedBitstreamContext *ctx, RWContext *rw, > > flag(sps_palette_predictor_initializer_present_flag); > > if (current->sps_palette_predictor_initializer_present_flag) { > > -ue(sps_num_palette_predictor_initializer_minus1, 0, 128); > > +ue(sps_num_palette_predictor_initializer_minus1, 0, 127); > > for (comp = 0; comp < (current->chroma_format_idc ? 3 : 1); > > comp++) { > > int bit_depth = comp == 0 ? > > current->bit_depth_luma_minus8 + 8 > > : > > current->bit_depth_chroma_minus8 + 8; > > > > sps_num_palette_predictor_initializer_minus1 plus 1 must be at most 128, so > LGTM. will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No snowflake in an avalanche ever feels responsible. -- Voltaire 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] 15-bit Westwood VQA3 decoding
Pekka Väänänen: > 1. Is it possible to preserve the pixels of a frame for easy delta updates? > In that 2009 patch set they used an old "FF_BUFFER_HINTS_PRESERVE" flag > that doesn't exist anymore. > You keep a reference to the earlier frame (use av_frame_ref()). > 2. Is it problematic to dereference 16-bit values like this: > > uint16_t code = *(uint16_t*)stream; > stream += 2; > > because the old code used > > code = bytestream_get_le16(&src); > > instead. Endianess shouldn't be a problem since the bytes are just > copied as-is. Does it make sense to create a 'bytestream' object just to > read from a statically allocated array (s->decode_buffer)? > Actually, endianess is a problem in your case. If the bytes at the position stream are 0xFF and 0x00, then on a little endian system code will be 0x00FF and type is zero; on a big endian system code will be 0xFF00 and type is 0x07. Alignment might also be a problem (I see that you might consume a single byte from stream in the loop), so use bytestream. This has no overhead at all, because there is no bytestream object (all it does is manipulate the pointer you already have). This is different from the bytestream2 API. > > +int count = 0; > +uint16_t code = *(uint16_t*)stream; > +int type; > + > +stream += 2; > +type = code >> 13; > +code &= 0x1fff; - 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] Westwood VQA3 demuxer additions
Sep 20, 2021, 20:43 by "Pekka Väänänen" : > Greetings! > > This small patch is required for high color 15-bit Westwood VQA3 videos > to be decoded properly. It just saves an offset of a VQFL chunk when it > sees one and then concatenates it with the packet of a later VQFR chunk > that contains full frame data. This way the (yet-to-be-merged) VQA3 > decoder can apply the updated codebook before rendering a new frame and > each packet contains a standalone frame, as expected. > > This change was already added by Adam Iglewski as part of GSoC 2009: > > https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2009-May/075047.html > > However that patch had a memory leak with the dynamically allocated > memory: > > https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2009-May/075154.html > > Here that problem is avoided because no heap allocation is done. > > One question though: is it a problem that I use avio_seek() to rewind > the stream? > It's fine, but you do want to use ffio_ensure_seekback() to guarantee success, preferably calling it at just the moment the stream is at the position you're planning on rewinding back to. ___ 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: add morpho filter
Sep 20, 2021, 19:33 by one...@gmail.com: > Signed-off-by: Paul B Mahol > --- > doc/filters.texi | 32 ++ > libavfilter/Makefile | 1 + > libavfilter/allfilters.c | 1 + > libavfilter/vf_morpho.c | 865 +++ > 4 files changed, 899 insertions(+) > create mode 100644 libavfilter/vf_morpho.c > > diff --git a/doc/filters.texi b/doc/filters.texi > index 0c45fb710d..b46556c12c 100644 > --- a/doc/filters.texi > +++ b/doc/filters.texi > @@ -10225,6 +10225,7 @@ A number representing position of the first frame > with respect to the telecine > pattern. This is to be used if the stream is cut. The default value is > @code{0}. > @end table > > +@anchor{dilation} > @section dilation > > Apply dilation effect to the video. > @@ -11541,6 +11542,7 @@ value. > > @end table > > +@anchor{erosion} > @section erosion > > Apply erosion effect to the video. > @@ -15316,6 +15318,36 @@ Default value is 0. > > This filter supports the all above options as @ref{commands}. > > +@section morpho > + > +This filter allows to apply main morphological grayscale transforms, > +erode and dilate with arbitrary structures set in second input stream. > + > +Unlike naive implementation and much slower performance in @ref{erosion} > +and @ref{dilation} filters, when speed is critical @code{morpho} filter > +should be used instead. > + > +A description of accepted options follows, > + > +@table @option > +@item mode > +Set morphological transform to apply, can be @code{erode} or @code{dilate}. > +Default is @code{erode}. > + > +@item planes > +Set planes to filter, by default all planes except alpha are filtered. > + > +@item structure > +Set which structure video frames will be processed from second input stream, > +can be @var{first} or @var{all}. Default is @var{all}. > +@end table > + > +The @code{morpho} filter also supports the @ref{framesync} options. > + > +@subsection Commands > + > +This filter supports same @ref{commands} as options. > + > @section mpdecimate > > Drop frames that do not differ greatly from the previous frame in > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > index 272f876c07..06e01da38e 100644 > --- a/libavfilter/Makefile > +++ b/libavfilter/Makefile > @@ -350,6 +350,7 @@ OBJS-$(CONFIG_MIDEQUALIZER_FILTER) += > vf_midequalizer.o framesync.o > OBJS-$(CONFIG_MINTERPOLATE_FILTER) += vf_minterpolate.o > motion_estimation.o > OBJS-$(CONFIG_MIX_FILTER)+= vf_mix.o framesync.o > OBJS-$(CONFIG_MONOCHROME_FILTER) += vf_monochrome.o > +OBJS-$(CONFIG_MORPHO_FILTER) += vf_morpho.o > OBJS-$(CONFIG_MPDECIMATE_FILTER) += vf_mpdecimate.o > OBJS-$(CONFIG_NEGATE_FILTER) += vf_lut.o > OBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c > index 1283d124b8..10dfe72131 100644 > --- a/libavfilter/allfilters.c > +++ b/libavfilter/allfilters.c > @@ -335,6 +335,7 @@ extern const AVFilter ff_vf_midequalizer; > extern const AVFilter ff_vf_minterpolate; > extern const AVFilter ff_vf_mix; > extern const AVFilter ff_vf_monochrome; > +extern const AVFilter ff_vf_morpho; > extern const AVFilter ff_vf_mpdecimate; > extern const AVFilter ff_vf_msad; > extern const AVFilter ff_vf_negate; > diff --git a/libavfilter/vf_morpho.c b/libavfilter/vf_morpho.c > new file mode 100644 > index 00..46c641c4b9 > --- /dev/null > +++ b/libavfilter/vf_morpho.c > @@ -0,0 +1,865 @@ > +/* > + * Copyright (c) 2016 ReneBrals > + * Copyright (c) 2021 Paul B Mahol > + * > + * This file is part of FFmpeg. > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > copy > + * of this software and associated documentation files (the "Software"), to > deal > + * in the Software without restriction, including without limitation the > rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included > in all > + * copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > THE > + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING > FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > THE > + * SOFTWARE. > + */ > + > +#include "avfilter.h" > +#include "formats.h" > +#include "internal.h" > +#include "libavutil/intreadwrite.h" > +#include "libavutil/imgutils.h" >
[FFmpeg-devel] [PATCH 14/14] avcodec/elbg: Mark ELBGContext as being unaliased by using av_restrict
This improves performance: For msvideo1, the performance improved by 4.8% when encoding the sample from the fate-vsynth1-msvideo1 test; when encoding the sample from fate-vsynth1-cinepak, performance improved by 2%. The compiler user was GCC 10 and the calls to encode2 have been timed. Signed-off-by: Andreas Rheinhardt --- libavcodec/elbg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c index 712c125a58..d97a7bc3f9 100644 --- a/libavcodec/elbg.c +++ b/libavcodec/elbg.c @@ -346,7 +346,7 @@ static void do_shiftings(ELBGContext *elbg) } } -static void do_elbg(ELBGContext *elbg, int *points, int numpoints, +static void do_elbg(ELBGContext *av_restrict elbg, int *points, int numpoints, int max_steps) { int *const size_part = elbg->size_part; @@ -419,7 +419,7 @@ static void do_elbg(ELBGContext *elbg, int *points, int numpoints, * If not, it calls do_elbg for a (smaller) random sample of the points in * points. */ -static void init_elbg(ELBGContext *elbg, int *points, int *temp_points, +static void init_elbg(ELBGContext *av_restrict elbg, int *points, int *temp_points, int numpoints, int max_steps) { int dim = elbg->dim; @@ -447,7 +447,7 @@ int avpriv_elbg_do(ELBGContext **elbgp, int *points, int dim, int numpoints, int *codebook, int num_cb, int max_steps, int *closest_cb, AVLFG *rand_state, uintptr_t flags) { -ELBGContext *const elbg = *elbgp ? *elbgp : av_mallocz(sizeof(*elbg)); +ELBGContext *const av_restrict elbg = *elbgp ? *elbgp : av_mallocz(sizeof(*elbg)); if (!elbg) return AVERROR(ENOMEM); -- 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 10/13] avcodec/cinepakenc: Check all calls to avpriv_elbg_do()
Tomas Härdin: > fre 2021-09-17 klockan 04:08 +0200 skrev Andreas Rheinhardt: >> Signed-off-by: Andreas Rheinhardt >> --- >> libavcodec/cinepakenc.c | 28 ++-- >> 1 file changed, 22 insertions(+), 6 deletions(-) > > Gave this one a try with -vframes 100 -s 640x360 for some random clips > on my machine. Wall time doesn't change much. > I highly doubted that this would be even noticeable, but your comment made me benchmark this. This patch is indeed not noticeable, but patches 6 and 7 are a bit noticeable. They even outweigh the benefits of avoiding the allocations. I guess you might be seeing this. The reason seems to be that the compiler now has to presume that the ELBGContext is aliased (whereas before that it was just a structure on the stack of which it could prove that its address doesn't leak). Adding av_restrict fixed this (with GCC 10) and improved performance to something a bit better than it was before this patchset. They also help for the msvideo1 case (where the speedup due to avoiding allocations dwarfs everything else). Sorry for only benchmarking the msvideo1 case earlier and not noticing this. - 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] avfilter: add morpho filter
Signed-off-by: Paul B Mahol --- doc/filters.texi | 39 ++ libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_morpho.c | 909 +++ 4 files changed, 950 insertions(+) create mode 100644 libavfilter/vf_morpho.c diff --git a/doc/filters.texi b/doc/filters.texi index 0c45fb710d..7c8861d2b3 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -10225,6 +10225,7 @@ A number representing position of the first frame with respect to the telecine pattern. This is to be used if the stream is cut. The default value is @code{0}. @end table +@anchor{dilation} @section dilation Apply dilation effect to the video. @@ -11541,6 +11542,7 @@ value. @end table +@anchor{erosion} @section erosion Apply erosion effect to the video. @@ -15316,6 +15318,43 @@ Default value is 0. This filter supports the all above options as @ref{commands}. +@section morpho + +This filter allows to apply main morphological grayscale transforms, +erode and dilate with arbitrary structures set in second input stream. + +Unlike naive implementation and much slower performance in @ref{erosion} +and @ref{dilation} filters, when speed is critical @code{morpho} filter +should be used instead. + +A description of accepted options follows, + +@table @option +@item mode +Set morphological transform to apply, can be: + +@table @samp +@item erode +@item dilate +@item open +@item close +@end table +Default is @code{erode}. + +@item planes +Set planes to filter, by default all planes except alpha are filtered. + +@item structure +Set which structure video frames will be processed from second input stream, +can be @var{first} or @var{all}. Default is @var{all}. +@end table + +The @code{morpho} filter also supports the @ref{framesync} options. + +@subsection Commands + +This filter supports same @ref{commands} as options. + @section mpdecimate Drop frames that do not differ greatly from the previous frame in diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 272f876c07..06e01da38e 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -350,6 +350,7 @@ OBJS-$(CONFIG_MIDEQUALIZER_FILTER) += vf_midequalizer.o framesync.o OBJS-$(CONFIG_MINTERPOLATE_FILTER) += vf_minterpolate.o motion_estimation.o OBJS-$(CONFIG_MIX_FILTER)+= vf_mix.o framesync.o OBJS-$(CONFIG_MONOCHROME_FILTER) += vf_monochrome.o +OBJS-$(CONFIG_MORPHO_FILTER) += vf_morpho.o OBJS-$(CONFIG_MPDECIMATE_FILTER) += vf_mpdecimate.o OBJS-$(CONFIG_NEGATE_FILTER) += vf_lut.o OBJS-$(CONFIG_NLMEANS_FILTER)+= vf_nlmeans.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 1283d124b8..10dfe72131 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -335,6 +335,7 @@ extern const AVFilter ff_vf_midequalizer; extern const AVFilter ff_vf_minterpolate; extern const AVFilter ff_vf_mix; extern const AVFilter ff_vf_monochrome; +extern const AVFilter ff_vf_morpho; extern const AVFilter ff_vf_mpdecimate; extern const AVFilter ff_vf_msad; extern const AVFilter ff_vf_negate; diff --git a/libavfilter/vf_morpho.c b/libavfilter/vf_morpho.c new file mode 100644 index 00..d55ddbce48 --- /dev/null +++ b/libavfilter/vf_morpho.c @@ -0,0 +1,909 @@ +/* + * Copyright (c) 2016 ReneBrals + * Copyright (c) 2021 Paul B Mahol + * + * This file is part of FFmpeg. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "libavutil/avassert.h" +#include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/opt.h" +#include "libavutil/pixdesc.h" +#include "avfilter.h" +#include "formats.h" +#include "framesync.h" +#include "internal.h" +#include "video.h" + +enum MorphModes { +ERODE, +DILATE, +OPEN, +CLOSE, +NB_MODES +}; + +typedef struct IPlane { +uint8_t **img; +
[FFmpeg-devel] [PATCH] avcodec: add native Speex decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile|1 + libavcodec/allcodecs.c |1 + libavcodec/speexdata.h | 780 libavcodec/speexdec.c | 1584 4 files changed, 2366 insertions(+) create mode 100644 libavcodec/speexdata.h create mode 100644 libavcodec/speexdec.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 11873eecae..7a603e44dd 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -632,6 +632,7 @@ OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o OBJS-$(CONFIG_SONIC_LS_ENCODER)+= sonic.o OBJS-$(CONFIG_SPEEDHQ_DECODER) += speedhq.o mpeg12.o mpeg12data.o simple_idct.o OBJS-$(CONFIG_SPEEDHQ_ENCODER) += speedhq.o mpeg12data.o mpeg12enc.o speedhqenc.o +OBJS-$(CONFIG_SPEEX_DECODER) += speexdec.o OBJS-$(CONFIG_SP5X_DECODER)+= sp5xdec.o OBJS-$(CONFIG_SRGC_DECODER)+= mscc.o OBJS-$(CONFIG_SRT_DECODER) += srtdec.o ass.o htmlsubtitles.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index c42aba140d..fc6bf7cc25 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -307,6 +307,7 @@ extern const AVCodec ff_snow_decoder; extern const AVCodec ff_sp5x_decoder; extern const AVCodec ff_speedhq_decoder; extern const AVCodec ff_speedhq_encoder; +extern const AVCodec ff_speex_decoder; extern const AVCodec ff_srgc_decoder; extern const AVCodec ff_sunrast_encoder; extern const AVCodec ff_sunrast_decoder; diff --git a/libavcodec/speexdata.h b/libavcodec/speexdata.h new file mode 100644 index 00..0fb3364424 --- /dev/null +++ b/libavcodec/speexdata.h @@ -0,0 +1,780 @@ +/* + * Copyright 2002-2008 Xiph.org Foundation + * Copyright 2002-2008 Jean-Marc Valin + * Copyright 2005-2007 Analog Devices Inc. + * Copyright 2005-2008 Commonwealth Scientific and Industrial Research Organisation (CSIRO) + * Copyright 1993, 2002, 2006 David Rowe + * Copyright 2003 EpicGames + * Copyright 1992-1994 Jutta Degener, Carsten Bormann + + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + + * - Neither the name of the Xiph.org Foundation nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * 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 + */ + +#ifndef AVCODEC_SPEEXDATA_H +#define AVCODEC_SPEEXDATA_H + +#include "libavutil/common.h" + +static const int8_t high_lsp_cdbk[512] = { +39, 12, -14, -20, -29, -61, -67, -76, -32, -71, -67, 68, 77, 46, +34, 5,-13, -48, -46, -72, -81, -84, -60, -58, -40, -28, 82, 93, +68, 45, 29, 3, -19, -47, -28, -43, -35, -30, -8, -13, -39, -91, +-91, -123, -96, 10, 10, -6, -18, -55, -60, -91, -56, -36, -27, -16, +-48, -75, 40, 28, -10, -28, 35, 9,37, 19, 1, -20, -31, -41, +-18, -25, -35, -68, -80, 45, 27, -1, 47, 13, 0, -29, -35, -57, +
Re: [FFmpeg-devel] [PATCH] avcodec: add native Speex decoder
On 9/20/2021 7:33 PM, Paul B Mahol wrote: +static int speex_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame_ptr, AVPacket *avpkt) +{ +SpeexContext *s = avctx->priv_data; +AVFrame *frame = data; +const float scale = 1.f / 32768.f; +int buf_size = avpkt->size; +float *dst; +int ret; + +if (s->pkt_size && avpkt->size == 62) +buf_size = s->pkt_size; +if ((ret = init_get_bits8(&s->gb, avpkt->data, buf_size)) < 0) +return ret; + +frame->nb_samples = s->frame_size * s->frames_per_packet; +if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) +return ret; + +dst = (float *)frame->extended_data[0]; +for (int i = 0; i < s->frames_per_packet; i++) { +ret = speex_modes[s->mode]->decode(avctx, &s->st[s->mode], &s->gb, dst + i * s->frame_size); +if (ret < 0) +return ret; +if (avctx->channels == 2) +speex_decode_stereo(dst + i * s->frame_size, s->frame_size, &s->stereo); +} + +dst = (float *)frame->extended_data[0]; +for (int n = 0; n < frame->nb_samples * avctx->channels; n++) +dst[n] *= scale; Does this buffer fulfill the constrains of AVFloatDSPContext's vector_fmul_scalar()? Alignment wise i know it does because it's an AVFrame buffer, but the length? If not, you could maybe FFALIGN frame->nb_samples before the ff_get_buffer() call, then restore the original value afterwards. + +*got_frame_ptr = 1; + +return buf_size; +} ___ 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] libavcodec/libx264: add user data unregistered SEI encoding
On Monday, 6 September 2021 10:17:14 AM AEST Brad Hards wrote: > On Sunday, 22 August 2021 7:25:25 PM AEST Brad Hards wrote: > > On Saturday, 14 August 2021 9:51:03 AM AEST Brad Hards wrote: > > > On Friday, 6 August 2021 7:16:33 PM AEST Brad Hards wrote: > > > > MISB ST 0604 and ST 2101 require user data unregistered SEI messages > > > > (precision timestamps and sensor identifiers) to be included. That > > > > currently isn't supported for libx264. This patch adds support > > > > for user data unregistered SEI messages in accordance with ISO/IEC > > > > 14496-10:2020(E) section D.1.7 (syntax) and D.2.7 (semantics). > > > > > > > > This code is based on a similar change for libx265 (commit > > > > 1f58503013720700a5adfd72c708e6275aefc165). > > > > --- > > > > > > > > libavcodec/libx264.c | 30 ++ > > > > 1 file changed, 30 insertions(+) > > > > > > > > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c > > > > index 9afaf19547..e9bbe8d494 100644 > > > > --- a/libavcodec/libx264.c > > > > +++ b/libavcodec/libx264.c > > > > @@ -32,6 +32,7 @@ > > > > > > > > #include "internal.h" > > > > #include "packet_internal.h" > > > > #include "atsc_a53.h" > > > > > > > > +#include "sei.h" > > > > > > > > #if defined(_MSC_VER) > > > > #define X264_API_IMPORTS 1 > > > > > > > > @@ -114,6 +115,9 @@ typedef struct X264Context { > > > > > > > > * encounter a frame with ROI side data. > > > > */ > > > > > > > > int roi_warned; > > > > > > > > + > > > > +void *sei_data; > > > > +int sei_data_size; > > > > > > > > } X264Context; > > > > > > > > static void X264_log(void *p, int level, const char *fmt, va_list > > > > args) > > > > > > > > @@ -317,6 +321,9 @@ static int X264_frame(AVCodecContext *ctx, > > > > AVPacket > > > > *pkt, const AVFrame *frame,> > > > > > > > > x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt); > > > > > > > > if (frame) { > > > > > > > > +x264_sei_t *sei = &x4->pic.extra_sei; > > > > +sei->num_payloads = 0; > > > > + > > > > > > > > for (i = 0; i < x4->pic.img.i_plane; i++) { > > > > > > > > x4->pic.img.plane[i]= frame->data[i]; > > > > x4->pic.img.i_stride[i] = frame->linesize[i]; > > > > > > > > @@ -439,6 +446,27 @@ static int X264_frame(AVCodecContext *ctx, > > > > AVPacket > > > > *pkt, const AVFrame *frame,> > > > > > > > > } > > > > > > > > } > > > > > > > > } > > > > > > > > + > > > > +for (int j = 0; j < frame->nb_side_data; j++) { > > > > +AVFrameSideData *side_data = frame->side_data[j]; > > > > +void *tmp; > > > > +x264_sei_payload_t *sei_payload; > > > > +if (side_data->type != AV_FRAME_DATA_SEI_UNREGISTERED) > > > > +continue; > > > > +tmp = av_fast_realloc(x4->sei_data, &x4->sei_data_size, > > > > (sei->num_payloads + 1) * sizeof(*sei_payload)); +if > > > > (!tmp) > > > > { > > > > +av_freep(&x4->pic.extra_sei.payloads); > > > > +av_freep(&x4->pic.prop.quant_offsets); > > > > +return AVERROR(ENOMEM); > > > > +} > > > > +x4->sei_data = tmp; > > > > +sei->payloads = x4->sei_data; > > > > +sei_payload = &sei->payloads[sei->num_payloads]; > > > > +sei_payload->payload = side_data->data; > > > > +sei_payload->payload_size = side_data->size; > > > > +sei_payload->payload_type = > > > > SEI_TYPE_USER_DATA_UNREGISTERED; > > > > +sei->num_payloads++; > > > > +} > > > > > > > > } > > > > > > > > do { > > > > > > > > @@ -505,6 +533,8 @@ static av_cold int X264_close(AVCodecContext > > > > *avctx) > > > > > > > > x264_param_cleanup(&x4->params); > > > > > > > > #endif > > > > > > > > +av_freep(&x4->sei_data); > > > > + > > > > > > > > if (x4->enc) { > > > > > > > > x264_encoder_close(x4->enc); > > > > x4->enc = NULL; > > > > > > Ping on this patch. > > > > Ping on this patch. > > Ping on this patch. > Ping on this patch. Brad ___ 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] webp: fix transforms after a palette with pixel packing.
On Wed, Sep 8, 2021 at 6:46 PM James Zern wrote: > > On Mon, Aug 30, 2021 at 5:11 AM Maryla > wrote: > > > > When a color indexing transform with 16 or fewer colors is used, > > WebP uses "pixel packing", i.e. storing several pixels in one byte, > > which virtually reduces the width of the image (see WebPContext's > > reduced_width field). This reduced_width should always be used when > > reading and applying subsequent transforms. > > > > Updated patch with added fate test. > > The source image dual_transform.webp can be downloaded by cloning > > https://chromium.googlesource.com/webm/libwebp-test-data/ > > > > Fixes: 9368 > > --- > > libavcodec/webp.c | 34 ++- > > tests/fate/image.mak | 3 ++ > > .../fate/webp-rgb-lossless-palette-predictor | 6 > > 3 files changed, 27 insertions(+), 16 deletions(-) > > create mode 100644 tests/ref/fate/webp-rgb-lossless-palette-predictor > > > > This works locally and matches the output from libwebp. I sent a > request to samples-request@ to add the file. This should have a micro > version bump for libavcodec/version.h; I've added that locally. > The sample addition is still pending. I've verified the pam output of this file and lossless* from the webp test set match libwebp. I'll submit this soon with the fate test disabled if there aren't any comments. > > diff --git a/libavcodec/webp.c b/libavcodec/webp.c > > index 3efd4438d9..e4c67adc3a 100644 > > --- a/libavcodec/webp.c > > +++ b/libavcodec/webp.c > > @@ -181,7 +181,10 @@ typedef struct ImageContext { > > uint32_t *color_cache; /* color cache data */ > > int nb_huffman_groups; /* number of huffman groups */ > > HuffReader *huffman_groups; /* reader for each huffman group */ > > -int size_reduction; /* relative size compared to > > primary image, log2 */ > > +/* relative size compared to primary image, log2. > > + * for IMAGE_ROLE_COLOR_INDEXING with <= 16 colors, this is log2 of the > > + * number of pixels per byte in the primary image (pixel packing) */ > > +int size_reduction; > > int is_alpha_primary; > > } ImageContext; > > > > @@ -205,7 +208,9 @@ typedef struct WebPContext { > > > > int nb_transforms; /* number of transforms */ > > enum TransformType transforms[4]; /* transformations used in the > > image, in order */ > > -int reduced_width; /* reduced width for index image, > > if applicable */ > > +/* reduced width when using a color indexing transform with <= 16 > > colors (pixel packing) > > + * before pixels are unpacked, or same as width otherwise. */ > > +int reduced_width; > > int nb_huffman_groups; /* number of huffman groups in the > > primary image */ > > ImageContext image[IMAGE_ROLE_NB]; /* image context for each role */ > > } WebPContext; > > @@ -425,13 +430,9 @@ static int decode_entropy_coded_image(WebPContext *s, > > enum ImageRole role, > > static int decode_entropy_image(WebPContext *s) > > { > > ImageContext *img; > > -int ret, block_bits, width, blocks_w, blocks_h, x, y, max; > > +int ret, block_bits, blocks_w, blocks_h, x, y, max; > > > > -width = s->width; > > -if (s->reduced_width > 0) > > -width = s->reduced_width; > > - > > -PARSE_BLOCK_SIZE(width, s->height); > > +PARSE_BLOCK_SIZE(s->reduced_width, s->height); > > > > ret = decode_entropy_coded_image(s, IMAGE_ROLE_ENTROPY, blocks_w, > > blocks_h); > > if (ret < 0) > > @@ -460,7 +461,7 @@ static int parse_transform_predictor(WebPContext *s) > > { > > int block_bits, blocks_w, blocks_h, ret; > > > > -PARSE_BLOCK_SIZE(s->width, s->height); > > +PARSE_BLOCK_SIZE(s->reduced_width, s->height); > > > > ret = decode_entropy_coded_image(s, IMAGE_ROLE_PREDICTOR, blocks_w, > > blocks_h); > > @@ -476,7 +477,7 @@ static int parse_transform_color(WebPContext *s) > > { > > int block_bits, blocks_w, blocks_h, ret; > > > > -PARSE_BLOCK_SIZE(s->width, s->height); > > +PARSE_BLOCK_SIZE(s->reduced_width, s->height); > > > > ret = decode_entropy_coded_image(s, IMAGE_ROLE_COLOR_TRANSFORM, > > blocks_w, > > blocks_h); > > @@ -620,7 +621,7 @@ static int decode_entropy_coded_image(WebPContext *s, > > enum ImageRole role, > > } > > > > width = img->frame->width; > > -if (role == IMAGE_ROLE_ARGB && s->reduced_width > 0) > > +if (role == IMAGE_ROLE_ARGB) > > width = s->reduced_width; > > > > x = 0; y = 0; > > @@ -925,7 +926,7 @@ static int apply_predictor_transform(WebPContext *s) > > int x, y; > > > > for (y = 0; y < img->frame->height; y++) { > > -for (x = 0; x < img->frame->width; x++) { > > +for (x = 0; x < s->reduced_width; x++) { > > int tx = x >> pimg->size
[FFmpeg-devel] [PATCH] swscale/yuv2rgb: fix shift values for conversion to X2RGB10
This resolves a problem where conversions from YUV to X2RGB10LE would produce color values a factor 4 too small. The variable 'yval' used later in the switch case 30 has range [0,255], but the color channel values in X2RGB10 have two more bits than 'yval' and can go up to 1023. Increasing (r|g|b)base by 2 effectively multiplies yval by 4 and fixes this discrepancy. Signed-off-by: Manuel Stoeckl --- libswscale/yuv2rgb.c | 6 +++--- tests/ref/fate/filter-pixdesc-x2rgb10le | 2 +- tests/ref/fate/filter-pixfmts-copy | 2 +- tests/ref/fate/filter-pixfmts-crop | 2 +- tests/ref/fate/filter-pixfmts-field | 2 +- tests/ref/fate/filter-pixfmts-fieldorder | 2 +- tests/ref/fate/filter-pixfmts-hflip | 2 +- tests/ref/fate/filter-pixfmts-il | 2 +- tests/ref/fate/filter-pixfmts-null | 2 +- tests/ref/fate/filter-pixfmts-pad| 2 +- tests/ref/fate/filter-pixfmts-scale | 2 +- tests/ref/fate/filter-pixfmts-transpose | 2 +- tests/ref/fate/filter-pixfmts-vflip | 2 +- 13 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index cac82f4c6f..e084bd8eec 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -966,9 +966,9 @@ av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], fill_gv_table(c->table_gV, 1, cgv); break; case 30: -rbase = 20; -gbase = 10; -bbase = 0; +rbase = 22; +gbase = 12; +bbase = 2; needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat); if (!needAlpha) abase = 30; diff --git a/tests/ref/fate/filter-pixdesc-x2rgb10le b/tests/ref/fate/filter-pixdesc-x2rgb10le index 94c8640a56..093d3bc3e7 100644 --- a/tests/ref/fate/filter-pixdesc-x2rgb10le +++ b/tests/ref/fate/filter-pixdesc-x2rgb10le @@ -1 +1 @@ -pixdesc-x2rgb10le98d697ed4668daf535163d5e08c903bb +pixdesc-x2rgb10le d3a315972acd4cbc16837bd8c8410d17 diff --git a/tests/ref/fate/filter-pixfmts-copy b/tests/ref/fate/filter-pixfmts-copy index 1d7657c2af..7a7e42a8b4 100644 --- a/tests/ref/fate/filter-pixfmts-copy +++ b/tests/ref/fate/filter-pixfmts-copy @@ -80,7 +80,7 @@ rgbab6e1b441c365e03b5ffdf9b7b68d9a0c rgba64beae2ae04b5efedca3505f47c4dd6ea6ea rgba64leb91e1d77f799eb92241a2d2d28437b15 uyvy422 3bcf3c80047592f2211fae3260b1b65d -x2rgb10le b0a0c8056521beeaa3fea4985ca87176 +x2rgb10le 75665d76a2077d0106d8cd65a067c475 xyz12be a1ef56bf746d71f59669c28e48fc8450 xyz12le 831ff03c1ba4ef19374686f16a064d8c ya16be 37c07787e544f900c87b853253bfc8dd diff --git a/tests/ref/fate/filter-pixfmts-crop b/tests/ref/fate/filter-pixfmts-crop index 8fc7614192..17e1db2721 100644 --- a/tests/ref/fate/filter-pixfmts-crop +++ b/tests/ref/fate/filter-pixfmts-crop @@ -77,7 +77,7 @@ rgb89b364a8f112ad9459fec47a51cc03b30 rgba9488ac85abceaf99a9309eac5a87697e rgba64be89910046972ab3c68e2a348302cc8ca9 rgba64lefea8ebfc869b52adf353778f29eac7a7 -x2rgb10le 5c0789f76a713f343c2ed42a371d441d +x2rgb10le 69385674767a31dad7118bd444958c54 xyz12be cb4571f9aaa7b59f999ef327276104b7 xyz12le cd6aae8d26b18bdb4b9d068586276d91 ya16be a3d18014454942a96f15a49947c0c55d diff --git a/tests/ref/fate/filter-pixfmts-field b/tests/ref/fate/filter-pixfmts-field index ce8e53571f..871234bd00 100644 --- a/tests/ref/fate/filter-pixfmts-field +++ b/tests/ref/fate/filter-pixfmts-field @@ -80,7 +80,7 @@ rgbaee616262ca6d67b7ecfba4b36c602ce3 rgba64be23c8c0edaabe3eaec89ce69633fb0048 rgba64ledfdba4de4a7cac9abf08852666c341d3 uyvy422 1c49e44ab3f060e85fc4a3a9464f045e -x2rgb10le a7a5dcdfe1d4b6bd71e40b01c735f144 +x2rgb10le 3a271577cbbd82b58381fd9649812707 xyz12be d2fa69ec91d3ed862f2dac3f8e7a3437 xyz12le 02bccd5e0b6824779a1f848b0ea3e3b5 ya16be 40403b5277364777e0671da4d38e01ac diff --git a/tests/ref/fate/filter-pixfmts-fieldorder b/tests/ref/fate/filter-pixfmts-fieldorder index 90d36add83..413ea2925a 100644 --- a/tests/ref/fate/filter-pixfmts-fieldorder +++ b/tests/ref/fate/filter-pixfmts-fieldorder @@ -71,7 +71,7 @@ rgba1fdf872a087a32cd35b80cc7be399578 rgba64be5598f44514d122b9a57c5c92c20bbc61 rgba64leb34e6e30621ae579519a2d91a96a0acf uyvy422 75de70e31c435dde878002d3f22b238a -x2rgb10le 636c90498c64abba1cc0624c5209a61f +x2rgb10le 403e41a1387fbe3e31b3bca8313961f1 xyz12be 15f5cda71de5fef9cec5e75e3833b6bc xyz12le 7be6c8781f38c21a6b8f602f62ca31e6 ya16be 0f13e0f52586d172aaa07710fa3e8f31 diff --git a/tests/ref/fate/filter-pixfmts-hflip b/tests/ref/fate/filter-pixfmts-hflip index 0d40b93e97..6d5ddca677 100644 --- a/tests/r
Re: [FFmpeg-devel] [PATCH 1/4] avcodec/mjpegdec: export display matrix frame side data when available
> -Original Message- > From: ffmpeg-devel On Behalf Of James Almer > Sent: Wednesday, September 08, 2021 11:34 AM > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH 1/4] avcodec/mjpegdec: export display matrix > frame side data when available > > Signed-off-by: James Almer > --- > libavcodec/mjpegdec.c | 53 +++ > 1 file changed, 53 insertions(+) > > diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c > index 2a5868fe1d..7bec5ce221 100644 > --- a/libavcodec/mjpegdec.c > +++ b/libavcodec/mjpegdec.c > @@ -30,6 +30,7 @@ > * MJPEG decoder. > */ > > +#include "libavutil/display.h" > #include "libavutil/imgutils.h" > #include "libavutil/avassert.h" > #include "libavutil/opt.h" > @@ -2406,6 +2407,7 @@ int ff_mjpeg_receive_frame(AVCodecContext *avctx, > AVFrame *frame) > int i, index; > int ret = 0; > int is16bit; > +AVDictionaryEntry *e = NULL; > > s->force_pal8 = 0; > > @@ -2864,6 +2866,57 @@ the_end: > } > } > > +if (e = av_dict_get(s->exif_metadata, "Orientation", e, > AV_DICT_IGNORE_SUFFIX)) { > +char *value = e->value + strspn(e->value, " \n\t\r"), *endptr; > +int orientation = strtol(value, &endptr, 0); > + > +if (!*endptr) { > +AVFrameSideData *sd = NULL; > + > +if (orientation >= 2 && orientation <= 8) { > +int32_t *matrix; > + > +sd = av_frame_new_side_data(frame, > AV_FRAME_DATA_DISPLAYMATRIX, sizeof(int32_t) * 9); > +if (!sd) { > +av_log(s->avctx, AV_LOG_ERROR, "Could not allocate frame > side data\n"); > +return AVERROR(ENOMEM); > +} > + > +matrix = (int32_t *)sd->data; > + > +switch (orientation) { > +case 2: > +av_display_rotation_set(matrix, 0.0); > +av_display_matrix_flip(matrix, 1, 0); > +break; > +case 3: > +av_display_rotation_set(matrix, 180.0); > +break; > +case 4: > +av_display_rotation_set(matrix, 180.0); > +av_display_matrix_flip(matrix, 1, 0); > +break; > +case 5: > +av_display_rotation_set(matrix, 90.0); > +av_display_matrix_flip(matrix, 0, 1); > +break; > +case 6: > +av_display_rotation_set(matrix, 90.0); > +break; > +case 7: > +av_display_rotation_set(matrix, -90.0); > +av_display_matrix_flip(matrix, 0, 1); > +break; > +case 8: > +av_display_rotation_set(matrix, -90.0); > +break; > +default: > +av_assert0(0); > +} > +} > +} > +} > + > av_dict_copy(&frame->metadata, s->exif_metadata, 0); > av_dict_free(&s->exif_metadata); > James, please see regression reported in https://trac.ffmpeg.org/ticket/9432 > -- > 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 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/3] avcodec/dynamic_hdr10_plus: check size before using it
On Tue, Sep 14, 2021 at 06:50:38PM +0800, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavcodec/dynamic_hdr10_plus.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/dynamic_hdr10_plus.c b/libavcodec/dynamic_hdr10_plus.c > index 854e70d..34a44aa 100644 > --- a/libavcodec/dynamic_hdr10_plus.c > +++ b/libavcodec/dynamic_hdr10_plus.c > @@ -40,10 +40,10 @@ int > ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t > if (ret < 0) > return ret; > > -s->application_version = get_bits(gb, 8); > - > -if (get_bits_left(gb) < 2) > +if (get_bits_left(gb) < 10) > return AVERROR_INVALIDDATA; > + > +s->application_version = get_bits(gb, 8); > s->num_windows = get_bits(gb, 2); > > if (s->num_windows < 1 || s->num_windows > 3) { > -- > 1.8.3.1 > will apply this patchset unless there are objections. -- Thanks, Limin Wang ___ 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/3] avcodec/dynamic_hdr10_plus: check size before using it
lance.lmw...@gmail.com: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > libavcodec/dynamic_hdr10_plus.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libavcodec/dynamic_hdr10_plus.c b/libavcodec/dynamic_hdr10_plus.c > index 854e70d..34a44aa 100644 > --- a/libavcodec/dynamic_hdr10_plus.c > +++ b/libavcodec/dynamic_hdr10_plus.c > @@ -40,10 +40,10 @@ int > ff_parse_itu_t_t35_to_dynamic_hdr10_plus(AVDynamicHDRPlus *s, const uint8_t > if (ret < 0) > return ret; > > -s->application_version = get_bits(gb, 8); > - > -if (get_bits_left(gb) < 2) > +if (get_bits_left(gb) < 10) > return AVERROR_INVALIDDATA; > + > +s->application_version = get_bits(gb, 8); > s->num_windows = get_bits(gb, 2); > > if (s->num_windows < 1 || s->num_windows > 3) { > LGTM. - 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/5] avcodec: remove the unused low_delay
From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/h264dec.c | 1 - libavcodec/mpegutils.c | 1 - libavcodec/mpegutils.h | 1 - libavcodec/mpegvideo.c | 2 +- 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index 5ca41cc..6a5bf51 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -944,7 +944,6 @@ static int finalize_frame(H264Context *h, AVFrame *dst, H264Picture *out, int *g out->mb_type, out->qscale_table, out->motion_val, - NULL, out->mb_width, out->mb_height, out->mb_stride, 1); } } diff --git a/libavcodec/mpegutils.c b/libavcodec/mpegutils.c index e5105ec..4cbc474 100644 --- a/libavcodec/mpegutils.c +++ b/libavcodec/mpegutils.c @@ -102,7 +102,6 @@ void ff_draw_horiz_band(AVCodecContext *avctx, void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table, uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2], - int *low_delay, int mb_width, int mb_height, int mb_stride, int quarter_sample) { if ((avctx->export_side_data & AV_CODEC_EXPORT_DATA_MVS) && mbtype_table && motion_val[0]) { diff --git a/libavcodec/mpegutils.h b/libavcodec/mpegutils.h index 5aeff47..0770585 100644 --- a/libavcodec/mpegutils.h +++ b/libavcodec/mpegutils.h @@ -142,7 +142,6 @@ void ff_draw_horiz_band(AVCodecContext *avctx, AVFrame *cur, AVFrame *last, */ void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table, uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2], - int *low_delay, int mb_width, int mb_height, int mb_stride, int quarter_sample); #endif /* AVCODEC_MPEGUTILS_H */ diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 5383f9d..ba5b519 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1417,7 +1417,7 @@ void ff_mpv_frame_end(MpegEncContext *s) void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict) { ff_print_debug_info2(s->avctx, pict, s->mbskip_table, p->mb_type, - p->qscale_table, p->motion_val, &s->low_delay, + p->qscale_table, p->motion_val, s->mb_width, s->mb_height, s->mb_stride, s->quarter_sample); } -- 1.8.3.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 2/5] avfilter/vf_codecview: added new options for block
From: Limin Wang Signed-off-by: Limin Wang --- doc/filters.texi | 3 +++ libavfilter/version.h | 2 +- libavfilter/vf_codecview.c | 35 +++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 9416100..9caaf4d 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8152,6 +8152,9 @@ means. For example, some MPEG based codecs export motion vectors through the The filter accepts the following option: @table @option +@item block +Display block partition structure using the luma plane. + @item mv Set motion vectors to visualize. diff --git a/libavfilter/version.h b/libavfilter/version.h index 24b59ac..2688679 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -31,7 +31,7 @@ #define LIBAVFILTER_VERSION_MAJOR 8 #define LIBAVFILTER_VERSION_MINOR 9 -#define LIBAVFILTER_VERSION_MICRO 100 +#define LIBAVFILTER_VERSION_MICRO 101 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ diff --git a/libavfilter/vf_codecview.c b/libavfilter/vf_codecview.c index dc3d3ac..4a2766a 100644 --- a/libavfilter/vf_codecview.c +++ b/libavfilter/vf_codecview.c @@ -32,6 +32,7 @@ #include "libavutil/imgutils.h" #include "libavutil/motion_vector.h" #include "libavutil/opt.h" +#include "libavutil/video_enc_params.h" #include "avfilter.h" #include "qp_table.h" #include "internal.h" @@ -52,6 +53,7 @@ typedef struct CodecViewContext { unsigned mv_type; int hsub, vsub; int qp; +int block; } CodecViewContext; #define OFFSET(x) offsetof(CodecViewContext, x) @@ -73,6 +75,7 @@ static const AVOption codecview_options[] = { CONST("if", "I-frames", FRAME_TYPE_I, "frame_type"), CONST("pf", "P-frames", FRAME_TYPE_P, "frame_type"), CONST("bf", "B-frames", FRAME_TYPE_B, "frame_type"), +{ "block", "set block partitioning structure to visualize", OFFSET(block), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS }, { NULL } }; @@ -210,6 +213,21 @@ static void draw_arrow(uint8_t *buf, int sx, int sy, int ex, draw_line(buf, sx, sy, ex, ey, w, h, stride, color); } +static void draw_block_rectangle(uint8_t *buf, int sx, int sy, int w, int h, int stride, int color) +{ +for (int x = sx; x < sx + w; x++) +buf[x] = color; + +for (int y = sy; y < sy + h; y++) { +buf[sx] = color; +buf[sx + w - 1] = color; +buf += stride; +} + +for (int x = sx; x < sx + w; x++) +buf[x] = color; +} + static int filter_frame(AVFilterLink *inlink, AVFrame *frame) { AVFilterContext *ctx = inlink->dst; @@ -247,6 +265,23 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) av_freep(&qp_table); } +if (s->block) { +AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_VIDEO_ENC_PARAMS); +if (sd) { +AVVideoEncParams *par = (AVVideoEncParams*)sd->data; +const int stride = frame->linesize[0]; + +if (par->nb_blocks) { +for (int block_idx = 0; block_idx < par->nb_blocks; block_idx++) { +AVVideoBlockParams *b = av_video_enc_params_block(par, block_idx); +uint8_t *buf = frame->data[0] + b->src_y * stride; + +draw_block_rectangle(buf, b->src_x, b->src_y, b->w, b->h, stride, 100); +} +} +} +} + if (s->mv || s->mv_type) { AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_MOTION_VECTORS); if (sd) { -- 1.8.3.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 3/5] avfilter/vf_guided: Fix indention
From: Limin Wang Signed-off-by: Limin Wang --- libavfilter/vf_guided.c | 77 - 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c index f808ba1..066a00d 100644 --- a/libavfilter/vf_guided.c +++ b/libavfilter/vf_guided.c @@ -110,19 +110,19 @@ static int box_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs) w = (radius << 1) + 1; numPix = w * w; for (int i = slice_start;i < slice_end;i++) { - for (int j = 0;j < width;j++) { -float temp = 0.0; -for (int row = -radius;row <= radius;row++) { - for (int col = -radius;col <= radius;col++) { -int x = i + row; -int y = j + col; -x = (x < 0) ? 0 : (x >= height ? height - 1 : x); -y = (y < 0) ? 0 : (y >= width ? width - 1 : y); -temp += src[x * src_stride + y]; - } +for (int j = 0;j < width;j++) { +float temp = 0.0; +for (int row = -radius;row <= radius;row++) { +for (int col = -radius;col <= radius;col++) { +int x = i + row; +int y = j + col; +x = (x < 0) ? 0 : (x >= height ? height - 1 : x); +y = (y < 0) ? 0 : (y >= width ? width - 1 : y); +temp += src[x * src_stride + y]; +} +} +dst[i * dst_stride + j] = temp / numPix; } -dst[i * dst_stride + j] = temp / numPix; - } } return 0; } @@ -161,8 +161,7 @@ static int config_input(AVFilterLink *inlink) if (s->mode == BASIC) { s->sub = 1; -} -else if (s->mode == FAST) { +} else if (s->mode == FAST) { if (s->radius >= s->sub) s->radius = s->radius / s->sub; else { @@ -235,13 +234,13 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s, goto end; \ } \ for (int i = 0;i < h;i++) { \ - for (int j = 0;j < w;j++) { \ -int x = i * w + j; \ -I[x] = src[(i * src_stride + j) * sub] / maxval; \ -II[x] = I[x] * I[x]; \ -P[x] = srcRef[(i * src_ref_stride + j) * sub] / maxval; \ -IP[x] = I[x] * P[x]; \ - } \ +for (int j = 0;j < w;j++) { \ +int x = i * w + j; \ +I[x] = src[(i * src_stride + j) * sub] / maxval; \ +II[x] = I[x] * I[x]; \ +P[x] = srcRef[(i * src_ref_stride + j) * sub] / maxval; \ +IP[x] = I[x] * P[x]; \ +} \ } \ \ t.width = w; \ @@ -262,13 +261,13 @@ static int guided_##name(AVFilterContext *ctx, GuidedContext *s, ff_filter_execute(ctx, s->box_slice, &t, NULL, FFMIN(h, nb_threads)); \ \ for (int i = 0;i < h;i++) { \ - for (int j = 0;j < w;j++) { \ -int x = i * w + j; \ -float varI = meanII[x] - (meanI[x] * meanI[x]); \ -float covIP = meanIP[x] - (meanI[x] * meanP[x]); \ -A[x] = covIP / (varI + eps); \ -B[x] = meanP[x] - A[x] * meanI[x]; \ - } \ +for (int j = 0;j < w;j++) { \ +int x = i * w + j;
[FFmpeg-devel] [PATCH 4/5] avformat/utils: add const for argument passed to ff_is_http_proto()
From: Limin Wang Signed-off-by: Limin Wang --- libavformat/internal.h | 2 +- libavformat/utils.c| 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index cc8c8f4..6f1f1c0 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -907,7 +907,7 @@ void ff_format_io_close(AVFormatContext *s, AVIOContext **pb); * @param s AVFormatContext * @param filename URL or file name to open for writing */ -int ff_is_http_proto(char *filename); +int ff_is_http_proto(const char *filename); /** * Parse creation_time in AVFormatContext metadata if exists and warn if the diff --git a/libavformat/utils.c b/libavformat/utils.c index 2157f93..509c0ec 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1802,7 +1802,7 @@ void ff_format_io_close(AVFormatContext *s, AVIOContext **pb) *pb = NULL; } -int ff_is_http_proto(char *filename) { +int ff_is_http_proto(const char *filename) { const char *proto = avio_find_protocol_name(filename); return proto ? (!av_strcasecmp(proto, "http") || !av_strcasecmp(proto, "https")) : 0; } -- 1.8.3.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 5/5] avformat/hlsenc: add const for filename argument
From: Limin Wang Signed-off-by: Limin Wang --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 7c37bc5..98608a8 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -281,7 +281,7 @@ static int strftime_expand(const char *fmt, char **dest) return r; } -static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename, +static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, const char *filename, AVDictionary **options) { HLSContext *hls = s->priv_data; -- 1.8.3.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 01/26] avfilter/af_afade: Remove redundant checks and assignments
The acrossfade filter uses the ff_set_common_* functions in its query_formats(), so that the formats, the sample rates as well as the channel layouts and counts of all links coincide. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_afade.c | 11 --- 1 file changed, 11 deletions(-) diff --git a/libavfilter/af_afade.c b/libavfilter/af_afade.c index a55d5d72c3..3bd0331e77 100644 --- a/libavfilter/af_afade.c +++ b/libavfilter/af_afade.c @@ -588,18 +588,7 @@ static int acrossfade_config_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; AudioFadeContext *s = ctx->priv; -if (ctx->inputs[0]->sample_rate != ctx->inputs[1]->sample_rate) { -av_log(ctx, AV_LOG_ERROR, - "Inputs must have the same sample rate " - "%d for in0 vs %d for in1\n", - ctx->inputs[0]->sample_rate, ctx->inputs[1]->sample_rate); -return AVERROR(EINVAL); -} - -outlink->sample_rate = ctx->inputs[0]->sample_rate; outlink->time_base = ctx->inputs[0]->time_base; -outlink->channel_layout = ctx->inputs[0]->channel_layout; -outlink->channels = ctx->inputs[0]->channels; switch (outlink->format) { case AV_SAMPLE_FMT_DBL: s->crossfade_samples = crossfade_samples_dbl; break; -- 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 02/26] avfilter/af_agate: Honour query_formats API, fix segfault
The sidechaingate filter wants its main input and its (only) output to have the same channel layout and number of channels; yet it does not link them in its query_formats callback. Instead it sets the outlink to only accept the first offered choice for the main input's channel layout and then sets both inputs to independently accept any channel counts. The config_output callback then overwrote the outlink's channel layout and channels properties with the main input's, even though they may differ in case the first offered choice for the main input's channel layout turns out not to be the final one. Consider e.g. the following filtergraph: [in]aformat=channel_layouts=mono,aformat=channel_layouts=stereo|mono[out];\ [out][in2]sidechaingate,stereotools The two aformats ensure that the first offered channel layout (stereo) will not be chosen for the input; yet it is the only offered channel layout for the output of sidechaingate and will therefore be chosen by the query_formats framework. Because the sidechaingate outputs interleaved doubles which stereotools expects the output of sidechaingate appears to be suitable as input for stereotools without further conversions. Yet stereotools actually only receives a mono frame and therefore overreads its input buffer which leads to segfaults; it can also lead to heap corruption because there can be writes beyond the end of the buffer, too. Fix this by linking the channel layouts of the main input and the output in query_formats and remove the code overwriting it in config_output. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_agate.c | 26 +++--- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/libavfilter/af_agate.c b/libavfilter/af_agate.c index 284880833a..8e5cca4228 100644 --- a/libavfilter/af_agate.c +++ b/libavfilter/af_agate.c @@ -332,29 +332,19 @@ static int activate(AVFilterContext *ctx) static int scquery_formats(AVFilterContext *ctx) { -AVFilterChannelLayouts *layouts = NULL; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE }; -int ret, i; - -if (!ctx->inputs[0]->incfg.channel_layouts || -!ctx->inputs[0]->incfg.channel_layouts->nb_channel_layouts) { -av_log(ctx, AV_LOG_WARNING, - "No channel layout for input 1\n"); -return AVERROR(EAGAIN); -} - -if ((ret = ff_add_channel_layout(&layouts, ctx->inputs[0]->incfg.channel_layouts->channel_layouts[0])) < 0 || -(ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) +int ret = ff_channel_layouts_ref(ff_all_channel_counts(), + &ctx->inputs[1]->outcfg.channel_layouts); +if (ret < 0) return ret; -for (i = 0; i < 2; i++) { -layouts = ff_all_channel_counts(); -if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) -return ret; -} +/* This will link the channel properties of the main input and the output; + * it won't touch the second input as its channel_layouts is already set. */ +if ((ret = ff_set_common_all_channel_counts(ctx)) < 0) +return ret; if ((ret = ff_set_common_formats_from_list(ctx, sample_fmts)) < 0) return ret; @@ -377,8 +367,6 @@ static int scconfig_output(AVFilterLink *outlink) outlink->sample_rate = ctx->inputs[0]->sample_rate; outlink->time_base = ctx->inputs[0]->time_base; -outlink->channel_layout = ctx->inputs[0]->channel_layout; -outlink->channels = ctx->inputs[0]->channels; s->fifo[0] = av_audio_fifo_alloc(ctx->inputs[0]->format, ctx->inputs[0]->channels, 1024); s->fifo[1] = av_audio_fifo_alloc(ctx->inputs[1]->format, ctx->inputs[1]->channels, 1024); -- 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 03/26] avfilter/af_sidechaincompress: Honour query_formats API, fix segfault
Just like the sidechaingate filter, the sidechaincompress filter overwrote the channel layout and channel count of its output in its config_output callback to match the channel layout of its main input instead of linking the main input and its output together in its query_formats callback. This is an API violation that can lead to segfaults, as in the following filtergraph, where stereotools rightly expects stereo, yet receives only mono: [in]aformat=channel_layouts=mono,aformat=channel_layouts=stereo|mono[out];\ [out][in2]sidechaincompress,stereotools Fix this by linking the channel layouts of the main input and the output in query_formats and remove the code overwriting it in config_output. Signed-off-by: Andreas Rheinhardt --- Will deduplicate af_agate.c and af_sidechaincompress.c later. libavfilter/af_sidechaincompress.c | 26 +++--- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/libavfilter/af_sidechaincompress.c b/libavfilter/af_sidechaincompress.c index 48d450fd50..af4a90ea09 100644 --- a/libavfilter/af_sidechaincompress.c +++ b/libavfilter/af_sidechaincompress.c @@ -298,29 +298,19 @@ static int activate(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { -AVFilterChannelLayouts *layouts = NULL; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE }; -int ret, i; - -if (!ctx->inputs[0]->incfg.channel_layouts || -!ctx->inputs[0]->incfg.channel_layouts->nb_channel_layouts) { -av_log(ctx, AV_LOG_WARNING, - "No channel layout for input 1\n"); -return AVERROR(EAGAIN); -} - -if ((ret = ff_add_channel_layout(&layouts, ctx->inputs[0]->incfg.channel_layouts->channel_layouts[0])) < 0 || -(ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) +int ret = ff_channel_layouts_ref(ff_all_channel_counts(), + &ctx->inputs[1]->outcfg.channel_layouts); +if (ret < 0) return ret; -for (i = 0; i < 2; i++) { -layouts = ff_all_channel_counts(); -if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) -return ret; -} +/* This will link the channel properties of the main input and the output; + * it won't touch the second input as its channel_layouts is already set. */ +if ((ret = ff_set_common_all_channel_counts(ctx)) < 0) +return ret; if ((ret = ff_set_common_formats_from_list(ctx, sample_fmts)) < 0) return ret; @@ -343,8 +333,6 @@ static int config_output(AVFilterLink *outlink) outlink->sample_rate = ctx->inputs[0]->sample_rate; outlink->time_base = ctx->inputs[0]->time_base; -outlink->channel_layout = ctx->inputs[0]->channel_layout; -outlink->channels = ctx->inputs[0]->channels; s->fifo[0] = av_audio_fifo_alloc(ctx->inputs[0]->format, ctx->inputs[0]->channels, 1024); s->fifo[1] = av_audio_fifo_alloc(ctx->inputs[1]->format, ctx->inputs[1]->channels, 1024); -- 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 04/26] avfilter/af_agate: Remove always-false samplerate check
This filter uses ff_set_common_all_samplerates(). Also don't overwrite outlink->sample_rate in config_output; it is harmless, because it is overwritten with the value it already had, but it is an API violation. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_agate.c | 9 - 1 file changed, 9 deletions(-) diff --git a/libavfilter/af_agate.c b/libavfilter/af_agate.c index 8e5cca4228..5de2cc0f0e 100644 --- a/libavfilter/af_agate.c +++ b/libavfilter/af_agate.c @@ -357,15 +357,6 @@ static int scconfig_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; AudioGateContext *s = ctx->priv; -if (ctx->inputs[0]->sample_rate != ctx->inputs[1]->sample_rate) { -av_log(ctx, AV_LOG_ERROR, - "Inputs must have the same sample rate " - "%d for in0 vs %d for in1\n", - ctx->inputs[0]->sample_rate, ctx->inputs[1]->sample_rate); -return AVERROR(EINVAL); -} - -outlink->sample_rate = ctx->inputs[0]->sample_rate; outlink->time_base = ctx->inputs[0]->time_base; s->fifo[0] = av_audio_fifo_alloc(ctx->inputs[0]->format, ctx->inputs[0]->channels, 1024); -- 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 05/26] avfilter/af_amerge: Remove always-false samplerate check
This filter uses ff_set_common_all_samplerates(). Also don't overwrite outlink->sample_rate in config_output; it is harmless, because it is overwritten with the value it already had, but it is an API violation. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_amerge.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index d67e3d7e32..9c6da15a9f 100644 --- a/libavfilter/af_amerge.c +++ b/libavfilter/af_amerge.c @@ -151,17 +151,7 @@ static int config_output(AVFilterLink *outlink) AVBPrint bp; int i; -for (i = 1; i < s->nb_inputs; i++) { -if (ctx->inputs[i]->sample_rate != ctx->inputs[0]->sample_rate) { -av_log(ctx, AV_LOG_ERROR, - "Inputs must have the same sample rate " - "%d for in%d vs %d\n", - ctx->inputs[i]->sample_rate, i, ctx->inputs[0]->sample_rate); -return AVERROR(EINVAL); -} -} s->bps = av_get_bytes_per_sample(ctx->outputs[0]->format); -outlink->sample_rate = ctx->inputs[0]->sample_rate; outlink->time_base = ctx->inputs[0]->time_base; av_bprint_init(&bp, 0, AV_BPRINT_SIZE_AUTOMATIC); -- 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 06/26] avfilter/af_sidechaincompress: Remove always-false samplerate check
This filter uses ff_set_common_all_samplerates(). Also don't overwrite outlink->sample_rate in config_output; it is harmless, because it is overwritten with the value it already had, but it is an API violation. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_sidechaincompress.c | 9 - 1 file changed, 9 deletions(-) diff --git a/libavfilter/af_sidechaincompress.c b/libavfilter/af_sidechaincompress.c index af4a90ea09..22a86ae2a7 100644 --- a/libavfilter/af_sidechaincompress.c +++ b/libavfilter/af_sidechaincompress.c @@ -323,15 +323,6 @@ static int config_output(AVFilterLink *outlink) AVFilterContext *ctx = outlink->src; SidechainCompressContext *s = ctx->priv; -if (ctx->inputs[0]->sample_rate != ctx->inputs[1]->sample_rate) { -av_log(ctx, AV_LOG_ERROR, - "Inputs must have the same sample rate " - "%d for in0 vs %d for in1\n", - ctx->inputs[0]->sample_rate, ctx->inputs[1]->sample_rate); -return AVERROR(EINVAL); -} - -outlink->sample_rate = ctx->inputs[0]->sample_rate; outlink->time_base = ctx->inputs[0]->time_base; s->fifo[0] = av_audio_fifo_alloc(ctx->inputs[0]->format, ctx->inputs[0]->channels, 1024); -- 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 07/26] avfilter/vf_blend: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_blend.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c index 73fdea3c79..47ec1b5a2d 100644 --- a/libavfilter/vf_blend.c +++ b/libavfilter/vf_blend.c @@ -821,10 +821,6 @@ static int config_output(AVFilterLink *outlink) if (!s->tblend) { AVFilterLink *bottomlink = ctx->inputs[BOTTOM]; -if (toplink->format != bottomlink->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (toplink->w != bottomlink->w || toplink->h != bottomlink->h) { av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " "(size %dx%d) do not match the corresponding " -- 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 08/26] avfilter/vf_bm3d: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_bm3d.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_bm3d.c b/libavfilter/vf_bm3d.c index 198fc43268..007f8bbf8c 100644 --- a/libavfilter/vf_bm3d.c +++ b/libavfilter/vf_bm3d.c @@ -968,10 +968,6 @@ static int config_output(AVFilterLink *outlink) if (s->ref) { ref = ctx->inputs[1]; -if (src->format != ref->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (src->w != ref->w || src->h != ref->h) { av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " -- 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 09/26] avfilter/vf_convolve: Remove always-false format check
These filters use ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_convolve.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_convolve.c b/libavfilter/vf_convolve.c index ab6d1a271f..70d6793a50 100644 --- a/libavfilter/vf_convolve.c +++ b/libavfilter/vf_convolve.c @@ -162,10 +162,6 @@ static int config_input_impulse(AVFilterLink *inlink) av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n"); return AVERROR(EINVAL); } -if (ctx->inputs[0]->format != ctx->inputs[1]->format) { -av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n"); -return AVERROR(EINVAL); -} return 0; } -- 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 10/26] avfilter/vf_displace: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_displace.c | 5 - 1 file changed, 5 deletions(-) diff --git a/libavfilter/vf_displace.c b/libavfilter/vf_displace.c index 0bd35b2516..3dbba3b95c 100644 --- a/libavfilter/vf_displace.c +++ b/libavfilter/vf_displace.c @@ -311,11 +311,6 @@ static int config_output(AVFilterLink *outlink) FFFrameSyncIn *in; int ret; -if (srclink->format != xlink->format || -srclink->format != ylink->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (srclink->w != xlink->w || srclink->h != xlink->h || srclink->w != ylink->w || -- 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 11/26] avfilter/vf_guided: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_guided.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c index f808ba1043..bf8be866e6 100644 --- a/libavfilter/vf_guided.c +++ b/libavfilter/vf_guided.c @@ -367,10 +367,6 @@ static int config_output(AVFilterLink *outlink) av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n"); return AVERROR(EINVAL); } -if (ctx->inputs[0]->format != ctx->inputs[1]->format) { -av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n"); -return AVERROR(EINVAL); -} } outlink->w = mainlink->w; -- 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 12/26] avfilter/vf_hysteresis: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_hysteresis.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_hysteresis.c b/libavfilter/vf_hysteresis.c index cbbee2691b..0346465e43 100644 --- a/libavfilter/vf_hysteresis.c +++ b/libavfilter/vf_hysteresis.c @@ -295,10 +295,6 @@ static int config_output(AVFilterLink *outlink) FFFrameSyncIn *in; int ret; -if (base->format != alt->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (base->w != alt->w || base->h != alt->h) { av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " "(size %dx%d) do not match the corresponding " -- 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 13/26] avfilter/vf_identity: Remove always-false format check
These filters use ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_identity.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_identity.c b/libavfilter/vf_identity.c index fd72137344..5f0b4e9834 100644 --- a/libavfilter/vf_identity.c +++ b/libavfilter/vf_identity.c @@ -274,10 +274,6 @@ static int config_input_ref(AVFilterLink *inlink) av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n"); return AVERROR(EINVAL); } -if (ctx->inputs[0]->format != ctx->inputs[1]->format) { -av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n"); -return AVERROR(EINVAL); -} s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0; s->comps[0] = s->is_rgb ? 'R' : 'Y' ; -- 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 14/26] avfilter/vf_libvmaf: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_libvmaf.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c index d3e9f62e33..00b2661f5e 100644 --- a/libavfilter/vf_libvmaf.c +++ b/libavfilter/vf_libvmaf.c @@ -271,10 +271,6 @@ static int config_input_ref(AVFilterLink *inlink) av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n"); return AVERROR(EINVAL); } -if (ctx->inputs[0]->format != ctx->inputs[1]->format) { -av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n"); -return AVERROR(EINVAL); -} s->desc = av_pix_fmt_desc_get(inlink->format); s->width = ctx->inputs[0]->w; -- 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 15/26] avfilter/vf_maskedclamp: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_maskedclamp.c | 5 - 1 file changed, 5 deletions(-) diff --git a/libavfilter/vf_maskedclamp.c b/libavfilter/vf_maskedclamp.c index c19bc9d849..f46c5c9934 100644 --- a/libavfilter/vf_maskedclamp.c +++ b/libavfilter/vf_maskedclamp.c @@ -230,11 +230,6 @@ static int config_output(AVFilterLink *outlink) FFFrameSyncIn *in; int ret; -if (base->format != dark->format || -base->format != bright->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (base->w != dark->w || base->h != dark->h || base->w != bright->w || base->h != bright->h) { av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " -- 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 16/26] avfilter/vf_maskedmerge: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_maskedmerge.c | 5 - 1 file changed, 5 deletions(-) diff --git a/libavfilter/vf_maskedmerge.c b/libavfilter/vf_maskedmerge.c index 00e9308622..26b54830b8 100644 --- a/libavfilter/vf_maskedmerge.c +++ b/libavfilter/vf_maskedmerge.c @@ -228,11 +228,6 @@ static int config_output(AVFilterLink *outlink) FFFrameSyncIn *in; int ret; -if (base->format != overlay->format || -base->format != mask->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (base->w != overlay->w || base->h != overlay->h || base->w != mask->w|| base->h != mask->h) { av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " -- 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 17/26] avfilter/vf_maskedminmax: Remove always-false format check
These filters use ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_maskedminmax.c | 5 - 1 file changed, 5 deletions(-) diff --git a/libavfilter/vf_maskedminmax.c b/libavfilter/vf_maskedminmax.c index 6c7f6de211..82b0eca8f0 100644 --- a/libavfilter/vf_maskedminmax.c +++ b/libavfilter/vf_maskedminmax.c @@ -239,11 +239,6 @@ static int config_output(AVFilterLink *outlink) FFFrameSyncIn *in; int ret; -if (source->format != f1->format || -source->format != f2->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (source->w != f1->w || source->h != f1->h || source->w != f2->w || source->h != f2->h) { av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " -- 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 18/26] avfilter/vf_maskedthreshold: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_maskedthreshold.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_maskedthreshold.c b/libavfilter/vf_maskedthreshold.c index 4b183eb9fd..a8f717364e 100644 --- a/libavfilter/vf_maskedthreshold.c +++ b/libavfilter/vf_maskedthreshold.c @@ -208,10 +208,6 @@ static int config_output(AVFilterLink *outlink) FFFrameSyncIn *in; int ret; -if (source->format != ref->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (source->w != ref->w || source->h != ref->h) { av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " "(size %dx%d) do not match the corresponding " -- 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 19/26] avfilter/vf_midequalizer: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_midequalizer.c | 5 - 1 file changed, 5 deletions(-) diff --git a/libavfilter/vf_midequalizer.c b/libavfilter/vf_midequalizer.c index 0e87723609..069bf47174 100644 --- a/libavfilter/vf_midequalizer.c +++ b/libavfilter/vf_midequalizer.c @@ -305,11 +305,6 @@ static int config_output(AVFilterLink *outlink) FFFrameSyncIn *in; int ret; -if (in0->format != in1->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} - outlink->w = in0->w; outlink->h = in0->h; outlink->sample_aspect_ratio = in0->sample_aspect_ratio; -- 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 20/26] avfilter/vf_premultiply: Remove always-false format check
These filters use ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_premultiply.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_premultiply.c b/libavfilter/vf_premultiply.c index a76c08405c..ada249fc55 100644 --- a/libavfilter/vf_premultiply.c +++ b/libavfilter/vf_premultiply.c @@ -700,10 +700,6 @@ static int config_output(AVFilterLink *outlink) if (!s->inplace) { alpha = ctx->inputs[1]; -if (base->format != alpha->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (base->w != alpha->w || base->h != alpha->h) { av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " -- 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 21/26] avfilter/vf_psnr: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_psnr.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c index d254d0cb55..a4ce9a4c4c 100644 --- a/libavfilter/vf_psnr.c +++ b/libavfilter/vf_psnr.c @@ -332,10 +332,6 @@ static int config_input_ref(AVFilterLink *inlink) av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n"); return AVERROR(EINVAL); } -if (ctx->inputs[0]->format != ctx->inputs[1]->format) { -av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n"); -return AVERROR(EINVAL); -} s->max[0] = (1 << desc->comp[0].depth) - 1; s->max[1] = (1 << desc->comp[1].depth) - 1; -- 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 22/26] avfilter/vf_ssim: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_ssim.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c index 61a84ff990..14d7ab3ec6 100644 --- a/libavfilter/vf_ssim.c +++ b/libavfilter/vf_ssim.c @@ -453,10 +453,6 @@ static int config_input_ref(AVFilterLink *inlink) av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n"); return AVERROR(EINVAL); } -if (ctx->inputs[0]->format != ctx->inputs[1]->format) { -av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n"); -return AVERROR(EINVAL); -} s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0; s->comps[0] = s->is_rgb ? 'R' : 'Y'; -- 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 23/26] avfilter/vf_threshold: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_threshold.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/libavfilter/vf_threshold.c b/libavfilter/vf_threshold.c index 828f7a8746..b6b93fef6f 100644 --- a/libavfilter/vf_threshold.c +++ b/libavfilter/vf_threshold.c @@ -253,12 +253,6 @@ static int config_output(AVFilterLink *outlink) FFFrameSyncIn *in; int ret; -if (base->format != threshold->format || -base->format != min->format || -base->format != max->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (base->w != threshold->w || base->h != threshold->h || base->w != min->w || -- 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 24/26] avfilter/vf_vif: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_vif.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_vif.c b/libavfilter/vf_vif.c index da3069c1f6..ee7c67337d 100644 --- a/libavfilter/vf_vif.c +++ b/libavfilter/vf_vif.c @@ -496,10 +496,6 @@ static int config_input_ref(AVFilterLink *inlink) av_log(ctx, AV_LOG_ERROR, "Width and height of input videos must be same.\n"); return AVERROR(EINVAL); } -if (ctx->inputs[0]->format != ctx->inputs[1]->format) { -av_log(ctx, AV_LOG_ERROR, "Inputs must be of same pixel format.\n"); -return AVERROR(EINVAL); -} s->desc = av_pix_fmt_desc_get(inlink->format); s->width = ctx->inputs[0]->w; -- 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 25/26] avfilter/vf_xfade: Remove always-false format check
This filter uses ff_set_common_formats_from_list(). Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_xfade.c | 4 1 file changed, 4 deletions(-) diff --git a/libavfilter/vf_xfade.c b/libavfilter/vf_xfade.c index eff8a8b854..b4edcbf1b4 100644 --- a/libavfilter/vf_xfade.c +++ b/libavfilter/vf_xfade.c @@ -1717,10 +1717,6 @@ static int config_output(AVFilterLink *outlink) XFadeContext *s = ctx->priv; const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink0->format); -if (inlink0->format != inlink1->format) { -av_log(ctx, AV_LOG_ERROR, "inputs must be of same pixel format\n"); -return AVERROR(EINVAL); -} if (inlink0->w != inlink1->w || inlink0->h != inlink1->h) { av_log(ctx, AV_LOG_ERROR, "First input link %s parameters " "(size %dx%d) do not match the corresponding " -- 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 26/26] avfilter/vf_geq: Simplify creating string
Also fixes a Wformat-truncation warning from GCC. Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_geq.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavfilter/vf_geq.c b/libavfilter/vf_geq.c index 4a78336540..1dc59dc1fa 100644 --- a/libavfilter/vf_geq.c +++ b/libavfilter/vf_geq.c @@ -250,9 +250,7 @@ static av_cold int geq_init(AVFilterContext *ctx) } if (!geq->expr_str[A]) { -char bps_string[8]; -snprintf(bps_string, sizeof(bps_string), "%d", (1expr_str[A] = av_strdup(bps_string); +geq->expr_str[A] = av_asprintf("%d", (1 expr_str[G]) geq->expr_str[G] = av_strdup("g(X,Y)"); -- 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 2/2] avcodec/mlpenc: fix encoding stereo single stream in TrueHD
Quoting Paul B Mahol (2021-09-20 19:40:33) > On Mon, Sep 20, 2021 at 12:56 PM Anton Khirnov wrote: > > > Quoting Paul B Mahol (2021-09-18 19:21:05) > > > Signed-off-by: Paul B Mahol > > > --- > > > libavcodec/mlpenc.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > Sure would be nice to have tests. > > > > Too soon, encoder is still experimental. The decoder can still be tested, no? -- Anton Khirnov ___ 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 25/26] avfilter/vf_xfade: Remove always-false format 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 01/26] avfilter/af_afade: Remove redundant checks and assignments
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] avcodec/mlpenc: fix encoding stereo single stream in TrueHD
On Tue, Sep 21, 2021 at 8:43 AM Anton Khirnov wrote: > Quoting Paul B Mahol (2021-09-20 19:40:33) > > On Mon, Sep 20, 2021 at 12:56 PM Anton Khirnov > wrote: > > > > > Quoting Paul B Mahol (2021-09-18 19:21:05) > > > > Signed-off-by: Paul B Mahol > > > > --- > > > > libavcodec/mlpenc.c | 2 +- > > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > Sure would be nice to have tests. > > > > > > > Too soon, encoder is still experimental. > > The decoder can still be tested, no? > If its also not buggy. > > -- > Anton Khirnov > ___ 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".