[FFmpeg-cvslog] fftools/ffmpeg_filter: add -autoscale to disable/enable the default scale
ffmpeg | branch: master | Linjie Fu | Mon Jun 8 16:58:05 2020 +0800| [0b511bd9a5487c672fe199ffb2a78a50fc5b2d9f] | committer: Linjie Fu fftools/ffmpeg_filter: add -autoscale to disable/enable the default scale Currently, ffmpeg inserts scale filter by default in the filter graph to force the whole decoded stream to scale into the same size with the first frame. It's not quite make sense in resolution changing cases if user wants the rawvideo without any scale. Using autoscale/noautoscale as an output option to indicate whether auto inserting the scale filter in the filter graph: -noautoscale or -autoscale 0: disable the default auto scale filter inserting. ffmpeg -y -i input.mp4 out1.yuv -noautoscale out2.yuv -autoscale 0 out3.yuv Update docs. Suggested-by: Mark Thompson Reviewed-by: Nicolas George Signed-off-by: U. Artie Eoff Signed-off-by: Linjie Fu > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0b511bd9a5487c672fe199ffb2a78a50fc5b2d9f --- doc/ffmpeg.texi | 16 fftools/ffmpeg.h| 3 +++ fftools/ffmpeg_filter.c | 2 +- fftools/ffmpeg_opt.c| 6 ++ 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 92fb10f4f4..70b8965d7f 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -734,10 +734,6 @@ ffmpeg -dump_attachment:t "" -i INPUT Technical note -- attachments are implemented as codec extradata, so this option can actually be used to extract extradata from any stream, not just attachments. - -@item -noautorotate -Disable automatically rotating video based on file metadata. - @end table @section Video Options @@ -819,6 +815,18 @@ Create the filtergraph specified by @var{filtergraph} and use it to filter the stream. This is an alias for @code{-filter:v}, see the @ref{filter_option,,-filter option}. + +@item -autorotate +Automatically rotate the video according to file metadata. Enabled by +default, use @option{-noautorotate} to disable it. + +@item -autoscale +Automatically scale the video according to the resolution of first frame. +Enabled by default, use @option{-noautoscale} to disable it. When autoscale is +disabled, all output frames of filter graph might not be in the same resolution +and may be inadequate for some encoder/muxer. Therefore, it is not recommended +to disable it unless you really know what you are doing. +Disable autoscale at your own risk. @end table @section Advanced Video options diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 828cb2a4ff..6e3f2545c7 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -229,6 +229,8 @@ typedef struct OptionsContext { intnb_time_bases; SpecifierOpt *enc_time_bases; intnb_enc_time_bases; +SpecifierOpt *autoscale; +intnb_autoscale; } OptionsContext; typedef struct InputFilter { @@ -479,6 +481,7 @@ typedef struct OutputStream { int force_fps; int top_field_first; int rotate_overridden; +int autoscale; double rotate_override_value; AVRational frame_aspect_ratio; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 422e1268e9..4784e8a575 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -470,7 +470,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, if (ret < 0) return ret; -if (ofilter->width || ofilter->height) { +if ((ofilter->width || ofilter->height) && ofilter->ost->autoscale) { char args[255]; AVFilterContext *filter; AVDictionaryEntry *e = NULL; diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 2eb4e1c973..9d1489ce01 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -62,6 +62,7 @@ static const char *opt_name_hwaccels[] = {"hwaccel", NULL}; static const char *opt_name_hwaccel_devices[] = {"hwaccel_device", NULL}; static const char *opt_name_hwaccel_output_formats[]= {"hwaccel_output_format", NULL}; static const char *opt_name_autorotate[]= {"autorotate", NULL}; +static const char *opt_name_autoscale[] = {"autoscale", NULL}; static const char *opt_name_max_frames[]= {"frames", "aframes", "vframes", "dframes", NULL}; static const char *opt_name_bitstream_filters[] = {"bsf", "absf", "vbsf", NULL}; static const char *opt_name_codec_tags[]= {"tag", "atag", "vtag", "stag", NULL}; @@ -1462,6 +1463,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc); MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); +ost->autoscale = 1; +MATCH_PER_STREAM_OPT(autoscale, i, ost->autoscale, oc, st); if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s { do { buf =
[FFmpeg-cvslog] lavf/hls: Add missed side data/disposition
ffmpeg | branch: master | vacingfang | Thu Jun 4 21:59:43 2020 +0800| [b7f3a7c439885945af697580a0c08c0573f8885b] | committer: Jun Zhao lavf/hls: Add missed side data/disposition hls demuxer get the stream info from sub-stream, but missed side data/disposition part, e,g, missed the DOVI side data when the stream is Dolby Vision streams. Reviewed-by Signed-off-by: vacingfang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7f3a7c439885945af697580a0c08c0573f8885b --- libavformat/hls.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavformat/hls.c b/libavformat/hls.c index 17b3dd545d..3798bdd5d1 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1768,6 +1768,20 @@ static int set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, else avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den); +// copy disposition +st->disposition = ist->disposition; + +// copy side data +for (int i = 0; i < ist->nb_side_data; i++) { +const AVPacketSideData *sd_src = &ist->side_data[i]; +uint8_t *dst_data; + +dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size); +if (!dst_data) +return AVERROR(ENOMEM); +memcpy(dst_data, sd_src->data, sd_src->size); +} + st->internal->need_context_update = 1; return 0; ___ 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] lavf/dashdec: Add missed side data/disposition
ffmpeg | branch: master | Jun Zhao | Thu Jun 4 22:00:48 2020 +0800| [3cf2f515e392ab22594f34966e93e75931cfc7e2] | committer: Jun Zhao lavf/dashdec: Add missed side data/disposition dash demuxer get the stream info from sub-stream, but missed side data/disposition part, e,g, missed the DOVI side data when the stream is Dolby Vision streams Signed-off-by: Jun Zhao > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3cf2f515e392ab22594f34966e93e75931cfc7e2 --- libavformat/dashdec.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index ec2aadcee3..694782c820 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -2001,6 +2001,20 @@ static int open_demux_for_component(AVFormatContext *s, struct representation *p st->id = i; avcodec_parameters_copy(st->codecpar, ist->codecpar); avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den); + +// copy disposition +st->disposition = ist->disposition; + +// copy side data +for (int i = 0; i < ist->nb_side_data; i++) { +const AVPacketSideData *sd_src = &ist->side_data[i]; +uint8_t *dst_data; + +dst_data = av_stream_new_side_data(st, sd_src->type, sd_src->size); +if (!dst_data) +return AVERROR(ENOMEM); +memcpy(dst_data, sd_src->data, sd_src->size); +} } return 0; ___ 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] avformat: add MCC demuxer
ffmpeg | branch: master | Paul B Mahol | Sat Jun 13 15:07:41 2020 +0200| [71f19bf5e31ec4039ef0f9e22b157657c57e2cb9] | committer: Paul B Mahol avformat: add MCC demuxer Fixes #7680 > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=71f19bf5e31ec4039ef0f9e22b157657c57e2cb9 --- Changelog| 1 + libavformat/Makefile | 1 + libavformat/allformats.c | 1 + libavformat/mccdec.c | 238 +++ libavformat/version.h| 4 +- 5 files changed, 243 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 2a50ae5dce..a60e7d2eb8 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,7 @@ releases are sorted from youngest to oldest. version : - AudioToolbox output device +- MacCaption demuxer version 4.3: diff --git a/libavformat/Makefile b/libavformat/Makefile index 0658fa3710..26af859a28 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -303,6 +303,7 @@ OBJS-$(CONFIG_MATROSKA_MUXER)+= matroskaenc.o matroska.o \ av1.o avc.o hevc.o \ flacenc_header.o avlanguage.o \ vorbiscomment.o wv.o +OBJS-$(CONFIG_MCC_DEMUXER) += mccdec.o subtitles.o OBJS-$(CONFIG_MD5_MUXER) += hashenc.o OBJS-$(CONFIG_MGSTS_DEMUXER) += mgsts.o OBJS-$(CONFIG_MICRODVD_DEMUXER) += microdvddec.o subtitles.o diff --git a/libavformat/allformats.c b/libavformat/allformats.c index a7c5c9db89..97fd06debb 100644 --- a/libavformat/allformats.c +++ b/libavformat/allformats.c @@ -230,6 +230,7 @@ extern AVInputFormat ff_lvf_demuxer; extern AVInputFormat ff_lxf_demuxer; extern AVInputFormat ff_m4v_demuxer; extern AVOutputFormat ff_m4v_muxer; +extern AVInputFormat ff_mcc_demuxer; extern AVOutputFormat ff_md5_muxer; extern AVInputFormat ff_matroska_demuxer; extern AVOutputFormat ff_matroska_muxer; diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c new file mode 100644 index 00..874ff45cdf --- /dev/null +++ b/libavformat/mccdec.c @@ -0,0 +1,238 @@ +/* + * MCC subtitle demuxer + * Copyright (c) 2020 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 "avformat.h" +#include "internal.h" +#include "subtitles.h" +#include "libavutil/avstring.h" +#include "libavutil/bprint.h" +#include "libavutil/intreadwrite.h" + +typedef struct MCCContext { +FFDemuxSubtitlesQueue q; +} MCCContext; + +static int mcc_probe(const AVProbeData *p) +{ +char buf[28]; +FFTextReader tr; + +ff_text_init_buf(&tr, p->buf, p->buf_size); + +while (ff_text_peek_r8(&tr) == '\r' || ff_text_peek_r8(&tr) == '\n') +ff_text_r8(&tr); + +ff_text_read(&tr, buf, sizeof(buf)); + +if (!memcmp(buf, "File Format=MacCaption_MCC V", 28)) +return AVPROBE_SCORE_MAX; + +return 0; +} + +static int convert(uint8_t x) +{ +if (x >= 'a') +x -= 87; +else if (x >= 'A') +x -= 55; +else +x -= '0'; +return x; +} + +typedef struct alias { +uint8_t key; +int len; +const char *value; +} alias; + +static const alias aliases[20] = { +{ .key = 16, .len = 3, .value = "\xFA\x0\x0", }, +{ .key = 17, .len = 6, .value = "\xFA\x0\x0\xFA\x0\x0", }, +{ .key = 18, .len = 9, .value = "\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0", }, +{ .key = 19, .len = 12, .value = "\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0", }, +{ .key = 20, .len = 15, .value = "\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0", }, +{ .key = 21, .len = 18, .value = "\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0", }, +{ .key = 22, .len = 21, .value = "\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0", }, +{ .key = 23, .len = 24, .value = "\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0", }, +{ .key = 24, .len = 27, .value = "\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0\xFA\x0\x0", }, +{ .key = 25, .len = 3, .value = "\xFB\x80\x80", }, +{ .key = 26, .len = 3, .value = "\xFC\x80\x80", }, +{ .key = 27, .len = 3, .value = "\xFD\x80\x80", }, +{ .key
[FFmpeg-cvslog] avformat/sccdec: make splitting more robust
ffmpeg | branch: master | Paul B Mahol | Wed Jun 17 10:24:05 2020 +0200| [b52ca2cec27bc5d60750680f01f86d22dc8c2cbb] | committer: Paul B Mahol avformat/sccdec: make splitting more robust > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b52ca2cec27bc5d60750680f01f86d22dc8c2cbb --- libavformat/sccdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/sccdec.c b/libavformat/sccdec.c index 4d94743c81..645e52857b 100644 --- a/libavformat/sccdec.c +++ b/libavformat/sccdec.c @@ -140,7 +140,7 @@ static int scc_read_header(AVFormatContext *s) lline = NULL; if (i > 12 && o1 == 0x94 && o2 == 0x20 && saveptr && -(av_strncasecmp(saveptr, "942f", 4) || !av_strncasecmp(saveptr, "942c", 4))) { +(av_strncasecmp(saveptr, "942f", 4) && !av_strncasecmp(saveptr, "942c", 4))) { out[i] = 0; ___ 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/encode: restructure the core encoding code
ffmpeg | branch: master | James Almer | Tue Jun 9 18:31:32 2020 -0300| [827d6fe73d2f5472c1c2128eb14fab6a4db29032] | committer: James Almer avcodec/encode: restructure the core encoding code This commit follows the same logic as 061a0c14bb, but for the encode API: The new public encoding API will no longer be a wrapper around the old deprecated one, and the internal API used by the encoders now consists of a single receive_packet() callback that pulls frames as required. amf encoders adapted by James Almer librav1e encoder adapted by James Almer nvidia encoders adapted by James Almer MediaFoundation encoders adapted by James Almer vaapi encoders adapted by Linjie Fu v4l2_m2m encoders adapted by Andriy Gelman Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=827d6fe73d2f5472c1c2128eb14fab6a4db29032 --- libavcodec/amfenc.c | 43 +++--- libavcodec/amfenc.h | 2 - libavcodec/amfenc_h264.c| 1 - libavcodec/amfenc_hevc.c| 1 - libavcodec/codec.h | 10 +- libavcodec/encode.c | 286 ++-- libavcodec/encode.h | 39 ++ libavcodec/internal.h | 7 +- libavcodec/librav1e.c | 51 --- libavcodec/mfenc.c | 58 libavcodec/nvenc.c | 72 +- libavcodec/nvenc.h | 9 +- libavcodec/nvenc_h264.c | 6 - libavcodec/nvenc_hevc.c | 4 - libavcodec/utils.c | 10 +- libavcodec/v4l2_m2m.c | 8 ++ libavcodec/v4l2_m2m.h | 3 + libavcodec/v4l2_m2m_enc.c | 15 ++- libavcodec/vaapi_encode.c | 27 +++- libavcodec/vaapi_encode.h | 3 +- libavcodec/vaapi_encode_h264.c | 1 - libavcodec/vaapi_encode_h265.c | 1 - libavcodec/vaapi_encode_mjpeg.c | 1 - libavcodec/vaapi_encode_mpeg2.c | 1 - libavcodec/vaapi_encode_vp8.c | 1 - libavcodec/vaapi_encode_vp9.c | 1 - libavcodec/version.h| 2 +- 27 files changed, 443 insertions(+), 220 deletions(-) diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index 876fddd2b6..da0652943d 100644 --- a/libavcodec/amfenc.c +++ b/libavcodec/amfenc.c @@ -33,6 +33,7 @@ #include "libavutil/time.h" #include "amfenc.h" +#include "encode.h" #include "internal.h" #if CONFIG_D3D11VA @@ -588,17 +589,27 @@ static void amf_release_buffer_with_frame_ref(AMFBuffer *frame_ref_storage_buffe frame_ref_storage_buffer->pVtbl->Release(frame_ref_storage_buffer); } -int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame) +int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt) { AmfContext *ctx = avctx->priv_data; AMFSurface *surface; AMF_RESULT res; int ret; +AMF_RESULT res_query; +AMFData*data = NULL; +AVFrame*frame = ctx->delayed_frame; +int block_and_wait; if (!ctx->encoder) return AVERROR(EINVAL); -if (!frame) { // submit drain +if (!frame->buf[0]) { +ret = ff_encode_get_frame(avctx, frame); +if (ret < 0 && ret != AVERROR_EOF) +return ret; +} + +if (!frame->buf[0]) { // submit drain if (!ctx->eof) { // submit drain one time only if (ctx->delayed_surface != NULL) { ctx->delayed_drain = 1; // input queue is full: resubmit Drain() in ff_amf_receive_packet @@ -613,15 +624,10 @@ int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame) AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, "Drain() failed with error %d\n", res); } } -} else{ -return AVERROR_EOF; } -} else { // submit frame +} else if (!ctx->delayed_surface) { // submit frame int hw_surface = 0; -if (ctx->delayed_surface != NULL) { -return AVERROR(EAGAIN); // should not happen when called from ffmpeg, other clients may resubmit -} // prepare surface from frame switch (frame->format) { #if CONFIG_D3D11VA @@ -693,38 +699,23 @@ int ff_amf_send_frame(AVCodecContext *avctx, const AVFrame *frame) break; } - // submit surface res = ctx->encoder->pVtbl->SubmitInput(ctx->encoder, (AMFData*)surface); if (res == AMF_INPUT_FULL) { // handle full queue //store surface for later submission ctx->delayed_surface = surface; -if (surface->pVtbl->GetMemoryType(surface) == AMF_MEMORY_DX11) { -av_frame_ref(ctx->delayed_frame, frame); -} } else { +int64_t pts = frame->pts; surface->pVtbl->Release(surface); AMF_RETURN_IF_FALSE(ctx, res == AMF_OK, AVERROR_UNKNOWN, "SubmitInput() failed with error %d\n", res); -if ((ret = timestamp_queue_enqueue(avctx, frame->pts)) < 0) { +av_frame
[FFmpeg-cvslog] avcodec/encode: restructure the old encode API
ffmpeg | branch: master | James Almer | Tue Jun 9 18:35:00 2020 -0300| [93016f5d1d280f9cb7856883af287fa66affc04c] | committer: James Almer avcodec/encode: restructure the old encode API Following the same logic as 061a0c14bb, this commit turns the old encode API into a wrapper for the new one. Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=93016f5d1d280f9cb7856883af287fa66affc04c --- libavcodec/encode.c | 370 +++--- libavcodec/internal.h | 1 + libavcodec/utils.c| 8 +- 3 files changed, 116 insertions(+), 263 deletions(-) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 83602ca45b..8bc10c4abb 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -32,43 +32,28 @@ int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size) { -if (avpkt->size < 0) { -av_log(avctx, AV_LOG_ERROR, "Invalid negative user packet size %d\n", avpkt->size); -return AVERROR(EINVAL); -} if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) { av_log(avctx, AV_LOG_ERROR, "Invalid minimum required packet size %"PRId64" (max allowed is %d)\n", size, INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE); return AVERROR(EINVAL); } +av_assert0(!avpkt->data); + if (avctx && 2*min_size < size) { // FIXME The factor needs to be finetuned -av_assert0(!avpkt->data || avpkt->data != avctx->internal->byte_buffer); -if (!avpkt->data || avpkt->size < size) { -av_fast_padded_malloc(&avctx->internal->byte_buffer, &avctx->internal->byte_buffer_size, size); -avpkt->data = avctx->internal->byte_buffer; -avpkt->size = avctx->internal->byte_buffer_size; -} +av_fast_padded_malloc(&avctx->internal->byte_buffer, &avctx->internal->byte_buffer_size, size); +avpkt->data = avctx->internal->byte_buffer; +avpkt->size = size; } -if (avpkt->data) { -AVBufferRef *buf = avpkt->buf; - -if (avpkt->size < size) { -av_log(avctx, AV_LOG_ERROR, "User packet is too small (%d < %"PRId64")\n", avpkt->size, size); -return AVERROR(EINVAL); -} - -av_init_packet(avpkt); -avpkt->buf = buf; -avpkt->size = size; -return 0; -} else { +if (!avpkt->data) { int ret = av_new_packet(avpkt, size); if (ret < 0) av_log(avctx, AV_LOG_ERROR, "Failed to allocate packet of size %"PRId64"\n", size); return ret; } + +return 0; } /** @@ -105,244 +90,6 @@ fail: return ret; } -int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx, - AVPacket *avpkt, - const AVFrame *frame, - int *got_packet_ptr) -{ -AVFrame *extended_frame = NULL; -AVFrame *padded_frame = NULL; -int ret; -AVPacket user_pkt = *avpkt; -int needs_realloc = !user_pkt.data; - -*got_packet_ptr = 0; - -if (!avctx->codec->encode2) { -av_log(avctx, AV_LOG_ERROR, "This encoder requires using the avcodec_send_frame() API.\n"); -return AVERROR(ENOSYS); -} - -if (!(avctx->codec->capabilities & AV_CODEC_CAP_DELAY) && !frame) { -av_packet_unref(avpkt); -return 0; -} - -/* ensure that extended_data is properly set */ -if (frame && !frame->extended_data) { -if (av_sample_fmt_is_planar(avctx->sample_fmt) && -avctx->channels > AV_NUM_DATA_POINTERS) { -av_log(avctx, AV_LOG_ERROR, "Encoding to a planar sample format, " -"with more than %d channels, but extended_data is not set.\n", - AV_NUM_DATA_POINTERS); -return AVERROR(EINVAL); -} -av_log(avctx, AV_LOG_WARNING, "extended_data is not set.\n"); - -extended_frame = av_frame_alloc(); -if (!extended_frame) -return AVERROR(ENOMEM); - -memcpy(extended_frame, frame, sizeof(AVFrame)); -extended_frame->extended_data = extended_frame->data; -frame = extended_frame; -} - -/* extract audio service type metadata */ -if (frame) { -AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_AUDIO_SERVICE_TYPE); -if (sd && sd->size >= sizeof(enum AVAudioServiceType)) -avctx->audio_service_type = *(enum AVAudioServiceType*)sd->data; -} - -/* check for valid frame size */ -if (frame) { -if (avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) { -if (frame->nb_samples > avctx->frame_size) { -av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n"); -ret = AVERROR(EINVAL); -goto end;
[FFmpeg-cvslog] avfilter/vf_overlay: add yuv420p10 and yuv422p10 10bit format support
ffmpeg | branch: master | Limin Wang | Fri Jun 5 21:58:01 2020 +0800| [dacae40a4bbb542b0f02ba32ca558d318c7b7db0] | committer: Limin Wang avfilter/vf_overlay: add yuv420p10 and yuv422p10 10bit format support Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dacae40a4bbb542b0f02ba32ca558d318c7b7db0 --- doc/filters.texi | 6 libavfilter/vf_overlay.c | 79 libavfilter/vf_overlay.h | 2 ++ 3 files changed, 87 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 84567dec16..5f0eb28f76 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -14342,9 +14342,15 @@ It accepts the following values: @item yuv420 force YUV420 output +@item yuv420p10 +force YUV420p10 output + @item yuv422 force YUV422 output +@item yuv422p10 +force YUV422p10 output + @item yuv444 force YUV444 output diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index 5c986c3bd3..b3a1ac1a09 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -154,6 +154,7 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar static const enum AVPixelFormat alpha_pix_fmts[] = { AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_YUVA444P, +AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_ARGB, AV_PIX_FMT_ABGR, AV_PIX_FMT_RGBA, AV_PIX_FMT_BGRA, AV_PIX_FMT_GBRAP, AV_PIX_FMT_NONE }; @@ -172,6 +173,14 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE }; +static const enum AVPixelFormat main_pix_fmts_yuv420p10[] = { +AV_PIX_FMT_YUV420P10, AV_PIX_FMT_YUVA420P10, +AV_PIX_FMT_NONE +}; +static const enum AVPixelFormat overlay_pix_fmts_yuv420p10[] = { +AV_PIX_FMT_YUVA420P10, AV_PIX_FMT_NONE +}; + static const enum AVPixelFormat main_pix_fmts_yuv422[] = { AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVA422P, AV_PIX_FMT_NONE }; @@ -179,6 +188,13 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_YUVA422P, AV_PIX_FMT_NONE }; +static const enum AVPixelFormat main_pix_fmts_yuv422p10[] = { +AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_NONE +}; +static const enum AVPixelFormat overlay_pix_fmts_yuv422p10[] = { +AV_PIX_FMT_YUVA422P10, AV_PIX_FMT_NONE +}; + static const enum AVPixelFormat main_pix_fmts_yuv444[] = { AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE }; @@ -217,6 +233,13 @@ static int query_formats(AVFilterContext *ctx) goto fail; } break; +case OVERLAY_FORMAT_YUV420P10: +if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv420p10)) || +!(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv420p10))) { +ret = AVERROR(ENOMEM); +goto fail; +} +break; case OVERLAY_FORMAT_YUV422: if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv422)) || !(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv422))) { @@ -224,6 +247,13 @@ static int query_formats(AVFilterContext *ctx) goto fail; } break; +case OVERLAY_FORMAT_YUV422P10: +if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv422p10)) || +!(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv422p10))) { +ret = AVERROR(ENOMEM); +goto fail; +} +break; case OVERLAY_FORMAT_YUV444: if (!(main_formats= ff_make_format_list(main_pix_fmts_yuv444)) || !(overlay_formats = ff_make_format_list(overlay_pix_fmts_yuv444))) { @@ -566,6 +596,7 @@ static av_always_inline void blend_plane_##depth##_##nbits##bits(AVFilterContext } \ } DEFINE_BLEND_PLANE(8, 8); +DEFINE_BLEND_PLANE(16, 10); #define DEFINE_ALPHA_COMPOSITE(depth, nbits) \ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, const AVFrame *dst, \ @@ -617,6 +648,7 @@ static inline void alpha_composite_##depth##_##nbits##bits(const AVFrame *src, c } \ } DEFINE_ALPHA_COMPOSITE(8, 8); +DEFINE_ALPHA_COMPOSITE(16, 10); #define DEFINE_BLEND_SLICE_YUV(depth, nbits) \ static av_always_inline void blend_slice_yuv_##depth##_##nbits##bits(AVFilterContext *ctx, \ @@ -648,6 +680,7 @@ static av_always_inline void blend_slice_yuv_##depth##_##nbits##bits(AVFilterCon jobnr, nb_
[FFmpeg-cvslog] avfilter/vf_overlay: support for 8bit and 10bit overlay with macro-based function
ffmpeg | branch: master | Limin Wang | Fri Jun 5 21:58:00 2020 +0800| [4d787c16e844dc35a0de3b1ac6db7c6e1aa62138] | committer: Limin Wang avfilter/vf_overlay: support for 8bit and 10bit overlay with macro-based function Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4d787c16e844dc35a0de3b1ac6db7c6e1aa62138 --- libavfilter/vf_overlay.c | 417 +-- 1 file changed, 220 insertions(+), 197 deletions(-) diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index b5ab5fba5f..5c986c3bd3 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -441,190 +441,213 @@ static av_always_inline void blend_slice_packed_rgb(AVFilterContext *ctx, } } -static av_always_inline void blend_plane(AVFilterContext *ctx, - AVFrame *dst, const AVFrame *src, - int src_w, int src_h, - int dst_w, int dst_h, - int i, int hsub, int vsub, - int x, int y, - int main_has_alpha, - int dst_plane, - int dst_offset, - int dst_step, - int straight, - int yuv, - int jobnr, - int nb_jobs) -{ -OverlayContext *octx = ctx->priv; -int src_wp = AV_CEIL_RSHIFT(src_w, hsub); -int src_hp = AV_CEIL_RSHIFT(src_h, vsub); -int dst_wp = AV_CEIL_RSHIFT(dst_w, hsub); -int dst_hp = AV_CEIL_RSHIFT(dst_h, vsub); -int yp = y>>vsub; -int xp = x>>hsub; -uint8_t *s, *sp, *d, *dp, *dap, *a, *da, *ap; -int jmax, j, k, kmax; -int slice_start, slice_end; - -j = FFMAX(-yp, 0); -jmax = FFMIN3(-yp + dst_hp, FFMIN(src_hp, dst_hp), yp + src_hp); - -slice_start = j + (jmax * jobnr) / nb_jobs; -slice_end = j + (jmax * (jobnr+1)) / nb_jobs; - -sp = src->data[i] + (slice_start) * src->linesize[i]; -dp = dst->data[dst_plane] - + (yp + slice_start) * dst->linesize[dst_plane] - + dst_offset; -ap = src->data[3] + (slice_start << vsub) * src->linesize[3]; -dap = dst->data[3] + ((yp + slice_start) << vsub) * dst->linesize[3]; - -for (j = slice_start; j < slice_end; j++) { -k = FFMAX(-xp, 0); -d = dp + (xp+k) * dst_step; -s = sp + k; -a = ap + (kblend_row[i](d, da, s, a, kmax - k, src->linesize[3]); - -s += c; -d += dst_step * c; -da += (1 << hsub) * c; -a += (1 << hsub) * c; -k += c; -} -for (; k < kmax; k++) { -int alpha_v, alpha_h, alpha; - -// average alpha for color components, improve quality -if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) { -alpha = (a[0] + a[src->linesize[3]] + - a[1] + a[src->linesize[3]+1]) >> 2; -} else if (hsub || vsub) { -alpha_h = hsub && k+1 < src_wp ? -(a[0] + a[1]) >> 1 : a[0]; -alpha_v = vsub && j+1 < src_hp ? -(a[0] + a[src->linesize[3]]) >> 1 : a[0]; -alpha = (alpha_v + alpha_h) >> 1; -} else -alpha = a[0]; -// if the main channel has an alpha channel, alpha has to be calculated -// to create an un-premultiplied (straight) alpha value -if (main_has_alpha && alpha != 0 && alpha != 255) { -// average alpha for color components, improve quality -uint8_t alpha_d; -if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) { -alpha_d = (da[0] + da[dst->linesize[3]] + - da[1] + da[dst->linesize[3]+1]) >> 2; -} else if (hsub || vsub) { -alpha_h = hsub && k+1 < src_wp ? -(da[0] + da[1]) >> 1 : da[0]; -alpha_v = vsub && j+1 < src_hp ? -(da[0] + da[dst->linesize[3]]) >> 1 : da[0]; -alpha_d = (alpha_v + alpha_h) >> 1; -} else -alpha_d = da[0]; -alpha = UNPREMULTIPLY_ALPHA(alpha, alpha_d); -} -if (straight) { -*d = FAST_DIV255(*d * (255 - alpha) + *s * alpha); -} else { -if (i && yuv) -*d = av_clip(FAST_DIV255((*d - 128) * (255 - alpha)) + *s - 128, -128, 128) + 128; -else -*d = FFMIN(FAST_DIV255(*d * (255 - alpha)) + *s, 255); -}
[FFmpeg-cvslog] fate: add yuv420p10 and yuv422p10 tests for overlay filter
ffmpeg | branch: master | Limin Wang | Fri Jun 5 21:58:02 2020 +0800| [2f5994679b17da1f8a8737cd6b87e912b897e32d] | committer: Limin Wang fate: add yuv420p10 and yuv422p10 tests for overlay filter Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2f5994679b17da1f8a8737cd6b87e912b897e32d --- tests/fate/filter-video.mak | 8 tests/filtergraphs/overlay_yuv420p10| 5 + tests/filtergraphs/overlay_yuv422p10| 5 + tests/ref/fate/filter-overlay_yuv420p10 | 8 tests/ref/fate/filter-overlay_yuv422p10 | 8 5 files changed, 34 insertions(+) diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak index cfeb53e532..18fe4f7016 100644 --- a/tests/fate/filter-video.mak +++ b/tests/fate/filter-video.mak @@ -223,6 +223,10 @@ FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_F fate-filter-overlay_yuv420: tests/data/filtergraphs/overlay_yuv420 fate-filter-overlay_yuv420: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv420 +FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_yuv420p10 +fate-filter-overlay_yuv420p10: tests/data/filtergraphs/overlay_yuv420p10 +fate-filter-overlay_yuv420p10: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv420p10 -pix_fmt yuv420p10le -frames:v 3 + FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_nv12 fate-filter-overlay_nv12: tests/data/filtergraphs/overlay_nv12 fate-filter-overlay_nv12: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_nv12 @@ -237,6 +241,10 @@ FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_F fate-filter-overlay_yuv422: tests/data/filtergraphs/overlay_yuv422 fate-filter-overlay_yuv422: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv422 +FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_yuv422p10 +fate-filter-overlay_yuv422p10: tests/data/filtergraphs/overlay_yuv422p10 +fate-filter-overlay_yuv422p10: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv422p10 -pix_fmt yuv422p10le -frames:v 3 + FATE_FILTER_VSYNTH-$(call ALLYES, SPLIT_FILTER SCALE_FILTER PAD_FILTER OVERLAY_FILTER) += fate-filter-overlay_yuv444 fate-filter-overlay_yuv444: tests/data/filtergraphs/overlay_yuv444 fate-filter-overlay_yuv444: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_complex_script $(TARGET_PATH)/tests/data/filtergraphs/overlay_yuv444 diff --git a/tests/filtergraphs/overlay_yuv420p10 b/tests/filtergraphs/overlay_yuv420p10 new file mode 100644 index 00..d946d3c521 --- /dev/null +++ b/tests/filtergraphs/overlay_yuv420p10 @@ -0,0 +1,5 @@ +sws_flags=+accurate_rnd+bitexact; +split [main][over]; +[over] scale=88:72, format=yuv420p10, pad=96:80:4:4 [overf]; +[main] format=yuv420p10 [mainf]; +[mainf][overf] overlay=240:16:format=yuv420p10 diff --git a/tests/filtergraphs/overlay_yuv422p10 b/tests/filtergraphs/overlay_yuv422p10 new file mode 100644 index 00..5753ba6c91 --- /dev/null +++ b/tests/filtergraphs/overlay_yuv422p10 @@ -0,0 +1,5 @@ +sws_flags=+accurate_rnd+bitexact; +split [main][over]; +[over] scale=88:72, format=yuv420p10, pad=96:80:4:4 [overf]; +[main] format=yuv420p10 [mainf]; +[mainf][overf] overlay=240:16:format=yuv422p10 diff --git a/tests/ref/fate/filter-overlay_yuv420p10 b/tests/ref/fate/filter-overlay_yuv420p10 new file mode 100644 index 00..b431dc6ccb --- /dev/null +++ b/tests/ref/fate/filter-overlay_yuv420p10 @@ -0,0 +1,8 @@ +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 352x288 +#sar 0: 0/1 +0, 0, 0,1, 304128, 0x29a6ca86 +0, 1, 1,1, 304128, 0x82950e6f +0, 2, 2,1, 304128, 0x8363d1d8 diff --git a/tests/ref/fate/filter-overlay_yuv422p10 b/tests/ref/fate/filter-overlay_yuv422p10 new file mode 100644 index 00..393c08169e --- /dev/null +++ b/tests/ref/fate/filter-overlay_yuv422p10 @@ -0,0 +1,8 @@ +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 352x288 +#sar 0: 0/1 +0, 0, 0,1, 405504, 0x11108b36 +0, 1, 1,1, 405504, 0x9d5f7c2a +0, 2, 2,1, 405504, 0x25373098 ___ 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/libx265: Fix integer overflow in computation of max and avg bitrate
ffmpeg | branch: master | Limin Wang | Mon Jun 8 19:51:33 2020 +0800| [e3b5897fe3f1b76b4d46bab452cd35a7f308a93a] | committer: Limin Wang avcodec/libx265: Fix integer overflow in computation of max and avg bitrate Signed-off-by: Limin Wang > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e3b5897fe3f1b76b4d46bab452cd35a7f308a93a --- libavcodec/libx265.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index f560d7f62f..686c205b6b 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -310,8 +310,8 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx) if (!cpb_props) return AVERROR(ENOMEM); cpb_props->buffer_size = ctx->params->rc.vbvBufferSize * 1000; -cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000; -cpb_props->avg_bitrate = ctx->params->rc.bitrate * 1000; +cpb_props->max_bitrate = ctx->params->rc.vbvMaxBitrate * 1000LL; +cpb_props->avg_bitrate = ctx->params->rc.bitrate * 1000LL; if (!(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) ctx->params->bRepeatHeaders = 1; ___ 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".