[FFmpeg-cvslog] libavcodec/qsvence: Use QSV encoder defaults as ffmpeg defaults
ffmpeg | branch: master | Soft Works | Tue Aug 10 08:53:15 2021 +| [4b3906bd7e211f2681bee6b2bb650648a0a04c35] | committer: James Almer libavcodec/qsvence: Use QSV encoder defaults as ffmpeg defaults Signed-off-by: softworkz > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4b3906bd7e211f2681bee6b2bb650648a0a04c35 --- libavcodec/qsvenc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index fc8a14143e..ba20b6f906 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -76,8 +76,8 @@ #define QSV_COMMON_OPTS \ { "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VE }, \ -{ "avbr_accuracy","Accuracy of the AVBR ratecontrol", OFFSET(qsv.avbr_accuracy),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, \ -{ "avbr_convergence", "Convergence of the AVBR ratecontrol", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, \ +{ "avbr_accuracy","Accuracy of the AVBR ratecontrol (unit of tenth of percent)",OFFSET(qsv.avbr_accuracy),AV_OPT_TYPE_INT, { .i64 = 1 }, 1, UINT16_MAX, VE }, \ +{ "avbr_convergence", "Convergence of the AVBR ratecontrol (unit of 100 frames)", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, UINT16_MAX, VE }, \ { "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_BALANCED }, MFX_TARGETUSAGE_BEST_QUALITY, MFX_TARGETUSAGE_BEST_SPEED, VE, "preset" }, \ { "veryfast",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" }, \ { "faster", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_6 }, INT_MIN, INT_MAX, VE, "preset" }, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avcodec/h264_slice: clear old slice POC values on parsing failure
ffmpeg | branch: release/4.1 | James Almer | Sun Aug 8 15:30:26 2021 -0300| [347bcf6054890f19dd67f53b33489bc5c3c40471] | committer: James Almer avcodec/h264_slice: clear old slice POC values on parsing failure If a slice header fails to parse, and the next one uses different Sequence and Picture parameter sets, certain values may not be read if they are not coded, resulting in the previous slice values being used. Signed-off-by: James Almer (cherry picked from commit ce4a31cd1ff0348d279af74d49556d0315171e94) > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=347bcf6054890f19dd67f53b33489bc5c3c40471 --- libavcodec/h264_slice.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 1c9a270fb6..272f3b00a4 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1821,6 +1821,8 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, if (nal->type == H264_NAL_IDR_SLICE) get_ue_golomb_long(&sl->gb); /* idr_pic_id */ +sl->poc_lsb = 0; +sl->delta_poc_bottom = 0; if (sps->poc_type == 0) { sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); @@ -1828,6 +1830,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, sl->delta_poc_bottom = get_se_golomb(&sl->gb); } +sl->delta_poc[0] = sl->delta_poc[1] = 0; if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) { sl->delta_poc[0] = get_se_golomb(&sl->gb); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] avfilter/avfilter: Use av_memdup where appropriate
ffmpeg | branch: master | Andreas Rheinhardt | Mon Aug 9 08:45:00 2021 +0200| [35b1f46d7930b052d8accb63ccf0993451ae36f2] | committer: Andreas Rheinhardt avfilter/avfilter: Use av_memdup where appropriate Reviewed-by: Nicolas George Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=35b1f46d7930b052d8accb63ccf0993451ae36f2 --- libavfilter/avfilter.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 358bf8a853..f9d7226386 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -659,10 +659,9 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) ret->nb_inputs = avfilter_pad_count(filter->inputs); if (ret->nb_inputs ) { -ret->input_pads = av_malloc_array(ret->nb_inputs, sizeof(AVFilterPad)); +ret->input_pads = av_memdup(filter->inputs, ret->nb_inputs * sizeof(*filter->inputs)); if (!ret->input_pads) goto err; -memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->nb_inputs); ret->inputs = av_mallocz_array(ret->nb_inputs, sizeof(AVFilterLink*)); if (!ret->inputs) goto err; @@ -670,10 +669,9 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) ret->nb_outputs = avfilter_pad_count(filter->outputs); if (ret->nb_outputs) { -ret->output_pads = av_malloc_array(ret->nb_outputs, sizeof(AVFilterPad)); +ret->output_pads = av_memdup(filter->outputs, ret->nb_outputs * sizeof(*filter->outputs)); if (!ret->output_pads) goto err; -memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->nb_outputs); ret->outputs = av_mallocz_array(ret->nb_outputs, sizeof(AVFilterLink*)); if (!ret->outputs) goto err; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] fftools/cmdutils: Use av_strstart() instead of strncmp()
ffmpeg | branch: master | Andreas Rheinhardt | Tue Aug 10 20:19:25 2021 +0200| [c66bb56d9aa819ff952eb7159d014c7c3265016a] | committer: Andreas Rheinhardt fftools/cmdutils: Use av_strstart() instead of strncmp() This also avoids hardcoding lengths. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c66bb56d9aa819ff952eb7159d014c7c3265016a --- fftools/cmdutils.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 64237a4796..6d0bcd6085 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -903,20 +903,18 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg) if (!i && !cmd) { flags = 0; /* missing relative prefix, build absolute value */ } -if (!strncmp(token, "repeat", 6)) { +if (av_strstart(token, "repeat", &arg)) { if (cmd == '-') { flags |= AV_LOG_SKIP_REPEATED; } else { flags &= ~AV_LOG_SKIP_REPEATED; } -arg = token + 6; -} else if (!strncmp(token, "level", 5)) { +} else if (av_strstart(token, "level", &arg)) { if (cmd == '-') { flags &= ~AV_LOG_PRINT_LEVEL; } else { flags |= AV_LOG_PRINT_LEVEL; } -arg = token + 5; } else { break; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] doc/examples/qsvdec: simplify this example via hw_device_ctx interface
ffmpeg | branch: master | Haihao Xiang | Wed Aug 11 14:01:55 2021 +0800| [c3ef9e027769b8fb272ff2794b3e84c98bddea7d] | committer: James Almer doc/examples/qsvdec: simplify this example via hw_device_ctx interface Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c3ef9e027769b8fb272ff2794b3e84c98bddea7d --- doc/examples/qsvdec.c | 45 + 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/doc/examples/qsvdec.c b/doc/examples/qsvdec.c index 7415eefca5..571d868f93 100644 --- a/doc/examples/qsvdec.c +++ b/doc/examples/qsvdec.c @@ -44,38 +44,10 @@ #include "libavutil/hwcontext_qsv.h" #include "libavutil/mem.h" -typedef struct DecodeContext { -AVBufferRef *hw_device_ref; -} DecodeContext; - static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts) { while (*pix_fmts != AV_PIX_FMT_NONE) { if (*pix_fmts == AV_PIX_FMT_QSV) { -DecodeContext *decode = avctx->opaque; -AVHWFramesContext *frames_ctx; -AVQSVFramesContext *frames_hwctx; -int ret; - -/* create a pool of surfaces to be used by the decoder */ -avctx->hw_frames_ctx = av_hwframe_ctx_alloc(decode->hw_device_ref); -if (!avctx->hw_frames_ctx) -return AV_PIX_FMT_NONE; -frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; -frames_hwctx = frames_ctx->hwctx; - -frames_ctx->format= AV_PIX_FMT_QSV; -frames_ctx->sw_format = avctx->sw_pix_fmt; -frames_ctx->width = FFALIGN(avctx->coded_width, 32); -frames_ctx->height= FFALIGN(avctx->coded_height, 32); -frames_ctx->initial_pool_size = 32; - -frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; - -ret = av_hwframe_ctx_init(avctx->hw_frames_ctx); -if (ret < 0) -return AV_PIX_FMT_NONE; - return AV_PIX_FMT_QSV; } @@ -87,7 +59,7 @@ static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts) return AV_PIX_FMT_NONE; } -static int decode_packet(DecodeContext *decode, AVCodecContext *decoder_ctx, +static int decode_packet(AVCodecContext *decoder_ctx, AVFrame *frame, AVFrame *sw_frame, AVPacket *pkt, AVIOContext *output_ctx) { @@ -144,12 +116,12 @@ int main(int argc, char **argv) AVPacket pkt = { 0 }; AVFrame *frame = NULL, *sw_frame = NULL; -DecodeContext decode = { NULL }; - AVIOContext *output_ctx = NULL; int ret, i; +AVBufferRef *device_ref = NULL; + if (argc < 3) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; @@ -177,7 +149,7 @@ int main(int argc, char **argv) } /* open the hardware device */ -ret = av_hwdevice_ctx_create(&decode.hw_device_ref, AV_HWDEVICE_TYPE_QSV, +ret = av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_QSV, "auto", NULL, 0); if (ret < 0) { fprintf(stderr, "Cannot open the hardware device\n"); @@ -209,7 +181,8 @@ int main(int argc, char **argv) decoder_ctx->extradata_size = video_st->codecpar->extradata_size; } -decoder_ctx->opaque = &decode; + +decoder_ctx->hw_device_ctx = av_buffer_ref(device_ref); decoder_ctx->get_format = get_format; ret = avcodec_open2(decoder_ctx, NULL, NULL); @@ -239,7 +212,7 @@ int main(int argc, char **argv) break; if (pkt.stream_index == video_st->index) -ret = decode_packet(&decode, decoder_ctx, frame, sw_frame, &pkt, output_ctx); +ret = decode_packet(decoder_ctx, frame, sw_frame, &pkt, output_ctx); av_packet_unref(&pkt); } @@ -247,7 +220,7 @@ int main(int argc, char **argv) /* flush the decoder */ pkt.data = NULL; pkt.size = 0; -ret = decode_packet(&decode, decoder_ctx, frame, sw_frame, &pkt, output_ctx); +ret = decode_packet(decoder_ctx, frame, sw_frame, &pkt, output_ctx); finish: if (ret < 0) { @@ -263,7 +236,7 @@ finish: avcodec_free_context(&decoder_ctx); -av_buffer_unref(&decode.hw_device_ref); +av_buffer_unref(&device_ref); avio_close(output_ctx); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] qsvdec: add support for HW_DEVICE_CTX method
ffmpeg | branch: master | Haihao Xiang | Wed Aug 11 14:01:54 2021 +0800| [ecee3b07cde23e05bcc6b4eaa55d860b62dbd2dc] | committer: James Almer qsvdec: add support for HW_DEVICE_CTX method This allows user set hw_device_ctx instead of hw_frames_ctx for QSV decoders, hence we may remove the ad-hoc libmfx setup code from FFmpeg. "-hwaccel_output_format format" is applied to QSV decoders after removing the ad-hoc libmfx code. In order to keep compatibility with old commandlines, the default format is set to AV_PIX_FMT_QSV, but this behavior will be removed in the future. Please set "-hwaccel_output_format qsv" explicitly if AV_PIX_FMT_QSV is expected. The normal device stuff works for QSV decoders now, user may use "-init_hw_device args" to initialise device and "-hwaccel_device devicename" to select a device for QSV decoders. "-qsv_device device" which was added for workarounding device selection in the ad-hoc libmfx code still works For example: $> ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=/dev/dri/card0 -hwaccel qsv -c:v h264_qsv -i input.h264 -f null - /dev/dri/renderD128 is actually open for h264_qsv decoder in the above command without this patch. After applying this patch, /dev/dri/card0 is used. $> ffmpeg -init_hw_device vaapi=va:/dev/dri/card0 -init_hw_device qsv=hw@va -hwaccel_device hw -hwaccel qsv -c:v h264_qsv -i input.h264 -f null - device hw of type qsv is not usable in the above command without this patch. After applying this patch, this command works as expected. Reviewed-by: Soft Works Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ecee3b07cde23e05bcc6b4eaa55d860b62dbd2dc --- fftools/Makefile | 1 - fftools/ffmpeg.h | 1 - fftools/ffmpeg_hw.c | 12 ++ fftools/ffmpeg_opt.c | 28 +++-- fftools/ffmpeg_qsv.c | 109 --- libavcodec/qsvdec.c | 31 ++- 6 files changed, 66 insertions(+), 116 deletions(-) diff --git a/fftools/Makefile b/fftools/Makefile index 5affaa3f56..5234932ab0 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -10,7 +10,6 @@ ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF)) ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF)) OBJS-ffmpeg+= fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o -OBJS-ffmpeg-$(CONFIG_LIBMFX) += fftools/ffmpeg_qsv.o ifndef CONFIG_VIDEOTOOLBOX OBJS-ffmpeg-$(CONFIG_VDA) += fftools/ffmpeg_videotoolbox.o endif diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index d9c0628657..d2dd7ca092 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -61,7 +61,6 @@ enum HWAccelID { HWACCEL_AUTO, HWACCEL_GENERIC, HWACCEL_VIDEOTOOLBOX, -HWACCEL_QSV, }; typedef struct HWAccel { diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index fc4a5d31d6..6923c4c5a1 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -339,6 +339,18 @@ int hw_device_setup_for_decode(InputStream *ist) } else if (ist->hwaccel_id == HWACCEL_GENERIC) { type = ist->hwaccel_device_type; dev = hw_device_get_by_type(type); + +// When "-qsv_device device" is used, an internal QSV device named +// as "__qsv_device" is created. Another QSV device is created too +// if "-init_hw_device qsv=name:device" is used. There are 2 QSV devices +// if both "-qsv_device device" and "-init_hw_device qsv=name:device" +// are used, hw_device_get_by_type(AV_HWDEVICE_TYPE_QSV) returns NULL. +// To keep back-compatibility with the removed ad-hoc libmfx setup code, +// call hw_device_get_by_name("__qsv_device") to select the internal QSV +// device. +if (!dev && type == AV_HWDEVICE_TYPE_QSV) +dev = hw_device_get_by_name("__qsv_device"); + if (!dev) err = hw_device_init_from_type(type, NULL, &dev); } else { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 34cc6c4fd3..428934a3d8 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -137,9 +137,6 @@ static const char *const opt_name_enc_time_bases[] = {"enc_time_base" const HWAccel hwaccels[] = { #if CONFIG_VIDEOTOOLBOX { "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX }, -#endif -#if CONFIG_LIBMFX -{ "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV }, #endif { 0 }, }; @@ -571,6 +568,23 @@ static int opt_vaapi_device(void *optctx, const char *opt, const char *arg) } #endif +#if CONFIG_QSV +static int opt_qsv_device(void *optctx, const char *opt, const char *arg) +{ +const char *prefix = "qsv=__qsv_device:hw_any,child_device="; +int err; +char *tmp = av_asprintf("%s%s", prefix, arg); + +if (!tmp) +return AVERROR(ENOMEM); + +err = hw_device_init_from_string(tmp, NULL); +av_free(tmp); + +retur
[FFmpeg-cvslog] libavformat/file.c: 'file_delete()' and 'file_move()' require 'CONFIG_FILE_PROTOCOL'
ffmpeg | branch: master | Michael Witten | Tue Aug 10 16:25:00 2021 +| [f040c1ec4e8020f250d4f9ff966607cb6e6b9811] | committer: Andreas Rheinhardt libavformat/file.c: 'file_delete()' and 'file_move()' require 'CONFIG_FILE_PROTOCOL' This quashes 2 warnings when the 'file' protocol is not enabled. Signed-off-by: Andreas Rheinhardt > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f040c1ec4e8020f250d4f9ff966607cb6e6b9811 --- libavformat/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/file.c b/libavformat/file.c index 8303436be0..9c23f680cd 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -167,6 +167,8 @@ static int file_check(URLContext *h, int mask) return ret; } +#if CONFIG_FILE_PROTOCOL + static int file_delete(URLContext *h) { #if HAVE_UNISTD_H @@ -203,8 +205,6 @@ static int file_move(URLContext *h_src, URLContext *h_dst) return 0; } -#if CONFIG_FILE_PROTOCOL - static int file_open(URLContext *h, const char *filename, int flags) { FileContext *c = h->priv_data; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".