Re: [FFmpeg-devel] [PATCH] avfilter/vidstab: set bytesPerPixel only for packed formats.
On 12/23/2017 4:39 PM, Gyan Doshi wrote: Patch for ticket #6736. This patch alters the test, not any assignment, so corrected verbiage. Regards, Gyan From dbc21f9fe4061ac30339b8086226ea2c47f8bd29 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Sat, 23 Dec 2017 16:14:25 +0530 Subject: [PATCH] avfilter/vidstab: check bytesPerPixel only for packed formats. libvidstab introduced this variable only for packed formats but in vf_vidstab*.c, it's checked for all inputs. So the filter errors out for YUV422/444P streams. Fixes #6736. --- libavfilter/vf_vidstabdetect.c| 3 ++- libavfilter/vf_vidstabtransform.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_vidstabdetect.c b/libavfilter/vf_vidstabdetect.c index 63a178a0c2..fd7ff3be24 100644 --- a/libavfilter/vf_vidstabdetect.c +++ b/libavfilter/vf_vidstabdetect.c @@ -107,10 +107,11 @@ static int config_input(AVFilterLink *inlink) VSMotionDetect* md = &(s->md); VSFrameInfo fi; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); +int is_planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR; vsFrameInfoInit(&fi, inlink->w, inlink->h, ff_av2vs_pixfmt(ctx, inlink->format)); -if (fi.bytesPerPixel != av_get_bits_per_pixel(desc)/8) { +if (!is_planar && fi.bytesPerPixel != av_get_bits_per_pixel(desc)/8) { av_log(ctx, AV_LOG_ERROR, "pixel-format error: wrong bits/per/pixel, please report a BUG"); return AVERROR(EINVAL); } diff --git a/libavfilter/vf_vidstabtransform.c b/libavfilter/vf_vidstabtransform.c index 11a0e3d512..d1ec1391cb 100644 --- a/libavfilter/vf_vidstabtransform.c +++ b/libavfilter/vf_vidstabtransform.c @@ -146,6 +146,7 @@ static int config_input(AVFilterLink *inlink) FILE *f; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); +int is_planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR; VSTransformData *td = &(tc->td); @@ -161,7 +162,7 @@ static int config_input(AVFilterLink *inlink) return AVERROR(EINVAL); } -if (fi_src.bytesPerPixel != av_get_bits_per_pixel(desc)/8 || +if ((!is_planar && fi_src.bytesPerPixel != av_get_bits_per_pixel(desc)/8) || fi_src.log2ChromaW != desc->log2_chroma_w || fi_src.log2ChromaH != desc->log2_chroma_h) { av_log(ctx, AV_LOG_ERROR, "pixel-format error: bpp %i<>%i ", -- 2.11.1.windows.1___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 3/5] atrac3plus_parser: use libavcodec's oma
From: Misty De Meo --- libavcodec/Makefile| 2 +- libavcodec/atrac3plus_parser.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index e0e3f1ebac..0e1c6d53ea 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -977,7 +977,7 @@ OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \ mpeg4audio.o OBJS-$(CONFIG_AC3_PARSER) += ac3tab.o aac_ac3_parser.o OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o -OBJS-$(CONFIG_ATRAC3P_PARSER) += atrac3plus_parser.o +OBJS-$(CONFIG_ATRAC3P_PARSER) += atrac3plus_parser.o oma.o OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o diff --git a/libavcodec/atrac3plus_parser.c b/libavcodec/atrac3plus_parser.c index 01fcad4c45..11b236b0bf 100644 --- a/libavcodec/atrac3plus_parser.c +++ b/libavcodec/atrac3plus_parser.c @@ -20,7 +20,7 @@ #include "parser.h" #include "get_bits.h" -#include "libavformat/oma.h" +#include "oma.h" typedef struct Atrac3PlusParseContext { ParseContext pc; -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 5/5] mpeg: fix use of deprecated struct
From: Misty De Meo --- libavformat/mpeg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index a366ece0ed..210424faf3 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -547,8 +547,8 @@ redo: len--; for (i = 0; i < s->nb_streams; i++) { st = s->streams[i]; -if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && -st->codec->codec_id == AV_CODEC_ID_ATRAC3P && +if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && +st->codecpar->codec_id == AV_CODEC_ID_ATRAC3P && st->id - 0x1BD0 == (startcode & 0xF)) goto found; } -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 4/5] Fix detecting ATRAC3 audio from MPS files
From: Misty De Meo MPS files are MPEG files used on PSP Video discs. They lack the PSMF header used by .pms files, and so the special casing in the original patch fails to support their audio. This patch fixes this by unconditionally reading a new byte for the startcode for PRIVATE_STREAM_1 sections, and doing the comparison on that to find ATRAC-3 streams. In my testing, it works fine for both MPS and PSMF files. --- Changelog | 1 + libavformat/mpeg.c | 38 ++ libavformat/mpeg.h | 1 + 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Changelog b/Changelog index ee48876128..67f28ea839 100644 --- a/Changelog +++ b/Changelog @@ -27,6 +27,7 @@ version : - video setrange filter - nsp demuxer - support LibreSSL (via libtls) +- ATRAC-3 support for Sony PSP MPEG files version 3.4: diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 895c6fb231..a366ece0ed 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -128,7 +128,6 @@ typedef struct MpegDemuxContext { int sofdec; int dvd; int imkh_cctv; -int sony_psmf; // true if Play Station Movie file signature is present #if CONFIG_VOBSUB_DEMUXER AVFormatContext *sub_ctx; FFDemuxSubtitlesQueue q[32]; @@ -148,8 +147,6 @@ static int mpegps_read_header(AVFormatContext *s) avio_get_str(s->pb, 6, buffer, sizeof(buffer)); if (!memcmp("IMKH", buffer, 4)) { m->imkh_cctv = 1; -} else if (!memcmp("PSMF00", buffer, 6)) { -m->sony_psmf = 1; } else if (!memcmp("Sofdec", buffer, 6)) { m->sofdec = 1; } else @@ -444,7 +441,7 @@ redo: goto redo; } -if (startcode == PRIVATE_STREAM_1 && !m->sony_psmf) { +if (startcode == PRIVATE_STREAM_1) { startcode = avio_r8(s->pb); len--; } @@ -544,28 +541,21 @@ redo: else request_probe= 1; type = AVMEDIA_TYPE_VIDEO; -} else if (startcode == PRIVATE_STREAM_1 && m->sony_psmf) { -uint8_t stream_id; - -if (len < 2) -goto skip; -stream_id = avio_r8(s->pb); +// Sony PSP video with ATRAC-3 audio +} else if (!(startcode & STREAM_TYPE_AUDIO_ATRAC3)) { avio_r8(s->pb); // skip padding -len -= 2; -if (!(stream_id & 0xF0)) { // seems like we got an ATRAC stream -/* check if an appropriate stream already exists */ -for (i = 0; i < s->nb_streams; i++) { -st = s->streams[i]; -if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && -st->codec->codec_id == AV_CODEC_ID_ATRAC3P && -st->id - 0x1BD0 == (stream_id & 0xF)) -goto found; -} - -startcode = 0x1BD0 + (stream_id & 0xF); -type = AVMEDIA_TYPE_AUDIO; -codec_id = AV_CODEC_ID_ATRAC3P; +len--; +for (i = 0; i < s->nb_streams; i++) { +st = s->streams[i]; +if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && +st->codec->codec_id == AV_CODEC_ID_ATRAC3P && +st->id - 0x1BD0 == (startcode & 0xF)) +goto found; } + +startcode = 0x1BD0 + (startcode & 0xF); +type = AVMEDIA_TYPE_AUDIO; +codec_id = AV_CODEC_ID_ATRAC3P; } else if (startcode == PRIVATE_STREAM_2) { type = AVMEDIA_TYPE_DATA; codec_id = AV_CODEC_ID_DVD_NAV; diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h index 617e36cba8..efbadec8ba 100644 --- a/libavformat/mpeg.h +++ b/libavformat/mpeg.h @@ -58,6 +58,7 @@ #define STREAM_TYPE_VIDEO_CAVS 0x42 #define STREAM_TYPE_AUDIO_AC3 0x81 +#define STREAM_TYPE_AUDIO_ATRAC30xF0 static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 }; -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/5] oma: move some constants into libavcodec
From: Misty De Meo Most of the constants in libavcodec/oma aren't specific to libavformat; moving them into libavcodec makes them available to libavcodec as well as keeping them compatible with libavformat. ff_oma_codec_tags uses a libavformat-specific type, so it has been left in libavformat. --- libavformat/oma.c => libavcodec/oma.h | 27 +-- libavcodec/version.h | 2 +- libavformat/Makefile | 4 ++-- libavformat/oma.h | 21 + libavformat/omadec.c | 1 + libavformat/omaenc.c | 1 + libavformat/version.h | 2 +- 7 files changed, 28 insertions(+), 30 deletions(-) rename libavformat/oma.c => libavcodec/oma.h (65%) diff --git a/libavformat/oma.c b/libavcodec/oma.h similarity index 65% rename from libavformat/oma.c rename to libavcodec/oma.h index f7ae3c9948..176f93ed22 100644 --- a/libavformat/oma.c +++ b/libavcodec/oma.h @@ -18,25 +18,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef AVCODEC_OMA_H +#define AVCODEC_OMA_H + +#include + #include "internal.h" -#include "oma.h" -#include "libavcodec/avcodec.h" #include "libavutil/channel_layout.h" -const uint16_t ff_oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 }; +#define EA3_HEADER_SIZE 96 +#define ID3v2_EA3_MAGIC "ea3" +#define OMA_ENC_HEADER_SIZE 16 -const AVCodecTag ff_oma_codec_tags[] = { -{ AV_CODEC_ID_ATRAC3, OMA_CODECID_ATRAC3}, -{ AV_CODEC_ID_ATRAC3P, OMA_CODECID_ATRAC3P }, -{ AV_CODEC_ID_MP3, OMA_CODECID_MP3 }, -{ AV_CODEC_ID_PCM_S16BE, OMA_CODECID_LPCM }, -{ AV_CODEC_ID_ATRAC3PAL, OMA_CODECID_ATRAC3PAL }, -{ AV_CODEC_ID_ATRAC3AL,OMA_CODECID_ATRAC3AL }, -{ 0 }, -}; +static const uint16_t ff_oma_srate_tab[8] = { 320, 441, 480, 882, 960, 0 }; /** map ATRAC-X channel id to internal channel layout */ -const uint64_t ff_oma_chid_to_native_layout[7] = { +static const uint64_t ff_oma_chid_to_native_layout[7] = { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_SURROUND, @@ -47,4 +44,6 @@ const uint64_t ff_oma_chid_to_native_layout[7] = { }; /** map ATRAC-X channel id to total number of channels */ -const int ff_oma_chid_to_num_channels[7] = {1, 2, 3, 4, 6, 7, 8}; +static const int ff_oma_chid_to_num_channels[7] = {1, 2, 3, 4, 6, 7, 8}; + +#endif /* AVCODEC_OMA_H */ diff --git a/libavcodec/version.h b/libavcodec/version.h index d55de89797..d48857578d 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MINOR 8 -#define LIBAVCODEC_VERSION_MICRO 100 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ diff --git a/libavformat/Makefile b/libavformat/Makefile index cb70eac920..ef0365e6e2 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -358,8 +358,8 @@ OBJS-$(CONFIG_OGG_MUXER) += oggenc.o \ vorbiscomment.o OBJS-$(CONFIG_OGV_MUXER) += oggenc.o \ vorbiscomment.o -OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o oma.o -OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o oma.o id3v2enc.o +OBJS-$(CONFIG_OMA_DEMUXER) += omadec.o pcm.o +OBJS-$(CONFIG_OMA_MUXER) += omaenc.o rawenc.o id3v2enc.o OBJS-$(CONFIG_OPUS_MUXER)+= oggenc.o \ vorbiscomment.o OBJS-$(CONFIG_PAF_DEMUXER) += paf.o diff --git a/libavformat/oma.h b/libavformat/oma.h index 36fd0125e4..ccd57d779e 100644 --- a/libavformat/oma.h +++ b/libavformat/oma.h @@ -21,14 +21,8 @@ #ifndef AVFORMAT_OMA_H #define AVFORMAT_OMA_H -#include - #include "internal.h" -#define EA3_HEADER_SIZE 96 -#define ID3v2_EA3_MAGIC "ea3" -#define OMA_ENC_HEADER_SIZE 16 - enum { OMA_CODECID_ATRAC3 = 0, OMA_CODECID_ATRAC3P = 1, @@ -39,11 +33,14 @@ enum { OMA_CODECID_ATRAC3AL = 34, }; -extern const uint16_t ff_oma_srate_tab[8]; - -extern const AVCodecTag ff_oma_codec_tags[]; - -extern const uint64_t ff_oma_chid_to_native_layout[7]; -extern const int ff_oma_chid_to_num_channels[7]; +static const AVCodecTag ff_oma_codec_tags[] = { +{ AV_CODEC_ID_ATRAC3, OMA_CODECID_ATRAC3}, +{ AV_CODEC_ID_ATRAC3P, OMA_CODECID_ATRAC3P }, +{ AV_CODEC_ID_MP3, OMA_CODECID_MP3 }, +{ AV_CODEC_ID_PCM_S16BE, OMA_CODECID_LPCM }, +{ AV_CODEC_ID_ATRAC3PAL, OMA_CODECID_ATRAC3PAL }, +{ AV_CODEC_ID_ATRAC3AL,OMA_CODECID_ATRAC3AL }, +{ 0 }, +}; #endif /* AVFORMAT_OMA_H */ diff --git a/libavformat/omadec.c b/libavformat/omadec.c index 423d52b3aa..ccefd6c1bc 100644 --- a/lib
[FFmpeg-devel] [PATCH 0/5] oma: move some constants into libavcodec
From: Misty De Meo > I believe such an internal change doesn't deserve a Changelog entry. Sure; I've updated the patch set to remove that change from the Changelog. Maxim Poliakovski (1): mpeg: add experimental support for PSMF audio. Misty De Meo (4): oma: move some constants into libavcodec atrac3plus_parser: use libavcodec's oma Fix detecting ATRAC3 audio from MPS files mpeg: fix use of deprecated struct Changelog | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c| 1 + libavcodec/atrac3plus_parser.c| 153 ++ libavformat/oma.c => libavcodec/oma.h | 27 +++--- libavcodec/version.h | 2 +- libavformat/Makefile | 4 +- libavformat/mpeg.c| 15 libavformat/mpeg.h| 1 + libavformat/oma.h | 21 ++--- libavformat/omadec.c | 1 + libavformat/omaenc.c | 1 + libavformat/version.h | 2 +- 13 files changed, 200 insertions(+), 30 deletions(-) create mode 100644 libavcodec/atrac3plus_parser.c rename libavformat/oma.c => libavcodec/oma.h (65%) -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/5] mpeg: add experimental support for PSMF audio.
From: Maxim Poliakovski --- libavcodec/Makefile| 1 + libavcodec/allcodecs.c | 1 + libavcodec/atrac3plus_parser.c | 153 + libavformat/mpeg.c | 27 +++- 4 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 libavcodec/atrac3plus_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ca72138c02..e0e3f1ebac 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -977,6 +977,7 @@ OBJS-$(CONFIG_AAC_PARSER) += aac_parser.o aac_ac3_parser.o \ mpeg4audio.o OBJS-$(CONFIG_AC3_PARSER) += ac3tab.o aac_ac3_parser.o OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o adx.o +OBJS-$(CONFIG_ATRAC3P_PARSER) += atrac3plus_parser.o OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o OBJS-$(CONFIG_CAVSVIDEO_PARSER)+= cavs_parser.o OBJS-$(CONFIG_COOK_PARSER) += cook_parser.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ed1e7ab06e..81d5d2814a 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -623,6 +623,7 @@ static void register_all(void) REGISTER_PARSER(AAC_LATM, aac_latm); REGISTER_PARSER(AC3,ac3); REGISTER_PARSER(ADX,adx); +REGISTER_PARSER(ATRAC3P,atrac3p); REGISTER_PARSER(BMP,bmp); REGISTER_PARSER(CAVSVIDEO, cavsvideo); REGISTER_PARSER(COOK, cook); diff --git a/libavcodec/atrac3plus_parser.c b/libavcodec/atrac3plus_parser.c new file mode 100644 index 00..01fcad4c45 --- /dev/null +++ b/libavcodec/atrac3plus_parser.c @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2014 Maxim Poliakovski + * + * 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 "parser.h" +#include "get_bits.h" +#include "libavformat/oma.h" + +typedef struct Atrac3PlusParseContext { +ParseContext pc; +uint8_t hdr[8]; +int hdr_bytes_needed, got_bytes; +int sample_rate, channel_id, frame_size; +} Atrac3PlusParseContext; + +static int parse_sound_frame_header(Atrac3PlusParseContext *c, +const uint8_t *buf) +{ +uint16_t atrac_config; + +if (AV_RB16(buf) != 0x0FD0) +return AVERROR_INVALIDDATA; + +atrac_config = AV_RB16(&buf[2]); +c->sample_rate = ff_oma_srate_tab[(atrac_config >> 13) & 7] * 100; +c->channel_id = (atrac_config >> 10) & 7; +c->frame_size = ((atrac_config & 0x3FF) * 8) + 8; + +if (!c->channel_id || !c->sample_rate || !c->frame_size) +return AVERROR_INVALIDDATA; + +return 0; +} + +static int ff_atrac3p_parse(AVCodecParserContext *s, + AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ +Atrac3PlusParseContext *ctx = s->priv_data; +const uint8_t *hdr_buf = buf; +size_t bytes_remain; +int frame_size, hdr_bytes = 8; +int next = 0; + +if (s->flags & PARSER_FLAG_COMPLETE_FRAMES || !buf_size) { +next = buf_size; +} else { +if (buf_size >= 2) { +bytes_remain = AV_RB16(buf); + +if (bytes_remain != 0xFD0) { +next += 2; +buf += 2; +buf_size -= 2; +hdr_buf = buf; + +if (bytes_remain && !ctx->pc.index && !ctx->hdr_bytes_needed) { +av_log(avctx, AV_LOG_ERROR, + "2nd frame portion found but the 1st one is missing!\n"); +return AVERROR_INVALIDDATA; +} + +if (ctx->hdr_bytes_needed) { +if (buf_size >= ctx->hdr_bytes_needed) { +memcpy(&ctx->hdr[8 - ctx->hdr_bytes_needed], + buf, ctx->hdr_bytes_needed); +hdr_bytes = ctx->hdr_bytes_needed; +ctx->hdr_bytes_needed = 0; +hdr_buf = ctx->hdr; +} +} else if (bytes_remain) { +if (buf_size < bytes_remain) { +av_log(avctx, AV_LOG_ERROR, +
Re: [FFmpeg-devel] [PATCH] lavc: add new API for iterating codecs and codec parsers
On Sun, 24 Dec 2017 02:06:40 +0100 Michael Niedermayer wrote: > If you and others agree we can also easily maintain support for user apps > to register codecs. The only thing needed is to make the array bigger and > add codecs which arent ours in there as long as there is space. > doing this would be very easy, a atomic integer pointing to the begin of > the free space which is atomically increased for each register is all that > is needed Not sure how often I repeated this (specifically for you), but: - users can't provide AVCodec, because it would require accessing internal API and private ABI unstable fields - if we provide the ability to add user codecs (which I'm not fundamentally against), then it should not modify global state. Having named user codecs in a process wide list would definitely lead to name clashes or other conflicts - also, we would have to provide stable/public API for implementing codecs in the first place (all AVCodec callback fields are private), and we're nowhere near the state of adding it - dropping avcodec_register() is definitely not the worst blocker for user codecs - it's very, very far from it, because once we have fixed the things above, we can just add a new public API for registering (which would have to have a different function signature to avoid global mutable lists). So I don't know why you complain. - these points are technical, not ideological Can you point out any user application which registers its own codecs (and this violates the API)? > > +AVCodec *av_codec_next(const AVCodec *c) > > +{ > > +pthread_once(&av_codec_next_init, av_codec_init_next); > > + > > +if (c) > > +return c->next; > > AVCodec->next should be removed as it makes the structs non constant That has to happen after a deprecation phase, unless you have an idea how to make av_codec_next() not O(n^2) without this. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault) - Add function 'resolve_content_path' to propagate the baseURL from upper level nodes. * if no baseURL is av
On Sat, Dec 23, 2017 at 09:47:05PM +, Colin NG wrote: > --- > libavformat/dashdec.c | 110 > -- > 1 file changed, 97 insertions(+), 13 deletions(-) seems my git doesnt like this patch: Applying: libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault) - Add function 'resolve_content_path' to propagate the baseURL from upper level nodes. * if no baseURL is available, the path of mpd file will be set as the baseURL. - Remove che... error: corrupt patch at line 20 error: could not build fake ancestor Patch failed at 0001 libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault) - Add function 'resolve_content_path' to propagate the baseURL from upper level nodes. * if no baseURL is available, the path of mpd file will be set as the baseURL. - Remove che... The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "You are 36 times more likely to die in a bathtub than at the hands of a terrorist. Also, you are 2.5 times more likely to become a president and 2 times more likely to become an astronaut, than to die in a terrorist attack." -- Thoughty2 signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc: add new API for iterating codecs and codec parsers
On Sat, Dec 23, 2017 at 01:27:53PM +, Josh de Kock wrote: > This is the first patch to add the new API for iterating items within the > libraries to lavc, this completes lavc's support for this API (BSFs were > already using it). > > I'm currently working on a similar patch for lavfi, lavf and lavd. Note that > I'm not entirely sure how to properly deprecate stuff so if that's incorrect > some advice would be appreciated. > > -- > Josh de Kock > configure | 14 > libavcodec/allcodecs.c | 1472 > - > libavcodec/avcodec.h | 25 > libavcodec/parser.c| 86 ++ > libavcodec/utils.c | 105 --- > 5 files changed, 962 insertions(+), 740 deletions(-) > 1d29484b82a8f3aaa4689f316f20819ebe3ff8a6 > 0001-lavc-add-new-API-for-iterating-codecs-and-codec-pars.patch > From 1d84641556eea563b82b17a6ffe54226e0e31c4e Mon Sep 17 00:00:00 2001 > From: Josh de Kock > Date: Fri, 22 Dec 2017 22:17:00 + > Subject: [PATCH] lavc: add new API for iterating codecs and codec parsers > > Also replace linked list with an array. > --- > configure | 14 +- > libavcodec/allcodecs.c | 1472 > > libavcodec/avcodec.h | 25 + > libavcodec/parser.c| 86 ++- > libavcodec/utils.c | 105 > 5 files changed, 962 insertions(+), 740 deletions(-) [...] > +static void av_codec_init_next(void) > +{ > +AVCodec *prev = NULL, *p; > +void *i = 0; > +while ((p = (AVCodec*)av_codec_iterate(&i))) { > +if (prev) > +prev->next = p; > +prev = p; > } > +prev->next = NULL; > +} > > -#define REGISTER_DECODER(X, x) \ > -{ \ > -extern AVCodec ff_##x##_decoder;\ > -if (CONFIG_##X##_DECODER) \ > -avcodec_register(&ff_##x##_decoder);\ > +av_cold void avcodec_register(AVCodec *codec) > +{ > +#if CONFIG_ME_CMP > +pthread_once(&ff_me_cmp_static_init, ff_me_cmp_init_static); > +#endif > + > +pthread_once(&av_codec_next_init, av_codec_init_next); > + > +if (codec->init_static_data) > +codec->init_static_data(codec); > +} > + This would not register the provided codec. You have to still register it in case its a AVCodec provided by the user (app). The commit message does not say that registering user provided codecs is removed. This is unacceptable. You cannot silently remove this. If you mean to lock libavcodec down so that registration of codecs is no longer possible, this has to be made clear in the commit message. I do in fact not agree to remove this as i belive its moving us away from the spirit of open source. But in case im in the minority at least what is done must be clearly stated in the commit message. Its untrue that this is just adding a new API Now changing the linked list to an array (which your patch does half of) is probably a good idea. If you and others agree we can also easily maintain support for user apps to register codecs. The only thing needed is to make the array bigger and add codecs which arent ours in there as long as there is space. doing this would be very easy, a atomic integer pointing to the begin of the free space which is atomically increased for each register is all that is needed > +AVCodec *av_codec_next(const AVCodec *c) > +{ > +pthread_once(&av_codec_next_init, av_codec_init_next); > + > +if (c) > +return c->next; AVCodec->next should be removed as it makes the structs non constant Thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Never trust a computer, one day, it may think you are the virus. -- Compn signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] mpeg4videodec: Fix unused variable warning
On Thu, Dec 21, 2017 at 07:54:56PM +, Mark Thompson wrote: > video_format is not used. > --- > Introduced by 4b2a186ef02c1fbe7f7cae30a2bdfff72bcc75f7: > > src/libavcodec/mpeg4videodec.c: In function ‘mpeg4_decode_visual_object’: > src/libavcodec/mpeg4videodec.c:1771:17: warning: unused variable > ‘video_format’ [-Wunused-variable] > int video_format = get_bits(gb, 3); > ^~~~ > > libavcodec/mpeg4videodec.c | 7 --- > 1 file changed, 4 insertions(+), 3 deletions(-) LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "Nothing to hide" only works if the folks in power share the values of you and everyone you know entirely and always will -- Tom Scott signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 4/5] lavc, lavf: move avformat static mutex from avcodec to avformat
It's completely absurd that libavcodec would care about libavformat locking, but it was there because the lock manager was in libavcodec. This is more stright forward. Changes ABI, but we don't require ABI compatibility currently. --- libavcodec/internal.h | 3 --- libavcodec/utils.c| 11 --- libavformat/avisynth.c| 10 +- libavformat/chromaprint.c | 9 + libavformat/internal.h| 4 libavformat/tls_gnutls.c | 8 libavformat/tls_openssl.c | 10 +- libavformat/utils.c | 13 + 8 files changed, 36 insertions(+), 32 deletions(-) diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 30cb9a0de1..bf58f36ad3 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -245,9 +245,6 @@ extern volatile int ff_avcodec_locked; int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec); int ff_unlock_avcodec(const AVCodec *codec); -int avpriv_lock_avformat(void); -int avpriv_unlock_avformat(void); - /** * Maximum size in bytes of extradata. * This value was chosen such that every bit of the buffer is diff --git a/libavcodec/utils.c b/libavcodec/utils.c index eec4437693..9c631c4fb0 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -70,7 +70,6 @@ const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; volatile int ff_avcodec_locked; static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0); static AVMutex codec_mutex = AV_MUTEX_INITIALIZER; -static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER; void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) { @@ -1904,16 +1903,6 @@ int ff_unlock_avcodec(const AVCodec *codec) return 0; } -int avpriv_lock_avformat(void) -{ -return ff_mutex_lock(&avformat_mutex) ? -1 : 0; -} - -int avpriv_unlock_avformat(void) -{ -return ff_mutex_unlock(&avformat_mutex) ? -1 : 0; -} - unsigned int avpriv_toupper4(unsigned int x) { return av_toupper(x & 0xFF) + diff --git a/libavformat/avisynth.c b/libavformat/avisynth.c index 56700288f7..250a489321 100644 --- a/libavformat/avisynth.c +++ b/libavformat/avisynth.c @@ -774,15 +774,15 @@ static av_cold int avisynth_read_header(AVFormatContext *s) int ret; // Calling library must implement a lock for thread-safe opens. -if (ret = avpriv_lock_avformat()) +if (ret = ff_lock_avformat()) return ret; if (ret = avisynth_open_file(s)) { -avpriv_unlock_avformat(); +ff_unlock_avformat(); return ret; } -avpriv_unlock_avformat(); +ff_unlock_avformat(); return 0; } @@ -818,11 +818,11 @@ static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt) static av_cold int avisynth_read_close(AVFormatContext *s) { -if (avpriv_lock_avformat()) +if (ff_lock_avformat()) return AVERROR_UNKNOWN; avisynth_context_destroy(s->priv_data); -avpriv_unlock_avformat(); +ff_unlock_avformat(); return 0; } diff --git a/libavformat/chromaprint.c b/libavformat/chromaprint.c index 4da02bef76..f39c09ddb9 100644 --- a/libavformat/chromaprint.c +++ b/libavformat/chromaprint.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "internal.h" #include "libavutil/opt.h" #include "libavcodec/internal.h" #include @@ -49,9 +50,9 @@ typedef struct ChromaprintMuxContext { static void cleanup(ChromaprintMuxContext *cpr) { if (cpr->ctx) { -avpriv_lock_avformat(); +ff_lock_avformat(); chromaprint_free(cpr->ctx); -avpriv_unlock_avformat(); +ff_unlock_avformat(); } } @@ -60,9 +61,9 @@ static int write_header(AVFormatContext *s) ChromaprintMuxContext *cpr = s->priv_data; AVStream *st; -avpriv_lock_avformat(); +ff_lock_avformat(); cpr->ctx = chromaprint_new(cpr->algorithm); -avpriv_unlock_avformat(); +ff_unlock_avformat(); if (!cpr->ctx) { av_log(s, AV_LOG_ERROR, "Failed to create chromaprint context.\n"); diff --git a/libavformat/internal.h b/libavformat/internal.h index de4b784634..745d3ebea6 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -681,4 +681,8 @@ int ff_bprint_to_codecpar_extradata(AVCodecParameters *par, struct AVBPrint *buf int ff_interleaved_peek(AVFormatContext *s, int stream, AVPacket *pkt, int add_offset); + +int ff_lock_avformat(void); +int ff_unlock_avformat(void); + #endif /* AVFORMAT_INTERNAL_H */ diff --git a/libavformat/tls_gnutls.c b/libavformat/tls_gnutls.c index 0cef9575ec..e3c43683be 100644 --- a/libavformat/tls_gnutls.c +++ b/libavformat/tls_gnutls.c @@ -55,20 +55,20 @@ typedef struct TLSContext { void ff_gnutls_init(void) { -avpriv_lock_avformat(); +ff_lock_avformat(); #if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #endif gnutls_global_in
[FFmpeg-devel] [PATCH v3 5/5] lavc: remove complex debug code around avcodec init locking
This is just a lot of complicated and confusing code that had no purpose anymore. Also, the functions return values were checked only sometimes. Locking shouldn't fail anyway, so remove the return values. Barely any other pthread lock calls check the return value (including more important code that is more likely to fail horribly if locking fails). It could be argued that it might be helpful in some debugging situations, or when the user built FFmpeg without thread support against all good advice. But there are dummy atomics too, so the atomic check won't help with ensuring correctness absolutely. You gain very little. Also, for debugging, you can just raise the ASSERT_LEVEL, and then libavutil/thread.h will redefine the locking functions to explicitly check the return values. --- libavcodec/internal.h | 4 libavcodec/utils.c| 55 +-- 2 files changed, 14 insertions(+), 45 deletions(-) diff --git a/libavcodec/internal.h b/libavcodec/internal.h index bf58f36ad3..1c901a7cbc 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -241,10 +241,6 @@ int ff_init_buffer_info(AVCodecContext *s, AVFrame *frame); void ff_color_frame(AVFrame *frame, const int color[4]); -extern volatile int ff_avcodec_locked; -int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec); -int ff_unlock_avcodec(const AVCodec *codec); - /** * Maximum size in bytes of extradata. * This value was chosen such that every bit of the buffer is diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 9c631c4fb0..dfbfe98d63 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -67,8 +67,6 @@ #include "libavutil/ffversion.h" const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; -volatile int ff_avcodec_locked; -static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0); static AVMutex codec_mutex = AV_MUTEX_INITIALIZER; void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) @@ -550,6 +548,19 @@ static int64_t get_bit_rate(AVCodecContext *ctx) return bit_rate; } + +static void ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec) +{ +if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) +ff_mutex_lock(&codec_mutex); +} + +static void ff_unlock_avcodec(const AVCodec *codec) +{ +if (!(codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE) && codec->init) +ff_mutex_unlock(&codec_mutex); +} + int attribute_align_arg ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options) { int ret = 0; @@ -589,9 +600,7 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code if (options) av_dict_copy(&tmp, *options, 0); -ret = ff_lock_avcodec(avctx, codec); -if (ret < 0) -return ret; +ff_lock_avcodec(avctx, codec); avctx->internal = av_mallocz(sizeof(AVCodecInternal)); if (!avctx->internal) { @@ -1867,42 +1876,6 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) } #endif -int ff_lock_avcodec(AVCodecContext *log_ctx, const AVCodec *codec) -{ -if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init) -return 0; - -if (ff_mutex_lock(&codec_mutex)) -return -1; - -if (atomic_fetch_add(&entangled_thread_counter, 1)) { -av_log(log_ctx, AV_LOG_ERROR, - "Insufficient thread locking. At least %d threads are " - "calling avcodec_open2() at the same time right now.\n", - atomic_load(&entangled_thread_counter)); -ff_avcodec_locked = 1; -ff_unlock_avcodec(codec); -return AVERROR(EINVAL); -} -av_assert0(!ff_avcodec_locked); -ff_avcodec_locked = 1; -return 0; -} - -int ff_unlock_avcodec(const AVCodec *codec) -{ -if (codec->caps_internal & FF_CODEC_CAP_INIT_THREADSAFE || !codec->init) -return 0; - -av_assert0(ff_avcodec_locked); -ff_avcodec_locked = 0; -atomic_fetch_add(&entangled_thread_counter, -1); -if (ff_mutex_unlock(&codec_mutex)) -return -1; - -return 0; -} - unsigned int avpriv_toupper4(unsigned int x) { return av_toupper(x & 0xFF) + -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 2/5] lavc: replace and deprecate the lock manager
Use static mutexes instead of requiring a lock manager. The behavior should be roughly the same before and after this change for API users which did not set the lock manager at all (except that a minor memory leak disappears). --- doc/APIchanges | 5 +++ libavcodec/avcodec.h | 8 +++- libavcodec/utils.c | 107 +-- libavcodec/version.h | 5 ++- libavutil/thread.h | 2 + 5 files changed, 28 insertions(+), 99 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index da444ffb7c..df1391d83a 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,11 @@ libavutil: 2017-10-21 API changes, most recent first: +2017-xx-xx - xxx - lavc 58.9.100 - avcodec.h + Deprecate av_lockmgr_register(). You need to build FFmpeg with threading + support enabled to get basic thread-safety (which is the default build + configuration). + 2017-xx-xx - xxx - lavc 58.8.100 - avcodec.h The MediaCodec decoders now support AVCodecContext.hw_device_ctx. diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ce089b7c4a..a9182a9e3d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -5930,10 +5930,11 @@ attribute_deprecated AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel); #endif - +#if FF_API_LOCKMGR /** * Lock operation used by lockmgr */ +attribute_deprecated enum AVLockOp { AV_LOCK_CREATE, ///< Create a mutex AV_LOCK_OBTAIN, ///< Lock the mutex @@ -5963,8 +5964,13 @@ enum AVLockOp { * mechanism (i.e. do not use a single static object to * implement your lock manager). If cb is set to NULL the * lockmgr will be unregistered. + * + * @deprecated This function does nothing, and always returns 0. Be sure to + * build with thread support to get basic thread safety. */ +attribute_deprecated int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); +#endif /** * Get the type of the given codec. diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 873f39f9bd..eec4437693 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -67,58 +67,10 @@ #include "libavutil/ffversion.h" const char av_codec_ffversion[] = "FFmpeg version " FFMPEG_VERSION; -#if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS -static int default_lockmgr_cb(void **arg, enum AVLockOp op) -{ -void * volatile * mutex = arg; -int err; - -switch (op) { -case AV_LOCK_CREATE: -return 0; -case AV_LOCK_OBTAIN: -if (!*mutex) { -pthread_mutex_t *tmp = av_malloc(sizeof(pthread_mutex_t)); -if (!tmp) -return AVERROR(ENOMEM); -if ((err = pthread_mutex_init(tmp, NULL))) { -av_free(tmp); -return AVERROR(err); -} -if (avpriv_atomic_ptr_cas(mutex, NULL, tmp)) { -pthread_mutex_destroy(tmp); -av_free(tmp); -} -} - -if ((err = pthread_mutex_lock(*mutex))) -return AVERROR(err); - -return 0; -case AV_LOCK_RELEASE: -if ((err = pthread_mutex_unlock(*mutex))) -return AVERROR(err); - -return 0; -case AV_LOCK_DESTROY: -if (*mutex) -pthread_mutex_destroy(*mutex); -av_free(*mutex); -avpriv_atomic_ptr_cas(mutex, *mutex, NULL); -return 0; -} -return 1; -} -static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = default_lockmgr_cb; -#else -static int (*lockmgr_cb)(void **mutex, enum AVLockOp op) = NULL; -#endif - - volatile int ff_avcodec_locked; static atomic_int entangled_thread_counter = ATOMIC_VAR_INIT(0); -static void *codec_mutex; -static void *avformat_mutex; +static AVMutex codec_mutex = AV_MUTEX_INITIALIZER; +static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER; void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) { @@ -1909,55 +1861,26 @@ void av_register_hwaccel(AVHWAccel *hwaccel) } #endif +#if FF_API_LOCKMGR int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) { -if (lockmgr_cb) { -// There is no good way to rollback a failure to destroy the -// mutex, so we ignore failures. -lockmgr_cb(&codec_mutex,AV_LOCK_DESTROY); -lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY); -lockmgr_cb = NULL; -codec_mutex= NULL; -avformat_mutex = NULL; -} - -if (cb) { -void *new_codec_mutex= NULL; -void *new_avformat_mutex = NULL; -int err; -if (err = cb(&new_codec_mutex, AV_LOCK_CREATE)) { -return err > 0 ? AVERROR_UNKNOWN : err; -} -if (err = cb(&new_avformat_mutex, AV_LOCK_CREATE)) { -// Ignore failures to destroy the newly created mutex. -cb(&new_codec_mutex, AV_LOCK_DESTROY); -return err > 0 ? AVERROR_UNKNOWN : err; -} -lockmgr_cb = cb; -
[FFmpeg-devel] [PATCH v3 1/5] w32pthreads: always use Vista+ API, drop XP support
This removes the XP compatibility code, and switches entirely to SWR locks, which are available starting at Windows Vista. This removes CRITICAL_SECTION use, which allows us to add PTHREAD_MUTEX_INITIALIZER, which will be useful later. Windows XP is hereby not a supported build target anymore. It was decided in a project vote that this is OK. (Technically, it could still be built for Windows XP using an external pthread lib as of this commit.) --- Will probably apply this in 1 or 2 days if nobody complains. --- Changelog | 2 + compat/w32pthreads.h | 266 ++--- configure | 13 ++- libavcodec/pthread_frame.c | 4 - libavcodec/pthread_slice.c | 4 - libavfilter/pthread.c | 4 - libavutil/slicethread.c| 4 - 7 files changed, 19 insertions(+), 278 deletions(-) diff --git a/Changelog b/Changelog index ee48876128..decd6c712a 100644 --- a/Changelog +++ b/Changelog @@ -27,6 +27,8 @@ version : - video setrange filter - nsp demuxer - support LibreSSL (via libtls) +- Dropped support for building for Windows XP. The minimum supported Windows + version is Windows Vista. version 3.4: diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h index eeead6051f..237cab5677 100644 --- a/compat/w32pthreads.h +++ b/compat/w32pthreads.h @@ -56,19 +56,12 @@ typedef struct pthread_t { void *ret; } pthread_t; -/* the conditional variable api for windows 6.0+ uses critical sections and - * not mutexes */ -typedef CRITICAL_SECTION pthread_mutex_t; - -/* This is the CONDITION_VARIABLE typedef for using Windows' native - * conditional variables on kernels 6.0+. */ -#if HAVE_CONDITION_VARIABLE_PTR +/* use light weight mutex/condition variable API for Windows Vista and later */ +typedef SRWLOCK pthread_mutex_t; typedef CONDITION_VARIABLE pthread_cond_t; -#else -typedef struct pthread_cond_t { -void *Ptr; -} pthread_cond_t; -#endif + +#define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT +#define PTHREAD_COND_INITIALIZER CONDITION_VARIABLE_INIT #if _WIN32_WINNT >= 0x0600 #define InitializeCriticalSection(x) InitializeCriticalSectionEx(x, 0, 0) @@ -114,26 +107,25 @@ static av_unused int pthread_join(pthread_t thread, void **value_ptr) static inline int pthread_mutex_init(pthread_mutex_t *m, void* attr) { -InitializeCriticalSection(m); +InitializeSRWLock(m); return 0; } static inline int pthread_mutex_destroy(pthread_mutex_t *m) { -DeleteCriticalSection(m); +/* Unlocked SWR locks use no resources */ return 0; } static inline int pthread_mutex_lock(pthread_mutex_t *m) { -EnterCriticalSection(m); +AcquireSRWLockExclusive(m); return 0; } static inline int pthread_mutex_unlock(pthread_mutex_t *m) { -LeaveCriticalSection(m); +ReleaseSRWLockExclusive(m); return 0; } -#if _WIN32_WINNT >= 0x0600 typedef INIT_ONCE pthread_once_t; #define PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT @@ -167,7 +159,7 @@ static inline int pthread_cond_broadcast(pthread_cond_t *cond) static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { -SleepConditionVariableCS(cond, mutex, INFINITE); +SleepConditionVariableSRW(cond, mutex, INFINITE, 0); return 0; } @@ -177,242 +169,4 @@ static inline int pthread_cond_signal(pthread_cond_t *cond) return 0; } -#else // _WIN32_WINNT < 0x0600 - -/* atomic init state of dynamically loaded functions */ -static LONG w32thread_init_state = 0; -static av_unused void w32thread_init(void); - -/* for pre-Windows 6.0 platforms, define INIT_ONCE struct, - * compatible to the one used in the native API */ - -typedef union pthread_once_t { -void * Ptr;///< For the Windows 6.0+ native functions -LONG state;///< For the pre-Windows 6.0 compat code -} pthread_once_t; - -#define PTHREAD_ONCE_INIT {0} - -/* function pointers to init once API on windows 6.0+ kernels */ -static BOOL (WINAPI *initonce_begin)(pthread_once_t *lpInitOnce, DWORD dwFlags, BOOL *fPending, void **lpContext); -static BOOL (WINAPI *initonce_complete)(pthread_once_t *lpInitOnce, DWORD dwFlags, void *lpContext); - -/* pre-Windows 6.0 compat using a spin-lock */ -static inline void w32thread_once_fallback(LONG volatile *state, void (*init_routine)(void)) -{ -switch (InterlockedCompareExchange(state, 1, 0)) { -/* Initial run */ -case 0: -init_routine(); -InterlockedExchange(state, 2); -break; -/* Another thread is running init */ -case 1: -while (1) { -MemoryBarrier(); -if (*state == 2) -break; -Sleep(0); -} -break; -/* Initialization complete */ -case 2: -break; -} -} - -static av_unused int pthread_once(pthread_once_t *once_control, void (*init_routine)(void)) -{ -w32thread_once_fallback(&w32thread_init_state, w32thread_init); - -/* Use native functions on Windows 6.0+ */
[FFmpeg-devel] [PATCH v3 3/5] ffplay: drop lock manager use
Deprecated and useless. --- fftools/ffplay.c | 27 --- 1 file changed, 27 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 10a917194d..9bfa3e6cea 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -1284,7 +1284,6 @@ static void do_exit(VideoState *is) SDL_DestroyRenderer(renderer); if (window) SDL_DestroyWindow(window); -av_lockmgr_register(NULL); uninit_opts(); #if CONFIG_AVFILTER av_freep(&vfilters_list); @@ -3641,27 +3640,6 @@ void show_help_default(const char *opt, const char *arg) ); } -static int lockmgr(void **mtx, enum AVLockOp op) -{ - switch(op) { - case AV_LOCK_CREATE: - *mtx = SDL_CreateMutex(); - if(!*mtx) { - av_log(NULL, AV_LOG_FATAL, "SDL_CreateMutex(): %s\n", SDL_GetError()); - return 1; - } - return 0; - case AV_LOCK_OBTAIN: - return !!SDL_LockMutex(*mtx); - case AV_LOCK_RELEASE: - return !!SDL_UnlockMutex(*mtx); - case AV_LOCK_DESTROY: - SDL_DestroyMutex(*mtx); - return 0; - } - return 1; -} - /* Called from the main */ int main(int argc, char **argv) { @@ -3723,11 +3701,6 @@ int main(int argc, char **argv) SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); SDL_EventState(SDL_USEREVENT, SDL_IGNORE); -if (av_lockmgr_register(lockmgr)) { -av_log(NULL, AV_LOG_FATAL, "Could not initialize lock manager!\n"); -do_exit(NULL); -} - av_init_packet(&flush_pkt); flush_pkt.data = (uint8_t *)&flush_pkt; -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 4/5] lavc, lavf: move avformat static mutex from avcodec to avformat
On Thu, Dec 21, 2017 at 11:22:23PM +0100, wm4 wrote: > It's completely absurd that libavcodec would care about libavformat > locking, but it was there because the lock manager was in libavcodec. > > This is more stright forward. Changes ABI, but we don't require ABI > compatibility currently. > --- > openssl, avisynth, chromaprint build untested build with all 3 tested [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct answer. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] avfilter/vf_framerate: simplify filter
The framerate filter was quite convoluted with some filter_frame / request_frame logic bugs. It seemed easier to rewrite the whole filter_frame / request_frame part and also the frame interpolation ratio calculation part in one step. Notable changes: - The filter now only stores 2 frames instead of 3 - filter_frame outputs all the frames it can to be able to handle consecutive filter_frame calls which previously caused early drops of buffered frames. - because of this, request_frame is largely simplified and it only outputs frames on flush. Previously consecuitve request_frame calls could cause the filter to think it is in flush mode filling its buffer with the same frames causing a "ghost" effect on the output. - PTS discontinuities are handled better - frames with unknown PTS values are now dropped Fixes ticket #4870. Probably fixes ticket #5493. Signed-off-by: Marton Balint --- libavfilter/vf_framerate.c | 358 --- tests/ref/fate/filter-framerate-12bit-up | 1 + 2 files changed, 94 insertions(+), 265 deletions(-) diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c index 38f45a8033..4d46b0011f 100644 --- a/libavfilter/vf_framerate.c +++ b/libavfilter/vf_framerate.c @@ -55,30 +55,25 @@ typedef struct FrameRateContext { int line_size[4]; ///< bytes of pixel data per line for each plane int vsub; -int frst, next, prev, crnt, last; -int pending_srce_frames;///< how many input frames are still waiting to be processed -int flush; ///< are we flushing final frames -int pending_end_frame; ///< flag indicating we are waiting to call filter_frame() - AVRational srce_time_base; ///< timebase of source - AVRational dest_time_base; ///< timebase of destination -int32_t dest_frame_num; -int64_t last_dest_frame_pts;///< pts of the last frame output -int64_t average_srce_pts_dest_delta;///< average input pts delta converted from input rate to output rate -int64_t average_dest_pts_delta; ///< calculated average output pts delta av_pixelutils_sad_fn sad; ///< Sum of the absolute difference function (scene detect only) double prev_mafd; ///< previous MAFD (scene detect only) -AVFrame *srce[N_SRCE]; ///< buffered source frames -int64_t srce_pts_dest[N_SRCE]; ///< pts for source frames scaled to output timebase -double srce_score[N_SRCE]; ///< scene change score compared to the next srce frame -int64_t pts;///< pts of frame we are working on - int max; int bitdepth; AVFrame *work; + +AVFrame *f0;///< last frame +AVFrame *f1;///< current frame +int64_t pts0; ///< last frame pts in dest_time_base +int64_t pts1; ///< current frame pts in dest_time_base +int64_t delta; ///< pts1 to pts0 delta +double score; ///< scene change score (f0 to f1) +int flush; ///< 1 if the filter is being flushed +int64_t start_pts; ///< pts of the first output frame +int64_t n; ///< output frame counter } FrameRateContext; #define OFFSET(x) offsetof(FrameRateContext, x) @@ -102,27 +97,6 @@ static const AVOption framerate_options[] = { AVFILTER_DEFINE_CLASS(framerate); -static void next_source(AVFilterContext *ctx) -{ -FrameRateContext *s = ctx->priv; -int i; - -ff_dlog(ctx, "next_source()\n"); - -if (s->srce[s->last] && s->srce[s->last] != s->srce[s->last-1]) { -ff_dlog(ctx, "next_source() unlink %d\n", s->last); -av_frame_free(&s->srce[s->last]); -} -for (i = s->last; i > s->frst; i--) { -ff_dlog(ctx, "next_source() copy %d to %d\n", i - 1, i); -s->srce[i] = s->srce[i - 1]; -s->srce_score[i] = s->srce_score[i - 1]; -} -ff_dlog(ctx, "next_source() make %d null\n", s->frst); -s->srce[s->frst] = NULL; -s->srce_score[s->frst] = -1.0; -} - static av_always_inline int64_t sad_8x8_16(const uint16_t *src1, ptrdiff_t stride1, const uint16_t *src2, ptrdiff_t stride2) { @@ -307,28 +281,25 @@ static int filter_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs) return 0; } -static int blend_frames(AVFilterContext *ctx, int interpolate, -int src1, int src2) +static int blend_frames(AVFilterContext *ctx, int interpolate) { FrameRateContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; double interpolate_scene_score = 0; -if ((s->flags & FRAMERATE_FLAG_SCD) && s->srce[src1] && s->srce[src2]) { -int i1 = src1 < src2 ? src1 : src2; -
[FFmpeg-devel] [PATCH 1/2] avfilter/vf_framerate: calculate interpolation as integer
It was truncated to int later on anyway. Fate test changes are due to rounding instead of truncation. Signed-off-by: Marton Balint --- libavfilter/vf_framerate.c | 22 +--- tests/ref/fate/filter-framerate-12bit-down | 40 +++--- tests/ref/fate/filter-framerate-12bit-up | 40 +++--- tests/ref/fate/filter-framerate-up | 4 +-- 4 files changed, 55 insertions(+), 51 deletions(-) diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c index 1336ea0469..38f45a8033 100644 --- a/libavfilter/vf_framerate.c +++ b/libavfilter/vf_framerate.c @@ -47,8 +47,10 @@ typedef struct FrameRateContext { AVRational dest_frame_rate; ///< output frames per second int flags; ///< flags affecting frame rate conversion algorithm double scene_score; ///< score that denotes a scene change has happened -int interp_start; ///< start of range to apply linear interpolation -int interp_end; ///< end of range to apply linear interpolation +int interp_start; ///< start of range to apply linear interpolation (same bitdepth as input) +int interp_end; ///< end of range to apply linear interpolation (same bitdepth as input) +int interp_start_param; ///< start of range to apply linear interpolation +int interp_end_param; ///< end of range to apply linear interpolation int line_size[4]; ///< bytes of pixel data per line for each plane int vsub; @@ -87,8 +89,8 @@ typedef struct FrameRateContext { static const AVOption framerate_options[] = { {"fps", "required output frames per second rate", OFFSET(dest_frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="50"}, 0, INT_MAX, V|F }, -{"interp_start","point to start linear interpolation", OFFSET(interp_start),AV_OPT_TYPE_INT, {.i64=15}, 0, 255, V|F }, -{"interp_end", "point to end linear interpolation", OFFSET(interp_end), AV_OPT_TYPE_INT, {.i64=240},0, 255, V|F }, +{"interp_start","point to start linear interpolation", OFFSET(interp_start_param),AV_OPT_TYPE_INT,{.i64=15}, 0, 255, V|F }, +{"interp_end", "point to end linear interpolation", OFFSET(interp_end_param), AV_OPT_TYPE_INT,{.i64=240},0, 255, V|F }, {"scene", "scene change level", OFFSET(scene_score), AV_OPT_TYPE_DOUBLE, {.dbl=8.2},0, INT_MAX, V|F }, {"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS,{.i64=1}, 0, INT_MAX, V|F, "flags" }, @@ -305,7 +307,7 @@ static int filter_slice16(AVFilterContext *ctx, void *arg, int job, int nb_jobs) return 0; } -static int blend_frames(AVFilterContext *ctx, float interpolate, +static int blend_frames(AVFilterContext *ctx, int interpolate, int src1, int src2) { FrameRateContext *s = ctx->priv; @@ -326,7 +328,7 @@ static int blend_frames(AVFilterContext *ctx, float interpolate, ThreadData td; td.copy_src1 = s->srce[src1]; td.copy_src2 = s->srce[src2]; -td.src2_factor = fabsf(interpolate) * (1 << (s->bitdepth - 8)); +td.src2_factor = FFABS(interpolate); td.src1_factor = s->max - td.src2_factor; // get work-space for output frame @@ -347,7 +349,7 @@ static int process_work_frame(AVFilterContext *ctx, int stop) { FrameRateContext *s = ctx->priv; int64_t work_next_pts; -float interpolate; +int interpolate; int src1, src2; ff_dlog(ctx, "process_work_frame()\n"); @@ -390,8 +392,8 @@ static int process_work_frame(AVFilterContext *ctx, int stop) } // calculate interpolation -interpolate = ((s->pts - s->srce_pts_dest[s->crnt]) * 256.0 / s->average_srce_pts_dest_delta); -ff_dlog(ctx, "process_work_frame() interpolate:%f/256\n", interpolate); +interpolate = av_rescale(s->pts - s->srce_pts_dest[s->crnt], s->max, s->average_srce_pts_dest_delta); +ff_dlog(ctx, "process_work_frame() interpolate:%d/%d\n", interpolate, s->max); src1 = s->crnt; if (interpolate > s->interp_end) { ff_dlog(ctx, "process_work_frame() source is:NEXT\n"); @@ -572,6 +574,8 @@ static int config_input(AVFilterLink *inlink) s->bitdepth = pix_desc->comp[0].depth; s->vsub = pix_desc->log2_chroma_h; +s->interp_start = s->interp_start_param << (s->bitdepth - 8); +s->interp_end = s->interp_end_param << (s->bitdepth - 8); s->sad = av_pixelutils_get_sad_fn(3, 3, 2, s); // 8x8 both sources aligned if (!s->sad) diff --git a/tes
[FFmpeg-devel] [PATCH 2/3] Add muxer/demuxer for raw codec2 and .c2 files
From e4e400fd17e7f248a61ef74681f55eed8b18be7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Tue, 8 Aug 2017 15:28:06 +0200 Subject: [PATCH 2/3] Add muxer/demuxer for raw codec2 and .c2 files --- Changelog| 1 + doc/general.texi | 4 + libavformat/Makefile | 4 + libavformat/allformats.c | 2 + libavformat/codec2.c | 314 +++ libavformat/rawenc.c | 13 ++ libavformat/utils.c | 1 + libavformat/version.h| 2 +- 8 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 libavformat/codec2.c diff --git a/Changelog b/Changelog index b828190e52..0531460a6a 100644 --- a/Changelog +++ b/Changelog @@ -28,6 +28,7 @@ version : - nsp demuxer - support LibreSSL (via libtls) - 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 2b7efe2bef..09e2e815b7 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -308,6 +308,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 cb70eac920..ea804c92de 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -131,6 +131,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 6a9b9883c9..4c84d29650 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -97,6 +97,8 @@ static void register_all(void) REGISTER_DEMUXER (CDG, cdg); REGISTER_DEMUXER (CDXL, cdxl); REGISTER_DEMUXER (CINE, cine); +REGISTER_MUXDEMUX(CODEC2, codec2); +REGISTER_MUXDEMUX(CODEC2RAW,codec2raw); REGISTER_DEMUXER (CONCAT, concat); REGISTER_MUXER (CRC, crc); REGISTER_MUXDEMUX(DASH, dash); diff --git a/libavformat/codec2.c b/libavformat/codec2.c new file mode 100644 index 00..56092467ac --- /dev/null +++ b/libavformat/codec2.c @@ -0,0 +1,314 @@ +/* + * 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 "avio_internal.h" +#include "avformat.h" +#include "internal.h" +#include "rawdec.h" +#include "rawenc.h" +#include "pcm.h" + +#define AVPRIV_CODEC2_HEADER_SIZE 7 + +//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 const uint8_t avpriv_codec2_magic[3] = {0xC0, 0xDE, 0xC2}; + +//check for 0xC0DEC2, return non-zero if it doesn't match +static int check_magic(uint8_t *ptr) { +return memcmp(ptr, avpriv_codec2_magic, 3); +} + +static int codec2_probe(AVProbeData *p) +{ +int score; + +//must be at least 7 bytes and start wih 0xC0DEC2 +if (p->buf_siz
[FFmpeg-devel] [PATCH 3/3] Don't complain about codec2's 700 bit/s modes in ffmpeg.c
From 8bd1d9981484c9b4964f3fdfd542951a02f5a01d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Thu, 3 Aug 2017 17:33:04 +0200 Subject: [PATCH 3/3] Don't complain about codec2's 700 bit/s modes in ffmpeg.c --- fftools/ffmpeg.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6aff3366c5..17989a8114 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"); -- 2.11.0 signature.asc Description: This is a digitally signed message part ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/3] Add libcodec2 en/decoder
From 630e64fbf080dacfd19b0f62ed874014bd6d3ef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Tue, 8 Aug 2017 15:27:27 +0200 Subject: [PATCH 1/3] Add libcodec2 en/decoder --- Changelog| 1 + configure| 5 ++ doc/general.texi | 20 + libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h | 1 + libavcodec/codec2utils.c | 80 ++ libavcodec/codec2utils.h | 82 ++ libavcodec/codec_desc.c | 7 ++ libavcodec/libcodec2.c | 213 +++ libavcodec/version.h | 2 +- 11 files changed, 413 insertions(+), 1 deletion(-) create mode 100644 libavcodec/codec2utils.c create mode 100644 libavcodec/codec2utils.h create mode 100644 libavcodec/libcodec2.c diff --git a/Changelog b/Changelog index ee48876128..b828190e52 100644 --- a/Changelog +++ b/Changelog @@ -27,6 +27,7 @@ version : - video setrange filter - nsp demuxer - support LibreSSL (via libtls) +- codec2 en/decoding via libcodec2 version 3.4: diff --git a/configure b/configure index d09eec4155..0a7ccdfa54 100755 --- a/configure +++ b/configure @@ -225,6 +225,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] @@ -1596,6 +1597,7 @@ EXTERNAL_LIBRARY_LIST=" libbs2b libcaca libcelt +libcodec2 libdc1394 libdrm libflite @@ -2932,6 +2934,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" @@ -5831,6 +5835,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 26919c9287..2b7efe2bef 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. @@ -1004,6 +1022,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 mode (DSS SP) @tab @tab X d
[FFmpeg-devel] [PATCH 0/3] Add codec2 support
Hi I've had some time recently to revise the codec2 patchset from a few months ago, just in time for the holidays. For those not in the know, codec2 is an ultra-low bitrate voice codec primarily intended for amateur radio use, but which has recently found use in compressing podcasts and audiobooks. Trunking is another potential use. The most important changes in this patchset are: * Removed the CODEC2_MODE_* defines since they caused trouble if the system has an older version of libcodec2 installed. Debian stretch ships libcodec2 0.4 which lacks CODEC2_MODE_700C and so this wouldn't compile. These defines are only used in AVPRIV_CODEC2_AVOPTIONS anyway, so verbatim numbers are fine IMO. * Fixed detection of non-working modes. Again, attempting 700C on libcodec2 0.4. * Expanded documentation. Bikeshedding opportunities: * should codec2 mode be carried in extradata or codec_tag? Future work: * add support for CODEC2_MODE_WB once it's stable * FATE tests: bitexact remuxing in all modes, encoding all modes, decoding all modes For the FATE bit I'm thinking something like the test script attached. I attached a 12 second sample too, a whopping 5 kB in size 😎 /Tomas sa2tms.c2 Description: Binary data test_codec2.sh Description: application/shellscript signature.asc Description: This is a digitally signed message part ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault) - Add function 'resolve_content_path' to propagate the baseURL from upper level nodes. * if no baseURL is availa
--- libavformat/dashdec.c | 110 -- 1 file changed, 97 insertions(+), 13 deletions(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 3798649..6574e56 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -148,6 +148,11 @@ static uint64_t get_current_time_in_sec(void) return av_gettime() / 100; } +static int ishttp(char *url) { +const char *proto_name = avio_find_protocol_name(url); +return av_strstart(proto_name, "http", NULL); +} static uint64_t get_utc_date_time_insec(AVFormatContext *s, const char *datetime) { struct tm timeinfo; @@ -392,7 +397,9 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5)) return AVERROR_INVALIDDATA; -ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp); +av_freep(pb); +ret = avio_open2(pb, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp); if (ret >= 0) { // update cookies on http response with setcookies. char *new_cookies = NULL; @@ -639,6 +646,85 @@ static int parse_manifest_segmenttimeline(AVFormatContext *s, struct representat return 0; } +static int resolve_content_path(AVFormatContext *s, const char *url, xmlNodePtr *baseurl_nodes, int n_baseurl_nodes) { + +char *tmp_str = av_mallocz(MAX_URL_SIZE); +char *path = av_mallocz(MAX_URL_SIZE); +char *mpdName = NULL; +xmlNodePtr node = NULL; +char *baseurl = NULL; +char *root_url = NULL; +char *text = NULL; + +int isRootHttp = 0; +char token ='/'; +int start = 0; +int rootId = 0; +int updated = 0; +int size = 0; +int i; + +if (!tmp_str || !path) { +updated = AVERROR(ENOMEM); +goto end; +} + +av_strlcpy(tmp_str, url, strlen(url) + 1); +mpdName = strtok (tmp_str, "/"); +while (mpdName = strtok (NULL, "/")) { +size = strlen(mpdName); +} + +av_strlcpy (path, url, strlen(url) - size + 1); + +for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId--) { +if (!(node = baseurl_nodes[rootId])) { +continue; +} +if (ishttp(xmlNodeGetContent(node))) { +break; +} +} + +node = baseurl_nodes[rootId]; +baseurl = xmlNodeGetContent(node); +root_url = (av_strcasecmp(baseurl, ""))? baseurl: path; +if (node) { +xmlNodeSetContent(node, root_url); +} + +size = strlen(root_url); +isRootHttp= ishttp(root_url); + +if (root_url[size-1]==token) { +av_strlcat(root_url, "/", size+2); +size+=2; +} + +for (i = 0; i < n_baseurl_nodes; ++i) { +if (i == rootId) { +continue; +} +text = xmlNodeGetContent(baseurl_nodes[i]); +if (text) { +memset(tmp_str, 0, strlen(tmp_str)); +if (!ishttp(text) && isRootHttp) { +av_strlcpy(tmp_str, root_url, size + 1); +} +start = (text[0] == token) ? 1: 0; +av_strlcat(tmp_str, text + start, MAX_URL_SIZE); +xmlNodeSetContent(baseurl_nodes[i], tmp_str); +updated = 1; +xmlFree(text); +} +} + +end: +av_free(path); +av_free(tmp_str); +return updated; + +} static int parse_manifest_representation(AVFormatContext *s, const char *url, xmlNodePtr node, xmlNodePtr adaptionset_node, @@ -698,6 +784,12 @@ static int parse_manifest_representation(AVFormatContext *s, const char *url, baseurl_nodes[2] = adaptionset_baseurl_node; baseurl_nodes[3] = representation_baseurl_node; +ret = resolve_content_path(s, url, baseurl_nodes, 4); +if (ret == AVERROR(ENOMEM) || ret == 0) { +goto end; +} + if (representation_segmenttemplate_node || fragment_template_node) { fragment_timeline_node = NULL; fragment_templates_tab[0] = representation_segmenttemplate_node; @@ -993,6 +1085,9 @@ static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in) } mpd_baseurl_node = find_child_node_by_name(node, "BaseURL"); +if (!mpd_baseurl_node) { +mpd_baseurl_node = xmlNewNode(NULL, "BaseURL"); +} // at now we can handle only one period, with the longest duration node = xmlFirstElementChild(node); @@ -1315,6 +1410,7 @@ static int read_from_url(struct representation *pls, struct fragment *seg, } else { ret = avio_read(pls->input, buf, buf_size); } if (ret > 0) pls->cur_seg_offset += ret; @@ -1343,18 +1439,6 @@ static int open_input(DASHContext *c, struct representation *pls, struct fragmen goto cleanup; } -/* Seek to the requested position. If this was a HTTP request, the offset - * should alre
Re: [FFmpeg-devel] [PATCH 2/5] lavc: replace and deprecate the lock manager
On Sat, 23 Dec 2017 22:32:36 +0100 Michael Niedermayer wrote: > On Thu, Dec 21, 2017 at 11:22:21PM +0100, wm4 wrote: > > Use static mutexes instead of requiring a lock manager. The behavior > > should be roughly the same before and after this change for API users > > which did not set the lock manager at all (except that a minor memory > > leak disappears). > > --- > > doc/APIchanges | 5 +++ > > libavcodec/avcodec.h | 8 +++- > > libavcodec/utils.c | 107 > > +-- > > libavcodec/version.h | 5 ++- > > 4 files changed, 26 insertions(+), 99 deletions(-) > > Are all thread APIs users used with our lock manager compatible with this > replacement ? Yes, unless they explicitly disable threads in FFmpeg and used a lock manager to compensate for it. But that would lose safety in other places, where we already rely on pthread_once(), and would disable useful features like frame threading. Possibly we should add a note about this when the next release happens, or disallow disabling building without thread support. > Someone, possibly reimar, but i may misremember who it was. Talked in the > past > about thread API incompatibilies > I believe the concern was that the user APP used multiple threads, one for > each > decoder and one for the demuxer. But the locking used by the user app between > its threads could be incompatible with the locking of our "pthread" locks. > > If this is not an issue, then iam happy about this patch and the > removial of the lock manager complexity. I'm not worried about it, because FFmpeg uses the OS native threading lib. Thus it's compatible with whatever else builds on native threading. I don't even think it's possible to have threading that does not build on the OS primitives, unless you do extremely hacky stuff behind the libc (or ntdll on Windows). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 2/5] lavc: replace and deprecate the lock manager
On Thu, Dec 21, 2017 at 11:22:21PM +0100, wm4 wrote: > Use static mutexes instead of requiring a lock manager. The behavior > should be roughly the same before and after this change for API users > which did not set the lock manager at all (except that a minor memory > leak disappears). > --- > doc/APIchanges | 5 +++ > libavcodec/avcodec.h | 8 +++- > libavcodec/utils.c | 107 > +-- > libavcodec/version.h | 5 ++- > 4 files changed, 26 insertions(+), 99 deletions(-) Are all thread APIs users used with our lock manager compatible with this replacement ? Someone, possibly reimar, but i may misremember who it was. Talked in the past about thread API incompatibilies I believe the concern was that the user APP used multiple threads, one for each decoder and one for the demuxer. But the locking used by the user app between its threads could be incompatible with the locking of our "pthread" locks. If this is not an issue, then iam happy about this patch and the removial of the lock manager complexity. thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship naturally arises out of democracy, and the most aggravated form of tyranny and slavery out of the most extreme liberty. -- Plato signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 7/9] sbcenc: add MMX optimizations
On Sat, Dec 23, 2017 at 09:52:11PM +0100, Aurelien Jacobs wrote: > On Sat, Dec 23, 2017 at 05:47:04PM -0300, James Almer wrote: > > On 12/23/2017 5:44 PM, Aurelien Jacobs wrote: > > > On Sat, Dec 23, 2017 at 03:35:28PM -0300, James Almer wrote: > > >> On 12/23/2017 3:01 PM, Aurelien Jacobs wrote: > > >>> This was originally based on libsbc, and was fully integrated into > > >>> ffmpeg. > > >>> > > >>> Rough speed test: > > >>> C version:speed= 592x > > >>> MMX version: speed= 785x > > >>> --- > > >>> libavcodec/sbcdsp.c | 3 + > > >>> libavcodec/sbcdsp.h | 2 + > > >>> libavcodec/x86/Makefile | 2 + > > >>> libavcodec/x86/sbcdsp.asm| 284 > > >>> +++ > > >>> libavcodec/x86/sbcdsp_init.c | 51 > > >>> 5 files changed, 342 insertions(+) > > >>> create mode 100644 libavcodec/x86/sbcdsp.asm > > >>> create mode 100644 libavcodec/x86/sbcdsp_init.c > > >> > > >> [...] > > >> > > >>> +;*** > > >>> +;void ff_sbc_calc_scalefactors(int32_t sb_sample_f[16][2][8], > > >>> +; uint32_t scale_factor[2][8], > > >>> +; int blocks, int channels, int subbands) > > >>> +;*** > > >>> +INIT_MMX mmx > > >>> +cglobal sbc_calc_scalefactors, 5, 7, 3, sb_sample_f, scale_factor, > > >>> blocks, channels, subbands, ptr, blk > > >>> +; subbands = 4 * subbands * channels > > >>> +shl subbandsd, 2 > > >>> +cmp channelsd, 2 > > >>> +jl .loop_1 > > >>> +shl subbandsd, 1 > > >>> + > > >>> +.loop_1: > > >>> +sub subbandsq, 8 > > >>> +lea ptrq, [sb_sample_fq + subbandsq] > > >>> + > > >>> +; blk = (blocks - 1) * 64; > > >>> +lea blkq, [blocksq - 1] > > >>> +shl blkd, 6 > > >>> + > > >>> +movq m0, [scale_mask] > > >> > > >> I insist, this can be easily loaded outside the loop. You have enough > > >> spare regs to store a copy. > > > > > > Oh, I forgot to reply to this. There isn't any register left available > > > on x86_32, hence why I kept those load inside the loop. > > > > You're not using a gprs to store the mask nor need to. You're using mmx > > regs and have 5 left. > > Oh, indeed ! Not sure why it didn't even cross my mind... > I will have a look at this. Here it is with the scale_mask load out of the loop. >From 5c8ac4e2d23c0ebf27d6592645d53b60d07d47ef Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Sun, 17 Dec 2017 20:07:33 +0100 Subject: [PATCH 7/9] sbcenc: add MMX optimizations This was originally based on libsbc, and was fully integrated into ffmpeg. Rough speed test: C version:speed= 592x MMX version: speed= 785x --- libavcodec/sbcdsp.c | 3 + libavcodec/sbcdsp.h | 2 + libavcodec/x86/Makefile | 2 + libavcodec/x86/sbcdsp.asm| 285 +++ libavcodec/x86/sbcdsp_init.c | 51 5 files changed, 343 insertions(+) create mode 100644 libavcodec/x86/sbcdsp.asm create mode 100644 libavcodec/x86/sbcdsp_init.c diff --git a/libavcodec/sbcdsp.c b/libavcodec/sbcdsp.c index e155387f0d..2d0addcf28 100644 --- a/libavcodec/sbcdsp.c +++ b/libavcodec/sbcdsp.c @@ -379,4 +379,7 @@ av_cold void ff_sbcdsp_init(SBCDSPContext *s) /* Default implementation for scale factors calculation */ s->sbc_calc_scalefactors = sbc_calc_scalefactors; s->sbc_calc_scalefactors_j = sbc_calc_scalefactors_j; + +if (ARCH_X86) +ff_sbcdsp_init_x86(s); } diff --git a/libavcodec/sbcdsp.h b/libavcodec/sbcdsp.h index 66ed7d324e..127e6a8a11 100644 --- a/libavcodec/sbcdsp.h +++ b/libavcodec/sbcdsp.h @@ -80,4 +80,6 @@ struct sbc_dsp_context { */ void ff_sbcdsp_init(SBCDSPContext *s); +void ff_sbcdsp_init_x86(SBCDSPContext *s); + #endif /* AVCODEC_SBCDSP_H */ diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index a805cd37b4..2350c8bbee 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -63,6 +63,7 @@ OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp_init.o OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp_init.o OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp_init.o OBJS-$(CONFIG_RV40_DECODER)+= x86/rv40dsp_init.o +OBJS-$(CONFIG_SBC_ENCODER) += x86/sbcdsp_init.o OBJS-$(CONFIG_SVQ1_ENCODER)+= x86/svq1enc_init.o OBJS-$(CONFIG_TAK_DECODER) += x86/takdsp_init.o OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp_init.o @@ -172,6 +173,7 @@ X86ASM-OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp.o X86ASM-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp.o X86ASM-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp.o X86ASM-OBJS-$(CONFIG_RV40_DECODER) += x86/rv40dsp.o +X86ASM-OBJS-$(CONFIG_SBC_ENCODER) += x86/sbcdsp.o X86ASM-OBJS-$(CONFIG_SVQ1_ENCODER) += x86/svq1enc.o X86A
Re: [FFmpeg-devel] [PATCH 7/9] sbcenc: add MMX optimizations
On Sat, Dec 23, 2017 at 05:47:04PM -0300, James Almer wrote: > On 12/23/2017 5:44 PM, Aurelien Jacobs wrote: > > On Sat, Dec 23, 2017 at 03:35:28PM -0300, James Almer wrote: > >> On 12/23/2017 3:01 PM, Aurelien Jacobs wrote: > >>> This was originally based on libsbc, and was fully integrated into ffmpeg. > >>> > >>> Rough speed test: > >>> C version:speed= 592x > >>> MMX version: speed= 785x > >>> --- > >>> libavcodec/sbcdsp.c | 3 + > >>> libavcodec/sbcdsp.h | 2 + > >>> libavcodec/x86/Makefile | 2 + > >>> libavcodec/x86/sbcdsp.asm| 284 > >>> +++ > >>> libavcodec/x86/sbcdsp_init.c | 51 > >>> 5 files changed, 342 insertions(+) > >>> create mode 100644 libavcodec/x86/sbcdsp.asm > >>> create mode 100644 libavcodec/x86/sbcdsp_init.c > >> > >> [...] > >> > >>> +;*** > >>> +;void ff_sbc_calc_scalefactors(int32_t sb_sample_f[16][2][8], > >>> +; uint32_t scale_factor[2][8], > >>> +; int blocks, int channels, int subbands) > >>> +;*** > >>> +INIT_MMX mmx > >>> +cglobal sbc_calc_scalefactors, 5, 7, 3, sb_sample_f, scale_factor, > >>> blocks, channels, subbands, ptr, blk > >>> +; subbands = 4 * subbands * channels > >>> +shl subbandsd, 2 > >>> +cmp channelsd, 2 > >>> +jl .loop_1 > >>> +shl subbandsd, 1 > >>> + > >>> +.loop_1: > >>> +sub subbandsq, 8 > >>> +lea ptrq, [sb_sample_fq + subbandsq] > >>> + > >>> +; blk = (blocks - 1) * 64; > >>> +lea blkq, [blocksq - 1] > >>> +shl blkd, 6 > >>> + > >>> +movq m0, [scale_mask] > >> > >> I insist, this can be easily loaded outside the loop. You have enough > >> spare regs to store a copy. > > > > Oh, I forgot to reply to this. There isn't any register left available > > on x86_32, hence why I kept those load inside the loop. > > You're not using a gprs to store the mask nor need to. You're using mmx > regs and have 5 left. Oh, indeed ! Not sure why it didn't even cross my mind... I will have a look at this. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 7/9] sbcenc: add MMX optimizations
On 12/23/2017 5:44 PM, Aurelien Jacobs wrote: > On Sat, Dec 23, 2017 at 03:35:28PM -0300, James Almer wrote: >> On 12/23/2017 3:01 PM, Aurelien Jacobs wrote: >>> This was originally based on libsbc, and was fully integrated into ffmpeg. >>> >>> Rough speed test: >>> C version:speed= 592x >>> MMX version: speed= 785x >>> --- >>> libavcodec/sbcdsp.c | 3 + >>> libavcodec/sbcdsp.h | 2 + >>> libavcodec/x86/Makefile | 2 + >>> libavcodec/x86/sbcdsp.asm| 284 >>> +++ >>> libavcodec/x86/sbcdsp_init.c | 51 >>> 5 files changed, 342 insertions(+) >>> create mode 100644 libavcodec/x86/sbcdsp.asm >>> create mode 100644 libavcodec/x86/sbcdsp_init.c >> >> [...] >> >>> +;*** >>> +;void ff_sbc_calc_scalefactors(int32_t sb_sample_f[16][2][8], >>> +; uint32_t scale_factor[2][8], >>> +; int blocks, int channels, int subbands) >>> +;*** >>> +INIT_MMX mmx >>> +cglobal sbc_calc_scalefactors, 5, 7, 3, sb_sample_f, scale_factor, blocks, >>> channels, subbands, ptr, blk >>> +; subbands = 4 * subbands * channels >>> +shl subbandsd, 2 >>> +cmp channelsd, 2 >>> +jl .loop_1 >>> +shl subbandsd, 1 >>> + >>> +.loop_1: >>> +sub subbandsq, 8 >>> +lea ptrq, [sb_sample_fq + subbandsq] >>> + >>> +; blk = (blocks - 1) * 64; >>> +lea blkq, [blocksq - 1] >>> +shl blkd, 6 >>> + >>> +movq m0, [scale_mask] >> >> I insist, this can be easily loaded outside the loop. You have enough >> spare regs to store a copy. > > Oh, I forgot to reply to this. There isn't any register left available > on x86_32, hence why I kept those load inside the loop. You're not using a gprs to store the mask nor need to. You're using mmx regs and have 5 left. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 7/9] sbcenc: add MMX optimizations
On Sat, Dec 23, 2017 at 03:35:28PM -0300, James Almer wrote: > On 12/23/2017 3:01 PM, Aurelien Jacobs wrote: > > This was originally based on libsbc, and was fully integrated into ffmpeg. > > > > Rough speed test: > > C version:speed= 592x > > MMX version: speed= 785x > > --- > > libavcodec/sbcdsp.c | 3 + > > libavcodec/sbcdsp.h | 2 + > > libavcodec/x86/Makefile | 2 + > > libavcodec/x86/sbcdsp.asm| 284 > > +++ > > libavcodec/x86/sbcdsp_init.c | 51 > > 5 files changed, 342 insertions(+) > > create mode 100644 libavcodec/x86/sbcdsp.asm > > create mode 100644 libavcodec/x86/sbcdsp_init.c > > [...] > > > +;*** > > +;void ff_sbc_calc_scalefactors(int32_t sb_sample_f[16][2][8], > > +; uint32_t scale_factor[2][8], > > +; int blocks, int channels, int subbands) > > +;*** > > +INIT_MMX mmx > > +cglobal sbc_calc_scalefactors, 5, 7, 3, sb_sample_f, scale_factor, blocks, > > channels, subbands, ptr, blk > > +; subbands = 4 * subbands * channels > > +shl subbandsd, 2 > > +cmp channelsd, 2 > > +jl .loop_1 > > +shl subbandsd, 1 > > + > > +.loop_1: > > +sub subbandsq, 8 > > +lea ptrq, [sb_sample_fq + subbandsq] > > + > > +; blk = (blocks - 1) * 64; > > +lea blkq, [blocksq - 1] > > +shl blkd, 6 > > + > > +movq m0, [scale_mask] > > I insist, this can be easily loaded outside the loop. You have enough > spare regs to store a copy. Oh, I forgot to reply to this. There isn't any register left available on x86_32, hence why I kept those load inside the loop. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 5/9] sbc: implement SBC encoder (low-complexity subband codec)
Updated to match new identifier for CRC (AV_CRC_8_EBU). >From 380c36ec392b066d4b70b0f9fd4957a595294f5a Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Sun, 17 Dec 2017 19:59:30 +0100 Subject: [PATCH 5/9] sbc: implement SBC encoder (low-complexity subband codec) This was originally based on libsbc, and was fully integrated into ffmpeg. --- doc/general.texi | 2 +- libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 4 +- libavcodec/sbcdsp.c | 382 libavcodec/sbcdsp.h | 83 + libavcodec/sbcdsp_data.c | 329 +++ libavcodec/sbcdsp_data.h | 55 ++ libavcodec/sbcenc.c | 443 +++ 8 files changed, 1297 insertions(+), 3 deletions(-) create mode 100644 libavcodec/sbcdsp.c create mode 100644 libavcodec/sbcdsp.h create mode 100644 libavcodec/sbcdsp_data.c create mode 100644 libavcodec/sbcdsp_data.h create mode 100644 libavcodec/sbcenc.c diff --git a/doc/general.texi b/doc/general.texi index 65aee47f2a..e5669b0e93 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1103,7 +1103,7 @@ following image formats are supported: @tab Real low bitrate AC-3 codec @item RealAudio Lossless @tab @tab X @item RealAudio SIPR / ACELP.NET @tab @tab X -@item SBC (low-complexity subband codec) @tab @tab X +@item SBC (low-complexity subband codec) @tab X @tab X @tab Used in Bluetooth A2DP @item Shorten@tab @tab X @item Sierra VMD audio @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 58c8c6e499..d237deeefc 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -582,7 +582,9 @@ OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o OBJS-$(CONFIG_LIBRSVG_DECODER) += librsvgdec.o OBJS-$(CONFIG_SBC_DECODER) += sbcdec.o sbcdec_data.o sbc.o +OBJS-$(CONFIG_SBC_ENCODER) += sbcenc.o sbc.o sbcdsp.o sbcdsp_data.o OBJS-$(CONFIG_MSBC_DECODER)+= sbcdec.o sbcdec_data.o sbc.o +OBJS-$(CONFIG_MSBC_ENCODER)+= sbcenc.o sbc.o sbcdsp.o sbcdsp_data.o OBJS-$(CONFIG_SVQ1_DECODER)+= svq1dec.o svq1.o svq13.o h263data.o OBJS-$(CONFIG_SVQ1_ENCODER)+= svq1enc.o svq1.o h263data.o \ h263.o ituh263enc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 3e3b37f638..e5b3c20ec7 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -379,7 +379,7 @@ static void register_all(void) REGISTER_DECODER(MP3ON4FLOAT, mp3on4float); REGISTER_DECODER(MPC7, mpc7); REGISTER_DECODER(MPC8, mpc8); -REGISTER_DECODER(MSBC, msbc); +REGISTER_ENCDEC (MSBC, msbc); REGISTER_ENCDEC (NELLYMOSER,nellymoser); REGISTER_DECODER(ON2AVC,on2avc); REGISTER_ENCDEC (OPUS, opus); @@ -393,7 +393,7 @@ static void register_all(void) REGISTER_DECODER(SHORTEN, shorten); REGISTER_DECODER(SIPR, sipr); REGISTER_DECODER(SMACKAUD, smackaud); -REGISTER_DECODER(SBC, sbc); +REGISTER_ENCDEC (SBC, sbc); REGISTER_ENCDEC (SONIC, sonic); REGISTER_ENCODER(SONIC_LS, sonic_ls); REGISTER_DECODER(TAK, tak); diff --git a/libavcodec/sbcdsp.c b/libavcodec/sbcdsp.c new file mode 100644 index 00..e155387f0d --- /dev/null +++ b/libavcodec/sbcdsp.c @@ -0,0 +1,382 @@ +/* + * Bluetooth low-complexity, subband codec (SBC) + * + * Copyright (C) 2017 Aurelien Jacobs + * Copyright (C) 2012-2013 Intel Corporation + * Copyright (C) 2008-2010 Nokia Corporation + * Copyright (C) 2004-2010 Marcel Holtmann + * Copyright (C) 2004-2005 Henryk Ploetz + * Copyright (C) 2005-2006 Brad Midgley + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * SBC basic "building bricks" + */ + +#include +#include +#include +#include "libavutil/common.h" +#include "libavutil/intmath.h" +#include "libavutil/intreadwrite.h" +#include "sbc.h" +#include "sbcdsp.h" +#include "
Re: [FFmpeg-devel] [PATCH 2/9] sbc: implement SBC decoder (low-complexity subband codec)
Updated to match new identifier for CRC (AV_CRC_8_EBU). >From c168e5e7b288edc2730a4a14614ead5c22d67289 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Sun, 17 Dec 2017 19:53:35 +0100 Subject: [PATCH 2/9] sbc: implement SBC decoder (low-complexity subband codec) This was originally based on libsbc, and was fully integrated into ffmpeg. --- doc/general.texi | 2 + libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 2 + libavcodec/avcodec.h | 2 + libavcodec/codec_desc.c | 14 ++ libavcodec/sbc.c | 280 libavcodec/sbc.h | 121 libavcodec/sbcdec.c | 466 +++ libavcodec/sbcdec_data.c | 127 + libavcodec/sbcdec_data.h | 44 + 10 files changed, 1060 insertions(+) create mode 100644 libavcodec/sbc.c create mode 100644 libavcodec/sbc.h create mode 100644 libavcodec/sbcdec.c create mode 100644 libavcodec/sbcdec_data.c create mode 100644 libavcodec/sbcdec_data.h diff --git a/doc/general.texi b/doc/general.texi index 26919c9287..ed137f999f 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1102,6 +1102,8 @@ following image formats are supported: @tab Real low bitrate AC-3 codec @item RealAudio Lossless @tab @tab X @item RealAudio SIPR / ACELP.NET @tab @tab X +@item SBC (low-complexity subband codec) @tab @tab X +@tab Used in Bluetooth A2DP @item Shorten@tab @tab X @item Sierra VMD audio @tab @tab X @tab Used in Sierra VMD files. diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ca72138c02..c46d102227 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -581,6 +581,8 @@ OBJS-$(CONFIG_SUBVIEWER_DECODER) += subviewerdec.o ass.o OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o OBJS-$(CONFIG_LIBRSVG_DECODER) += librsvgdec.o +OBJS-$(CONFIG_SBC_DECODER) += sbcdec.o sbcdec_data.o sbc.o +OBJS-$(CONFIG_MSBC_DECODER)+= sbcdec.o sbcdec_data.o sbc.o OBJS-$(CONFIG_SVQ1_DECODER)+= svq1dec.o svq1.o svq13.o h263data.o OBJS-$(CONFIG_SVQ1_ENCODER)+= svq1enc.o svq1.o h263data.o \ h263.o ituh263enc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ed1e7ab06e..9e2480d2d4 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -379,6 +379,7 @@ static void register_all(void) REGISTER_DECODER(MP3ON4FLOAT, mp3on4float); REGISTER_DECODER(MPC7, mpc7); REGISTER_DECODER(MPC8, mpc8); +REGISTER_DECODER(MSBC, msbc); REGISTER_ENCDEC (NELLYMOSER,nellymoser); REGISTER_DECODER(ON2AVC,on2avc); REGISTER_ENCDEC (OPUS, opus); @@ -392,6 +393,7 @@ static void register_all(void) REGISTER_DECODER(SHORTEN, shorten); REGISTER_DECODER(SIPR, sipr); REGISTER_DECODER(SMACKAUD, smackaud); +REGISTER_DECODER(SBC, sbc); REGISTER_ENCDEC (SONIC, sonic); REGISTER_ENCODER(SONIC_LS, sonic_ls); REGISTER_DECODER(TAK, tak); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ce089b7c4a..5b7ec8541d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -634,6 +634,8 @@ enum AVCodecID { AV_CODEC_ID_ATRAC3PAL, AV_CODEC_ID_DOLBY_E, AV_CODEC_ID_APTX, +AV_CODEC_ID_SBC, +AV_CODEC_ID_MSBC, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index c3688de1d6..a69897d379 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2866,6 +2866,20 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("aptX (Audio Processing Technology for Bluetooth)"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_SBC, +.type = AVMEDIA_TYPE_AUDIO, +.name = "sbc", +.long_name = NULL_IF_CONFIG_SMALL("SBC (low-complexity subband codec)"), +.props = AV_CODEC_PROP_LOSSY, +}, +{ +.id= AV_CODEC_ID_MSBC, +.type = AVMEDIA_TYPE_AUDIO, +.name = "msbc", +.long_name = NULL_IF_CONFIG_SMALL("mSBC (wideband speech mono SBC)"), +.props = AV_CODEC_PROP_LOSSY, +}, /* subtitle codecs */ { diff --git a/libavcodec/sbc.c b/libavcodec/sbc.c new file mode 100644 index 00..af3e9a3fa8 --- /dev/null +++ b/libavcodec/sbc.c @@ -0,0 +1,280 @@ +/* + * Bluetooth low-complexity, subband codec (SBC) + * + * Copyright (C) 2017 Aurelien Jacobs + * Copyright (C) 2012-2013 Intel Corporation + * Copyright (C) 2008-2010 Nokia Corporation
Re: [FFmpeg-devel] [PATCH 1/9] crc: add AV_CRC_8_SBC as a 8 bits CRC with polynomial 0x1D
On Sat, Dec 23, 2017 at 04:32:26PM -0300, James Almer wrote: > On 12/23/2017 3:01 PM, Aurelien Jacobs wrote: > > --- > > libavutil/crc.c | 26 ++ > > libavutil/crc.h | 1 + > > libavutil/tests/crc.c | 7 --- > > tests/ref/fate/crc| 1 + > > 4 files changed, 32 insertions(+), 3 deletions(-) > > > > diff --git a/libavutil/crc.c b/libavutil/crc.c > > index d44550c9c0..8e44a76ec8 100644 > > --- a/libavutil/crc.c > > +++ b/libavutil/crc.c > > @@ -52,6 +52,30 @@ static const AVCRC av_crc_table[AV_CRC_MAX][257] = { > > 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, > > 0xEF, > > 0xFA, 0xFD, 0xF4, 0xF3, 0x01 > > }, > > +[AV_CRC_8_SBC] = { > > +0x00, 0x1D, 0x3A, 0x27, 0x74, 0x69, 0x4E, 0x53, 0xE8, 0xF5, 0xD2, > > 0xCF, > > +0x9C, 0x81, 0xA6, 0xBB, 0xCD, 0xD0, 0xF7, 0xEA, 0xB9, 0xA4, 0x83, > > 0x9E, > > +0x25, 0x38, 0x1F, 0x02, 0x51, 0x4C, 0x6B, 0x76, 0x87, 0x9A, 0xBD, > > 0xA0, > > +0xF3, 0xEE, 0xC9, 0xD4, 0x6F, 0x72, 0x55, 0x48, 0x1B, 0x06, 0x21, > > 0x3C, > > +0x4A, 0x57, 0x70, 0x6D, 0x3E, 0x23, 0x04, 0x19, 0xA2, 0xBF, 0x98, > > 0x85, > > +0xD6, 0xCB, 0xEC, 0xF1, 0x13, 0x0E, 0x29, 0x34, 0x67, 0x7A, 0x5D, > > 0x40, > > +0xFB, 0xE6, 0xC1, 0xDC, 0x8F, 0x92, 0xB5, 0xA8, 0xDE, 0xC3, 0xE4, > > 0xF9, > > +0xAA, 0xB7, 0x90, 0x8D, 0x36, 0x2B, 0x0C, 0x11, 0x42, 0x5F, 0x78, > > 0x65, > > +0x94, 0x89, 0xAE, 0xB3, 0xE0, 0xFD, 0xDA, 0xC7, 0x7C, 0x61, 0x46, > > 0x5B, > > +0x08, 0x15, 0x32, 0x2F, 0x59, 0x44, 0x63, 0x7E, 0x2D, 0x30, 0x17, > > 0x0A, > > +0xB1, 0xAC, 0x8B, 0x96, 0xC5, 0xD8, 0xFF, 0xE2, 0x26, 0x3B, 0x1C, > > 0x01, > > +0x52, 0x4F, 0x68, 0x75, 0xCE, 0xD3, 0xF4, 0xE9, 0xBA, 0xA7, 0x80, > > 0x9D, > > +0xEB, 0xF6, 0xD1, 0xCC, 0x9F, 0x82, 0xA5, 0xB8, 0x03, 0x1E, 0x39, > > 0x24, > > +0x77, 0x6A, 0x4D, 0x50, 0xA1, 0xBC, 0x9B, 0x86, 0xD5, 0xC8, 0xEF, > > 0xF2, > > +0x49, 0x54, 0x73, 0x6E, 0x3D, 0x20, 0x07, 0x1A, 0x6C, 0x71, 0x56, > > 0x4B, > > +0x18, 0x05, 0x22, 0x3F, 0x84, 0x99, 0xBE, 0xA3, 0xF0, 0xED, 0xCA, > > 0xD7, > > +0x35, 0x28, 0x0F, 0x12, 0x41, 0x5C, 0x7B, 0x66, 0xDD, 0xC0, 0xE7, > > 0xFA, > > +0xA9, 0xB4, 0x93, 0x8E, 0xF8, 0xE5, 0xC2, 0xDF, 0x8C, 0x91, 0xB6, > > 0xAB, > > +0x10, 0x0D, 0x2A, 0x37, 0x64, 0x79, 0x5E, 0x43, 0xB2, 0xAF, 0x88, > > 0x95, > > +0xC6, 0xDB, 0xFC, 0xE1, 0x5A, 0x47, 0x60, 0x7D, 0x2E, 0x33, 0x14, > > 0x09, > > +0x7F, 0x62, 0x45, 0x58, 0x0B, 0x16, 0x31, 0x2C, 0x97, 0x8A, 0xAD, > > 0xB0, > > +0xE3, 0xFE, 0xD9, 0xC4, 0x01 > > +}, > > [AV_CRC_16_ANSI] = { > > 0x, 0x0580, 0x0F80, 0x0A00, 0x1B80, 0x1E00, 0x1400, 0x1180, > > 0x3380, 0x3600, 0x3C00, 0x3980, 0x2800, 0x2D80, 0x2780, 0x2200, > > @@ -305,6 +329,7 @@ static void id ## _init_table_once(void) > > #define CRC_INIT_TABLE_ONCE(id) ff_thread_once(&id ## _once_control, id ## > > _init_table_once) > > > > DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_8_ATM, 0, 8, 0x07) > > +DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_8_SBC, 0, 8, 0x1D) > > The polynomial 0x1D seems to be used in a couple standards, including > one defined by the European Broadcasting Union, so instead of _SBC which > is a codec using the CRC, I'd use _EBU for the enum constant. Agreed. Here is an updated patch. >From 652900498e94f843d09d868809e452d9ef0fc8a3 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Wed, 20 Dec 2017 01:29:05 +0100 Subject: [PATCH 1/9] crc: add AV_CRC_8_SBC as a 8 bits CRC with polynomial 0x1D --- libavutil/crc.c | 26 ++ libavutil/crc.h | 1 + libavutil/tests/crc.c | 7 --- tests/ref/fate/crc| 1 + 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/libavutil/crc.c b/libavutil/crc.c index d44550c9c0..c45ea63a62 100644 --- a/libavutil/crc.c +++ b/libavutil/crc.c @@ -52,6 +52,30 @@ static const AVCRC av_crc_table[AV_CRC_MAX][257] = { 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3, 0x01 }, +[AV_CRC_8_EBU] = { +0x00, 0x1D, 0x3A, 0x27, 0x74, 0x69, 0x4E, 0x53, 0xE8, 0xF5, 0xD2, 0xCF, +0x9C, 0x81, 0xA6, 0xBB, 0xCD, 0xD0, 0xF7, 0xEA, 0xB9, 0xA4, 0x83, 0x9E, +0x25, 0x38, 0x1F, 0x02, 0x51, 0x4C, 0x6B, 0x76, 0x87, 0x9A, 0xBD, 0xA0, +0xF3, 0xEE, 0xC9, 0xD4, 0x6F, 0x72, 0x55, 0x48, 0x1B, 0x06, 0x21, 0x3C, +0x4A, 0x57, 0x70, 0x6D, 0x3E, 0x23, 0x04, 0x19, 0xA2, 0xBF, 0x98, 0x85, +0xD6, 0xCB, 0xEC, 0xF1, 0x13, 0x0E, 0x29, 0x34, 0x67, 0x7A, 0x5D, 0x40, +0xFB, 0xE6, 0xC1, 0xDC, 0x8F, 0x92, 0xB5, 0xA8, 0xDE, 0xC3, 0xE4, 0xF9, +0xAA, 0xB7, 0x90, 0x8D, 0x36, 0x2B, 0x0C, 0x11, 0x42, 0x5F, 0x78, 0x65, +0x94, 0x89, 0xAE, 0xB3, 0xE0, 0xFD, 0xDA, 0xC7, 0x7C, 0x61, 0x46, 0x5B, +0x08, 0x15, 0x32, 0x2F, 0x59, 0x44, 0x63, 0x7E, 0x2D, 0x30,
Re: [FFmpeg-devel] [PATCH 1/9] crc: add AV_CRC_8_SBC as a 8 bits CRC with polynomial 0x1D
On 12/23/2017 3:01 PM, Aurelien Jacobs wrote: > --- > libavutil/crc.c | 26 ++ > libavutil/crc.h | 1 + > libavutil/tests/crc.c | 7 --- > tests/ref/fate/crc| 1 + > 4 files changed, 32 insertions(+), 3 deletions(-) > > diff --git a/libavutil/crc.c b/libavutil/crc.c > index d44550c9c0..8e44a76ec8 100644 > --- a/libavutil/crc.c > +++ b/libavutil/crc.c > @@ -52,6 +52,30 @@ static const AVCRC av_crc_table[AV_CRC_MAX][257] = { > 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, > 0xEF, > 0xFA, 0xFD, 0xF4, 0xF3, 0x01 > }, > +[AV_CRC_8_SBC] = { > +0x00, 0x1D, 0x3A, 0x27, 0x74, 0x69, 0x4E, 0x53, 0xE8, 0xF5, 0xD2, > 0xCF, > +0x9C, 0x81, 0xA6, 0xBB, 0xCD, 0xD0, 0xF7, 0xEA, 0xB9, 0xA4, 0x83, > 0x9E, > +0x25, 0x38, 0x1F, 0x02, 0x51, 0x4C, 0x6B, 0x76, 0x87, 0x9A, 0xBD, > 0xA0, > +0xF3, 0xEE, 0xC9, 0xD4, 0x6F, 0x72, 0x55, 0x48, 0x1B, 0x06, 0x21, > 0x3C, > +0x4A, 0x57, 0x70, 0x6D, 0x3E, 0x23, 0x04, 0x19, 0xA2, 0xBF, 0x98, > 0x85, > +0xD6, 0xCB, 0xEC, 0xF1, 0x13, 0x0E, 0x29, 0x34, 0x67, 0x7A, 0x5D, > 0x40, > +0xFB, 0xE6, 0xC1, 0xDC, 0x8F, 0x92, 0xB5, 0xA8, 0xDE, 0xC3, 0xE4, > 0xF9, > +0xAA, 0xB7, 0x90, 0x8D, 0x36, 0x2B, 0x0C, 0x11, 0x42, 0x5F, 0x78, > 0x65, > +0x94, 0x89, 0xAE, 0xB3, 0xE0, 0xFD, 0xDA, 0xC7, 0x7C, 0x61, 0x46, > 0x5B, > +0x08, 0x15, 0x32, 0x2F, 0x59, 0x44, 0x63, 0x7E, 0x2D, 0x30, 0x17, > 0x0A, > +0xB1, 0xAC, 0x8B, 0x96, 0xC5, 0xD8, 0xFF, 0xE2, 0x26, 0x3B, 0x1C, > 0x01, > +0x52, 0x4F, 0x68, 0x75, 0xCE, 0xD3, 0xF4, 0xE9, 0xBA, 0xA7, 0x80, > 0x9D, > +0xEB, 0xF6, 0xD1, 0xCC, 0x9F, 0x82, 0xA5, 0xB8, 0x03, 0x1E, 0x39, > 0x24, > +0x77, 0x6A, 0x4D, 0x50, 0xA1, 0xBC, 0x9B, 0x86, 0xD5, 0xC8, 0xEF, > 0xF2, > +0x49, 0x54, 0x73, 0x6E, 0x3D, 0x20, 0x07, 0x1A, 0x6C, 0x71, 0x56, > 0x4B, > +0x18, 0x05, 0x22, 0x3F, 0x84, 0x99, 0xBE, 0xA3, 0xF0, 0xED, 0xCA, > 0xD7, > +0x35, 0x28, 0x0F, 0x12, 0x41, 0x5C, 0x7B, 0x66, 0xDD, 0xC0, 0xE7, > 0xFA, > +0xA9, 0xB4, 0x93, 0x8E, 0xF8, 0xE5, 0xC2, 0xDF, 0x8C, 0x91, 0xB6, > 0xAB, > +0x10, 0x0D, 0x2A, 0x37, 0x64, 0x79, 0x5E, 0x43, 0xB2, 0xAF, 0x88, > 0x95, > +0xC6, 0xDB, 0xFC, 0xE1, 0x5A, 0x47, 0x60, 0x7D, 0x2E, 0x33, 0x14, > 0x09, > +0x7F, 0x62, 0x45, 0x58, 0x0B, 0x16, 0x31, 0x2C, 0x97, 0x8A, 0xAD, > 0xB0, > +0xE3, 0xFE, 0xD9, 0xC4, 0x01 > +}, > [AV_CRC_16_ANSI] = { > 0x, 0x0580, 0x0F80, 0x0A00, 0x1B80, 0x1E00, 0x1400, 0x1180, > 0x3380, 0x3600, 0x3C00, 0x3980, 0x2800, 0x2D80, 0x2780, 0x2200, > @@ -305,6 +329,7 @@ static void id ## _init_table_once(void) > #define CRC_INIT_TABLE_ONCE(id) ff_thread_once(&id ## _once_control, id ## > _init_table_once) > > DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_8_ATM, 0, 8, 0x07) > +DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_8_SBC, 0, 8, 0x1D) The polynomial 0x1D seems to be used in a couple standards, including one defined by the European Broadcasting Union, so instead of _SBC which is a codec using the CRC, I'd use _EBU for the enum constant. This is public API, so once introduced it can't easily be changed. > DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_16_ANSI,0, 16, 0x8005) > DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_16_CCITT, 0, 16, 0x1021) > DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_24_IEEE,0, 24, 0x864CFB) > @@ -351,6 +376,7 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id) > #if !CONFIG_HARDCODED_TABLES > switch (crc_id) { > case AV_CRC_8_ATM: CRC_INIT_TABLE_ONCE(AV_CRC_8_ATM); break; > +case AV_CRC_8_SBC: CRC_INIT_TABLE_ONCE(AV_CRC_8_SBC); break; > case AV_CRC_16_ANSI:CRC_INIT_TABLE_ONCE(AV_CRC_16_ANSI); break; > case AV_CRC_16_CCITT: CRC_INIT_TABLE_ONCE(AV_CRC_16_CCITT); break; > case AV_CRC_24_IEEE:CRC_INIT_TABLE_ONCE(AV_CRC_24_IEEE); break; > diff --git a/libavutil/crc.h b/libavutil/crc.h > index fe9a7c8fcb..e57a1af903 100644 > --- a/libavutil/crc.h > +++ b/libavutil/crc.h > @@ -54,6 +54,7 @@ typedef enum { > AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */ > AV_CRC_16_ANSI_LE, /*< reversed bitorder version of AV_CRC_16_ANSI */ > AV_CRC_24_IEEE, > +AV_CRC_8_SBC, > AV_CRC_MAX, /*< Not part of public API! Do not use outside > libavutil. */ > }AVCRCId; > > diff --git a/libavutil/tests/crc.c b/libavutil/tests/crc.c > index 9825d6bec9..3fdc335cc3 100644 > --- a/libavutil/tests/crc.c > +++ b/libavutil/tests/crc.c > @@ -25,20 +25,21 @@ int main(void) > { > uint8_t buf[1999]; > int i; > -static const unsigned p[6][3] = { > +static const unsigned p[7][3] = { > { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 }, > { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 }, > { AV_CRC_24_IEEE , 0x864CFB , 0xB704CE }, > { AV_CRC_16_ANSI_LE, 0xA001, 0xBFD8 }, >
Re: [FFmpeg-devel] ffmpeg fails to compile CentOS 7
On Thu, Nov 30, 2017 at 12:38:36 -0500, PUPCo Studios wrote: > I have been working for a week to look for a solution that would allow me to > compile ffmpeg and associated encoders from the ffmpeg wiki tutorial page > with no success. I have covered everything, new OS to changes to the > compilation directions from the tutorial. I am using CentOS 7 updated and > the only way I have ever been able to get it to maybe compile is to borrow > a fix from an Ubuntu script. This question belongs onto the ffmpeg-user mailing list. > This is where the ffmpeg compile halts on: > > ERROR: libmp3lame >= 3.98.3 not found This was bug #6918, and should be fixed: https://trac.ffmpeg.org/ticket/6918 > sed -i -e 's/\(3.98.3..lame.lame.h.lame.set.VBR.quality..lmp3lame\)/\1 -lm/' Wow, what a fragile regex and a bad way to add extra flags. ./configure provides its own method, so --extra-cflags="-lm" should have sufficed. > This allows the compile process to go further, but then ends up causing a > time skew issue which I could only fix by touch command as follows: A time skew is an issue of your system, not caused by ./configure or make. > find /root -type f -exec touch {} + Why /root? Is that directory name chosen arbitrarily? Or is it user "root"'s home directory? I hope not. > I have in the past made tutorials for compiling ffmpeg with a multitude of > encoder support (which of course that guide fails in the same way during the > fffmpeg compiling ) so I am no stranger to having to fix the tutorial with > workarounds and such and I am now not even compiling anything as shared as > the point of installing ffmpeg which is to install ffmpeg-php also. I truly hope your tutorials don't suggest users to compile stuff as user ID "root". > Attached is my ffbuild/config.log at which point the compile fails with > ERROR: libmp3lame >= 3.98.3 not found As mentioned, should be fixed. Please try latest master HEAD. Cheers, Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 7/9] sbcenc: add MMX optimizations
On 12/23/2017 3:01 PM, Aurelien Jacobs wrote: > This was originally based on libsbc, and was fully integrated into ffmpeg. > > Rough speed test: > C version:speed= 592x > MMX version: speed= 785x > --- > libavcodec/sbcdsp.c | 3 + > libavcodec/sbcdsp.h | 2 + > libavcodec/x86/Makefile | 2 + > libavcodec/x86/sbcdsp.asm| 284 > +++ > libavcodec/x86/sbcdsp_init.c | 51 > 5 files changed, 342 insertions(+) > create mode 100644 libavcodec/x86/sbcdsp.asm > create mode 100644 libavcodec/x86/sbcdsp_init.c [...] > +;*** > +;void ff_sbc_calc_scalefactors(int32_t sb_sample_f[16][2][8], > +; uint32_t scale_factor[2][8], > +; int blocks, int channels, int subbands) > +;*** > +INIT_MMX mmx > +cglobal sbc_calc_scalefactors, 5, 7, 3, sb_sample_f, scale_factor, blocks, > channels, subbands, ptr, blk > +; subbands = 4 * subbands * channels > +shl subbandsd, 2 > +cmp channelsd, 2 > +jl .loop_1 > +shl subbandsd, 1 > + > +.loop_1: > +sub subbandsq, 8 > +lea ptrq, [sb_sample_fq + subbandsq] > + > +; blk = (blocks - 1) * 64; > +lea blkq, [blocksq - 1] > +shl blkd, 6 > + > +movq m0, [scale_mask] I insist, this can be easily loaded outside the loop. You have enough spare regs to store a copy. In any case, the patch looks good regardless of the above. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 8/9] sbcenc: add armv6 and neon asm optimizations
This was originally based on libsbc, and was fully integrated into ffmpeg. --- libavcodec/arm/Makefile | 3 + libavcodec/arm/sbcdsp_armv6.S| 245 ++ libavcodec/arm/sbcdsp_init_arm.c | 105 ++ libavcodec/arm/sbcdsp_neon.S | 714 +++ libavcodec/sbcdsp.c | 2 + libavcodec/sbcdsp.h | 1 + 6 files changed, 1070 insertions(+) create mode 100644 libavcodec/arm/sbcdsp_armv6.S create mode 100644 libavcodec/arm/sbcdsp_init_arm.c create mode 100644 libavcodec/arm/sbcdsp_neon.S diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile index 1eeac5449e..fd2401f4e5 100644 --- a/libavcodec/arm/Makefile +++ b/libavcodec/arm/Makefile @@ -42,6 +42,7 @@ OBJS-$(CONFIG_DCA_DECODER) += arm/synth_filter_init_arm.o OBJS-$(CONFIG_HEVC_DECODER)+= arm/hevcdsp_init_arm.o OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_init_arm.o OBJS-$(CONFIG_RV40_DECODER)+= arm/rv40dsp_init_arm.o +OBJS-$(CONFIG_SBC_ENCODER) += arm/sbcdsp_init_arm.o OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_init_arm.o OBJS-$(CONFIG_VP6_DECODER) += arm/vp6dsp_init_arm.o OBJS-$(CONFIG_VP9_DECODER) += arm/vp9dsp_init_10bpp_arm.o \ @@ -81,6 +82,7 @@ ARMV6-OBJS-$(CONFIG_VP8DSP)+= arm/vp8_armv6.o \ # decoders/encoders ARMV6-OBJS-$(CONFIG_MLP_DECODER) += arm/mlpdsp_armv6.o +ARMV6-OBJS-$(CONFIG_SBC_ENCODER) += arm/sbcdsp_armv6.o # VFP optimizations @@ -140,6 +142,7 @@ NEON-OBJS-$(CONFIG_HEVC_DECODER) += arm/hevcdsp_init_neon.o \ NEON-OBJS-$(CONFIG_RV30_DECODER) += arm/rv34dsp_neon.o NEON-OBJS-$(CONFIG_RV40_DECODER) += arm/rv34dsp_neon.o\ arm/rv40dsp_neon.o +NEON-OBJS-$(CONFIG_SBC_ENCODER)+= arm/sbcdsp_neon.o NEON-OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_neon.o NEON-OBJS-$(CONFIG_VP6_DECODER)+= arm/vp6dsp_neon.o NEON-OBJS-$(CONFIG_VP9_DECODER)+= arm/vp9itxfm_16bpp_neon.o \ diff --git a/libavcodec/arm/sbcdsp_armv6.S b/libavcodec/arm/sbcdsp_armv6.S new file mode 100644 index 00..f1ff845798 --- /dev/null +++ b/libavcodec/arm/sbcdsp_armv6.S @@ -0,0 +1,245 @@ +/* + * Bluetooth low-complexity, subband codec (SBC) + * + * Copyright (C) 2017 Aurelien Jacobs + * Copyright (C) 2008-2010 Nokia Corporation + * Copyright (C) 2004-2010 Marcel Holtmann + * Copyright (C) 2004-2005 Henryk Ploetz + * Copyright (C) 2005-2006 Brad Midgley + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * SBC ARMv6 optimizations. The instructions are scheduled for ARM11 pipeline. + */ + +#include "libavutil/arm/asm.S" + +function ff_sbc_analyze_4_armv6, export=1 +@ r0 = in, r1 = out, r2 = consts +push{r1, r3-r7, lr} +push{r8-r12, r14} +ldrdr4, r5, [r0, #0] +ldrdr6, r7, [r2, #0] +ldrdr8, r9, [r0, #16] +ldrdr10, r11, [r2, #16] +mov r14, #0x8000 +smlad r3, r4, r6, r14 +smlad r12, r5, r7, r14 +ldrdr4, r5, [r0, #32] +ldrdr6, r7, [r2, #32] +smlad r3, r8, r10, r3 +smlad r12, r9, r11, r12 +ldrdr8, r9, [r0, #48] +ldrdr10, r11, [r2, #48] +smlad r3, r4, r6, r3 +smlad r12, r5, r7, r12 +ldrdr4, r5, [r0, #64] +ldrdr6, r7, [r2, #64] +smlad r3, r8, r10, r3 +smlad r12, r9, r11, r12 +ldrdr8, r9, [r0, #8] +ldrdr10, r11, [r2, #8] +smlad r3, r4, r6, r3@ t1[0] is done +smlad r12, r5, r7, r12 @ t1[1] is done +ldrdr4, r5, [r0, #24] +ldrdr6, r7, [r2, #24] +pkhtb r3, r12, r3, asr #16@ combine t1[0] and t1[1] +smlad r12, r8, r10, r14 +smlad r14, r9, r11, r14 +ldrd
[FFmpeg-devel] [PATCH 7/9] sbcenc: add MMX optimizations
This was originally based on libsbc, and was fully integrated into ffmpeg. Rough speed test: C version:speed= 592x MMX version: speed= 785x --- libavcodec/sbcdsp.c | 3 + libavcodec/sbcdsp.h | 2 + libavcodec/x86/Makefile | 2 + libavcodec/x86/sbcdsp.asm| 284 +++ libavcodec/x86/sbcdsp_init.c | 51 5 files changed, 342 insertions(+) create mode 100644 libavcodec/x86/sbcdsp.asm create mode 100644 libavcodec/x86/sbcdsp_init.c diff --git a/libavcodec/sbcdsp.c b/libavcodec/sbcdsp.c index e155387f0d..2d0addcf28 100644 --- a/libavcodec/sbcdsp.c +++ b/libavcodec/sbcdsp.c @@ -379,4 +379,7 @@ av_cold void ff_sbcdsp_init(SBCDSPContext *s) /* Default implementation for scale factors calculation */ s->sbc_calc_scalefactors = sbc_calc_scalefactors; s->sbc_calc_scalefactors_j = sbc_calc_scalefactors_j; + +if (ARCH_X86) +ff_sbcdsp_init_x86(s); } diff --git a/libavcodec/sbcdsp.h b/libavcodec/sbcdsp.h index 66ed7d324e..127e6a8a11 100644 --- a/libavcodec/sbcdsp.h +++ b/libavcodec/sbcdsp.h @@ -80,4 +80,6 @@ struct sbc_dsp_context { */ void ff_sbcdsp_init(SBCDSPContext *s); +void ff_sbcdsp_init_x86(SBCDSPContext *s); + #endif /* AVCODEC_SBCDSP_H */ diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index a805cd37b4..2350c8bbee 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -63,6 +63,7 @@ OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp_init.o OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp_init.o OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp_init.o OBJS-$(CONFIG_RV40_DECODER)+= x86/rv40dsp_init.o +OBJS-$(CONFIG_SBC_ENCODER) += x86/sbcdsp_init.o OBJS-$(CONFIG_SVQ1_ENCODER)+= x86/svq1enc_init.o OBJS-$(CONFIG_TAK_DECODER) += x86/takdsp_init.o OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp_init.o @@ -172,6 +173,7 @@ X86ASM-OBJS-$(CONFIG_PNG_DECODER) += x86/pngdsp.o X86ASM-OBJS-$(CONFIG_PRORES_DECODER) += x86/proresdsp.o X86ASM-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp.o X86ASM-OBJS-$(CONFIG_RV40_DECODER) += x86/rv40dsp.o +X86ASM-OBJS-$(CONFIG_SBC_ENCODER) += x86/sbcdsp.o X86ASM-OBJS-$(CONFIG_SVQ1_ENCODER) += x86/svq1enc.o X86ASM-OBJS-$(CONFIG_TAK_DECODER) += x86/takdsp.o X86ASM-OBJS-$(CONFIG_TRUEHD_DECODER) += x86/mlpdsp.o diff --git a/libavcodec/x86/sbcdsp.asm b/libavcodec/x86/sbcdsp.asm new file mode 100644 index 00..0538705fb7 --- /dev/null +++ b/libavcodec/x86/sbcdsp.asm @@ -0,0 +1,284 @@ +;** +;* SIMD optimized SBC encoder DSP functions +;* +;* Copyright (C) 2017 Aurelien Jacobs +;* Copyright (C) 2008-2010 Nokia Corporation +;* Copyright (C) 2004-2010 Marcel Holtmann +;* Copyright (C) 2004-2005 Henryk Ploetz +;* Copyright (C) 2005-2006 Brad Midgley +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;** + +%include "libavutil/x86/x86util.asm" + +SECTION_RODATA + +scale_mask: times 2 dd 0x8000; 1 << (SBC_PROTO_FIXED_SCALE - 1) + +SECTION .text + +;*** +;void ff_sbc_analyze_4(const int16_t *in, int32_t *out, const int16_t *consts); +;*** +INIT_MMX mmx +cglobal sbc_analyze_4, 3, 3, 4, in, out, consts +movq m0, [inq] +movq m1, [inq+8] +pmaddwd m0, [constsq] +pmaddwd m1, [constsq+8] +paddd m0, [scale_mask] +paddd m1, [scale_mask] + +movq m2, [inq+16] +movq m3, [inq+24] +pmaddwd m2, [constsq+16] +pmaddwd m3, [constsq+24] +paddd m0, m2 +paddd m1, m3 + +movq m2, [inq+32] +movq m3, [inq+40] +pmaddwd m2, [constsq+32] +pmaddwd m3, [constsq+40] +paddd m0, m2 +paddd m1, m3 + +movq m2, [inq+48] +movq m3, [inq+56] +pmaddwd m2, [constsq+48] +pmaddwd m3, [constsq+56] +paddd m0, m2 +paddd
[FFmpeg-devel] [PATCH 9/9] Changelog: list the new SBC codec
--- Changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/Changelog b/Changelog index ee48876128..4a98884a3c 100644 --- a/Changelog +++ b/Changelog @@ -27,6 +27,7 @@ version : - video setrange filter - nsp demuxer - support LibreSSL (via libtls) +- native SBC and mSBC encoder and decoder version 3.4: -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 6/9] sbc: add raw muxer for SBC
--- doc/general.texi | 2 +- libavformat/Makefile | 2 ++ libavformat/allformats.c | 4 ++-- libavformat/rawenc.c | 28 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/doc/general.texi b/doc/general.texi index e5669b0e93..560465a4b8 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -466,7 +466,7 @@ library: @item raw NULL @tab X @tab @item raw video @tab X @tab X @item raw id RoQ@tab X @tab -@item raw SBC @tab @tab X +@item raw SBC @tab X @tab X @item raw Shorten @tab @tab X @item raw TAK @tab @tab X @item raw TrueHD@tab X @tab X diff --git a/libavformat/Makefile b/libavformat/Makefile index 6270c28a8a..689fc6b23f 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -448,7 +448,9 @@ OBJS-$(CONFIG_SAMI_DEMUXER) += samidec.o subtitles.o OBJS-$(CONFIG_SAP_DEMUXER) += sapdec.o OBJS-$(CONFIG_SAP_MUXER) += sapenc.o OBJS-$(CONFIG_SBC_DEMUXER) += sbcdec.o rawdec.o +OBJS-$(CONFIG_SBC_MUXER) += rawenc.o OBJS-$(CONFIG_MSBC_DEMUXER) += sbcdec.o rawdec.o +OBJS-$(CONFIG_MSBC_MUXER)+= rawenc.o OBJS-$(CONFIG_SBG_DEMUXER) += sbgdec.o OBJS-$(CONFIG_SCC_DEMUXER) += sccdec.o subtitles.o OBJS-$(CONFIG_SCC_MUXER) += sccenc.o subtitles.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index a6b72715bd..eb1d17d38c 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -211,7 +211,7 @@ static void register_all(void) REGISTER_MUXDEMUX(MPJPEG, mpjpeg); REGISTER_DEMUXER (MPL2, mpl2); REGISTER_DEMUXER (MPSUB,mpsub); -REGISTER_DEMUXER (MSBC, msbc); +REGISTER_MUXDEMUX(MSBC, msbc); REGISTER_DEMUXER (MSF, msf); REGISTER_DEMUXER (MSNWC_TCP,msnwc_tcp); REGISTER_DEMUXER (MTAF, mtaf); @@ -278,7 +278,7 @@ static void register_all(void) REGISTER_DEMUXER (S337M,s337m); REGISTER_DEMUXER (SAMI, sami); REGISTER_MUXDEMUX(SAP, sap); -REGISTER_DEMUXER (SBC, sbc); +REGISTER_MUXDEMUX(SBC, sbc); REGISTER_DEMUXER (SBG, sbg); REGISTER_MUXDEMUX(SCC, scc); REGISTER_DEMUXER (SDP, sdp); diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c index aa3ef76fbf..e27b280014 100644 --- a/libavformat/rawenc.c +++ b/libavformat/rawenc.c @@ -426,6 +426,34 @@ AVOutputFormat ff_rawvideo_muxer = { }; #endif +#if CONFIG_SBC_MUXER +AVOutputFormat ff_sbc_muxer = { +.name = "sbc", +.long_name = NULL_IF_CONFIG_SMALL("raw SBC"), +.mime_type = "audio/x-sbc", +.extensions= "sbc", +.audio_codec = AV_CODEC_ID_SBC, +.video_codec = AV_CODEC_ID_NONE, +.write_header = force_one_stream, +.write_packet = ff_raw_write_packet, +.flags = AVFMT_NOTIMESTAMPS, +}; +#endif + +#if CONFIG_MSBC_MUXER +AVOutputFormat ff_msbc_muxer = { +.name = "msbc", +.long_name = NULL_IF_CONFIG_SMALL("raw mSBC"), +.mime_type = "audio/x-msbc", +.extensions= "msbc", +.audio_codec = AV_CODEC_ID_MSBC, +.video_codec = AV_CODEC_ID_NONE, +.write_header = force_one_stream, +.write_packet = ff_raw_write_packet, +.flags = AVFMT_NOTIMESTAMPS, +}; +#endif + #if CONFIG_TRUEHD_MUXER AVOutputFormat ff_truehd_muxer = { .name = "truehd", -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 5/9] sbc: implement SBC encoder (low-complexity subband codec)
This was originally based on libsbc, and was fully integrated into ffmpeg. --- doc/general.texi | 2 +- libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 4 +- libavcodec/sbcdsp.c | 382 libavcodec/sbcdsp.h | 83 + libavcodec/sbcdsp_data.c | 329 +++ libavcodec/sbcdsp_data.h | 55 ++ libavcodec/sbcenc.c | 443 +++ 8 files changed, 1297 insertions(+), 3 deletions(-) create mode 100644 libavcodec/sbcdsp.c create mode 100644 libavcodec/sbcdsp.h create mode 100644 libavcodec/sbcdsp_data.c create mode 100644 libavcodec/sbcdsp_data.h create mode 100644 libavcodec/sbcenc.c diff --git a/doc/general.texi b/doc/general.texi index 65aee47f2a..e5669b0e93 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1103,7 +1103,7 @@ following image formats are supported: @tab Real low bitrate AC-3 codec @item RealAudio Lossless @tab @tab X @item RealAudio SIPR / ACELP.NET @tab @tab X -@item SBC (low-complexity subband codec) @tab @tab X +@item SBC (low-complexity subband codec) @tab X @tab X @tab Used in Bluetooth A2DP @item Shorten@tab @tab X @item Sierra VMD audio @tab @tab X diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 58c8c6e499..d237deeefc 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -582,7 +582,9 @@ OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o OBJS-$(CONFIG_LIBRSVG_DECODER) += librsvgdec.o OBJS-$(CONFIG_SBC_DECODER) += sbcdec.o sbcdec_data.o sbc.o +OBJS-$(CONFIG_SBC_ENCODER) += sbcenc.o sbc.o sbcdsp.o sbcdsp_data.o OBJS-$(CONFIG_MSBC_DECODER)+= sbcdec.o sbcdec_data.o sbc.o +OBJS-$(CONFIG_MSBC_ENCODER)+= sbcenc.o sbc.o sbcdsp.o sbcdsp_data.o OBJS-$(CONFIG_SVQ1_DECODER)+= svq1dec.o svq1.o svq13.o h263data.o OBJS-$(CONFIG_SVQ1_ENCODER)+= svq1enc.o svq1.o h263data.o \ h263.o ituh263enc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 3e3b37f638..e5b3c20ec7 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -379,7 +379,7 @@ static void register_all(void) REGISTER_DECODER(MP3ON4FLOAT, mp3on4float); REGISTER_DECODER(MPC7, mpc7); REGISTER_DECODER(MPC8, mpc8); -REGISTER_DECODER(MSBC, msbc); +REGISTER_ENCDEC (MSBC, msbc); REGISTER_ENCDEC (NELLYMOSER,nellymoser); REGISTER_DECODER(ON2AVC,on2avc); REGISTER_ENCDEC (OPUS, opus); @@ -393,7 +393,7 @@ static void register_all(void) REGISTER_DECODER(SHORTEN, shorten); REGISTER_DECODER(SIPR, sipr); REGISTER_DECODER(SMACKAUD, smackaud); -REGISTER_DECODER(SBC, sbc); +REGISTER_ENCDEC (SBC, sbc); REGISTER_ENCDEC (SONIC, sonic); REGISTER_ENCODER(SONIC_LS, sonic_ls); REGISTER_DECODER(TAK, tak); diff --git a/libavcodec/sbcdsp.c b/libavcodec/sbcdsp.c new file mode 100644 index 00..e155387f0d --- /dev/null +++ b/libavcodec/sbcdsp.c @@ -0,0 +1,382 @@ +/* + * Bluetooth low-complexity, subband codec (SBC) + * + * Copyright (C) 2017 Aurelien Jacobs + * Copyright (C) 2012-2013 Intel Corporation + * Copyright (C) 2008-2010 Nokia Corporation + * Copyright (C) 2004-2010 Marcel Holtmann + * Copyright (C) 2004-2005 Henryk Ploetz + * Copyright (C) 2005-2006 Brad Midgley + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * SBC basic "building bricks" + */ + +#include +#include +#include +#include "libavutil/common.h" +#include "libavutil/intmath.h" +#include "libavutil/intreadwrite.h" +#include "sbc.h" +#include "sbcdsp.h" +#include "sbcdsp_data.h" + +/* + * A reference C code of analysis filter with SIMD-friendly tables + * reordering and code layout. This code can be used to develop platform + * specific SIMD optimizations. Also it may be used as some kind of test + * for compiler autovectorizatio
[FFmpeg-devel] [PATCH 3/9] sbc: add parser for SBC
--- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/sbc_parser.c | 124 3 files changed, 126 insertions(+) create mode 100644 libavcodec/sbc_parser.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index c46d102227..58c8c6e499 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1012,6 +1012,7 @@ OBJS-$(CONFIG_PNG_PARSER) += png_parser.o OBJS-$(CONFIG_PNM_PARSER) += pnm_parser.o pnm.o OBJS-$(CONFIG_RV30_PARSER) += rv34_parser.o OBJS-$(CONFIG_RV40_PARSER) += rv34_parser.o +OBJS-$(CONFIG_SBC_PARSER) += sbc_parser.o OBJS-$(CONFIG_SIPR_PARSER) += sipr_parser.o OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 9e2480d2d4..3e3b37f638 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -653,6 +653,7 @@ static void register_all(void) REGISTER_PARSER(PNM,pnm); REGISTER_PARSER(RV30, rv30); REGISTER_PARSER(RV40, rv40); +REGISTER_PARSER(SBC,sbc); REGISTER_PARSER(SIPR, sipr); REGISTER_PARSER(TAK,tak); REGISTER_PARSER(VC1,vc1); diff --git a/libavcodec/sbc_parser.c b/libavcodec/sbc_parser.c new file mode 100644 index 00..032f72cf2b --- /dev/null +++ b/libavcodec/sbc_parser.c @@ -0,0 +1,124 @@ +/* + * SBC parser + * + * Copyright (C) 2017 Aurelien Jacobs + * + * 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 "sbc.h" +#include "parser.h" + +typedef struct SBCParseContext { +ParseContext pc; +uint8_t header[3]; +int header_size; +int buffered_size; +} SBCParseContext; + +static int sbc_parse_header(AVCodecParserContext *s, AVCodecContext *avctx, +const uint8_t *data, size_t len) +{ +static const int sample_rates[4] = { 16000, 32000, 44100, 48000 }; +int sr, blocks, mode, subbands, bitpool, channels, joint; +int length; + +if (len < 3) +return -1; + +if (data[0] == MSBC_SYNCWORD && data[1] == 0 && data[2] == 0) { +avctx->channels = 1; +avctx->sample_fmt = AV_SAMPLE_FMT_S16; +avctx->sample_rate = 16000; +avctx->frame_size = 120; +s->duration = avctx->frame_size; +return 57; +} + +if (data[0] != SBC_SYNCWORD) +return -2; + +sr = (data[1] >> 6) & 0x03; +blocks = (((data[1] >> 4) & 0x03) + 1) << 2; +mode = (data[1] >> 2) & 0x03; +subbands = (((data[1] >> 0) & 0x01) + 1) << 2; +bitpool = data[2]; + +channels = mode == SBC_MODE_MONO ? 1 : 2; +joint= mode == SBC_MODE_JOINT_STEREO; + +length = 4 + (subbands * channels) / 2; +if (channels == 1 || mode == SBC_MODE_DUAL_CHANNEL) +length += ((channels * blocks * bitpool) + 7) / 8; +else +length += (((joint ? subbands : 0) + blocks * bitpool) + 7) / 8; + +avctx->channels = channels; +avctx->sample_fmt = AV_SAMPLE_FMT_S16; +avctx->sample_rate = sample_rates[sr]; +avctx->frame_size = subbands * blocks; +s->duration = avctx->frame_size; +return length; +} + +static int sbc_parse(AVCodecParserContext *s, AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size) +{ +SBCParseContext *pc = s->priv_data; +int next; + +if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { +next = buf_size; +} else { +if (pc->header_size) { +memcpy(pc->header + pc->header_size, buf, + sizeof(pc->header) - pc->header_size); +next = sbc_parse_header(s, avctx, pc->header, sizeof(pc->header)) + - pc->buffered_size; +pc->header_size = 0; +} else { +next = sbc_parse_header(s, avctx, buf, buf_size); +if (next >= buf_size) +next = -1; +} + +if (next < 0) { +pc->header_size = FFMIN(sizeof(pc->header), buf_size); +mem
[FFmpeg-devel] [PATCH 1/9] crc: add AV_CRC_8_SBC as a 8 bits CRC with polynomial 0x1D
--- libavutil/crc.c | 26 ++ libavutil/crc.h | 1 + libavutil/tests/crc.c | 7 --- tests/ref/fate/crc| 1 + 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/libavutil/crc.c b/libavutil/crc.c index d44550c9c0..8e44a76ec8 100644 --- a/libavutil/crc.c +++ b/libavutil/crc.c @@ -52,6 +52,30 @@ static const AVCRC av_crc_table[AV_CRC_MAX][257] = { 0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB, 0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3, 0x01 }, +[AV_CRC_8_SBC] = { +0x00, 0x1D, 0x3A, 0x27, 0x74, 0x69, 0x4E, 0x53, 0xE8, 0xF5, 0xD2, 0xCF, +0x9C, 0x81, 0xA6, 0xBB, 0xCD, 0xD0, 0xF7, 0xEA, 0xB9, 0xA4, 0x83, 0x9E, +0x25, 0x38, 0x1F, 0x02, 0x51, 0x4C, 0x6B, 0x76, 0x87, 0x9A, 0xBD, 0xA0, +0xF3, 0xEE, 0xC9, 0xD4, 0x6F, 0x72, 0x55, 0x48, 0x1B, 0x06, 0x21, 0x3C, +0x4A, 0x57, 0x70, 0x6D, 0x3E, 0x23, 0x04, 0x19, 0xA2, 0xBF, 0x98, 0x85, +0xD6, 0xCB, 0xEC, 0xF1, 0x13, 0x0E, 0x29, 0x34, 0x67, 0x7A, 0x5D, 0x40, +0xFB, 0xE6, 0xC1, 0xDC, 0x8F, 0x92, 0xB5, 0xA8, 0xDE, 0xC3, 0xE4, 0xF9, +0xAA, 0xB7, 0x90, 0x8D, 0x36, 0x2B, 0x0C, 0x11, 0x42, 0x5F, 0x78, 0x65, +0x94, 0x89, 0xAE, 0xB3, 0xE0, 0xFD, 0xDA, 0xC7, 0x7C, 0x61, 0x46, 0x5B, +0x08, 0x15, 0x32, 0x2F, 0x59, 0x44, 0x63, 0x7E, 0x2D, 0x30, 0x17, 0x0A, +0xB1, 0xAC, 0x8B, 0x96, 0xC5, 0xD8, 0xFF, 0xE2, 0x26, 0x3B, 0x1C, 0x01, +0x52, 0x4F, 0x68, 0x75, 0xCE, 0xD3, 0xF4, 0xE9, 0xBA, 0xA7, 0x80, 0x9D, +0xEB, 0xF6, 0xD1, 0xCC, 0x9F, 0x82, 0xA5, 0xB8, 0x03, 0x1E, 0x39, 0x24, +0x77, 0x6A, 0x4D, 0x50, 0xA1, 0xBC, 0x9B, 0x86, 0xD5, 0xC8, 0xEF, 0xF2, +0x49, 0x54, 0x73, 0x6E, 0x3D, 0x20, 0x07, 0x1A, 0x6C, 0x71, 0x56, 0x4B, +0x18, 0x05, 0x22, 0x3F, 0x84, 0x99, 0xBE, 0xA3, 0xF0, 0xED, 0xCA, 0xD7, +0x35, 0x28, 0x0F, 0x12, 0x41, 0x5C, 0x7B, 0x66, 0xDD, 0xC0, 0xE7, 0xFA, +0xA9, 0xB4, 0x93, 0x8E, 0xF8, 0xE5, 0xC2, 0xDF, 0x8C, 0x91, 0xB6, 0xAB, +0x10, 0x0D, 0x2A, 0x37, 0x64, 0x79, 0x5E, 0x43, 0xB2, 0xAF, 0x88, 0x95, +0xC6, 0xDB, 0xFC, 0xE1, 0x5A, 0x47, 0x60, 0x7D, 0x2E, 0x33, 0x14, 0x09, +0x7F, 0x62, 0x45, 0x58, 0x0B, 0x16, 0x31, 0x2C, 0x97, 0x8A, 0xAD, 0xB0, +0xE3, 0xFE, 0xD9, 0xC4, 0x01 +}, [AV_CRC_16_ANSI] = { 0x, 0x0580, 0x0F80, 0x0A00, 0x1B80, 0x1E00, 0x1400, 0x1180, 0x3380, 0x3600, 0x3C00, 0x3980, 0x2800, 0x2D80, 0x2780, 0x2200, @@ -305,6 +329,7 @@ static void id ## _init_table_once(void) #define CRC_INIT_TABLE_ONCE(id) ff_thread_once(&id ## _once_control, id ## _init_table_once) DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_8_ATM, 0, 8, 0x07) +DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_8_SBC, 0, 8, 0x1D) DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_16_ANSI,0, 16, 0x8005) DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_16_CCITT, 0, 16, 0x1021) DECLARE_CRC_INIT_TABLE_ONCE(AV_CRC_24_IEEE,0, 24, 0x864CFB) @@ -351,6 +376,7 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id) #if !CONFIG_HARDCODED_TABLES switch (crc_id) { case AV_CRC_8_ATM: CRC_INIT_TABLE_ONCE(AV_CRC_8_ATM); break; +case AV_CRC_8_SBC: CRC_INIT_TABLE_ONCE(AV_CRC_8_SBC); break; case AV_CRC_16_ANSI:CRC_INIT_TABLE_ONCE(AV_CRC_16_ANSI); break; case AV_CRC_16_CCITT: CRC_INIT_TABLE_ONCE(AV_CRC_16_CCITT); break; case AV_CRC_24_IEEE:CRC_INIT_TABLE_ONCE(AV_CRC_24_IEEE); break; diff --git a/libavutil/crc.h b/libavutil/crc.h index fe9a7c8fcb..e57a1af903 100644 --- a/libavutil/crc.h +++ b/libavutil/crc.h @@ -54,6 +54,7 @@ typedef enum { AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */ AV_CRC_16_ANSI_LE, /*< reversed bitorder version of AV_CRC_16_ANSI */ AV_CRC_24_IEEE, +AV_CRC_8_SBC, AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */ }AVCRCId; diff --git a/libavutil/tests/crc.c b/libavutil/tests/crc.c index 9825d6bec9..3fdc335cc3 100644 --- a/libavutil/tests/crc.c +++ b/libavutil/tests/crc.c @@ -25,20 +25,21 @@ int main(void) { uint8_t buf[1999]; int i; -static const unsigned p[6][3] = { +static const unsigned p[7][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 }, { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 }, { AV_CRC_24_IEEE , 0x864CFB , 0xB704CE }, { AV_CRC_16_ANSI_LE, 0xA001, 0xBFD8 }, { AV_CRC_16_ANSI , 0x8005, 0x1FBB }, -{ AV_CRC_8_ATM , 0x07 , 0xE3 } +{ AV_CRC_8_ATM , 0x07 , 0xE3 }, +{ AV_CRC_8_SBC , 0x1D , 0xD6 }, }; const AVCRC *ctx; for (i = 0; i < sizeof(buf); i++) buf[i] = i + i * i; -for (i = 0; i < 6; i++) { +for (i = 0; i < 7; i++) { ctx = av_crc_get_table(p[i][0]); printf("crc %08X = %X\n", p[i][1], av_crc(ctx, 0, buf, sizeof(buf))); } diff --git a/tests/ref/fate/crc b/tests/ref/fate/crc i
[FFmpeg-devel] [PATCH 4/9] sbc: add raw demuxer for SBC
--- doc/general.texi | 1 + libavformat/Makefile | 2 ++ libavformat/allformats.c | 2 ++ libavformat/sbcdec.c | 47 +++ 4 files changed, 52 insertions(+) create mode 100644 libavformat/sbcdec.c diff --git a/doc/general.texi b/doc/general.texi index ed137f999f..65aee47f2a 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -466,6 +466,7 @@ library: @item raw NULL @tab X @tab @item raw video @tab X @tab X @item raw id RoQ@tab X @tab +@item raw SBC @tab @tab X @item raw Shorten @tab @tab X @item raw TAK @tab @tab X @item raw TrueHD@tab X @tab X diff --git a/libavformat/Makefile b/libavformat/Makefile index cb70eac920..6270c28a8a 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -447,6 +447,8 @@ OBJS-$(CONFIG_S337M_DEMUXER) += s337m.o spdif.o OBJS-$(CONFIG_SAMI_DEMUXER) += samidec.o subtitles.o OBJS-$(CONFIG_SAP_DEMUXER) += sapdec.o OBJS-$(CONFIG_SAP_MUXER) += sapenc.o +OBJS-$(CONFIG_SBC_DEMUXER) += sbcdec.o rawdec.o +OBJS-$(CONFIG_MSBC_DEMUXER) += sbcdec.o rawdec.o OBJS-$(CONFIG_SBG_DEMUXER) += sbgdec.o OBJS-$(CONFIG_SCC_DEMUXER) += sccdec.o subtitles.o OBJS-$(CONFIG_SCC_MUXER) += sccenc.o subtitles.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index 6a9b9883c9..a6b72715bd 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -211,6 +211,7 @@ static void register_all(void) REGISTER_MUXDEMUX(MPJPEG, mpjpeg); REGISTER_DEMUXER (MPL2, mpl2); REGISTER_DEMUXER (MPSUB,mpsub); +REGISTER_DEMUXER (MSBC, msbc); REGISTER_DEMUXER (MSF, msf); REGISTER_DEMUXER (MSNWC_TCP,msnwc_tcp); REGISTER_DEMUXER (MTAF, mtaf); @@ -277,6 +278,7 @@ static void register_all(void) REGISTER_DEMUXER (S337M,s337m); REGISTER_DEMUXER (SAMI, sami); REGISTER_MUXDEMUX(SAP, sap); +REGISTER_DEMUXER (SBC, sbc); REGISTER_DEMUXER (SBG, sbg); REGISTER_MUXDEMUX(SCC, scc); REGISTER_DEMUXER (SDP, sdp); diff --git a/libavformat/sbcdec.c b/libavformat/sbcdec.c new file mode 100644 index 00..a04a7c4328 --- /dev/null +++ b/libavformat/sbcdec.c @@ -0,0 +1,47 @@ +/* + * RAW SBC demuxer + * Copyright (C) 2017 Aurelien Jacobs + * + * 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 "avformat.h" +#include "rawdec.h" + +#if CONFIG_SBC_DEMUXER +AVInputFormat ff_sbc_demuxer = { +.name = "sbc", +.long_name = NULL_IF_CONFIG_SMALL("raw SBC (low-complexity subband codec)"), +.extensions = "sbc", +.raw_codec_id = AV_CODEC_ID_SBC, +.read_header= ff_raw_audio_read_header, +.read_packet= ff_raw_read_partial_packet, +.flags = AVFMT_GENERIC_INDEX, +}; +#endif + +#if CONFIG_MSBC_DEMUXER +AVInputFormat ff_msbc_demuxer = { +.name = "msbc", +.long_name = NULL_IF_CONFIG_SMALL("raw mSBC (wideband speech mono SBC)"), +.extensions = "msbc", +.raw_codec_id = AV_CODEC_ID_MSBC, +.read_header= ff_raw_audio_read_header, +.read_packet= ff_raw_read_partial_packet, +.flags = AVFMT_GENERIC_INDEX, +}; +#endif -- 2.15.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/9] sbc: implement SBC decoder (low-complexity subband codec)
This was originally based on libsbc, and was fully integrated into ffmpeg. --- doc/general.texi | 2 + libavcodec/Makefile | 2 + libavcodec/allcodecs.c | 2 + libavcodec/avcodec.h | 2 + libavcodec/codec_desc.c | 14 ++ libavcodec/sbc.c | 280 libavcodec/sbc.h | 121 libavcodec/sbcdec.c | 466 +++ libavcodec/sbcdec_data.c | 127 + libavcodec/sbcdec_data.h | 44 + 10 files changed, 1060 insertions(+) create mode 100644 libavcodec/sbc.c create mode 100644 libavcodec/sbc.h create mode 100644 libavcodec/sbcdec.c create mode 100644 libavcodec/sbcdec_data.c create mode 100644 libavcodec/sbcdec_data.h diff --git a/doc/general.texi b/doc/general.texi index 26919c9287..ed137f999f 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -1102,6 +1102,8 @@ following image formats are supported: @tab Real low bitrate AC-3 codec @item RealAudio Lossless @tab @tab X @item RealAudio SIPR / ACELP.NET @tab @tab X +@item SBC (low-complexity subband codec) @tab @tab X +@tab Used in Bluetooth A2DP @item Shorten@tab @tab X @item Sierra VMD audio @tab @tab X @tab Used in Sierra VMD files. diff --git a/libavcodec/Makefile b/libavcodec/Makefile index ca72138c02..c46d102227 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -581,6 +581,8 @@ OBJS-$(CONFIG_SUBVIEWER_DECODER) += subviewerdec.o ass.o OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o OBJS-$(CONFIG_SUNRAST_ENCODER) += sunrastenc.o OBJS-$(CONFIG_LIBRSVG_DECODER) += librsvgdec.o +OBJS-$(CONFIG_SBC_DECODER) += sbcdec.o sbcdec_data.o sbc.o +OBJS-$(CONFIG_MSBC_DECODER)+= sbcdec.o sbcdec_data.o sbc.o OBJS-$(CONFIG_SVQ1_DECODER)+= svq1dec.o svq1.o svq13.o h263data.o OBJS-$(CONFIG_SVQ1_ENCODER)+= svq1enc.o svq1.o h263data.o \ h263.o ituh263enc.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ed1e7ab06e..9e2480d2d4 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -379,6 +379,7 @@ static void register_all(void) REGISTER_DECODER(MP3ON4FLOAT, mp3on4float); REGISTER_DECODER(MPC7, mpc7); REGISTER_DECODER(MPC8, mpc8); +REGISTER_DECODER(MSBC, msbc); REGISTER_ENCDEC (NELLYMOSER,nellymoser); REGISTER_DECODER(ON2AVC,on2avc); REGISTER_ENCDEC (OPUS, opus); @@ -392,6 +393,7 @@ static void register_all(void) REGISTER_DECODER(SHORTEN, shorten); REGISTER_DECODER(SIPR, sipr); REGISTER_DECODER(SMACKAUD, smackaud); +REGISTER_DECODER(SBC, sbc); REGISTER_ENCDEC (SONIC, sonic); REGISTER_ENCODER(SONIC_LS, sonic_ls); REGISTER_DECODER(TAK, tak); diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index ce089b7c4a..5b7ec8541d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -634,6 +634,8 @@ enum AVCodecID { AV_CODEC_ID_ATRAC3PAL, AV_CODEC_ID_DOLBY_E, AV_CODEC_ID_APTX, +AV_CODEC_ID_SBC, +AV_CODEC_ID_MSBC, /* subtitle codecs */ AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index c3688de1d6..a69897d379 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2866,6 +2866,20 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("aptX (Audio Processing Technology for Bluetooth)"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_SBC, +.type = AVMEDIA_TYPE_AUDIO, +.name = "sbc", +.long_name = NULL_IF_CONFIG_SMALL("SBC (low-complexity subband codec)"), +.props = AV_CODEC_PROP_LOSSY, +}, +{ +.id= AV_CODEC_ID_MSBC, +.type = AVMEDIA_TYPE_AUDIO, +.name = "msbc", +.long_name = NULL_IF_CONFIG_SMALL("mSBC (wideband speech mono SBC)"), +.props = AV_CODEC_PROP_LOSSY, +}, /* subtitle codecs */ { diff --git a/libavcodec/sbc.c b/libavcodec/sbc.c new file mode 100644 index 00..af3e9a3fa8 --- /dev/null +++ b/libavcodec/sbc.c @@ -0,0 +1,280 @@ +/* + * Bluetooth low-complexity, subband codec (SBC) + * + * Copyright (C) 2017 Aurelien Jacobs + * Copyright (C) 2012-2013 Intel Corporation + * Copyright (C) 2008-2010 Nokia Corporation + * Copyright (C) 2004-2010 Marcel Holtmann + * Copyright (C) 2004-2005 Henryk Ploetz + * Copyright (C) 2005-2008 Brad Midgley + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms o
Re: [FFmpeg-devel] [PATCH 02/10] crc: add av_crc_bits() to compute CRC on block with bit boundary
On Thu, Dec 21, 2017 at 11:39:02AM +, Rostislav Pehlivanov wrote: > On 20 December 2017 at 19:58, Aurelien Jacobs wrote: > > > --- > > libavutil/crc.c | 20 > > libavutil/crc.h | 12 > > 2 files changed, 32 insertions(+) > > > > diff --git a/libavutil/crc.c b/libavutil/crc.c > > index 8e44a76ec8..cb26a09a20 100644 > > --- a/libavutil/crc.c > > +++ b/libavutil/crc.c > > @@ -413,3 +413,23 @@ uint32_t av_crc(const AVCRC *ctx, uint32_t crc, > > > > return crc; > > } > > + > > +uint32_t av_crc_bits(const AVCRC *ctx, uint32_t crc, > > + const uint8_t *buffer, size_t length) > > +{ > > +size_t byte_length = length >> 3; > > +int bit_length = length & 7; > > + > > +crc = av_crc(ctx, crc, buffer, byte_length); > > + > > +if (bit_length) { > > +uint8_t bits = buffer[byte_length]; > > +while (bit_length--) { > > +int8_t mask = (bits ^ crc); > > +crc = (crc << 1) ^ (ctx[1] & (mask >> 7)); > > +bits <<= 1; > > +} > > +} > > + > > +return crc; > > +} > > diff --git a/libavutil/crc.h b/libavutil/crc.h > > index e57a1af903..bde31f858a 100644 > > --- a/libavutil/crc.h > > +++ b/libavutil/crc.h > > @@ -86,6 +86,7 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id); > > /** > > * Calculate the CRC of a block. > > * @param crc CRC of previous blocks if any or initial value for CRC > > + * @param length number of bytes in the given block > > * @return CRC updated with the data from the given block > > * > > * @see av_crc_init() "le" parameter > > @@ -93,6 +94,17 @@ const AVCRC *av_crc_get_table(AVCRCId crc_id); > > uint32_t av_crc(const AVCRC *ctx, uint32_t crc, > > const uint8_t *buffer, size_t length) av_pure; > > > > +/** > > + * Calculate the CRC of a block with bits boundary. > > + * @param crc CRC of previous blocks if any or initial value for CRC > > + * @param length number of bits in the given block > > + * @return CRC updated with the data from the given block > > + * > > + * @see av_crc_init() "le" parameter > > + */ > > +uint32_t av_crc_bits(const AVCRC *ctx, uint32_t crc, > > + const uint8_t *buffer, size_t length) av_pure; > > + > > /** > > * @} > > */ > > > > ___ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > Sorry, I didn't see that sbc does fucked up crc on 7 bits. Well, it is not on 7 bits. That actual data length is a multiple of 4 bits. > In that case could you submit a new version of just the sbc patch which > adds this back in the decoder? I moved the function back to sbc, but I keept its usage of av_crc() for the whole buffer except for the last bits that don't form a full byte. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 08/10] sbcenc: add MMX optimizations
On Wed, Dec 20, 2017 at 10:22:54PM -0300, James Almer wrote: > On 12/20/2017 4:58 PM, Aurelien Jacobs wrote: > > +;*** > > +;void ff_sbc_calc_scalefactors(int32_t sb_sample_f[16][2][8], > > +; uint32_t scale_factor[2][8], > > +; int blocks, int channels, int subbands) > > +;*** > > +INIT_MMX mmx > > +cglobal sbc_calc_scalefactors, 5, 7, 3, sb_sample_f, scale_factor, blocks, > > channels, subbands, ptr, blk > > +; subbands = 4 * subbands * channels > > +shl subbandsq, 2 > > Again, shl subbandsd, 2 OK, good catch ! Fixed in upcoming patch. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 01/10] crc: add AV_CRC_8_SBC as a 8 bits CRC with polynomial 0x1D
On Thu, Dec 21, 2017 at 02:12:26AM +0100, Michael Niedermayer wrote: > On Wed, Dec 20, 2017 at 08:58:05PM +0100, Aurelien Jacobs wrote: > > --- > > libavutil/crc.c | 26 ++ > > libavutil/crc.h | 1 + > > libavutil/tests/crc.c | 7 --- > > 3 files changed, 31 insertions(+), 3 deletions(-) > > This needs a update for > tests/ref/fate/crc Oh, indeed, fixed. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc: add new API for iterating codecs and codec parsers
On Sat, 23 Dec 2017 13:27:53 + Josh de Kock wrote: > From 1d84641556eea563b82b17a6ffe54226e0e31c4e Mon Sep 17 00:00:00 2001 > From: Josh de Kock > Date: Fri, 22 Dec 2017 22:17:00 + > Subject: [PATCH] lavc: add new API for iterating codecs and codec parsers > > Also replace linked list with an array. > --- I generally agree with this patch. > configure | 14 +- > libavcodec/allcodecs.c | 1472 > > libavcodec/avcodec.h | 25 + > libavcodec/parser.c| 86 ++- > libavcodec/utils.c | 105 > 5 files changed, 962 insertions(+), 740 deletions(-) > > diff --git a/configure b/configure > index d09eec4..681fe10 100755 > --- a/configure > +++ b/configure > @@ -3517,9 +3517,6 @@ find_things(){ > sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" > "$file" > } > > -ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c) > -DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c) > -PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c) > MUXER_LIST=$(find_thingsmuxer_MUX libavformat/allformats.c) > DEMUXER_LIST=$(find_things demuxer DEMUXlibavformat/allformats.c) > OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c) > @@ -3533,6 +3530,13 @@ find_things_extern(){ > sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" > "$file" > } > > +ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c) > +DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c) > +CODEC_LIST=" > +$ENCODER_LIST > +$DECODER_LIST > +" > +PARSER_LIST=$(find_things_extern parser AVCodecParser libavcodec/parser.c) > BSF_LIST=$(find_things_extern bsf AVBitStreamFilter > libavcodec/bitstream_filters.c) > HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h) > PROTOCOL_LIST=$(find_things_extern protocol URLProtocol > libavformat/protocols.c) > @@ -7020,6 +7024,10 @@ print_enabled_components(){ > cp_if_changed $TMPH $file > } > > +print_enabled_components libavcodec/codec_list.c AVCodec codec_list > $CODEC_LIST > +#print_enabled_components libavcodec/encoder_list.c AVCodec encoder_list > $ENCODER_LIST > +#print_enabled_components libavcodec/decoder_list.c AVCodec decoder_list > $DECODER_LIST Commented leftover crap? > +print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list > $PARSER_LIST > print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter > bitstream_filters $BSF_LIST > print_enabled_components libavformat/protocol_list.c URLProtocol > url_protocols $PROTOCOL_LIST > > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c > index ed1e7ab..cea2bf3 100644 > --- a/libavcodec/allcodecs.c > +++ b/libavcodec/allcodecs.c > @@ -29,641 +29,865 @@ > #include "avcodec.h" > #include "version.h" > > -#define REGISTER_ENCODER(X, x) \ > -{ \ > -extern AVCodec ff_##x##_encoder;\ > -if (CONFIG_##X##_ENCODER) \ > -avcodec_register(&ff_##x##_encoder);\ > +extern AVCodec ff_a64multi_encoder; > [...] > > +#include "codec_list.c" > + > +#if CONFIG_ME_CMP > +#include "me_cmp.h" > +pthread_once_t ff_me_cmp_static_init = PTHREAD_ONCE_INIT; > +#endif > + > +pthread_once_t av_codec_next_init = PTHREAD_ONCE_INIT; > + > +const AVCodec *av_codec_iterate(void **opaque) > +{ > +uintptr_t i = (uintptr_t)*opaque; > +const AVCodec *c = codec_list[i]; > + > +if (c) > +*opaque = (void*)(i + 1); > + > +return c; > +} > + > +static void av_codec_init_next(void) > +{ > +AVCodec *prev = NULL, *p; > +void *i = 0; > +while ((p = (AVCodec*)av_codec_iterate(&i))) { > +if (prev) > +prev->next = p; > +prev = p; > } > +prev->next = NULL; > +} > > -#define REGISTER_DECODER(X, x) \ > -{ \ > -extern AVCodec ff_##x##_decoder;\ > -if (CONFIG_##X##_DECODER) \ > -avcodec_register(&ff_##x##_decoder);\ > +av_cold void avcodec_register(AVCodec *codec) > +{ This function, together with av_codec_next(), should be deprecated. Just adding attribute_deprecated isn't enough. You also need to add that FF_API_ ifdeffery soup (unfortunately). > +#if CONFIG_ME_CMP > +pthread_once(&ff_me_cmp_static_init, ff_me_cmp_init_static); > +#endif > + > +pthread_once(&av_codec_next_init, av_codec_init_next); > + > +if (codec->init_static_data) > +codec->init_static_data(codec); > +} As I stated below, this stuff shou
Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: improve compute target_duration way
On 12/23/17 8:02 PM, Steven Liu wrote: > > >> 在 2017年12月23日,下午6:38,Jeyapal, Karthick 写道: >> >> >>> On 12/23/17 4:59 AM, Steven Liu wrote: >>> just use lrint(lrint(duration * 10.0) / 10.0) >>> fix ticket: 6915 >>> >>> Suggested-by: beloko >>> Signed-off-by: Steven Liu >>> --- >>> libavformat/dashenc.c | 2 +- >>> libavformat/hlsenc.c | 2 +- >>> 2 files changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c >>> index 5368a2334c..102558d17e 100644 >>> --- a/libavformat/dashenc.c >>> +++ b/libavformat/dashenc.c >>> @@ -358,7 +358,7 @@ static void output_segment_list(OutputStream *os, >>> AVIOContext *out, DASHContext >>> Segment *seg = os->segments[i]; >>> double duration = (double) seg->duration / timescale; >>> if (target_duration <= duration) >>> -target_duration = lrint(duration); >>> +target_duration = lrint(lrint(duration * 10.0) / 10.0); >> This will just move the move the corner case from x.5 to x.45(x.46 depending >> on the double precision errors). Will not solve the original issue. >> For example, right now 1.5 is a corner case, as lrint(1.5) = 2, and >> lrint(1.49) = 1. >> After this patch, 1.46 will become the corner case. For example >> lrint(lrint(1.45 * 10.0) / 10.0) = 1 and lrint(lrint(1.46 * 10.0) / 10.0) = 2 >> When someone chooses a segment duration of 1.46, this issue will again >> resurface. > maybe you are right, and I use mediastreamvalidator check again, I focus the > error, when the media_0.m3u8 media_1.m3u8 EXT-X-TARGETDURATION different, it > no error of the two playlist, I think Roger response is right, maybe our > focus is not right. Look at your lrint patch, the test error context is not > target duration different error, and I have test use the code before your > patch , no target duration error of two playlist. Just fragment duration > error to target duration, look it again. As I said earlier, we need not focus on segment size being 1.5 or 1.45, as it is not a valid use-case. Even hlsenc does support only integral number of seconds as a configuration option(hls_time). According to me, right now there is no issue in ffmpeg w.r.t target duration as integer segment sizes are handled correctly. We can come back to this problem, when it really becomes a use-case and somebody reports this as an issue. As you might know, the older spec allowed only integer EXTINF durations as well. Later they added floating point duration as video and audio segments cannot always be cut at exactly at integral multiple of seconds, which was leading to accumulation of errors causing unexpected player behavior. My guess is floating point duration was added to avoid error accumulation, and not for supporting fractional segment sizes as a feature. As far I am aware, no popular video streaming service is using HLS with fractional segment durations like 1.5, 2.5 etc., All of them are using integral multiple of seconds as segment sizes. >> >> Thanks and regards, >> Karthick >>> } >>> >>> ff_hls_write_playlist_header(out_hls, 6, -1, target_duration, >>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c >>> index 0095ca4339..bf6f1d9253 100644 >>> --- a/libavformat/hlsenc.c >>> +++ b/libavformat/hlsenc.c >>> @@ -1235,7 +1235,7 @@ static int hls_window(AVFormatContext *s, int last, >>> VariantStream *vs) >>> >>> for (en = vs->segments; en; en = en->next) { >>> if (target_duration <= en->duration) >>> -target_duration = lrint(en->duration); >>> +target_duration = lrint(lrint(en->duration * 10.0) / 10.0); >>> } >>> >>> vs->discontinuity_set = 0; >> >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: improve compute target_duration way
> 在 2017年12月23日,下午6:38,Jeyapal, Karthick 写道: > > >> On 12/23/17 4:59 AM, Steven Liu wrote: >> just use lrint(lrint(duration * 10.0) / 10.0) >> fix ticket: 6915 >> >> Suggested-by: beloko >> Signed-off-by: Steven Liu >> --- >> libavformat/dashenc.c | 2 +- >> libavformat/hlsenc.c | 2 +- >> 2 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c >> index 5368a2334c..102558d17e 100644 >> --- a/libavformat/dashenc.c >> +++ b/libavformat/dashenc.c >> @@ -358,7 +358,7 @@ static void output_segment_list(OutputStream *os, >> AVIOContext *out, DASHContext >> Segment *seg = os->segments[i]; >> double duration = (double) seg->duration / timescale; >> if (target_duration <= duration) >> -target_duration = lrint(duration); >> +target_duration = lrint(lrint(duration * 10.0) / 10.0); > This will just move the move the corner case from x.5 to x.45(x.46 depending > on the double precision errors). Will not solve the original issue. > For example, right now 1.5 is a corner case, as lrint(1.5) = 2, and > lrint(1.49) = 1. > After this patch, 1.46 will become the corner case. For example > lrint(lrint(1.45 * 10.0) / 10.0) = 1 and lrint(lrint(1.46 * 10.0) / 10.0) = 2 > When someone chooses a segment duration of 1.46, this issue will again > resurface. maybe you are right, and I use mediastreamvalidator check again, I focus the error, when the media_0.m3u8 media_1.m3u8 EXT-X-TARGETDURATION different, it no error of the two playlist, I think Roger response is right, maybe our focus is not right. Look at your lrint patch, the test error context is not target duration different error, and I have test use the code before your patch , no target duration error of two playlist. Just fragment duration error to target duration, look it again. > > Thanks and regards, > Karthick >> } >> >> ff_hls_write_playlist_header(out_hls, 6, -1, target_duration, >> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c >> index 0095ca4339..bf6f1d9253 100644 >> --- a/libavformat/hlsenc.c >> +++ b/libavformat/hlsenc.c >> @@ -1235,7 +1235,7 @@ static int hls_window(AVFormatContext *s, int last, >> VariantStream *vs) >> >> for (en = vs->segments; en; en = en->next) { >> if (target_duration <= en->duration) >> -target_duration = lrint(en->duration); >> +target_duration = lrint(lrint(en->duration * 10.0) / 10.0); >> } >> >> vs->discontinuity_set = 0; > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] lavc: add new API for iterating codecs and codec parsers
This is the first patch to add the new API for iterating items within the libraries to lavc, this completes lavc's support for this API (BSFs were already using it). I'm currently working on a similar patch for lavfi, lavf and lavd. Note that I'm not entirely sure how to properly deprecate stuff so if that's incorrect some advice would be appreciated. -- Josh de Kock >From 1d84641556eea563b82b17a6ffe54226e0e31c4e Mon Sep 17 00:00:00 2001 From: Josh de Kock Date: Fri, 22 Dec 2017 22:17:00 + Subject: [PATCH] lavc: add new API for iterating codecs and codec parsers Also replace linked list with an array. --- configure | 14 +- libavcodec/allcodecs.c | 1472 libavcodec/avcodec.h | 25 + libavcodec/parser.c| 86 ++- libavcodec/utils.c | 105 5 files changed, 962 insertions(+), 740 deletions(-) diff --git a/configure b/configure index d09eec4..681fe10 100755 --- a/configure +++ b/configure @@ -3517,9 +3517,6 @@ find_things(){ sed -n "s/^[^#]*$pattern.*([^,]*, *\([^,]*\)\(,.*\)*).*/\1_$thing/p" "$file" } -ENCODER_LIST=$(find_things encoder ENC libavcodec/allcodecs.c) -DECODER_LIST=$(find_things decoder DEC libavcodec/allcodecs.c) -PARSER_LIST=$(find_things parser PARSER libavcodec/allcodecs.c) MUXER_LIST=$(find_thingsmuxer_MUX libavformat/allformats.c) DEMUXER_LIST=$(find_things demuxer DEMUXlibavformat/allformats.c) OUTDEV_LIST=$(find_things outdev OUTDEV libavdevice/alldevices.c) @@ -3533,6 +3530,13 @@ find_things_extern(){ sed -n "s/^[^#]*extern.*$pattern *ff_\([^ ]*\)_$thing;/\1_$thing/p" "$file" } +ENCODER_LIST=$(find_things_extern encoder AVCodec libavcodec/allcodecs.c) +DECODER_LIST=$(find_things_extern decoder AVCodec libavcodec/allcodecs.c) +CODEC_LIST=" +$ENCODER_LIST +$DECODER_LIST +" +PARSER_LIST=$(find_things_extern parser AVCodecParser libavcodec/parser.c) BSF_LIST=$(find_things_extern bsf AVBitStreamFilter libavcodec/bitstream_filters.c) HWACCEL_LIST=$(find_things_extern hwaccel AVHWAccel libavcodec/hwaccels.h) PROTOCOL_LIST=$(find_things_extern protocol URLProtocol libavformat/protocols.c) @@ -7020,6 +7024,10 @@ print_enabled_components(){ cp_if_changed $TMPH $file } +print_enabled_components libavcodec/codec_list.c AVCodec codec_list $CODEC_LIST +#print_enabled_components libavcodec/encoder_list.c AVCodec encoder_list $ENCODER_LIST +#print_enabled_components libavcodec/decoder_list.c AVCodec decoder_list $DECODER_LIST +print_enabled_components libavcodec/parser_list.c AVCodecParser parser_list $PARSER_LIST print_enabled_components libavcodec/bsf_list.c AVBitStreamFilter bitstream_filters $BSF_LIST print_enabled_components libavformat/protocol_list.c URLProtocol url_protocols $PROTOCOL_LIST diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index ed1e7ab..cea2bf3 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -29,641 +29,865 @@ #include "avcodec.h" #include "version.h" -#define REGISTER_ENCODER(X, x) \ -{ \ -extern AVCodec ff_##x##_encoder;\ -if (CONFIG_##X##_ENCODER) \ -avcodec_register(&ff_##x##_encoder);\ +extern AVCodec ff_a64multi_encoder; +extern AVCodec ff_a64multi5_encoder; +extern AVCodec ff_aasc_decoder; +extern AVCodec ff_aic_decoder; +extern AVCodec ff_alias_pix_encoder; +extern AVCodec ff_alias_pix_decoder; +extern AVCodec ff_amv_encoder; +extern AVCodec ff_amv_decoder; +extern AVCodec ff_anm_decoder; +extern AVCodec ff_ansi_decoder; +extern AVCodec ff_apng_encoder; +extern AVCodec ff_apng_decoder; +extern AVCodec ff_asv1_encoder; +extern AVCodec ff_asv1_decoder; +extern AVCodec ff_asv2_encoder; +extern AVCodec ff_asv2_decoder; +extern AVCodec ff_aura_decoder; +extern AVCodec ff_aura2_decoder; +extern AVCodec ff_avrp_encoder; +extern AVCodec ff_avrp_decoder; +extern AVCodec ff_avrn_decoder; +extern AVCodec ff_avs_decoder; +extern AVCodec ff_avui_encoder; +extern AVCodec ff_avui_decoder; +extern AVCodec ff_ayuv_encoder; +extern AVCodec ff_ayuv_decoder; +extern AVCodec ff_bethsoftvid_decoder; +extern AVCodec ff_bfi_decoder; +extern AVCodec ff_bink_decoder; +extern AVCodec ff_bmp_encoder; +extern AVCodec ff_bmp_decoder; +extern AVCodec ff_bmv_video_decoder; +extern AVCodec ff_brender_pix_decoder; +extern AVCodec ff_c93_decoder; +extern AVCodec ff_cavs_decoder; +extern AVCodec ff_cdgraphics_decoder; +extern AVCodec ff_cdxl_decoder; +extern AVCodec ff_cfhd_decoder; +extern AVCodec ff_cinepak_encoder; +extern AVCodec ff_cinepak_decoder; +extern AVCodec ff_clearvideo_decoder; +extern AVCodec ff_cljr_encoder; +extern AVCodec ff_cljr_decoder; +extern AVCodec ff_cllc_decoder; +extern AVCodec ff_comfortnoise_encoder; +extern AVCodec ff_comfortnoise_d
Re: [FFmpeg-devel] [PATCH 1/1] oma: move some constants into libavcodec
On Sat, Dec 23, 2017 at 13:42:51 +0800, mi...@brew.sh wrote: > --- a/Changelog > +++ b/Changelog > @@ -27,6 +27,7 @@ version : > - video setrange filter > - nsp demuxer > - support LibreSSL (via libtls) > +- Move some OMA constants from libavformat into libavcodec I believe such an internal change doesn't deserve a Changelog entry. Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 4/5] Fix detecting ATRAC3 audio from MPS files
On Fri, Dec 22, 2017 at 22:35:11 +0800, mi...@brew.sh wrote: > for PRIVATE_STREAM_1 sections, and doing the comparison on that > to find ATRAC-3 streams. In my testing, it works fine for both MPS > and PSMF files. I think this might be worth a small fate test, assuming small samples can be found and shared. Moritz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avfilter/vidstab: set bytesPerPixel only for packed formats.
Patch for ticket #6736. Regards, Gyan From a3161609f7e9a583506869df3da7a19e37629f32 Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Sat, 23 Dec 2017 16:14:25 +0530 Subject: [PATCH] avfilter/vidstab: set bytesPerPixel only for packed formats. libvidstab introduced this variable only for packed formats but in vf_vidstab*.c, it's set for all inputs. So the filter fails for YUV422/444P streams. Fixes #6736. --- libavfilter/vf_vidstabdetect.c| 3 ++- libavfilter/vf_vidstabtransform.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_vidstabdetect.c b/libavfilter/vf_vidstabdetect.c index 63a178a0c2..fd7ff3be24 100644 --- a/libavfilter/vf_vidstabdetect.c +++ b/libavfilter/vf_vidstabdetect.c @@ -107,10 +107,11 @@ static int config_input(AVFilterLink *inlink) VSMotionDetect* md = &(s->md); VSFrameInfo fi; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); +int is_planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR; vsFrameInfoInit(&fi, inlink->w, inlink->h, ff_av2vs_pixfmt(ctx, inlink->format)); -if (fi.bytesPerPixel != av_get_bits_per_pixel(desc)/8) { +if (!is_planar && fi.bytesPerPixel != av_get_bits_per_pixel(desc)/8) { av_log(ctx, AV_LOG_ERROR, "pixel-format error: wrong bits/per/pixel, please report a BUG"); return AVERROR(EINVAL); } diff --git a/libavfilter/vf_vidstabtransform.c b/libavfilter/vf_vidstabtransform.c index 11a0e3d512..d1ec1391cb 100644 --- a/libavfilter/vf_vidstabtransform.c +++ b/libavfilter/vf_vidstabtransform.c @@ -146,6 +146,7 @@ static int config_input(AVFilterLink *inlink) FILE *f; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); +int is_planar = desc->flags & AV_PIX_FMT_FLAG_PLANAR; VSTransformData *td = &(tc->td); @@ -161,7 +162,7 @@ static int config_input(AVFilterLink *inlink) return AVERROR(EINVAL); } -if (fi_src.bytesPerPixel != av_get_bits_per_pixel(desc)/8 || +if ((!is_planar && fi_src.bytesPerPixel != av_get_bits_per_pixel(desc)/8) || fi_src.log2ChromaW != desc->log2_chroma_w || fi_src.log2ChromaH != desc->log2_chroma_h) { av_log(ctx, AV_LOG_ERROR, "pixel-format error: bpp %i<>%i ", -- 2.11.1.windows.1___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/hlsenc: improve compute target_duration way
On 12/23/17 4:59 AM, Steven Liu wrote: > just use lrint(lrint(duration * 10.0) / 10.0) > fix ticket: 6915 > > Suggested-by: beloko > Signed-off-by: Steven Liu > --- > libavformat/dashenc.c | 2 +- > libavformat/hlsenc.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c > index 5368a2334c..102558d17e 100644 > --- a/libavformat/dashenc.c > +++ b/libavformat/dashenc.c > @@ -358,7 +358,7 @@ static void output_segment_list(OutputStream *os, > AVIOContext *out, DASHContext > Segment *seg = os->segments[i]; > double duration = (double) seg->duration / timescale; > if (target_duration <= duration) > -target_duration = lrint(duration); > +target_duration = lrint(lrint(duration * 10.0) / 10.0); This will just move the move the corner case from x.5 to x.45(x.46 depending on the double precision errors). Will not solve the original issue. For example, right now 1.5 is a corner case, as lrint(1.5) = 2, and lrint(1.49) = 1. After this patch, 1.46 will become the corner case. For example lrint(lrint(1.45 * 10.0) / 10.0) = 1 and lrint(lrint(1.46 * 10.0) / 10.0) = 2 When someone chooses a segment duration of 1.46, this issue will again resurface. Thanks and regards, Karthick > } > > ff_hls_write_playlist_header(out_hls, 6, -1, target_duration, > diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c > index 0095ca4339..bf6f1d9253 100644 > --- a/libavformat/hlsenc.c > +++ b/libavformat/hlsenc.c > @@ -1235,7 +1235,7 @@ static int hls_window(AVFormatContext *s, int last, > VariantStream *vs) > > for (en = vs->segments; en; en = en->next) { > if (target_duration <= en->duration) > -target_duration = lrint(en->duration); > +target_duration = lrint(lrint(en->duration * 10.0) / 10.0); > } > > vs->discontinuity_set = 0; ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel