[FFmpeg-cvslog] Add myself as codec2 maintainer
ffmpeg | branch: master | Tomas Härdin | Tue Feb 13 11:46:44 2018 +0100| [5f36c546ec4ef279027da6e0f0ef1276bea4207a] | committer: Tomas Härdin Add myself as codec2 maintainer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5f36c546ec4ef279027da6e0f0ef1276bea4207a --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index bf1299bdbf..cc4c23df6f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -188,6 +188,7 @@ Codecs: jvdec.c Peter Ross lcl*.cRoberto Togni, Reimar Doeffinger libcelt_dec.c Nicolas George + libcodec2.c Tomas Härdin libdirac* David Conrad libgsm.c Michel Bardiaux libkvazaar.c Arttu Ylä-Outinen @@ -395,6 +396,7 @@ Muxers/Demuxers: brstm.c Paul B Mahol caf* Peter Ross cdxl.cPaul B Mahol + codec2.c Tomas Härdin crc.c Michael Niedermayer dashdec.c Steven Liu dashenc.c Karthick Jeyapal ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Don't complain about codec2's 700 bit/s modes in ffmpeg.c
ffmpeg | branch: master | Tomas Härdin | Thu Aug 3 17:33:04 2017 +0200| [5caae279799893e9ecd7646433262a07e0dfca75] | committer: Tomas Härdin Don't complain about codec2's 700 bit/s modes in ffmpeg.c > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5caae279799893e9ecd7646433262a07e0dfca75 --- fftools/ffmpeg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index bea922b0aa..32caa4bfb2 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -3502,7 +3502,8 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len) av_buffersink_set_frame_size(ost->filter->filter, ost->enc_ctx->frame_size); assert_avoptions(ost->encoder_opts); -if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) +if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000 && +ost->enc_ctx->codec_id != AV_CODEC_ID_CODEC2 /* don't complain about 700 bit/s modes */) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." " It takes bits/s as argument, not kbits/s\n"); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] Add muxer/demuxer for raw codec2 and .c2 files
ffmpeg | branch: master | Tomas Härdin | Tue Aug 8 15:28:06 2017 +0200| [5655048c73f7c737f44f63e0c0d2b60abe4b9d2b] | committer: Tomas Härdin Add muxer/demuxer for raw codec2 and .c2 files > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5655048c73f7c737f44f63e0c0d2b60abe4b9d2b --- Changelog| 1 + doc/general.texi | 4 + libavformat/Makefile | 4 + libavformat/allformats.c | 4 + libavformat/codec2.c | 285 +++ libavformat/rawenc.c | 13 +++ libavformat/utils.c | 1 + libavformat/version.h| 2 +- 8 files changed, 313 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index d726d119ea..499413f306 100644 --- a/Changelog +++ b/Changelog @@ -41,6 +41,7 @@ version : - VAAPI-accelerated ProcAmp (color balance), denoise and sharpness filters - Add android_camera indev - codec2 en/decoding via libcodec2 +- muxer/demuxer for raw codec2 files and .c2 files version 3.4: diff --git a/doc/general.texi b/doc/general.texi index 63722f272d..63aed34808 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -320,6 +320,10 @@ library: @item BRSTM @tab @tab X @tab Audio format used on the Nintendo Wii. @item BWF @tab X @tab X +@item codec2 (raw) @tab X @tab X +@tab Must be given -mode format option to decode correctly. +@item codec2 (.c2 files)@tab X @tab X +@tab Contains header with version and mode info, simplifying playback. @item CRI ADX @tab X @tab X @tab Audio-only format used in console video games. @item Discworld II BMV @tab @tab X diff --git a/libavformat/Makefile b/libavformat/Makefile index 7ac1ba95ad..d90766e201 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -133,6 +133,10 @@ OBJS-$(CONFIG_CAVSVIDEO_MUXER) += rawenc.o OBJS-$(CONFIG_CDG_DEMUXER) += cdg.o OBJS-$(CONFIG_CDXL_DEMUXER) += cdxl.o OBJS-$(CONFIG_CINE_DEMUXER) += cinedec.o +OBJS-$(CONFIG_CODEC2_DEMUXER)+= ../libavcodec/codec2utils.o codec2.o rawdec.o pcm.o +OBJS-$(CONFIG_CODEC2_MUXER) += ../libavcodec/codec2utils.o codec2.o rawenc.o +OBJS-$(CONFIG_CODEC2RAW_DEMUXER) += ../libavcodec/codec2utils.o codec2.o rawdec.o pcm.o +OBJS-$(CONFIG_CODEC2RAW_MUXER) += rawenc.o OBJS-$(CONFIG_CONCAT_DEMUXER)+= concatdec.o OBJS-$(CONFIG_CRC_MUXER) += crcenc.o OBJS-$(CONFIG_DATA_DEMUXER) += rawdec.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index e75cd917e4..662e505416 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -96,6 +96,10 @@ extern AVOutputFormat ff_cavsvideo_muxer; extern AVInputFormat ff_cdg_demuxer; extern AVInputFormat ff_cdxl_demuxer; extern AVInputFormat ff_cine_demuxer; +extern AVInputFormat ff_codec2_demuxer; +extern AVOutputFormat ff_codec2_muxer; +extern AVInputFormat ff_codec2raw_demuxer; +extern AVOutputFormat ff_codec2raw_muxer; extern AVInputFormat ff_concat_demuxer; extern AVOutputFormat ff_crc_muxer; extern AVInputFormat ff_dash_demuxer; diff --git a/libavformat/codec2.c b/libavformat/codec2.c new file mode 100644 index 00..28dbbd8176 --- /dev/null +++ b/libavformat/codec2.c @@ -0,0 +1,285 @@ +/* + * codec2 muxer and demuxers + * Copyright (c) 2017 Tomas Härdin + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libavcodec/codec2utils.h" +#include "libavutil/intreadwrite.h" +#include "avio_internal.h" +#include "avformat.h" +#include "internal.h" +#include "rawdec.h" +#include "rawenc.h" +#include "pcm.h" + +#define AVPRIV_CODEC2_HEADER_SIZE 7 +#define AVPRIV_CODEC2_MAGIC 0xC0DEC2 + +//the lowest version we should ever run across is 0.8 +//we may run across later versions as the format evolves +#define EXPECTED_CODEC2_MAJOR_VERSION 0 +#define EXPECTED_CODEC2_MINOR_VERSION 8 + +typedef struct { +const AVClass *class; +int mode; +int frames_per_packet; +} Codec2Context; + +static int codec2_probe(AVProbeData *p) +{ +//must start wih C0 DE C2 +if (AV_RB24(p->buf) != AVPRIV_CODEC2_MAGIC) { +return 0; +
[FFmpeg-cvslog] Add libcodec2 en/decoder
ffmpeg | branch: master | Tomas Härdin | Tue Aug 8 15:27:27 2017 +0200| [f958f431eced497f42220d8f9890506215742512] | committer: Tomas Härdin Add libcodec2 en/decoder > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f958f431eced497f42220d8f9890506215742512 --- Changelog| 1 + configure| 5 ++ doc/general.texi | 20 + libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 2 + libavcodec/avcodec.h | 1 + libavcodec/codec2utils.c | 80 ++ libavcodec/codec2utils.h | 82 ++ libavcodec/codec_desc.c | 7 ++ libavcodec/libcodec2.c | 213 +++ libavcodec/version.h | 4 +- 11 files changed, 415 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index f7afd2f9ed..d726d119ea 100644 --- a/Changelog +++ b/Changelog @@ -40,6 +40,7 @@ version : - VideoToolbox HEVC encoder and hwaccel - VAAPI-accelerated ProcAmp (color balance), denoise and sharpness filters - Add android_camera indev +- codec2 en/decoding via libcodec2 version 3.4: diff --git a/configure b/configure index d40718f842..1bdb7c1c2d 100755 --- a/configure +++ b/configure @@ -224,6 +224,7 @@ External library support: --enable-libcaca enable textual display using libcaca [no] --enable-libcelt enable CELT decoding via libcelt [no] --enable-libcdio enable audio CD grabbing with libcdio [no] + --enable-libcodec2 enable codec2 en/decoding using libcodec2 [no] --enable-libdc1394 enable IIDC-1394 grabbing using libdc1394 and libraw1394 [no] --enable-libfdk-aac enable AAC de/encoding via libfdk-aac [no] @@ -1603,6 +1604,7 @@ EXTERNAL_LIBRARY_LIST=" libbs2b libcaca libcelt +libcodec2 libdc1394 libdrm libflite @@ -2944,6 +2946,8 @@ h264_videotoolbox_encoder_select="videotoolbox_encoder" hevc_videotoolbox_encoder_deps="pthreads" hevc_videotoolbox_encoder_select="videotoolbox_encoder" libcelt_decoder_deps="libcelt" +libcodec2_decoder_deps="libcodec2" +libcodec2_encoder_deps="libcodec2" libfdk_aac_decoder_deps="libfdk_aac" libfdk_aac_encoder_deps="libfdk_aac" libfdk_aac_encoder_select="audio_frame_queue" @@ -5891,6 +5895,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && { check_lib libcelt celt/celt.h celt_decoder_create_custom -lcelt0 || die "ERROR: libcelt must be installed and version must be >= 0.11.0."; } enabled libcaca && require_pkg_config libcaca caca caca.h caca_create_canvas +enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create -lcodec2 enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new enabled libdrm&& require_pkg_config libdrm libdrm xf86drm.h drmGetVersion enabled libfdk_aac&& { check_pkg_config libfdk_aac fdk-aac "fdk-aac/aacenc_lib.h" aacEncOpen || diff --git a/doc/general.texi b/doc/general.texi index 9ddcccf041..63722f272d 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -85,6 +85,24 @@ Go to @url{http://www.twolame.org/} and follow the instructions for installing the library. Then pass @code{--enable-libtwolame} to configure to enable it. +@section libcodec2 / codec2 general + +FFmpeg can make use of libcodec2 for codec2 encoding and decoding. +There is currently no native decoder, so libcodec2 must be used for decoding. + +Go to @url{http://freedv.org/}, download "Codec 2 source archive". +Build and install using CMake. Debian users can install the libcodec2-dev package instead. +Once libcodec2 is installed you can pass @code{--enable-libcodec2} to configure to enable it. + +The easiest way to use codec2 is with .c2 files, since they contain the mode information required for decoding. +To encode such a file, use a .c2 file extension and give the libcodec2 encoder the -mode option: +@code{ffmpeg -i input.wav -mode 700C output.c2}. +Playback is as simple as @code{ffplay output.c2}. +For a list of supported modes, run @code{ffmpeg -h encoder=libcodec2}. +Raw codec2 files are also supported. +To make sense of them the mode in use needs to be specified as a format option: +@code{ffmpeg -f codec2raw -mode 1300 -i input.raw output.wav}. + @section libvpx FFmpeg can make use of the libvpx library for VP8/VP9 encoding. @@ -1019,6 +1037,8 @@ following image formats are supported: @tab Used in Bink and Smacker files in many games. @item CELT @tab @tab E @tab decoding supported through external library libcelt +@item codec2 @tab E @tab E +@tab en/decoding supported through external library libcodec2 @item Delphine Software International CIN audio @tab @tab X @tab Codec used in Delphine Software International games. @item Digital Speech Standard - Standard Play m
[FFmpeg-cvslog] avformat/aviobuf: add ff_read_line_to_bprint and ff_read_line_to_bprint_overwrite functions
ffmpeg | branch: master | Marton Balint | Sat Feb 3 22:03:58 2018 +0100| [dcb2ef2211fd472b4fa235e9f1c4a48582e44049] | committer: Marton Balint avformat/aviobuf: add ff_read_line_to_bprint and ff_read_line_to_bprint_overwrite functions To be able to read lines longer than a static buffer size. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dcb2ef2211fd472b4fa235e9f1c4a48582e44049 --- libavformat/aviobuf.c | 46 ++ libavformat/internal.h | 26 ++ 2 files changed, 72 insertions(+) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index d63db3897f..95b3364478 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -823,6 +823,52 @@ int ff_get_line(AVIOContext *s, char *buf, int maxlen) return i; } +int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp) +{ +int len, end; +int64_t read = 0; +char tmp[1024]; +char c; + +do { +len = 0; +do { +c = avio_r8(s); +end = (c == '\r' || c == '\n' || c == '\0'); +if (!end) +tmp[len++] = c; +} while (!end && len < sizeof(tmp)); +av_bprint_append_data(bp, tmp, len); +read += len; +} while (!end); + +if (c == '\r' && avio_r8(s) != '\n' && !avio_feof(s)) +avio_skip(s, -1); + +if (!c && s->error) +return s->error; + +if (!c && !read && avio_feof(s)) +return AVERROR_EOF; + +return read; +} + +int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp) +{ +int64_t ret; + +av_bprint_clear(bp); +ret = ff_read_line_to_bprint(s, bp); +if (ret < 0) +return ret; + +if (!av_bprint_is_complete(bp)) +return AVERROR(ENOMEM); + +return bp->len; +} + int avio_get_str(AVIOContext *s, int maxlen, char *buf, int buflen) { int i; diff --git a/libavformat/internal.h b/libavformat/internal.h index 0d08576c29..2ac7e2e1a0 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -299,6 +299,32 @@ void ff_put_v(AVIOContext *bc, uint64_t val); */ int ff_get_line(AVIOContext *s, char *buf, int maxlen); +/** + * Read a whole line of text from AVIOContext to an AVBPrint buffer. Stop + * reading after reaching a \\r, a \\n, a \\r\\n, a \\0 or EOF. The line + * ending characters are NOT included in the buffer, but they are skipped on + * the input. + * + * @param s the read-only AVIOContext + * @param bp the AVBPrint buffer + * @return the length of the read line, not including the line endings, + * negative on error. + */ +int64_t ff_read_line_to_bprint(AVIOContext *s, AVBPrint *bp); + +/** + * Read a whole line of text from AVIOContext to an AVBPrint buffer overwriting + * its contents. Stop reading after reaching a \\r, a \\n, a \\r\\n, a \\0 or + * EOF. The line ending characters are NOT included in the buffer, but they + * are skipped on the input. + * + * @param s the read-only AVIOContext + * @param bp the AVBPrint buffer + * @return the length of the read line not including the line endings, + * negative on error, or if the buffer becomes truncated. + */ +int64_t ff_read_line_to_bprint_overwrite(AVIOContext *s, AVBPrint *bp); + #define SPACE_CHARS " \t\r\n" /** ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/concatdec: add support for very long line sizes
ffmpeg | branch: master | Marton Balint | Sat Feb 3 22:05:21 2018 +0100| [ffabff1baa0873a2aa9c0c09ec93b2f4191493b5] | committer: Marton Balint avformat/concatdec: add support for very long line sizes Fixes ticket #6761. Signed-off-by: Marton Balint > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ffabff1baa0873a2aa9c0c09ec93b2f4191493b5 --- libavformat/concatdec.c | 19 +++ 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index 178fac86cb..8fff9cc2cb 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -20,6 +20,7 @@ #include "libavutil/avassert.h" #include "libavutil/avstring.h" +#include "libavutil/bprint.h" #include "libavutil/intreadwrite.h" #include "libavutil/opt.h" #include "libavutil/parseutils.h" @@ -386,18 +387,18 @@ static int concat_read_close(AVFormatContext *avf) static int concat_read_header(AVFormatContext *avf) { ConcatContext *cat = avf->priv_data; -uint8_t buf[4096]; +AVBPrint bp; uint8_t *cursor, *keyword; -int ret, line = 0, i; +int line = 0, i; unsigned nb_files_alloc = 0; ConcatFile *file = NULL; -int64_t time = 0; +int64_t ret, time = 0; -while (1) { -if ((ret = ff_get_line(avf->pb, buf, sizeof(buf))) <= 0) -break; +av_bprint_init(&bp, 0, AV_BPRINT_SIZE_UNLIMITED); + +while ((ret = ff_read_line_to_bprint_overwrite(avf->pb, &bp)) >= 0) { line++; -cursor = buf; +cursor = bp.str; keyword = get_keyword(&cursor); if (!*keyword || *keyword == '#') continue; @@ -473,7 +474,7 @@ static int concat_read_header(AVFormatContext *avf) FAIL(AVERROR_INVALIDDATA); } } -if (ret < 0) +if (ret != AVERROR_EOF && ret < 0) goto fail; if (!cat->nb_files) FAIL(AVERROR_INVALIDDATA); @@ -499,9 +500,11 @@ static int concat_read_header(AVFormatContext *avf) MATCH_ONE_TO_ONE; if ((ret = open_file(avf, 0)) < 0) goto fail; +av_bprint_finalize(&bp, NULL); return 0; fail: +av_bprint_finalize(&bp, NULL); concat_read_close(avf); return ret; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] fate/exr : add test for long name flag
ffmpeg | branch: master | Martin Vignali | Fri Feb 9 09:16:04 2018 +0100| [c8552b78584a13cea3eaf7401027a5e29acdec05] | committer: Martin Vignali fate/exr : add test for long name flag ticket 6994 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c8552b78584a13cea3eaf7401027a5e29acdec05 --- tests/fate/image.mak | 3 +++ tests/ref/fate/exr-rgba-zip16-16x32-flag4 | 6 ++ 2 files changed, 9 insertions(+) diff --git a/tests/fate/image.mak b/tests/fate/image.mak index 7e7be3f119..121405aab9 100644 --- a/tests/fate/image.mak +++ b/tests/fate/image.mak @@ -284,6 +284,9 @@ fate-exr-y-scanline-zip-half-12x8: CMD = framecrc -i $(TARGET_SAMPLES)/exr/y_sca FATE_EXR += fate-exr-rgb-scanline-half-piz-dw-t08 fate-exr-rgb-scanline-half-piz-dw-t08: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgb_scanline_half_piz_dw_t08.exr -pix_fmt rgb48le +FATE_EXR += fate-exr-rgba-zip16-16x32-flag4 +fate-exr-rgba-zip16-16x32-flag4: CMD = framecrc -i $(TARGET_SAMPLES)/exr/rgba_zip16_16x32_flag4.exr -pix_fmt rgba64le + FATE_EXR-$(call DEMDEC, IMAGE2, EXR) += $(FATE_EXR) FATE_IMAGE += $(FATE_EXR-yes) diff --git a/tests/ref/fate/exr-rgba-zip16-16x32-flag4 b/tests/ref/fate/exr-rgba-zip16-16x32-flag4 new file mode 100644 index 00..e34aa711ea --- /dev/null +++ b/tests/ref/fate/exr-rgba-zip16-16x32-flag4 @@ -0,0 +1,6 @@ +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 16x32 +#sar 0: 1/1 +0, 0, 0,1, 4096, 0xf90ab1e9 ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/exr : add support for long name flag and be more explicit about unsupported flag
ffmpeg | branch: master | Martin Vignali | Sat Feb 17 20:44:12 2018 +0100| [ea03f295ec79ee72d3c7a6af4e4abcda70b9a423] | committer: Martin Vignali avcodec/exr : add support for long name flag and be more explicit about unsupported flag based-on patch by Carl Eugen Hoyos Fix ticket 6994 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ea03f295ec79ee72d3c7a6af4e4abcda70b9a423 --- libavcodec/exr.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 47f59bd638..444af17778 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -1350,12 +1350,14 @@ static int decode_header(EXRContext *s, AVFrame *frame) flags = bytestream2_get_le24(&s->gb); -if (flags == 0x00) -s->is_tile = 0; -else if (flags & 0x02) +if (flags & 0x02) s->is_tile = 1; -else{ -avpriv_report_missing_feature(s->avctx, "flags %d", flags); +if (flags & 0x08) { +avpriv_report_missing_feature(s->avctx, "deep data"); +return AVERROR_PATCHWELCOME; +} +if (flags & 0x10) { +avpriv_report_missing_feature(s->avctx, "multipart"); return AVERROR_PATCHWELCOME; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avfilter/x86/vf_blend : reorganize init in order to add 16 bit version
ffmpeg | branch: master | Martin Vignali | Sat Feb 17 20:49:12 2018 +0100| [7590d58b61462ef1f802fc75a092662758d4039a] | committer: Martin Vignali avfilter/x86/vf_blend : reorganize init in order to add 16 bit version > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7590d58b61462ef1f802fc75a092662758d4039a --- libavfilter/x86/vf_blend_init.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavfilter/x86/vf_blend_init.c b/libavfilter/x86/vf_blend_init.c index 6e782e4edb..b88ea7a7d2 100644 --- a/libavfilter/x86/vf_blend_init.c +++ b/libavfilter/x86/vf_blend_init.c @@ -73,7 +73,8 @@ av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit) { int cpu_flags = av_get_cpu_flags(); -if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1 && !is_16bit) { +if (!is_16bit) { +if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1) { switch (param->mode) { case BLEND_ADDITION: param->blend = ff_blend_addition_sse2; break; case BLEND_GRAINMERGE: param->blend = ff_blend_grainmerge_sse2; break; @@ -95,7 +96,7 @@ av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit) case BLEND_NEGATION: param->blend = ff_blend_negation_sse2; break; } } -if (EXTERNAL_SSSE3(cpu_flags) && param->opacity == 1 && !is_16bit) { +if (EXTERNAL_SSSE3(cpu_flags) && param->opacity == 1) { switch (param->mode) { case BLEND_DIFFERENCE: param->blend = ff_blend_difference_ssse3; break; case BLEND_EXTREMITY: param->blend = ff_blend_extremity_ssse3; break; @@ -103,7 +104,7 @@ av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit) } } -if (EXTERNAL_AVX2_FAST(cpu_flags) && param->opacity == 1 && !is_16bit) { +if (EXTERNAL_AVX2_FAST(cpu_flags) && param->opacity == 1) { switch (param->mode) { case BLEND_ADDITION: param->blend = ff_blend_addition_avx2; break; case BLEND_GRAINMERGE: param->blend = ff_blend_grainmerge_avx2; break; @@ -124,4 +125,5 @@ av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit) case BLEND_NEGATION: param->blend = ff_blend_negation_avx2; break; } } +} } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] checkasm/vf_blend : add depth param in order to add test for 16 bit version
ffmpeg | branch: master | Martin Vignali | Sat Feb 17 20:48:42 2018 +0100| [e3fc36a84c4335fcb347ed82911f98339279ec39] | committer: Martin Vignali checkasm/vf_blend : add depth param in order to add test for 16 bit version > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3fc36a84c4335fcb347ed82911f98339279ec39 --- tests/checkasm/vf_blend.c | 57 --- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/tests/checkasm/vf_blend.c b/tests/checkasm/vf_blend.c index be65730452..9933f0426e 100644 --- a/tests/checkasm/vf_blend.c +++ b/tests/checkasm/vf_blend.c @@ -60,28 +60,29 @@ } \ } while (0) -#define check_blend_func() \ +#define check_blend_func(depth) \ do { \ -int i; \ +int i, w; \ declare_func(void, const uint8_t *top, ptrdiff_t top_linesize, \ const uint8_t *bottom, ptrdiff_t bottom_linesize, \ uint8_t *dst, ptrdiff_t dst_linesize, \ ptrdiff_t width, ptrdiff_t height, \ struct FilterParams *param, double *values); \ +w = WIDTH / depth; \ \ for (i = 0; i < BUF_UNITS - 1; i++) { \ int src_offset = i * SIZE_PER_UNIT + i; /* Test various alignments */ \ int dst_offset = i * SIZE_PER_UNIT; /* dst must be aligned */ \ randomize_buffers(); \ -call_ref(top1 + src_offset, WIDTH, bot1 + src_offset, WIDTH, \ - dst1 + dst_offset, WIDTH, WIDTH, HEIGHT, ¶m, NULL); \ -call_new(top2 + src_offset, WIDTH, bot2 + src_offset, WIDTH, \ - dst2 + dst_offset, WIDTH, WIDTH, HEIGHT, ¶m, NULL); \ +call_ref(top1 + src_offset, w, bot1 + src_offset, w, \ + dst1 + dst_offset, w, w, HEIGHT, ¶m, NULL); \ +call_new(top2 + src_offset, w, bot2 + src_offset, w, \ + dst2 + dst_offset, w, w, HEIGHT, ¶m, NULL); \ if (memcmp(top1, top2, BUF_SIZE) || memcmp(bot1, bot2, BUF_SIZE) || memcmp(dst1, dst2, BUF_SIZE)) \ fail(); \ } \ -bench_new(top2, WIDTH / 4, bot2, WIDTH / 4, dst2, WIDTH / 4, \ - WIDTH / 4, HEIGHT / 4, ¶m, NULL); \ +bench_new(top2, w / 4, bot2, w / 4, dst2, w / 4, \ + w / 4, HEIGHT / 4, ¶m, NULL); \ } while (0) void checkasm_check_blend(void) @@ -96,29 +97,29 @@ void checkasm_check_blend(void) .opacity = 1.0, }; -#define check_and_report(name, val) \ +#define check_and_report(name, val, depth)\ param.mode = val; \ -ff_blend_init(¶m, 0); \ +ff_blend_init(¶m, depth - 1); \ if (check_func(param.blend, #name)) \ -check_blend_func(); +check_blend_func(depth); -check_and_report(addition, BLEND_ADDITION) -check_and_report(grainmerge, BLEND_GRAINMERGE) -check_and_report(and, BLEND_AND) -check_and_report(average, BLEND_AVERAGE) -check_and_report(darken, BLEND_DARKEN) -check_and_report(grainextract, BLEND_GRAINEXTRACT) -check_and_report(hardmix, BLEND_HARDMIX) -check_and_report(lighten, BLEND_LIGHTEN) -check_and_report(multiply, BLEND_MULTIPLY) -check_and_report(or, BLEND_OR) -check_and_report(phoenix, BLEND_PHOENIX) -check_and_report(screen, BLEND_SCREEN) -check_and_report(subtract, BLEND_SUBTRACT) -check_and_report(xor, BLEND_XOR) -check_and_report(difference, BLEND_DIFFERENCE) -check_and_report(extremity, BLEND_EXTREMITY) -check_and_report(negation, BLEND_NEGATION) +check_and_report(addition, BLEND_A
[FFmpeg-cvslog] avfilter/x86/vf_blend : indent
ffmpeg | branch: master | Martin Vignali | Sat Feb 17 20:49:32 2018 +0100| [6c6c9d14a841543166189dec79e33471c44dc863] | committer: Martin Vignali avfilter/x86/vf_blend : indent > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6c6c9d14a841543166189dec79e33471c44dc863 --- libavfilter/x86/vf_blend_init.c | 94 - 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/libavfilter/x86/vf_blend_init.c b/libavfilter/x86/vf_blend_init.c index b88ea7a7d2..c9c7a52ef9 100644 --- a/libavfilter/x86/vf_blend_init.c +++ b/libavfilter/x86/vf_blend_init.c @@ -74,56 +74,56 @@ av_cold void ff_blend_init_x86(FilterParams *param, int is_16bit) int cpu_flags = av_get_cpu_flags(); if (!is_16bit) { -if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1) { -switch (param->mode) { -case BLEND_ADDITION: param->blend = ff_blend_addition_sse2; break; -case BLEND_GRAINMERGE: param->blend = ff_blend_grainmerge_sse2; break; -case BLEND_AND: param->blend = ff_blend_and_sse2; break; -case BLEND_AVERAGE: param->blend = ff_blend_average_sse2; break; -case BLEND_DARKEN: param->blend = ff_blend_darken_sse2; break; -case BLEND_GRAINEXTRACT: param->blend = ff_blend_grainextract_sse2; break; -case BLEND_DIVIDE: param->blend = ff_blend_divide_sse2; break; -case BLEND_HARDMIX: param->blend = ff_blend_hardmix_sse2; break; -case BLEND_LIGHTEN: param->blend = ff_blend_lighten_sse2; break; -case BLEND_MULTIPLY: param->blend = ff_blend_multiply_sse2; break; -case BLEND_OR: param->blend = ff_blend_or_sse2; break; -case BLEND_PHOENIX: param->blend = ff_blend_phoenix_sse2; break; -case BLEND_SCREEN: param->blend = ff_blend_screen_sse2; break; -case BLEND_SUBTRACT: param->blend = ff_blend_subtract_sse2; break; -case BLEND_XOR: param->blend = ff_blend_xor_sse2; break; -case BLEND_DIFFERENCE: param->blend = ff_blend_difference_sse2; break; -case BLEND_EXTREMITY: param->blend = ff_blend_extremity_sse2; break; -case BLEND_NEGATION: param->blend = ff_blend_negation_sse2; break; +if (EXTERNAL_SSE2(cpu_flags) && param->opacity == 1) { +switch (param->mode) { +case BLEND_ADDITION: param->blend = ff_blend_addition_sse2; break; +case BLEND_GRAINMERGE: param->blend = ff_blend_grainmerge_sse2; break; +case BLEND_AND: param->blend = ff_blend_and_sse2; break; +case BLEND_AVERAGE: param->blend = ff_blend_average_sse2; break; +case BLEND_DARKEN: param->blend = ff_blend_darken_sse2; break; +case BLEND_GRAINEXTRACT: param->blend = ff_blend_grainextract_sse2; break; +case BLEND_DIVIDE: param->blend = ff_blend_divide_sse2; break; +case BLEND_HARDMIX: param->blend = ff_blend_hardmix_sse2; break; +case BLEND_LIGHTEN: param->blend = ff_blend_lighten_sse2; break; +case BLEND_MULTIPLY: param->blend = ff_blend_multiply_sse2; break; +case BLEND_OR: param->blend = ff_blend_or_sse2; break; +case BLEND_PHOENIX: param->blend = ff_blend_phoenix_sse2; break; +case BLEND_SCREEN: param->blend = ff_blend_screen_sse2; break; +case BLEND_SUBTRACT: param->blend = ff_blend_subtract_sse2; break; +case BLEND_XOR: param->blend = ff_blend_xor_sse2; break; +case BLEND_DIFFERENCE: param->blend = ff_blend_difference_sse2; break; +case BLEND_EXTREMITY:param->blend = ff_blend_extremity_sse2; break; +case BLEND_NEGATION: param->blend = ff_blend_negation_sse2; break; +} } -} -if (EXTERNAL_SSSE3(cpu_flags) && param->opacity == 1) { -switch (param->mode) { -case BLEND_DIFFERENCE: param->blend = ff_blend_difference_ssse3; break; -case BLEND_EXTREMITY: param->blend = ff_blend_extremity_ssse3; break; -case BLEND_NEGATION: param->blend = ff_blend_negation_ssse3; break; +if (EXTERNAL_SSSE3(cpu_flags) && param->opacity == 1) { +switch (param->mode) { +case BLEND_DIFFERENCE: param->blend = ff_blend_difference_ssse3; break; +case BLEND_EXTREMITY: param->blend = ff_blend_extremity_ssse3; break; +case BLEND_NEGATION: param->blend = ff_blend_negation_ssse3; break; +} } -} -if (EXTERNAL_AVX2_FAST(cpu_flags) && param->opacity == 1) { -switch (param->mode) { -case BLEND_ADDITION: param->blend = ff_blend_addition_avx2; break; -case BLEND_GRAINMERGE: param->blend = ff_blend_grainmerge_avx2; break; -case BLEND
[FFmpeg-cvslog] avfilter/x86/vf_blend : add 16 bit version for BLEND_SIMPLE, phoenix, difference for SSE and AVX2 (x86_64)
ffmpeg | branch: master | Martin Vignali | Sat Feb 17 21:01:34 2018 +0100| [53a03b5c8c7d355bd353727115efc9977aa76f28] | committer: Martin Vignali avfilter/x86/vf_blend : add 16 bit version for BLEND_SIMPLE, phoenix, difference for SSE and AVX2 (x86_64) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=53a03b5c8c7d355bd353727115efc9977aa76f28 --- libavfilter/x86/vf_blend.asm| 75 ++--- libavfilter/x86/vf_blend_init.c | 54 + 2 files changed, 116 insertions(+), 13 deletions(-) diff --git a/libavfilter/x86/vf_blend.asm b/libavfilter/x86/vf_blend.asm index 680e266348..5d9a909192 100644 --- a/libavfilter/x86/vf_blend.asm +++ b/libavfilter/x86/vf_blend.asm @@ -36,10 +36,13 @@ pb_255: times 16 db 255 SECTION .text -%macro BLEND_INIT 2 +%macro BLEND_INIT 2-3 %if ARCH_X86_64 cglobal blend_%1, 6, 9, %2, top, top_linesize, bottom, bottom_linesize, dst, dst_linesize, width, end, x movwidthd, dword widthm +%if %0 == 3; is 16 bit +addwidthq, widthq ; doesn't compile on x86_32 +%endif %else cglobal blend_%1, 5, 7, %2, top, top_linesize, bottom, bottom_linesize, dst, end, x %define dst_linesizeq r5mp @@ -61,8 +64,8 @@ cglobal blend_%1, 5, 7, %2, top, top_linesize, bottom, bottom_linesize, dst, end REP_RET %endmacro -%macro BLEND_SIMPLE 2 -BLEND_INIT %1, 2 +%macro BLEND_SIMPLE 2-3 +BLEND_INIT %1, 2, %3 .nextrow: movxq, widthq @@ -270,8 +273,9 @@ BLEND_INIT divide, 4 BLEND_END %endmacro -%macro PHOENIX 0 -BLEND_INIT phoenix, 4 +%macro PHOENIX 2-3 +; %1 name, %2 b or w, %3 (opt) 1 if 16 bit +BLEND_INIT %1, 4, %3 VBROADCASTI128 m3, [pb_255] .nextrow: movxq, widthq @@ -280,19 +284,19 @@ BLEND_INIT phoenix, 4 movum0, [topq + xq] movum1, [bottomq + xq] movam2, m0 -pminub m0, m1 -pmaxub m1, m2 +pminu%2 m0, m1 +pmaxu%2 m1, m2 movam2, m3 -psubusb m2, m1 -paddusb m2, m0 +psubus%2m2, m1 +paddus%2m2, m0 mova [dstq + xq], m2 add xq, mmsize jl .loop BLEND_END %endmacro -%macro BLEND_ABS 0 -BLEND_INIT difference, 5 +%macro DIFFERENCE 1-2 +BLEND_INIT %1, 5, %2 pxor m2, m2 .nextrow: movxq, widthq @@ -300,6 +304,17 @@ BLEND_INIT difference, 5 .loop: movum0, [topq + xq] movum1, [bottomq + xq] +%if %0 == 2 ; 16 bit +punpckhwd m3, m0, m2 +punpcklwd m0, m2 +punpckhwd m4, m1, m2 +punpcklwd m1, m2 +psubd m0, m1 +psubd m3, m4 +pabsd m0, m0 +pabsd m3, m3 +packusdwm0, m3 +%else punpckhbw m3, m0, m2 punpcklbw m0, m2 punpckhbw m4, m1, m2 @@ -308,11 +323,14 @@ BLEND_INIT difference, 5 psubw m3, m4 ABS2m0, m3, m1, m4 packuswbm0, m3 +%endif mova [dstq + xq], m0 add xq, mmsize jl .loop BLEND_END +%endmacro +%macro BLEND_ABS 0 BLEND_INIT extremity, 8 pxor m2, m2 VBROADCASTI128 m4, [pw_255] @@ -378,14 +396,32 @@ BLEND_SCREEN AVERAGE GRAINMERGE HARDMIX -PHOENIX +PHOENIX phoenix, b +DIFFERENCE difference DIVIDE BLEND_ABS +%if ARCH_X86_64 +BLEND_SIMPLE addition_16, addusw, 1 +BLEND_SIMPLE and_16, and,1 +BLEND_SIMPLE or_16, or, 1 +BLEND_SIMPLE subtract_16, subusw, 1 +BLEND_SIMPLE xor_16, xor,1 +%endif + INIT_XMM ssse3 +DIFFERENCE difference BLEND_ABS +INIT_XMM sse4 +%if ARCH_X86_64 +BLEND_SIMPLE darken_16, minuw, 1 +BLEND_SIMPLE lighten_16, maxuw, 1 +PHOENIX phoenix_16, w, 1 +DIFFERENCE difference_16, 1 +%endif + %if HAVE_AVX2_EXTERNAL INIT_YMM avx2 BLEND_SIMPLE xor, xor @@ -401,7 +437,20 @@ BLEND_SCREEN AVERAGE GRAINMERGE HARDMIX -PHOENIX +PHOENIX phoenix, b +DIFFERENCE difference BLEND_ABS + +%if ARCH_X86_64 +BLEND_SIMPLE addition_16, addusw, 1 +BLEND_SIMPLE and_16, and,1 +BLEND_SIMPLE darken_16, minuw, 1 +BLEND_SIMPLE lighten_16, maxuw, 1 +BLEND_SIMPLE or_16, or, 1 +BLEND_SIMPLE subtract_16, subusw, 1 +BLEND_SIMPLE xor_16, xor,1 +PHOENIX phoenix_16, w, 1 +DIFFERENCE difference_16, 1 +%endif %endif diff --git a/libavfilter/x86/vf_blend_init.c b/libavfilter/x86/vf_blend_init.c index c9c7a52ef9..0962f6d7fd 100644 --- a/libavfilter/x86/vf_blend_init.c +++ b/libavfilter/x86/vf_blend_init.c @@ -69,6 +69,27 @@ BLEND_FUNC(negation, sse2) BLEND_FUNC(negation, ssse3) BLEND_FUNC(negation, avx2) +#if ARCH_X86_64 +BLEND_FUNC(addition_16, sse2) +BLEND_FUNC(addition_16, avx2) +BLEND_FUNC(and_16, sse2) +BLEND_FUNC(and_16, avx2) +BLEND_FUNC(darken
[FFmpeg-cvslog] checkasm/vf_blend : add test for blend_simple_16, phoenix_16 and difference_16
ffmpeg | branch: master | Martin Vignali | Sat Feb 17 21:02:12 2018 +0100| [c0919c49855b4b7f6a476d2daf2b160d9c50407b] | committer: Martin Vignali checkasm/vf_blend : add test for blend_simple_16, phoenix_16 and difference_16 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c0919c49855b4b7f6a476d2daf2b160d9c50407b --- tests/checkasm/vf_blend.c | 12 1 file changed, 12 insertions(+) diff --git a/tests/checkasm/vf_blend.c b/tests/checkasm/vf_blend.c index 9933f0426e..79bdf9f163 100644 --- a/tests/checkasm/vf_blend.c +++ b/tests/checkasm/vf_blend.c @@ -123,6 +123,18 @@ void checkasm_check_blend(void) report("8bit"); +check_and_report(addition_16, BLEND_ADDITION, 2) +check_and_report(and_16, BLEND_AND, 2) +check_and_report(darken_16, BLEND_DARKEN, 2) +check_and_report(difference_16, BLEND_DIFFERENCE, 2) +check_and_report(lighten_16, BLEND_LIGHTEN, 2) +check_and_report(or_16, BLEND_OR, 2) +check_and_report(phoenix_16, BLEND_PHOENIX, 2) +check_and_report(subtract_16, BLEND_SUBTRACT, 2) +check_and_report(xor_16, BLEND_SUBTRACT, 2) + +report("16bit"); + av_freep(&top1); av_freep(&top2); av_freep(&bot1); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog