Re: [FFmpeg-devel] make work (live) libsrt
On Wed, Aug 22, 2018 at 4:30 AM Tudor Suciu wrote: > > Hello, > > I get errors when I try to send a live srt stream that the first packet is > too big: > 21:30:39.896626/ffmpeg*E: SRT.c: LiveSmoother: payload size: 1504 exceeds > maximum allowed 1316 > > Here are example commands for server and client: > ffmpeg -re -i ~/Downloads/ToS-4k-1920.mov -vcodec libx264 -g 50 -refs 1 -s > 640x360 -b:v 1000k -acodec aac -b:a 64k -flush_packets 0 -f mpegts "srt:// > 127.0.0.1:?mode=listener" > ffplay srt://127.0.0.1: > > A patch that fully solves the issue is: > diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c > index 0f9529d263..156a4776e2 100644 > --- a/libavformat/libsrt.c > +++ b/libavformat/libsrt.c > @@ -412,6 +412,8 @@ static int libsrt_open(URLContext *h, const char *uri, > int flags) > return AVERROR_UNKNOWN; > } > > +h->max_packet_size = 1316; > + > /* SRT options (srt/srt.h) */ > p = strchr(uri, '?'); > if (p) { > > How would you like this option to be made work in a way that can be > accepted in ffmpeg? > Is there a way to change the max packet size without this patch? > In your case, I don't think hard coding max packet size == 1316 is not a good idea in loopback device, and after deep in the srt library(https://github.com/Haivision/srt) source code, I think srt library need to fix the hardcode about packet size limition. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] examples/vaapi_dec_scaling: init export
On Wed, Aug 22, 2018 at 5:51 PM Carl Eugen Hoyos wrote: > > 2018-08-22 2:42 GMT+02:00, myp...@gmail.com : > > On Tue, Aug 21, 2018 at 4:45 PM Carl Eugen Hoyos wrote: > >> > >> 2018-06-11 13:22 GMT+02:00, Jun Zhao : > >> > >> > + * Copyright (c) 2018 Jun Zhao > >> > + * > >> > + * VA-API Acceleration API (video decoding/scaling) sample > >> > + * > >> > + * 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. > >> > >> This is not an ideal license for doc/examples. > > > > I didn't realize this problem, any other license be suggested? MIT ? > > I think so, yes. > Will change the license and update the other vaapi_xxx sample (after asking the other related contributor with mail), Thanks. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 16/41] vaapi_encode: Add support for max QP in rate control
This was added in libva 2.1.0 (VAAPI 1.1.0). Use AVCodecContext.qmax, matching the existing behaviour for qmin, and clean up the defaults so that we only pass min/max when explicitly set. --- doc/encoders.texi | 3 ++- libavcodec/vaapi_encode.c | 3 +++ libavcodec/vaapi_encode_h264.c | 3 ++- libavcodec/vaapi_encode_h265.c | 2 ++ libavcodec/vaapi_encode_mpeg2.c | 2 ++ libavcodec/vaapi_encode_vp8.c | 2 ++ libavcodec/vaapi_encode_vp9.c | 2 ++ 7 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 0c0a307987..861f9f4f1f 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2588,7 +2588,8 @@ Speed / quality tradeoff: higher values are faster / worse quality. Size / quality tradeoff: higher values are smaller / worse quality. @item @option{qmin} -(only: @option{qmax} is not supported) +@item +@option{qmax} @item @option{i_qfactor} / @option{i_quant_factor} @item diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 25d89c65c9..e9eeb6eb83 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1436,6 +1436,9 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) .initial_qp= 0, .min_qp= (avctx->qmin > 0 ? avctx->qmin : 0), .basic_unit_size = 0, +#if VA_CHECK_VERSION(1, 1, 0) +.max_qp= (avctx->qmax > 0 ? avctx->qmax : 0), +#endif }; vaapi_encode_add_global_param(avctx, &ctx->rc_params.misc, sizeof(ctx->rc_params)); diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index c63766d918..e903b251c0 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -1033,7 +1033,8 @@ static const AVCodecDefault vaapi_encode_h264_defaults[] = { { "i_qoffset", "0" }, { "b_qfactor", "6/5" }, { "b_qoffset", "0" }, -{ "qmin", "0" }, +{ "qmin", "-1" }, +{ "qmax", "-1" }, { NULL }, }; diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index b296919b37..13ddad79ae 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1148,6 +1148,8 @@ static const AVCodecDefault vaapi_encode_h265_defaults[] = { { "i_qoffset", "0" }, { "b_qfactor", "6/5" }, { "b_qoffset", "0" }, +{ "qmin", "-1" }, +{ "qmax", "-1" }, { NULL }, }; diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index ff86b8817e..db72516187 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -672,6 +672,8 @@ static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = { { "b_qfactor", "6/5" }, { "b_qoffset", "0" }, { "global_quality", "10" }, +{ "qmin", "-1" }, +{ "qmax", "-1" }, { NULL }, }; diff --git a/libavcodec/vaapi_encode_vp8.c b/libavcodec/vaapi_encode_vp8.c index 40871a6bbf..db67136556 100644 --- a/libavcodec/vaapi_encode_vp8.c +++ b/libavcodec/vaapi_encode_vp8.c @@ -230,6 +230,8 @@ static const AVCodecDefault vaapi_encode_vp8_defaults[] = { { "bf", "0" }, { "g", "120" }, { "global_quality", "40" }, +{ "qmin", "-1" }, +{ "qmax", "-1" }, { NULL }, }; diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index e400bc8b79..2b0658ec1f 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -253,6 +253,8 @@ static const AVCodecDefault vaapi_encode_vp9_defaults[] = { { "bf", "0" }, { "g", "250" }, { "global_quality", "100" }, +{ "qmin", "-1" }, +{ "qmax", "-1" }, { NULL }, }; -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 00/41] VAAPI encode and related stuff
I think patches 1-8 are uncontentious, I'll push them in a few days if there are no objections. Patches 9-35 are updated to reflect comments on the previous round, along with a few other minor changes. Interested parties may want to look through them again. Patches 36-41 are new, and probably not complete at this point. Any thoughts invited. Thanks, - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 11/41] vaapi_encode: Add common options between all encoders
The only common option here is low_power - it was previously supported for H.264 only, that specific option is removed. --- doc/encoders.texi | 14 -- libavcodec/vaapi_encode.h | 9 + libavcodec/vaapi_encode_h264.c | 8 ++-- libavcodec/vaapi_encode_h265.c | 2 ++ libavcodec/vaapi_encode_vp8.c | 1 + libavcodec/vaapi_encode_vp9.c | 1 + 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 16be6359b3..62a1509a96 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2599,6 +2599,18 @@ Size / quality tradeoff: higher values are smaller / worse quality. @option{b_qoffset} / @option{b_quant_offset} @end itemize +All encoders support the following options: +@itemize +@item +@option{low_power} + +Some drivers/platforms offer a second encoder for some codecs intended to use +less power than the default encoder; setting this option will attempt to use +that encoder. Note that it may support a reduced feature set, so some other +options may not be available in this mode. +@end itemize + +Each encoder also has its own specific options: @table @option @item h264_vaapi @@ -2606,8 +2618,6 @@ Size / quality tradeoff: higher values are smaller / worse quality. @option{level} sets the value of @emph{level_idc}. @table @option -@item low_power -Use low-power encoding mode. @item coder Set entropy encoder (default is @emph{cabac}). Possible values: diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 0da8e356f0..30c3f7fbec 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -298,4 +298,13 @@ int ff_vaapi_encode2(AVCodecContext *avctx, AVPacket *pkt, int ff_vaapi_encode_init(AVCodecContext *avctx); int ff_vaapi_encode_close(AVCodecContext *avctx); + +#define VAAPI_ENCODE_COMMON_OPTIONS \ +{ "low_power", \ + "Use low-power encoding mode (only available on some platforms; " \ + "may not support all encoding features)", \ + OFFSET(common.low_power), AV_OPT_TYPE_BOOL, \ + { .i64 = 0 }, 0, 1, FLAGS } + + #endif /* AVCODEC_VAAPI_ENCODE_H */ diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 456806032b..5ef72b222d 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -52,7 +52,6 @@ typedef struct VAAPIEncodeH264Context { // User options. int qp; int quality; -int low_power; int coder; int aud; int sei; @@ -936,8 +935,6 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx) return AVERROR_PATCHWELCOME; } -ctx->low_power = priv->low_power; - if (avctx->bit_rate > 0) { if (avctx->rc_max_rate == avctx->bit_rate) ctx->va_rc_mode = VA_RC_CBR; @@ -970,13 +967,12 @@ static av_cold int vaapi_encode_h264_close(AVCodecContext *avctx) #define OFFSET(x) offsetof(VAAPIEncodeH264Context, x) #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) static const AVOption vaapi_encode_h264_options[] = { +VAAPI_ENCODE_COMMON_OPTIONS, + { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)", OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 20 }, 0, 52, FLAGS }, { "quality", "Set encode quality (trades off against speed, higher is faster)", OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 8, FLAGS }, -{ "low_power", "Use low-power encoding mode (experimental: only supported " - "on some platforms, does not support all features)", - OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, { "coder", "Entropy coder type", OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, "coder" }, { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, "coder" }, diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 9fa16593d0..b8b66b87cb 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1099,6 +1099,8 @@ static av_cold int vaapi_encode_h265_close(AVCodecContext *avctx) #define OFFSET(x) offsetof(VAAPIEncodeH265Context, x) #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) static const AVOption vaapi_encode_h265_options[] = { +VAAPI_ENCODE_COMMON_OPTIONS, + { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)", OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, 52, FLAGS }, diff --git a/libavcodec/vaapi_encode_vp8.c b/libavcodec/vaapi_encode_vp8.c index a502df7885..9588826bfb 100644 --- a/libavcodec/vaapi_encode_vp8.c +++ b/libavcodec/vaapi_encode_vp8.c @@ -228,6 +228,7 @@ static av_cold int vaapi_encode_vp8_init(AVCodecContext *avctx) #define OFFSET(x) offsetof(VAAPIEncodeVP8Context, x) #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) static const AVOption vaapi_encode_vp8_options[] = { +VAAPI_ENCODE_COMMON_OPTIONS, { "loop_filter_level", "Loop fi
[FFmpeg-devel] [PATCH v3 23/41] lavc/cbs: Add JPEG support
--- configure | 2 + libavcodec/Makefile | 1 + libavcodec/cbs.c | 6 + libavcodec/cbs_internal.h | 1 + libavcodec/cbs_jpeg.c | 520 ++ libavcodec/cbs_jpeg.h | 130 +++ libavcodec/cbs_jpeg_syntax_template.c | 191 ++ 7 files changed, 851 insertions(+) create mode 100644 libavcodec/cbs_jpeg.c create mode 100644 libavcodec/cbs_jpeg.h create mode 100644 libavcodec/cbs_jpeg_syntax_template.c diff --git a/configure b/configure index 1aab3c60d7..f9e6f017ac 100755 --- a/configure +++ b/configure @@ -2248,6 +2248,7 @@ CONFIG_EXTRA=" cbs cbs_h264 cbs_h265 +cbs_jpeg cbs_mpeg2 cbs_vp9 dirac_parse @@ -2511,6 +2512,7 @@ threads_if_any="$THREADS_LIST" # subsystems cbs_h264_select="cbs golomb" cbs_h265_select="cbs golomb" +cbs_jpeg_select="cbs" cbs_mpeg2_select="cbs" cbs_vp9_select="cbs" dct_select="rdft" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f0c8226283..cbbfc9af2e 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -65,6 +65,7 @@ OBJS-$(CONFIG_CABAC) += cabac.o OBJS-$(CONFIG_CBS) += cbs.o OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o +OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o OBJS-$(CONFIG_CBS_MPEG2) += cbs_mpeg2.o OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o OBJS-$(CONFIG_CRYSTALHD) += crystalhd.o diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index be6c043b58..bb3ce95971 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -35,6 +35,9 @@ static const CodedBitstreamType *cbs_type_table[] = { #if CONFIG_CBS_H265 &ff_cbs_type_h265, #endif +#if CONFIG_CBS_JPEG +&ff_cbs_type_jpeg, +#endif #if CONFIG_CBS_MPEG2 &ff_cbs_type_mpeg2, #endif @@ -50,6 +53,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = { #if CONFIG_CBS_H265 AV_CODEC_ID_H265, #endif +#if CONFIG_CBS_JPEG +AV_CODEC_ID_MJPEG, +#endif #if CONFIG_CBS_MPEG2 AV_CODEC_ID_MPEG2VIDEO, #endif diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h index 172b8a2515..e0e912e28e 100644 --- a/libavcodec/cbs_internal.h +++ b/libavcodec/cbs_internal.h @@ -88,6 +88,7 @@ int ff_cbs_write_unsigned(CodedBitstreamContext *ctx, PutBitContext *pbc, extern const CodedBitstreamType ff_cbs_type_h264; extern const CodedBitstreamType ff_cbs_type_h265; +extern const CodedBitstreamType ff_cbs_type_jpeg; extern const CodedBitstreamType ff_cbs_type_mpeg2; extern const CodedBitstreamType ff_cbs_type_vp9; diff --git a/libavcodec/cbs_jpeg.c b/libavcodec/cbs_jpeg.c new file mode 100644 index 00..5a72f0e2e7 --- /dev/null +++ b/libavcodec/cbs_jpeg.c @@ -0,0 +1,520 @@ +/* + * 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 "cbs.h" +#include "cbs_internal.h" +#include "cbs_jpeg.h" + + +#define HEADER(name) do { \ +ff_cbs_trace_header(ctx, name); \ +} while (0) + +#define CHECK(call) do { \ +err = (call); \ +if (err < 0) \ +return err; \ +} while (0) + +#define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL) + +#define u(width, name, range_min, range_max) \ +xu(width, name, range_min, range_max, 0) +#define us(width, name, sub, range_min, range_max) \ +xu(width, name, range_min, range_max, 1, sub) + + +#define READ +#define READWRITE read +#define RWContext GetBitContext +#define FUNC(name) cbs_jpeg_read_ ## name + +#define xu(width, name, range_min, range_max, subs, ...) do { \ +uint32_t value = range_min; \ +CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \ + SUBSCRIPTS(subs, __VA_ARGS__), \ + &value, range_min, range_max)); \ +current->name = value; \ +} while (0) + +#include "cbs_jpeg_syntax_template.c" + +#undef READ +#undef READWRITE +#undef RWContext +#undef FUNC +#undef xu + +#define WRITE +#define READWRITE write +#define RWContext PutBitContext +#define FUNC(name) cbs_jpeg_write_ ## name + +#define xu(width, name, ra
[FFmpeg-devel] [PATCH v3 18/41] vaapi_encode: Clean up the packed header configuration
Add a larger warning more clearly explaining the consequences of missing packed header support in the driver. Also only write the extradata if the user actually requests it via the GLOBAL_HEADER flag. --- libavcodec/vaapi_encode.c | 119 +--- libavcodec/vaapi_encode.h | 7 +- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- libavcodec/vaapi_encode_mjpeg.c | 2 +- libavcodec/vaapi_encode_mpeg2.c | 4 +- libavcodec/vaapi_encode_vp8.c | 6 +- libavcodec/vaapi_encode_vp9.c | 6 +- 8 files changed, 80 insertions(+), 68 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index e48e703ab4..2c34cdce2c 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1206,60 +1206,6 @@ fail: return err; } -static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx) -{ -VAAPIEncodeContext *ctx = avctx->priv_data; -VAStatus vas; -int i; - -VAConfigAttrib attr[] = { -{ VAConfigAttribEncPackedHeaders }, -}; - -vas = vaGetConfigAttributes(ctx->hwctx->display, -ctx->va_profile, ctx->va_entrypoint, -attr, FF_ARRAY_ELEMS(attr)); -if (vas != VA_STATUS_SUCCESS) { -av_log(avctx, AV_LOG_ERROR, "Failed to fetch config " - "attributes: %d (%s).\n", vas, vaErrorStr(vas)); -return AVERROR(EINVAL); -} - -for (i = 0; i < FF_ARRAY_ELEMS(attr); i++) { -if (attr[i].value == VA_ATTRIB_NOT_SUPPORTED) { -// Unfortunately we have to treat this as "don't know" and hope -// for the best, because the Intel MJPEG encoder returns this -// for all the interesting attributes. -av_log(avctx, AV_LOG_DEBUG, "Attribute (%d) is not supported.\n", - attr[i].type); -continue; -} -switch (attr[i].type) { -case VAConfigAttribEncPackedHeaders: -if (ctx->va_packed_headers & ~attr[i].value) { -// This isn't fatal, but packed headers are always -// preferable because they are under our control. -// When absent, the driver is generating them and some -// features may not work (e.g. VUI or SEI in H.264). -av_log(avctx, AV_LOG_WARNING, "Warning: some packed " - "headers are not supported (want %#x, got %#x).\n", - ctx->va_packed_headers, attr[i].value); -ctx->va_packed_headers &= attr[i].value; -} -ctx->config_attributes[ctx->nb_config_attributes++] = -(VAConfigAttrib) { -.type = VAConfigAttribEncPackedHeaders, -.value = ctx->va_packed_headers, -}; -break; -default: -av_assert0(0 && "Unexpected config attribute."); -} -} - -return 0; -} - static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; @@ -1498,6 +1444,66 @@ static av_cold int vaapi_encode_init_gop_structure(AVCodecContext *avctx) return 0; } +static av_cold int vaapi_encode_init_packed_headers(AVCodecContext *avctx) +{ +VAAPIEncodeContext *ctx = avctx->priv_data; +VAStatus vas; +VAConfigAttrib attr = { VAConfigAttribEncPackedHeaders }; + +vas = vaGetConfigAttributes(ctx->hwctx->display, +ctx->va_profile, +ctx->va_entrypoint, +&attr, 1); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to query packed headers " + "attribute: %d (%s).\n", vas, vaErrorStr(vas)); +return AVERROR_EXTERNAL; +} + +if (attr.value == VA_ATTRIB_NOT_SUPPORTED) { +if (ctx->desired_packed_headers) { +av_log(avctx, AV_LOG_WARNING, "Driver does not support any " + "packed headers (wanted %#x).\n", + ctx->desired_packed_headers); +} else { +av_log(avctx, AV_LOG_VERBOSE, "Driver does not support any " + "packed headers (none wanted).\n"); +} +ctx->va_packed_headers = 0; +} else { +if (ctx->desired_packed_headers & ~attr.value) { +av_log(avctx, AV_LOG_WARNING, "Driver does not support some " + "wanted packed headers (wanted %#x, found %#x).\n", + ctx->desired_packed_headers, attr.value); +} else { +av_log(avctx, AV_LOG_VERBOSE, "All wanted packed headers " + "available (wanted %#x, found %#x).\n", + ctx->desired_packed_headers, attr.value); +} +ctx->va_packed_headers = ctx->desired_packed_headers & attr.value; +} + +if (ctx->va_packed_headers) { +ctx->config_attribu
[FFmpeg-devel] [PATCH v3 15/41] vaapi_encode: Clean up rate control configuration
Query which modes are supported and select between VBR and CBR based on that - this removes all of the codec-specific rate control mode selection code. --- doc/encoders.texi | 2 - libavcodec/vaapi_encode.c | 181 +++- libavcodec/vaapi_encode.h | 6 +- libavcodec/vaapi_encode_h264.c | 18 +--- libavcodec/vaapi_encode_h265.c | 14 +-- libavcodec/vaapi_encode_mjpeg.c | 3 +- libavcodec/vaapi_encode_mpeg2.c | 9 +- libavcodec/vaapi_encode_vp8.c | 13 +-- libavcodec/vaapi_encode_vp9.c | 13 +-- 9 files changed, 145 insertions(+), 114 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 62a1509a96..0c0a307987 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2643,8 +2643,6 @@ Always encodes using the standard quantisation and huffman tables - @item mpeg2_vaapi @option{profile} and @option{level} set the value of @emph{profile_and_level_indication}. -No rate control is supported. - @item vp8_vaapi B-frames are not supported. diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 1969c9252f..25d89c65c9 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1213,7 +1213,6 @@ static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx) int i; VAConfigAttrib attr[] = { -{ VAConfigAttribRateControl }, { VAConfigAttribEncMaxRefFrames }, { VAConfigAttribEncPackedHeaders }, }; @@ -1237,32 +1236,6 @@ static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx) continue; } switch (attr[i].type) { -case VAConfigAttribRateControl: -// Hack for backward compatibility: CBR was the only -// usable RC mode for a long time, so old drivers will -// only have it. Normal default options may now choose -// VBR and then fail, however, so override it here with -// CBR if that is the only supported mode. -if (ctx->va_rc_mode == VA_RC_VBR && -!(attr[i].value & VA_RC_VBR) && -(attr[i].value & VA_RC_CBR)) { -av_log(avctx, AV_LOG_WARNING, "VBR rate control is " - "not supported with this driver version; " - "using CBR instead.\n"); -ctx->va_rc_mode = VA_RC_CBR; -} -if (!(ctx->va_rc_mode & attr[i].value)) { -av_log(avctx, AV_LOG_ERROR, "Rate control mode %#x " - "is not supported (mask: %#x).\n", - ctx->va_rc_mode, attr[i].value); -return AVERROR(EINVAL); -} -ctx->config_attributes[ctx->nb_config_attributes++] = -(VAConfigAttrib) { -.type = VAConfigAttribRateControl, -.value = ctx->va_rc_mode, -}; -break; case VAConfigAttribEncMaxRefFrames: { unsigned int ref_l0 = attr[i].value & 0x; @@ -1309,44 +1282,152 @@ static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx) static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; -int rc_bits_per_second; -int rc_target_percentage; -int rc_window_size; -int hrd_buffer_size; -int hrd_initial_buffer_fullness; +int64_t rc_bits_per_second; +int rc_target_percentage; +int rc_window_size; +int64_t hrd_buffer_size; +int64_t hrd_initial_buffer_fullness; int fr_num, fr_den; +VAConfigAttrib rc_attr = { VAConfigAttribRateControl }; +VAStatus vas; + +vas = vaGetConfigAttributes(ctx->hwctx->display, +ctx->va_profile, ctx->va_entrypoint, +&rc_attr, 1); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to query rate control " + "config attribute: %d (%s).\n", vas, vaErrorStr(vas)); +return AVERROR_EXTERNAL; +} + +if (rc_attr.value == VA_ATTRIB_NOT_SUPPORTED) { +av_log(avctx, AV_LOG_VERBOSE, "Driver does not report any " + "supported rate control modes: assuming constant-quality.\n"); +ctx->va_rc_mode = VA_RC_CQP; +return 0; +} +if (avctx->flags & AV_CODEC_FLAG_QSCALE || +avctx->bit_rate <= 0) { +if (rc_attr.value & VA_RC_CQP) { +av_log(avctx, AV_LOG_VERBOSE, "Using constant-quality mode.\n"); +ctx->va_rc_mode = VA_RC_CQP; +if (avctx->bit_rate > 0 || avctx->rc_max_rate > 0) { +av_log(avctx, AV_LOG_WARNING, "Bitrate target parameters " + "ignored in constant-quality mode.\n"); +} +return 0; +} else { +av_log(avctx, AV_LOG_ERROR, "Driver does not support " + "constant-quality mode (%#x).\n",
[FFmpeg-devel] [PATCH v3 22/41] hwcontext_vaapi: Improve logging around quirk detection
Clarify that the list is the naughty list, and therefore being on it is not desirable. The i965 driver does not need to be on the list after version 2.0 (when the standard parameter buffer rendering behaviour was changed). --- libavutil/hwcontext_vaapi.c | 27 +++ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index a2387d4fc4..4088a96be4 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -279,11 +279,14 @@ static const struct { const char *match_string; unsigned int quirks; } vaapi_driver_quirks_table[] = { +#if !VA_CHECK_VERSION(1, 0, 0) +// The i965 driver did not conform before version 2.0. { "Intel i965 (Quick Sync)", "i965", AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS, }, +#endif { "Intel iHD", "ubit", @@ -344,29 +347,37 @@ static int vaapi_device_init(AVHWDeviceContext *hwdev) } } +vendor_string = vaQueryVendorString(hwctx->display); +if (vendor_string) +av_log(hwdev, AV_LOG_VERBOSE, "VAAPI driver: %s.\n", vendor_string); + if (hwctx->driver_quirks & AV_VAAPI_DRIVER_QUIRK_USER_SET) { -av_log(hwdev, AV_LOG_VERBOSE, "Not detecting driver: " - "quirks set by user.\n"); +av_log(hwdev, AV_LOG_VERBOSE, "Using quirks set by user (%#x).\n", + hwctx->driver_quirks); } else { // Detect the driver in use and set quirk flags if necessary. -vendor_string = vaQueryVendorString(hwctx->display); hwctx->driver_quirks = 0; if (vendor_string) { for (i = 0; i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table); i++) { if (strstr(vendor_string, vaapi_driver_quirks_table[i].match_string)) { -av_log(hwdev, AV_LOG_VERBOSE, "Matched \"%s\" as known " - "driver \"%s\".\n", vendor_string, - vaapi_driver_quirks_table[i].friendly_name); +av_log(hwdev, AV_LOG_VERBOSE, "Matched driver string " + "as known nonstandard driver \"%s\", setting " + "quirks (%#x).\n", + vaapi_driver_quirks_table[i].friendly_name, + vaapi_driver_quirks_table[i].quirks); hwctx->driver_quirks |= vaapi_driver_quirks_table[i].quirks; break; } } if (!(i < FF_ARRAY_ELEMS(vaapi_driver_quirks_table))) { -av_log(hwdev, AV_LOG_VERBOSE, "Unknown driver \"%s\", " - "assuming standard behaviour.\n", vendor_string); +av_log(hwdev, AV_LOG_VERBOSE, "Driver not found in known " + "nonstandard list, using standard behaviour.\n"); } +} else { +av_log(hwdev, AV_LOG_VERBOSE, "Driver has no vendor string, " + "assuming standard behaviour.\n"); } } -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 13/41] vaapi_encode: Clean up the encode quality configuration
--- libavcodec/vaapi_encode.c | 84 +- libavcodec/vaapi_encode_h264.c | 7 ++- 2 files changed, 54 insertions(+), 37 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index f838ee5bd5..35a4e90f67 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1387,6 +1387,51 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) return 0; } +static av_cold int vaapi_encode_init_quality(AVCodecContext *avctx) +{ +#if VA_CHECK_VERSION(0, 36, 0) +VAAPIEncodeContext *ctx = avctx->priv_data; +VAStatus vas; +VAConfigAttrib attr = { VAConfigAttribEncQualityRange }; +int quality = avctx->compression_level; + +vas = vaGetConfigAttributes(ctx->hwctx->display, +ctx->va_profile, +ctx->va_entrypoint, +&attr, 1); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to query quality " + "config attribute: %d (%s).\n", vas, vaErrorStr(vas)); +return AVERROR_EXTERNAL; +} + +if (attr.value == VA_ATTRIB_NOT_SUPPORTED) { +if (quality != 0) { +av_log(avctx, AV_LOG_WARNING, "Quality attribute is not " + "supported: will use default quality level.\n"); +} +} else { +if (quality > attr.value) { +av_log(avctx, AV_LOG_WARNING, "Invalid quality level: " + "valid range is 0-%d, using %d.\n", + attr.value, attr.value); +quality = attr.value; +} + +ctx->quality_params.misc.type = VAEncMiscParameterTypeQualityLevel; +ctx->quality_params.quality.quality_level = quality; + +vaapi_encode_add_global_param(avctx, &ctx->quality_params.misc, + sizeof(ctx->quality_params)); +} +#else +av_log(avctx, AV_LOG_WARNING, "The encode quality option is " + "not supported with this VAAPI version.\n"); +#endif + +return 0; +} + static void vaapi_encode_free_output_buffer(void *opaque, uint8_t *data) { @@ -1568,6 +1613,12 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx) if (err < 0) goto fail; +if (avctx->compression_level >= 0) { +err = vaapi_encode_init_quality(avctx); +if (err < 0) +goto fail; +} + vas = vaCreateConfig(ctx->hwctx->display, ctx->va_profile, ctx->va_entrypoint, ctx->config_attributes, ctx->nb_config_attributes, @@ -1617,39 +1668,6 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx) goto fail; } -if (avctx->compression_level >= 0) { -#if VA_CHECK_VERSION(0, 36, 0) -VAConfigAttrib attr = { VAConfigAttribEncQualityRange }; - -vas = vaGetConfigAttributes(ctx->hwctx->display, -ctx->va_profile, -ctx->va_entrypoint, -&attr, 1); -if (vas != VA_STATUS_SUCCESS) { -av_log(avctx, AV_LOG_WARNING, "Failed to query quality " - "attribute: will use default compression level.\n"); -} else { -if (avctx->compression_level > attr.value) { -av_log(avctx, AV_LOG_WARNING, "Invalid compression " - "level: valid range is 0-%d, using %d.\n", - attr.value, attr.value); -avctx->compression_level = attr.value; -} - -ctx->quality_params.misc.type = -VAEncMiscParameterTypeQualityLevel; -ctx->quality_params.quality.quality_level = -avctx->compression_level; - -vaapi_encode_add_global_param(avctx, &ctx->quality_params.misc, - sizeof(ctx->quality_params)); -} -#else -av_log(avctx, AV_LOG_WARNING, "The encode compression level " - "option is not supported with this VAAPI version.\n"); -#endif -} - ctx->input_order = 0; ctx->output_delay = avctx->max_b_frames; ctx->decode_delay = 1; diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 5ef72b222d..69e95dd340 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -831,9 +831,6 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx) av_assert0(0 && "Invalid RC mode."); } -if (avctx->compression_level == FF_COMPRESSION_DEFAULT) -avctx->compression_level = priv->quality; - if (priv->sei & SEI_IDENTIFIER) { const char *lavc = LIBAVCODEC_IDENT; const char *vaapi = VA_VERSION_S; @@ -907,6 +904,8 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx) avctx->profile = priv->profile;
[FFmpeg-devel] [PATCH v3 41/41] vaapi_encode_vp9: Support more complex reference structures
--- vp9_raw_reorder required when using this feature. Timestamps will need some more thought - currently the output stream can get incorrect DTS values after reordering. libavcodec/vaapi_encode_vp9.c | 104 +- 1 file changed, 51 insertions(+), 53 deletions(-) diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index 94f29c0483..97142dcc49 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -32,6 +32,10 @@ #define VP9_MAX_QUANT 255 +typedef struct VAAPIEncodeVP9Picture { +int slot; +} VAAPIEncodeVP9Picture; + typedef struct VAAPIEncodeVP9Context { VAAPIEncodeContext common; @@ -43,22 +47,9 @@ typedef struct VAAPIEncodeVP9Context { int q_idx_idr; int q_idx_p; int q_idx_b; - -// Stream state. - -// Reference direction for B-like frames: -// 0 - most recent P/IDR frame is last. -// 1 - most recent P frame is golden. -int last_ref_dir; } VAAPIEncodeVP9Context; -#define vseq_var(name) vseq->name, name -#define vseq_field(name) vseq->seq_fields.bits.name, name -#define vpic_var(name) vpic->name, name -#define vpic_field(name) vpic->pic_fields.bits.name, name - - static int vaapi_encode_vp9_init_sequence_params(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; @@ -88,6 +79,7 @@ static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx, { VAAPIEncodeContext *ctx = avctx->priv_data; VAAPIEncodeVP9Context *priv = avctx->priv_data; +VAAPIEncodeVP9Picture *hpic = pic->priv_data; VAEncPictureParameterBufferVP9 *vpic = pic->codec_picture_params; int i; @@ -98,65 +90,71 @@ static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx, case PICTURE_TYPE_IDR: av_assert0(pic->nb_refs == 0); vpic->ref_flags.bits.force_kf = 1; -vpic->refresh_frame_flags = 0x01; -priv->last_ref_dir = 0; +vpic->refresh_frame_flags = 0xff; +hpic->slot = 0; break; case PICTURE_TYPE_P: av_assert0(pic->nb_refs == 1); -if (ctx->b_per_p > 0) { -if (priv->last_ref_dir) { -vpic->ref_flags.bits.ref_frame_ctrl_l0 = 2; -vpic->ref_flags.bits.ref_gf_idx = 1; -vpic->ref_flags.bits.ref_gf_sign_bias = 1; -vpic->refresh_frame_flags = 0x01; +{ +VAAPIEncodeVP9Picture *href = pic->refs[0]->priv_data; +av_assert0(href->slot == 0 || href->slot == 1); + +if (ctx->max_b_depth > 0) { +hpic->slot = !href->slot; +vpic->refresh_frame_flags = 1 << hpic->slot | 0xfc; } else { -vpic->ref_flags.bits.ref_frame_ctrl_l0 = 1; -vpic->ref_flags.bits.ref_last_idx = 0; -vpic->ref_flags.bits.ref_last_sign_bias = 1; -vpic->refresh_frame_flags = 0x02; +hpic->slot = 0; +vpic->refresh_frame_flags = 0xff; } -} else { vpic->ref_flags.bits.ref_frame_ctrl_l0 = 1; -vpic->ref_flags.bits.ref_last_idx = 0; +vpic->ref_flags.bits.ref_last_idx = href->slot; vpic->ref_flags.bits.ref_last_sign_bias = 1; -vpic->refresh_frame_flags = 0x01; } break; case PICTURE_TYPE_B: av_assert0(pic->nb_refs == 2); -if (priv->last_ref_dir) { +{ +VAAPIEncodeVP9Picture *href0 = pic->refs[0]->priv_data, + *href1 = pic->refs[1]->priv_data; +av_assert0(href0->slot < pic->b_depth + 1 && + href1->slot < pic->b_depth + 1); + +if (pic->b_depth == ctx->max_b_depth) { +// Unreferenced frame. +vpic->refresh_frame_flags = 0x00; +hpic->slot = 8; +} else { +vpic->refresh_frame_flags = 0xfe << pic->b_depth & 0xff; +hpic->slot = 1 + pic->b_depth; +} vpic->ref_flags.bits.ref_frame_ctrl_l0 = 1; vpic->ref_flags.bits.ref_frame_ctrl_l1 = 2; -vpic->ref_flags.bits.ref_last_idx = 0; +vpic->ref_flags.bits.ref_last_idx = href0->slot; vpic->ref_flags.bits.ref_last_sign_bias = 1; -vpic->ref_flags.bits.ref_gf_idx = 1; +vpic->ref_flags.bits.ref_gf_idx = href1->slot; vpic->ref_flags.bits.ref_gf_sign_bias = 0; -} else { -vpic->ref_flags.bits.ref_frame_ctrl_l0 = 2; -vpic->ref_flags.bits.ref_frame_ctrl_l1 = 1; -vpic->ref_flags.bits.ref_last_idx = 0; -vpic->ref_flags.bits.ref_last_sign_bias = 0; -vpic->ref_flags.bits.ref_gf_idx = 1; -vpic->ref_flags.bits.ref_gf_sign
[FFmpeg-devel] [PATCH v3 40/41] vaapi_encode_h265: Support more complex reference structures
The reference picture sets are now constructed directly from the DPB information. --- An obvious useful change (not done) would be the move the RPSs to the SPS where possible, since they are now even larger. libavcodec/vaapi_encode_h265.c | 191 +++-- 1 file changed, 111 insertions(+), 80 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index f25ba7edf0..b3c60523b6 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -42,6 +42,16 @@ enum { SEI_CONTENT_LIGHT_LEVEL = 0x10, }; +typedef struct VAAPIEncodeH265Picture { +int pic_order_cnt; + +int64_t last_idr_frame; + +int slice_nal_unit; +int slice_type; +int pic_type; +} VAAPIEncodeH265Picture; + typedef struct VAAPIEncodeH265Context { VAAPIEncodeContext common; @@ -61,14 +71,6 @@ typedef struct VAAPIEncodeH265Context { int fixed_qp_p; int fixed_qp_b; -// Stream state. -int64_t last_idr_frame; -int pic_order_cnt; - -int slice_nal_unit; -int slice_type; -int pic_type; - // Writer structures. H265RawAUD raw_aud; H265RawVPS raw_vps; @@ -362,8 +364,8 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) } vps->vps_sub_layer_ordering_info_present_flag = 0; -vps->vps_max_dec_pic_buffering_minus1[0] = (ctx->b_per_p > 0) + 1; -vps->vps_max_num_reorder_pics[0] = (ctx->b_per_p > 0); +vps->vps_max_dec_pic_buffering_minus1[0] = ctx->max_b_depth + 1; +vps->vps_max_num_reorder_pics[0] = ctx->max_b_depth; vps->vps_max_latency_increase_plus1[0]= 0; vps->vps_max_layer_id = 0; @@ -672,41 +674,54 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic) { +VAAPIEncodeContext *ctx = avctx->priv_data; VAAPIEncodeH265Context *priv = avctx->priv_data; +VAAPIEncodeH265Picture *hpic = pic->priv_data; +VAAPIEncodePicture *prev = pic->prev; +VAAPIEncodeH265Picture *hprev = prev ? prev->priv_data : NULL; VAEncPictureParameterBufferHEVC *vpic = pic->codec_picture_params; int i; if (pic->type == PICTURE_TYPE_IDR) { av_assert0(pic->display_order == pic->encode_order); -priv->last_idr_frame = pic->display_order; +hpic->last_idr_frame = pic->display_order; -priv->slice_nal_unit = HEVC_NAL_IDR_W_RADL; -priv->slice_type = HEVC_SLICE_I; -priv->pic_type = 0; +hpic->slice_nal_unit = HEVC_NAL_IDR_W_RADL; +hpic->slice_type = HEVC_SLICE_I; +hpic->pic_type = 0; } else { -av_assert0(pic->encode_order > priv->last_idr_frame); +av_assert0(prev); +hpic->last_idr_frame = hprev->last_idr_frame; if (pic->type == PICTURE_TYPE_I) { -priv->slice_nal_unit = HEVC_NAL_CRA_NUT; -priv->slice_type = HEVC_SLICE_I; -priv->pic_type = 0; +hpic->slice_nal_unit = HEVC_NAL_CRA_NUT; +hpic->slice_type = HEVC_SLICE_I; +hpic->pic_type = 0; } else if (pic->type == PICTURE_TYPE_P) { av_assert0(pic->refs[0]); -priv->slice_nal_unit = HEVC_NAL_TRAIL_R; -priv->slice_type = HEVC_SLICE_P; -priv->pic_type = 1; +hpic->slice_nal_unit = HEVC_NAL_TRAIL_R; +hpic->slice_type = HEVC_SLICE_P; +hpic->pic_type = 1; } else { +VAAPIEncodePicture *irap_ref; av_assert0(pic->refs[0] && pic->refs[1]); -if (pic->refs[1]->type == PICTURE_TYPE_I) -priv->slice_nal_unit = HEVC_NAL_RASL_N; -else -priv->slice_nal_unit = HEVC_NAL_TRAIL_N; -priv->slice_type = HEVC_SLICE_B; -priv->pic_type = 2; +for (irap_ref = pic; irap_ref; irap_ref = irap_ref->refs[1]) { +if (irap_ref->type == PICTURE_TYPE_I) +break; +} +if (pic->b_depth == ctx->max_b_depth) { +hpic->slice_nal_unit = irap_ref ? HEVC_NAL_RASL_N +: HEVC_NAL_TRAIL_N; +} else { +hpic->slice_nal_unit = irap_ref ? HEVC_NAL_RASL_R +: HEVC_NAL_TRAIL_R; +} +hpic->slice_type = HEVC_SLICE_B; +hpic->pic_type = 2; } } -priv->pic_order_cnt = pic->display_order - priv->last_idr_frame; +hpic->pic_order_cnt = pic->display_order - hpic->last_idr_frame; if (priv->aud) { priv->aud_needed = 1; @@ -716,7 +731,7 @@ static int vaapi
[FFmpeg-devel] [PATCH v3 37/41] vaapi_encode: Convert to send/receive API
This attaches the logic of picking the mode of for the next picture to the output, which simplifies some choices by removing the concept of the picture for which input is not yet available. At the same time, we allow more complex reference structures and track more reference metadata (particularly the contents of the DPB) for use in the codec-specific code. It also adds flags to explicitly track the available features of the different codecs. The new structure also allows open-GOP support, so that is now available for codecs which can do it. --- libavcodec/vaapi_encode.c | 635 +--- libavcodec/vaapi_encode.h | 80 +++- libavcodec/vaapi_encode_h264.c | 6 +- libavcodec/vaapi_encode_h265.c | 6 +- libavcodec/vaapi_encode_mjpeg.c | 8 +- libavcodec/vaapi_encode_mpeg2.c | 5 +- libavcodec/vaapi_encode_vp8.c | 3 +- libavcodec/vaapi_encode_vp9.c | 5 +- 8 files changed, 425 insertions(+), 323 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index a6981d69fa..d03bd1925e 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -158,16 +158,10 @@ static int vaapi_encode_issue(AVCodecContext *avctx, av_log(avctx, AV_LOG_DEBUG, ".\n"); } -av_assert0(pic->input_available && !pic->encode_issued); +av_assert0(!pic->encode_issued); for (i = 0; i < pic->nb_refs; i++) { av_assert0(pic->refs[i]); -// If we are serialised then the references must have already -// completed. If not, they must have been issued but need not -// have completed yet. -if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING) -av_assert0(pic->refs[i]->encode_complete); -else -av_assert0(pic->refs[i]->encode_issued); +av_assert0(pic->refs[i]->encode_issued); } av_log(avctx, AV_LOG_DEBUG, "Input surface is %#x.\n", pic->input_surface); @@ -422,10 +416,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx, pic->encode_issued = 1; -if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING) -return vaapi_encode_wait(avctx, pic); -else -return 0; +return 0; fail_with_picture: vaEndPicture(ctx->hwctx->display, ctx->va_context); @@ -582,315 +573,330 @@ static int vaapi_encode_free(AVCodecContext *avctx, return 0; } -static int vaapi_encode_step(AVCodecContext *avctx, - VAAPIEncodePicture *target) +static void vaapi_encode_add_ref(AVCodecContext *avctx, + VAAPIEncodePicture *pic, + VAAPIEncodePicture *target, + int is_ref, int in_dpb, int prev) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodePicture *pic; -int i, err; +int refs = 0; -if (ctx->issue_mode == ISSUE_MODE_SERIALISE_EVERYTHING || -ctx->issue_mode == ISSUE_MODE_MINIMISE_LATENCY) { -// These two modes are equivalent, except that we wait for -// immediate completion on each operation if serialised. - -if (!target) { -// No target, nothing to do yet. -return 0; -} - -if (target->encode_complete) { -// Already done. -return 0; -} - -pic = target; -for (i = 0; i < pic->nb_refs; i++) { -if (!pic->refs[i]->encode_complete) { -err = vaapi_encode_step(avctx, pic->refs[i]); -if (err < 0) -return err; -} -} - -err = vaapi_encode_issue(avctx, pic); -if (err < 0) -return err; - -} else if (ctx->issue_mode == ISSUE_MODE_MAXIMISE_THROUGHPUT) { -int activity; - -// Run through the list of all available pictures repeatedly -// and issue the first one found which has all dependencies -// available (including previously-issued but not necessarily -// completed pictures). -do { -activity = 0; -for (pic = ctx->pic_start; pic; pic = pic->next) { -if (!pic->input_available || pic->encode_issued) -continue; -for (i = 0; i < pic->nb_refs; i++) { -if (!pic->refs[i]->encode_issued) -break; -} -if (i < pic->nb_refs) -continue; -err = vaapi_encode_issue(avctx, pic); -if (err < 0) -return err; -activity = 1; -// Start again from the beginning of the list, -// because issuing this picture may have satisfied -// forward dependencies of earlier ones. -break; -} -} while(activity); +if (is_ref) { +av_assert0(pic != target); +av_assert0(pic->nb_refs < MAX_PICTURE_REFERENCES); +
[FFmpeg-devel] [PATCH v3 38/41] vaapi_encode: Let the reconstructed frame pool be sized dynamically
No supported encode driver requires the pool to be fixed-size, so just remove this constraint. --- libavcodec/vaapi_encode.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index d03bd1925e..e20280065c 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1721,9 +1721,6 @@ static av_cold int vaapi_encode_create_recon_frames(AVCodecContext *avctx) ctx->recon_frames->sw_format = recon_format; ctx->recon_frames->width = ctx->surface_width; ctx->recon_frames->height= ctx->surface_height; -// At most three IDR/I/P frames and two runs of B frames can be in -// flight at any one time. -ctx->recon_frames->initial_pool_size = 3 + 2 * ctx->b_per_p; err = av_hwframe_ctx_init(ctx->recon_frames_ref); if (err < 0) { -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 39/41] vaapi_encode_h264: Support more complex reference structures
--- Some future changes: * Don't use r-p-l-m if the list is already correct. * Support more than one reference frame in either direction. libavcodec/vaapi_encode_h264.c | 180 ++--- 1 file changed, 120 insertions(+), 60 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index bf6e7dfb98..2313201a42 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -47,6 +47,20 @@ static const uint8_t vaapi_encode_h264_sei_identifier_uuid[16] = { 0x96, 0x75, 0x19, 0xd4, 0x1f, 0xea, 0xa9, 0x4d, }; +typedef struct VAAPIEncodeH264Picture { +int frame_num; +int pic_order_cnt; + +int64_t last_idr_frame; +uint16_t idr_pic_id; + +int primary_pic_type; +int slice_type; + +int cpb_delay; +int dpb_delay; +} VAAPIEncodeH264Picture; + typedef struct VAAPIEncodeH264Context { VAAPIEncodeContext common; @@ -67,19 +81,6 @@ typedef struct VAAPIEncodeH264Context { int fixed_qp_p; int fixed_qp_b; -// Stream state. -int frame_num; -int pic_order_cnt; -int next_frame_num; -int64_t last_idr_frame; -int64_t idr_pic_count; - -int primary_pic_type; -int slice_type; - -int cpb_delay; -int dpb_delay; - // Writer structures. CodedBitstreamContext *cbc; CodedBitstreamFragment current_access_unit; @@ -324,7 +325,7 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) if (ctx->gop_size == 1) dpb_frames = 0; else -dpb_frames = 1 + (ctx->b_per_p > 0); +dpb_frames = 1 + ctx->max_b_depth; if (avctx->level != FF_LEVEL_UNKNOWN) { sps->level_idc = avctx->level; @@ -353,8 +354,7 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) sps->log2_max_frame_num_minus4 = 4; sps->pic_order_cnt_type= 0; -sps->log2_max_pic_order_cnt_lsb_minus4 = -av_clip(av_log2(ctx->b_per_p + 1) - 2, 0, 12); +sps->log2_max_pic_order_cnt_lsb_minus4 = 4; sps->max_num_ref_frames = dpb_frames; @@ -493,8 +493,8 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) sps->vui.motion_vectors_over_pic_boundaries_flag = 1; sps->vui.log2_max_mv_length_horizontal = 15; sps->vui.log2_max_mv_length_vertical = 15; -sps->vui.max_num_reorder_frames= (ctx->b_per_p > 0); -sps->vui.max_dec_frame_buffering = sps->max_num_ref_frames; +sps->vui.max_num_reorder_frames= ctx->max_b_depth; +sps->vui.max_dec_frame_buffering = ctx->max_b_depth + 1; pps->nal_unit_header.nal_ref_idc = 3; pps->nal_unit_header.nal_unit_type = H264_NAL_PPS; @@ -615,6 +615,9 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, { VAAPIEncodeContext *ctx = avctx->priv_data; VAAPIEncodeH264Context *priv = avctx->priv_data; +VAAPIEncodeH264Picture *hpic = pic->priv_data; +VAAPIEncodePicture *prev = pic->prev; +VAAPIEncodeH264Picture *hprev = prev ? prev->priv_data : NULL; H264RawSPS *sps = &priv->raw_sps; VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params; int i; @@ -624,37 +627,39 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, if (pic->type == PICTURE_TYPE_IDR) { av_assert0(pic->display_order == pic->encode_order); -priv->frame_num = 0; -priv->next_frame_num = 1; -priv->cpb_delay = 0; -priv->last_idr_frame = pic->display_order; -++priv->idr_pic_count; - -priv->slice_type = 7; -priv->primary_pic_type = 0; + +hpic->frame_num = 0; +hpic->last_idr_frame = pic->display_order; +hpic->idr_pic_id = hprev ? hprev->idr_pic_id + 1 : 0; + +hpic->primary_pic_type = 0; +hpic->slice_type = 7; + +hpic->cpb_delay = 0; } else { -priv->frame_num = priv->next_frame_num; +av_assert0(prev); -if (pic->type != PICTURE_TYPE_B) { -// Reference picture, so frame_num advances. -priv->next_frame_num = (priv->frame_num + 1) & -((1 << (4 + sps->log2_max_frame_num_minus4)) - 1); -} -++priv->cpb_delay; +hpic->frame_num = hprev->frame_num + prev->is_reference & +((1 << (4 + sps->log2_max_frame_num_minus4)) - 1); + +hpic->last_idr_frame = hprev->last_idr_frame; +hpic->idr_pic_id = hprev->idr_pic_id; if (pic->type == PICTURE_TYPE_I) { -priv->slice_type = 7; -priv->primary_pic_type = 0; +hpic->slice_type = 7; +hpic->primary_pic_type = 0; } else if (pic->type == PICTURE_TYPE_P) { -priv->slice_type = 5; -priv->primary_pic_type = 1; +hpic->slice_type
[FFmpeg-devel] [PATCH v3 36/41] vaapi_encode: Allocate picture-private data in generic code
--- libavcodec/vaapi_encode.c | 15 --- libavcodec/vaapi_encode.h | 4 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 2c34cdce2c..a6981d69fa 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -526,14 +526,23 @@ static int vaapi_encode_discard(AVCodecContext *avctx, return 0; } -static VAAPIEncodePicture *vaapi_encode_alloc(void) +static VAAPIEncodePicture *vaapi_encode_alloc(AVCodecContext *avctx) { +VAAPIEncodeContext *ctx = avctx->priv_data; VAAPIEncodePicture *pic; pic = av_mallocz(sizeof(*pic)); if (!pic) return NULL; +if (ctx->codec->picture_priv_data_size > 0) { +pic->priv_data = av_mallocz(ctx->codec->picture_priv_data_size); +if (!pic->priv_data) { +av_freep(&pic); +return NULL; +} +} + pic->input_surface = VA_INVALID_ID; pic->recon_surface = VA_INVALID_ID; pic->output_buffer = VA_INVALID_ID; @@ -666,7 +675,7 @@ static int vaapi_encode_get_next(AVCodecContext *avctx, } } -pic = vaapi_encode_alloc(); +pic = vaapi_encode_alloc(avctx); if (!pic) return AVERROR(ENOMEM); @@ -695,7 +704,7 @@ static int vaapi_encode_get_next(AVCodecContext *avctx, for (i = 0; i < ctx->b_per_p && ctx->gop_counter < ctx->gop_size; i++) { -pic = vaapi_encode_alloc(); +pic = vaapi_encode_alloc(avctx); if (!pic) goto fail; diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 091889f9ae..33bdd16403 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -244,6 +244,10 @@ typedef struct VAAPIEncodeType { // add any necessary global parameters). int (*configure)(AVCodecContext *avctx); +// The size of any private data structure associated with each +// picture (can be zero if not required). +size_t picture_priv_data_size; + // The size of the parameter structures: // sizeof(VAEnc{type}ParameterBuffer{codec}). size_t sequence_params_size; -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 35/41] doc/encoders: Document -sei option to hevc_vaapi
--- doc/encoders.texi | 10 ++ 1 file changed, 10 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index d61a1cc4bc..3894774bef 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2663,6 +2663,16 @@ Include access unit delimiters in the stream (not included by default). Set @emph{general_tier_flag}. This may affect the level chosen for the stream if it is not explicitly specified. +@item sei +Set SEI message types to include. +Some combination of the following values: +@table @samp +@item hdr +Include HDR metadata if the input frames have it +(@emph{mastering_display_colour_volume} and @emph{content_light_level} +messages). +@end table + @end table @item mjpeg_vaapi -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 31/41] cbs_h264: Infer default VUI values if VUI parameters are not present
--- libavcodec/cbs_h264_syntax_template.c | 42 +++ 1 file changed, 42 insertions(+) diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 7befde4b68..32e6acd68e 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -213,6 +213,46 @@ static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw, return 0; } +static int FUNC(vui_parameters_default)(CodedBitstreamContext *ctx, +RWContext *rw, H264RawVUI *current, +H264RawSPS *sps) +{ +infer(aspect_ratio_idc, 0); + +infer(video_format, 5); +infer(video_full_range_flag,0); +infer(colour_primaries, 2); +infer(transfer_characteristics, 2); +infer(matrix_coefficients, 2); + +infer(chroma_sample_loc_type_top_field,0); +infer(chroma_sample_loc_type_bottom_field, 0); + +infer(fixed_frame_rate_flag, 0); +infer(low_delay_hrd_flag,1); + +infer(pic_struct_present_flag, 0); + +infer(motion_vectors_over_pic_boundaries_flag, 1); +infer(max_bytes_per_pic_denom, 2); +infer(max_bits_per_mb_denom, 1); +infer(log2_max_mv_length_horizontal, 15); +infer(log2_max_mv_length_vertical, 15); + +if ((sps->profile_idc == 44 || sps->profile_idc == 86 || + sps->profile_idc == 100 || sps->profile_idc == 110 || + sps->profile_idc == 122 || sps->profile_idc == 244) && +sps->constraint_set3_flag) { +infer(max_num_reorder_frames, 0); +infer(max_dec_frame_buffering, 0); +} else { +infer(max_num_reorder_frames, H264_MAX_DPB_FRAMES); +infer(max_dec_frame_buffering, H264_MAX_DPB_FRAMES); +} + +return 0; +} + static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current) { @@ -317,6 +357,8 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, flag(vui_parameters_present_flag); if (current->vui_parameters_present_flag) CHECK(FUNC(vui_parameters)(ctx, rw, ¤t->vui, current)); +else +CHECK(FUNC(vui_parameters_default)(ctx, rw, ¤t->vui, current)); CHECK(FUNC(rbsp_trailing_bits)(ctx, rw)); -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 34/41] vaapi_encode_h265: Set level based on stream if not set by user
Sets the level based on the stream properties if it is not explicitly set by the user. Also add a tier option to set general_tier_flag, since that affects the level choice. --- doc/encoders.texi | 4 libavcodec/vaapi_encode_h265.c | 40 +++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index ceddfdda64..d61a1cc4bc 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2659,6 +2659,10 @@ Include recovery points where appropriate (@emph{recovery_point} messages). @item aud Include access unit delimiters in the stream (not included by default). +@item tier +Set @emph{general_tier_flag}. This may affect the level chosen for the stream +if it is not explicitly specified. + @end table @item mjpeg_vaapi diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 45576868df..1ada973dd3 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "cbs.h" #include "cbs_h265.h" +#include "h265_profile_level.h" #include "hevc.h" #include "hevc_sei.h" #include "internal.h" @@ -48,6 +49,7 @@ typedef struct VAAPIEncodeH265Context { int qp; int aud; int profile; +int tier; int level; int sei; @@ -314,7 +316,7 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) ptl->general_profile_space = 0; ptl->general_profile_idc = avctx->profile; -ptl->general_tier_flag = 0; +ptl->general_tier_flag = priv->tier; if (chroma_format == 1) { ptl->general_profile_compatibility_flag[1] = bit_depth == 8; @@ -339,7 +341,25 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) ptl->general_lower_bit_rate_constraint_flag = 1; -ptl->general_level_idc = avctx->level; +if (avctx->level != FF_LEVEL_UNKNOWN) { +ptl->general_level_idc = avctx->level; +} else { +const H265LevelDescriptor *level; + +level = ff_h265_guess_level(ptl, avctx->bit_rate, +ctx->surface_width, ctx->surface_height, +1, 1, 1, (ctx->b_per_p > 0) + 1); +if (level) { +av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name); +ptl->general_level_idc = level->level_idc; +} else { +av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to " + "any normal level; using level 8.5.\n"); +ptl->general_level_idc = 255; +// The tier flag must be set in level 8.5. +ptl->general_tier_flag = 1; +} +} vps->vps_sub_layer_ordering_info_present_flag = 0; vps->vps_max_dec_pic_buffering_minus1[0] = (ctx->b_per_p > 0) + 1; @@ -1103,6 +1123,12 @@ static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx) if (avctx->level == FF_LEVEL_UNKNOWN) avctx->level = priv->level; +if (avctx->level != FF_LEVEL_UNKNOWN && avctx->level & ~0xff) { +av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit " + "in 8-bit unsigned integer.\n", avctx->level); +return AVERROR(EINVAL); +} + ctx->desired_packed_headers = VA_ENC_PACKED_HEADER_SEQUENCE | // VPS, SPS and PPS. VA_ENC_PACKED_HEADER_SLICE| // Slice headers. @@ -1145,9 +1171,17 @@ static const AVOption vaapi_encode_h265_options[] = { { PROFILE("rext", FF_PROFILE_HEVC_REXT) }, #undef PROFILE +{ "tier", "Set tier (general_tier_flag)", + OFFSET(tier), AV_OPT_TYPE_INT, + { .i64 = 0 }, 0, 1, FLAGS, "tier" }, +{ "main", NULL, 0, AV_OPT_TYPE_CONST, + { .i64 = 0 }, 0, 0, FLAGS, "tier" }, +{ "high", NULL, 0, AV_OPT_TYPE_CONST, + { .i64 = 1 }, 0, 0, FLAGS, "tier" }, + { "level", "Set level (general_level_idc)", OFFSET(level), AV_OPT_TYPE_INT, - { .i64 = 153 }, 0x00, 0xff, FLAGS, "level" }, + { .i64 = FF_LEVEL_UNKNOWN }, FF_LEVEL_UNKNOWN, 0xff, FLAGS, "level" }, #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \ { .i64 = value }, 0, 0, FLAGS, "level" -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 33/41] lavc/h265: Add some common code for profile/tier/level handling
Adds support for determining for level limits, including mapping PTL blocks to profiles to check profile-dependent level limits. --- libavcodec/h265_profile_level.c | 245 libavcodec/h265_profile_level.h | 89 2 files changed, 334 insertions(+) create mode 100644 libavcodec/h265_profile_level.c create mode 100644 libavcodec/h265_profile_level.h diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c new file mode 100644 index 00..aac1529c9b --- /dev/null +++ b/libavcodec/h265_profile_level.c @@ -0,0 +1,245 @@ +/* + * 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 "h265_profile_level.h" + + +static const H265LevelDescriptor h265_levels[] = { +// Name CpbFactor-MainMaxSliceSegmentsPerPicture +// | level_idc| CpbFactor-High MaxLumaSr BrFactor-High +// | | MaxLumaPs| | | MaxTileRows | BrFactor-Main | MinCr-Main +// | | | | | | | MaxTileCols | || MinCr-High +{ "1",30,36864,350, 0, 16, 1, 1, 552960,128, 0, 2, 2 }, +{ "2",60, 122880, 1500, 0, 16, 1, 1,3686400, 1500, 0, 2, 2 }, +{ "2.1", 63, 245760, 3000, 0, 20, 1, 1,7372800, 3000, 0, 2, 2 }, +{ "3",90, 552960, 6000, 0, 30, 2, 2, 16588800, 6000, 0, 2, 2 }, +{ "3.1", 93, 983040, 1, 0, 40, 3, 3, 33177600, 1, 0, 2, 2 }, +{ "4", 120, 2228224, 12000, 3, 75, 5, 5, 66846720, 12000, 3, 4, 4 }, +{ "4.1", 123, 2228224, 2, 5, 75, 5, 5, 133693440, 2, 5, 4, 4 }, +{ "5", 150, 8912896, 25000, 10, 200, 11, 10, 267386880, 25000, 10, 6, 4 }, +{ "5.1", 153, 8912896, 4, 16, 200, 11, 10, 534773760, 4, 16, 8, 4 }, +{ "5.2", 156, 8912896, 6, 24, 200, 11, 10, 1069547520, 6, 24, 8, 4 }, +{ "6", 180, 35651584, 6, 24, 600, 22, 20, 1069547520, 6, 24, 8, 4 }, +{ "6.1", 183, 35651584, 12, 48, 600, 22, 20, 2139095040, 12, 48, 8, 4 }, +{ "6.2", 186, 35651584, 24, 80, 600, 22, 20, 4278190080, 24, 80, 6, 4 }, +}; + +static const H265ProfileDescriptor h265_profiles[] = { +// profile_idc 8bit one-picture +// HT-profile | 422chroma| lower-bit-rate +// | 14bit| | 420chroma | | CpbVclFactor MinCrScaleFactor +// | | 12bit | | | monochrome|| CpbNalFactor| +// | | | 10bit | | | intra || | FormatCapabilityFactor +{ "Monochrome", // | | | | | || | | | + 4, 0, 2, 1, 1, 1, 1, 1, 1, 0, 0, 1, 667, 733, 1.000, 1.0 }, +{ "Monochrome 12", + 4, 0, 2, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1000, 1100, 1.500, 1.0 }, +{ "Monochrome 16", + 4, 0, 2, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1333, 1467, 2.000, 1.0 }, +{ "Main", + 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0 }, +{ "Screen-Extended Main", + 9, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.500, 1.0 }, +{ "Main 10", + 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.875, 1.0 }, +{ "Screen-Extended Main 10", + 9, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.875, 1.0 }, +{ "Main 12", + 4, 0, 2, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1500, 1650, 2.250, 1.0 }, +{ "Main Still Picture", + 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0 }, +{ "Main 4:2:2 10", + 4, 0, 2, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1667, 1833, 2.500, 0.5 }, +{ "Main 4:2:2 12", + 4, 0, 2, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, +{ "Main 4:4:4", + 4, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, +{ "High Throughput 4:4:4", + 5, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, +{ "Screen-Extended Main 4:4:4", + 9, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, +{ "Screen-Extended High Throughput 4:4:4", + 9, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, +{ "Main 4:4:4 10", + 4, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750
[FFmpeg-devel] [PATCH v3 30/41] cbs_h264: Fix profile typo
--- libavcodec/cbs_h264_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 1efa97dccb..7befde4b68 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -199,7 +199,7 @@ static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw, infer(log2_max_mv_length_vertical, 15); if ((sps->profile_idc == 44 || sps->profile_idc == 86 || - sps->profile_idc == 110 || sps->profile_idc == 110 || + sps->profile_idc == 100 || sps->profile_idc == 110 || sps->profile_idc == 122 || sps->profile_idc == 244) && sps->constraint_set3_flag) { infer(max_num_reorder_frames, 0); -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 29/41] cbs_h264: Fix default value for max mv lengths
A recent version of the standard changed the max and default to 15, from 16 in older versions. This updates the default to 15 to match, but the max stays as 16 so that we don't reject older streams. --- libavcodec/cbs_h264_syntax_template.c | 6 -- libavcodec/vaapi_encode_h264.c| 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libavcodec/cbs_h264_syntax_template.c b/libavcodec/cbs_h264_syntax_template.c index 027b555db6..1efa97dccb 100644 --- a/libavcodec/cbs_h264_syntax_template.c +++ b/libavcodec/cbs_h264_syntax_template.c @@ -185,6 +185,8 @@ static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw, flag(motion_vectors_over_pic_boundaries_flag); ue(max_bytes_per_pic_denom, 0, 16); ue(max_bits_per_mb_denom, 0, 16); +// The current version of the standard constrains this to be in +// [0,15], but older versions allow 16. ue(log2_max_mv_length_horizontal, 0, 16); ue(log2_max_mv_length_vertical, 0, 16); ue(max_num_reorder_frames, 0, H264_MAX_DPB_FRAMES); @@ -193,8 +195,8 @@ static int FUNC(vui_parameters)(CodedBitstreamContext *ctx, RWContext *rw, infer(motion_vectors_over_pic_boundaries_flag, 1); infer(max_bytes_per_pic_denom, 2); infer(max_bits_per_mb_denom, 1); -infer(log2_max_mv_length_horizontal, 16); -infer(log2_max_mv_length_vertical, 16); +infer(log2_max_mv_length_horizontal, 15); +infer(log2_max_mv_length_vertical, 15); if ((sps->profile_idc == 44 || sps->profile_idc == 86 || sps->profile_idc == 110 || sps->profile_idc == 110 || diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index e55ed0f59c..8feae0d42f 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -491,8 +491,8 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) sps->vui.bitstream_restriction_flag= 1; sps->vui.motion_vectors_over_pic_boundaries_flag = 1; -sps->vui.log2_max_mv_length_horizontal = 16; -sps->vui.log2_max_mv_length_vertical = 16; +sps->vui.log2_max_mv_length_horizontal = 15; +sps->vui.log2_max_mv_length_vertical = 15; sps->vui.max_num_reorder_frames= (ctx->b_per_p > 0); sps->vui.max_dec_frame_buffering = sps->max_num_ref_frames; -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 32/41] vaapi_encode_h265: Improve profile support
Set profile compatibility/constraint flags properly (including the constraint flags used for RExt profiles, as all streams we can currently generate are RExt-compatible), and use that to add support for the "Main Intra" and "Main 10 Intra" RExt subprofiles (for which we can re-use the existing Main and Main10 VAAPI profiles). --- libavcodec/Makefile| 2 +- libavcodec/vaapi_encode_h265.c | 70 ++ 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index d07a9073af..756779ec16 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -373,7 +373,7 @@ OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec_h2645.o OBJS-$(CONFIG_HEVC_QSV_ENCODER)+= qsvenc_hevc.o hevc_ps_enc.o \ hevc_data.o OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o -OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o +OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += h265_profile_level.o vaapi_encode_h265.o OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER)+= v4l2_m2m_dec.o OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER)+= v4l2_m2m_enc.o OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 6940a59240..45576868df 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -23,6 +23,7 @@ #include "libavutil/avassert.h" #include "libavutil/common.h" +#include "libavutil/pixdesc.h" #include "libavutil/opt.h" #include "libavutil/mastering_display_metadata.h" @@ -260,9 +261,12 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) H265RawVPS*vps = &priv->raw_vps; H265RawSPS*sps = &priv->raw_sps; H265RawPPS*pps = &priv->raw_pps; +H265RawProfileTierLevel *ptl = &vps->profile_tier_level; H265RawVUI*vui = &sps->vui; VAEncSequenceParameterBufferHEVC *vseq = ctx->codec_sequence_params; VAEncPictureParameterBufferHEVC *vpic = ctx->codec_picture_params; +const AVPixFmtDescriptor *desc; +int chroma_format, bit_depth; int i; memset(&priv->current_access_unit, 0, @@ -273,6 +277,25 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) memset(pps, 0, sizeof(*pps)); +desc = av_pix_fmt_desc_get(priv->common.input_frames->sw_format); +av_assert0(desc); +if (desc->nb_components == 1) { +chroma_format = 0; +} else { +if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1) { +chroma_format = 1; +} else if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 0) { +chroma_format = 2; +} else if (desc->log2_chroma_w == 0 && desc->log2_chroma_h == 0) { +chroma_format = 3; +} else { +av_log(avctx, AV_LOG_ERROR, "Chroma format of input pixel format " + "%s is not supported.\n", desc->name); +} +} +bit_depth = desc->comp[0].depth; + + // VPS vps->nal_unit_header = (H265RawNALUnitHeader) { @@ -289,19 +312,34 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx) vps->vps_max_sub_layers_minus1 = 0; vps->vps_temporal_id_nesting_flag = 1; -vps->profile_tier_level = (H265RawProfileTierLevel) { -.general_profile_space = 0, -.general_profile_idc = avctx->profile, -.general_tier_flag = 0, +ptl->general_profile_space = 0; +ptl->general_profile_idc = avctx->profile; +ptl->general_tier_flag = 0; -.general_progressive_source_flag= 1, -.general_interlaced_source_flag = 0, -.general_non_packed_constraint_flag = 1, -.general_frame_only_constraint_flag = 1, +if (chroma_format == 1) { +ptl->general_profile_compatibility_flag[1] = bit_depth == 8; +ptl->general_profile_compatibility_flag[2] = bit_depth <= 10; +} +ptl->general_profile_compatibility_flag[4] = 1; -.general_level_idc = avctx->level, -}; -vps->profile_tier_level.general_profile_compatibility_flag[avctx->profile & 31] = 1; +ptl->general_progressive_source_flag= 1; +ptl->general_interlaced_source_flag = 0; +ptl->general_non_packed_constraint_flag = 1; +ptl->general_frame_only_constraint_flag = 1; + +ptl->general_max_12bit_constraint_flag = bit_depth <= 12; +ptl->general_max_10bit_constraint_flag = bit_depth <= 10; +ptl->general_max_8bit_constraint_flag = bit_depth == 8; + +ptl->general_max_422chroma_constraint_flag = chroma_format <= 2; +ptl->general_max_420chroma_constraint_flag = chroma_format <= 1; +ptl->general_max_monochrome_constraint_flag = chroma_format == 0; + +ptl->general_intra_constraint_flag = ctx->gop_size == 1; + +ptl->general_lower_bit_rate_constraint_fl
[FFmpeg-devel] [PATCH v3 28/41] h264_metadata: Add option to set the level of the stream
--- doc/bitstream_filters.texi | 9 libavcodec/h264_metadata_bsf.c | 90 ++ 2 files changed, 99 insertions(+) diff --git a/doc/bitstream_filters.texi b/doc/bitstream_filters.texi index 7d7e97503a..d948c6d658 100644 --- a/doc/bitstream_filters.texi +++ b/doc/bitstream_filters.texi @@ -215,6 +215,15 @@ insert the string ``hello'' associated with the given UUID. @item delete_filler Deletes both filler NAL units and filler SEI messages. +@item level +Set the level in the SPS. Refer to H.264 section A.3 and tables A-1 +to A-5. + +The argument must be the name of a level (for example, @samp{4.2}), a +level_idc value (for example, @samp{42}), or the special name @samp{auto} +indicating that the filter should attempt to guess the level from the +input stream properties. + @end table @section h264_mp4toannexb diff --git a/libavcodec/h264_metadata_bsf.c b/libavcodec/h264_metadata_bsf.c index 90ad4aad98..991fcfa537 100644 --- a/libavcodec/h264_metadata_bsf.c +++ b/libavcodec/h264_metadata_bsf.c @@ -25,6 +25,7 @@ #include "cbs.h" #include "cbs_h264.h" #include "h264.h" +#include "h264_levels.h" #include "h264_sei.h" enum { @@ -39,6 +40,11 @@ enum { FLIP_VERTICAL = 2, }; +enum { +LEVEL_UNSET = -2, +LEVEL_AUTO = -1, +}; + typedef struct H264MetadataContext { const AVClass *class; @@ -74,6 +80,8 @@ typedef struct H264MetadataContext { int display_orientation; double rotate; int flip; + +int level; } H264MetadataContext; @@ -208,6 +216,58 @@ static int h264_metadata_update_sps(AVBSFContext *bsf, CROP(bottom, crop_unit_y); #undef CROP +if (ctx->level != LEVEL_UNSET) { +int level_idc; + +if (ctx->level == LEVEL_AUTO) { +const H264LevelDescriptor *desc; +int64_t bit_rate; +int width, height; + +if (sps->vui.nal_hrd_parameters_present_flag) { +bit_rate = (sps->vui.nal_hrd_parameters.bit_rate_value_minus1[0] + 1) * + (1 << (sps->vui.nal_hrd_parameters.bit_rate_scale + 6)); +} else if (sps->vui.vcl_hrd_parameters_present_flag) { +bit_rate = (sps->vui.vcl_hrd_parameters.bit_rate_value_minus1[0] + 1) * + (1 << (sps->vui.vcl_hrd_parameters.bit_rate_scale + 6)); +// Adjust for VCL vs. NAL limits. +bit_rate = bit_rate * 6 / 5; +} else { +bit_rate = 0; +} + +width = 16 * (sps->pic_width_in_mbs_minus1 + 1); +height = 16 * (sps->pic_height_in_map_units_minus1 + 1) * +(2 - sps->frame_mbs_only_flag); + +desc = ff_h264_guess_level(sps->profile_idc, bit_rate, + width, height, + sps->vui.max_dec_frame_buffering); +if (desc) { +level_idc = desc->level_idc; +} else { +av_log(bsf, AV_LOG_WARNING, "Stream does not appear to " + "conform to any level: using level 6.2.\n"); +level_idc = 62; +} +} else { +level_idc = ctx->level; +} + +if (level_idc == 9) { +if (sps->profile_idc == 66 || +sps->profile_idc == 77 || +sps->profile_idc == 88) { +sps->level_idc = 10; +sps->constraint_set3_flag = 1; +} else { +sps->level_idc = 9; +} +} else { +sps->level_idc = level_idc; +} +} + if (need_vui) sps->vui_parameters_present_flag = 1; @@ -683,6 +743,36 @@ static const AVOption h264_metadata_options[] = { 0, AV_OPT_TYPE_CONST, { .i64 = FLIP_VERTICAL }, .flags = FLAGS, .unit = "flip" }, +{ "level", "Set level (table A-1)", +OFFSET(level), AV_OPT_TYPE_INT, +{ .i64 = LEVEL_UNSET }, LEVEL_UNSET, 0xff, FLAGS, "level" }, +{ "auto", "Attempt to guess level from stream properties", +0, AV_OPT_TYPE_CONST, +{ .i64 = LEVEL_AUTO }, .flags = FLAGS, .unit = "level" }, +#define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \ +{ .i64 = value }, .flags = FLAGS, .unit = "level" +{ LEVEL("1", 10) }, +{ LEVEL("1b", 9) }, +{ LEVEL("1.1", 11) }, +{ LEVEL("1.2", 12) }, +{ LEVEL("1.3", 13) }, +{ LEVEL("2", 20) }, +{ LEVEL("2.1", 21) }, +{ LEVEL("2.2", 22) }, +{ LEVEL("3", 30) }, +{ LEVEL("3.1", 31) }, +{ LEVEL("3.2", 32) }, +{ LEVEL("4", 40) }, +{ LEVEL("4.1", 41) }, +{ LEVEL("4.2", 42) }, +{ LEVEL("5", 50) }, +{ LEVEL("5.1", 51) }, +{ LEVEL("5.2", 52) }, +{ LEVEL("6", 60) }, +{ LEVEL("6.1", 61) }, +{ LEVEL("6.2", 62) }, +#undef LEVEL + { NULL } }; -- 2.18.0 ___ ffmpeg-devel mailing list ffmpe
[FFmpeg-devel] [PATCH v3 27/41] vaapi_encode_h264: Set level based on stream if not set by user
--- libavcodec/vaapi_encode_h264.c | 40 ++ 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 0774ec25f9..e55ed0f59c 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -30,6 +30,7 @@ #include "cbs.h" #include "cbs_h264.h" #include "h264.h" +#include "h264_levels.h" #include "h264_sei.h" #include "internal.h" #include "vaapi_encode.h" @@ -294,6 +295,7 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) H264RawPPS*pps = &priv->raw_pps; VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params; VAEncPictureParameterBufferH264 *vpic = ctx->codec_picture_params; +int dpb_frames; memset(&priv->current_access_unit, 0, sizeof(priv->current_access_unit)); @@ -319,7 +321,32 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) sps->constraint_set5_flag = ctx->b_per_p == 0; } -sps->level_idc = avctx->level; +if (ctx->gop_size == 1) +dpb_frames = 0; +else +dpb_frames = 1 + (ctx->b_per_p > 0); + +if (avctx->level != FF_LEVEL_UNKNOWN) { +sps->level_idc = avctx->level; +} else { +const H264LevelDescriptor *level; + +level = ff_h264_guess_level(sps->profile_idc, +avctx->bit_rate, +priv->mb_width * 16, +priv->mb_height * 16, +dpb_frames); +if (level) { +av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name); +if (level->constraint_set3_flag) +sps->constraint_set3_flag = 1; +sps->level_idc = level->level_idc; +} else { +av_log(avctx, AV_LOG_WARNING, "Stream will not conform " + "to any level: using level 6.2.\n"); +sps->level_idc = 62; +} +} sps->seq_parameter_set_id = 0; sps->chroma_format_idc= 1; @@ -329,8 +356,7 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) sps->log2_max_pic_order_cnt_lsb_minus4 = av_clip(av_log2(ctx->b_per_p + 1) - 2, 0, 12); -sps->max_num_ref_frames = -ctx->gop_size == 1 ? 0 : 1 + (ctx->b_per_p > 0); +sps->max_num_ref_frames = dpb_frames; sps->pic_width_in_mbs_minus1= priv->mb_width - 1; sps->pic_height_in_map_units_minus1 = priv->mb_height - 1; @@ -938,6 +964,12 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx) return AVERROR_PATCHWELCOME; } +if (avctx->level != FF_LEVEL_UNKNOWN && avctx->level & ~0xff) { +av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit " + "in 8-bit unsigned integer.\n", avctx->level); +return AVERROR(EINVAL); +} + ctx->desired_packed_headers = VA_ENC_PACKED_HEADER_SEQUENCE | // SPS and PPS. VA_ENC_PACKED_HEADER_SLICE| // Slice headers. @@ -1005,7 +1037,7 @@ static const AVOption vaapi_encode_h264_options[] = { { "level", "Set level (level_idc)", OFFSET(level), AV_OPT_TYPE_INT, - { .i64 = 51 }, 0x00, 0xff, FLAGS, "level" }, + { .i64 = FF_LEVEL_UNKNOWN }, FF_LEVEL_UNKNOWN, 0xff, FLAGS, "level" }, #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \ { .i64 = value }, 0, 0, FLAGS, "level" -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 26/41] lavc/h264: Add common code for level handling
Including a unit test. --- libavcodec/Makefile| 3 +- libavcodec/h264_levels.c | 130 +++ libavcodec/h264_levels.h | 53 ++ libavcodec/tests/.gitignore| 1 + libavcodec/tests/h264_levels.c | 183 + tests/fate/libavcodec.mak | 5 + 6 files changed, 374 insertions(+), 1 deletion(-) create mode 100644 libavcodec/h264_levels.c create mode 100644 libavcodec/h264_levels.h create mode 100644 libavcodec/tests/h264_levels.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index cbbfc9af2e..d07a9073af 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -355,7 +355,7 @@ OBJS-$(CONFIG_H264_OMX_ENCODER)+= omx.o OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec_h2645.o OBJS-$(CONFIG_H264_QSV_ENCODER)+= qsvenc_h264.o OBJS-$(CONFIG_H264_RKMPP_DECODER) += rkmppdec.o -OBJS-$(CONFIG_H264_VAAPI_ENCODER) += vaapi_encode_h264.o +OBJS-$(CONFIG_H264_VAAPI_ENCODER) += h264_levels.o vaapi_encode_h264.o OBJS-$(CONFIG_H264_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o OBJS-$(CONFIG_H264_V4L2M2M_DECODER)+= v4l2_m2m_dec.o OBJS-$(CONFIG_H264_V4L2M2M_ENCODER)+= v4l2_m2m_enc.o @@ -1134,6 +1134,7 @@ TESTPROGS-$(CONFIG_IDCTDSP) += dct TESTPROGS-$(CONFIG_IIRFILTER) += iirfilter TESTPROGS-$(HAVE_MMX) += motion TESTPROGS-$(CONFIG_MPEGVIDEO) += mpeg12framerate +TESTPROGS-$(CONFIG_H264_VAAPI_ENCODER)+= h264_levels TESTPROGS-$(CONFIG_RANGECODER)+= rangecoder TESTPROGS-$(CONFIG_SNOW_ENCODER) += snowenc diff --git a/libavcodec/h264_levels.c b/libavcodec/h264_levels.c new file mode 100644 index 00..6b4e18a914 --- /dev/null +++ b/libavcodec/h264_levels.c @@ -0,0 +1,130 @@ +/* + * 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 "avcodec.h" +#include "h264_levels.h" + +// H.264 table A-1. +static const H264LevelDescriptor h264_levels[] = { +// Name MaxMBPS MaxBR MinCR +// | level_idc | MaxFS|MaxCPB| MaxMvsPer2Mb +// | | cs3f| | MaxDpbMbs | | MaxVmvR | | +{ "1", 10, 0, 1485, 99,396, 64,175, 64, 2, 0 }, +{ "1b", 10, 1, 1485, 99,396,128,350, 64, 2, 0 }, +{ "1b", 9, 0, 1485, 99,396,128,350, 64, 2, 0 }, +{ "1.1", 11, 0, 3000,396,900,192,500, 128, 2, 0 }, +{ "1.2", 12, 0, 6000,396, 2376,384, 1000, 128, 2, 0 }, +{ "1.3", 13, 0,11880,396, 2376,768, 2000, 128, 2, 0 }, +{ "2", 20, 0,11880,396, 2376, 2000, 2000, 128, 2, 0 }, +{ "2.1", 21, 0,19800,792, 4752, 4000, 4000, 256, 2, 0 }, +{ "2.2", 22, 0,20250, 1620, 8100, 4000, 4000, 256, 2, 0 }, +{ "3", 30, 0,40500, 1620, 8100, 1, 1, 256, 2, 32 }, +{ "3.1", 31, 0, 108000, 3600, 18000, 14000, 14000, 512, 4, 16 }, +{ "3.2", 32, 0, 216000, 5120, 20480, 2, 2, 512, 4, 16 }, +{ "4", 40, 0, 245760, 8192, 32768, 2, 25000, 512, 4, 16 }, +{ "4.1", 41, 0, 245760, 8192, 32768, 5, 62500, 512, 2, 16 }, +{ "4.2", 42, 0, 522240, 8704, 34816, 5, 62500, 512, 2, 16 }, +{ "5", 50, 0, 589824, 22080, 110400, 135000, 135000, 512, 2, 16 }, +{ "5.1", 51, 0, 983040, 36864, 184320, 24, 24, 512, 2, 16 }, +{ "5.2", 52, 0, 2073600, 36864, 184320, 24, 24, 512, 2, 16 }, +{ "6", 60, 0, 4177920, 139264, 696320, 24, 24, 8192, 2, 16 }, +{ "6.1", 61, 0, 8355840, 139264, 696320, 48, 48, 8192, 2, 16 }, +{ "6.2", 62, 0, 16711680, 139264, 696320, 80, 80, 8192, 2, 16 }, +}; + +// H.264 table A-2 plus values from A-1. +static const struct { +int profile_idc; +int cpb_br_vcl_factor; +int cpb_br_nal_factor; +} h264_br_factors[] = { +{ 66, 1000, 1200 }, +{ 77, 1000, 1200 }, +{ 88, 1000, 1200 }, +{ 100, 1250, 1500 }, +{ 110, 3000, 3600 }, +{ 122, 4000, 4800 }, +{ 244, 4000, 4800 }, +{ 44, 4000, 4800 }, +}; + +// We are only ever
[FFmpeg-devel] [PATCH v3 24/41] vaapi_encode_mjpeg: Use CBS to store parameters and write headers
Also adds greyscale, 4:2:2, 4:4:4 and RGB support. --- configure | 2 +- doc/encoders.texi | 17 +- libavcodec/vaapi_encode_mjpeg.c | 529 3 files changed, 347 insertions(+), 201 deletions(-) diff --git a/configure b/configure index f9e6f017ac..f8fc6f47b9 100755 --- a/configure +++ b/configure @@ -2944,7 +2944,7 @@ mjpeg_cuvid_decoder_deps="cuvid" mjpeg_qsv_encoder_deps="libmfx" mjpeg_qsv_encoder_select="qsvenc" mjpeg_vaapi_encoder_deps="VAEncPictureParameterBufferJPEG" -mjpeg_vaapi_encoder_select="vaapi_encode jpegtables" +mjpeg_vaapi_encoder_select="cbs_jpeg jpegtables vaapi_encode" mpeg1_cuvid_decoder_deps="cuvid" mpeg1_v4l2m2m_decoder_deps="v4l2_m2m mpeg1_v4l2_m2m" mpeg2_crystalhd_decoder_select="crystalhd" diff --git a/doc/encoders.texi b/doc/encoders.texi index b451142cfb..ceddfdda64 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2662,8 +2662,21 @@ Include access unit delimiters in the stream (not included by default). @end table @item mjpeg_vaapi -Always encodes using the standard quantisation and huffman tables - -@option{global_quality} scales the standard quantisation table (range 1-100). +Only baseline DCT encoding is supported. The encoder always uses the standard +quantisation and huffman tables - @option{global_quality} scales the standard +quantisation table (range 1-100). + +For YUV, 4:2:0, 4:2:2 and 4:4:4 subsampling modes are supported. RGB is also +supported, and will create an RGB JPEG. + +@table @option +@item jfif +Include JFIF header in each frame (not included by default). +@item huffman +Include standard huffman tables (on by default). Turning this off will save +a few hundred bytes in each output frame, but may lose compatibility with some +JPEG decoders which don't fully handle MJPEG. +@end table @item mpeg2_vaapi @option{profile} and @option{level} set the value of @emph{profile_and_level_indication}. diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index 332053ae34..db9b36321a 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -23,9 +23,12 @@ #include "libavutil/common.h" #include "libavutil/internal.h" #include "libavutil/opt.h" -#include "libavutil/pixfmt.h" +#include "libavutil/pixdesc.h" #include "avcodec.h" +#include "bytestream.h" +#include "cbs.h" +#include "cbs_jpeg.h" #include "internal.h" #include "jpegtables.h" #include "mjpeg.h" @@ -58,253 +61,346 @@ static const unsigned char vaapi_encode_mjpeg_quant_chrominance[64] = { typedef struct VAAPIEncodeMJPEGContext { VAAPIEncodeContext common; +// User options. +int jfif; +int huffman; + +// Derived settings. int quality; -int component_subsample_h[3]; -int component_subsample_v[3]; +uint8_t jfif_data[14]; + +// Writer structures. +JPEGRawFrameHeader frame_header; +JPEGRawScanscan; +JPEGRawApplicationData jfif_header; +JPEGRawQuantisationTableSpecification quant_tables; +JPEGRawHuffmanTableSpecification huffman_tables; -VAQMatrixBufferJPEG quant_tables; -VAHuffmanTableBufferJPEGBaseline huffman_tables; +CodedBitstreamContext *cbc; +CodedBitstreamFragment current_fragment; } VAAPIEncodeMJPEGContext; -static av_cold void vaapi_encode_mjpeg_copy_huffman(unsigned char *dst_lengths, -unsigned char *dst_values, -const unsigned char *src_lengths, -const unsigned char *src_values) +static int vaapi_encode_mjpeg_write_image_header(AVCodecContext *avctx, + VAAPIEncodePicture *pic, + VAAPIEncodeSlice *slice, + char *data, size_t *data_len) { -int i, mt; - -++src_lengths; +VAAPIEncodeMJPEGContext *priv = avctx->priv_data; +CodedBitstreamFragment *frag = &priv->current_fragment; +int err; + +if (priv->jfif) { +err = ff_cbs_insert_unit_content(priv->cbc, frag, -1, + JPEG_MARKER_APPN + 0, + &priv->jfif_header, NULL); +if (err < 0) +goto fail; +} -mt = 0; -for (i = 0; i < 16; i++) -mt += (dst_lengths[i] = src_lengths[i]); +err = ff_cbs_insert_unit_content(priv->cbc, frag, -1, + JPEG_MARKER_DQT, + &priv->quant_tables, NULL); +if (err < 0) +goto fail; + +err = ff_cbs_insert_unit_content(priv->cbc, frag, -1, + JPEG_MARKER_SOF0, + &priv->frame_header, NULL); +if (err < 0) +goto fail; + +if (priv->huffman) { +err = ff_cbs_inser
[FFmpeg-devel] [PATCH v3 21/41] doc/encoders: Add missing options to VAAPI encoders
--- doc/encoders.texi | 24 1 file changed, 24 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 861f9f4f1f..b451142cfb 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2631,12 +2631,36 @@ Use CABAC. @item cavlc Use CAVLC. @end table + +@item aud +Include access unit delimiters in the stream (not included by default). + +@item sei +Set SEI message types to include. +Some combination of the following values: +@table @samp +@item identifier +Include a @emph{user_data_unregistered} message containing information about +the encoder. +@item timing +Include picture timing parameters (@emph{buffering_period} and +@emph{pic_timing} messages). +@item recovery_point +Include recovery points where appropriate (@emph{recovery_point} messages). +@end table + @end table @item hevc_vaapi @option{profile} and @option{level} set the values of @emph{general_profile_idc} and @emph{general_level_idc} respectively. +@table @option +@item aud +Include access unit delimiters in the stream (not included by default). + +@end table + @item mjpeg_vaapi Always encodes using the standard quantisation and huffman tables - @option{global_quality} scales the standard quantisation table (range 1-100). -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 25/41] hwcontext_vaapi: Improve format mapping
Give the entries in the VAAPI format map table an explicit type and add functions to do the necessary lookups. Add another field to this table indicating whether the chroma planes are swapped (as in YV12), and use that rather than explicit comparisons where swapping is needed. --- libavutil/hwcontext_vaapi.c | 133 1 file changed, 76 insertions(+), 57 deletions(-) diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 4088a96be4..8624369bb9 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -87,57 +87,82 @@ typedef struct VAAPIMapping { int flags; } VAAPIMapping; -#define MAP(va, rt, av) { \ +typedef struct VAAPIFormat { +unsigned int fourcc; +unsigned int rt_format; +enum AVPixelFormat pix_fmt; +int chroma_planes_swapped; +} VAAPIFormatDescriptor; + +#define MAP(va, rt, av, swap_uv) { \ VA_FOURCC_ ## va, \ VA_RT_FORMAT_ ## rt, \ -AV_PIX_FMT_ ## av \ +AV_PIX_FMT_ ## av, \ +swap_uv, \ } // The map fourcc <-> pix_fmt isn't bijective because of the annoying U/V // plane swap cases. The frame handling below tries to hide these. -static const struct { -unsigned int fourcc; -unsigned int rt_format; -enum AVPixelFormat pix_fmt; -} vaapi_format_map[] = { -MAP(NV12, YUV420, NV12), -MAP(YV12, YUV420, YUV420P), // With U/V planes swapped. -MAP(IYUV, YUV420, YUV420P), +static const VAAPIFormatDescriptor vaapi_format_map[] = { +MAP(NV12, YUV420, NV12,0), #ifdef VA_FOURCC_I420 -MAP(I420, YUV420, YUV420P), +MAP(I420, YUV420, YUV420P, 0), #endif +MAP(YV12, YUV420, YUV420P, 1), +MAP(IYUV, YUV420, YUV420P, 0), +MAP(422H, YUV422, YUV422P, 0), #ifdef VA_FOURCC_YV16 -MAP(YV16, YUV422, YUV422P), // With U/V planes swapped. +MAP(YV16, YUV422, YUV422P, 1), #endif -MAP(422H, YUV422, YUV422P), -MAP(UYVY, YUV422, UYVY422), -MAP(YUY2, YUV422, YUYV422), -MAP(411P, YUV411, YUV411P), -MAP(422V, YUV422, YUV440P), -MAP(444P, YUV444, YUV444P), -MAP(Y800, YUV400, GRAY8), +MAP(UYVY, YUV422, UYVY422, 0), +MAP(YUY2, YUV422, YUYV422, 0), +MAP(411P, YUV411, YUV411P, 0), +MAP(422V, YUV422, YUV440P, 0), +MAP(444P, YUV444, YUV444P, 0), +MAP(Y800, YUV400, GRAY8, 0), #ifdef VA_FOURCC_P010 -MAP(P010, YUV420_10BPP, P010), +MAP(P010, YUV420_10BPP, P010, 0), #endif -MAP(BGRA, RGB32, BGRA), -MAP(BGRX, RGB32, BGR0), -MAP(RGBA, RGB32, RGBA), -MAP(RGBX, RGB32, RGB0), +MAP(BGRA, RGB32, BGRA, 0), +MAP(BGRX, RGB32, BGR0, 0), +MAP(RGBA, RGB32, RGBA, 0), +MAP(RGBX, RGB32, RGB0, 0), #ifdef VA_FOURCC_ABGR -MAP(ABGR, RGB32, ABGR), -MAP(XBGR, RGB32, 0BGR), +MAP(ABGR, RGB32, ABGR, 0), +MAP(XBGR, RGB32, 0BGR, 0), #endif -MAP(ARGB, RGB32, ARGB), -MAP(XRGB, RGB32, 0RGB), +MAP(ARGB, RGB32, ARGB, 0), +MAP(XRGB, RGB32, 0RGB, 0), }; #undef MAP -static enum AVPixelFormat vaapi_pix_fmt_from_fourcc(unsigned int fourcc) +static const VAAPIFormatDescriptor * +vaapi_format_from_fourcc(unsigned int fourcc) { int i; for (i = 0; i < FF_ARRAY_ELEMS(vaapi_format_map); i++) if (vaapi_format_map[i].fourcc == fourcc) -return vaapi_format_map[i].pix_fmt; -return AV_PIX_FMT_NONE; +return &vaapi_format_map[i]; +return NULL; +} + +static const VAAPIFormatDescriptor * +vaapi_format_from_pix_fmt(enum AVPixelFormat pix_fmt) +{ +int i; +for (i = 0; i < FF_ARRAY_ELEMS(vaapi_format_map); i++) +if (vaapi_format_map[i].pix_fmt == pix_fmt) +return &vaapi_format_map[i]; +return NULL; +} + +static enum AVPixelFormat vaapi_pix_fmt_from_fourcc(unsigned int fourcc) +{ +const VAAPIFormatDescriptor *desc; +desc = vaapi_format_from_fourcc(fourcc); +if (desc) +return desc->pix_fmt; +else +return AV_PIX_FMT_NONE; } static int vaapi_get_image_format(AVHWDeviceContext *hwdev, @@ -461,22 +486,16 @@ static int vaapi_frames_init(AVHWFramesContext *hwfc) AVVAAPIFramesContext *avfc = hwfc->hwctx; VAAPIFramesContext *ctx = hwfc->internal->priv; AVVAAPIDeviceContext *hwctx = hwfc->device_ctx->hwctx; +const VAAPIFormatDescriptor *desc; VAImageFormat *expected_format; AVBufferRef *test_surface = NULL; VASurfaceID test_surface_id; VAImage test_image; VAStatus vas; int err, i; -unsigned int fourcc, rt_format; -for (i = 0; i < FF_ARRAY_ELEMS(vaapi_format_map); i++) { -if (vaapi_format_map[i].pix_fmt == hwfc->sw_format) { -fourcc= vaapi_format_map[i].fourcc; -rt_format = vaapi_format_map[i].rt_format; -break; -} -} -if (i >= FF_ARRAY_ELEMS(vaapi_format_map)) { +desc = vaapi_format_from_pix_fmt(hwfc->sw_format); +if (!desc) { av_log(hwfc, AV_LOG_ERRO
[FFmpeg-devel] [PATCH v3 20/41] vaapi_encode_h26[45]: Make the AUD option a boolean
--- libavcodec/vaapi_encode_h264.c | 2 +- libavcodec/vaapi_encode_h265.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index bba6848f03..0774ec25f9 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -976,7 +976,7 @@ static const AVOption vaapi_encode_h264_options[] = { { "ac",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS, "coder" }, { "aud", "Include AUD", - OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, + OFFSET(aud), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, { "sei", "Set SEI to include", OFFSET(sei), AV_OPT_TYPE_FLAGS, diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index c40782a78e..6940a59240 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1093,7 +1093,7 @@ static const AVOption vaapi_encode_h265_options[] = { OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, 52, FLAGS }, { "aud", "Include AUD", - OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS }, + OFFSET(aud), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, { "profile", "Set profile (general_profile_idc)", OFFSET(profile), AV_OPT_TYPE_INT, -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 14/41] vaapi_encode: Always reapply global parameters after the sequence header
The codec sequence headers may contain fields which can overwrite the fine parameters given in the specific settings (e.g. a crude bitrate value vs. the max-rate / target-percentage / etc. values in VAEncMiscParameterRateControl). Always reapply all global parameters after a sequence header to avoid this causing problems. --- libavcodec/vaapi_encode.c | 20 +--- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 35a4e90f67..1969c9252f 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -207,9 +207,16 @@ static int vaapi_encode_issue(AVCodecContext *avctx, pic->nb_param_buffers = 0; -if (pic->encode_order == 0) { -// Global parameter buffers are set on the first picture only. +if (pic->type == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) { +err = vaapi_encode_make_param_buffer(avctx, pic, + VAEncSequenceParameterBufferType, + ctx->codec_sequence_params, + ctx->codec->sequence_params_size); +if (err < 0) +goto fail; +} +if (pic->type == PICTURE_TYPE_IDR) { for (i = 0; i < ctx->nb_global_params; i++) { err = vaapi_encode_make_param_buffer(avctx, pic, VAEncMiscParameterBufferType, @@ -220,15 +227,6 @@ static int vaapi_encode_issue(AVCodecContext *avctx, } } -if (pic->type == PICTURE_TYPE_IDR && ctx->codec->init_sequence_params) { -err = vaapi_encode_make_param_buffer(avctx, pic, - VAEncSequenceParameterBufferType, - ctx->codec_sequence_params, - ctx->codec->sequence_params_size); -if (err < 0) -goto fail; -} - if (ctx->codec->init_picture_params) { err = ctx->codec->init_picture_params(avctx, pic); if (err < 0) { -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 09/41] configure: Use pkgconfig for VAAPI
Set the minimum version to 0.35.0 (libva 1.3.0) and remove redundant configure tests. This also allows the proprietary libmfx fork of libva, which always shows the version number 0.99.0 (independent of the actual version). --- configure | 31 --- libavcodec/vaapi_decode.c | 2 -- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/configure b/configure index 9b5421d5a8..1aab3c60d7 100755 --- a/configure +++ b/configure @@ -2867,7 +2867,7 @@ vc1_vdpau_hwaccel_deps="vdpau" vc1_vdpau_hwaccel_select="vc1_decoder" vp8_nvdec_hwaccel_deps="nvdec" vp8_nvdec_hwaccel_select="vp8_decoder" -vp8_vaapi_hwaccel_deps="vaapi VAPictureParameterBufferVP8" +vp8_vaapi_hwaccel_deps="vaapi" vp8_vaapi_hwaccel_select="vp8_decoder" vp9_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_VP9" vp9_d3d11va_hwaccel_select="vp9_decoder" @@ -2921,7 +2921,6 @@ h264_qsv_decoder_select="h264_mp4toannexb_bsf h264_parser qsvdec" h264_qsv_encoder_select="qsvenc" h264_rkmpp_decoder_deps="rkmpp" h264_rkmpp_decoder_select="h264_mp4toannexb_bsf" -h264_vaapi_encoder_deps="VAEncPictureParameterBufferH264" h264_vaapi_encoder_select="cbs_h264 vaapi_encode" h264_v4l2m2m_decoder_deps="v4l2_m2m h264_v4l2_m2m" h264_v4l2m2m_encoder_deps="v4l2_m2m h264_v4l2_m2m" @@ -2952,7 +2951,6 @@ mpeg2_mmal_decoder_deps="mmal" mpeg2_mediacodec_decoder_deps="mediacodec" mpeg2_qsv_decoder_select="qsvdec mpegvideo_parser" mpeg2_qsv_encoder_select="qsvenc" -mpeg2_vaapi_encoder_deps="VAEncPictureParameterBufferMPEG2" mpeg2_vaapi_encoder_select="cbs_mpeg2 vaapi_encode" mpeg2_v4l2m2m_decoder_deps="v4l2_m2m mpeg2_v4l2_m2m" mpeg4_crystalhd_decoder_select="crystalhd" @@ -3335,7 +,7 @@ deconvolve_filter_select="fft" deinterlace_qsv_filter_deps="libmfx" deinterlace_vaapi_filter_deps="vaapi" delogo_filter_deps="gpl" -denoise_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer" +denoise_vaapi_filter_deps="vaapi" deshake_filter_select="pixelutils" dilation_opencl_filter_deps="opencl" drawtext_filter_deps="libfreetype" @@ -3383,7 +3381,7 @@ phase_filter_deps="gpl" pp7_filter_deps="gpl" pp_filter_deps="gpl postproc" prewitt_opencl_filter_deps="opencl" -procamp_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer" +procamp_vaapi_filter_deps="vaapi" program_opencl_filter_deps="opencl" pullup_filter_deps="gpl" removelogo_filter_deps="avcodec avformat swscale" @@ -3396,7 +3394,7 @@ scale2ref_filter_deps="swscale" scale_filter_deps="swscale" scale_qsv_filter_deps="libmfx" select_filter_select="pixelutils" -sharpness_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer" +sharpness_vaapi_filter_deps="vaapi" showcqt_filter_deps="avcodec avformat swscale" showcqt_filter_suggest="libfontconfig libfreetype" showcqt_filter_select="fft" @@ -3435,7 +3433,7 @@ libvmaf_filter_deps="libvmaf pthreads" zmq_filter_deps="libzmq" zoompan_filter_deps="swscale" zscale_filter_deps="libzimg const_nan" -scale_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer" +scale_vaapi_filter_deps="vaapi" vpp_qsv_filter_deps="libmfx" vpp_qsv_filter_select="qsvvpp" @@ -5909,13 +5907,9 @@ check_type "windows.h d3d11.h" "ID3D11VideoContext" check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602 check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC" -check_type "va/va.h va/va_dec_vp8.h" "VAPictureParameterBufferVP8" check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth -check_type "va/va.h va/va_vpp.h" "VAProcPipelineParameterBuffer" -check_type "va/va.h va/va_enc_h264.h" "VAEncPictureParameterBufferH264" check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC" check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG" -check_type "va/va.h va/va_enc_mpeg2.h" "VAEncPictureParameterBufferMPEG2" check_type "va/va.h va/va_enc_vp8.h" "VAEncPictureParameterBufferVP8" check_type "va/va.h va/va_enc_vp9.h" "VAEncPictureParameterBufferVP9" @@ -6331,18 +6325,17 @@ test_cpp <= 0.35.0" "va/va.h" vaInitialize if enabled vaapi; then -check_lib vaapi_drm "va/va.h va/va_drm.h" vaGetDisplayDRM -lva -lva-drm -check_lib vaapi_x11 "va/va.h va/va_x11.h" vaGetDisplay -lva -lva-x11 -lX11 -fi +check_pkg_config vaapi_drm "libva-drm" "va/va_drm.h" vaGetDisplayDRM + +if enabled xlib; then +check_pkg_config vaapi_x11 "libva-x11" "va/va_x11.h" vaGetDisplay +fi -enabled vaapi && check_cpp_condition vaapi_1 "va/va.h" "VA_CHECK_VERSION(1, 0, 0)" +fi if enabled_all opencl libdrm ; then check_type "CL/cl_intel.h" "clCreateImageFromFdINTEL_fn" && diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c index d0a6b5817d..ece75c0815 100644 --- a/libavcodec/vaapi_decode.c +++ b/libavcodec/vaapi_decode.c @@ -389,9 +389,7 @@ static const struct { MAP(VC1, VC1_MAIN,VC1Main ), MAP(VC1, VC1_COMPLEX, VC1Advanced ), MAP(VC1, VC1_ADVANCED,VC1Advanced ), -#if VA_CH
[FFmpeg-devel] [PATCH v3 17/41] vaapi_encode: Clean up the GOP structure configuration
Choose what types of reference frames will be used based on what types are available, and make the intra-only mode explicit (GOP size one, which must be used for MJPEG). --- libavcodec/vaapi_encode.c | 83 ++--- libavcodec/vaapi_encode.h | 1 + libavcodec/vaapi_encode_h264.c | 4 +- libavcodec/vaapi_encode_h265.c | 4 +- libavcodec/vaapi_encode_mjpeg.c | 1 + libavcodec/vaapi_encode_mpeg2.c | 2 +- libavcodec/vaapi_encode_vp8.c | 7 +-- libavcodec/vaapi_encode_vp9.c | 7 +-- 8 files changed, 68 insertions(+), 41 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index e9eeb6eb83..e48e703ab4 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -671,7 +671,7 @@ static int vaapi_encode_get_next(AVCodecContext *avctx, return AVERROR(ENOMEM); if (ctx->input_order == 0 || ctx->force_idr || -ctx->gop_counter >= avctx->gop_size) { +ctx->gop_counter >= ctx->gop_size) { pic->type = PICTURE_TYPE_IDR; ctx->force_idr = 0; ctx->gop_counter = 1; @@ -694,7 +694,7 @@ static int vaapi_encode_get_next(AVCodecContext *avctx, // encode-after it, but not exceeding the GOP size. for (i = 0; i < ctx->b_per_p && - ctx->gop_counter < avctx->gop_size; i++) { + ctx->gop_counter < ctx->gop_size; i++) { pic = vaapi_encode_alloc(); if (!pic) goto fail; @@ -1213,7 +1213,6 @@ static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx) int i; VAConfigAttrib attr[] = { -{ VAConfigAttribEncMaxRefFrames }, { VAConfigAttribEncPackedHeaders }, }; @@ -1236,24 +1235,6 @@ static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx) continue; } switch (attr[i].type) { -case VAConfigAttribEncMaxRefFrames: -{ -unsigned int ref_l0 = attr[i].value & 0x; -unsigned int ref_l1 = (attr[i].value >> 16) & 0x; - -if (avctx->gop_size > 1 && ref_l0 < 1) { -av_log(avctx, AV_LOG_ERROR, "P frames are not " - "supported (%#x).\n", attr[i].value); -return AVERROR(EINVAL); -} -if (avctx->max_b_frames > 0 && ref_l1 < 1) { -av_log(avctx, AV_LOG_WARNING, "B frames are not " - "supported (%#x) by the underlying driver.\n", - attr[i].value); -avctx->max_b_frames = 0; -} -} -break; case VAConfigAttribEncPackedHeaders: if (ctx->va_packed_headers & ~attr[i].value) { // This isn't fatal, but packed headers are always @@ -1469,6 +1450,54 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) return 0; } +static av_cold int vaapi_encode_init_gop_structure(AVCodecContext *avctx) +{ +VAAPIEncodeContext *ctx = avctx->priv_data; +VAStatus vas; +VAConfigAttrib attr = { VAConfigAttribEncMaxRefFrames }; +uint32_t ref_l0, ref_l1; + +vas = vaGetConfigAttributes(ctx->hwctx->display, +ctx->va_profile, +ctx->va_entrypoint, +&attr, 1); +if (vas != VA_STATUS_SUCCESS) { +av_log(avctx, AV_LOG_ERROR, "Failed to query reference frames " + "attribute: %d (%s).\n", vas, vaErrorStr(vas)); +return AVERROR_EXTERNAL; +} + +if (attr.value == VA_ATTRIB_NOT_SUPPORTED) { +ref_l0 = ref_l1 = 0; +} else { +ref_l0 = attr.value & 0x; +ref_l1 = attr.value >> 16 & 0x; +} + +if (avctx->gop_size <= 1) { +av_log(avctx, AV_LOG_VERBOSE, "Using intra frames only.\n"); +ctx->gop_size = 1; +} else if (ref_l0 < 1) { +av_log(avctx, AV_LOG_ERROR, "Driver does not support any " + "reference frames.\n"); +return AVERROR(EINVAL); +} else if (ref_l1 < 1 || avctx->max_b_frames < 1) { +av_log(avctx, AV_LOG_VERBOSE, "Using intra and P-frames " + "(supported references: %d / %d).\n", ref_l0, ref_l1); +ctx->gop_size = avctx->gop_size; +ctx->p_per_i = INT_MAX; +ctx->b_per_p = 0; +} else { +av_log(avctx, AV_LOG_VERBOSE, "Using intra, P- and B-frames " + "(supported references: %d / %d).\n", ref_l0, ref_l1); +ctx->gop_size = avctx->gop_size; +ctx->p_per_i = INT_MAX; +ctx->b_per_p = avctx->max_b_frames; +} + +return 0; +} + static av_cold int vaapi_encode_init_quality(AVCodecContext *avctx) { #if VA_CHECK_VERSION(0, 36, 0) @@ -1640,7 +1669,7 @@ static av_cold int vaapi_encode_create_recon_frames(AVCodecContext *avctx) ctx->recon_frames->height= ctx->surface_height; // At most three IDR/I/P frames and two runs o
[FFmpeg-devel] [PATCH v3 19/41] vaapi_encode_h264: Properly set constraint flags
constraint_set1_flag should be set for constrained baseline and main profiles, because the stream conforms to main profile. constraint_set3_flag should be set for high profile when the stream is intra-only. constraint_set4_flag should always be set for main and high profiles because interlaced encoding is not supported. constraint_set5_flag should be set for main and high profiles when B-frames are not used. Also fix the setting of max_num_ref_frames - use the gop_size value to check for intra-only rather than the constraint flag (which is not necessarily set). --- libavcodec/vaapi_encode_h264.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index b233a91d04..bba6848f03 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -305,10 +305,19 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) sps->nal_unit_header.nal_unit_type = H264_NAL_SPS; sps->profile_idc = avctx->profile & 0xff; -sps->constraint_set1_flag = -!!(avctx->profile & FF_PROFILE_H264_CONSTRAINED); -sps->constraint_set3_flag = -!!(avctx->profile & FF_PROFILE_H264_INTRA); + +if (avctx->profile == FF_PROFILE_H264_CONSTRAINED_BASELINE || +avctx->profile == FF_PROFILE_H264_MAIN) +sps->constraint_set1_flag = 1; + +if (avctx->profile == FF_PROFILE_H264_HIGH) +sps->constraint_set3_flag = ctx->gop_size == 1; + +if (avctx->profile == FF_PROFILE_H264_MAIN || +avctx->profile == FF_PROFILE_H264_HIGH) { +sps->constraint_set4_flag = 1; +sps->constraint_set5_flag = ctx->b_per_p == 0; +} sps->level_idc = avctx->level; @@ -321,8 +330,7 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) av_clip(av_log2(ctx->b_per_p + 1) - 2, 0, 12); sps->max_num_ref_frames = -(avctx->profile & FF_PROFILE_H264_INTRA) ? 0 : -1 + (ctx->b_per_p > 0); +ctx->gop_size == 1 ? 0 : 1 + (ctx->b_per_p > 0); sps->pic_width_in_mbs_minus1= priv->mb_width - 1; sps->pic_height_in_map_units_minus1 = priv->mb_height - 1; -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 08/41] vaapi_encode: Factorise out adding global parameters
--- libavcodec/vaapi_encode.c | 38 ++ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index cedf3d3549..313f55118e 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -960,6 +960,20 @@ fail: return err; } +static av_cold void vaapi_encode_add_global_param(AVCodecContext *avctx, + VAEncMiscParameterBuffer *buffer, + size_t size) +{ +VAAPIEncodeContext *ctx = avctx->priv_data; + +av_assert0(ctx->nb_global_params < MAX_GLOBAL_PARAMS); + +ctx->global_params [ctx->nb_global_params] = buffer; +ctx->global_params_size[ctx->nb_global_params] = size; + +++ctx->nb_global_params; +} + static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; @@ -1182,20 +1196,16 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) .min_qp= (avctx->qmin > 0 ? avctx->qmin : 0), .basic_unit_size = 0, }; -ctx->global_params[ctx->nb_global_params] = -&ctx->rc_params.misc; -ctx->global_params_size[ctx->nb_global_params++] = -sizeof(ctx->rc_params); +vaapi_encode_add_global_param(avctx, &ctx->rc_params.misc, + sizeof(ctx->rc_params)); ctx->hrd_params.misc.type = VAEncMiscParameterTypeHRD; ctx->hrd_params.hrd = (VAEncMiscParameterHRD) { .initial_buffer_fullness = hrd_initial_buffer_fullness, .buffer_size = hrd_buffer_size, }; -ctx->global_params[ctx->nb_global_params] = -&ctx->hrd_params.misc; -ctx->global_params_size[ctx->nb_global_params++] = -sizeof(ctx->hrd_params); +vaapi_encode_add_global_param(avctx, &ctx->hrd_params.misc, + sizeof(ctx->hrd_params)); if (avctx->framerate.num > 0 && avctx->framerate.den > 0) av_reduce(&fr_num, &fr_den, @@ -1208,10 +1218,8 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) ctx->fr_params.fr.framerate = (unsigned int)fr_den << 16 | fr_num; #if VA_CHECK_VERSION(0, 40, 0) -ctx->global_params[ctx->nb_global_params] = -&ctx->fr_params.misc; -ctx->global_params_size[ctx->nb_global_params++] = -sizeof(ctx->fr_params); +vaapi_encode_add_global_param(avctx, &ctx->fr_params.misc, + sizeof(ctx->fr_params)); #endif return 0; @@ -1467,10 +1475,8 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx) ctx->quality_params.quality.quality_level = avctx->compression_level; -ctx->global_params[ctx->nb_global_params] = -&ctx->quality_params.misc; -ctx->global_params_size[ctx->nb_global_params++] = -sizeof(ctx->quality_params); +vaapi_encode_add_global_param(avctx, &ctx->quality_params.misc, + sizeof(ctx->quality_params)); } #else av_log(avctx, AV_LOG_WARNING, "The encode compression level " -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 12/41] vaapi_encode_mpeg2: Add options
Include the common options, and also named options for setting the profile and level. --- libavcodec/vaapi_encode_mpeg2.c | 53 +++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index 7f6c7833da..db79d72115 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -30,6 +30,10 @@ typedef struct VAAPIEncodeMPEG2Context { VAAPIEncodeContext common; +// User options. +int profile; +int level; + // Derived settings. int mb_width; int mb_height; @@ -581,10 +585,18 @@ static const VAAPIEncodeType vaapi_encode_type_mpeg2 = { static av_cold int vaapi_encode_mpeg2_init(AVCodecContext *avctx) { -VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodeMPEG2Context *priv = avctx->priv_data; ctx->codec = &vaapi_encode_type_mpeg2; +if (avctx->profile == FF_PROFILE_UNKNOWN) +avctx->profile = priv->profile; +if (avctx->level == FF_LEVEL_UNKNOWN) +avctx->level = priv->level; + +// Reject unknown levels (these are required to set f_code for +// motion vector encoding). switch (avctx->level) { case 4: // High case 6: // High 1440 @@ -623,8 +635,37 @@ static av_cold int vaapi_encode_mpeg2_close(AVCodecContext *avctx) return ff_vaapi_encode_close(avctx); } +#define OFFSET(x) offsetof(VAAPIEncodeMPEG2Context, x) +#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) +static const AVOption vaapi_encode_mpeg2_options[] = { +VAAPI_ENCODE_COMMON_OPTIONS, + +{ "profile", "Set profile (in profile_and_level_indication)", + OFFSET(profile), AV_OPT_TYPE_INT, + { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 7, FLAGS, "profile" }, + +#define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \ + { .i64 = value }, 0, 0, FLAGS, "profile" +{ PROFILE("simple", FF_PROFILE_MPEG2_SIMPLE) }, +{ PROFILE("main", FF_PROFILE_MPEG2_MAIN) }, +#undef PROFILE + +{ "level", "Set level (in profile_and_level_indication)", + OFFSET(level), AV_OPT_TYPE_INT, + { .i64 = 4 }, 0, 15, FLAGS, "level" }, + +#define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \ + { .i64 = value }, 0, 0, FLAGS, "level" +{ LEVEL("low", 10) }, +{ LEVEL("main", 8) }, +{ LEVEL("high_1440", 6) }, +{ LEVEL("high", 4) }, +#undef LEVEL + +{ NULL }, +}; + static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = { -{ "level", "4" }, { "bf", "1" }, { "g", "120" }, { "i_qfactor", "1" }, @@ -635,6 +676,13 @@ static const AVCodecDefault vaapi_encode_mpeg2_defaults[] = { { NULL }, }; +static const AVClass vaapi_encode_mpeg2_class = { +.class_name = "mpeg2_vaapi", +.item_name = av_default_item_name, +.option = vaapi_encode_mpeg2_options, +.version= LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_mpeg2_vaapi_encoder = { .name = "mpeg2_vaapi", .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 (VAAPI)"), @@ -644,6 +692,7 @@ AVCodec ff_mpeg2_vaapi_encoder = { .init = &vaapi_encode_mpeg2_init, .encode2= &ff_vaapi_encode2, .close = &vaapi_encode_mpeg2_close, +.priv_class = &vaapi_encode_mpeg2_class, .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, .defaults = vaapi_encode_mpeg2_defaults, .pix_fmts = (const enum AVPixelFormat[]) { -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 06/41] vaapi_encode_vp9: Move options and common structures into context
--- libavcodec/vaapi_encode_vp9.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index 9108699ac3..6e62213bc9 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -33,21 +33,25 @@ typedef struct VAAPIEncodeVP9Context { +VAAPIEncodeContext common; + +// User options. +int loop_filter_level; +int loop_filter_sharpness; + +// Derived settings. int q_idx_idr; int q_idx_p; int q_idx_b; +// Stream state. + // Reference direction for B-like frames: // 0 - most recent P/IDR frame is last. // 1 - most recent P frame is golden. int last_ref_dir; } VAAPIEncodeVP9Context; -typedef struct VAAPIEncodeVP9Options { -int loop_filter_level; -int loop_filter_sharpness; -} VAAPIEncodeVP9Options; - #define vseq_var(name) vseq->name, name #define vseq_field(name) vseq->seq_fields.bits.name, name @@ -82,10 +86,8 @@ static int vaapi_encode_vp9_init_sequence_params(AVCodecContext *avctx) static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic) { -VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodeVP9Context *priv = avctx->priv_data; VAEncPictureParameterBufferVP9 *vpic = pic->codec_picture_params; -VAAPIEncodeVP9Context *priv = ctx->priv_data; -VAAPIEncodeVP9Options *opt = ctx->codec_options; int i; vpic->reconstructed_frame = pic->recon_surface; @@ -169,8 +171,8 @@ static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx, vpic->chroma_ac_qindex_delta = 0; vpic->chroma_dc_qindex_delta = 0; -vpic->filter_level= opt->loop_filter_level; -vpic->sharpness_level = opt->loop_filter_sharpness; +vpic->filter_level= priv->loop_filter_level; +vpic->sharpness_level = priv->loop_filter_sharpness; if (avctx->max_b_frames > 0 && pic->type == PICTURE_TYPE_P) priv->last_ref_dir = !priv->last_ref_dir; @@ -180,8 +182,7 @@ static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx, static av_cold int vaapi_encode_vp9_configure(AVCodecContext *avctx) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeVP9Context *priv = ctx->priv_data; +VAAPIEncodeVP9Context *priv = avctx->priv_data; priv->q_idx_p = av_clip(avctx->global_quality, 0, VP9_MAX_QUANT); if (avctx->i_quant_factor > 0.0) @@ -266,8 +267,7 @@ static av_cold int vaapi_encode_vp9_init(AVCodecContext *avctx) return ff_vaapi_encode_init(avctx); } -#define OFFSET(x) (offsetof(VAAPIEncodeContext, codec_options_data) + \ - offsetof(VAAPIEncodeVP9Options, x)) +#define OFFSET(x) offsetof(VAAPIEncodeVP9Context, x) #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) static const AVOption vaapi_encode_vp9_options[] = { { "loop_filter_level", "Loop filter level", @@ -298,8 +298,7 @@ AVCodec ff_vp9_vaapi_encoder = { .long_name = NULL_IF_CONFIG_SMALL("VP9 (VAAPI)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP9, -.priv_data_size = (sizeof(VAAPIEncodeContext) + - sizeof(VAAPIEncodeVP9Options)), +.priv_data_size = sizeof(VAAPIEncodeVP9Context), .init = &vaapi_encode_vp9_init, .encode2= &ff_vaapi_encode2, .close = &ff_vaapi_encode_close, -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 05/41] vaapi_encode_vp8: Move options and common structures into context
--- libavcodec/vaapi_encode_vp8.c | 31 ++- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/libavcodec/vaapi_encode_vp8.c b/libavcodec/vaapi_encode_vp8.c index a2e861a8d1..ab5e0b2dda 100644 --- a/libavcodec/vaapi_encode_vp8.c +++ b/libavcodec/vaapi_encode_vp8.c @@ -32,14 +32,16 @@ typedef struct VAAPIEncodeVP8Context { -int q_index_i; -int q_index_p; -} VAAPIEncodeVP8Context; +VAAPIEncodeContext common; -typedef struct VAAPIEncodeVP8Options { +// User options. int loop_filter_level; int loop_filter_sharpness; -} VAAPIEncodeVP8Options; + +// Derived settings. +int q_index_i; +int q_index_p; +} VAAPIEncodeVP8Context; #define vseq_var(name) vseq->name, name @@ -73,9 +75,8 @@ static int vaapi_encode_vp8_init_sequence_params(AVCodecContext *avctx) static int vaapi_encode_vp8_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic) { -VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodeVP8Context *priv = avctx->priv_data; VAEncPictureParameterBufferVP8 *vpic = pic->codec_picture_params; -VAAPIEncodeVP8Options *opt = ctx->codec_options; int i; vpic->reconstructed_frame = pic->recon_surface; @@ -116,8 +117,8 @@ static int vaapi_encode_vp8_init_picture_params(AVCodecContext *avctx, vpic->pic_flags.bits.version = 0; vpic->pic_flags.bits.loop_filter_type = 0; for (i = 0; i < 4; i++) -vpic->loop_filter_level[i] = opt->loop_filter_level; -vpic->sharpness_level = opt->loop_filter_sharpness; +vpic->loop_filter_level[i] = priv->loop_filter_level; +vpic->sharpness_level = priv->loop_filter_sharpness; vpic->clamp_qindex_low = 0; vpic->clamp_qindex_high = 127; @@ -130,8 +131,7 @@ static int vaapi_encode_vp8_write_quant_table(AVCodecContext *avctx, int index, int *type, char *data, size_t *data_len) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeVP8Context *priv = ctx->priv_data; +VAAPIEncodeVP8Context *priv = avctx->priv_data; VAQMatrixBufferVP8 quant; int i, q; @@ -161,8 +161,7 @@ static int vaapi_encode_vp8_write_quant_table(AVCodecContext *avctx, static av_cold int vaapi_encode_vp8_configure(AVCodecContext *avctx) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeVP8Context *priv = ctx->priv_data; +VAAPIEncodeVP8Context *priv = avctx->priv_data; priv->q_index_p = av_clip(avctx->global_quality, 0, VP8_MAX_QUANT); if (avctx->i_quant_factor > 0.0) @@ -225,8 +224,7 @@ static av_cold int vaapi_encode_vp8_init(AVCodecContext *avctx) return ff_vaapi_encode_init(avctx); } -#define OFFSET(x) (offsetof(VAAPIEncodeContext, codec_options_data) + \ - offsetof(VAAPIEncodeVP8Options, x)) +#define OFFSET(x) offsetof(VAAPIEncodeVP8Context, x) #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) static const AVOption vaapi_encode_vp8_options[] = { { "loop_filter_level", "Loop filter level", @@ -256,8 +254,7 @@ AVCodec ff_vp8_vaapi_encoder = { .long_name = NULL_IF_CONFIG_SMALL("VP8 (VAAPI)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP8, -.priv_data_size = (sizeof(VAAPIEncodeContext) + - sizeof(VAAPIEncodeVP8Options)), +.priv_data_size = sizeof(VAAPIEncodeVP8Context), .init = &vaapi_encode_vp8_init, .encode2= &ff_vaapi_encode2, .close = &ff_vaapi_encode_close, -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 07/41] vaapi_encode: Remove common priv_data and options fields
The codec-specific context now contains both the common context and the codec-specific options directly. --- libavcodec/vaapi_encode.c | 10 -- libavcodec/vaapi_encode.h | 11 --- libavcodec/vaapi_encode_h264.c | 2 -- libavcodec/vaapi_encode_h265.c | 2 -- libavcodec/vaapi_encode_mjpeg.c | 2 -- libavcodec/vaapi_encode_mpeg2.c | 2 -- libavcodec/vaapi_encode_vp8.c | 2 -- libavcodec/vaapi_encode_vp9.c | 2 -- 8 files changed, 33 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 910fd1b365..cedf3d3549 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1372,17 +1372,9 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx) return AVERROR(EINVAL); } -ctx->codec_options = ctx->codec_options_data; - ctx->va_config = VA_INVALID_ID; ctx->va_context = VA_INVALID_ID; -ctx->priv_data = av_mallocz(ctx->codec->priv_data_size); -if (!ctx->priv_data) { -err = AVERROR(ENOMEM); -goto fail; -} - ctx->input_frames_ref = av_buffer_ref(avctx->hw_frames_ctx); if (!ctx->input_frames_ref) { err = AVERROR(ENOMEM); @@ -1583,7 +1575,5 @@ av_cold int ff_vaapi_encode_close(AVCodecContext *avctx) av_buffer_unref(&ctx->input_frames_ref); av_buffer_unref(&ctx->device_ref); -av_freep(&ctx->priv_data); - return 0; } diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index bcb9d57371..c7370a17e2 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -113,9 +113,6 @@ typedef struct VAAPIEncodeContext { // Everything above this point must be set before calling // ff_vaapi_encode_init(). -// Codec-specific state. -void *priv_data; - // Configuration attributes to use when creating va_config. VAConfigAttrib config_attributes[MAX_CONFIG_ATTRIBUTES]; int nb_config_attributes; @@ -205,18 +202,10 @@ typedef struct VAAPIEncodeContext { int gop_counter; int p_counter; int end_of_stream; - -// Codec-local options are allocated to follow this structure in -// memory (in the AVCodec definition, set priv_data_size to -// sizeof(VAAPIEncodeContext) + sizeof(VAAPIEncodeFooOptions)). -void *codec_options; -char codec_options_data[0]; } VAAPIEncodeContext; typedef struct VAAPIEncodeType { -size_t priv_data_size; - // Perform any extra codec-specific configuration after the // codec context is initialised (set up the private data and // add any necessary global parameters). diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 9be05b20a5..b65c9943e5 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -867,8 +867,6 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx) } static const VAAPIEncodeType vaapi_encode_type_h264 = { -.priv_data_size= sizeof(VAAPIEncodeH264Context), - .configure = &vaapi_encode_h264_configure, .sequence_params_size = sizeof(VAEncSequenceParameterBufferH264), diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index 757fd74c30..8f191efc4b 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -1026,8 +1026,6 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx) } static const VAAPIEncodeType vaapi_encode_type_h265 = { -.priv_data_size= sizeof(VAAPIEncodeH265Context), - .configure = &vaapi_encode_h265_configure, .sequence_params_size = sizeof(VAEncSequenceParameterBufferHEVC), diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index 983c77d194..481981a71c 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -360,8 +360,6 @@ static av_cold int vaapi_encode_mjpeg_configure(AVCodecContext *avctx) } static const VAAPIEncodeType vaapi_encode_type_mjpeg = { -.priv_data_size= sizeof(VAAPIEncodeMJPEGContext), - .configure = &vaapi_encode_mjpeg_configure, .picture_params_size = sizeof(VAEncPictureParameterBufferJPEG), diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index ae77a9ce76..5577fa9e04 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -553,8 +553,6 @@ static av_cold int vaapi_encode_mpeg2_configure(AVCodecContext *avctx) } static const VAAPIEncodeType vaapi_encode_type_mpeg2 = { -.priv_data_size= sizeof(VAAPIEncodeMPEG2Context), - .configure = &vaapi_encode_mpeg2_configure, .sequence_params_size = sizeof(VAEncSequenceParameterBufferMPEG2), diff --git a/libavcodec/vaapi_encode_vp8.c b/libavcodec/vaapi_encode_vp8.c index ab5e0b2dda..6cdd30abda 100644 --- a/libavcodec/vaapi_encode_vp8.c +++ b/libavcodec/vaapi_encode_vp8.c @@ -178,8 +178,6 @@ static av_cold i
[FFmpeg-devel] [PATCH v3 10/41] vaapi_encode: Choose profiles dynamically
Previously there was one fixed choice for each codec (e.g. H.265 -> Main profile), and using anything else then required an explicit option from the user. This changes to selecting the profile based on the input format and the set of profiles actually supported by the driver (e.g. P010 input will choose Main 10 profile for H.265 if the driver supports it). The entrypoint and render target format are also chosen dynamically in the same way, removing those explicit selections from the per-codec code. --- doc/encoders.texi | 3 + libavcodec/vaapi_encode.c | 276 +--- libavcodec/vaapi_encode.h | 43 - libavcodec/vaapi_encode_h264.c | 45 ++ libavcodec/vaapi_encode_h265.c | 35 ++-- libavcodec/vaapi_encode_mjpeg.c | 13 +- libavcodec/vaapi_encode_mpeg2.c | 36 + libavcodec/vaapi_encode_vp8.c | 11 +- libavcodec/vaapi_encode_vp9.c | 34 +--- 9 files changed, 315 insertions(+), 181 deletions(-) diff --git a/doc/encoders.texi b/doc/encoders.texi index 7b095754d1..16be6359b3 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -2565,6 +2565,9 @@ The following standard libavcodec options are used: @option{bf} / @option{max_b_frames} @item @option{profile} + +If not set, this will be determined automatically from the format of the input +frames and the profiles supported by the driver. @item @option{level} @item diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 313f55118e..f838ee5bd5 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -974,70 +974,252 @@ static av_cold void vaapi_encode_add_global_param(AVCodecContext *avctx, ++ctx->nb_global_params; } -static av_cold int vaapi_encode_config_attributes(AVCodecContext *avctx) +typedef struct VAAPIEncodeRTFormat { +const char *name; +unsigned int value; +int depth; +int nb_components; +int log2_chroma_w; +int log2_chroma_h; +} VAAPIEncodeRTFormat; + +static const VAAPIEncodeRTFormat vaapi_encode_rt_formats[] = { +{ "YUV400",VA_RT_FORMAT_YUV400,8, 1, }, +{ "YUV420",VA_RT_FORMAT_YUV420,8, 3, 1, 1 }, +{ "YUV422",VA_RT_FORMAT_YUV422,8, 3, 1, 0 }, +{ "YUV444",VA_RT_FORMAT_YUV444,8, 3, 0, 0 }, +{ "YUV411",VA_RT_FORMAT_YUV411,8, 3, 2, 0 }, +#if VA_CHECK_VERSION(0, 38, 1) +{ "YUV420_10", VA_RT_FORMAT_YUV420_10BPP, 10, 3, 1, 1 }, +#endif +}; + +static const VAEntrypoint vaapi_encode_entrypoints_normal[] = { +VAEntrypointEncSlice, +VAEntrypointEncPicture, +#if VA_CHECK_VERSION(0, 39, 2) +VAEntrypointEncSliceLP, +#endif +0 +}; +#if VA_CHECK_VERSION(0, 39, 2) +static const VAEntrypoint vaapi_encode_entrypoints_low_power[] = { +VAEntrypointEncSliceLP, +0 +}; +#endif + +static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx) { -VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodeContext *ctx = avctx->priv_data; +VAProfile*va_profiles= NULL; +VAEntrypoint *va_entrypoints = NULL; VAStatus vas; -int i, n, err; -VAProfile*profiles= NULL; -VAEntrypoint *entrypoints = NULL; -VAConfigAttrib attr[] = { -{ VAConfigAttribRTFormat }, -{ VAConfigAttribRateControl }, -{ VAConfigAttribEncMaxRefFrames }, -{ VAConfigAttribEncPackedHeaders }, -}; +const VAEntrypoint *usable_entrypoints; +const VAAPIEncodeProfile *profile; +const AVPixFmtDescriptor *desc; +VAConfigAttrib rt_format_attr; +const VAAPIEncodeRTFormat *rt_format; +const char *profile_string, *entrypoint_string; +int i, j, n, depth, err; + + +if (ctx->low_power) { +#if VA_CHECK_VERSION(0, 39, 2) +usable_entrypoints = vaapi_encode_entrypoints_low_power; +#else +av_log(avctx, AV_LOG_ERROR, "Low-power encoding is not " + "supported with this VAAPI version.\n"); +return AVERROR(EINVAL); +#endif +} else { +usable_entrypoints = vaapi_encode_entrypoints_normal; +} + +desc = av_pix_fmt_desc_get(ctx->input_frames->sw_format); +if (!desc) { +av_log(avctx, AV_LOG_ERROR, "Invalid input pixfmt (%d).\n", + ctx->input_frames->sw_format); +return AVERROR(EINVAL); +} +depth = desc->comp[0].depth; +for (i = 1; i < desc->nb_components; i++) { +if (desc->comp[i].depth != depth) { +av_log(avctx, AV_LOG_ERROR, "Invalid input pixfmt (%s).\n", + desc->name); +return AVERROR(EINVAL); +} +} +av_log(avctx, AV_LOG_VERBOSE, "Input surface format is %s.\n", + desc->name); n = vaMaxNumProfiles(ctx->hwctx->display); -profiles = av_malloc_array(n, sizeof(VAProfile)); -if (!profiles) { +va_profiles = av_malloc_array(n, sizeof(VAProfile)); +if (!va_profiles) { err = AVERROR(ENOMEM); goto fail; } -vas = vaQu
[FFmpeg-devel] [PATCH v3 03/41] vaapi_encode_mjpeg: Move common structure into context
--- libavcodec/vaapi_encode_mjpeg.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c index c949e89646..983c77d194 100644 --- a/libavcodec/vaapi_encode_mjpeg.c +++ b/libavcodec/vaapi_encode_mjpeg.c @@ -56,6 +56,8 @@ static const unsigned char vaapi_encode_mjpeg_quant_chrominance[64] = { }; typedef struct VAAPIEncodeMJPEGContext { +VAAPIEncodeContext common; + int quality; int component_subsample_h[3]; int component_subsample_v[3]; @@ -83,8 +85,7 @@ static av_cold void vaapi_encode_mjpeg_copy_huffman(unsigned char *dst_lengths, static av_cold void vaapi_encode_mjpeg_init_tables(AVCodecContext *avctx) { -VAAPIEncodeContext*ctx = avctx->priv_data; -VAAPIEncodeMJPEGContext *priv = ctx->priv_data; +VAAPIEncodeMJPEGContext *priv = avctx->priv_data; VAQMatrixBufferJPEG *quant = &priv->quant_tables; VAHuffmanTableBufferJPEGBaseline *huff = &priv->huffman_tables; int i; @@ -133,10 +134,9 @@ static int vaapi_encode_mjpeg_write_image_header(AVCodecContext *avctx, VAAPIEncodeSlice *slice, char *data, size_t *data_len) { -VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodeMJPEGContext *priv = avctx->priv_data; VAEncPictureParameterBufferJPEG *vpic = pic->codec_picture_params; VAEncSliceParameterBufferJPEG *vslice = slice->codec_slice_params; -VAAPIEncodeMJPEGContext *priv = ctx->priv_data; PutBitContext pbc; int t, i, quant_scale; @@ -242,8 +242,7 @@ static int vaapi_encode_mjpeg_write_extra_buffer(AVCodecContext *avctx, int index, int *type, char *data, size_t *data_len) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeMJPEGContext *priv = ctx->priv_data; +VAAPIEncodeMJPEGContext *priv = avctx->priv_data; if (index == 0) { // Write quantisation tables. @@ -270,9 +269,8 @@ static int vaapi_encode_mjpeg_write_extra_buffer(AVCodecContext *avctx, static int vaapi_encode_mjpeg_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic) { -VAAPIEncodeContext *ctx = avctx->priv_data; +VAAPIEncodeMJPEGContext *priv = avctx->priv_data; VAEncPictureParameterBufferJPEG *vpic = pic->codec_picture_params; -VAAPIEncodeMJPEGContext *priv = ctx->priv_data; vpic->reconstructed_picture = pic->recon_surface; vpic->coded_buf = pic->output_buffer; @@ -336,7 +334,7 @@ static int vaapi_encode_mjpeg_init_slice_params(AVCodecContext *avctx, static av_cold int vaapi_encode_mjpeg_configure(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeMJPEGContext *priv = ctx->priv_data; +VAAPIEncodeMJPEGContext *priv = avctx->priv_data; priv->quality = avctx->global_quality; if (priv->quality < 1 || priv->quality > 100) { @@ -417,7 +415,7 @@ AVCodec ff_mjpeg_vaapi_encoder = { .long_name = NULL_IF_CONFIG_SMALL("MJPEG (VAAPI)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_MJPEG, -.priv_data_size = sizeof(VAAPIEncodeContext), +.priv_data_size = sizeof(VAAPIEncodeMJPEGContext), .init = &vaapi_encode_mjpeg_init, .encode2= &ff_vaapi_encode2, .close = &ff_vaapi_encode_close, -- 2.18.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH v3 04/41] vaapi_encode_mpeg2: Move common structure into context
--- libavcodec/vaapi_encode_mpeg2.c | 53 - 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c index 42df77ea49..ae77a9ce76 100644 --- a/libavcodec/vaapi_encode_mpeg2.c +++ b/libavcodec/vaapi_encode_mpeg2.c @@ -28,6 +28,9 @@ #include "vaapi_encode.h" typedef struct VAAPIEncodeMPEG2Context { +VAAPIEncodeContext common; + +// Derived settings. int mb_width; int mb_height; @@ -35,15 +38,6 @@ typedef struct VAAPIEncodeMPEG2Context { int quant_p; int quant_b; -MPEG2RawSequenceHeader sequence_header; -MPEG2RawExtensionData sequence_extension; -MPEG2RawExtensionData sequence_display_extension; -MPEG2RawGroupOfPicturesHeader gop_header; -MPEG2RawPictureHeader picture_header; -MPEG2RawExtensionData picture_coding_extension; - -int64_t last_i_frame; - unsigned int bit_rate; unsigned int vbv_buffer_size; @@ -52,6 +46,17 @@ typedef struct VAAPIEncodeMPEG2Context { unsigned int f_code_horizontal; unsigned int f_code_vertical; +// Stream state. +int64_t last_i_frame; + +// Writer structures. +MPEG2RawSequenceHeader sequence_header; +MPEG2RawExtensionData sequence_extension; +MPEG2RawExtensionData sequence_display_extension; +MPEG2RawGroupOfPicturesHeader gop_header; +MPEG2RawPictureHeader picture_header; +MPEG2RawExtensionData picture_coding_extension; + CodedBitstreamContext *cbc; CodedBitstreamFragment current_fragment; } VAAPIEncodeMPEG2Context; @@ -61,8 +66,7 @@ static int vaapi_encode_mpeg2_write_fragment(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *frag) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeMPEG2Context *priv = ctx->priv_data; +VAAPIEncodeMPEG2Context *priv = avctx->priv_data; int err; err = ff_cbs_write_fragment_data(priv->cbc, frag); @@ -88,8 +92,7 @@ static int vaapi_encode_mpeg2_add_header(AVCodecContext *avctx, CodedBitstreamFragment *frag, int type, void *header) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeMPEG2Context *priv = ctx->priv_data; +VAAPIEncodeMPEG2Context *priv = avctx->priv_data; int err; err = ff_cbs_insert_unit_content(priv->cbc, frag, -1, type, header, NULL); @@ -105,8 +108,7 @@ static int vaapi_encode_mpeg2_add_header(AVCodecContext *avctx, static int vaapi_encode_mpeg2_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeMPEG2Context *priv = ctx->priv_data; +VAAPIEncodeMPEG2Context *priv = avctx->priv_data; CodedBitstreamFragment *frag = &priv->current_fragment; int err; @@ -140,8 +142,7 @@ static int vaapi_encode_mpeg2_write_picture_header(AVCodecContext *avctx, VAAPIEncodePicture *pic, char *data, size_t *data_len) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeMPEG2Context *priv = ctx->priv_data; +VAAPIEncodeMPEG2Context *priv = avctx->priv_data; CodedBitstreamFragment *frag = &priv->current_fragment; int err; @@ -164,7 +165,7 @@ fail: static int vaapi_encode_mpeg2_init_sequence_params(AVCodecContext *avctx) { VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeMPEG2Context *priv = ctx->priv_data; +VAAPIEncodeMPEG2Context *priv = avctx->priv_data; MPEG2RawSequenceHeader *sh = &priv->sequence_header; MPEG2RawSequenceExtension *se = &priv->sequence_extension.data.sequence; MPEG2RawSequenceDisplayExtension *sde = &priv->sequence_display_extension.data.sequence_display; @@ -416,8 +417,7 @@ static int vaapi_encode_mpeg2_init_sequence_params(AVCodecContext *avctx) static int vaapi_encode_mpeg2_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic) { -VAAPIEncodeContext*ctx = avctx->priv_data; -VAAPIEncodeMPEG2Context *priv = ctx->priv_data; +VAAPIEncodeMPEG2Context *priv = avctx->priv_data; MPEG2RawPictureHeader *ph = &priv->picture_header; MPEG2RawPictureCodingExtension*pce = &priv->picture_coding_extension.data.picture_coding; VAEncPictureParameterBufferMPEG2 *vpic = pic->codec_picture_params; @@ -482,9 +482,8 @@ static int vaapi_encode_mpeg2_init_slice_params(AVCodecContext *avctx, VAAPIEncodePicture *pic,
[FFmpeg-devel] [PATCH v3 02/41] vaapi_encode_h265: Move options and common structures into context
Matching previous commit for H.264. --- libavcodec/vaapi_encode_h265.c | 182 - 1 file changed, 90 insertions(+), 92 deletions(-) diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c index bbba2b8cd9..757fd74c30 100644 --- a/libavcodec/vaapi_encode_h265.c +++ b/libavcodec/vaapi_encode_h265.c @@ -41,6 +41,16 @@ enum { }; typedef struct VAAPIEncodeH265Context { +VAAPIEncodeContext common; + +// User options. +int qp; +int aud; +int profile; +int level; +int sei; + +// Derived settings. unsigned int ctu_width; unsigned int ctu_height; @@ -48,16 +58,7 @@ typedef struct VAAPIEncodeH265Context { int fixed_qp_p; int fixed_qp_b; -H265RawAUD aud; -H265RawVPS vps; -H265RawSPS sps; -H265RawPPS pps; -H265RawSlice slice; -H265RawSEI sei; - -H265RawSEIMasteringDisplayColourVolume mastering_display; -H265RawSEIContentLightLevelInfo content_light_level; - +// Stream state. int64_t last_idr_frame; int pic_order_cnt; @@ -65,27 +66,29 @@ typedef struct VAAPIEncodeH265Context { int slice_type; int pic_type; +// Writer structures. +H265RawAUD raw_aud; +H265RawVPS raw_vps; +H265RawSPS raw_sps; +H265RawPPS raw_pps; +H265RawSEI raw_sei; +H265RawSlice raw_slice; + +H265RawSEIMasteringDisplayColourVolume sei_mastering_display; +H265RawSEIContentLightLevelInfosei_content_light_level; + CodedBitstreamContext *cbc; CodedBitstreamFragment current_access_unit; int aud_needed; int sei_needed; } VAAPIEncodeH265Context; -typedef struct VAAPIEncodeH265Options { -int qp; -int aud; -int profile; -int level; -int sei; -} VAAPIEncodeH265Options; - static int vaapi_encode_h265_write_access_unit(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *au) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeH265Context *priv = ctx->priv_data; +VAAPIEncodeH265Context *priv = avctx->priv_data; int err; err = ff_cbs_write_fragment_data(priv->cbc, au); @@ -111,8 +114,7 @@ static int vaapi_encode_h265_add_nal(AVCodecContext *avctx, CodedBitstreamFragment *au, void *nal_unit) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeH265Context *priv = ctx->priv_data; +VAAPIEncodeH265Context *priv = avctx->priv_data; H265RawNALUnitHeader *header = nal_unit; int err; @@ -130,27 +132,26 @@ static int vaapi_encode_h265_add_nal(AVCodecContext *avctx, static int vaapi_encode_h265_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeH265Context *priv = ctx->priv_data; +VAAPIEncodeH265Context *priv = avctx->priv_data; CodedBitstreamFragment *au = &priv->current_access_unit; int err; if (priv->aud_needed) { -err = vaapi_encode_h265_add_nal(avctx, au, &priv->aud); +err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_aud); if (err < 0) goto fail; priv->aud_needed = 0; } -err = vaapi_encode_h265_add_nal(avctx, au, &priv->vps); +err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_vps); if (err < 0) goto fail; -err = vaapi_encode_h265_add_nal(avctx, au, &priv->sps); +err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_sps); if (err < 0) goto fail; -err = vaapi_encode_h265_add_nal(avctx, au, &priv->pps); +err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_pps); if (err < 0) goto fail; @@ -165,19 +166,18 @@ static int vaapi_encode_h265_write_slice_header(AVCodecContext *avctx, VAAPIEncodeSlice *slice, char *data, size_t *data_len) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeH265Context *priv = ctx->priv_data; +VAAPIEncodeH265Context *priv = avctx->priv_data; CodedBitstreamFragment *au = &priv->current_access_unit; int err; if (priv->aud_needed) { -err = vaapi_encode_h265_add_nal(avctx, au, &priv->aud); +err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_aud); if (err < 0) goto fail; priv->aud_needed = 0; } -err = vaapi_encode_h265_add_nal(avctx, au, &priv->slice); +err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_slice); if (err < 0) goto fail; @@ -192,12 +192,13 @@ static int vaapi_encode_h265_write_extra_header(AVCodecContext *avctx, int index, int *type,
[FFmpeg-devel] [PATCH v3 01/41] vaapi_encode_h264: Move options and common structures into context
This will make it easier to support options in common between different encoders. It also cleans up some of the field naming. --- libavcodec/vaapi_encode_h264.c | 226 + 1 file changed, 114 insertions(+), 112 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index 905c50760e..9be05b20a5 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -47,6 +47,19 @@ static const uint8_t vaapi_encode_h264_sei_identifier_uuid[16] = { }; typedef struct VAAPIEncodeH264Context { +VAAPIEncodeContext common; + +// User options. +int qp; +int quality; +int low_power; +int coder; +int aud; +int sei; +int profile; +int level; + +// Derived settings. int mb_width; int mb_height; @@ -54,18 +67,7 @@ typedef struct VAAPIEncodeH264Context { int fixed_qp_p; int fixed_qp_b; -H264RawAUD aud; -H264RawSPS sps; -H264RawPPS pps; -H264RawSEI sei; -H264RawSlice slice; - -H264RawSEIBufferingPeriod buffering_period; -H264RawSEIPicTiming pic_timing; -H264RawSEIRecoveryPoint recovery_point; -H264RawSEIUserDataUnregistered identifier; -char *identifier_string; - +// Stream state. int frame_num; int pic_order_cnt; int next_frame_num; @@ -78,32 +80,33 @@ typedef struct VAAPIEncodeH264Context { int cpb_delay; int dpb_delay; +// Writer structures. CodedBitstreamContext *cbc; CodedBitstreamFragment current_access_unit; + +H264RawAUD raw_aud; +H264RawSPS raw_sps; +H264RawPPS raw_pps; +H264RawSEI raw_sei; +H264RawSlice raw_slice; + +H264RawSEIBufferingPeriod sei_buffering_period; +H264RawSEIPicTimingsei_pic_timing; +H264RawSEIRecoveryPointsei_recovery_point; +H264RawSEIUserDataUnregistered sei_identifier; +char *sei_identifier_string; + int aud_needed; int sei_needed; int sei_cbr_workaround_needed; } VAAPIEncodeH264Context; -typedef struct VAAPIEncodeH264Options { -int qp; -int quality; -int low_power; -// Entropy encoder type. -int coder; -int aud; -int sei; -int profile; -int level; -} VAAPIEncodeH264Options; - static int vaapi_encode_h264_write_access_unit(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *au) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeH264Context *priv = ctx->priv_data; +VAAPIEncodeH264Context *priv = avctx->priv_data; int err; err = ff_cbs_write_fragment_data(priv->cbc, au); @@ -129,8 +132,7 @@ static int vaapi_encode_h264_add_nal(AVCodecContext *avctx, CodedBitstreamFragment *au, void *nal_unit) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeH264Context *priv = ctx->priv_data; +VAAPIEncodeH264Context *priv = avctx->priv_data; H264RawNALUnitHeader *header = nal_unit; int err; @@ -148,23 +150,22 @@ static int vaapi_encode_h264_add_nal(AVCodecContext *avctx, static int vaapi_encode_h264_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeH264Context *priv = ctx->priv_data; +VAAPIEncodeH264Context *priv = avctx->priv_data; CodedBitstreamFragment *au = &priv->current_access_unit; int err; if (priv->aud_needed) { -err = vaapi_encode_h264_add_nal(avctx, au, &priv->aud); +err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud); if (err < 0) goto fail; priv->aud_needed = 0; } -err = vaapi_encode_h264_add_nal(avctx, au, &priv->sps); +err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_sps); if (err < 0) goto fail; -err = vaapi_encode_h264_add_nal(avctx, au, &priv->pps); +err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_pps); if (err < 0) goto fail; @@ -179,19 +180,18 @@ static int vaapi_encode_h264_write_slice_header(AVCodecContext *avctx, VAAPIEncodeSlice *slice, char *data, size_t *data_len) { -VAAPIEncodeContext *ctx = avctx->priv_data; -VAAPIEncodeH264Context *priv = ctx->priv_data; +VAAPIEncodeH264Context *priv = avctx->priv_data; CodedBitstreamFragment *au = &priv->current_access_unit; int err; if (priv->aud_needed) { -err = vaapi_encode_h264_add_nal(avctx, au, &priv->aud); +err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud); if (err < 0) goto fail; priv->aud_needed = 0;
[FFmpeg-devel] [PATCH] avcodec: add HYMT decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/huffyuvdec.c | 174 +++- libavformat/riff.c | 1 + 6 files changed, 128 insertions(+), 57 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9a309c348e..c9335f39fa 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -381,6 +381,7 @@ OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \ OBJS-$(CONFIG_HQX_DECODER) += hqx.o hqxvlc.o hqxdsp.o canopus.o OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o huffyuvdec.o OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o huffyuvenc.o +OBJS-$(CONFIG_HYMT_DECODER)+= huffyuv.o huffyuvdec.o OBJS-$(CONFIG_IDCIN_DECODER) += idcinvideo.o OBJS-$(CONFIG_IDF_DECODER) += bintext.o cga_data.o OBJS-$(CONFIG_IFF_ILBM_DECODER)+= iff.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index b1d1ef26c0..53ab6e0025 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -151,6 +151,7 @@ extern AVCodec ff_hq_hqa_decoder; extern AVCodec ff_hqx_decoder; extern AVCodec ff_huffyuv_encoder; extern AVCodec ff_huffyuv_decoder; +extern AVCodec ff_hymt_decoder; extern AVCodec ff_idcin_decoder; extern AVCodec ff_iff_ilbm_decoder; extern AVCodec ff_imm4_decoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2a4be2ca4f..d428be4741 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -449,6 +449,7 @@ enum AVCodecID { AV_CODEC_ID_FITS, AV_CODEC_ID_IMM4, AV_CODEC_ID_PROSUMER, +AV_CODEC_ID_HYMT, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index e611183599..362dc253c2 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1668,6 +1668,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_HYMT, +.type = AVMEDIA_TYPE_VIDEO, +.name = "hymt", +.long_name = NULL_IF_CONFIG_SMALL("HuffYUV MT"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, +}, /* various PCM "codecs" */ { diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 66357bfb40..b5b65510ed 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -905,54 +905,23 @@ static void add_median_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *s s->hdsp.add_hfyu_median_pred_int16((uint16_t *)dst, (const uint16_t *)src, (const uint16_t *)diff, s->n-1, w, left, left_top); } } -static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, -AVPacket *avpkt) + +static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height, +int buf_size, int y_offset) { -const uint8_t *buf = avpkt->data; -int buf_size = avpkt->size; HYuvContext *s = avctx->priv_data; +int fake_ystride, fake_ustride, fake_vstride; const int width = s->width; const int width2 = s->width >> 1; -const int height = s->height; -int fake_ystride, fake_ustride, fake_vstride; -ThreadFrame frame = { .f = data }; -AVFrame *const p = data; -int table_size = 0, ret; - -if (buf_size < (width * height + 7)/8) -return AVERROR_INVALIDDATA; - -av_fast_padded_malloc(&s->bitstream_buffer, - &s->bitstream_buffer_size, - buf_size); -if (!s->bitstream_buffer) -return AVERROR(ENOMEM); - -s->bdsp.bswap_buf((uint32_t *) s->bitstream_buffer, - (const uint32_t *) buf, buf_size / 4); - -if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) -return ret; - -if (s->context) { -table_size = read_huffman_tables(s, s->bitstream_buffer, buf_size); -if (table_size < 0) -return table_size; -} - -if ((unsigned) (buf_size - table_size) >= INT_MAX / 8) -return AVERROR_INVALIDDATA; +int ret; -if ((ret = init_get_bits(&s->gb, s->bitstream_buffer + table_size, - (buf_size - table_size) * 8)) < 0) +if ((ret = init_get_bits8(&s->gb, s->bitstream_buffer, buf_size)) < 0) return ret; fake_ystride = s->interlaced ? p->linesize[0] * 2 : p->linesize[0]; fake_ustride = s->interlaced ? p->linesize[1] * 2 : p->linesize[1]; fake_vstride = s->interlaced ? p->linesize[2] * 2 : p->linesize[2]; -s->last_slice_end = 0; - if (s->version > 2) { int plane; for(plane = 0; plane < 1 + 2*s->chroma + s->
Re: [FFmpeg-devel] [PATCH 4/7] Adds gray floating-point pixel formats.
> > But maybe to make tests simpler, we can use/add bit exact conversion > > for uint8 to float, we can generate a LUT without float calc > > and for uint16 to float, we can add a uint16 to float conversion without > > float calc, or maybe, generate a LUT in bit exact mode (probably faster, > if > > it's acceptable to have a LUT for 16bit entries) > > I think before you design everything around a non float based convertion > it would make sense to evaluate the speed of SIMD for the convertion. > so all the choices are understood > > > > > > If the bit exact mode is much slower than the "float" version we can keep > > both, > > this is possible, it is not ideal though as the tested and used in practice > code path differs then. Of course a bit exact version does make sense > either > way. As some people probably want scaling to be bitexact > > Having func too much complicated to test, have more chance to make func not tested at all Bit exact mode is convenient for testing inside ffmpeg, but also useful outside, for example to be sure transcoding pipeline still give the same output (when i can, i prefer to use this even if the conv is slower, because is more reliable). Following your comments, i propose for a first step to add bit_exact mode for float <-> uint8/16 where i can, keeping the current func (adding a test for SWS_BIT_EXACT, in order to choose the right func) In a second step, test simd for "float" version. If using SIMD (or not), we can have faster conv, using the "float" method, we keep each func otherwise we remove the non bit-exact version, and add a comment in the code. If we keep both func, we can make a test func by func, comparing bit exact with non bit-exact, in order to be sure, both way to make the conversion have similar result. Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Register for VDD 2018 conference
On 8/22/18, Dave Rice wrote: > >>> On Aug 22, 2018, at 14:12, Michael Niedermayer >>> wrote: >>> >>> On Wed, Aug 22, 2018 at 03:14:53PM +0200, Jean-Baptiste Kempf wrote: >>> Hello fellow devs, >>> >>> VideoLAN is happy to invite you to the usual conference of the end of the >>> summer: >>> VDD2018 is happening in Paris, for the 10 years of the original conf. >>> >>> As usual, this is a very technical conference focused on open source >>> multimedia development. >>> We will talk about AV1, FFv1, FFv2, x264/x265, VLC, FFmpeg and other >>> related technologies. >> >> what is FFv2 ? > > FFV2 is referenced in this patch http://akuvian.org/src/x264/ffv2.94.diff. > > Also FFV2 is referenced as a derivative experimental work from Daala. > https://twitter.com/atomnuker/status/924846477083578368?s=21 > > Also FFV2 is referenced by Reto Kromer as a forked alternative to the work > on FFV1 version 4 by the IETF cellar working group. > https://twitter.com/retokromer/status/884030201050648576?s=21 So we already have 3 FFV2 variants. Which of them are actually useful? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Register for VDD 2018 conference
>> On Aug 22, 2018, at 14:12, Michael Niedermayer >> wrote: >> >> On Wed, Aug 22, 2018 at 03:14:53PM +0200, Jean-Baptiste Kempf wrote: >> Hello fellow devs, >> >> VideoLAN is happy to invite you to the usual conference of the end of the >> summer: >> VDD2018 is happening in Paris, for the 10 years of the original conf. >> >> As usual, this is a very technical conference focused on open source >> multimedia development. >> We will talk about AV1, FFv1, FFv2, x264/x265, VLC, FFmpeg and other related >> technologies. > > what is FFv2 ? FFV2 is referenced in this patch http://akuvian.org/src/x264/ffv2.94.diff. Also FFV2 is referenced as a derivative experimental work from Daala. https://twitter.com/atomnuker/status/924846477083578368?s=21 Also FFV2 is referenced by Reto Kromer as a forked alternative to the work on FFV1 version 4 by the IETF cellar working group. https://twitter.com/retokromer/status/884030201050648576?s=21 Dave Rice ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 1/2] libavdevice/decklink: Add support for EIA-708 output over SDI
Hook in libklvanc and use it for output of EIA-708 captions over SDI. The bulk of this patch is just general support for ancillary data for the Decklink SDI module - the real work for construction of the EIA-708 CDP and VANC line construction is done by libklvanc. Libklvanc can be found at: https://github.com/stoth68000/libklvanc Updated to reflect feedback from Marton Balint , Carl Eugen Hoyos , Aaron Levinson , and Moritz Barsnick Signed-off-by: Devin Heitmueller --- configure | 4 + libavcodec/v210enc.c| 9 ++ libavdevice/decklink_common.cpp | 16 +++- libavdevice/decklink_common.h | 10 +++ libavdevice/decklink_enc.cpp| 179 ++-- 5 files changed, 207 insertions(+), 11 deletions(-) diff --git a/configure b/configure index 9b5421d5a8..ecc86c606f 100755 --- a/configure +++ b/configure @@ -239,6 +239,7 @@ External library support: --enable-libiec61883 enable iec61883 via libiec61883 [no] --enable-libilbc enable iLBC de/encoding via libilbc [no] --enable-libjack enable JACK audio sound server [no] + --enable-libklvanc enable Kernel Labs VANC processing [no] --enable-libkvazaar enable HEVC encoding via libkvazaar [no] --enable-liblensfun enable lensfun lens correction [no] --enable-libmodplug enable ModPlug via libmodplug [no] @@ -1700,6 +1701,7 @@ EXTERNAL_LIBRARY_LIST=" libiec61883 libilbc libjack +libklvanc libkvazaar libmodplug libmp3lame @@ -3210,6 +3212,7 @@ decklink_deps_any="libdl LoadLibrary" decklink_indev_deps="decklink threads" decklink_indev_extralibs="-lstdc++" decklink_outdev_deps="decklink threads" +decklink_outdev_suggest="libklvanc" decklink_outdev_extralibs="-lstdc++" libndi_newtek_indev_deps="libndi_newtek" libndi_newtek_indev_extralibs="-lndi" @@ -6034,6 +6037,7 @@ enabled libgsm&& { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do check_lib libgsm "${gsm_hdr}" gsm_create -lgsm && break; done || die "ERROR: libgsm not found"; } enabled libilbc && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc $pthreads_extralibs +enabled libklvanc && require libklvanc libklvanc/vanc.h klvanc_context_create -lklvanc enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 0.8.1" kvazaar.h kvz_api_get enabled liblensfun&& require_pkg_config liblensfun lensfun lensfun.h lf_db_new # While it may appear that require is being used as a pkg-config diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index a6afbbfc41..b9dcf9a672 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -123,6 +123,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, int aligned_width = ((avctx->width + 47) / 48) * 48; int stride = aligned_width * 8 / 3; int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4; +AVFrameSideData *side_data; int h, w, ret; uint8_t *dst; @@ -233,6 +234,14 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } } +side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_A53_CC); +if (side_data && side_data->size) { +uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_A53_CC, side_data->size); +if (!buf) +return AVERROR(ENOMEM); +memcpy(buf, side_data->data, side_data->size); +} + pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; return 0; diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp index aab9d85b94..503417bb35 100644 --- a/libavdevice/decklink_common.cpp +++ b/libavdevice/decklink_common.cpp @@ -239,10 +239,18 @@ int ff_decklink_set_format(AVFormatContext *avctx, &support, NULL) != S_OK) return -1; } else { -if (ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, bmdFormat8BitYUV, - bmdVideoOutputFlagDefault, - &support, NULL) != S_OK) -return -1; +if (!ctx->supports_vanc || ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, ctx->raw_format, + bmdVideoOutputVANC, + &support, NULL) != S_OK) { +/* Try without VANC enabled */ +if (ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, ctx->raw_format, + bmdVideoOutputFlagDefault, + &support, NULL) != S_OK) { +return -1; +} +ctx->supports_vanc = 0; +} + } if (support == bmdDisplayModeSupported) return 0; diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h index 96b001c2d8..12814
[FFmpeg-devel] [PATCH 0/2] Support for Decklink output of EIA-708 and AFD
The following patches add support for output of 708 and AFD over the Decklink SDI interface. This series is a subset of a series submitted in early January, with the hope of getting the less controversial parts merged upstream. Devin Heitmueller (2): libavdevice/decklink: Add support for EIA-708 output over SDI decklink: Add support for output of Active Format Description (AFD) configure | 4 + libavcodec/avcodec.h| 6 ++ libavcodec/v210enc.c| 17 +++ libavdevice/decklink_common.cpp | 16 ++- libavdevice/decklink_common.h | 10 ++ libavdevice/decklink_enc.cpp| 229 ++-- 6 files changed, 271 insertions(+), 11 deletions(-) -- 2.13.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 2/2] decklink: Add support for output of Active Format Description (AFD)
Implement support for including AFD in decklink output. This includes making sure the AFD data is preserved when going from an AVFrame to a V210 packet (needed for 10-bit support). Updated to reflect feedback from Marton Balint , Carl Eugen Hoyos and Aaron Levinson . Signed-off-by: Devin Heitmueller --- libavcodec/avcodec.h | 6 + libavcodec/v210enc.c | 8 +++ libavdevice/decklink_enc.cpp | 54 ++-- 3 files changed, 66 insertions(+), 2 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 31e50d5a94..192e15746d 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1362,6 +1362,12 @@ enum AVPacketSideDataType { AV_PKT_DATA_ENCRYPTION_INFO, /** + * Active Format Description data consisting of a single byte as specified + * in ETSI TS 101 154 using AVActiveFormatDescription enum. + */ +AV_PKT_DATA_AFD, + +/** * The number of side data types. * This is not part of the public API/ABI in the sense that it may * change when new side data types are added. diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index b9dcf9a672..b024806d0b 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -242,6 +242,14 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, memcpy(buf, side_data->data, side_data->size); } +side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_AFD); +if (side_data && side_data->size) { +uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_AFD, side_data->size); +if (!buf) +return AVERROR(ENOMEM); +memcpy(buf, side_data->data, side_data->size); +} + pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; return 0; diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp index de7758cb91..2d03d33554 100644 --- a/libavdevice/decklink_enc.cpp +++ b/libavdevice/decklink_enc.cpp @@ -303,7 +303,8 @@ av_cold int ff_decklink_write_trailer(AVFormatContext *avctx) #if CONFIG_LIBKLVANC static int decklink_construct_vanc(AVFormatContext *avctx, struct decklink_ctx *ctx, - AVPacket *pkt, decklink_frame *frame) + AVPacket *pkt, decklink_frame *frame, + AVStream *st) { struct klvanc_line_set_s vanc_lines = { 0 }; int ret, size, i; @@ -363,6 +364,55 @@ static int decklink_construct_vanc(AVFormatContext *avctx, struct decklink_ctx * } } +data = av_packet_get_side_data(pkt, AV_PKT_DATA_AFD, &size); +if (data) { +struct klvanc_packet_afd_s *pkt; +uint16_t *afd; +uint16_t len; + +ret = klvanc_create_AFD(&pkt); +if (ret) { +for (i = 0; i < vanc_lines.num_lines; i++) +klvanc_line_free(vanc_lines.lines[i]); +return AVERROR(ENOMEM); +} + +ret = klvanc_set_AFD_val(pkt, data[0]); +if (ret) { +av_log(avctx, AV_LOG_ERROR, "Invalid AFD value specified: %d\n", + data[0]); +klvanc_destroy_AFD(pkt); +for (i = 0; i < vanc_lines.num_lines; i++) +klvanc_line_free(vanc_lines.lines[i]); +return AVERROR(EINVAL); +} + +/* FIXME: Should really rely on the coded_width but seems like that + is not accessible to libavdevice outputs */ +if (av_cmp_q((AVRational) {st->codecpar->width, st->codecpar->height}, (AVRational) {4, 3}) == 1) +pkt->aspectRatio = ASPECT_16x9; +else +pkt->aspectRatio = ASPECT_4x3; + +ret = klvanc_convert_AFD_to_words(pkt, &afd, &len); +klvanc_destroy_AFD(pkt); +if (ret) { +av_log(avctx, AV_LOG_ERROR, "Failed converting AFD packet to words\n"); +for (i = 0; i < vanc_lines.num_lines; i++) +klvanc_line_free(vanc_lines.lines[i]); +return AVERROR(ENOMEM); +} + +ret = klvanc_line_insert(ctx->vanc_ctx, &vanc_lines, afd, len, 12, 0); +free(afd); +if (ret) { +av_log(avctx, AV_LOG_ERROR, "VANC line insertion failed\n"); +for (i = 0; i < vanc_lines.num_lines; i++) +klvanc_line_free(vanc_lines.lines[i]); +return AVERROR(ENOMEM); +} +} + IDeckLinkVideoFrameAncillary *vanc; int result = ctx->dlo->CreateAncillaryData(bmdFormat10BitYUV, &vanc); if (result != S_OK) { @@ -457,7 +507,7 @@ static int decklink_write_video_packet(AVFormatContext *avctx, AVPacket *pkt) frame = new decklink_frame(ctx, avpacket, st->codecpar->codec_id, ctx->bmd_height, ctx->bmd_width); #if CONFIG_LIBKLVANC -ret = decklink_construct_vanc(avctx, ctx, pkt, frame); +ret = decklink_construct_vanc(avctx, ctx, pkt, frame, st); if (ret) av_log(avctx, AV_LOG_ERROR, "Failed to con
Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert no-expensive-optimizations
On Wed, Aug 22, 2018 at 06:11:15PM +0800, Shiyou Yin wrote: > >-Original Message- > >From: ffmpeg-devel-boun...@ffmpeg.org > >[mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of > >Michael Niedermayer > >Sent: Wednesday, August 22, 2018 6:04 AM > >To: FFmpeg development discussions and patches > >Subject: Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert > >no-expensive-optimizations > > > >On Tue, Aug 21, 2018 at 04:06:05PM +0800, Shiyou Yin wrote: > >> >-Original Message- > >> >From: ffmpeg-devel-boun...@ffmpeg.org > >> >[mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Shiyou Yin > >> >Sent: Thursday, July 12, 2018 8:44 PM > >> >To: ffmpeg-devel@ffmpeg.org > >> >Subject: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert > >> >no-expensive-optimizations > >> > > >> >The bug in gcc-4.9.x has been fixed in gcc master branch. > >> >Loongson released gcc-4.9.3-3.fc21.loongson with this patch. > >> >More bug info see: > >> >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67736 > >> >https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00401.html > >> > > >> >Change-Id: I780125d4cdee71d40457aaee22126ba0547a2c8f > >> >Signed-off-by: Shiyou Yin > >> >--- > >> > configure | 6 +++--- > >> > 1 file changed, 3 insertions(+), 3 deletions(-) > >> > > >> >diff --git a/configure b/configure > >> >index b1a4dcf..17a7ea9 100755 > >> >--- a/configure > >> >+++ b/configure > >> >@@ -4789,13 +4789,13 @@ elif enabled mips; then > >> > disable mipsdspr2 > >> > case $cpu in > >> > loongson3*) > >> >-cpuflags="-march=loongson3a -mhard-float > >-fno-expensive-optimizations" > >> >+cpuflags="-march=loongson3a -mhard-float" > >> > ;; > >> > loongson2e) > >> >-cpuflags="-march=loongson2e -mhard-float > >-fno-expensive-optimizations" > >> >+cpuflags="-march=loongson2e -mhard-float" > >> > ;; > >> > loongson2f) > >> >-cpuflags="-march=loongson2f -mhard-float > >-fno-expensive-optimizations" > >> >+cpuflags="-march=loongson2f -mhard-float" > >> > ;; > >> > esac > >> > ;; > >> >-- > >> >2.1.0 > >> > > >> > >> Hi Michael, could you please help to apply this patch. It has been tested > >> on loongson platform. > > > >shouldnt this test the compiler the user uses ? its version or something ? > > > Thank you very much for your review. Be strictly, it's needed to check the > compiler version which > user uses. > Consider that this bug has been fixed about three years and the compiler has > been upgraded a lot of > times in loongson yum repository. > At present, there are still only a few developers will build ffmpeg on > loongson platform. The risk > of his change is controllable. > So, between the simplicity and absolute reliability of the code I chosed the > simplicity this time. > Should I still add version check here? I think there should maybe be a check for the minimum gcc version supported then to ensure that no too old version is used. If you do not want to add teh flag for specific versions The effect of the bug was IIRC not trivial to connect to the gcc version so it could leave a developer quite lost and confused what is causing it [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
On 8/22/18, Carl Eugen Hoyos wrote: > 2018-08-22 18:00 GMT+02:00, Paul B Mahol : > >> +switch (avctx->bits_per_coded_sample) { >> +case 12: >> + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; >> + break; >> +default: >> + return AVERROR_INVALIDDATA; >> +} > > Why are the condition and the error needed? Because only that is supported. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 4/7] Adds gray floating-point pixel formats.
On Wed, Aug 22, 2018 at 10:20:53AM +0200, Martin Vignali wrote: > > > > > So the only thing I can do is to disable these tests for > > > these formats. > > > Otherwise, I need to test other changes somehow. Here is the patch, that > > > skips > > > pixfmts tests for these formats. > > > > in absence of another solution this should be ok > > > > > I'm not against, removing these tests for now, > > But maybe to make tests simpler, we can use/add bit exact conversion > for uint8 to float, we can generate a LUT without float calc > and for uint16 to float, we can add a uint16 to float conversion without > float calc, or maybe, generate a LUT in bit exact mode (probably faster, if > it's acceptable to have a LUT for 16bit entries) I think before you design everything around a non float based convertion it would make sense to evaluate the speed of SIMD for the convertion. so all the choices are understood > > If the bit exact mode is much slower than the "float" version we can keep > both, this is possible, it is not ideal though as the tested and used in practice code path differs then. Of course a bit exact version does make sense either way. As some people probably want scaling to be bitexact > in order to use the bit exact for various tests > and use it as reference in order to compare bit exact and "float" conv for > each func. > > I can send patch for this, if need. > > Martin > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Rewriting code that is poorly written but fully understood is good. Rewriting code that one doesnt understand is a sign that one is less smart then the original author, trying to rewrite it will not make it better. signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] Register for VDD 2018 conference
On Wed, Aug 22, 2018 at 03:14:53PM +0200, Jean-Baptiste Kempf wrote: > Hello fellow devs, > > VideoLAN is happy to invite you to the usual conference of the end of the > summer: > VDD2018 is happening in Paris, for the 10 years of the original conf. > > As usual, this is a very technical conference focused on open source > multimedia development. > We will talk about AV1, FFv1, FFv2, x264/x265, VLC, FFmpeg and other related > technologies. what is FFv2 ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Observe your enemies, for they first find out your faults. -- Antisthenes signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
2018-08-22 18:00 GMT+02:00, Paul B Mahol : > +switch (avctx->bits_per_coded_sample) { > +case 12: > + s->stride = 3LL * FFALIGN(avctx->width, 8) >> 1; > + break; > +default: > + return AVERROR_INVALIDDATA; > +} Why are the condition and the error needed? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] swscale/input : avoid float calc for GrayFloat to Gray16 conv
On Wed, Aug 22, 2018 at 09:02:57PM +0200, Martin Vignali wrote: > > > > well then it should be ok > > not sure if the ff_ prefix is ideal for a static inline function > > > > > Do you think flt_2_uint16 is a better name ? yes thx > (can probably be interesting to also add same kind of func for float to > uint8 in unscaled part) > > Martin > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Let us carefully observe those good qualities wherein our enemies excel us and endeavor to excel them, by avoiding what is faulty, and imitating what is excellent in them. -- Plutarch signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] swscale/input : avoid float calc for GrayFloat to Gray16 conv
> > well then it should be ok > not sure if the ff_ prefix is ideal for a static inline function > > Do you think flt_2_uint16 is a better name ? (can probably be interesting to also add same kind of func for float to uint8 in unscaled part) Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavfi/avf_concat: switch to activate.
Nicolas George (2018-08-10): > Fix trac ticket #7351. > > Signed-off-by: Nicolas George > --- > libavfilter/avf_concat.c | 156 +++ > 1 file changed, 78 insertions(+), 78 deletions(-) Will push soon unless I forget. Regards, -- Nicolas George signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 01/12] avformat/mxfenc: automatically update descriptors klv size
2018-07-06 19:17 GMT+02:00, Carl Eugen Hoyos : > 2018-07-04 20:35 GMT+02:00, Baptiste Coudurier > : >> --- >> libavformat/mxfenc.c | 80 +--- >> 1 file changed, 39 insertions(+), 41 deletions(-) > > Does any of the patches fix ticket #6693? Ping? Or #6781? Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] swscale/input : avoid float calc for GrayFloat to Gray16 conv
On Wed, Aug 22, 2018 at 12:45:50PM +0200, Martin Vignali wrote: > > > --- > > > libswscale/input.c| 10 +- > > > libswscale/swscale_internal.h | 20 > > > 2 files changed, 25 insertions(+), 5 deletions(-) > > > > please provide benchmark, what is the impact on speed from this ? > > > > > In my tests, the patch increase speed by around 20%. well then it should be ok not sure if the ff_ prefix is ideal for a static inline function thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Does the universe only have a finite lifespan? No, its going to go on forever, its just that you wont like living in it. -- Hiranya Peiri signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] configure: do not add --fsanitize= if coverage is tested
On Tue, Aug 21, 2018 at 05:59:00PM -0300, James Almer wrote: > On 8/21/2018 5:54 PM, Michael Niedermayer wrote: > > On Mon, Aug 20, 2018 at 10:55:00AM -0300, James Almer wrote: > >> On 8/19/2018 5:40 PM, Michael Niedermayer wrote: > >>> Found-by: Max Moroz > >>> Signed-off-by: Michael Niedermayer > >>> --- > >>> configure | 2 +- > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>> > >>> diff --git a/configure b/configure > >>> index 9b5421d5a8..b9c9d0b307 100755 > >>> --- a/configure > >>> +++ b/configure > >>> @@ -3964,7 +3964,7 @@ set >> $logfile > >>> > >>> test -n "$valgrind" && toolchain="valgrind-memcheck" > >>> > >>> -enabled ossfuzz && ! echo $CFLAGS | grep -q -- "-fsanitize=" &&{ > >>> +enabled ossfuzz && ! echo $CFLAGS | grep -q -- "-fsanitize=" && ! echo > >>> $CFLAGS | grep -q -- "-fcoverage-mapping" &&{ > >> > >> What part of configure adds -fcoverage-mapping? Or is this looking for a > >> user set cflag? > > > > user cflags > > > > > >> > >> The subject should be more specific. This is specific for ossfuzz, not > >> other toolchains that add -fsanitize like asan/usan. > > > > what do you suggest ? > > "configure: do not add fsanitize cflags with ossfuzz if coverage is > tested" or something like that. Just make it clear that this is not > directly related to the gcov/llvm-cov/usan/asan toolchains. ok, will apply with exactly that thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have often repented speaking, but never of holding my tongue. -- Xenocrates 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/hevc_ps: fix crop info for monochrome
On 8/22/2018 6:40 AM, Zhao Zhili wrote: > > > On 2018年08月22日 08:26, Michael Niedermayer wrote: >> On Mon, Aug 20, 2018 at 10:19:04AM +0800, Zhao Zhili wrote: >>> >>> On 2018年08月18日 05:33, Michael Niedermayer wrote: On Fri, Aug 17, 2018 at 09:52:57AM +0800, Zhao Zhili wrote: > The values of SubWidthC and SubHeightC are 1 in the ITU-T H.265. The > current code use the value of 2. > --- > libavcodec/hevc_ps.c | 16 > 1 file changed, 12 insertions(+), 4 deletions(-) > > diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c > index fbd9fbf..b56b078 100644 > --- a/libavcodec/hevc_ps.c > +++ b/libavcodec/hevc_ps.c > @@ -70,6 +70,14 @@ static const AVRational vui_sar[] = { > { 2, 1 }, > }; > +static const unsigned hevc_sub_width_c[] = { uint8_t saves a few bytes more important, the commit message should mention a ticket or test sample also a fate test with a _small_ testsample would be usefull. Obviously the existing tests do not cover this >>> The bug was found by reading the source code. There is no ticket >>> related to the bug. I need some time to download the test suite >>> and figure out how it work. Feel free to add the test if anyone >>> has a suitable sample. >> if theres no test sample, creating one would be a good idea so this >> is tested. Because as is it would be a change that completely untested > > Updated patch and test sample are attached. Please review. > >> thx >> >> [...] >> >> >> ___ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > 0001-lavc-hevc_ps-fix-crop-info-for-monochrome.patch > > > From 74dd822640b359beff6c843143e878fe39fc92c5 Mon Sep 17 00:00:00 2001 > From: Zhao Zhili > Date: Wed, 22 Aug 2018 17:37:15 +0800 > Subject: [PATCH] lavc/hevc_ps: fix crop info for monochrome > > The values of SubWidthC and SubHeightC are 1 in the ITU-T H.265. The > current code use the value of 2. > --- > libavcodec/hevc_ps.c| 16 > tests/fate/hevc.mak | 3 +++ > tests/ref/fate/hevc-monochrome-crop | 6 ++ > 3 files changed, 21 insertions(+), 4 deletions(-) > create mode 100644 tests/ref/fate/hevc-monochrome-crop > > diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c > index fbd9fbf..ea984af 100644 > --- a/libavcodec/hevc_ps.c > +++ b/libavcodec/hevc_ps.c > @@ -70,6 +70,14 @@ static const AVRational vui_sar[] = { > { 2, 1 }, > }; > > +static const uint8_t hevc_sub_width_c[] = { > +1, 2, 2, 1 > +}; > + > +static const uint8_t hevc_sub_height_c[] = { > +1, 2, 1, 1 > +}; > + > static void remove_pps(HEVCParamSets *s, int id) > { > if (s->pps_list[id] && s->pps == (const HEVCPPS*)s->pps_list[id]->data) > @@ -628,8 +636,8 @@ static void decode_vui(GetBitContext *gb, AVCodecContext > *avctx, > vui->default_display_window_flag = get_bits1(gb); > > if (vui->default_display_window_flag) { > -int vert_mult = 1 + (sps->chroma_format_idc < 2); > -int horiz_mult = 1 + (sps->chroma_format_idc < 3); > +int vert_mult = hevc_sub_height_c[sps->chroma_format_idc]; > +int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc]; > vui->def_disp_win.left_offset = get_ue_golomb_long(gb) * > horiz_mult; > vui->def_disp_win.right_offset = get_ue_golomb_long(gb) * > horiz_mult; > vui->def_disp_win.top_offset= get_ue_golomb_long(gb) * > vert_mult; > @@ -923,8 +931,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, > unsigned int *sps_id, > return ret; > > if (get_bits1(gb)) { // pic_conformance_flag > -int vert_mult = 1 + (sps->chroma_format_idc < 2); > -int horiz_mult = 1 + (sps->chroma_format_idc < 3); > +int vert_mult = hevc_sub_height_c[sps->chroma_format_idc]; > +int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc]; > sps->pic_conf_win.left_offset = get_ue_golomb_long(gb) * > horiz_mult; > sps->pic_conf_win.right_offset = get_ue_golomb_long(gb) * > horiz_mult; > sps->pic_conf_win.top_offset= get_ue_golomb_long(gb) * > vert_mult; > diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak > index 184349e..9c288fc 100644 > --- a/tests/fate/hevc.mak > +++ b/tests/fate/hevc.mak > @@ -250,6 +250,9 @@ FATE_HEVC-$(call DEMDEC, MOV, HEVC) += > fate-hevc-extradata-reload > > fate-hevc-extradata-reload: CMD = framemd5 -i > $(TARGET_SAMPLES)/hevc/extradata-reload-multi-stsd.mov -sws_flags bitexact > > +fate-hevc-monochrome-crop: CMD = ffprobe$(PROGSSUF)$(EXESUF) -show_entries > stream=width,height,coded_width,coded_height > $(TARGET_SAMPLES)/hevc/hevc-monochrome.hevc This should have called run() before ffprobe. It fails otherwise as $(TARGET_PATH) is not added. Changed it to use the probeframes() function anyway
[FFmpeg-devel] [PATCH] avcodec/proresdec2: add frame threading support
Signed-off-by: Paul B Mahol --- libavcodec/proresdec2.c | 18 -- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index b4ea6b5e03..d818e5d8da 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -36,6 +36,7 @@ #include "simple_idct.h" #include "proresdec.h" #include "proresdata.h" +#include "thread.h" static void permute(uint8_t *dst, const uint8_t *src, const uint8_t permutation[64]) { @@ -644,6 +645,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { ProresContext *ctx = avctx->priv_data; +ThreadFrame tframe = { .f = data }; AVFrame *frame = data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; @@ -669,7 +671,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, buf += frame_hdr_size; buf_size -= frame_hdr_size; -if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) +if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0) return ret; decode_picture: @@ -697,6 +699,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return avpkt->size; } +#if HAVE_THREADS +static int decode_init_thread_copy(AVCodecContext *avctx) +{ +ProresContext *ctx = avctx->priv_data; + +ctx->slices = NULL; + +return 0; +} +#endif + static av_cold int decode_close(AVCodecContext *avctx) { ProresContext *ctx = avctx->priv_data; @@ -713,7 +726,8 @@ AVCodec ff_prores_decoder = { .id = AV_CODEC_ID_PRORES, .priv_data_size = sizeof(ProresContext), .init = decode_init, +.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .close = decode_close, .decode = decode_frame, -.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, +.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, }; -- 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avcodec: add Brooktree ProSumer Video decoder
Signed-off-by: Paul B Mahol --- libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/avcodec.h| 1 + libavcodec/codec_desc.c | 7 + libavcodec/prosumer.c | 405 libavformat/riff.c | 1 + 6 files changed, 416 insertions(+) create mode 100644 libavcodec/prosumer.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f0c8226283..9a309c348e 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -515,6 +515,7 @@ OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o proresdsp.o proresdata.o OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o +OBJS-$(CONFIG_PROSUMER_DECODER)+= prosumer.o OBJS-$(CONFIG_PSD_DECODER) += psd.o OBJS-$(CONFIG_PTX_DECODER) += ptx.o OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o \ diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index fd35fc1d0b..b1d1ef26c0 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -235,6 +235,7 @@ extern AVCodec ff_prores_encoder; extern AVCodec ff_prores_decoder; extern AVCodec ff_prores_aw_encoder; extern AVCodec ff_prores_ks_encoder; +extern AVCodec ff_prosumer_decoder; extern AVCodec ff_psd_decoder; extern AVCodec ff_ptx_decoder; extern AVCodec ff_qdraw_decoder; diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 31e50d5a94..2a4be2ca4f 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -448,6 +448,7 @@ enum AVCodecID { AV_CODEC_ID_GDV, AV_CODEC_ID_FITS, AV_CODEC_ID_IMM4, +AV_CODEC_ID_PROSUMER, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index af66b35d2b..e611183599 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1661,6 +1661,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Infinity IMM4"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_PROSUMER, +.type = AVMEDIA_TYPE_VIDEO, +.name = "prosumer", +.long_name = NULL_IF_CONFIG_SMALL("Brooktree ProSumer Video"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, +}, /* various PCM "codecs" */ { diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c new file mode 100644 index 00..7b9d5e7bdb --- /dev/null +++ b/libavcodec/prosumer.c @@ -0,0 +1,405 @@ +/* + * Brooktree ProSumer Video decoder + * Copyright (c) 2018 Paul B Mahol + * + * 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 +#include + +#include "libavutil/imgutils.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" + +#include "avcodec.h" +#include "bytestream.h" +#include "internal.h" + +typedef struct ProSumerContext { +GetByteContext gb; +PutByteContext pb; + +unsigned stride; +unsigned size; +unsigned lut[0x1]; +uint8_t *table_b; +uint8_t *decbuffer; +} ProSumerContext; + +#define PAIR(high, low) (((uint64_t)(high)<> 20; +b = lut[2 * idx]; + +while (1) { +if (((b & 0xFF00u) != 0x8000u) || (b & 0xFFu)) { +if ((b & 0xFF00u) != 0x8000u) { +bytestream2_put_le16(pb, b); +} else if (b & 0xFFu) { +idx = 0; +for (i = 0; i < (b & 0xFFu); i++) +bytestream2_put_le32(pb, 0); +} +c = b >> 16; +if (c & 0xFF00u) { +c = (((c >> 8) & 0xFFu) | (c & 0xFF00)) & 0xF00F; +fill = lut[2 * idx + 1]; +if ((c & 0xFF00u) == 0x1000) { +bytestream2_put_le16(pb, fill); +c &= 0x00FFu; +} else { +bytestream2_put_le32(pb, fill); +c &= 0x00FFu; +} +} +while (c) { +a <<= 4; +cn
Re: [FFmpeg-devel] [PATCH 01/12] avformat/mxfenc: automatically update descriptors klv size
On Wed, Jul 4, 2018 at 6:21 PM, Michael Niedermayer wrote: > On Wed, Jul 04, 2018 at 11:35:03AM -0700, Baptiste Coudurier wrote: > > --- > > libavformat/mxfenc.c | 80 +--- > > 1 file changed, 39 insertions(+), 41 deletions(-) > > > > diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c > > index 77f60f5874..b98d234f03 100644 > > --- a/libavformat/mxfenc.c > > +++ b/libavformat/mxfenc.c > > @@ -1104,14 +1104,16 @@ static void > > mxf_write_multi_descriptor(AVFormatContext > *s) > > mxf_write_uuid(pb, SubDescriptor, i); > > } > > > > -static void mxf_write_generic_desc(AVFormatContext *s, AVStream *st, > const UID key, unsigned size) > > +static int64_t mxf_write_generic_desc(AVFormatContext *s, AVStream > *st, const UID key) > > { > > MXFContext *mxf = s->priv_data; > > MXFStreamContext *sc = st->priv_data; > > AVIOContext *pb = s->pb; > > +int64_t pos; > > > > avio_write(pb, key, 16); > > -klv_encode_ber4_length(pb, size+20+8+12+20); > > +klv_encode_ber4_length(pb, 0); > > +pos = avio_tell(pb); > > > > mxf_write_local_tag(pb, 16, 0x3C0A); > > mxf_write_uuid(pb, SubDescriptor, st->index); > > @@ -1136,6 +1138,8 @@ static void mxf_write_generic_desc(AVFormatContext > *s, AVStream *st, const UID k > > > > mxf_write_local_tag(pb, 16, 0x3004); > > avio_write(pb, mxf_essence_container_uls[sc->index].container_ul, > 16); > > + > > +return pos; > > } > > > > static const UID mxf_mpegvideo_descriptor_key = { > 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 > }; > > @@ -1172,7 +1176,7 @@ static int get_trc(UID ul, enum > AVColorTransferCharacteristic trc) > > } > > } > > > > -static void mxf_write_cdci_common(AVFormatContext *s, AVStream *st, > const UID key, unsigned size) > > +static int64_t mxf_write_cdci_common(AVFormatContext *s, AVStream *st, > const UID key) > > { > > MXFStreamContext *sc = st->priv_data; > > AVIOContext *pb = s->pb; > > @@ -1180,25 +1184,10 @@ static void mxf_write_cdci_common(AVFormatContext > *s, AVStream *st, const UID ke > > int stored_height = (st->codecpar->height+15)/16*16; > > int display_height; > > int f1, f2; > > -unsigned desc_size = size+8+8+8+8+8+8+8+5+16+4+12+20+5 + 5*8 + 6; > > UID transfer_ul = {0}; > > +int64_t pos = mxf_write_generic_desc(s, st, key); > > > > -if (sc->interlaced && sc->field_dominance) > > -desc_size += 5; > > -if (sc->signal_standard) > > -desc_size += 5; > > -if (sc->interlaced) > > -desc_size += 8; > > -if (sc->v_chroma_sub_sample) > > -desc_size += 8; > > -if (st->codecpar->color_range != AVCOL_RANGE_UNSPECIFIED) > > -desc_size += 8 * 3; > > -if (s->oformat == &ff_mxf_d10_muxer) > > -desc_size += 8 + 8 + 8; > > -if (get_trc(transfer_ul, st->codecpar->color_trc) >= 0) > > -desc_size += 20; > > - > > -mxf_write_generic_desc(s, st, key, desc_size); > > +get_trc(transfer_ul, st->codecpar->color_trc); > > nice simplification! > Applied. -- Baptiste ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] mpeg4video: Add Studio DPCM support
2018-08-22 14:25 GMT+02:00, Kieran Kunhya : > On Wed, 22 Aug 2018 at 10:44 Carl Eugen Hoyos wrote: > >> 2018-08-22 1:29 GMT+02:00, Kieran Kunhya : >> > $subj >> >> Please split the re-indentation and please fix the indentation of "else". > > Would you mind explaining these in more details. The following should be "} else {": } else { Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Problem while decoding aac file to wav file
Hi experts, This is my first mail to ffmpeg , apologies if make some mistakes. I tried many online example codes for decoding aac audio to wav file. including example codes which is for MP2 codec. below is one such example code , it doubles the decoded file size (.wav) but not playable. Can any one point in right direction or help me in correcting the below code. Thanks in advance #include #include #include #include #include #include #define AUDIO_INBUF_SIZE 4096 #define AUDIO_REFILL_THRESH 4096 static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile) { int i, ch; int ret, data_size; /* send the packet with the compressed data to the decoder */ ret = avcodec_send_packet(dec_ctx, pkt); if (ret < 0) { fprintf(stderr, "Error submitting the packet to the decoder\n"); exit(1); } /* read all the output frames (in general there may be any number of them */ while (ret >= 0) { ret = avcodec_receive_frame(dec_ctx, frame); if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) return; else if (ret < 0) { fprintf(stderr, "Error during decoding\n"); exit(1); } data_size = av_get_bytes_per_sample(dec_ctx->sample_fmt); if (data_size < 0) { /* This should not occur, checking just for paranoia */ fprintf(stderr, "Failed to calculate data size\n"); exit(1); } for (i = 0; i < frame->nb_samples; i++) for (ch = 0; ch < dec_ctx->channels; ch++) fwrite(frame->data[ch] + data_size * i, 1, data_size, outfile); } } int main(int argc, char **argv) { const char *outfilename, *filename; const AVCodec *codec; AVCodecContext *c = NULL; AVCodecParserContext *parser = NULL; int len, ret; FILE *f, *outfile; uint8_t inbuf[AUDIO_INBUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE]; uint8_t *data; size_t data_size; AVPacket *pkt; AVFrame *decoded_frame = NULL; if (argc <= 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(0); } filename = argv[1]; outfilename = argv[2]; pkt = av_packet_alloc(); /* find the MPEG audio decoder */ codec = avcodec_find_decoder(AV_CODEC_ID_AAC); if (!codec) { fprintf(stderr, "Codec not found\n"); exit(1); } parser = av_parser_init(codec->id); if (!parser) { fprintf(stderr, "Parser not found\n"); exit(1); } c = avcodec_alloc_context3(codec); c->channels = 2; c->sample_rate = 44100; c->bit_rate = 32; if (!c) { fprintf(stderr, "Could not allocate audio codec context\n"); exit(1); } /* open it */ if (avcodec_open2(c, codec, NULL) < 0) { fprintf(stderr, "Could not open codec\n"); exit(1); } f = fopen(filename, "rb"); if (!f) { fprintf(stderr, "Could not open %s\n", filename); exit(1); } outfile = fopen(outfilename, "wb"); if (!outfile) { av_free(c); exit(1); } /* decode until eof */ data = inbuf; data_size = fread(inbuf, 1, AUDIO_INBUF_SIZE, f); while (data_size > 0) { if (!decoded_frame) { if (!(decoded_frame = av_frame_alloc())) { fprintf(stderr, "Could not allocate audio frame\n"); exit(1); } } ret = av_parser_parse2(parser, c, &pkt->data, &pkt->size, data, data_size, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0); if (ret < 0) { fprintf(stderr, "Error while parsing\n"); exit(1); } data += ret; data_size -= ret; if (pkt->size) decode(c, pkt, decoded_frame, outfile); if (data_size < AUDIO_REFILL_THRESH) { memmove(inbuf, data, data_size); data = inbuf; len = fread(data + data_size, 1, AUDIO_INBUF_SIZE - data_size, f); if (len > 0) data_size += len; } } /* flush the decoder */ pkt->data = NULL; pkt->size = 0; decode(c, pkt, decoded_frame, outfile); fclose(outfile); fclose(f); avcodec_free_context(&c); av_parser_close(parser); av_frame_free(&decoded_frame); av_packet_free(&pkt); return 0; } Regards, Aasim +91 8197948544 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] Register for VDD 2018 conference
Hello fellow devs, VideoLAN is happy to invite you to the usual conference of the end of the summer: VDD2018 is happening in Paris, for the 10 years of the original conf. As usual, this is a very technical conference focused on open source multimedia development. We will talk about AV1, FFv1, FFv2, x264/x265, VLC, FFmpeg and other related technologies. Open Source developers can have all their conference costs sponsored. Places are limited, so register soon! Please suggest a lightning talk! Please consider joining for the pathological sample competition! More information on: https://vdd.videolan.org/ Registration: https://goo.gl/forms/8WGREy2hMxRNfGzv2 See you soon, in Paris. -- Jean-Baptiste Kempf - President +33 672 704 734 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] mpeg4video: Add Studio DPCM support
On Wed, 22 Aug 2018 at 10:44 Carl Eugen Hoyos wrote: > 2018-08-22 1:29 GMT+02:00, Kieran Kunhya : > > $subj > > Please split the re-indentation and please fix the indentation of "else". > Would you mind explaining these in more details. Kieran ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avformat/hls: support decryption AES128 fmp4 m3u8 list
> 在 2018年8月13日,下午6:17,Steven Liu 写道: > > m3u8 list create by: > mediafilesegmenter --encrypt-key-file=keya.key --encrypt-key-url="keya.key" > --iso-fragmented input.mp4 > > before this patch: > bogon:xxx StevenLiu$ ./ffplay -allowed_extensions ALL prog_index.m3u8 > ffplay version N-91601-g551a029a18 Copyright (c) 2003-2018 the FFmpeg > developers > built with Apple LLVM version 9.1.0 (clang-902.0.39.2) > configuration: --enable-libass --enable-opengl --enable-libx264 > --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local > --enable-libtesseract --enable-libspeex --enable-libfreetype > --enable-libfontconfig --enable-libfdk-aac --enable-videotoolbox > --enable-libxml2 > libavutil 56. 19.100 / 56. 19.100 > libavcodec 58. 22.101 / 58. 22.101 > libavformat58. 17.101 / 58. 17.101 > libavdevice58. 4.101 / 58. 4.101 > libavfilter 7. 26.100 / 7. 26.100 > libswscale 5. 2.100 / 5. 2.100 > libswresample 3. 2.100 / 3. 2.100 > libpostproc55. 2.100 / 55. 2.100 > [hls,applehttp @ 0x7fa30305f000] Opening 'fileSequence0.mp4' for reading > [hls,applehttp @ 0x7fa30305f000] Opening 'keya.key' for reading > [hls,applehttp @ 0x7fa30305f000] Opening 'crypto:fileSequence1.mp4' for > reading > Format ac3 detected only with low score of 25, misdetection possible! > [ac3 @ 0x7fa304869000] frame sync errorvq=0KB sq=0B f=0/0 > [ac3 @ 0x7fa304869000] new coupling strategy must be present in block 0 > [ac3 @ 0x7fa304869000] error decoding the audio block > Input #0, hls,applehttp, from 'prog_index.m3u8': > Duration: 00:00:59.87, start: 0.00, bitrate: 0 kb/s > Program 0 >Metadata: > variant_bitrate : 0 >Stream #0:0: Audio: ac3, 48000 Hz, 5.1(side), fltp, 320 kb/s >Metadata: > variant_bitrate : 0 > [ac3 @ 0x7fa30382b800] frame sync error > [ac3 @ 0x7fa30382b800] new coupling strategy must be present in block 0 > [ac3 @ 0x7fa30382b800] error decoding the audio block > [ac3 @ 0x7fa30382b800] expacc 125 is out-of-range sq=0B f=0/0 > [ac3 @ 0x7fa30382b800] error decoding the audio block > > after this patch: > bogon:xxx StevenLiu$ ./ffplay -allowed_extensions ALL prog_index.m3u8 > ffplay version N-91602-g03fc3a68e7 Copyright (c) 2003-2018 the FFmpeg > developers > built with Apple LLVM version 9.1.0 (clang-902.0.39.2) > configuration: --enable-libass --enable-opengl --enable-libx264 > --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local > --enable-libtesseract --enable-libspeex --enable-libfreetype > --enable-libfontconfig --enable-libfdk-aac --enable-videotoolbox > --enable-libxml2 > libavutil 56. 19.100 / 56. 19.100 > libavcodec 58. 22.101 / 58. 22.101 > libavformat58. 17.101 / 58. 17.101 > libavdevice58. 4.101 / 58. 4.101 > libavfilter 7. 26.100 / 7. 26.100 > libswscale 5. 2.100 / 5. 2.100 > libswresample 3. 2.100 / 3. 2.100 > libpostproc55. 2.100 / 55. 2.100 > [hls,applehttp @ 0x7f86e1868000] Opening 'keya.key' for reading/0 > [hls,applehttp @ 0x7f86e1868000] Opening 'crypto:fileSequence0.mp4' for > reading > [hls,applehttp @ 0x7f86e1868000] Opening 'crypto:fileSequence1.mp4' for > reading > Input #0, hls,applehttp, from 'prog_index.m3u8': > Duration: 00:00:59.87, start: 10.00, bitrate: 0 kb/s > Program 0 >Metadata: > variant_bitrate : 0 >Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 > [SAR 1:1 DAR 16:9], 992 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc >Metadata: > variant_bitrate : 0 > major_brand : mp42 > minor_version : 1 > compatible_brands: mp41mp42isomhlsf > creation_time : 2018-08-13T10:04:15.00Z >Stream #0:1: Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, > 232 kb/s >Metadata: > variant_bitrate : 0 > [hls,applehttp @ 0x7f86e1868000] Opening 'crypto:fileSequence2.mp4' for > reading > > Signed-off-by: Steven Liu > --- > libavformat/hls.c | 21 + > 1 file changed, 21 insertions(+) > > diff --git a/libavformat/hls.c b/libavformat/hls.c > index 3d4f7f2647..8ad08baaed 100644 > --- a/libavformat/hls.c > +++ b/libavformat/hls.c > @@ -811,6 +811,27 @@ static int parse_playlist(HLSContext *c, const char *url, > ff_parse_key_value(ptr, (ff_parse_key_val_cb) > handle_init_section_args, >&info); > cur_init_section = new_init_section(pls, &info, url); > +cur_init_section->key_type = key_type; > +if (has_iv) { > +memcpy(cur_init_section->iv, iv, sizeof(iv)); > +} else { > +int seq = pls->start_seq_no + pls->n_segments; > +memset(cur_init_section->iv, 0, > sizeof(cur_init_section->iv)); > +AV_WB32(cur_init_section->iv + 12, seq); > +} > + > +if (key_type != KEY_NONE) { > +ff_make_absolute_url(tmp_str, sizeof(tmp_str), url, key)
[FFmpeg-devel] [PATCH] avdevice/decklink_enc: print preroll and buffer size
From f496d970d319ec3916a55e05b925f6b43763ebfa Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Wed, 22 Aug 2018 16:23:58 +0530 Subject: [PATCH] avdevice/decklink_enc: print preroll and buffer size Helpful in diagnosing latency issues. --- libavdevice/decklink_enc.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp index 28ab928cd5..ee4c962add 100644 --- a/libavdevice/decklink_enc.cpp +++ b/libavdevice/decklink_enc.cpp @@ -193,6 +193,9 @@ static int decklink_setup_video(AVFormatContext *avctx, AVStream *st) pthread_cond_init(&ctx->cond, NULL); ctx->frames_buffer_available_spots = ctx->frames_buffer; +av_log(avctx, AV_LOG_DEBUG, "output: %s, preroll: %d, frames buffer size: %d\n", + avctx->url, ctx->frames_preroll, ctx->frames_buffer); + /* The device expects the framerate to be fixed. */ avpriv_set_pts_info(st, 64, st->time_base.num, st->time_base.den); -- 2.18.0___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v3] doc/filters: Add double-pass example for loudnorm
On 22-08-2018 04:01 PM, Marvin Scholz wrote: Guessed Channel Layout for Input Stream #0.0 : stereo ... Stream #0:0(ger): Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, stereo, fltp, 192 kb/s [Parsed_aresample_1 @ 0x7fb7c540d500] Cannot select channel layout for the link between filters Parsed_aresample_1 and format_out_0_1. For this file, aresample=48000:ocl=stereo Gyan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] swscale/input : avoid float calc for GrayFloat to Gray16 conv
> > --- > > libswscale/input.c| 10 +- > > libswscale/swscale_internal.h | 20 > > 2 files changed, 25 insertions(+), 5 deletions(-) > > please provide benchmark, what is the impact on speed from this ? > > In my tests, the patch increase speed by around 20%. Test with this sample (UHD Gray float PSD file) : https://we.tl/t-Ty9hR20gUw And this command line (test the bswap func : grayf32ToY16_bswap_c) ./ffmpeg -benchmark -loop 1 -t 30 -i TEST_PSD_GRAY_0.psd -pix_fmt gray16be -f null - Without the patch : (using float calc) frame= 750 fps= 23 q=-0.0 Lsize=N/A time=00:00:30.00 bitrate=N/A speed=0.909x bench: utime=26.577s stime=10.061s rtime=33.063s bench: maxrss=697888768kB With the patch : (not use float calc) frame= 750 fps= 27 q=-0.0 Lsize=N/A time=00:00:30.00 bitrate=N/A speed=1.07x bench: utime=21.512s stime=10.136s rtime=27.992s bench: maxrss=697942016kB Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] GSOC Complete
On Wed, 22 Aug 2018 14:33:52 +0530 Gagandeep Singh wrote: > Hi, > > I would like to thank all the FFmpeg developers who have helped me in my 3 > months of project. durandal_1707 thanks for the last minute check on the > file. > > I also thank my mentor kierank, for his faith in me even though during the > second month i was not feeling that i would be able to work on it anymore. > > I would continue to be involved in FFmpeg development (in my capacity - > only a B.Tech student here :\ ). > > I also know that the project was comparatively easier and could have been > finished sooner, so thanks for being patient with me. > Thanks Gagandeep and all! > Sincerely > Gagandeep Singh > GSOC 2018 > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel -- - Shlomi Fish http://www.shlomifish.org/ http://shlomifishswiki.branchable.com/Self-Sufficiency/ There are no deletionists. Only Wikipedia articles which Chuck Norris allows to live. (By: joeyadams) — http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/ Please reply to list if it's a mailing list post - http://shlom.in/reply . ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v3] doc/filters: Add double-pass example for loudnorm
On 22 Aug 2018, at 11:44, Gyan Doshi wrote: On 22-08-2018 02:38 PM, Marvin Scholz wrote: On 22 Aug 2018, at 6:40, Gyan Doshi wrote: On 22-08-2018 04:43 AM, Marvin Scholz wrote: +@example +ffmpeg -i input -af loudnorm=I=-23:TP=-1:measured_I=-9.0:measured_TP=1.5:measured_LRA=9.4:measured_thresh=-19.5:print_format=summary output Since your input LRA is 9.4, and output LRA is 7 (default), the filter will upsample to 192 kHz. You should resample afterwards. Ok, whats the correct way to do that? e.g. ffmpeg -i input -af loudnorm=...,aresample=48000 output This just gives me: [Parsed_aresample_1 @ 0x7f99fb503ec0] Cannot select channel layout for the link between filters Parsed_aresample_1 and format_out_0_1. Share complete command and log. $ ffmpeg -i ~/Movies/input.wmv -af loudnorm=I=-13:TP=-1:measured_I=-9.0:measured_TP=1.5:measured_LRA=9.4:measured_thresh=-19.5:linear=true:print_format=summary,aresample=48000 -c:v prores -c:a pcm_s16le -f mov output.mov ffmpeg version 4.0.2 Copyright (c) 2000-2018 the FFmpeg developers built with Apple LLVM version 9.1.0 (clang-902.0.39.2) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.0.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma libavutil 56. 14.100 / 56. 14.100 libavcodec 58. 18.100 / 58. 18.100 libavformat58. 12.100 / 58. 12.100 libavdevice58. 3.100 / 58. 3.100 libavfilter 7. 16.100 / 7. 16.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 1.100 / 5. 1.100 libswresample 3. 1.100 / 3. 1.100 libpostproc55. 1.100 / 55. 1.100 [wmv3 @ 0x7fb7c5806600] Extra data: 8 bits left, value: 20 Guessed Channel Layout for Input Stream #0.0 : stereo Input #0, asf, from '/Users/epirat/Movies/input.wmv': Metadata: SfOriginalFPS : 299700 WMFSDKVersion : 12.0.17134.137 WMFSDKNeeded: 0.0.0. IsVBR : 0 DeviceConformanceTemplate: MP@HL Duration: 00:04:28.20, start: 0.00, bitrate: 5446 kb/s Stream #0:0(ger): Audio: wmav2 (a[1][0][0] / 0x0161), 48000 Hz, stereo, fltp, 192 kb/s Stream #0:1(ger): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 1280x720, 6099 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc [wmv3 @ 0x7fb7c5806c00] Extra data: 8 bits left, value: 20 Stream mapping: Stream #0:1 -> #0:0 (wmv3 (native) -> prores (native)) Stream #0:0 -> #0:1 (wmav2 (native) -> pcm_s16le (native)) Press [q] to stop, [?] for help [prores @ 0x7fb7c5860200] encoding with ProRes standard (apcn) profile [prores @ 0x7fb7c5891000] encoding with ProRes standard (apcn) profile [prores @ 0x7fb7c58e2a00] encoding with ProRes standard (apcn) profile [prores @ 0x7fb7c58d8c00] encoding with ProRes standard (apcn) profile [prores @ 0x7fb7c5814c00] encoding with ProRes standard (apcn) profile [Parsed_aresample_1 @ 0x7fb7c540d500] Cannot select channel layout for the link between filters Parsed_aresample_1 and format_out_0_1. Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0 Conversion failed! Gyan ___ 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 1/9] configure: [loongson] revert no-expensive-optimizations
>-Original Message- >From: ffmpeg-devel-boun...@ffmpeg.org [mailto:ffmpeg-devel-boun...@ffmpeg.org] >On Behalf Of >Michael Niedermayer >Sent: Wednesday, August 22, 2018 6:04 AM >To: FFmpeg development discussions and patches >Subject: Re: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert >no-expensive-optimizations > >On Tue, Aug 21, 2018 at 04:06:05PM +0800, Shiyou Yin wrote: >> >-Original Message- >> >From: ffmpeg-devel-boun...@ffmpeg.org >> >[mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Shiyou Yin >> >Sent: Thursday, July 12, 2018 8:44 PM >> >To: ffmpeg-devel@ffmpeg.org >> >Subject: [FFmpeg-devel] [PATCH 1/9] configure: [loongson] revert >> >no-expensive-optimizations >> > >> >The bug in gcc-4.9.x has been fixed in gcc master branch. >> >Loongson released gcc-4.9.3-3.fc21.loongson with this patch. >> >More bug info see: >> >https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67736 >> >https://gcc.gnu.org/ml/gcc-patches/2012-05/msg00401.html >> > >> >Change-Id: I780125d4cdee71d40457aaee22126ba0547a2c8f >> >Signed-off-by: Shiyou Yin >> >--- >> > configure | 6 +++--- >> > 1 file changed, 3 insertions(+), 3 deletions(-) >> > >> >diff --git a/configure b/configure >> >index b1a4dcf..17a7ea9 100755 >> >--- a/configure >> >+++ b/configure >> >@@ -4789,13 +4789,13 @@ elif enabled mips; then >> > disable mipsdspr2 >> > case $cpu in >> > loongson3*) >> >-cpuflags="-march=loongson3a -mhard-float >-fno-expensive-optimizations" >> >+cpuflags="-march=loongson3a -mhard-float" >> > ;; >> > loongson2e) >> >-cpuflags="-march=loongson2e -mhard-float >-fno-expensive-optimizations" >> >+cpuflags="-march=loongson2e -mhard-float" >> > ;; >> > loongson2f) >> >-cpuflags="-march=loongson2f -mhard-float >-fno-expensive-optimizations" >> >+cpuflags="-march=loongson2f -mhard-float" >> > ;; >> > esac >> > ;; >> >-- >> >2.1.0 >> > >> >> Hi Michael, could you please help to apply this patch. It has been tested on >> loongson platform. > >shouldnt this test the compiler the user uses ? its version or something ? > Thank you very much for your review. Be strictly, it's needed to check the compiler version which user uses. Consider that this bug has been fixed about three years and the compiler has been upgraded a lot of times in loongson yum repository. At present, there are still only a few developers will build ffmpeg on loongson platform. The risk of his change is controllable. So, between the simplicity and absolute reliability of the code I chosed the simplicity this time. Should I still add version check here? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] examples/vaapi_dec_scaling: init export
2018-08-22 2:42 GMT+02:00, myp...@gmail.com : > On Tue, Aug 21, 2018 at 4:45 PM Carl Eugen Hoyos wrote: >> >> 2018-06-11 13:22 GMT+02:00, Jun Zhao : >> >> > + * Copyright (c) 2018 Jun Zhao >> > + * >> > + * VA-API Acceleration API (video decoding/scaling) sample >> > + * >> > + * 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. >> >> This is not an ideal license for doc/examples. > > I didn't realize this problem, any other license be suggested? MIT ? I think so, yes. Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v3] doc/filters: Add double-pass example for loudnorm
On 22-08-2018 02:38 PM, Marvin Scholz wrote: On 22 Aug 2018, at 6:40, Gyan Doshi wrote: On 22-08-2018 04:43 AM, Marvin Scholz wrote: +@example +ffmpeg -i input -af loudnorm=I=-23:TP=-1:measured_I=-9.0:measured_TP=1.5:measured_LRA=9.4:measured_thresh=-19.5:print_format=summary output Since your input LRA is 9.4, and output LRA is 7 (default), the filter will upsample to 192 kHz. You should resample afterwards. Ok, whats the correct way to do that? e.g. ffmpeg -i input -af loudnorm=...,aresample=48000 output This just gives me: [Parsed_aresample_1 @ 0x7f99fb503ec0] Cannot select channel layout for the link between filters Parsed_aresample_1 and format_out_0_1. Share complete command and log. Gyan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] mpeg4video: Add Studio DPCM support
2018-08-22 1:29 GMT+02:00, Kieran Kunhya : > $subj Please split the re-indentation and please fix the indentation of "else". Thank you, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] lavc/hevc_ps: fix crop info for monochrome
On 2018年08月22日 08:26, Michael Niedermayer wrote: On Mon, Aug 20, 2018 at 10:19:04AM +0800, Zhao Zhili wrote: On 2018年08月18日 05:33, Michael Niedermayer wrote: On Fri, Aug 17, 2018 at 09:52:57AM +0800, Zhao Zhili wrote: The values of SubWidthC and SubHeightC are 1 in the ITU-T H.265. The current code use the value of 2. --- libavcodec/hevc_ps.c | 16 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index fbd9fbf..b56b078 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -70,6 +70,14 @@ static const AVRational vui_sar[] = { { 2, 1 }, }; +static const unsigned hevc_sub_width_c[] = { uint8_t saves a few bytes more important, the commit message should mention a ticket or test sample also a fate test with a _small_ testsample would be usefull. Obviously the existing tests do not cover this The bug was found by reading the source code. There is no ticket related to the bug. I need some time to download the test suite and figure out how it work. Feel free to add the test if anyone has a suitable sample. if theres no test sample, creating one would be a good idea so this is tested. Because as is it would be a change that completely untested Updated patch and test sample are attached. Please review. thx [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >From 74dd822640b359beff6c843143e878fe39fc92c5 Mon Sep 17 00:00:00 2001 From: Zhao Zhili Date: Wed, 22 Aug 2018 17:37:15 +0800 Subject: [PATCH] lavc/hevc_ps: fix crop info for monochrome The values of SubWidthC and SubHeightC are 1 in the ITU-T H.265. The current code use the value of 2. --- libavcodec/hevc_ps.c| 16 tests/fate/hevc.mak | 3 +++ tests/ref/fate/hevc-monochrome-crop | 6 ++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/ref/fate/hevc-monochrome-crop diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index fbd9fbf..ea984af 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -70,6 +70,14 @@ static const AVRational vui_sar[] = { { 2, 1 }, }; +static const uint8_t hevc_sub_width_c[] = { +1, 2, 2, 1 +}; + +static const uint8_t hevc_sub_height_c[] = { +1, 2, 1, 1 +}; + static void remove_pps(HEVCParamSets *s, int id) { if (s->pps_list[id] && s->pps == (const HEVCPPS*)s->pps_list[id]->data) @@ -628,8 +636,8 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx, vui->default_display_window_flag = get_bits1(gb); if (vui->default_display_window_flag) { -int vert_mult = 1 + (sps->chroma_format_idc < 2); -int horiz_mult = 1 + (sps->chroma_format_idc < 3); +int vert_mult = hevc_sub_height_c[sps->chroma_format_idc]; +int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc]; vui->def_disp_win.left_offset = get_ue_golomb_long(gb) * horiz_mult; vui->def_disp_win.right_offset = get_ue_golomb_long(gb) * horiz_mult; vui->def_disp_win.top_offset= get_ue_golomb_long(gb) * vert_mult; @@ -923,8 +931,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return ret; if (get_bits1(gb)) { // pic_conformance_flag -int vert_mult = 1 + (sps->chroma_format_idc < 2); -int horiz_mult = 1 + (sps->chroma_format_idc < 3); +int vert_mult = hevc_sub_height_c[sps->chroma_format_idc]; +int horiz_mult = hevc_sub_width_c[sps->chroma_format_idc]; sps->pic_conf_win.left_offset = get_ue_golomb_long(gb) * horiz_mult; sps->pic_conf_win.right_offset = get_ue_golomb_long(gb) * horiz_mult; sps->pic_conf_win.top_offset= get_ue_golomb_long(gb) * vert_mult; diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak index 184349e..9c288fc 100644 --- a/tests/fate/hevc.mak +++ b/tests/fate/hevc.mak @@ -250,6 +250,9 @@ FATE_HEVC-$(call DEMDEC, MOV, HEVC) += fate-hevc-extradata-reload fate-hevc-extradata-reload: CMD = framemd5 -i $(TARGET_SAMPLES)/hevc/extradata-reload-multi-stsd.mov -sws_flags bitexact +fate-hevc-monochrome-crop: CMD = ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream=width,height,coded_width,coded_height $(TARGET_SAMPLES)/hevc/hevc-monochrome.hevc +FATE_HEVC_FFPROBE-$(call DEMDEC, HEVC, HEVC) += fate-hevc-monochrome-crop + FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes) FATE_SAMPLES_FFPROBE += $(FATE_HEVC_FFPROBE-yes) diff --git a/tests/ref/fate/hevc-monochrome-crop b/tests/ref/fate/hevc-monochrome-crop new file mode 100644 index 000..531bfc8 --- /dev/null +++ b/tests/ref/fate/hevc-monochrome-crop @@ -0,0 +1,6 @@ +[STREAM] +width=384 +height=240 +coded_width=384 +coded_height=256 +[/STREAM] -- 2.9.5 hevc-monochrome.hevc Description: Binary data ___ ffmpeg-devel mailing list ffmpeg-devel
Re: [FFmpeg-devel] swscale : hScale16To19 : limit shift for float(32bits) input
> > patches should be ok > > Pushed, thanks. Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] avcodec/psd : add support for gray float (WIP)
Le lun. 20 août 2018 à 15:39, Martin Vignali a écrit : > Hello, > > Better patch in attach (reuse the same "copy part" than uint 8bpc and 16 > bpc pix fmt) > > Works only after applying swscale patch in discussion : > swscale : hScale16To19 : limit shift for float(32bits) input > > Can be test with : > ./ffmpeg -i lena-gray_float.psd -pix_fmt gray8 res8.png > ./ffmpeg -i lena-gray_float.psd res16.png > > > Pushed. Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] GSOC Complete
Hi, I would like to thank all the FFmpeg developers who have helped me in my 3 months of project. durandal_1707 thanks for the last minute check on the file. I also thank my mentor kierank, for his faith in me even though during the second month i was not feeling that i would be able to work on it anymore. I would continue to be involved in FFmpeg development (in my capacity - only a B.Tech student here :\ ). I also know that the project was comparatively easier and could have been finished sooner, so thanks for being patient with me. Sincerely Gagandeep Singh GSOC 2018 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH v3] doc/filters: Add double-pass example for loudnorm
On 22 Aug 2018, at 6:40, Gyan Doshi wrote: On 22-08-2018 04:43 AM, Marvin Scholz wrote: +@example +ffmpeg -i input -af loudnorm=I=-23:TP=-1:measured_I=-9.0:measured_TP=1.5:measured_LRA=9.4:measured_thresh=-19.5:print_format=summary output Since your input LRA is 9.4, and output LRA is 7 (default), the filter will upsample to 192 kHz. You should resample afterwards. Ok, whats the correct way to do that? e.g. ffmpeg -i input -af loudnorm=...,aresample=48000 output This just gives me: [Parsed_aresample_1 @ 0x7f99fb503ec0] Cannot select channel layout for the link between filters Parsed_aresample_1 and format_out_0_1. Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0 Ideally, loudnorm should call a resampler internally, but for now, this is what we can do. Thanks, Gyan ___ 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] avcodec/opus_parser: Handle complete frames flag.
On Wed, Aug 22, 2018 at 12:55 AM James Almer wrote: > > On 8/20/2018 3:35 PM, Jacob Trimble wrote: > > I am not entirely sure what this flag is supposed to be, since there > > is no documentation where it is defined. But this was suggested by > > James Almer as a fix for my encrypted Opus problems and several other > > codec parsers do the same thing. > > It's a flag that lets the parser know what kind of frames it's getting. > libavformat will set it if the source is a demuxer that guarantees the > propagation of complete frames, like mp4, Matroska and Ogg. > The flag should in a perfect world just be an optimization however, and not be required for things to actually work. Otherwise that would indicate a bug in the parser, or maybe a short-coming in the bitstream format to not present frames properly? - Hendrik ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 4/7] Adds gray floating-point pixel formats.
Martin Vignali wrote: >But maybe to make tests simpler, we can use/add bit exact >conversion for uint8 to float, we can generate a LUT without >float calc and for uint16 to float, we can add a uint16 to >float conversion without float calc, or maybe, generate a LUT >in bit exact mode (probably faster, if it's acceptable to have >a LUT for 16bit entries) In my experience, a LUT in bit exact mode is indeed faster. To me the proposed addition would be useful. And I guess LUTs for 16-bit entries will become necessary anyway at some point... Thank you! Reto ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 4/7] Adds gray floating-point pixel formats.
> > > So the only thing I can do is to disable these tests for > > these formats. > > Otherwise, I need to test other changes somehow. Here is the patch, that > > skips > > pixfmts tests for these formats. > > in absence of another solution this should be ok > > I'm not against, removing these tests for now, But maybe to make tests simpler, we can use/add bit exact conversion for uint8 to float, we can generate a LUT without float calc and for uint16 to float, we can add a uint16 to float conversion without float calc, or maybe, generate a LUT in bit exact mode (probably faster, if it's acceptable to have a LUT for 16bit entries) If the bit exact mode is much slower than the "float" version we can keep both, in order to use the bit exact for various tests and use it as reference in order to compare bit exact and "float" conv for each func. I can send patch for this, if need. Martin ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel