Re: [FFmpeg-devel] libavcodec: r12b decoder
In my case https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210607063205.180031-1-val.zapod...@gmail.com/ v1 failed to apply due to https://github.com/FFmpeg/FFmpeg/commit/575e52272d42f4278c6620f1a999c41425db2094 I suppose in your case it is https://github.com/FFmpeg/FFmpeg/commit/8bcce5673a267ed371140bf3228ffb420ca2f69b which increased micro. P.S. Do not forget to make micro 100 when you increase minor version now. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay_cuda: add hsub and vsub compute x and y positions
> 2021年5月31日 下午3:16,Steven Liu 写道: > > fix problem when set x to odd number in nv12 by cuda, > > test step: > 1. ffmpeg -f lavfi testsrc2=s=176x144 -pix_fmt nv12 -t 1 output_overlay.yuv > 1. ffmpeg -f lavfi testsrc2=s=352x288 -pix_fmt nv12 -t 1 output_main.yuv > before this patch: > overlay_cuda=x=0:y=0 will right, > overlay_cuda=x=3:y=0 will wrong, > > both will right after patch. > > Signed-off-by: Steven Liu > --- > libavfilter/vf_overlay_cuda.c | 8 > 1 file changed, 8 insertions(+) > > diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c > index b91ac9a713..37886a9d3b 100644 > --- a/libavfilter/vf_overlay_cuda.c > +++ b/libavfilter/vf_overlay_cuda.c > @@ -145,11 +145,16 @@ static int overlay_cuda_blend(FFFrameSync *fs) > AVFilterContext *avctx = fs->parent; > OverlayCUDAContext *ctx = avctx->priv; > AVFilterLink *outlink = avctx->outputs[0]; > +AVFilterLink *inlink = avctx->inputs[0]; > > CudaFunctions *cu = ctx->hwctx->internal->cuda_dl; > CUcontext dummy, cuda_ctx = ctx->hwctx->cuda_ctx; > > AVFrame *input_main, *input_overlay; > +const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); > + > +int hsub = pix_desc->log2_chroma_w; > +int vsub = pix_desc->log2_chroma_h; > > ctx->cu_ctx = cuda_ctx; > > @@ -178,6 +183,9 @@ static int overlay_cuda_blend(FFFrameSync *fs) > return ret; > } > > + > +ctx->x_position &= (1 << hsub) - 1; > +ctx->y_position &= (1 << vsub) - 1; > // overlay first plane > > overlay_cuda_call_kernel(ctx, > -- > 2.25.0 > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > Ping Thanks Steven Liu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/2] fftools/ffprobe: 240M matrix is not the same as BT.601
So I am resending still with that comment and a typo fixed to "ffplay". I also found this: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20180501194013.9552-8-one...@gmail.com/ It way be nice to apply that too, but then again my problem is not that. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] doc/examples/muxing: remove unused arguments of open_video and open_audio
> 2021年5月28日 下午9:36,Steven Liu 写道: > > Signed-off-by: Steven Liu > --- > doc/examples/muxing.c | 10 -- > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c > index fe1b9ded21..3986561b2f 100644 > --- a/doc/examples/muxing.c > +++ b/doc/examples/muxing.c > @@ -242,8 +242,7 @@ static AVFrame *alloc_audio_frame(enum AVSampleFormat > sample_fmt, > return frame; > } > > -static void open_audio(AVFormatContext *oc, const AVCodec *codec, > - OutputStream *ost, AVDictionary *opt_arg) > +static void open_audio(const AVCodec *codec, OutputStream *ost, AVDictionary > *opt_arg) > { > AVCodecContext *c; > int nb_samples; > @@ -406,8 +405,7 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, > int width, int height) > return picture; > } > > -static void open_video(AVFormatContext *oc, const AVCodec *codec, > - OutputStream *ost, AVDictionary *opt_arg) > +static void open_video(const AVCodec *codec, OutputStream *ost, AVDictionary > *opt_arg) > { > int ret; > AVCodecContext *c = ost->enc; > @@ -592,10 +590,10 @@ int main(int argc, char **argv) > /* Now that all the parameters are set, we can open the audio and > * video codecs and allocate the necessary encode buffers. */ > if (have_video) > -open_video(oc, video_codec, &video_st, opt); > +open_video(video_codec, &video_st, opt); > > if (have_audio) > -open_audio(oc, audio_codec, &audio_st, opt); > +open_audio(audio_codec, &audio_st, opt); > > av_dump_format(oc, 0, filename, 1); > > -- > 2.25.0 > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe”.ing > Ping Thanks Steven Liu ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] fftools/ffplay: 240M matrix is not the same as BT.601
Signed-off-by: Valerii Zapodovnikov --- fftools/ffplay.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 0be1d90bf9..53bd9362fa 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -963,12 +963,12 @@ static void set_sdl_yuv_conversion_mode(AVFrame *frame) if (frame && (frame->format == AV_PIX_FMT_YUV420P || frame->format == AV_PIX_FMT_YUYV422 || frame->format == AV_PIX_FMT_UYVY422)) { if (frame->color_range == AVCOL_RANGE_JPEG) mode = SDL_YUV_CONVERSION_JPEG; -else if (frame->colorspace == AVCOL_SPC_BT709) +else if (frame->colorspace == AVCOL_SPC_BT709) /* FIXME: sometimes it selects this even for BT.601 matrix, see issue 8862 */ mode = SDL_YUV_CONVERSION_BT709; -else if (frame->colorspace == AVCOL_SPC_BT470BG || frame->colorspace == AVCOL_SPC_SMPTE170M || frame->colorspace == AVCOL_SPC_SMPTE240M) +else if (frame->colorspace == AVCOL_SPC_BT470BG || frame->colorspace == AVCOL_SPC_SMPTE170M) mode = SDL_YUV_CONVERSION_BT601; } -SDL_SetYUVConversionMode(mode); +SDL_SetYUVConversionMode(mode); /* FIXME: no support for linear transfer */ #endif } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fate: fix input arguments for fate-unknown_layout-ac3
Do you know what command to use with http://fate-suite.ffmpeg.org/dolby_e/16-11.pcm? I used -ac 6, but I dunno everything else I used was not giving perfect sound (-f s16le -ac 6 was most important to at least get something playable). Sigh. Also I suppose sample rate will not be 48000 since it is PAL Dolby E. Thank you :) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] libavcodec: r12b decoder
Pulled master and re-applied to resolve version update conflict Kind regards, Dennis Fleurbaaij From b5fff34f545a107e07c9390a983e3a9aadb71a1c Mon Sep 17 00:00:00 2001 From: Dennis Fleurbaaij Date: Mon, 7 Jun 2021 12:06:51 +0200 Subject: [PATCH] libavcodec: r12b decoder added R12B is a format used by BlackMagic DeckLink cards, it is a big-endian 12bpp RGB format which packs 8 pixels into 36 bytes. --- Changelog | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/r12bdec.c| 139 libavcodec/version.h| 4 +- libavformat/riff.c | 1 + 8 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 libavcodec/r12bdec.c diff --git a/Changelog b/Changelog index b9d5188cf6..d0717072eb 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,7 @@ version : - ADPCM IMA Acorn Replay decoder - Argonaut Games CVG demuxer - Argonaut Games CVG muxer +- r12b decoder version 4.4: diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 4fa8d7ab10..cfef9d57ff 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -575,6 +575,7 @@ OBJS-$(CONFIG_QTRLE_ENCODER) += qtrleenc.o OBJS-$(CONFIG_R10K_DECODER)+= r210dec.o OBJS-$(CONFIG_R10K_ENCODER)+= r210enc.o OBJS-$(CONFIG_R210_DECODER)+= r210dec.o +OBJS-$(CONFIG_R12B_DECODER)+= r12bdec.o OBJS-$(CONFIG_R210_ENCODER)+= r210enc.o OBJS-$(CONFIG_RA_144_DECODER) += ra144dec.o ra144.o celp_filters.o OBJS-$(CONFIG_RA_144_ENCODER) += ra144enc.o ra144.o celp_filters.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 623db2a9fa..8db7e730a6 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -266,6 +266,7 @@ extern const AVCodec ff_qtrle_encoder; extern const AVCodec ff_qtrle_decoder; extern const AVCodec ff_r10k_encoder; extern const AVCodec ff_r10k_decoder; +extern const AVCodec ff_r12b_decoder; extern const AVCodec ff_r210_encoder; extern const AVCodec ff_r210_decoder; extern const AVCodec ff_rasc_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 35527dcc37..ef58d73576 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1856,6 +1856,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_R12B, +.type = AVMEDIA_TYPE_VIDEO, +.name = "r12b", +.long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 12-bit 8px in 36B"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSLESS, +}, /* various PCM "codecs" */ { diff --git a/libavcodec/codec_id.h b/libavcodec/codec_id.h index 83e1dbb4b3..ecfdbc46c0 100644 --- a/libavcodec/codec_id.h +++ b/libavcodec/codec_id.h @@ -306,6 +306,7 @@ enum AVCodecID { AV_CODEC_ID_CRI, AV_CODEC_ID_SIMBIOSIS_IMX, AV_CODEC_ID_SGA_VIDEO, +AV_CODEC_ID_R12B, /* various PCM "codecs" */ AV_CODEC_ID_FIRST_AUDIO = 0x1, ///< A dummy id pointing at the start of audio codecs diff --git a/libavcodec/r12bdec.c b/libavcodec/r12bdec.c new file mode 100644 index 00..7d415a8fd6 --- /dev/null +++ b/libavcodec/r12bdec.c @@ -0,0 +1,139 @@ +/* + * r12b decoder + * + * Copyright (c) 2021 Dennis Fleurbaaij + * + * 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 "internal.h" +#include "libavutil/bswap.h" +#include "libavutil/common.h" + +#define WORDS_PER_BLOCK 9 +#define PIXELS_PER_BLOCK 8 +#define BYTES_PER_BLOCK 36 + +static av_cold int decode_init(AVCodecContext *avctx) +{ +avctx->pix_fmt = AV_PIX_FMT_GBRP12LE; +avctx->bits_per_raw_sample = 12; + +return 0; +} + +static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, +AVPacket *avpkt) +{ +if (avctx->width % PIXELS_PER_BLOCK != 0) { +av_log(avctx, AV_LOG_ERROR, "image width not modulo 8\n"); +return AVERROR_INVALIDDATA; +} + +AVFrame *pic = data; +pic->pict_type = AV
Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay_cuda: add hsub and vsub compute x and y positions
Missed this one, will give it a test. Looks good to me so far. smime.p7s Description: S/MIME Cryptographic Signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] libavcodec: r12b decoder
Dennis Fleurbaaij: > Pulled master and re-applied to resolve version update conflict > > Kind regards, > Dennis Fleurbaaij > > > > +if (avctx->width % PIXELS_PER_BLOCK != 0) { > +av_log(avctx, AV_LOG_ERROR, "image width not modulo 8\n"); > +return AVERROR_INVALIDDATA; > +} > + > +AVFrame *pic = data; > +pic->pict_type = AV_PICTURE_TYPE_I; > +pic->key_frame = 1; > + This (and other declarations below) should give statement-before declaration warnings (FFmpeg still uses the C90 convention that all declarations have to be at the top of each block. > +const uint8_t* src = (const uint8_t *)avpkt->data; Unnecessary cast (adding const is safe and doesn't need a cast). > > +#define GET_F0(word, byte) ((GET_FF(word, byte) & 0xF0) >> 4) The & is unnecessary, but the compiler will probably figure this out on its own. > > +#if CONFIG_R12B_DECODER > +const AVCodec ff_r12b_decoder = { > +.name = "r12b", > +.long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 12-bit 8px in > 36B"), > +.type = AVMEDIA_TYPE_VIDEO, > +.id = AV_CODEC_ID_R12B, > +.init = decode_init, > +.decode = decode_frame, > +.capabilities = AV_CODEC_CAP_DR1, > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, > +}; > +#endif The #if is unnecessary as r12bdec.c will only get compiled if CONFIG_R12B_DECODER is true. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] ffmpeg: silence a thread_safe_callbacks deprecation warning
Signed-off-by: James Almer --- fftools/ffmpeg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 04ddc9e60b..e97d879cb3 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2962,7 +2962,9 @@ static int init_input_stream(int ist_index, char *error, int error_len) ist->dec_ctx->get_format= get_format; ist->dec_ctx->get_buffer2 = get_buffer; #if LIBAVCODEC_VERSION_MAJOR < 60 +FF_DISABLE_DEPRECATION_WARNINGS ist->dec_ctx->thread_safe_callbacks = 1; +FF_ENABLE_DEPRECATION_WARNINGS #endif if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE && -- 2.31.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 30/39] avcodec/internal: Remove outdated documentation of ff_alloc_packet2()
James Almer: > On 5/21/2021 6:17 AM, Andreas Rheinhardt wrote: >> Its documentation described the way user-supplied buffers worked >> before 93016f5d1d280f9cb7856883af287fa66affc04c. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavcodec/internal.h | 16 ++-- >> 1 file changed, 6 insertions(+), 10 deletions(-) >> >> diff --git a/libavcodec/internal.h b/libavcodec/internal.h >> index 60f65d3f2c..19c4e9e3f4 100644 >> --- a/libavcodec/internal.h >> +++ b/libavcodec/internal.h >> @@ -229,20 +229,16 @@ void ff_color_frame(AVFrame *frame, const int >> color[4]); >> #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - >> AV_INPUT_BUFFER_PADDING_SIZE) >> /** >> - * Check AVPacket size and/or allocate data. >> + * Check AVPacket size and allocate data. >> * >> * Encoders supporting AVCodec.encode2() can use this as a >> convenience to >> - * ensure the output packet data is large enough, whether provided by >> the user >> - * or allocated in this function. >> + * obtain a big enough buffer for the encoded bitstream. >> * >> * @param avctx the AVCodecContext of the encoder >> - * @param avpkt the AVPacket >> - * If avpkt->data is already set, avpkt->size is checked >> - * to ensure it is large enough. >> - * If avpkt->data is NULL, a new buffer is allocated. >> - * avpkt->size is set to the specified size. >> - * All other AVPacket fields will be reset with >> av_init_packet(). >> - * @param size the minimum required packet size >> + * @param avpkt The AVPacket: on success, avpkt->data will point to >> a buffer >> + * of size at least `size`; avpkt->buf may be `NULL`. > > May? You're no longer calling av_new_packet() in any scenario. IMO > better be explicit that the resulting packet will not be refcounted. > Changed "avpkt->buf may be `NULL`" to "the packet will not be refcounted". - Andreas >> + * This packet must be initially blank. >> + * @param size an upper bound of the size of the packet to encode >> * @param min_size This is a hint to the allocation algorithm, which >> indicates >> * to what minimal size the caller might later shrink >> the packet >> * to. Encoders often allocate packets which are >> larger than the > > LGTM otherwise. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 31/39] avcodec/encode: Always use intermediate buffer in ff_alloc_packet2()
Michael Niedermayer: > On Fri, May 21, 2021 at 11:17:34AM +0200, Andreas Rheinhardt wrote: >> Up until now, ff_alloc_packet2() has a min_size parameter: >> It is supposed to be a lower bound on the final size of the packet >> to allocate. If it is not too far from the upper bound (namely, >> if it is at least half the upper bound), then ff_alloc_packet2() >> already allocates the final, already refcounted packet; if it is >> not, then the packet is not refcounted and its data only points to >> a buffer owned by the AVCodecContext (in this case, the packet will >> be made refcounted in encode_simple_internal() in libavcodec/encode.c). >> The goal of this was to avoid data copies and intermediate buffers >> if one has a precise lower bound. >> >> Yet those encoders for which precise lower bounds exist have recently >> been switched to ff_get_encode_buffer() (which automatically allocates >> final buffers), leaving only two encoders to actually set the min_size >> to something else than zero (namely aliaspixenc and hapenc). Both of >> these encoders use a very low lower bound that is not helpful in any >> nontrivial case. >> >> This commit therefore removes the min_size parameter as well as the >> codepath in ff_alloc_packet2() for the allocation of final buffers. >> Furthermore, the function has been renamed to ff_alloc_packet() and >> moved to encode.h alongside ff_get_encode_buffer(). > > breaks: > > ./ffmpeg -f lavfi -i testsrc=size=5632x3168 -pix_fmt yuv420p -vframes 1 > -bitexact -vcodec ffv1 -y ffv-bigrgb-tocket6005.avi > > [ffv1 @ 0x559df8384f40] Cannot allocate worst case packet size, the encoding > could fail > [ffv1 @ 0x559df8384f40] Failed to allocate packet of size 2147483551 > Video encoding failed > Conversion failed! > This has been fixed by James in e44cb7363fed11b638f1cfc798d942bcf1e4db50 (thanks for this). So I'll apply the remainder of this patchset tomorrow unless there are further comments/objections. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec: Pass the HDR10+ metadata to the packet side data in VP9 encoder
HDR10+ metadata is stored in the bit stream for HEVC. The story is different for VP9 and cannot store the metadata in the bit stream. HDR10+ should be passed to packet side data an stored in the container (mkv) for VP9. This CL is taking HDR10+ from AVFrame side data in libvpxenc and is passing it to the AVPacket side data. --- doc/APIchanges | 2 + libavcodec/avpacket.c | 1 + libavcodec/decode.c| 1 + libavcodec/libvpxenc.c | 94 ++ libavcodec/packet.h| 8 libavcodec/version.h | 4 +- 6 files changed, 108 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index c46f4d5304..60995579e5 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,8 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-05-25 - 8c88a66d3c - lavc 59.2.100 - packet.h + Add AV_PKT_DATA_DYNAMIC_HDR10_PLUS 2021-04-27 - cb3ac722f4 - lavc 59.0.100 - avcodec.h Constified AVCodecParserContext.parser. diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 7383d12d3e..800bee3489 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -289,6 +289,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type) case AV_PKT_DATA_ICC_PROFILE:return "ICC Profile"; case AV_PKT_DATA_DOVI_CONF: return "DOVI configuration record"; case AV_PKT_DATA_S12M_TIMECODE: return "SMPTE ST 12-1:2014 timecode"; +case AV_PKT_DATA_DYNAMIC_HDR10_PLUS: return "HDR10+ Dynamic Metadata (SMPTE 2094-40)"; } return NULL; } diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 75bc7ad98e..40f688e40c 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1488,6 +1488,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC }, { AV_PKT_DATA_ICC_PROFILE,AV_FRAME_DATA_ICC_PROFILE }, { AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE }, +{ AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS }, }; if (IS_EMPTY(pkt) && av_fifo_size(avctx->internal->pkt_props) >= sizeof(*pkt)) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 66bad444d0..8930f079ef 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -64,6 +64,11 @@ struct FrameListData { struct FrameListData *next; }; +typedef struct FrameHDR10Plus { +int64_t pts; +AVBufferRef *hdr10_plus; +} FrameHDR10Plus; + typedef struct VPxEncoderContext { AVClass *class; struct vpx_codec_ctx encoder; @@ -121,6 +126,8 @@ typedef struct VPxEncoderContext { int tune_content; int corpus_complexity; int tpl_model; +int discard_hdr10_plus; +AVFifoBuffer *hdr10_plus_fifo; /** * If the driver does not support ROI then warn the first time we * encounter a frame with ROI side data. @@ -316,6 +323,55 @@ static av_cold void free_frame_list(struct FrameListData *list) } } +static av_cold int add_hdr10_plus(AVFifoBuffer *fifo, struct FrameHDR10Plus *data) +{ +int err = av_fifo_grow(fifo, sizeof(*data)); +if (err < 0) +return err; +av_fifo_generic_write(fifo, data, sizeof(*data), NULL); +return 0; +} + +static av_cold void free_hdr10_plus(struct FrameHDR10Plus *p) +{ +if (!p) +return; +av_buffer_unref(&p->hdr10_plus); +av_free(p); +} + +static av_cold void free_hdr10_plus_fifo(AVFifoBuffer **fifo) +{ +FrameHDR10Plus *frame_hdr10_plus = NULL; +while (av_fifo_size(*fifo) >= sizeof(FrameHDR10Plus)) { +av_fifo_generic_read(*fifo, frame_hdr10_plus, sizeof(FrameHDR10Plus), NULL); +free_hdr10_plus(frame_hdr10_plus); +} +av_fifo_freep(fifo); +} + +static int copy_hdr10_plus_to_pkt(AVFifoBuffer *fifo, AVPacket *pkt) +{ +FrameHDR10Plus *frame_hdr10_plus; +uint8_t *data; +if (av_fifo_size(fifo) < 1) +return 0; + +av_fifo_generic_read(fifo, frame_hdr10_plus, sizeof(*frame_hdr10_plus), NULL); +if (!frame_hdr10_plus || !pkt || !frame_hdr10_plus->hdr10_plus || frame_hdr10_plus->pts != pkt->pts) +return 0; + +data = av_packet_new_side_data(pkt, AV_PKT_DATA_DYNAMIC_HDR10_PLUS, frame_hdr10_plus->hdr10_plus->size); +if (!data) { +free_hdr10_plus(frame_hdr10_plus); +return AVERROR(ENOMEM); +} +memcpy(data, frame_hdr10_plus->hdr10_plus->data, frame_hdr10_plus->hdr10_plus->size); +free_hdr10_plus(frame_hdr10_plus); + +return 0; +} + static av_cold int codecctl_int(AVCodecContext *avctx, enum vp8e_enc_control_id id, int val) { @@ -384,6 +440,7 @@ static av_cold int vpx_free(AVCodecContext *avctx) av_freep(&ctx->twopass_stats.buf); av_freep(&avctx->stats_out); free_frame_list(ctx->coded_frame_list); +free_hdr10_plus_fifo(&ctx->hd
Re: [FFmpeg-devel] [PATCH] avcodec: Pass the HDR10+ metadata to the packet side data in VP9 encoder
On Wed, Jun 2, 2021 at 1:31 PM James Zern wrote: > On Tue, Jun 1, 2021 at 6:47 PM Mohammad Izadi > wrote: > > [...] > > +static av_cold int add_hdr10_plus(AVFifoBuffer *fifo, struct > FrameHDR10Plus *data) > > +{ > > +int err = av_fifo_grow(fifo, sizeof(FrameHDR10Plus)); > > Prefer sizeof(var) for these to match the rest of the code. > Done. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: Pass the HDR10+ metadata to the packet side data in VP9 encoder
Mohammad Izadi: > HDR10+ metadata is stored in the bit stream for HEVC. The story is different > for VP9 and cannot store the metadata in the bit stream. HDR10+ should be > passed to packet side data an stored in the container (mkv) for VP9. > > This CL is taking HDR10+ from AVFrame side data in libvpxenc and is passing > it to the AVPacket side data. > --- > doc/APIchanges | 2 + > libavcodec/avpacket.c | 1 + > libavcodec/decode.c| 1 + > libavcodec/libvpxenc.c | 94 ++ > libavcodec/packet.h| 8 > libavcodec/version.h | 4 +- > 6 files changed, 108 insertions(+), 2 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index c46f4d5304..60995579e5 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -13,6 +13,8 @@ libavutil: 2021-04-27 > > > API changes, most recent first: > +2021-05-25 - 8c88a66d3c - lavc 59.2.100 - packet.h > + Add AV_PKT_DATA_DYNAMIC_HDR10_PLUS > > 2021-04-27 - cb3ac722f4 - lavc 59.0.100 - avcodec.h >Constified AVCodecParserContext.parser. > diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c > index 7383d12d3e..800bee3489 100644 > --- a/libavcodec/avpacket.c > +++ b/libavcodec/avpacket.c > @@ -289,6 +289,7 @@ const char *av_packet_side_data_name(enum > AVPacketSideDataType type) > case AV_PKT_DATA_ICC_PROFILE:return "ICC Profile"; > case AV_PKT_DATA_DOVI_CONF: return "DOVI configuration > record"; > case AV_PKT_DATA_S12M_TIMECODE: return "SMPTE ST 12-1:2014 > timecode"; > +case AV_PKT_DATA_DYNAMIC_HDR10_PLUS: return "HDR10+ Dynamic > Metadata (SMPTE 2094-40)"; > } > return NULL; > } > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > index 75bc7ad98e..40f688e40c 100644 > --- a/libavcodec/decode.c > +++ b/libavcodec/decode.c > @@ -1488,6 +1488,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, > AVFrame *frame) > { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC }, > { AV_PKT_DATA_ICC_PROFILE,AV_FRAME_DATA_ICC_PROFILE > }, > { AV_PKT_DATA_S12M_TIMECODE, > AV_FRAME_DATA_S12M_TIMECODE }, > +{ AV_PKT_DATA_DYNAMIC_HDR10_PLUS, > AV_FRAME_DATA_DYNAMIC_HDR_PLUS }, > }; > > if (IS_EMPTY(pkt) && av_fifo_size(avctx->internal->pkt_props) >= > sizeof(*pkt)) > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > index 66bad444d0..8930f079ef 100644 > --- a/libavcodec/libvpxenc.c > +++ b/libavcodec/libvpxenc.c > @@ -64,6 +64,11 @@ struct FrameListData { > struct FrameListData *next; > }; > > +typedef struct FrameHDR10Plus { > +int64_t pts; > +AVBufferRef *hdr10_plus; > +} FrameHDR10Plus; > + > typedef struct VPxEncoderContext { > AVClass *class; > struct vpx_codec_ctx encoder; > @@ -121,6 +126,8 @@ typedef struct VPxEncoderContext { > int tune_content; > int corpus_complexity; > int tpl_model; > +int discard_hdr10_plus; > +AVFifoBuffer *hdr10_plus_fifo; > /** > * If the driver does not support ROI then warn the first time we > * encounter a frame with ROI side data. > @@ -316,6 +323,55 @@ static av_cold void free_frame_list(struct FrameListData > *list) > } > } > > +static av_cold int add_hdr10_plus(AVFifoBuffer *fifo, struct FrameHDR10Plus > *data) > +{ > +int err = av_fifo_grow(fifo, sizeof(*data)); > +if (err < 0) > +return err; > +av_fifo_generic_write(fifo, data, sizeof(*data), NULL); > +return 0; > +} > + > +static av_cold void free_hdr10_plus(struct FrameHDR10Plus *p) > +{ > +if (!p) > +return; > +av_buffer_unref(&p->hdr10_plus); > +av_free(p); > +} > + > +static av_cold void free_hdr10_plus_fifo(AVFifoBuffer **fifo) > +{ > +FrameHDR10Plus *frame_hdr10_plus = NULL; > +while (av_fifo_size(*fifo) >= sizeof(FrameHDR10Plus)) { > +av_fifo_generic_read(*fifo, frame_hdr10_plus, > sizeof(FrameHDR10Plus), NULL); > +free_hdr10_plus(frame_hdr10_plus); > +} > +av_fifo_freep(fifo); > +} > + > +static int copy_hdr10_plus_to_pkt(AVFifoBuffer *fifo, AVPacket *pkt) > +{ > +FrameHDR10Plus *frame_hdr10_plus; > +uint8_t *data; > +if (av_fifo_size(fifo) < 1) > +return 0; > + > +av_fifo_generic_read(fifo, frame_hdr10_plus, sizeof(*frame_hdr10_plus), > NULL); > +if (!frame_hdr10_plus || !pkt || !frame_hdr10_plus->hdr10_plus || > frame_hdr10_plus->pts != pkt->pts) > +return 0; > + > +data = av_packet_new_side_data(pkt, AV_PKT_DATA_DYNAMIC_HDR10_PLUS, > frame_hdr10_plus->hdr10_plus->size); > +if (!data) { > +free_hdr10_plus(frame_hdr10_plus); > +return AVERROR(ENOMEM); > +} > +memcpy(data, frame_hdr10_plus->hdr10_plus->data, > frame_hdr10_plus->hdr10_plus->size); > +free_hdr10_plus(frame_hdr10_plus); > + > +return 0; > +} > + > static av_cold int codecctl_int(AVCodecCon
Re: [FFmpeg-devel] [PATCH]avfilter: add Intel IPP library based x86 optimized video scaling filter
Soft Works (12021-06-05): > And I agree to that disagreement. Also we shouldn't start acting as if > the nonfree category wouldn't exist at all and everything that would > fall into that category would suddenly no longer be acceptable. This is exactly what we should do. We should not have accepted code that links to non-free libraries in the first place. The only legitimate reason for the non-free option is for license incompatibilities between different Libre software licenses. > If there's an open source or native implementation available, this > should always receive precedence, but otherwise it's not a valid > argument IMO to reject based on some fictional future (= someday, > somebody might contribute a native implementation). The Libre software movement has achieved so much thanks to people who have rejected this kind of compromise. But now people are taking it for granted, and it loses ground to Open Source, where software giants get free work without giving anything in return beyond token contribution and quasi-proprietary code. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 0/4] avdevice/dshow: implement capabilities API
Anton Khirnov (12021-06-05): > Sorry to rain on your parade, but I don't think we should go ahead with > this before deciding what is to be done with libavdevice. The last > discussion about it died without being resolved, but the issues are > still present. So, now we have somebody who wants to work on libavdevice, who uses it for application development, and who tells us that its API is quite fine. That's enough to make a decision: libavdevice is generally fine as it is for the foreseeable future and we can go ahead discussing the merits of this code. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4] avformat/mpegtsenc: enable muxing of ARIB captions
From: zheng qian Writes a general ARIB stream identifier descriptor, as well as a data component descriptor which also includes a pre-defined additional_arib_caption_info structure. Signed-off-by: zheng qian --- libavformat/mpegtsenc.c | 48 + 1 file changed, 48 insertions(+) diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 04af6da2db..98dac17994 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -287,6 +287,50 @@ static void putbuf(uint8_t **q_ptr, const uint8_t *buf, size_t len) *q_ptr += len; } +static int put_arib_caption_descriptor(AVFormatContext *s, uint8_t **q_ptr, + AVCodecParameters *codecpar) +{ +uint8_t stream_identifier; +uint16_t data_component_id; +uint8_t *q = *q_ptr; + +switch (codecpar->profile) { +case FF_PROFILE_ARIB_PROFILE_A: +stream_identifier = 0x30; +data_component_id = 0x0008; +break; +case FF_PROFILE_ARIB_PROFILE_C: +stream_identifier = 0x87; +data_component_id = 0x0012; +break; +default: +av_log(s, AV_LOG_ERROR, + "Unset/unknown ARIB caption profile %d utilized!\n", + codecpar->profile); +return AVERROR_INVALIDDATA; +} + +// stream_identifier_descriptor +*q++ = 0x52; // descriptor_tag +*q++ = 1; // descriptor_length +*q++ = stream_identifier; // component_tag: stream_identifier + +// data_component_descriptor, defined in ARIB STD-B10, part 2, 6.2.20 +*q++ = 0xFD; // descriptor_tag: ARIB data coding type descriptor +*q++ = 3; // descriptor_length +put16(&q, data_component_id); // data_component_id +// additional_arib_caption_info: defined in ARIB STD-B24, fascicle 1, Part 3, 9.6.1 +// Here we utilize a pre-defined set of values defined in ARIB TR-B14, +// Fascicle 2, 4.2.8.5 for PMT usage, with the reserved bits in the middle +// set to 1 (as that is what every broadcaster seems to be doing in +// production). +*q++ = 0x3D; // DMF('0011'), Reserved('11'), Timing('01') + +*q_ptr = q; + +return 0; +} + static void put_registration_descriptor(uint8_t **q_ptr, uint32_t tag) { uint8_t *q = *q_ptr; @@ -369,6 +413,7 @@ static int get_dvb_stream_type(AVFormatContext *s, AVStream *st) break; case AV_CODEC_ID_DVB_SUBTITLE: case AV_CODEC_ID_DVB_TELETEXT: +case AV_CODEC_ID_ARIB_CAPTION: stream_type = STREAM_TYPE_PRIVATE_DATA; break; case AV_CODEC_ID_SMPTE_KLV: @@ -726,6 +771,9 @@ static int mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) } *len_ptr = q - len_ptr - 1; +} else if (codec_id == AV_CODEC_ID_ARIB_CAPTION) { +if (put_arib_caption_descriptor(s, &q, st->codecpar) < 0) +break; } break; case AVMEDIA_TYPE_VIDEO: -- 2.31.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: Pass the HDR10+ metadata to the packet side data in VP9 encoder
On Wed, Jun 2, 2021 at 1:34 PM James Zern wrote: > On Tue, Jun 1, 2021 at 6:23 PM Mohammad Izadi > wrote: > > > > On Fri, May 28, 2021 at 4:49 AM Michael Niedermayer > > > wrote: > > > > > On Thu, May 27, 2021 at 09:44:10AM -0700, Mohammad Izadi wrote: > > > > HDR10+ metadata is stored in the bit stream for HEVC. The story is > > > different for VP9 and cannot store the metadata in the bit stream. > HDR10+ > > > should be passed to packet side data an stored in the container (mkv) > for > > > VP9. > > > > > > > > This CL is taking HDR10+ from AVFrame side data in libvpxenc and is > > > passing it to the AVPacket side data. > > > > --- > > > > doc/APIchanges | 2 + > > > > libavcodec/avpacket.c | 1 + > > > > libavcodec/decode.c| 1 + > > > > libavcodec/libvpxenc.c | 92 > ++ > > > > libavcodec/packet.h| 8 > > > > libavcodec/version.h | 2 +- > > > > 6 files changed, 105 insertions(+), 1 deletion(-) > > > [...] > > > > @@ -316,6 +323,53 @@ static av_cold void free_frame_list(struct > > > FrameListData *list) > > > > } > > > > } > > > > > > > > +static av_cold int add_hdr10_plus(AVFifoBuffer *fifo, struct > > > FrameHDR10Plus *data) > > > > +{ > > > > +int err = av_fifo_grow(fifo, sizeof(FrameHDR10Plus)); > > > > +if (err < 0) > > > > +return err; > > > > +av_fifo_generic_write(fifo, data, sizeof(FrameHDR10Plus), NULL); > > > > +return 0; > > > > +} > > > > + > > > > +static av_cold void free_hdr10_plus(struct FrameHDR10Plus *p) > > > > +{ > > > > +if (!p) > > > > +return; > > > > +av_buffer_unref(&p->hdr10_plus); > > > > +av_free(p); > > > > +} > > > > + > > > > +static av_cold void free_hdr10_plus_fifo(AVFifoBuffer **fifo) > > > > +{ > > > > +FrameHDR10Plus *frame_hdr10_plus = NULL; > > > > +while (av_fifo_generic_read(*fifo, frame_hdr10_plus, > > > sizeof(*frame_hdr10_plus), NULL) > 0) > > > > +free_hdr10_plus(frame_hdr10_plus); > > > > +av_fifo_freep(fifo); > > > > +} > > > > > > This seems crashing > > > > > Fixed. Can you please verify it? > > > > Is there a way we could enable this kind of test in fate? Mohammad, do > you have any examples of content that could be used for testing? > Yes. I already added a test for H265 in this patch: https://patchwork.ffmpeg.org/project/ffmpeg/patch/20201123212933.3560940-1-iz...@google.com/ A video sample is attached in the patch as well. I will add a test in fate in my followup patches after handling the packet in mkv as would have access to output. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] avformat/mpegtsenc: enable muxing of ARIB captions
On Mon, Jun 7, 2021 at 8:09 PM Jan Ekström wrote: > > From: zheng qian > > Writes a general ARIB stream identifier descriptor, as well > as a data component descriptor which also includes a > pre-defined additional_arib_caption_info structure. > > Signed-off-by: zheng qian > --- For the record, I did and do think that counting and limiting the amount of ARIB caption streams per program would be technically more correct, but since: 1. In most cases you will only have a single stream in your input of a given profile (as multi-language subtitles are supposed to be handled in the same PID). 2. it seems like a pain as mpegtsenc does not have existing infrastructure for these sorts of checks as nothing else is limited in stream count per-program. I decided that utilizing the default identifier (0x30, 0x87) for all such streams is Good Enough for an initial implementation. For Profile A streams values are available until 0x37, but effectively only permitted for secondary renditions (multi-view etc). Profile C only permits a single identifier - 0x87. As changes compared to v3: 1. I have split the descriptor writing into its own function, as mpegts_write_pmt is already long enough. 2. Checked references and adjusted some comments as well as the commit message. Jan ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: Pass the HDR10+ metadata to the packet side data in VP9 encoder
On Mon, Jun 7, 2021 at 9:51 AM Andreas Rheinhardt < andreas.rheinha...@outlook.com> wrote: > Mohammad Izadi: > > HDR10+ metadata is stored in the bit stream for HEVC. The story is > different for VP9 and cannot store the metadata in the bit stream. HDR10+ > should be passed to packet side data an stored in the container (mkv) for > VP9. > > > > This CL is taking HDR10+ from AVFrame side data in libvpxenc and is > passing it to the AVPacket side data. > > --- > > doc/APIchanges | 2 + > > libavcodec/avpacket.c | 1 + > > libavcodec/decode.c| 1 + > > libavcodec/libvpxenc.c | 94 ++ > > libavcodec/packet.h| 8 > > libavcodec/version.h | 4 +- > > 6 files changed, 108 insertions(+), 2 deletions(-) > > > > diff --git a/doc/APIchanges b/doc/APIchanges > > index c46f4d5304..60995579e5 100644 > > --- a/doc/APIchanges > > +++ b/doc/APIchanges > > @@ -13,6 +13,8 @@ libavutil: 2021-04-27 > > > > > > API changes, most recent first: > > +2021-05-25 - 8c88a66d3c - lavc 59.2.100 - packet.h > > + Add AV_PKT_DATA_DYNAMIC_HDR10_PLUS > > > > 2021-04-27 - cb3ac722f4 - lavc 59.0.100 - avcodec.h > >Constified AVCodecParserContext.parser. > > diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c > > index 7383d12d3e..800bee3489 100644 > > --- a/libavcodec/avpacket.c > > +++ b/libavcodec/avpacket.c > > @@ -289,6 +289,7 @@ const char *av_packet_side_data_name(enum > AVPacketSideDataType type) > > case AV_PKT_DATA_ICC_PROFILE:return "ICC Profile"; > > case AV_PKT_DATA_DOVI_CONF: return "DOVI > configuration record"; > > case AV_PKT_DATA_S12M_TIMECODE: return "SMPTE ST > 12-1:2014 timecode"; > > +case AV_PKT_DATA_DYNAMIC_HDR10_PLUS: return "HDR10+ Dynamic > Metadata (SMPTE 2094-40)"; > > } > > return NULL; > > } > > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > > index 75bc7ad98e..40f688e40c 100644 > > --- a/libavcodec/decode.c > > +++ b/libavcodec/decode.c > > @@ -1488,6 +1488,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, > AVFrame *frame) > > { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC > }, > > { AV_PKT_DATA_ICC_PROFILE, > AV_FRAME_DATA_ICC_PROFILE }, > > { AV_PKT_DATA_S12M_TIMECODE, > AV_FRAME_DATA_S12M_TIMECODE }, > > +{ AV_PKT_DATA_DYNAMIC_HDR10_PLUS, > AV_FRAME_DATA_DYNAMIC_HDR_PLUS }, > > }; > > > > if (IS_EMPTY(pkt) && av_fifo_size(avctx->internal->pkt_props) >= > sizeof(*pkt)) > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > > index 66bad444d0..8930f079ef 100644 > > --- a/libavcodec/libvpxenc.c > > +++ b/libavcodec/libvpxenc.c > > @@ -64,6 +64,11 @@ struct FrameListData { > > struct FrameListData *next; > > }; > > > > +typedef struct FrameHDR10Plus { > > +int64_t pts; > > +AVBufferRef *hdr10_plus; > > +} FrameHDR10Plus; > > + > > typedef struct VPxEncoderContext { > > AVClass *class; > > struct vpx_codec_ctx encoder; > > @@ -121,6 +126,8 @@ typedef struct VPxEncoderContext { > > int tune_content; > > int corpus_complexity; > > int tpl_model; > > +int discard_hdr10_plus; > > +AVFifoBuffer *hdr10_plus_fifo; > > /** > > * If the driver does not support ROI then warn the first time we > > * encounter a frame with ROI side data. > > @@ -316,6 +323,55 @@ static av_cold void free_frame_list(struct > FrameListData *list) > > } > > } > > > > +static av_cold int add_hdr10_plus(AVFifoBuffer *fifo, struct > FrameHDR10Plus *data) > > +{ > > +int err = av_fifo_grow(fifo, sizeof(*data)); > > +if (err < 0) > > +return err; > > +av_fifo_generic_write(fifo, data, sizeof(*data), NULL); > > +return 0; > > +} > > + > > +static av_cold void free_hdr10_plus(struct FrameHDR10Plus *p) > > +{ > > +if (!p) > > +return; > > +av_buffer_unref(&p->hdr10_plus); > > +av_free(p); > > +} > > + > > +static av_cold void free_hdr10_plus_fifo(AVFifoBuffer **fifo) > > +{ > > +FrameHDR10Plus *frame_hdr10_plus = NULL; > > +while (av_fifo_size(*fifo) >= sizeof(FrameHDR10Plus)) { > > +av_fifo_generic_read(*fifo, frame_hdr10_plus, > sizeof(FrameHDR10Plus), NULL); > > +free_hdr10_plus(frame_hdr10_plus); > > +} > > +av_fifo_freep(fifo); > > +} > > + > > +static int copy_hdr10_plus_to_pkt(AVFifoBuffer *fifo, AVPacket *pkt) > > +{ > > +FrameHDR10Plus *frame_hdr10_plus; > > +uint8_t *data; > > +if (av_fifo_size(fifo) < 1) > > +return 0; > > + > > +av_fifo_generic_read(fifo, frame_hdr10_plus, > sizeof(*frame_hdr10_plus), NULL); > > +if (!frame_hdr10_plus || !pkt || !frame_hdr10_plus->hdr10_plus || > frame_hdr10_plus->pts != pkt->pts) > > +return 0; > > + > > +data = av_packet_new_side_data(pkt, AV_PKT_DATA_DYNAMIC_HDR10_PLUS, > frame_hdr10_plus->hdr10_plus->size); > > +if (!data) { > > +free_hdr10_plus(frame_h
[FFmpeg-devel] [PATCH] avcodec: Pass the HDR10+ metadata to the packet side data in VP9 encoder
HDR10+ metadata is stored in the bit stream for HEVC. The story is different for VP9 and cannot store the metadata in the bit stream. HDR10+ should be passed to packet side data an stored in the container (mkv) for VP9. This CL is taking HDR10+ from AVFrame side data in libvpxenc and is passing it to the AVPacket side data. --- doc/APIchanges | 2 + libavcodec/avpacket.c | 1 + libavcodec/decode.c| 1 + libavcodec/libvpxenc.c | 98 ++ libavcodec/packet.h| 8 libavcodec/version.h | 4 +- 6 files changed, 112 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index c46f4d5304..60995579e5 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,8 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-05-25 - 8c88a66d3c - lavc 59.2.100 - packet.h + Add AV_PKT_DATA_DYNAMIC_HDR10_PLUS 2021-04-27 - cb3ac722f4 - lavc 59.0.100 - avcodec.h Constified AVCodecParserContext.parser. diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c index 7383d12d3e..800bee3489 100644 --- a/libavcodec/avpacket.c +++ b/libavcodec/avpacket.c @@ -289,6 +289,7 @@ const char *av_packet_side_data_name(enum AVPacketSideDataType type) case AV_PKT_DATA_ICC_PROFILE:return "ICC Profile"; case AV_PKT_DATA_DOVI_CONF: return "DOVI configuration record"; case AV_PKT_DATA_S12M_TIMECODE: return "SMPTE ST 12-1:2014 timecode"; +case AV_PKT_DATA_DYNAMIC_HDR10_PLUS: return "HDR10+ Dynamic Metadata (SMPTE 2094-40)"; } return NULL; } diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 75bc7ad98e..40f688e40c 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1488,6 +1488,7 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC }, { AV_PKT_DATA_ICC_PROFILE,AV_FRAME_DATA_ICC_PROFILE }, { AV_PKT_DATA_S12M_TIMECODE, AV_FRAME_DATA_S12M_TIMECODE }, +{ AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS }, }; if (IS_EMPTY(pkt) && av_fifo_size(avctx->internal->pkt_props) >= sizeof(*pkt)) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 66bad444d0..cf7e25a4bc 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -64,6 +64,11 @@ struct FrameListData { struct FrameListData *next; }; +typedef struct FrameHDR10Plus { +int64_t pts; +AVBufferRef *hdr10_plus; +} FrameHDR10Plus; + typedef struct VPxEncoderContext { AVClass *class; struct vpx_codec_ctx encoder; @@ -121,6 +126,8 @@ typedef struct VPxEncoderContext { int tune_content; int corpus_complexity; int tpl_model; +int discard_hdr10_plus; +AVFifoBuffer *hdr10_plus_fifo; /** * If the driver does not support ROI then warn the first time we * encounter a frame with ROI side data. @@ -316,6 +323,55 @@ static av_cold void free_frame_list(struct FrameListData *list) } } +static av_cold int add_hdr10_plus(AVFifoBuffer *fifo, struct FrameHDR10Plus *data) +{ +int err = av_fifo_grow(fifo, sizeof(*data)); +if (err < 0) +return err; +av_fifo_generic_write(fifo, data, sizeof(*data), NULL); +return 0; +} + +static av_cold void free_hdr10_plus(struct FrameHDR10Plus *p) +{ +if (!p) +return; +av_buffer_unref(&p->hdr10_plus); +av_free(p); +} + +static av_cold void free_hdr10_plus_fifo(AVFifoBuffer **fifo) +{ +FrameHDR10Plus *frame_hdr10_plus = NULL; +while (av_fifo_size(*fifo) >= sizeof(FrameHDR10Plus)) { +av_fifo_generic_read(*fifo, frame_hdr10_plus, sizeof(FrameHDR10Plus), NULL); +free_hdr10_plus(frame_hdr10_plus); +} +av_fifo_freep(fifo); +} + +static int copy_hdr10_plus_to_pkt(AVFifoBuffer *fifo, AVPacket *pkt) +{ +FrameHDR10Plus *frame_hdr10_plus; +uint8_t *data; +if (av_fifo_size(fifo) < 1) +return 0; + +av_fifo_generic_read(fifo, frame_hdr10_plus, sizeof(*frame_hdr10_plus), NULL); +if (!frame_hdr10_plus || !pkt || !frame_hdr10_plus->hdr10_plus || frame_hdr10_plus->pts != pkt->pts) +return 0; + +data = av_packet_new_side_data(pkt, AV_PKT_DATA_DYNAMIC_HDR10_PLUS, frame_hdr10_plus->hdr10_plus->size); +if (!data) { +free_hdr10_plus(frame_hdr10_plus); +return AVERROR(ENOMEM); +} +memcpy(data, frame_hdr10_plus->hdr10_plus->data, frame_hdr10_plus->hdr10_plus->size); +free_hdr10_plus(frame_hdr10_plus); + +return 0; +} + static av_cold int codecctl_int(AVCodecContext *avctx, enum vp8e_enc_control_id id, int val) { @@ -384,6 +440,7 @@ static av_cold int vpx_free(AVCodecContext *avctx) av_freep(&ctx->twopass_stats.buf); av_freep(&avctx->stats_out); free_frame_list(ctx->coded_frame_list); +free_hdr10_plus_fifo(&ctx->hd
Re: [FFmpeg-devel] [PATCH] fftools/ffplay: 240M matrix is not the same as BT.601
On Mon, 7 Jun 2021, Valerii Zapodovnikov wrote: Signed-off-by: Valerii Zapodovnikov --- fftools/ffplay.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 0be1d90bf9..53bd9362fa 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -963,12 +963,12 @@ static void set_sdl_yuv_conversion_mode(AVFrame *frame) if (frame && (frame->format == AV_PIX_FMT_YUV420P || frame->format == AV_PIX_FMT_YUYV422 || frame->format == AV_PIX_FMT_UYVY422)) { if (frame->color_range == AVCOL_RANGE_JPEG) mode = SDL_YUV_CONVERSION_JPEG; -else if (frame->colorspace == AVCOL_SPC_BT709) +else if (frame->colorspace == AVCOL_SPC_BT709) /* FIXME: sometimes it selects this even for BT.601 matrix, see issue 8862 */ I still dont understand, what can be fixed in ffplay and how. This FIXME helps very little regarding what needs to be done, what is missing and when. Either remove it or make it more exact. Thanks, Marton mode = SDL_YUV_CONVERSION_BT709; -else if (frame->colorspace == AVCOL_SPC_BT470BG || frame->colorspace == AVCOL_SPC_SMPTE170M || frame->colorspace == AVCOL_SPC_SMPTE240M) +else if (frame->colorspace == AVCOL_SPC_BT470BG || frame->colorspace == AVCOL_SPC_SMPTE170M) mode = SDL_YUV_CONVERSION_BT601; } -SDL_SetYUVConversionMode(mode); +SDL_SetYUVConversionMode(mode); /* FIXME: no support for linear transfer */ #endif } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: Pass the HDR10+ metadata to the packet side data in VP9 encoder
On Mon, Jun 07, 2021 at 10:39:19AM -0700, Mohammad Izadi wrote: > HDR10+ metadata is stored in the bit stream for HEVC. The story is different > for VP9 and cannot store the metadata in the bit stream. HDR10+ should be > passed to packet side data an stored in the container (mkv) for VP9. > > This CL is taking HDR10+ from AVFrame side data in libvpxenc and is passing > it to the AVPacket side data. > --- > doc/APIchanges | 2 + > libavcodec/avpacket.c | 1 + > libavcodec/decode.c| 1 + > libavcodec/libvpxenc.c | 98 ++ > libavcodec/packet.h| 8 > libavcodec/version.h | 4 +- > 6 files changed, 112 insertions(+), 2 deletions(-) still crashing ... heres a test with a fate sample: -i ~/fate/msmpeg4v1/mpg4.avi -vcodec libvpx -y vpx.webm frame= 50 fps=0.7 q=0.0 Lsize= 58kB time=00:00:01.63 bitrate= 288.0kbits/s speed=0.0229x video:57kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.558648% ==26333== Invalid read of size 4 ==26333==at 0x1220B5E: av_fifo_size (fifo.c:79) ==26333==by 0x9F64C5: free_hdr10_plus_fifo (libvpxenc.c:346) ==26333==by 0x9F699D: vpx_free (libvpxenc.c:443) ==26333==by 0x7A20D6: avcodec_close (avcodec.c:472) ==26333==by 0xAE5002: avcodec_free_context (options.c:163) ==26333==by 0x24AC0F: ffmpeg_cleanup (ffmpeg.c:609) ==26333==by 0x24258A: exit_program (cmdutils.c:135) ==26333==by 0x25C5AF: main (ffmpeg.c:5034) ==26333== Address 0x24 is not stack'd, malloc'd or (recently) free'd [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In fact, the RIAA has been known to suggest that students drop out of college or go to community college in order to be able to afford settlements. -- The RIAA signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec: Pass the HDR10+ metadata to the packet side data in VP9 encoder
Michael Niedermayer: > On Mon, Jun 07, 2021 at 10:39:19AM -0700, Mohammad Izadi wrote: >> HDR10+ metadata is stored in the bit stream for HEVC. The story is different >> for VP9 and cannot store the metadata in the bit stream. HDR10+ should be >> passed to packet side data an stored in the container (mkv) for VP9. >> >> This CL is taking HDR10+ from AVFrame side data in libvpxenc and is passing >> it to the AVPacket side data. >> --- >> doc/APIchanges | 2 + >> libavcodec/avpacket.c | 1 + >> libavcodec/decode.c| 1 + >> libavcodec/libvpxenc.c | 98 ++ >> libavcodec/packet.h| 8 >> libavcodec/version.h | 4 +- >> 6 files changed, 112 insertions(+), 2 deletions(-) > > still crashing ... > > heres a test with a fate sample: > > -i ~/fate/msmpeg4v1/mpg4.avi -vcodec libvpx -y vpx.webm > > > frame= 50 fps=0.7 q=0.0 Lsize= 58kB time=00:00:01.63 bitrate= > 288.0kbits/s speed=0.0229x > video:57kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing > overhead: 1.558648% > ==26333== Invalid read of size 4 > ==26333==at 0x1220B5E: av_fifo_size (fifo.c:79) > ==26333==by 0x9F64C5: free_hdr10_plus_fifo (libvpxenc.c:346) > ==26333==by 0x9F699D: vpx_free (libvpxenc.c:443) > ==26333==by 0x7A20D6: avcodec_close (avcodec.c:472) > ==26333==by 0xAE5002: avcodec_free_context (options.c:163) > ==26333==by 0x24AC0F: ffmpeg_cleanup (ffmpeg.c:609) > ==26333==by 0x24258A: exit_program (cmdutils.c:135) > ==26333==by 0x25C5AF: main (ffmpeg.c:5034) > ==26333== Address 0x24 is not stack'd, malloc'd or (recently) free'd > > The reason is that the fifo is not allocated unconditionally, but when freeing it is checked whether the fifo is empty even when the fifo has never been allocated at all. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] libavcodec: r12b decoder
Thanks for the review Andreas! I've addressed all your concerns besides the "& in the define", I didn't know that the binary AND is implicit in this situation, any link for this? Even if it is, I just find it much more pleasing to see the & there somehow, is there some leniency for personal preference? Revised patch attached. Kind regards, Dennis Fleurbaaij On Mon, Jun 7, 2021 at 12:59 PM Andreas Rheinhardt < andreas.rheinha...@outlook.com> wrote: > Dennis Fleurbaaij: > > Pulled master and re-applied to resolve version update conflict > > > > Kind regards, > > Dennis Fleurbaaij > > > > > > > > +if (avctx->width % PIXELS_PER_BLOCK != 0) { > > +av_log(avctx, AV_LOG_ERROR, "image width not modulo 8\n"); > > +return AVERROR_INVALIDDATA; > > +} > > + > > +AVFrame *pic = data; > > +pic->pict_type = AV_PICTURE_TYPE_I; > > +pic->key_frame = 1; > > + > > This (and other declarations below) should give statement-before > declaration warnings (FFmpeg still uses the C90 convention that all > declarations have to be at the top of each block. > > > +const uint8_t* src = (const uint8_t *)avpkt->data; > > Unnecessary cast (adding const is safe and doesn't need a cast). > > > > > +#define GET_F0(word, byte) ((GET_FF(word, byte) & 0xF0) >> > 4) > > The & is unnecessary, but the compiler will probably figure this out on > its own. > > > > > +#if CONFIG_R12B_DECODER > > +const AVCodec ff_r12b_decoder = { > > +.name = "r12b", > > +.long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 12-bit 8px > in 36B"), > > +.type = AVMEDIA_TYPE_VIDEO, > > +.id = AV_CODEC_ID_R12B, > > +.init = decode_init, > > +.decode = decode_frame, > > +.capabilities = AV_CODEC_CAP_DR1, > > +.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, > > +}; > > +#endif > > The #if is unnecessary as r12bdec.c will only get compiled if > CONFIG_R12B_DECODER is true. > > - Andreas > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > From 34f967772e3c8378ac3dd1f55a293e478dcc919c Mon Sep 17 00:00:00 2001 From: Dennis Fleurbaaij Date: Mon, 7 Jun 2021 21:53:42 +0200 Subject: [PATCH] libavcodec: r12b decoder added R12B is a format used by BlackMagic DeckLink cards, it is a big-endian 12bpp RGB format which packs 8 pixels into 36 bytes. Signed-off-by: Dennis Fleurbaaij --- Changelog | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/codec_desc.c | 7 ++ libavcodec/codec_id.h | 1 + libavcodec/r12bdec.c| 139 libavcodec/version.h| 4 +- libavformat/riff.c | 1 + 8 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 libavcodec/r12bdec.c diff --git a/Changelog b/Changelog index b9d5188cf6..d0717072eb 100644 --- a/Changelog +++ b/Changelog @@ -7,6 +7,7 @@ version : - ADPCM IMA Acorn Replay decoder - Argonaut Games CVG demuxer - Argonaut Games CVG muxer +- r12b decoder version 4.4: diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 4fa8d7ab10..cfef9d57ff 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -575,6 +575,7 @@ OBJS-$(CONFIG_QTRLE_ENCODER) += qtrleenc.o OBJS-$(CONFIG_R10K_DECODER)+= r210dec.o OBJS-$(CONFIG_R10K_ENCODER)+= r210enc.o OBJS-$(CONFIG_R210_DECODER)+= r210dec.o +OBJS-$(CONFIG_R12B_DECODER)+= r12bdec.o OBJS-$(CONFIG_R210_ENCODER)+= r210enc.o OBJS-$(CONFIG_RA_144_DECODER) += ra144dec.o ra144.o celp_filters.o OBJS-$(CONFIG_RA_144_ENCODER) += ra144enc.o ra144.o celp_filters.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 623db2a9fa..8db7e730a6 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -266,6 +266,7 @@ extern const AVCodec ff_qtrle_encoder; extern const AVCodec ff_qtrle_decoder; extern const AVCodec ff_r10k_encoder; extern const AVCodec ff_r10k_decoder; +extern const AVCodec ff_r12b_decoder; extern const AVCodec ff_r210_encoder; extern const AVCodec ff_r210_decoder; extern const AVCodec ff_rasc_decoder; diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 35527dcc37..ef58d73576 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -1856,6 +1856,13 @@ static const AVCodecDescriptor codec_descriptors[] = { .long_name = NULL_IF_CONFIG_SMALL("Digital Pictures SGA Video"), .props = AV_CODEC_PROP_LOSSY, }, +{ +.id= AV_CODEC_ID_R12B, +.type = AVMEDIA_TYPE_VIDEO, +.name = "r12b", +.long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 12-bit 8px in 36B"), +.props = AV_CODEC_PROP_INTRA_ONLY | AV
Re: [FFmpeg-devel] libavcodec: r12b decoder
Dennis Fleurbaaij: > Thanks for the review Andreas! > > I've addressed all your concerns besides the "& in the define", I didn't > know that the binary AND is implicit in this situation, any link for this? > Even if it is, I just find it much more pleasing to see the & there > somehow, is there some leniency for personal preference? > The lower nibble doesn't survive the right shift; and given that GET_FF() returns an uint8_t, there are no bits higher than 0xFF anyway. I have no objection to keeping the "&". > > +for (h = 0; h < avctx->height; h++) { > +g_dst = (uint16_t *)g_line; > +b_dst = (uint16_t *)b_line; > +r_dst = (uint16_t *)r_line; > + C90 disallows declarations in the middle of blocks, but it allows them at the beginning of *any* block, not only the outermost block of a function. You can declare these variables here. And we also allow for loops with variable declarations, i.e. you may declare h (and w later) via "for (int h = 0;". (This is illegal in C90.) Your code currently does not check the size of the input packet: It needs to be at least height * width / PIXELS_PER_BLOCK * BYTES_PER_BLOCK, but it doesn't check that (and I guess that too big packets are also invalid?). - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fftools/ffplay: 240M matrix is not the same as BT.601
I cannot clarify it further, the issue is there on trac. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]avfilter: add Intel IPP library based x86 optimized video scaling filter
> -Original Message- > From: ffmpeg-devel On Behalf Of > Nicolas George > Sent: Monday, June 7, 2021 6:57 PM > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH]avfilter: add Intel IPP library based x86 > optimized video scaling filter > > Soft Works (12021-06-05): > > And I agree to that disagreement. Also we shouldn't start acting as if > > the nonfree category wouldn't exist at all and everything that would > > fall into that category would suddenly no longer be acceptable. > > This is exactly what we should do. We should not have accepted code that > links to non-free libraries in the first place. While I respect and even understand your opinion, I don't share it. When there's a way to achieve so much better results, then I'd want to use it, just like hardware accelerations that are not always open source either. Surely, it makes sense to decide on a case-by-case basis. Though, just blindly rejecting everything that isn't completely open, might cause some significant(!) fork to emerge that covers all these things, which gladly hasn't happened yet. > > If there's an open source or native implementation available, this > > should always receive precedence, but otherwise it's not a valid > > argument IMO to reject based on some fictional future (= someday, > > somebody might contribute a native implementation). > > The Libre software movement has achieved so much thanks to people who > have rejected this kind of compromise. But now people are taking it for > granted, and it loses ground to Open Source, where software giants get free > work without giving anything in return beyond token contribution and quasi- > proprietary code. I don't think you could say that about Intel. They have open-sourced a huge amount of code in the recent years, they have more than a dozen developers that are making contributions to ffmpeg, so what you are saying may apply to others but not in this case. IPP is huge and exists for a long time. It has formerly been a commercial product, and now it's free, hopefully open-sourced at some time - I'd second that. What makes this a special case, is that IPP includes functions, each with many implementations, optimized for individual CPU models. This is something that a single or few open source developers couldn't easily replicate in a reasonable amount of time, at least not in the same detail and distinction between models, simply because nobody has access to that wide range of models to verify all these implementation on each model. Plus, there's has surely been a flow of internal knowledge into those implementations. Nothing is impossible, but in this case I think that it's just not realistic to expect that this could ever be paralleled by another implementation. That's why I'm all for including this. softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] checkasm/vp9dsp: rename the iszero function to is_zero
Hi, On Sun, Jun 6, 2021 at 10:42 PM James Almer wrote: > From: Matthieu Patou > > The function name iszero() may collide with a function in glibc. > > Suggested-by: ffm...@fb.com > Signed-off-by: James Almer > --- > tests/checkasm/vp9dsp.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/tests/checkasm/vp9dsp.c b/tests/checkasm/vp9dsp.c > index 99c023899f..44b02d60a2 100644 > --- a/tests/checkasm/vp9dsp.c > +++ b/tests/checkasm/vp9dsp.c > @@ -294,7 +294,7 @@ static int copy_subcoefs(int16_t *out, const int16_t > *in, enum TxfmMode tx, > return eob; > } > > -static int iszero(const int16_t *c, int sz) > +static int is_zero(const int16_t *c, int sz) > { > int n; > > @@ -362,8 +362,8 @@ static void check_itxfm(void) > call_ref(dst0, sz * SIZEOF_PIXEL, subcoef0, eob); > call_new(dst1, sz * SIZEOF_PIXEL, subcoef1, eob); > if (memcmp(dst0, dst1, sz * sz * SIZEOF_PIXEL) || > -!iszero(subcoef0, sz * sz * SIZEOF_COEF) || > -!iszero(subcoef1, sz * sz * SIZEOF_COEF)) > +!is_zero(subcoef0, sz * sz * SIZEOF_COEF) || > +!is_zero(subcoef1, sz * sz * SIZEOF_COEF)) > fail(); > > bench_new(dst, sz * SIZEOF_PIXEL, coef, eob); > -- > 2.31.1 > LGTM. Ronald ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fftools/ffplay: 240M matrix is not the same as BT.601
On Mon, 7 Jun 2021, Valerii Zapodovnikov wrote: I cannot clarify it further, the issue is there on trac. And that ticket is bogus, because comparison is made between 4:2:0 and 4:4:4. And when the reporter says the colors are muddy, he means the pixel format diffrerence, not the color space difference. So there is nothing to fix regarding the color space, because that is OK, and the different tone of green around the edges are only because of the 4:2:0, not because the wrong colorspace is used. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fftools/ffplay: 240M matrix is not the same as BT.601
You are **very** wrong. This is YCbCr 101: 420 has all the same colors as 444 does. Just if one pixel is fixated the entagled pixels have less than all possible colors. This is also not corners issues, it is reproducable on one color all over the plane. Again, the workaround is to use ffplay -vf scale=in_color_matrix=bt601,format=gbrp. Why you cannot try it? It is not THAT hard. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]avfilter: add Intel IPP library based x86 optimized video scaling filter
On Mon, Jun 7, 2021 at 11:44 PM Soft Works wrote: > > -Original Message- > > From: ffmpeg-devel On Behalf Of > > Nicolas George > > Sent: Monday, June 7, 2021 6:57 PM > > To: FFmpeg development discussions and patches > de...@ffmpeg.org> > > Subject: Re: [FFmpeg-devel] [PATCH]avfilter: add Intel IPP library based x86 > > optimized video scaling filter > > > > Soft Works (12021-06-05): > > > And I agree to that disagreement. Also we shouldn't start acting as if > > > the nonfree category wouldn't exist at all and everything that would > > > fall into that category would suddenly no longer be acceptable. > > > > This is exactly what we should do. We should not have accepted code that > > links to non-free libraries in the first place. > > While I respect and even understand your opinion, I don't share it. When > there's a way to achieve so much better results, then I'd want to use it, > just like hardware accelerations that are not always open source either. > Surely, it makes sense to decide on a case-by-case basis. > Though, just blindly rejecting everything that isn't completely open, might > cause some significant(!) fork to emerge that covers all these things, which > gladly hasn't happened yet. > If you just go without any rhetoric and just look at what "nonfree" (which IMHO is an awful name for the configuration option, it's just "non-distributable") We can start with the history of the option - originally added in 3fe142e2555ec8b527f2ff4cc517c015a114e91a (Jan, 2008) - to denote that due to the libamrnb/libamrwb wrappers being based on reference code, them being effectively not compatibly licensed even if someone was nice enough to make an open source wrapper around them. So it was all about open source, just licensing incompatibilities that were found out (just like some AAC library was later found to re-utilize reference code which was not under a friendly license). Then if we look at what the nonfree option is currently utilized for: capture card hardware integration (1): decklink open source that just happens to have incompatible licensing with regards to GPL (3): libfdk_aac openssl libtls (old) CUDA SDK things (3): cuda_nvcc cuda_sdk libnpp Thus looking at both historical point of that option, as well as its current uses, I don't see there's any reason to include a wrapper for a closed source scaling library that does not benefit the project (it re-implements already existing capability). For CPU based video scaling and color space conversions we already have: 1. swscale (which is problematic due to its early 2000s design, but recently got slice threading by Anton, so kudos to him) 2. zscale filter which is zimg-based (which also has intra picture threading if someone just cares to enable it in the filter) So I unfortunately disagree with adding this library wrapper for a closed source scaling/color space conversion library. > > > If there's an open source or native implementation available, this > > > should always receive precedence, but otherwise it's not a valid > > > argument IMO to reject based on some fictional future (= someday, > > > somebody might contribute a native implementation). > > > > The Libre software movement has achieved so much thanks to people who > > have rejected this kind of compromise. But now people are taking it for > > granted, and it loses ground to Open Source, where software giants get free > > work without giving anything in return beyond token contribution and quasi- > > proprietary code. > > I don't think you could say that about Intel. They have open-sourced a huge > amount of code in the recent years, they have more than a dozen developers > that are making contributions to ffmpeg, so what you are saying may apply to > others but not in this case. > IPP is huge and exists for a long time. It has formerly been a commercial > product, and now it's free, hopefully open-sourced at some time - I'd second > that. > > What makes this a special case, is that IPP includes functions, each with > many implementations, optimized for individual CPU models. This is something > that a single or few open source developers couldn't easily replicate in a > reasonable amount of time, at least not in the same detail and distinction > between models, simply because nobody has access to that wide range of models > to verify all these implementation on each model. Plus, there's has surely > been a flow of internal knowledge into those implementations. > > Nothing is impossible, but in this case I think that it's just not realistic > to expect that this could ever be paralleled by another implementation. > > That's why I'm all for including this. I don't disagree with swscale or zimg being not necessarily the best optimized (although to be honest, IMHO they are very much optimized on the general level), but instead of talking about this proprietary library as a mythical power-beast, maybe it would be more productive
Re: [FFmpeg-devel] [PATCH] fftools/ffplay: 240M matrix is not the same as BT.601
On Tue, 8 Jun 2021, Valerii Zapodovnikov wrote: You are **very** wrong. This is YCbCr 101: 420 has all the same colors as 444 does. Just if one pixel is fixated the entagled pixels have less than all possible colors. This is also not corners issues, it is reproducable on one color all over the plane. Then do reproduce with that and attach the sample having the same metadata (colorspace/primaries/transfer) to the ticket, with mpv and ffplay screenshots with the rendered output. I am asking this, because based on the tests I have made I still believe there is no color space issue, but feel free to prove me wrong. Thanks, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 17/35] avdevice/dshow: discover source color range/space/etc
Enabled discovering a DirectShow device's color range, space, primaries, transfer characteristics and chroma location, if the device exposes that information. Sets them in the stream's codecpars. Signed-off-by: Diederick Niehorster Co-authored-by: Valerii Zapodovnikov --- libavdevice/dshow.c | 231 +++- 1 file changed, 230 insertions(+), 1 deletion(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index d8a97797cc..6a7bac579a 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -29,6 +29,7 @@ #include "libavcodec/raw.h" #include "objidl.h" #include "shlwapi.h" +#include "dxva.h" static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount) @@ -54,6 +55,192 @@ static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount) return avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), biCompression); // all others } +static enum AVColorRange dshow_color_range(DXVA_ExtendedFormat* fmt_info) +{ +switch (fmt_info->NominalRange) +{ +case DXVA_NominalRange_Unknown: +return AVCOL_RANGE_UNSPECIFIED; +case DXVA_NominalRange_Normal: // equal to DXVA_NominalRange_0_255 +return AVCOL_RANGE_JPEG; +case DXVA_NominalRange_Wide:// equal to DXVA_NominalRange_16_235 +return AVCOL_RANGE_MPEG; +case DXVA_NominalRange_48_208: +// not an ffmpeg color range +return AVCOL_RANGE_UNSPECIFIED; + +// values from MediaFoundation SDK (mfobjects.h) +case 4: // MFNominalRange_64_127 +// not an ffmpeg color range +return AVCOL_RANGE_UNSPECIFIED; + +default: +return DXVA_NominalRange_Unknown; +} +} + +static enum AVColorSpace dshow_color_space(DXVA_ExtendedFormat* fmt_info) +{ +enum AVColorSpace ret = AVCOL_SPC_UNSPECIFIED; + +switch (fmt_info->VideoTransferMatrix) +{ +case DXVA_VideoTransferMatrix_BT709: +ret = AVCOL_SPC_BT709; +break; +case DXVA_VideoTransferMatrix_BT601: +ret = AVCOL_SPC_BT470BG; +break; +case DXVA_VideoTransferMatrix_SMPTE240M: +ret = AVCOL_SPC_SMPTE240M; +break; + +// values from MediaFoundation SDK (mfobjects.h) +case 4: // MFVideoTransferMatrix_BT2020_10 +case 5: // MFVideoTransferMatrix_BT2020_12 +if (fmt_info->VideoTransferFunction==12)// MFVideoTransFunc_2020_const +ret = AVCOL_SPC_BT2020_CL; +else +ret = AVCOL_SPC_BT2020_NCL; +break; +} + +if (ret == AVCOL_SPC_UNSPECIFIED) +{ +// if color space not known from transfer matrix, +// fall back to using primaries to guess color space +switch (fmt_info->VideoPrimaries) +{ +case DXVA_VideoPrimaries_BT709: +ret = AVCOL_SPC_BT709; +break; +case DXVA_VideoPrimaries_BT470_2_SysM: +ret = AVCOL_SPC_FCC; +break; +case DXVA_VideoPrimaries_BT470_2_SysBG: +case DXVA_VideoPrimaries_EBU3213: // this is PAL +ret = AVCOL_SPC_BT470BG; +break; +case DXVA_VideoPrimaries_SMPTE170M: +case DXVA_VideoPrimaries_SMPTE_C: +ret = AVCOL_SPC_SMPTE170M; +break; +case DXVA_VideoPrimaries_SMPTE240M: +ret = AVCOL_SPC_SMPTE240M; +break; +} +} + +return ret; +} + +static enum AVColorPrimaries dshow_color_primaries(DXVA_ExtendedFormat* fmt_info) +{ +switch (fmt_info->VideoPrimaries) +{ +case DXVA_VideoPrimaries_Unknown: +return AVCOL_PRI_UNSPECIFIED; +case DXVA_VideoPrimaries_reserved: +return AVCOL_PRI_RESERVED; +case DXVA_VideoPrimaries_BT709: +return AVCOL_PRI_BT709; +case DXVA_VideoPrimaries_BT470_2_SysM: +return AVCOL_PRI_BT470M; +case DXVA_VideoPrimaries_BT470_2_SysBG: +case DXVA_VideoPrimaries_EBU3213: // this is PAL +return AVCOL_PRI_BT470BG; +case DXVA_VideoPrimaries_SMPTE170M: +case DXVA_VideoPrimaries_SMPTE_C: +return AVCOL_PRI_SMPTE170M; +case DXVA_VideoPrimaries_SMPTE240M: +return AVCOL_PRI_SMPTE240M; + +// values from MediaFoundation SDK (mfobjects.h) +case 9: // MFVideoPrimaries_BT2020 +return AVCOL_PRI_BT2020; +case 10:// MFVideoPrimaries_XYZ +return AVCOL_PRI_SMPTE428; +case 11:// MFVideoPrimaries_DCI_P3 +return AVCOL_PRI_SMPTE431; +case 12:// MFVideoPrimaries_ACES (Academy Color Encoding System) +// not an FFmpeg color primary +return AVCOL_PRI_UNSPECIFIED; + +default: +return AVCOL_PRI_UNSPECIFIED; +} +} + +static enum AVColorTransferCharacteristic dshow_color_trc(DXVA_ExtendedFormat* fmt_info) +{ +switch (fmt_info->VideoTransferFunction) +{ +case DXVA_VideoTransFunc_Unknown: +return AVCOL_TRC_UNSPECIFIED; +case DXVA_VideoTransFunc_10: +return AVCOL_TRC_LINEAR; +case
[FFmpeg-devel] [PATCH 18/35] avdevice/dshow: select format with extended color info
Some DirectShow devices (Logitech C920 webcam) expose each DirectShow format they support twice, once without and once with extended color information. During format selection, both match, this patch ensures that the format with extended color information is selected if it is available, else it falls back to a matching format without such information. This also necessitated a new code path taken for default formats of a device (when user didn't request any specific video size, etc), because the default format may be one without extended color information when a twin with extended color information is also available. Getting the extended color information when available is important as it allows setting the color space, range, primaries, transfer characteristics and chroma location of the stream provided by dshow, enabling users to get more correct color automatically out of their device. Closes: #9271 Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 460 1 file changed, 332 insertions(+), 128 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 6a7bac579a..252db47351 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -23,6 +23,7 @@ #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavutil/opt.h" +#include "libavutil/mem.h" #include "libavformat/internal.h" #include "libavformat/riff.h" #include "avdevice.h" @@ -671,9 +672,111 @@ error: return ret; } +static int dshow_should_set_format(AVFormatContext* avctx, enum dshowDeviceType devtype) +{ +struct dshow_ctx* ctx = avctx->priv_data; + +return (devtype == VideoDevice && (ctx->framerate || + (ctx->requested_width && ctx->requested_height) || + ctx->pixel_format != AV_PIX_FMT_NONE || + ctx->video_codec_id != AV_CODEC_ID_RAWVIDEO)) +|| (devtype == AudioDevice && (ctx->channels || ctx->sample_size || ctx->sample_rate)); +} + + +struct dshow_format_info { +enum dshowDeviceType devtype; +// video +int64_t framerate; +enum AVPixelFormat pix_fmt; +enum AVCodecID codec_id; +enum AVColorRange col_range; +enum AVColorSpace col_space; +enum AVColorPrimaries col_prim; +enum AVColorTransferCharacteristic col_trc; +enum AVChromaLocation chroma_loc; +int width; +int height; +// audio +int sample_rate; +int sample_size; +int channels; +}; + +// user must av_free the returned pointer +static struct dshow_format_info* dshow_get_format_info(AM_MEDIA_TYPE* type) +{ +struct dshow_format_info *fmt_info = NULL; +BITMAPINFOHEADER *bih; +DXVA_ExtendedFormat *extended_format_info = NULL; +WAVEFORMATEX *fx; +enum dshowDeviceType devtype; +int64_t framerate; + +if (!type) +return NULL; + +if (IsEqualGUID(&type->formattype, &FORMAT_VideoInfo)) { +VIDEOINFOHEADER *v = (void *) type->pbFormat; +framerate = v->AvgTimePerFrame; +bih = &v->bmiHeader; +devtype = VideoDevice; +} else if (IsEqualGUID(&type->formattype, &FORMAT_VideoInfo2)) { +VIDEOINFOHEADER2 *v = (void *) type->pbFormat; +devtype = VideoDevice; +framerate = v->AvgTimePerFrame; +bih = &v->bmiHeader; +if (v->dwControlFlags & AMCONTROL_COLORINFO_PRESENT) +extended_format_info = (DXVA_ExtendedFormat *) &v->dwControlFlags; +} else if (IsEqualGUID(&type->formattype, &FORMAT_WaveFormatEx)) { +fx = (void *) type->pbFormat; +devtype = AudioDevice; +} else { +return NULL; +} + +fmt_info = av_mallocz(sizeof(struct dshow_format_info)); +if (!fmt_info) +return NULL; +// initialize fields where unset is not zero +fmt_info->pix_fmt = AV_PIX_FMT_NONE; +fmt_info->col_space = AVCOL_SPC_UNSPECIFIED; +fmt_info->col_prim = AVCOL_PRI_UNSPECIFIED; +fmt_info->col_trc = AVCOL_TRC_UNSPECIFIED; +// now get info about format +fmt_info->devtype = devtype; +if (devtype == VideoDevice) { +fmt_info->width = bih->biWidth; +fmt_info->height = bih->biHeight; +fmt_info->framerate = framerate; +fmt_info->pix_fmt = dshow_pixfmt(bih->biCompression, bih->biBitCount); +if (fmt_info->pix_fmt == AV_PIX_FMT_NONE) { +const AVCodecTag *const tags[] = { avformat_get_riff_video_tags(), NULL }; +fmt_info->codec_id = av_codec_get_id(tags, bih->biCompression); +} +else +fmt_info->codec_id = AV_CODEC_ID_RAWVIDEO; + +if (extended_format_info) { +fmt_info->col_range = dshow_color_range(extended_format_info); +fmt_info->col_space = dshow_color_space(extended_format_info); +fmt_info->col_prim = dshow_color_primaries(extended_format_info); +fmt_info->col_trc = dshow_color_trc
[FFmpeg-devel] [PATCH 19/35] avdevice/avdevice: Revert "Deprecate AVDevice Capabilities API"
This reverts commit 4f49ca7bbc75a9db4cdf93f27f95a668c751f160. This patch series will implement this capability for avdevice/dshow, enabling configuration discovery of DirectShow devices through the API, which is important for my use case. It enables making proper GUIs presenting users with options, instead of asking them to discover a dshow devices capabilities through the list_options option with an ffmpeg tool, and listing what they want to configure in text boxes. Signed-off-by: Diederick Niehorster --- libavdevice/avdevice.c | 71 ++ libavdevice/avdevice.h | 5 --- libavformat/avformat.h | 21 + libavformat/version.h | 2 +- 4 files changed, 87 insertions(+), 12 deletions(-) diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index e339cebf2d..695b9143af 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -27,11 +27,39 @@ #include "libavutil/ffversion.h" const char av_device_ffversion[] = "FFmpeg version " FFMPEG_VERSION; -#if FF_API_DEVICE_CAPABILITIES +#define E AV_OPT_FLAG_ENCODING_PARAM +#define D AV_OPT_FLAG_DECODING_PARAM +#define A AV_OPT_FLAG_AUDIO_PARAM +#define V AV_OPT_FLAG_VIDEO_PARAM +#define OFFSET(x) offsetof(AVDeviceCapabilitiesQuery, x) + const AVOption av_device_capabilities[] = { +{ "codec", "codec", OFFSET(codec), AV_OPT_TYPE_INT, +{.i64 = AV_CODEC_ID_NONE}, AV_CODEC_ID_NONE, INT_MAX, E|D|A|V }, +{ "sample_format", "sample format", OFFSET(sample_format), AV_OPT_TYPE_SAMPLE_FMT, +{.i64 = AV_SAMPLE_FMT_NONE}, AV_SAMPLE_FMT_NONE, INT_MAX, E|D|A }, +{ "sample_rate", "sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, +{.i64 = -1}, -1, INT_MAX, E|D|A }, +{ "channels", "channels", OFFSET(channels), AV_OPT_TYPE_INT, +{.i64 = -1}, -1, INT_MAX, E|D|A }, +{ "channel_layout", "channel layout", OFFSET(channel_layout), AV_OPT_TYPE_CHANNEL_LAYOUT, +{.i64 = -1}, -1, INT_MAX, E|D|A }, +{ "pixel_format", "pixel format", OFFSET(pixel_format), AV_OPT_TYPE_PIXEL_FMT, +{.i64 = AV_PIX_FMT_NONE}, AV_PIX_FMT_NONE, INT_MAX, E|D|V }, +{ "window_size", "window size", OFFSET(window_width), AV_OPT_TYPE_IMAGE_SIZE, +{.str = NULL}, -1, INT_MAX, E|D|V }, +{ "frame_size", "frame size", OFFSET(frame_width), AV_OPT_TYPE_IMAGE_SIZE, +{.str = NULL}, -1, INT_MAX, E|D|V }, +{ "fps", "fps", OFFSET(fps), AV_OPT_TYPE_RATIONAL, +{.dbl = -1}, -1, INT_MAX, E|D|V }, { NULL } }; -#endif + +#undef E +#undef D +#undef A +#undef V +#undef OFFSET unsigned avdevice_version(void) { @@ -68,18 +96,49 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA return s->control_message_cb(s, type, data, data_size); } -#if FF_API_DEVICE_CAPABILITIES int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s, AVDictionary **device_options) { -return AVERROR(ENOSYS); +int ret; +av_assert0(s && caps); +av_assert0(s->iformat || s->oformat); +if ((s->oformat && !s->oformat->create_device_capabilities) || +(s->iformat && !s->iformat->create_device_capabilities)) +return AVERROR(ENOSYS); +*caps = av_mallocz(sizeof(**caps)); +if (!(*caps)) +return AVERROR(ENOMEM); +(*caps)->device_context = s; +if (((ret = av_opt_set_dict(s->priv_data, device_options)) < 0)) +goto fail; +if (s->iformat) { +if ((ret = s->iformat->create_device_capabilities(s, *caps)) < 0) +goto fail; +} else { +if ((ret = s->oformat->create_device_capabilities(s, *caps)) < 0) +goto fail; +} +av_opt_set_defaults(*caps); +return 0; + fail: +av_freep(caps); +return ret; } void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s) { -return; +if (!s || !caps || !(*caps)) +return; +av_assert0(s->iformat || s->oformat); +if (s->iformat) { +if (s->iformat->free_device_capabilities) +s->iformat->free_device_capabilities(s, *caps); +} else { +if (s->oformat->free_device_capabilities) +s->oformat->free_device_capabilities(s, *caps); +} +av_freep(caps); } -#endif int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) { diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index 4fbdf6aabc..7c5e77df00 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -331,7 +331,6 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToAppMessageType type, void *data, size_t data_size); -#if FF_API_DEVICE_CAPABILITIES /** * Following API allows user to probe device capabilities (supported codecs, * pixel formats, sample formats, resolutions, channel counts, etc). @@ -427,7 +426,6 @@ typedef st
[FFmpeg-devel] [PATCH 20/35] avdevice/avdevice: clean up avdevice_capabilities_create
Draw implementation in line with that of avdevice_list_devices Signed-off-by: Diederick Niehorster --- libavdevice/avdevice.c | 9 ++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index 695b9143af..d73d36e1dd 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -100,12 +100,15 @@ int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatConte AVDictionary **device_options) { int ret; -av_assert0(s && caps); +av_assert0(s); +av_assert0(caps); av_assert0(s->iformat || s->oformat); if ((s->oformat && !s->oformat->create_device_capabilities) || -(s->iformat && !s->iformat->create_device_capabilities)) +(s->iformat && !s->iformat->create_device_capabilities)) { +*caps = NULL; return AVERROR(ENOSYS); -*caps = av_mallocz(sizeof(**caps)); +} +*caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); if (!(*caps)) return AVERROR(ENOMEM); (*caps)->device_context = s; -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 21/35] avdevice: capabilities API details no longer public
NB: will break build, makes needed corresponding changes to avformat. Signed-off-by: Diederick Niehorster --- libavdevice/avdevice.c | 34 -- libavdevice/avdevice.h | 42 +- libavdevice/internal.h | 33 + libavdevice/version.h | 2 +- 4 files changed, 63 insertions(+), 48 deletions(-) diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index d73d36e1dd..b521516ff5 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -96,51 +96,57 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA return s->control_message_cb(s, type, data, data_size); } -int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s, +int avdevice_capabilities_create(void** opaque, AVFormatContext *s, AVDictionary **device_options) { int ret; +AVDeviceCapabilitiesQuery *caps = NULL; av_assert0(s); -av_assert0(caps); +av_assert0(opaque); av_assert0(s->iformat || s->oformat); +*opaque = NULL; if ((s->oformat && !s->oformat->create_device_capabilities) || (s->iformat && !s->iformat->create_device_capabilities)) { -*caps = NULL; return AVERROR(ENOSYS); } -*caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); -if (!(*caps)) +*opaque = caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); +if (!caps) return AVERROR(ENOMEM); -(*caps)->device_context = s; +caps->device_context = s; if (((ret = av_opt_set_dict(s->priv_data, device_options)) < 0)) goto fail; if (s->iformat) { -if ((ret = s->iformat->create_device_capabilities(s, *caps)) < 0) +if ((ret = s->iformat->create_device_capabilities(s, caps)) < 0) goto fail; } else { -if ((ret = s->oformat->create_device_capabilities(s, *caps)) < 0) +if ((ret = s->oformat->create_device_capabilities(s, caps)) < 0) goto fail; } -av_opt_set_defaults(*caps); +av_opt_set_defaults(caps); return 0; fail: av_freep(caps); +*opaque = NULL; return ret; } -void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s) +void avdevice_capabilities_free(void **opaque, AVFormatContext *s) { -if (!s || !caps || !(*caps)) +AVDeviceCapabilitiesQuery *caps; +if (!s || !opaque) +return; +caps = *(AVDeviceCapabilitiesQuery **) opaque; +if (!caps) return; av_assert0(s->iformat || s->oformat); if (s->iformat) { if (s->iformat->free_device_capabilities) -s->iformat->free_device_capabilities(s, *caps); +s->iformat->free_device_capabilities(s, caps); } else { if (s->oformat->free_device_capabilities) -s->oformat->free_device_capabilities(s, *caps); +s->oformat->free_device_capabilities(s, caps); } -av_freep(caps); +av_freep(opaque); } int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index 7c5e77df00..389ac0b5f2 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -401,40 +401,15 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, * @endcode */ -/** - * Structure describes device capabilities. - * - * It is used by devices in conjunction with av_device_capabilities AVOption table - * to implement capabilities probing API based on AVOption API. Should not be used directly. - */ -typedef struct AVDeviceCapabilitiesQuery { -const AVClass *av_class; -AVFormatContext *device_context; -enum AVCodecID codec; -enum AVSampleFormat sample_format; -enum AVPixelFormat pixel_format; -int sample_rate; -int channels; -int64_t channel_layout; -int window_width; -int window_height; -int frame_width; -int frame_height; -AVRational fps; -} AVDeviceCapabilitiesQuery; - -/** - * AVOption table used by devices to implement device capabilities API. Should not be used by a user. - */ -extern const AVOption av_device_capabilities[]; - /** * Initialize capabilities probing API based on AVOption API. * * avdevice_capabilities_free() must be called when query capabilities API is * not used anymore. - * - * @param[out] caps Device capabilities data. Pointer to a NULL pointer must be passed. + * + * @param[out] opaqueA pointer where the capabilities API state will be stored. Pointer + * to a NULL pointer must be passed and caller must not touch this in + * any way. * @param s Context of the device. * @param device_options An AVDictionary filled with device-private options. * On return this parameter will be destroyed and replaced with a dict @@ -445,16 +420,17 @@ extern c
[FFmpeg-devel] [PATCH 22/35] avformat: avdevice capabilities API details no longer public
Signed-off-by: Diederick Niehorster --- libavformat/avformat.h | 9 - libavformat/version.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6fd09f52cb..12197465bc 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -319,7 +319,6 @@ struct AVFormatContext; struct AVDeviceInfoList; -struct AVDeviceCapabilitiesQuery; /** * @defgroup metadata_api Public Metadata API @@ -582,12 +581,12 @@ typedef struct AVOutputFormat { * Initialize device capabilities submodule. * @see avdevice_capabilities_create() for more details. */ -int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); +int (*create_device_capabilities)(struct AVFormatContext *s, void *opaque); /** * Free device capabilities submodule. * @see avdevice_capabilities_free() for more details. */ -int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); +int (*free_device_capabilities)(struct AVFormatContext *s, void *opaque); enum AVCodecID data_codec; /**< default data codec */ /** * Initialize format. May allocate data here, and set any AVFormatContext or @@ -763,13 +762,13 @@ typedef struct AVInputFormat { * Initialize device capabilities submodule. * @see avdevice_capabilities_create() for more details. */ -int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); +int (*create_device_capabilities)(struct AVFormatContext *s, void *opaque); /** * Free device capabilities submodule. * @see avdevice_capabilities_free() for more details. */ -int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); +int (*free_device_capabilities)(struct AVFormatContext *s, void *opaque); } AVInputFormat; /** * @} diff --git a/libavformat/version.h b/libavformat/version.h index 6519bba101..13df244d97 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 59 -#define LIBAVFORMAT_VERSION_MINOR 4 +#define LIBAVFORMAT_VERSION_MINOR 5 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 23/35] avformat: cosmetics
Signed-off-by: Diederick Niehorster --- libavformat/avformat.h | 9 + 1 file changed, 9 insertions(+) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 12197465bc..5e1e82a315 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -530,6 +530,7 @@ typedef struct AVOutputFormat { int priv_data_size; int (*write_header)(struct AVFormatContext *); + /** * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags, * pkt can be NULL in order to flush data buffered in the muxer. @@ -538,7 +539,9 @@ typedef struct AVOutputFormat { * data. */ int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); + int (*write_trailer)(struct AVFormatContext *); + /** * A format-specific function for interleavement. * If unset, packets will be interleaved by dts. @@ -577,17 +580,21 @@ typedef struct AVOutputFormat { * @see avdevice_list_devices() for more details. */ int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list); + /** * Initialize device capabilities submodule. * @see avdevice_capabilities_create() for more details. */ int (*create_device_capabilities)(struct AVFormatContext *s, void *opaque); + /** * Free device capabilities submodule. * @see avdevice_capabilities_free() for more details. */ int (*free_device_capabilities)(struct AVFormatContext *s, void *opaque); + enum AVCodecID data_codec; /**< default data codec */ + /** * Initialize format. May allocate data here, and set any AVFormatContext or * AVStream parameters that need to be set before packets are sent. @@ -598,6 +605,7 @@ typedef struct AVOutputFormat { * Any allocations made here must be freed in deinit(). */ int (*init)(struct AVFormatContext *); + /** * Deinitialize format. If present, this is called whenever the muxer is being * destroyed, regardless of whether or not the header has been written. @@ -607,6 +615,7 @@ typedef struct AVOutputFormat { * This is called if init() fails as well. */ void (*deinit)(struct AVFormatContext *); + /** * Set up any necessary bitstream filtering and extract any extra data needed * for the global header. -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 24/35] avutil/opt: AVOptionRange gains is_set field.
When querying a range of formats of an avdevice, sometimes for a given format the queried option is not available. This is not an error as the user is asking for a valid capability, it just doesn't always apply to all the matching formats of the device. This is now communicated through a special value (like 0 or -1), but that is a problem (like always with special values). The is_set field alleviates the use of special values. This will be used when implementing the avdevice capabilities API for avdevice/dshow in a later commit Signed-off-by: Diederick Niehorster --- libavutil/opt.c | 1 + libavutil/opt.h | 5 + libavutil/version.h | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index 4124efd9b6..ab127b30fa 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -1865,6 +1865,7 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch ranges->nb_ranges = 1; ranges->nb_components = 1; range->is_range = 1; +range->is_set = 1; range->value_min = field->min; range->value_max = field->max; diff --git a/libavutil/opt.h b/libavutil/opt.h index c2329e5589..ac0b4567a6 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -325,6 +325,11 @@ typedef struct AVOptionRange { * If set to 1 the struct encodes a range, if set to 0 a single value. */ int is_range; +/** + * Is set flag. + * If set to 1 the struct contains a value, if set to 0, the range is empty. + */ +int is_set; } AVOptionRange; /** diff --git a/libavutil/version.h b/libavutil/version.h index e11eaa20d0..34b83112de 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 0 +#define LIBAVUTIL_VERSION_MINOR 1 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 25/35] avutil/opt: add av_opt_to_string
This function allows formatting an option value stored in a double (such as the min and max fields of an AVOption, or min_value and max_value of an AVOptionRange) properly, e.g. 1 for a AV_OPT_TYPE_PIXEL_FMT -> yuyv422. Useful when printing more info about an option than just its value. Usage will be shown in upcoming device_get_capabilities example. av_opt_get (body changed) still passes FATE. Signed-off-by: Diederick Niehorster --- libavutil/opt.c | 93 + libavutil/opt.h | 12 +- libavutil/version.h | 2 +- 3 files changed, 89 insertions(+), 18 deletions(-) diff --git a/libavutil/opt.c b/libavutil/opt.c index ab127b30fa..3e385852eb 100644 --- a/libavutil/opt.c +++ b/libavutil/opt.c @@ -776,24 +776,14 @@ static void format_duration(char *buf, size_t size, int64_t d) *(--e) = 0; } -int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) +static int print_option(void* dst, enum AVOptionType type, int search_flags, uint8_t** out_val) { -void *dst, *target_obj; -const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); -uint8_t *bin, buf[128]; +uint8_t* bin, buf[128]; int len, i, ret; int64_t i64; -if (!o || !target_obj || (o->offset<=0 && o->type != AV_OPT_TYPE_CONST)) -return AVERROR_OPTION_NOT_FOUND; - -if (o->flags & AV_OPT_FLAG_DEPRECATED) -av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", name, o->help); - -dst = (uint8_t *)target_obj + o->offset; - buf[0] = 0; -switch (o->type) { +switch (type) { case AV_OPT_TYPE_BOOL: ret = snprintf(buf, sizeof(buf), "%s", (char *)av_x_if_null(get_bool_name(*(int *)dst), "invalid")); break; @@ -819,9 +809,6 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) case AV_OPT_TYPE_RATIONAL: ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational *)dst)->num, ((AVRational *)dst)->den); break; -case AV_OPT_TYPE_CONST: -ret = snprintf(buf, sizeof(buf), "%f", o->default_val.dbl); -break; case AV_OPT_TYPE_STRING: if (*(uint8_t **)dst) { *out_val = av_strdup(*(uint8_t **)dst); @@ -889,6 +876,80 @@ int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) return *out_val ? 0 : AVERROR(ENOMEM); } +int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) +{ +void *dst, *target_obj; +const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); +uint8_t buf[128]; +int ret; + +if (!o || !target_obj || (o->offset<=0 && o->type != AV_OPT_TYPE_CONST)) +return AVERROR_OPTION_NOT_FOUND; + +if (o->flags & AV_OPT_FLAG_DEPRECATED) +av_log(obj, AV_LOG_WARNING, "The \"%s\" option is deprecated: %s\n", name, o->help); + +dst = (uint8_t *)target_obj + o->offset; + + +if (o->type != AV_OPT_TYPE_CONST) +return print_option(dst, o->type, search_flags, out_val); + +// special case for a const +ret = snprintf(buf, sizeof(buf), "%f", o->default_val.dbl); +if (ret >= sizeof(buf)) +return AVERROR(EINVAL); +*out_val = av_strdup(buf); +return *out_val ? 0 : AVERROR(ENOMEM); +} +int av_opt_to_string(double val, enum AVOptionType type, uint8_t** out_val) +{ +*out_val = NULL; + +switch (type) { +case AV_OPT_TYPE_FLAGS: +case AV_OPT_TYPE_BOOL: +case AV_OPT_TYPE_INT: +case AV_OPT_TYPE_PIXEL_FMT: +case AV_OPT_TYPE_SAMPLE_FMT: +{ +int temp = lrint(val); +return print_option(&temp, type, 0, out_val); +} +case AV_OPT_TYPE_INT64: +case AV_OPT_TYPE_DURATION: +case AV_OPT_TYPE_CHANNEL_LAYOUT: +{ +int64_t temp = llrint(val); +return print_option(&temp, type, 0, out_val); +} +case AV_OPT_TYPE_UINT64: +{ +uint64_t temp = llrint(val); +return print_option(&temp, type, 0, out_val); +} +case AV_OPT_TYPE_FLOAT: +{ +float temp = (float)val; +return print_option(&temp, type, 0, out_val); +} +case AV_OPT_TYPE_DOUBLE: +return print_option(&val, type, 0, out_val); + +default: +// AV_OPT_TYPE_DICT, +// AV_OPT_TYPE_COLOR, +// AV_OPT_TYPE_BINARY, +// AV_OPT_TYPE_STRING, +// AV_OPT_TYPE_RATIONAL, +// AV_OPT_TYPE_IMAGE_SIZE, +// AV_OPT_TYPE_VIDEO_RATE, +// AV_OPT_TYPE_CONST +// cannot be stored in a single double, and are thus not a valid input +return AVERROR(EINVAL); +} +} + static int get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum, int search_flags) { diff --git a/libavutil/opt.h b/libavutil/opt.h index ac0b4567a6..bd386c411b 100644 --- a/libavutil/opt.h +++ b/libavutil/opt.h @@ -361,7 +361,7 @@ typedef struct AV
[FFmpeg-devel] [PATCH 26/35] avdevice: Add internal helpers for querying device capabilities
Signed-off-by: Diederick Niehorster --- libavdevice/internal.h | 31 +++ libavdevice/utils.c| 48 ++ libavdevice/version.h | 2 +- 3 files changed, 80 insertions(+), 1 deletion(-) diff --git a/libavdevice/internal.h b/libavdevice/internal.h index fe4be64ee7..10e1cdb80c 100644 --- a/libavdevice/internal.h +++ b/libavdevice/internal.h @@ -58,4 +58,35 @@ typedef struct AVDeviceCapabilitiesQuery { */ extern const AVOption av_device_capabilities[]; +/** + * Enumeration indicating which device capability is being queried. + */ +enum AVDeviceCapabilitiesQueryType { +AV_DEV_CAP_QUERY_NONE = 0, +// both audio and video +AV_DEV_CAP_QUERY_CODEC, +// audio +AV_DEV_CAP_QUERY_SAMPLE_FORMAT, +AV_DEV_CAP_QUERY_SAMPLE_RATE, +AV_DEV_CAP_QUERY_CHANNELS, +AV_DEV_CAP_QUERY_CHANNEL_LAYOUT, +// video +AV_DEV_CAP_QUERY_PIXEL_FORMAT, +AV_DEV_CAP_QUERY_WINDOW_SIZE, +AV_DEV_CAP_QUERY_FRAME_SIZE, +AV_DEV_CAP_QUERY_FPS +}; + +/** + * Find AVDeviceCapabilitiesQueryType enumeration by means of options name. + * Returns AV_DEV_CAP_QUERY_NONE if not found. + */ +enum AVDeviceCapabilitiesQueryType ff_device_get_query_type(const char* option_name); + +/** + * Get component name from AVDeviceCapabilitiesQueryType enumeration and component index. + * (Some options have multiple components, e.g. AV_DEV_CAP_QUERY_FRAME_SIZE). + */ +const char* ff_device_get_query_component_name(enum AVDeviceCapabilitiesQueryType query_type, int component); + #endif diff --git a/libavdevice/utils.c b/libavdevice/utils.c index d9a52c53ab..73fdc5766e 100644 --- a/libavdevice/utils.c +++ b/libavdevice/utils.c @@ -19,6 +19,7 @@ #include "internal.h" #include "libavutil/opt.h" #include "libavformat/avformat.h" +#include "libavutil/avassert.h" int ff_alloc_input_device_context(AVFormatContext **avctx, const AVInputFormat *iformat, const char *format) { @@ -57,3 +58,50 @@ int ff_alloc_input_device_context(AVFormatContext **avctx, const AVInputFormat * avformat_free_context(s); return ret; } + +typedef struct AVDeviceCapabilitiesQueryTypeEntry { +const char* name; +enum DshowCapQueryType query_type; +} AVDeviceCapabilitiesQueryTypeEntry; + +static const AVDeviceCapabilitiesQueryTypeEntry query_table[] = { +// both audio and video +{ "codec", AV_DEV_CAP_QUERY_CODEC }, +// audio +{ "sample_format", AV_DEV_CAP_QUERY_SAMPLE_FORMAT }, +{ "sample_rate",AV_DEV_CAP_QUERY_SAMPLE_RATE }, +{ "channels", AV_DEV_CAP_QUERY_CHANNELS }, +{ "channel_layout", AV_DEV_CAP_QUERY_CHANNEL_LAYOUT }, +// video +{ "pixel_format", AV_DEV_CAP_QUERY_PIXEL_FORMAT }, +{ "frame_size", AV_DEV_CAP_QUERY_FRAME_SIZE }, +{ "window_size",AV_DEV_CAP_QUERY_WINDOW_SIZE }, +{ "fps",AV_DEV_CAP_QUERY_FPS }, +}; + +enum AVDeviceCapabilitiesQueryType ff_device_get_query_type(const char* option_name) +{ +for (int i = 0; i < FF_ARRAY_ELEMS(query_table); ++i) { +if (!strcmp(query_table[i].name, option_name)) +return query_table[i].query_type; +} +// not found +return AV_DEV_CAP_QUERY_NONE; +} + +const char* ff_device_get_query_component_name(enum AVDeviceCapabilitiesQueryType query_type, int component) +{ +if (query_type == AV_DEV_CAP_QUERY_WINDOW_SIZE || query_type == AV_DEV_CAP_QUERY_FRAME_SIZE) { +// special case: different name for each component +return component == 0 ? "pixel_count" : (component == 1 ? "width" : (component == 2 ? "height" : "")); +} +else { +av_assert0(component == 0); +for (int i = 0; i < FF_ARRAY_ELEMS(query_table); ++i) { +if (query_table[i].query_type == query_type) +return query_table[i].name; +} +} +// not found +return NULL; +} \ No newline at end of file diff --git a/libavdevice/version.h b/libavdevice/version.h index 53af6fa0d0..e0361aebc1 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -29,7 +29,7 @@ #define LIBAVDEVICE_VERSION_MAJOR 59 #define LIBAVDEVICE_VERSION_MINOR 3 -#define LIBAVDEVICE_VERSION_MICRO 100 +#define LIBAVDEVICE_VERSION_MICRO 101 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ LIBAVDEVICE_VERSION_MINOR, \ -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 27/35] avdevice/dshow: move audio format helpers
Needs to be moved up in file for upcoming implementation of avdevice_capabilities_create. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 252db47351..004b4e6154 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -56,6 +56,26 @@ static enum AVPixelFormat dshow_pixfmt(DWORD biCompression, WORD biBitCount) return avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), biCompression); // all others } +static enum AVCodecID waveform_codec_id(enum AVSampleFormat sample_fmt) +{ +switch (sample_fmt) { +case AV_SAMPLE_FMT_U8: return AV_CODEC_ID_PCM_U8; +case AV_SAMPLE_FMT_S16: return AV_CODEC_ID_PCM_S16LE; +case AV_SAMPLE_FMT_S32: return AV_CODEC_ID_PCM_S32LE; +default:return AV_CODEC_ID_NONE; /* Should never happen. */ +} +} + +static enum AVSampleFormat sample_fmt_bits_per_sample(int bits) +{ +switch (bits) { +case 8: return AV_SAMPLE_FMT_U8; +case 16: return AV_SAMPLE_FMT_S16; +case 32: return AV_SAMPLE_FMT_S32; +default: return AV_SAMPLE_FMT_NONE; /* Should never happen. */ +} +} + static enum AVColorRange dshow_color_range(DXVA_ExtendedFormat* fmt_info) { switch (fmt_info->NominalRange) @@ -1610,26 +1630,6 @@ static int dshow_control_message(AVFormatContext *avctx, int type, void *data, s return 0; } -static enum AVCodecID waveform_codec_id(enum AVSampleFormat sample_fmt) -{ -switch (sample_fmt) { -case AV_SAMPLE_FMT_U8: return AV_CODEC_ID_PCM_U8; -case AV_SAMPLE_FMT_S16: return AV_CODEC_ID_PCM_S16LE; -case AV_SAMPLE_FMT_S32: return AV_CODEC_ID_PCM_S32LE; -default:return AV_CODEC_ID_NONE; /* Should never happen. */ -} -} - -static enum AVSampleFormat sample_fmt_bits_per_sample(int bits) -{ -switch (bits) { -case 8: return AV_SAMPLE_FMT_U8; -case 16: return AV_SAMPLE_FMT_S16; -case 32: return AV_SAMPLE_FMT_S32; -default: return AV_SAMPLE_FMT_NONE; /* Should never happen. */ -} -} - static int dshow_add_device(AVFormatContext *avctx, enum dshowDeviceType devtype) -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 28/35] avdevice/dshow: when closing, set context fields back to zero
After the avdevice capabilities API is implemented, the format context may be reused after querying device capabilities in a later avformat_open_input call. To enable this reuse, after releasing resources, make sure to also set the corresponding pointers back to NULL. This correctly indicates their state. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 17 + 1 file changed, 17 insertions(+) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 004b4e6154..40a492b787 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -272,14 +272,18 @@ dshow_read_close(AVFormatContext *s) ICaptureGraphBuilder2_Release(ctx->graph_builder2[VideoDevice]); if (ctx->graph_builder2[AudioDevice]) ICaptureGraphBuilder2_Release(ctx->graph_builder2[AudioDevice]); +ctx->graph_builder2[0] = NULL; +ctx->graph_builder2[1] = NULL; if (ctx->control) { IMediaControl_Stop(ctx->control); IMediaControl_Release(ctx->control); } +ctx->control = NULL; if (ctx->media_event) IMediaEvent_Release(ctx->media_event); +ctx->media_event = NULL; if (ctx->graph) { IEnumFilters *fenum; @@ -297,25 +301,34 @@ dshow_read_close(AVFormatContext *s) IEnumFilters_Release(fenum); } IGraphBuilder_Release(ctx->graph); +ctx->graph = NULL; } if (ctx->capture_pin[VideoDevice]) ff_dshow_pin_Release(ctx->capture_pin[VideoDevice]); if (ctx->capture_pin[AudioDevice]) ff_dshow_pin_Release(ctx->capture_pin[AudioDevice]); +ctx->capture_pin[0] = NULL; +ctx->capture_pin[1] = NULL; if (ctx->capture_filter[VideoDevice]) ff_dshow_filter_Release(ctx->capture_filter[VideoDevice]); if (ctx->capture_filter[AudioDevice]) ff_dshow_filter_Release(ctx->capture_filter[AudioDevice]); +ctx->capture_filter[0] = NULL; +ctx->capture_filter[1] = NULL; if (ctx->device_pin[VideoDevice]) IPin_Release(ctx->device_pin[VideoDevice]); if (ctx->device_pin[AudioDevice]) IPin_Release(ctx->device_pin[AudioDevice]); +ctx->device_pin[0] = NULL; +ctx->device_pin[1] = NULL; if (ctx->device_filter[VideoDevice]) IBaseFilter_Release(ctx->device_filter[VideoDevice]); if (ctx->device_filter[AudioDevice]) IBaseFilter_Release(ctx->device_filter[AudioDevice]); +ctx->device_filter[0] = NULL; +ctx->device_filter[1] = NULL; av_freep(&ctx->device_name[0]); av_freep(&ctx->device_name[1]); @@ -324,10 +337,13 @@ dshow_read_close(AVFormatContext *s) if(ctx->mutex) CloseHandle(ctx->mutex); +ctx->mutex = NULL; if(ctx->event[0]) CloseHandle(ctx->event[0]); if(ctx->event[1]) CloseHandle(ctx->event[1]); +ctx->event[0] = NULL; +ctx->event[1] = NULL; pktl = ctx->pktl; while (pktl) { @@ -336,6 +352,7 @@ dshow_read_close(AVFormatContext *s) av_free(pktl); pktl = next; } +ctx->pktl = NULL; CoUninitialize(); -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 29/35] avdevice/dshow: implement capabilities API
This implements avdevice_capabilities_create for the dshow device (avdevice_capabilities_free not needed as it would be no-op). Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 384 +--- 1 file changed, 365 insertions(+), 19 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 40a492b787..082ae5f26c 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -27,6 +27,7 @@ #include "libavformat/internal.h" #include "libavformat/riff.h" #include "avdevice.h" +#include "internal.h" #include "libavcodec/raw.h" #include "objidl.h" #include "shlwapi.h" @@ -815,11 +816,15 @@ static struct dshow_format_info* dshow_get_format_info(AM_MEDIA_TYPE* type) * try to set parameters specified through AVOptions, or the pin's * default format if no such parameters were set. If successful, * return 1 in *pformat_set. - * If pformat_set is NULL, list all pin capabilities. + * If pformat_set is NULL or the ranges input is not NULL, list all + * pin capabilities. + * When listing pin capabilities, if ranges is NULL, output to log, + * else store capabilities in ranges. */ static void dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, -IPin *pin, int *pformat_set) +IPin *pin, int *pformat_set, +AVOptionRanges *ranges, enum AVDeviceCapabilitiesQueryType query_type) { struct dshow_ctx *ctx = avctx->priv_data; IAMStreamConfig *config = NULL; @@ -863,7 +868,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, *one, with most info exposed (see comment below). */ use_default = !dshow_should_set_format(avctx, devtype); -if (use_default && pformat_set) +if (use_default && pformat_set && !ranges) { HRESULT hr; @@ -931,7 +936,9 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, // exposes contains a VIDEOINFOHEADER2. Fall back to the VIDEOINFOHEADER // format if no corresponding VIDEOINFOHEADER2 is found when we finish // iterating. -for (i = 0; i < n && !format_set; i++) { +for (i = 0; i < n && (!format_set || ranges); i++) { +AVOptionRange *new_range[3] = { NULL }; +int nb_range = 0; struct dshow_format_info *fmt_info = NULL; r = IAMStreamConfig_GetStreamCaps(config, i, &type, (void *) caps); if (r != S_OK) @@ -967,7 +974,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, wait_for_better = 0; } -if (!pformat_set) { +if (!pformat_set && !ranges) { if (fmt_info->pix_fmt == AV_PIX_FMT_NONE) { const AVCodec *codec = avcodec_find_decoder(fmt_info->codec_id); if (fmt_info->codec_id == AV_CODEC_ID_NONE || !codec) { @@ -1031,6 +1038,63 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, bih->biWidth = requested_width; bih->biHeight = requested_height; } + +if (ranges) { +for (int j = 0; j < ranges->nb_components; j++) { +new_range[j] = av_mallocz(sizeof(**new_range)); +if (!new_range[j]) +goto next; +++nb_range; + +switch (query_type) +{ +case AV_DEV_CAP_QUERY_CODEC: +if (dshow_pixfmt(bih->biCompression, bih->biBitCount) == AV_PIX_FMT_NONE) { +const AVCodecTag* const tags[] = { avformat_get_riff_video_tags(), NULL }; +new_range[j]->value_min = av_codec_get_id(tags, bih->biCompression); +} +else +new_range[j]->value_min = AV_CODEC_ID_RAWVIDEO; +new_range[j]->value_max = new_range[j]->value_min; +new_range[j]->is_set = 1; +break; +case AV_DEV_CAP_QUERY_PIXEL_FORMAT: +new_range[j]->value_min = new_range[j]->value_max = dshow_pixfmt(bih->biCompression, bih->biBitCount); +new_range[j]->value_min; +new_range[j]->is_set = 1; +break; +case AV_DEV_CAP_QUERY_FRAME_SIZE: +{ +switch (j) +{ +case 0: +new_range[j]->value_min = vcaps->MinOutputSize.cx * vcaps->MinOutputSize.cy; +new_range[j]->value_max = vcaps->MaxOutputSize.cx * vcaps->MaxOutputSize.cy; +break; +case 1: +new_range[j]->value_min = vcaps->MinOutputSize.cx; +
[FFmpeg-devel] [PATCH 30/35] avdevice/dshow: cosmetics
Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 21 +++-- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 082ae5f26c..c158a536d8 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -940,6 +940,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, AVOptionRange *new_range[3] = { NULL }; int nb_range = 0; struct dshow_format_info *fmt_info = NULL; + r = IAMStreamConfig_GetStreamCaps(config, i, &type, (void *) caps); if (r != S_OK) goto next; @@ -2399,15 +2400,15 @@ static const AVClass dshow_class = { }; const AVInputFormat ff_dshow_demuxer = { -.name = "dshow", -.long_name = NULL_IF_CONFIG_SMALL("DirectShow capture"), -.priv_data_size = sizeof(struct dshow_ctx), -.read_header= dshow_read_header, -.read_packet= dshow_read_packet, -.read_close = dshow_read_close, -.control_message = dshow_control_message, -.get_device_list= dshow_get_device_list, +.name = "dshow", +.long_name = NULL_IF_CONFIG_SMALL("DirectShow capture"), +.priv_data_size = sizeof(struct dshow_ctx), +.read_header= dshow_read_header, +.read_packet= dshow_read_packet, +.read_close = dshow_read_close, +.control_message= dshow_control_message, +.get_device_list= dshow_get_device_list, .create_device_capabilities = dshow_create_device_capabilities, -.flags = AVFMT_NOFILE | AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK, -.priv_class = &dshow_class, +.flags = AVFMT_NOFILE | AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK, +.priv_class = &dshow_class, }; -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 31/35] avformat: add avformat_alloc_input_context()
avformat_alloc_input_context function analogous to avformat_alloc_output_context2, except that it does not take a filename argument as guessing the format by just the filename does not make sense. avformat_alloc_input_context can be used e.g. with the avdevice capabilities API, which needs an allocated input format with priv_data (and default options) set, but device should not be opened. Added some checks to avformat_open_input, for the that AVFormatContext* allocated by avformat_alloc_input_context is provided: 1. if avformat_open_input's AVInputFormat *fmt argument is not NULL, clean up any already set s->iformat 2. if s->url is already set and avformat_open_input's filename argument is not NULL, free current url and replace by provided filename 3. if s->url is already set and avformat_open_input's filename argument is NULL, do not set s->url to "", but keep current url 4. if s->priv_data has already been allocated, do not do so again. Signed-off-by: Diederick Niehorster --- libavformat/avformat.h | 20 + libavformat/utils.c| 66 +++--- libavformat/version.h | 2 +- 3 files changed, 83 insertions(+), 5 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 5e1e82a315..b444602b86 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1896,6 +1896,26 @@ AVProgram *av_new_program(AVFormatContext *s, int id); * @} */ + /** + * Allocate an AVFormatContext for an input format. + * avformat_free_context() can be used to free the context and + * everything allocated by the framework within it. NB: in general + * the correct format cannot be known (unless the user has extra + * information) until the file is opened. If forcing a format by + * this method, but it turns out not to match the file's format + * upon avformat_open_input(), the latter will throw an error. + * + * @param *ctx is set to the created format context, or to NULL in + * case of failure + * @param iformat format to use for allocating the context, if NULL + * format_name is used instead + * @param format_name the name of input format to use for allocating the + * context + * @return >= 0 in case of success, a negative AVERROR code in case of + * failure + */ +int avformat_alloc_input_context(AVFormatContext** ctx, const AVInputFormat* iformat, + const char* format_name); /** * Allocate an AVFormatContext for an output format. diff --git a/libavformat/utils.c b/libavformat/utils.c index fe8eaa6cb3..2e8084a41b 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -478,6 +478,56 @@ static int update_stream_avctx(AVFormatContext *s) } +int avformat_alloc_input_context(AVFormatContext** avctx, const AVInputFormat* iformat, + const char* format) +{ +AVFormatContext* s = avformat_alloc_context(); +int ret = 0; + +*avctx = NULL; +if (!s) +goto nomem; + +if (!iformat) { +if (format) { +iformat = av_find_input_format(format); +if (!iformat) { +av_log(s, AV_LOG_ERROR, "Requested input format '%s' not found\n", format); +ret = AVERROR(EINVAL); +goto error; +} +} +else { +av_log(s, AV_LOG_ERROR, "You should provide an input format or the name of an input format when calling this function\n"); +ret = AVERROR(EINVAL); +goto error; +} +} + +s->iformat = iformat; +if (s->iformat->priv_data_size > 0) { +s->priv_data = av_mallocz(s->iformat->priv_data_size); +if (!s->priv_data) +goto nomem; +if (s->iformat->priv_class) { +*(const AVClass**)s->priv_data = s->iformat->priv_class; +av_opt_set_defaults(s->priv_data); +} +} +else +s->priv_data = NULL; + +*avctx = s; +return 0; +nomem: +av_log(s, AV_LOG_ERROR, "Out of memory\n"); +ret = AVERROR(ENOMEM); +error: +avformat_free_context(s); +return ret; +} + + int avformat_open_input(AVFormatContext **ps, const char *filename, const AVInputFormat *fmt, AVDictionary **options) { @@ -492,8 +542,14 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, av_log(NULL, AV_LOG_ERROR, "Input context has not been properly allocated by avformat_alloc_context() and is not NULL either\n"); return AVERROR(EINVAL); } -if (fmt) +if (fmt) { +if (s->iformat) { +if (s->iformat->priv_class && s->priv_data) +av_opt_free(s->priv_data); +av_freep(&s->priv_data); +} s->iformat = fmt; +} if (options) av_dict_copy(&tmp, *options, 0); @@ -504,7 +560,9 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, if ((ret = av_opt_set_dict(s, &tmp)) < 0) goto fa
[FFmpeg-devel] [PATCH 32/35] examples: adding device_get_capabilities example
Signed-off-by: Diederick Niehorster --- configure | 2 + doc/examples/.gitignore| 1 + doc/examples/Makefile | 1 + doc/examples/Makefile.example | 1 + doc/examples/device_get_capabilities.c | 192 + 5 files changed, 197 insertions(+) create mode 100644 doc/examples/device_get_capabilities.c diff --git a/configure b/configure index 6bfd98b384..31b1790c8d 100755 --- a/configure +++ b/configure @@ -1705,6 +1705,7 @@ EXAMPLE_LIST=" decode_audio_example decode_video_example demuxing_decoding_example +device_get_capabilities_example encode_audio_example encode_video_example extract_mvs_example @@ -3712,6 +3713,7 @@ avio_reading_deps="avformat avcodec avutil" decode_audio_example_deps="avcodec avutil" decode_video_example_deps="avcodec avutil" demuxing_decoding_example_deps="avcodec avformat avutil" +device_get_capabilities_example_deps="avdevice avformat avutil" encode_audio_example_deps="avcodec avutil" encode_video_example_deps="avcodec avutil" extract_mvs_example_deps="avcodec avformat avutil" diff --git a/doc/examples/.gitignore b/doc/examples/.gitignore index 44960e1de7..256f33a600 100644 --- a/doc/examples/.gitignore +++ b/doc/examples/.gitignore @@ -3,6 +3,7 @@ /decode_audio /decode_video /demuxing_decoding +/device_get_capabilities /encode_audio /encode_video /extract_mvs diff --git a/doc/examples/Makefile b/doc/examples/Makefile index 81bfd34d5d..de707bb3ca 100644 --- a/doc/examples/Makefile +++ b/doc/examples/Makefile @@ -3,6 +3,7 @@ EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding +EXAMPLES-$(CONFIG_DEVICE_GET_CAPABILITIES_EXAMPLE) += device_get_capabilities EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs diff --git a/doc/examples/Makefile.example b/doc/examples/Makefile.example index a232d97f98..b861b9cc74 100644 --- a/doc/examples/Makefile.example +++ b/doc/examples/Makefile.example @@ -16,6 +16,7 @@ EXAMPLES= avio_list_dir \ decode_audio \ decode_video \ demuxing_decoding \ +device_get_capabilities\ encode_audio \ encode_video \ extract_mvs\ diff --git a/doc/examples/device_get_capabilities.c b/doc/examples/device_get_capabilities.c new file mode 100644 index 00..f5909aaa0b --- /dev/null +++ b/doc/examples/device_get_capabilities.c @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2021 Diederick Niehorster + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * @file + * avdevice getting capabilities example. + * + * Shows how to use the avdevice capabilities API to probe + * device capabilities (supported codecs, pixel formats, sample + * formats, resolutions, channel counts, etc) + * @example device_get_capabilities.c + */ + +#include +#include +#include +#include + +void print_option_ranges(enum AVOptionType type, AVOptionRanges* ranges) +{ +for (int range_index = 0; range_index < ranges->nb_ranges; range_index++) { +for (int component_index = 0; component_index < ranges->nb_components; component_index++) +{ +AVOptionRange* range = ranges->range[ranges->nb_ranges * component_index + range_index]; +if (component_index > 0) +printf(", "); +printf("%s: ", range->str); +if (!range->is_set) +{ +
[FFmpeg-devel] [PATCH 33/35] Makefile/examples: cosmetics
Signed-off-by: Diederick Niehorster --- doc/examples/Makefile | 48 +-- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/doc/examples/Makefile b/doc/examples/Makefile index de707bb3ca..7988ed4226 100644 --- a/doc/examples/Makefile +++ b/doc/examples/Makefile @@ -1,27 +1,27 @@ -EXAMPLES-$(CONFIG_AVIO_LIST_DIR_EXAMPLE) += avio_list_dir -EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading -EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio -EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video -EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding -EXAMPLES-$(CONFIG_DEVICE_GET_CAPABILITIES_EXAMPLE) += device_get_capabilities -EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio -EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video -EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs -EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio -EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio -EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video -EXAMPLES-$(CONFIG_HTTP_MULTICLIENT_EXAMPLE) += http_multiclient -EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) += hw_decode -EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata -EXAMPLES-$(CONFIG_MUXING_EXAMPLE)+= muxing -EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)+= qsvdec -EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += remuxing -EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio -EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video -EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac -EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE) += transcoding -EXAMPLES-$(CONFIG_VAAPI_ENCODE_EXAMPLE) += vaapi_encode -EXAMPLES-$(CONFIG_VAAPI_TRANSCODE_EXAMPLE) += vaapi_transcode +EXAMPLES-$(CONFIG_AVIO_LIST_DIR_EXAMPLE) += avio_list_dir +EXAMPLES-$(CONFIG_AVIO_READING_EXAMPLE) += avio_reading +EXAMPLES-$(CONFIG_DECODE_AUDIO_EXAMPLE) += decode_audio +EXAMPLES-$(CONFIG_DECODE_VIDEO_EXAMPLE) += decode_video +EXAMPLES-$(CONFIG_DEMUXING_DECODING_EXAMPLE) += demuxing_decoding +EXAMPLES-$(CONFIG_DEVICE_GET_CAPABILITIES_EXAMPLE) += device_get_capabilities +EXAMPLES-$(CONFIG_ENCODE_AUDIO_EXAMPLE) += encode_audio +EXAMPLES-$(CONFIG_ENCODE_VIDEO_EXAMPLE) += encode_video +EXAMPLES-$(CONFIG_EXTRACT_MVS_EXAMPLE) += extract_mvs +EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE) += filter_audio +EXAMPLES-$(CONFIG_FILTERING_AUDIO_EXAMPLE) += filtering_audio +EXAMPLES-$(CONFIG_FILTERING_VIDEO_EXAMPLE) += filtering_video +EXAMPLES-$(CONFIG_HTTP_MULTICLIENT_EXAMPLE) += http_multiclient +EXAMPLES-$(CONFIG_HW_DECODE_EXAMPLE) += hw_decode +EXAMPLES-$(CONFIG_METADATA_EXAMPLE) += metadata +EXAMPLES-$(CONFIG_MUXING_EXAMPLE)+= muxing +EXAMPLES-$(CONFIG_QSVDEC_EXAMPLE)+= qsvdec +EXAMPLES-$(CONFIG_REMUXING_EXAMPLE) += remuxing +EXAMPLES-$(CONFIG_RESAMPLING_AUDIO_EXAMPLE) += resampling_audio +EXAMPLES-$(CONFIG_SCALING_VIDEO_EXAMPLE) += scaling_video +EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE) += transcode_aac +EXAMPLES-$(CONFIG_TRANSCODING_EXAMPLE) += transcoding +EXAMPLES-$(CONFIG_VAAPI_ENCODE_EXAMPLE) += vaapi_encode +EXAMPLES-$(CONFIG_VAAPI_TRANSCODE_EXAMPLE) += vaapi_transcode EXAMPLES := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)$(EXESUF)) EXAMPLES_G := $(EXAMPLES-yes:%=doc/examples/%$(PROGSSUF)_g$(EXESUF)) -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 34/35] avdevice/dshow: prevent NULL access
list_options true would crash when both a video and an audio device were specified as input. Crash would occur on line 1618 (in this new rev) because ctx->device_unique_name[otherDevType] would be NULL Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index c158a536d8..9af3360317 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -1503,9 +1503,9 @@ dshow_list_device_options(AVFormatContext *avctx, ICreateDevEnum *devenum, if ((r = dshow_cycle_devices(avctx, devenum, devtype, sourcetype, &device_filter, &device_unique_name, NULL)) < 0) return r; ctx->device_filter[devtype] = device_filter; +ctx->device_unique_name[devtype] = device_unique_name; if ((r = dshow_cycle_pins(avctx, devtype, sourcetype, device_filter, ranges ? &device_pin : NULL, ranges, query_type)) < 0) return r; -av_freep(&device_unique_name); return 0; } @@ -1565,7 +1565,8 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, goto error; } } -if (ctx->device_filter[otherDevType]) { + +if (ctx->device_filter[otherDevType]) { // avoid adding add two instances of the same device to the graph, one for video, one for audio // a few devices don't support this (could also do this check earlier to avoid double crossbars, etc. but they seem OK) if (strcmp(device_filter_unique_name, ctx->device_unique_name[otherDevType]) == 0) { @@ -2027,6 +2028,7 @@ static int dshow_read_header(AVFormatContext *avctx) } } } +// don't exit yet, allow it to list crossbar options in dshow_open_device } ctx->is_running = 0; if (ctx->device_name[VideoDevice]) { -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 35/35] avdevice/dshow: capabilities query also works on opened device
While the capabilities API is in principle meant to be used with an allocated format context belonging to an unopened device, small changes make it work for an opened dshow device as well. So hereby done. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 36 +++- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 9af3360317..c0032ae726 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -834,7 +834,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, void *caps = NULL; int i, n, size, r; int wait_for_better = 0; -int use_default; +int use_default, already_opened; // format parameters requested by user // if none are requested by user, the values will below be set to @@ -860,6 +860,9 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, if (!caps) goto end; +// get if device is already opened +already_opened = ctx->device_name[0] || ctx->device_name[1]; + /** * If we should open the device with the default format, * then: @@ -1173,7 +1176,7 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype, // in ranges, try to apply in all cases, and store // caps if successfully applied if (!wait_for_better || ranges) { -if (IAMStreamConfig_SetFormat(config, type) != S_OK) +if (!already_opened && IAMStreamConfig_SetFormat(config, type) != S_OK) // skip if device already opened goto next; else if (ranges) { // format matched and could be set successfully. @@ -1500,12 +1503,19 @@ dshow_list_device_options(AVFormatContext *avctx, ICreateDevEnum *devenum, char *device_unique_name = NULL; int r; -if ((r = dshow_cycle_devices(avctx, devenum, devtype, sourcetype, &device_filter, &device_unique_name, NULL)) < 0) -return r; -ctx->device_filter[devtype] = device_filter; -ctx->device_unique_name[devtype] = device_unique_name; +if (!ctx->device_filter[devtype]) { +if ((r = dshow_cycle_devices(avctx, devenum, devtype, sourcetype, &device_filter, &device_unique_name, NULL)) < 0) +return r; +} else +device_filter = ctx->device_filter[devtype]; if ((r = dshow_cycle_pins(avctx, devtype, sourcetype, device_filter, ranges ? &device_pin : NULL, ranges, query_type)) < 0) return r; + +if (!ctx->device_filter[devtype]) { +// put them in context so they'll be cleaned up again +ctx->device_filter[devtype] = device_filter; +ctx->device_unique_name[devtype] = device_unique_name; +} return 0; } @@ -2175,6 +2185,7 @@ static int dshow_query_ranges(AVOptionRanges** ranges_arg, void* obj, const char AVDeviceCapabilitiesQuery *caps = obj; const AVFormatContext *avctx = caps->device_context; struct dshow_ctx *ctx = avctx->priv_data; +int already_opened; int backup_sample_size; int backup_sample_rate; @@ -2214,13 +2225,11 @@ static int dshow_query_ranges(AVOptionRanges** ranges_arg, void* obj, const char goto fail1; } -if (ctx->device_name[0]) { -av_log(avctx, AV_LOG_ERROR, "You cannot query device capabilities on an opened device\n"); -ret = AVERROR(EIO); -goto fail1; -} +already_opened = ctx->device_name[0] || ctx->device_name[1]; +if (already_opened) +av_log(avctx, AV_LOG_WARNING, "Querying device capabilities on an opened device: may yield false positives\n"); -if (!parse_device_name(avctx)) { +if (!already_opened && !parse_device_name(avctx)) { av_log(avctx, AV_LOG_ERROR, "You must set a device name (AVFormatContext url) to specify which device to query capabilities from\n"); ret = AVERROR(EINVAL); goto fail1; @@ -2336,7 +2345,8 @@ fail2: // clear state variables that may have been set during the above process // (e.g. frees device names, removes device_filters, etc) -dshow_read_close(avctx); +if (!already_opened) +dshow_read_close(avctx); fail1: if (ret < 0) -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 02/35] avdevice/dshow: add use_video_device_timestamps to docs
Signed-off-by: Diederick Niehorster --- doc/indevs.texi | 6 ++ 1 file changed, 6 insertions(+) diff --git a/doc/indevs.texi b/doc/indevs.texi index b377924c2f..685b1357a6 100644 --- a/doc/indevs.texi +++ b/doc/indevs.texi @@ -611,6 +611,12 @@ Save the currently used video capture filter device and its parameters (if the filter supports it) to a file. If a file with the same name exists it will be overwritten. +@item use_video_device_timestamps +If set to @option{false}, the timestamp for video frames will be +derived from the wallclock instead of the timestamp provided by +the capture device. This allows working around devices that +provide unreliable timestamps. + @end table @subsection Examples -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 05/35] avdevice/dshow: set no-seek flags
avdevice/dshow is a realtime device and as such does not support seeking. Therefore, its demuxer format should define the AVFMT_NOBINSEARCH, AVFMT_NOGENSEARCH and AVFMT_NO_BYTE_SEEK flags. With these flags set, attempting to seek (with e.g. avformat_seek_file()) correctly yields -1 (operation not permitted) instead of -22 (invalid argument). This actually seems to apply to many other devices, at least the gdigrab, v4l2, vfwcap, x11grab, fbdev, kmsgrab and android_camera devices, from reading the source. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 2e9f9ddf3f..389daa6380 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -1336,6 +1336,6 @@ const AVInputFormat ff_dshow_demuxer = { .read_header= dshow_read_header, .read_packet= dshow_read_packet, .read_close = dshow_read_close, -.flags = AVFMT_NOFILE, +.flags = AVFMT_NOFILE | AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK, .priv_class = &dshow_class, }; -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 06/35] avdevice/dshow: implement get_device_list
Needed to enable programmatic discovery of DirectShow devices Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 80 + 1 file changed, 73 insertions(+), 7 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 389daa6380..25de6b1acd 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -202,11 +202,14 @@ fail: * retrieve the device with type specified by devtype and return the * pointer to the object found in *pfilter. * If pfilter is NULL, list all device names. + * If device_list is not NULL, populate it with found devices instead of + * outputting device names to log */ static int dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, enum dshowDeviceType devtype, enum dshowSourceFilterType sourcetype, -IBaseFilter **pfilter, char **device_unique_name) +IBaseFilter **pfilter, char **device_unique_name, +AVDeviceInfoList **device_list) { struct dshow_ctx *ctx = avctx->priv_data; IBaseFilter *device_filter = NULL; @@ -238,6 +241,7 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, IBindCtx *bind_ctx = NULL; LPOLESTR olestr = NULL; LPMALLOC co_malloc = NULL; +AVDeviceInfo *device = NULL; int i; r = CoGetMalloc(1, &co_malloc); @@ -282,11 +286,39 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, // success, loop will end now } } else { -av_log(avctx, AV_LOG_INFO, " \"%s\"\n", friendly_name); -av_log(avctx, AV_LOG_INFO, "Alternative name \"%s\"\n", unique_name); +if (device_list) { +device = av_mallocz(sizeof(AVDeviceInfo)); +if (!device) +goto fail1; + +device->device_name = av_strdup(friendly_name); +device->device_description = av_strdup(unique_name); +if (!device->device_name || !device->device_description) +goto fail1; + +// store to device_list output +if (av_reallocp_array(&(*device_list)->devices, + (*device_list)->nb_devices + 1, + sizeof(*(*device_list)->devices)) < 0) +goto fail1; +(*device_list)->devices[(*device_list)->nb_devices] = device; +(*device_list)->nb_devices++; +device = NULL; // copied into array, make sure not freed below +} +else { +av_log(avctx, AV_LOG_INFO, " \"%s\"\n", friendly_name); +av_log(avctx, AV_LOG_INFO, "Alternative name \"%s\"\n", unique_name); +} } fail1: +if (device) { +if (device->device_name) +av_freep(&device->device_name); +if (device->device_name) +av_freep(&device->device_description); +av_free(device); +} if (olestr && co_malloc) IMalloc_Free(co_malloc, olestr); if (bind_ctx) @@ -312,6 +344,39 @@ fail1: return 0; } +static int dshow_get_device_list(AVFormatContext *avctx, AVDeviceInfoList *device_list) +{ +struct dshow_ctx *ctx = avctx->priv_data; +ICreateDevEnum *devenum = NULL; +int r; +int ret = AVERROR(EIO); + +if (!device_list) +return AVERROR(EINVAL); + +CoInitialize(0); + +r = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, +&IID_ICreateDevEnum, (void**)&devenum); +if (r != S_OK) { +av_log(avctx, AV_LOG_ERROR, "Could not enumerate system devices.\n"); +goto error; +} + +ret = dshow_cycle_devices(avctx, devenum, VideoDevice, VideoSourceDevice, NULL, NULL, &device_list); +if (ret < S_OK) +goto error; +ret = dshow_cycle_devices(avctx, devenum, AudioDevice, AudioSourceDevice, NULL, NULL, &device_list); + +error: +if (devenum) +ICreateDevEnum_Release(devenum); + +CoUninitialize(); + +return ret; +} + /** * Cycle through available formats using the specified pin, * try to set parameters specified through AVOptions and if successful @@ -713,7 +778,7 @@ dshow_list_device_options(AVFormatContext *avctx, ICreateDevEnum *devenum, char *device_unique_name = NULL; int r; -if ((r = dshow_cycle_devices(avctx, devenum, devtype, sourcetype, &device_filter, &device_unique_name)) < 0) +if ((r = dshow_cycle_devices(avctx, devenum, devtype, sourcetype, &device_filter, &device_unique_name, NULL)) < 0) return r; ctx->device_filter[devtype] = device_filter; if ((r = dshow_cycle_pins(avctx, devtype, sourcetype, device_filter, NULL)) < 0) @@ -773,7 +838,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, av
[FFmpeg-devel] [PATCH 09/35] avdevice/dshow: add media type info to get_device_list
The list returned by get_device_list now contains info about what media type(s), if any, can be provided by each device. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 5d7f065a8c..3e41f4f99f 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -377,6 +377,11 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, if (!device->device_name || !device->device_description) goto fail1; +device->nb_media_types = nb_media_types; +device->media_types = media_types; +nb_media_types = 0; +media_types = NULL; + // store to device_list output if (av_reallocp_array(&(*device_list)->devices, (*device_list)->nb_devices + 1, @@ -412,6 +417,8 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, av_freep(&device->device_name); if (device->device_name) av_freep(&device->device_description); +if (device->media_types) +av_freep(&device->media_types); av_free(device); } if (olestr && co_malloc) -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 04/35] avdevice/dshow: handle unknown sample time
GetTime may return an error indication that the sample has not timestamps, or may return a NULL start time. In those cases, fall back to graph time better debug message in case sample dropped: could now be audio or video frame Signed-off-by: Diederick Niehorster --- libavdevice/dshow_pin.c | 19 --- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index 1d0e880480..310f48c85e 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -295,14 +295,15 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) uint8_t *buf; int buf_size; /* todo should be a long? */ int index; -int64_t chosentime; -int64_t sampletime; -int64_t graphtime; +int64_t chosentime = 0; +int64_t sampletime = 0; +int64_t graphtime = 0; int use_sample_time = 1; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio"; IReferenceClock *clock = pin->filter->clock; int64_t dummy; struct dshow_ctx *ctx; +HRESULT hr; dshowdebug("ff_dshow_meminputpin_Receive(%p)\n", this); @@ -314,22 +315,26 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) s = priv_data; ctx = s->priv_data; -IMediaSample_GetTime(sample, &sampletime, &dummy); +hr = IMediaSample_GetTime(sample, &sampletime, &dummy); IReferenceClock_GetTime(clock, &graphtime); if (devtype == VideoDevice && !ctx->use_video_device_timestamps) { /* PTS from video devices is unreliable. */ chosentime = graphtime; use_sample_time = 0; } else { -if (sampletime > 40LL) { +if (hr == VFW_E_SAMPLE_TIME_NOT_SET || sampletime == 0) { +chosentime = graphtime; +use_sample_time = 0; +} +else if (sampletime > 40LL) { /* initial frames sometimes start < 0 (shown as a very large number here, like 437650244077016960 which FFmpeg doesn't like). TODO figure out math. For now just drop them. */ av_log(NULL, AV_LOG_DEBUG, "dshow dropping initial (or ending) frame with odd PTS too high %"PRId64"\n", sampletime); return S_OK; -} -chosentime = sampletime; +} else +chosentime = sampletime; } // media sample time is relative to graph start time sampletime += pin->filter->start_time; -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 07/35] avdevice/dshow: list_devices: show media type(s) per device
the list_devices option of dshow didn't indicate whether a specific device provides audio or video output. This patch iterates through all media formats of all pins exposed by the device to see what types it provides for capture, and prints this to the console for each device. Importantly, this now allows to find devices that provide both audio and video, and devices that provide neither. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 103 +--- 1 file changed, 98 insertions(+), 5 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 25de6b1acd..5d7f065a8c 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -197,6 +197,79 @@ fail: return; } +static void dshow_get_device_media_types(AVFormatContext *avctx, enum dshowDeviceType devtype, + enum dshowSourceFilterType sourcetype, IBaseFilter *device_filter, + enum AVMediaType **media_types, int *nb_media_types) +{ +struct dshow_ctx *ctx = avctx->priv_data; +IEnumPins *pins = 0; +IPin *pin; +int has_audio = 0, has_video = 0; + +if (IBaseFilter_EnumPins(device_filter, &pins) != S_OK) +return; + +while (IEnumPins_Next(pins, 1, &pin, NULL) == S_OK) { +IKsPropertySet *p = NULL; +PIN_INFO info = { 0 }; +GUID category; +DWORD r2; +IEnumMediaTypes *types = NULL; +AM_MEDIA_TYPE *type; + +if (IPin_QueryPinInfo(pin, &info) != S_OK) +goto next; +IBaseFilter_Release(info.pFilter); + +if (info.dir != PINDIR_OUTPUT) +goto next; +if (IPin_QueryInterface(pin, &IID_IKsPropertySet, (void **) &p) != S_OK) +goto next; +if (IKsPropertySet_Get(p, &ROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, + NULL, 0, &category, sizeof(GUID), &r2) != S_OK) +goto next; +if (!IsEqualGUID(&category, &PIN_CATEGORY_CAPTURE)) +goto next; + +if (IPin_EnumMediaTypes(pin, &types) != S_OK) +goto next; + +// enumerate media types exposed by pin +// NB: don't know if a pin can expose both audio and video, check 'm all to be safe +IEnumMediaTypes_Reset(types); +while (IEnumMediaTypes_Next(types, 1, &type, NULL) == S_OK) { +if (IsEqualGUID(&type->majortype, &MEDIATYPE_Video)) { +has_video = 1; +} else if (IsEqualGUID(&type->majortype, &MEDIATYPE_Audio)) { +has_audio = 1; +} +CoTaskMemFree(type); +} + +next: +if (types) +IEnumMediaTypes_Release(types); +if (p) +IKsPropertySet_Release(p); +if (pin) +IPin_Release(pin); +} + +IEnumPins_Release(pins); + +if (has_audio || has_video) { +int nb_types = has_audio + has_video; +*media_types = av_malloc_array(nb_types, sizeof(enum AVMediaType)); +if (*media_types) { +if (has_audio) +*media_types[0] = AVMEDIA_TYPE_AUDIO; +if (has_video) +*media_types[0+has_audio] = AVMEDIA_TYPE_VIDEO; +*nb_media_types = nb_types; +} +} +} + /** * Cycle through available devices using the device enumerator devenum, * retrieve the device with type specified by devtype and return the @@ -242,6 +315,8 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, LPOLESTR olestr = NULL; LPMALLOC co_malloc = NULL; AVDeviceInfo *device = NULL; +enum AVMediaType *media_types = NULL; +int nb_media_types = 0; int i; r = CoGetMalloc(1, &co_malloc); @@ -286,6 +361,12 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, // success, loop will end now } } else { +// get media types exposed by pins of device +if (IMoniker_BindToObject(m, 0, 0, &IID_IBaseFilter, (void* ) &device_filter) == S_OK) { +dshow_get_device_media_types(avctx, devtype, sourcetype, device_filter, &media_types, &nb_media_types); +IBaseFilter_Release(device_filter); +device_filter = NULL; +} if (device_list) { device = av_mallocz(sizeof(AVDeviceInfo)); if (!device) @@ -306,12 +387,26 @@ dshow_cycle_devices(AVFormatContext *avctx, ICreateDevEnum *devenum, device = NULL; // copied into array, make sure not freed below } else { -av_log(avctx, AV_LOG_INFO, " \"%s\"\n", friendly_name); -av_log(avctx, AV_LOG_INFO, "Alternative name \"%s\"\n", unique_name); +av_log(avctx, AV_LOG_INFO, "\"%s\"", friendly_name); +if (nb_media_types > 0 && media_types) { +
[FFmpeg-devel] [PATCH 01/35] avdevice/dshow: implement option to use device video timestamps
The dshow plugin ignores timestamps for video frames provided by the DirectShow device, instead using wallclock time, apparently because the implementer of this code had a device that provided unreliable timestamps. Me (and others) would like to use the device's timestamps. The new use_video_device_timestamps option for dshow device enables them to do so. Since the majority of video devices out there probably provide fine timestamps, this patch sets the default to using the device timestamps, which means best fidelity timestamps are used by default. Using the new option, the user can switch this off and revert to the old behavior, so a fall back remains available in case the device provides broken timestamps. Closes: #8620 Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 1 + libavdevice/dshow_capture.h | 1 + libavdevice/dshow_pin.c | 15 --- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 8d0a6fcc09..2e9f9ddf3f 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -1317,6 +1317,7 @@ static const AVOption options[] = { { "audio_device_save", "save audio capture filter device (and properties) to file", OFFSET(audio_filter_save_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "video_device_load", "load video capture filter device (and properties) from file", OFFSET(video_filter_load_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { "video_device_save", "save video capture filter device (and properties) to file", OFFSET(video_filter_save_file), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, +{ "use_video_device_timestamps", "use device instead of wallclock timestamps for video frames", OFFSET(use_video_device_timestamps), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, DEC }, { NULL }, }; diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index 06ded2ba96..5a2691518c 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -312,6 +312,7 @@ struct dshow_ctx { char *audio_filter_save_file; char *video_filter_load_file; char *video_filter_save_file; +int use_video_device_timestamps; IBaseFilter *device_filter[2]; IPin*device_pin[2]; diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index 3dae405e65..ab0ead8041 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -309,12 +309,16 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) if (!sample) return E_POINTER; +priv_data = pin->filter->priv_data; +s = priv_data; +ctx = s->priv_data; + IMediaSample_GetTime(sample, &orig_curtime, &dummy); orig_curtime += pin->filter->start_time; IReferenceClock_GetTime(clock, &graphtime); -if (devtype == VideoDevice) { -/* PTS from video devices is unreliable. */ -IReferenceClock_GetTime(clock, &curtime); +if (devtype == VideoDevice && !ctx->use_video_device_timestamps) { +/* PTS from video devices is unreliable. */ +IReferenceClock_GetTime(clock, &curtime); } else { IMediaSample_GetTime(sample, &curtime, &dummy); if(curtime > 40LL) { @@ -322,7 +326,7 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) like 437650244077016960 which FFmpeg doesn't like. TODO figure out math. For now just drop them. */ av_log(NULL, AV_LOG_DEBUG, -"dshow dropping initial (or ending) audio frame with odd PTS too high %"PRId64"\n", curtime); +"dshow dropping initial (or ending) frame with odd PTS too high %"PRId64"\n", curtime); return S_OK; } curtime += pin->filter->start_time; @@ -330,9 +334,6 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) buf_size = IMediaSample_GetActualDataLength(sample); IMediaSample_GetPointer(sample, &buf); -priv_data = pin->filter->priv_data; -s = priv_data; -ctx = s->priv_data; index = pin->filter->stream_index; av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size %8d " -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 15/35] avdevice/dshow: tv_tuner_audio_dialog cleanup missing
Cleanup in case the show_analog_tv_tuner_audio_dialog was set was missing. Signed-off-by: Diederick Niehorster --- libavdevice/dshow_crossbar.c | 4 1 file changed, 4 insertions(+) diff --git a/libavdevice/dshow_crossbar.c b/libavdevice/dshow_crossbar.c index 2438683cde..961defe690 100644 --- a/libavdevice/dshow_crossbar.c +++ b/libavdevice/dshow_crossbar.c @@ -204,5 +204,9 @@ end: IAMTVTuner_Release(tv_tuner_filter); if (tv_tuner_base_filter) IBaseFilter_Release(tv_tuner_base_filter); +if (tv_audio_filter) +IAMAudioInputMixer_Release(tv_audio_filter); +if (tv_audio_base_filter) +IBaseFilter_Release(tv_audio_base_filter); return hr; } -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 14/35] avdevice/dshow: accept show config dialog control message
DirectShow source will pop up its configuration dialog when AV_APP_TO_DEV_CONFIG is received. Implementation for several other possible configuration dialogs is more involved and will be provided in the next commit. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 9f041e90f8..b3c005d3f7 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -1095,6 +1095,32 @@ static int dshow_control_message(AVFormatContext *avctx, int type, void *data, s case AV_APP_TO_DEV_TOGGLE_PAUSE: run_state = !run_state; break; +case AV_APP_TO_DEV_CONFIG: +{ +/* + * Documentation of dialog variable: + * 1st bit: if set, audio device, if not set, video device + * 2nd bit: if set, show property dialog for audio/video capture device + * 3rd bit: if set, show property dialog for crossbar connecting pins filter on audio/video device + * 4th bit: if set, show property dialog for analog tuner audio / analog tuner filter + */ +int dialog = *(int *) data; +enum dshowDeviceType devtype = (dialog & 1) ? AudioDevice : VideoDevice; +if (dialog & 1<<1) { +// device_dialog +if (ctx->device_filter[devtype]) +ff_dshow_show_filter_properties(ctx->device_filter[devtype], avctx); +} +else if (dialog & 1<<2) { +// crossbar_connection_dialog +// TODO +} +else if (dialog & 1<<3) { +// tv_tuner_dialog +// TODO +} +break; +} } // if play state change requested, apply -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 00/35] avdevice (mostly dshow) enhancements
This patch series implements a series of features, mostly enhancing the dshow avdevice, but also adding new functionality to avformat and avutil. This whole patchset enabled users of the FFmpeg API to fully query and control a dshow device, making FFmpeg a nice backend for any program that needs access to, e.g., a webcam. [PATCH 29/35] avdevice/dshow: implement capabilities API and [PATCH 32/35] examples: adding device_get_capabilities example have incorporated all of Andreas Rheinhardt's review comments. Querying the capabilities of a dshow device is now also possible on a device that is already opened. I expect/guess however that it may not be possible to achieve that for all of the avdevices, so in principle it is important that this patchset adds the ability to create an allocated but unopened AVFormatContext+AVInputFormat with the new function avformat_alloc_input_context(). Diederick Niehorster (35): avdevice/dshow: implement option to use device video timestamps avdevice/dshow: add use_video_device_timestamps to docs avdevice/dshow: query graph and sample time only once avdevice/dshow: handle unknown sample time avdevice/dshow: set no-seek flags avdevice/dshow: implement get_device_list avdevice/dshow: list_devices: show media type(s) per device avdevice: add info about media types(s) to AVDeviceInfo avdevice/dshow: add media type info to get_device_list fftools: provide media type info for devices avformat: add control_message function to AVInputFormat avdevice/dshow: implement control_message interface avdevice: adding control message requesting to show config dialog avdevice/dshow: accept show config dialog control message avdevice/dshow: tv_tuner_audio_dialog cleanup missing avdevice/dshow: add config dialog command for crossbar and tv tuner avdevice/dshow: discover source color range/space/etc avdevice/dshow: select format with extended color info avdevice/avdevice: Revert "Deprecate AVDevice Capabilities API" avdevice/avdevice: clean up avdevice_capabilities_create avdevice: capabilities API details no longer public avformat: avdevice capabilities API details no longer public avformat: cosmetics avutil/opt: AVOptionRange gains is_set field. avutil/opt: add av_opt_to_string avdevice: Add internal helpers for querying device capabilities avdevice/dshow: move audio format helpers avdevice/dshow: when closing, set context fields back to zero avdevice/dshow: implement capabilities API avdevice/dshow: cosmetics avformat: add avformat_alloc_input_context() examples: adding device_get_capabilities example Makefile/examples: cosmetics avdevice/dshow: prevent NULL access avdevice/dshow: capabilities query also works on opened device configure |2 + doc/examples/.gitignore|1 + doc/examples/Makefile | 47 +- doc/examples/Makefile.example |1 + doc/examples/device_get_capabilities.c | 192 doc/indevs.texi|6 + fftools/cmdutils.c | 41 +- libavdevice/avdevice.c | 94 +- libavdevice/avdevice.h | 59 +- libavdevice/dshow.c| 1372 +--- libavdevice/dshow_capture.h| 12 + libavdevice/dshow_crossbar.c | 95 +- libavdevice/dshow_pin.c| 46 +- libavdevice/internal.h | 64 ++ libavdevice/utils.c| 48 + libavdevice/version.h |4 +- libavformat/avformat.h | 57 +- libavformat/utils.c| 66 +- libavformat/version.h |4 +- libavutil/opt.c| 94 +- libavutil/opt.h| 17 +- libavutil/version.h|2 +- 22 files changed, 2021 insertions(+), 303 deletions(-) create mode 100644 doc/examples/device_get_capabilities.c -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 13/35] avdevice: adding control message requesting to show config dialog
This control message can be used to programmatically ask a device to show its configuration dialog. Bumping avdevice version. Signed-off-by: Diederick Niehorster --- libavdevice/avdevice.h | 10 ++ libavdevice/version.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index 6f24976dcc..4fbdf6aabc 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -190,6 +190,16 @@ enum AVAppToDevMessageType { */ AV_APP_TO_DEV_GET_VOLUME = MKBETAG('G', 'V', 'O', 'L'), AV_APP_TO_DEV_GET_MUTE = MKBETAG('G', 'M', 'U', 'T'), + +/** + * Request to show configuration dialog. + * + * If device has a configuration dialog of type indicated by + * data, show it. + * + * data: int. + */ +AV_APP_TO_DEV_CONFIG = MKBETAG('C', 'O', 'N', 'F'), }; /** diff --git a/libavdevice/version.h b/libavdevice/version.h index 6e593ba00e..0381d6cd0d 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVDEVICE_VERSION_MAJOR 59 -#define LIBAVDEVICE_VERSION_MINOR 1 +#define LIBAVDEVICE_VERSION_MINOR 2 #define LIBAVDEVICE_VERSION_MICRO 100 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 11/35] avformat: add control_message function to AVInputFormat
Control messages are useful for programmatic control of not only outdevs but also indevs. Bumping avformat version. Signed-off-by: Diederick Niehorster --- libavdevice/avdevice.c | 8 +--- libavformat/avformat.h | 6 ++ libavformat/version.h | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index 4a40929007..e339cebf2d 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -53,9 +53,11 @@ const char * avdevice_license(void) int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum AVAppToDevMessageType type, void *data, size_t data_size) { -if (!s->oformat || !s->oformat->control_message) -return AVERROR(ENOSYS); -return s->oformat->control_message(s, type, data, data_size); +if (s->oformat && s->oformat->control_message) +return s->oformat->control_message(s, type, data, data_size); +if (s->iformat && s->iformat->control_message) +return s->iformat->control_message(s, type, data, data_size); +return AVERROR(ENOSYS); } int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToAppMessageType type, diff --git a/libavformat/avformat.h b/libavformat/avformat.h index a28ac372da..adbdd712a7 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -737,6 +737,12 @@ typedef struct AVInputFormat { */ int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); +/** + * Allows sending messages from application to device. + */ +int (*control_message)(struct AVFormatContext *s, int type, + void *data, size_t data_size); + /** * Returns device list with it properties. * @see avdevice_list_devices() for more details. diff --git a/libavformat/version.h b/libavformat/version.h index 5de0814316..7f02e18f24 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,8 +32,8 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 59 -#define LIBAVFORMAT_VERSION_MINOR 2 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MINOR 3 +#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 08/35] avdevice: add info about media types(s) to AVDeviceInfo
An avdevice, regardless of whether its category says its an audio or video device, may provide access to devices providing different media types, or even single devices providing multiple media types. Also, some devices may provide no media types. dshow is an example encompassing all of these cases. Users should be provided with this information, so AVDeviceInfo is extended to provide it. Bump avdevice version Signed-off-by: Diederick Niehorster --- libavdevice/avdevice.c | 2 ++ libavdevice/avdevice.h | 2 ++ libavdevice/version.h | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index 22b7595ab1..4a40929007 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -158,6 +158,8 @@ void avdevice_free_list_devices(AVDeviceInfoList **device_list) if (dev) { av_freep(&dev->device_name); av_freep(&dev->device_description); +if (dev->media_types) +av_freep(&dev->media_types); av_free(dev); } } diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index 8370bbc7f2..6f24976dcc 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -457,6 +457,8 @@ void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContex typedef struct AVDeviceInfo { char *device_name; /**< device name, format depends on device */ char *device_description;/**< human friendly name */ +enum AVMediaType *media_types; /**< array indicating what media types(s), if any, a device can provide. If null, cannot provide any */ +int nb_media_types; /**< length of media_types array, 0 if device cannot provide any media types */ } AVDeviceInfo; /** diff --git a/libavdevice/version.h b/libavdevice/version.h index 6021a0dd65..6e593ba00e 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVDEVICE_VERSION_MAJOR 59 -#define LIBAVDEVICE_VERSION_MINOR 0 +#define LIBAVDEVICE_VERSION_MINOR 1 #define LIBAVDEVICE_VERSION_MICRO 100 #define LIBAVDEVICE_VERSION_INT AV_VERSION_INT(LIBAVDEVICE_VERSION_MAJOR, \ -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 03/35] avdevice/dshow: query graph and sample time only once
No need to query twice, use value we've already unconditionally got. Improve variable names Signed-off-by: Diederick Niehorster --- libavdevice/dshow_pin.c | 30 +- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/libavdevice/dshow_pin.c b/libavdevice/dshow_pin.c index ab0ead8041..1d0e880480 100644 --- a/libavdevice/dshow_pin.c +++ b/libavdevice/dshow_pin.c @@ -295,9 +295,10 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) uint8_t *buf; int buf_size; /* todo should be a long? */ int index; -int64_t curtime; -int64_t orig_curtime; +int64_t chosentime; +int64_t sampletime; int64_t graphtime; +int use_sample_time = 1; const char *devtypename = (devtype == VideoDevice) ? "video" : "audio"; IReferenceClock *clock = pin->filter->clock; int64_t dummy; @@ -313,24 +314,27 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) s = priv_data; ctx = s->priv_data; -IMediaSample_GetTime(sample, &orig_curtime, &dummy); -orig_curtime += pin->filter->start_time; +IMediaSample_GetTime(sample, &sampletime, &dummy); IReferenceClock_GetTime(clock, &graphtime); if (devtype == VideoDevice && !ctx->use_video_device_timestamps) { -/* PTS from video devices is unreliable. */ -IReferenceClock_GetTime(clock, &curtime); +/* PTS from video devices is unreliable. */ +chosentime = graphtime; +use_sample_time = 0; } else { -IMediaSample_GetTime(sample, &curtime, &dummy); -if(curtime > 40LL) { +if (sampletime > 40LL) { /* initial frames sometimes start < 0 (shown as a very large number here, - like 437650244077016960 which FFmpeg doesn't like. + like 437650244077016960 which FFmpeg doesn't like). TODO figure out math. For now just drop them. */ av_log(NULL, AV_LOG_DEBUG, -"dshow dropping initial (or ending) frame with odd PTS too high %"PRId64"\n", curtime); +"dshow dropping initial (or ending) frame with odd PTS too high %"PRId64"\n", sampletime); return S_OK; } -curtime += pin->filter->start_time; +chosentime = sampletime; } +// media sample time is relative to graph start time +sampletime += pin->filter->start_time; +if (use_sample_time) +chosentime += pin->filter->start_time; buf_size = IMediaSample_GetActualDataLength(sample); IMediaSample_GetPointer(sample, &buf); @@ -338,8 +342,8 @@ long ff_dshow_meminputpin_Receive(DShowMemInputPin *this, IMediaSample *sample) av_log(NULL, AV_LOG_VERBOSE, "dshow passing through packet of type %s size %8d " "timestamp %"PRId64" orig timestamp %"PRId64" graph timestamp %"PRId64" diff %"PRId64" %s\n", -devtypename, buf_size, curtime, orig_curtime, graphtime, graphtime - orig_curtime, ctx->device_name[devtype]); -pin->filter->callback(priv_data, index, buf, buf_size, curtime, devtype); +devtypename, buf_size, chosentime, sampletime, graphtime, graphtime - sampletime, ctx->device_name[devtype]); +pin->filter->callback(priv_data, index, buf, buf_size, chosentime, devtype); return S_OK; } -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 12/35] avdevice/dshow: implement control_message interface
This allows programmatic users of avdevice to start and stop the DirectShow Capture graph (i.e. receive frames or not). This is important because now the buffer fills up and starts dropping samples when enqueued packets are not read out immediately after the demuxer is opened. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 42 + libavdevice/dshow_capture.h | 1 + 2 files changed, 43 insertions(+) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index 3e41f4f99f..9f041e90f8 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -1079,6 +1079,45 @@ error: return ret; } +static int dshow_control_message(AVFormatContext *avctx, int type, void *data, size_t data_size) +{ +struct dshow_ctx *ctx = avctx->priv_data; +int run_state = ctx->is_running; +HRESULT hr; + +switch (type) { +case AV_APP_TO_DEV_PAUSE: +run_state = 0; +break; +case AV_APP_TO_DEV_PLAY: +run_state = 1; +break; +case AV_APP_TO_DEV_TOGGLE_PAUSE: +run_state = !run_state; +break; +} + +// if play state change requested, apply +if (run_state != ctx->is_running) { +if (run_state) +hr = IMediaControl_Run(ctx->control); +else +hr = IMediaControl_Pause(ctx->control); + +if (hr == S_FALSE) { +OAFilterState pfs; +hr = IMediaControl_GetState(ctx->control, 0, &pfs); +} +if (hr != S_OK) { +av_log(avctx, AV_LOG_ERROR, "Could not run/pause graph\n"); +return AVERROR(EIO); +} +ctx->is_running = run_state; +} + +return 0; +} + static enum AVCodecID waveform_codec_id(enum AVSampleFormat sample_fmt) { switch (sample_fmt) { @@ -1317,6 +1356,7 @@ static int dshow_read_header(AVFormatContext *avctx) } } } +ctx->is_running = 0; if (ctx->device_name[VideoDevice]) { if ((r = dshow_open_device(avctx, devenum, VideoDevice, VideoSourceDevice)) < 0 || (r = dshow_add_device(avctx, VideoDevice)) < 0) { @@ -1390,6 +1430,7 @@ static int dshow_read_header(AVFormatContext *avctx) av_log(avctx, AV_LOG_ERROR, "Could not run graph (sometimes caused by a device already in use by other application)\n"); goto error; } +ctx->is_running = 1; ret = 0; @@ -1502,6 +1543,7 @@ const AVInputFormat ff_dshow_demuxer = { .read_packet= dshow_read_packet, .read_close = dshow_read_close, .get_device_list= dshow_get_device_list, +.control_message = dshow_control_message, .flags = AVFMT_NOFILE | AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK, .priv_class = &dshow_class, }; diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index 5a2691518c..bb0f76a8f2 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -331,6 +331,7 @@ struct dshow_ctx { IMediaControl *control; IMediaEvent *media_event; +int is_running; enum AVPixelFormat pixel_format; enum AVCodecID video_codec_id; -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fftools/ffplay: 240M matrix is not the same as BT.601
Can you merge my mxfdec patch? Thank you. Maybe all my oldest patches too, except XYZ patch to libopenjpeg, that is WIP, since openjpeg did not even merge yet or did a release to support that wrapper option. Listen, it is commonly known that ffplay is broken, Carl agrees. MPV is not broken and is perfect according to reference calculator here. https://res18h39.netlify.app/color I did send you a sample in my "v1" patch (this is not v2, since v1 had wrong title, so v2 would be wrong thing to do, I just superseeded patch on patchwork). But for your comfort here it is again: https://trac.ffmpeg.org/attachment/ticket/9167/2.mp4 (also read #9167). Just *use* the sample above and ffplay it without any flags and ffplay with -vf scale=in_color_matrix=bt601,format=gbrp. I do not really care about ffplay, I care about Chromium (since I work on it) and now VLC. You can carefully read those two issues that use the sample above too. https://code.videolan.org/videolan/vlc/-/issues/25651 https://code.videolan.org/videolan/vlc/-/issues/25676 As you can see from those issues I know a lot about YCbCr and read the first documents from back when ITU-R was CCI(R). I even know that BT.709 was first defined in CCIR Rec. XA/11 1986-90f, a.k.a. IWP 11/6-2108 (Canada). That is not something you can fimd on the Internet, only in ITU-R archives (wikipedia is me, I wrote it there). So, please, stop with this. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 16/35] avdevice/dshow: add config dialog command for crossbar and tv tuner
The "show config dialog" command message can now also trigger dialog boxes for the crossbar connecting pins filter the analog tuner audio / analog tuner filters. _Untested_ as I do not have either device. Signed-off-by: Diederick Niehorster --- libavdevice/dshow.c | 52 +++-- libavdevice/dshow_capture.h | 10 libavdevice/dshow_crossbar.c | 91 +++- 3 files changed, 115 insertions(+), 38 deletions(-) diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c index b3c005d3f7..d8a97797cc 100644 --- a/libavdevice/dshow.c +++ b/libavdevice/dshow.c @@ -60,6 +60,11 @@ dshow_read_close(AVFormatContext *s) struct dshow_ctx *ctx = s->priv_data; PacketList *pktl; +if (ctx->graph_builder2[VideoDevice]) +ICaptureGraphBuilder2_Release(ctx->graph_builder2[VideoDevice]); +if (ctx->graph_builder2[AudioDevice]) +ICaptureGraphBuilder2_Release(ctx->graph_builder2[AudioDevice]); + if (ctx->control) { IMediaControl_Stop(ctx->control); IMediaControl_Release(ctx->control); @@ -1040,6 +1045,7 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, av_log(avctx, AV_LOG_ERROR, "Could not create CaptureGraphBuilder2\n"); goto error; } +ctx->graph_builder2[devtype] = graph_builder2; ICaptureGraphBuilder2_SetFiltergraph(graph_builder2, graph); if (r != S_OK) { av_log(avctx, AV_LOG_ERROR, "Could not set graph for CaptureGraphBuilder2\n"); @@ -1064,9 +1070,6 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum *devenum, ret = 0; error: -if (graph_builder2 != NULL) -ICaptureGraphBuilder2_Release(graph_builder2); - if (pers_stream) IPersistStream_Release(pers_stream); @@ -1113,11 +1116,50 @@ static int dshow_control_message(AVFormatContext *avctx, int type, void *data, s } else if (dialog & 1<<2) { // crossbar_connection_dialog -// TODO +if (ctx->device_filter[devtype] && ctx->graph_builder2[devtype]) { +IAMCrossbar *cross_bar = NULL; +IBaseFilter *cross_bar_base_filter = NULL; +hr = ff_dshow_get_crossbar_and_filter(ctx->graph_builder2[devtype], ctx->device_filter[devtype], cross_bar, &cross_bar_base_filter); + +if (hr == S_OK && cross_bar_base_filter) +ff_dshow_show_filter_properties(cross_bar_base_filter, avctx); + +if (cross_bar) +IAMCrossbar_Release(cross_bar); +if (cross_bar_base_filter) +IBaseFilter_Release(cross_bar_base_filter); +} } else if (dialog & 1<<3) { // tv_tuner_dialog -// TODO +if (ctx->device_filter[devtype] && ctx->graph_builder2[devtype]) { +if (devtype == VideoDevice) { +IAMTVTuner *tv_tuner_filter = NULL; +IBaseFilter *tv_tuner_base_filter = NULL; +hr = ff_dshow_get_tvtuner_and_filter(ctx->graph_builder2[devtype], ctx->device_filter[devtype], tv_tuner_filter, tv_tuner_base_filter); + +if (hr == S_OK && tv_tuner_base_filter) +ff_dshow_show_filter_properties(tv_tuner_base_filter, avctx); + +if (tv_tuner_filter) +IAMTVTuner_Release(tv_tuner_filter); +if (tv_tuner_base_filter) +IBaseFilter_Release(tv_tuner_base_filter); +} +else { +IAMAudioInputMixer *tv_audio_filter = NULL; +IBaseFilter *tv_audio_base_filter = NULL; +hr = ff_dshow_get_audiomixer_and_filter(ctx->graph_builder2[devtype], ctx->device_filter[devtype], tv_audio_filter, tv_audio_base_filter); + +if (hr == S_OK && tv_audio_base_filter) +ff_dshow_show_filter_properties(tv_audio_base_filter, avctx); + +if (tv_audio_filter) +IAMAudioInputMixer_Release(tv_audio_filter); +if (tv_audio_base_filter) +IBaseFilter_Release(tv_audio_base_filter); +} +} } break; } diff --git a/libavdevice/dshow_capture.h b/libavdevice/dshow_capture.h index bb0f76a8f2..127695a86b 100644 --- a/libavdevice/dshow_capture.h +++ b/libavdevice/dshow_capture.h @@ -318,6 +318,7 @@ struct dshow_ctx { IPin*device_pin[2]; DShowFilter *capture_filter[2]; DShowPin*capture_pin[2]; +ICaptureGraphBuilder2 *graph_builder2[2]; HANDLE mutex; HANDLE event[2]; /* event[0] is set by DirectShow @@ -352,6 +353,15 @@ struct dshow_ctx { HRESULT ff_dshow_try_setup_crossbar_options(ICaptureGraphBuilder2 *graph_builder2, IBaseFilter *device_filter, enum dshowDeviceType devtype, AVFormat
Re: [FFmpeg-devel] [PATCH 21/35] avdevice: capabilities API details no longer public
On 6/7/2021 8:04 PM, Diederick Niehorster wrote: NB: will break build, makes needed corresponding changes to avformat. Signed-off-by: Diederick Niehorster --- libavdevice/avdevice.c | 34 -- libavdevice/avdevice.h | 42 +- libavdevice/internal.h | 33 + libavdevice/version.h | 2 +- 4 files changed, 63 insertions(+), 48 deletions(-) diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index d73d36e1dd..b521516ff5 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -96,51 +96,57 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, enum AVDevToA return s->control_message_cb(s, type, data, data_size); } -int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s, +int avdevice_capabilities_create(void** opaque, AVFormatContext *s, AVDictionary **device_options) { int ret; +AVDeviceCapabilitiesQuery *caps = NULL; av_assert0(s); -av_assert0(caps); +av_assert0(opaque); av_assert0(s->iformat || s->oformat); +*opaque = NULL; if ((s->oformat && !s->oformat->create_device_capabilities) || (s->iformat && !s->iformat->create_device_capabilities)) { -*caps = NULL; return AVERROR(ENOSYS); } -*caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); -if (!(*caps)) +*opaque = caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); +if (!caps) return AVERROR(ENOMEM); -(*caps)->device_context = s; +caps->device_context = s; if (((ret = av_opt_set_dict(s->priv_data, device_options)) < 0)) goto fail; if (s->iformat) { -if ((ret = s->iformat->create_device_capabilities(s, *caps)) < 0) +if ((ret = s->iformat->create_device_capabilities(s, caps)) < 0) goto fail; } else { -if ((ret = s->oformat->create_device_capabilities(s, *caps)) < 0) +if ((ret = s->oformat->create_device_capabilities(s, caps)) < 0) goto fail; } -av_opt_set_defaults(*caps); +av_opt_set_defaults(caps); return 0; fail: av_freep(caps); +*opaque = NULL; return ret; } -void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, AVFormatContext *s) +void avdevice_capabilities_free(void **opaque, AVFormatContext *s) { -if (!s || !caps || !(*caps)) +AVDeviceCapabilitiesQuery *caps; +if (!s || !opaque) +return; +caps = *(AVDeviceCapabilitiesQuery **) opaque; +if (!caps) return; av_assert0(s->iformat || s->oformat); if (s->iformat) { if (s->iformat->free_device_capabilities) -s->iformat->free_device_capabilities(s, *caps); +s->iformat->free_device_capabilities(s, caps); } else { if (s->oformat->free_device_capabilities) -s->oformat->free_device_capabilities(s, *caps); +s->oformat->free_device_capabilities(s, caps); } -av_freep(caps); +av_freep(opaque); } int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index 7c5e77df00..389ac0b5f2 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -401,40 +401,15 @@ int avdevice_dev_to_app_control_message(struct AVFormatContext *s, * @endcode */ -/** - * Structure describes device capabilities. - * - * It is used by devices in conjunction with av_device_capabilities AVOption table - * to implement capabilities probing API based on AVOption API. Should not be used directly. - */ -typedef struct AVDeviceCapabilitiesQuery { -const AVClass *av_class; -AVFormatContext *device_context; -enum AVCodecID codec; -enum AVSampleFormat sample_format; -enum AVPixelFormat pixel_format; -int sample_rate; -int channels; -int64_t channel_layout; -int window_width; -int window_height; -int frame_width; -int frame_height; -AVRational fps; -} AVDeviceCapabilitiesQuery; Instead of removing the struct altogether, just keep its typedef here. That way the functions below and any libavformat struct can still use AVDeviceCapabilitiesQuery as an incomplete type. So in short: typedef struct AVDeviceCapabilitiesQuery AVDeviceCapabilitiesQuery; This is nonetheless technically an API break, but since nothing used this stuff, i guess we could make an exception. Not sure what other developers think. I assume you intend to also undo the deprecation? - -/** - * AVOption table used by devices to implement device capabilities API. Should not be used by a user. - */ -extern const AVOption av_device_capabilities[]; - /** * Initialize capabilities probing API based on AVOption API. * * avdevice_capabilities_free() must be called when query capabilities API is * not u
Re: [FFmpeg-devel] [PATCH 01/35] avdevice/dshow: implement option to use device video timestamps
Who knows what BS code "TODO figure out math. For now just drop them." means? Is PTS of the mentioned there can be even theoretically valid or not? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 10/35] fftools: provide media type info for devices
fftools now print info about what media type(s), if any, are provided by sink and source avdevices. Furthermore, printing is done with av_log instead of printf as the latter doesn't handle characters in some device names correctly (e.g. "Microphone Array (Intel® Smart Sound Technology (Intel® SST))" is printed incorrectly). Signed-off-by: Diederick Niehorster --- fftools/cmdutils.c | 41 +++-- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 4148285971..b7018b7dab 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -2205,9 +2205,36 @@ double get_rotation(AVStream *st) } #if CONFIG_AVDEVICE +static void print_device_list(AVDeviceInfoList *device_list) +{ +int i, error_level = av_log_get_level(); +// reset log level such that info messages are displayed +// we need to use av_log instead of printf as it handles +// unicode better +av_log_set_level(AV_LOG_INFO); +// print devices +for (i = 0; i < device_list->nb_devices; i++) { +av_log(NULL, AV_LOG_INFO, "%s %s [%s]", device_list->default_device == i ? "*" : " ", +device_list->devices[i]->device_name, device_list->devices[i]->device_description); +if (device_list->devices[i]->nb_media_types > 0 && device_list->devices[i]->media_types) { +const char* media_type = av_get_media_type_string(device_list->devices[i]->media_types[0]); +av_log(NULL, AV_LOG_INFO, " (%s", media_type ? media_type : "unknown"); +for (int i = 1; i < device_list->devices[i]->nb_media_types; ++i) { +media_type = av_get_media_type_string(device_list->devices[i]->media_types[i]); +av_log(NULL, AV_LOG_INFO, ", %s", media_type ? media_type : "unknown"); +} +av_log(NULL, AV_LOG_INFO, ")"); +} else { +av_log(NULL, AV_LOG_INFO, " (none)"); +} +av_log(NULL, AV_LOG_INFO, "\n"); +} + +av_log_set_level(error_level); +} static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts) { -int ret, i; +int ret; AVDeviceInfoList *device_list = NULL; if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category)) @@ -2225,10 +2252,7 @@ static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts) goto fail; } -for (i = 0; i < device_list->nb_devices; i++) { -printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", - device_list->devices[i]->device_name, device_list->devices[i]->device_description); -} +print_device_list(device_list); fail: avdevice_free_list_devices(&device_list); @@ -2237,7 +2261,7 @@ static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts) static int print_device_sinks(const AVOutputFormat *fmt, AVDictionary *opts) { -int ret, i; +int ret; AVDeviceInfoList *device_list = NULL; if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category)) @@ -2255,10 +2279,7 @@ static int print_device_sinks(const AVOutputFormat *fmt, AVDictionary *opts) goto fail; } -for (i = 0; i < device_list->nb_devices; i++) { -printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", - device_list->devices[i]->device_name, device_list->devices[i]->device_description); -} +print_device_list(device_list); fail: avdevice_free_list_devices(&device_list); -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 24/35] avutil/opt: AVOptionRange gains is_set field.
Actually it is commonly understood all over the world that limited range is the default when not present. All video in the world except Dolby Vision profile 5 (if using IPTPQc2) is limited range. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4] avformat/mpegtsenc: enable muxing of ARIB captions
On Tue, Jun 8, 2021 at 2:28 AM Jan Ekström wrote: > > On Mon, Jun 7, 2021 at 8:09 PM Jan Ekström wrote: > > > > From: zheng qian > > > > Writes a general ARIB stream identifier descriptor, as well > > as a data component descriptor which also includes a > > pre-defined additional_arib_caption_info structure. > > > > Signed-off-by: zheng qian > > --- > > For the record, I did and do think that counting and limiting the > amount of ARIB caption streams per program would be technically more > correct, but since: > 1. In most cases you will only have a single stream in your input of a > given profile (as multi-language subtitles are supposed to be handled > in the same PID). > 2. it seems like a pain as mpegtsenc does not have existing > infrastructure for these sorts of checks as nothing else is limited in > stream count per-program. > > I decided that utilizing the default identifier (0x30, 0x87) for all > such streams is Good Enough for an initial implementation. For Profile > A streams values are available until 0x37, but effectively only > permitted for secondary renditions (multi-view etc). Profile C only > permits a single identifier - 0x87. > > As changes compared to v3: > > 1. I have split the descriptor writing into its own function, as > mpegts_write_pmt is already long enough. > 2. Checked references and adjusted some comments as well as the commit > message. > > Jan LGTM. Regards, zheng qian > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 24/35] avutil/opt: AVOptionRange gains is_set field.
Valerii Zapodovnikov: > Actually it is commonly understood all over the world that limited range is > the default when not present. All video in the world except Dolby Vision > profile 5 (if using IPTPQc2) is limited range. This has absolutely nothing to do with full/limited range, but rather whether the AVOptionRange contains an interval or a single value. (Not that I know why this needs to be set explicitly and not implicitly via is_range = value_min < value_max.) - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 21/35] avdevice: capabilities API details no longer public
Diederick Niehorster: > NB: will break build, makes needed corresponding changes to avformat. > Then said changes should be part of this patch. Patches should be logically self-contained and atomic; this is not the same as splitting by file/library. But that is a moot point: James already told you a better way to fix this. > Signed-off-by: Diederick Niehorster > --- > libavdevice/avdevice.c | 34 -- > libavdevice/avdevice.h | 42 +- > libavdevice/internal.h | 33 + > libavdevice/version.h | 2 +- > 4 files changed, 63 insertions(+), 48 deletions(-) > > diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c > index d73d36e1dd..b521516ff5 100644 > --- a/libavdevice/avdevice.c > +++ b/libavdevice/avdevice.c > @@ -96,51 +96,57 @@ int avdevice_dev_to_app_control_message(struct > AVFormatContext *s, enum AVDevToA > return s->control_message_cb(s, type, data, data_size); > } > > -int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, > AVFormatContext *s, > +int avdevice_capabilities_create(void** opaque, AVFormatContext *s, > AVDictionary **device_options) > { > int ret; > +AVDeviceCapabilitiesQuery *caps = NULL; > av_assert0(s); > -av_assert0(caps); > +av_assert0(opaque); > av_assert0(s->iformat || s->oformat); > +*opaque = NULL; > if ((s->oformat && !s->oformat->create_device_capabilities) || > (s->iformat && !s->iformat->create_device_capabilities)) { > -*caps = NULL; > return AVERROR(ENOSYS); > } > -*caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); > -if (!(*caps)) > +*opaque = caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); > +if (!caps) > return AVERROR(ENOMEM); > -(*caps)->device_context = s; > +caps->device_context = s; > if (((ret = av_opt_set_dict(s->priv_data, device_options)) < 0)) > goto fail; > if (s->iformat) { > -if ((ret = s->iformat->create_device_capabilities(s, *caps)) < 0) > +if ((ret = s->iformat->create_device_capabilities(s, caps)) < 0) > goto fail; > } else { > -if ((ret = s->oformat->create_device_capabilities(s, *caps)) < 0) > +if ((ret = s->oformat->create_device_capabilities(s, caps)) < 0) > goto fail; > } > -av_opt_set_defaults(*caps); > +av_opt_set_defaults(caps); > return 0; >fail: > av_freep(caps); > +*opaque = NULL; > return ret; > } > > -void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, > AVFormatContext *s) > +void avdevice_capabilities_free(void **opaque, AVFormatContext *s) > { > -if (!s || !caps || !(*caps)) > +AVDeviceCapabilitiesQuery *caps; > +if (!s || !opaque) > +return; > +caps = *(AVDeviceCapabilitiesQuery **) opaque; > +if (!caps) > return; > av_assert0(s->iformat || s->oformat); > if (s->iformat) { > if (s->iformat->free_device_capabilities) > -s->iformat->free_device_capabilities(s, *caps); > +s->iformat->free_device_capabilities(s, caps); > } else { > if (s->oformat->free_device_capabilities) > -s->oformat->free_device_capabilities(s, *caps); > +s->oformat->free_device_capabilities(s, caps); > } > -av_freep(caps); > +av_freep(opaque); > } > > int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList **device_list) > diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h > index 7c5e77df00..389ac0b5f2 100644 > --- a/libavdevice/avdevice.h > +++ b/libavdevice/avdevice.h > @@ -401,40 +401,15 @@ int avdevice_dev_to_app_control_message(struct > AVFormatContext *s, > * @endcode > */ > > -/** > - * Structure describes device capabilities. > - * > - * It is used by devices in conjunction with av_device_capabilities AVOption > table > - * to implement capabilities probing API based on AVOption API. Should not > be used directly. > - */ > -typedef struct AVDeviceCapabilitiesQuery { > -const AVClass *av_class; > -AVFormatContext *device_context; > -enum AVCodecID codec; > -enum AVSampleFormat sample_format; > -enum AVPixelFormat pixel_format; > -int sample_rate; > -int channels; > -int64_t channel_layout; > -int window_width; > -int window_height; > -int frame_width; > -int frame_height; > -AVRational fps; > -} AVDeviceCapabilitiesQuery; > - > -/** > - * AVOption table used by devices to implement device capabilities API. > Should not be used by a user. > - */ > -extern const AVOption av_device_capabilities[]; > - > /** > * Initialize capabilities probing API based on AVOption API. > * > * avdevice_capabilities_free() must be called when query capabilities API is > * not used anymore. > - * > - * @param[out] caps Device capabilities data.
Re: [FFmpeg-devel] libavcodec: r12b decoder
Von meinem iPhone gesendet > Am 07.06.2021 um 12:09 schrieb Dennis Fleurbaaij : > > Pulled master and re-applied to resolve version update conflict > R12B is a format used by BlackMagic DeckLink cards How does the card produce avi files / why are you adding a fourcc? Please elaborate, Carl Eugen ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 24/35] avutil/opt: AVOptionRange gains is_set field.
Ah, yes, that is AVColorRange, sorry. :( Haha. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 21/35] avdevice: capabilities API details no longer public
James Almer: > On 6/7/2021 8:04 PM, Diederick Niehorster wrote: >> NB: will break build, makes needed corresponding changes to avformat. >> >> Signed-off-by: Diederick Niehorster >> --- >> libavdevice/avdevice.c | 34 -- >> libavdevice/avdevice.h | 42 +- >> libavdevice/internal.h | 33 + >> libavdevice/version.h | 2 +- >> 4 files changed, 63 insertions(+), 48 deletions(-) >> >> diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c >> index d73d36e1dd..b521516ff5 100644 >> --- a/libavdevice/avdevice.c >> +++ b/libavdevice/avdevice.c >> @@ -96,51 +96,57 @@ int avdevice_dev_to_app_control_message(struct >> AVFormatContext *s, enum AVDevToA >> return s->control_message_cb(s, type, data, data_size); >> } >> -int avdevice_capabilities_create(AVDeviceCapabilitiesQuery **caps, >> AVFormatContext *s, >> +int avdevice_capabilities_create(void** opaque, AVFormatContext *s, >> AVDictionary **device_options) >> { >> int ret; >> + AVDeviceCapabilitiesQuery *caps = NULL; >> av_assert0(s); >> - av_assert0(caps); >> + av_assert0(opaque); >> av_assert0(s->iformat || s->oformat); >> + *opaque = NULL; >> if ((s->oformat && !s->oformat->create_device_capabilities) || >> (s->iformat && !s->iformat->create_device_capabilities)) { >> - *caps = NULL; >> return AVERROR(ENOSYS); >> } >> - *caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); >> - if (!(*caps)) >> + *opaque = caps = av_mallocz(sizeof(AVDeviceCapabilitiesQuery)); >> + if (!caps) >> return AVERROR(ENOMEM); >> - (*caps)->device_context = s; >> + caps->device_context = s; >> if (((ret = av_opt_set_dict(s->priv_data, device_options)) < 0)) >> goto fail; >> if (s->iformat) { >> - if ((ret = s->iformat->create_device_capabilities(s, *caps)) >> < 0) >> + if ((ret = s->iformat->create_device_capabilities(s, caps)) < 0) >> goto fail; >> } else { >> - if ((ret = s->oformat->create_device_capabilities(s, *caps)) >> < 0) >> + if ((ret = s->oformat->create_device_capabilities(s, caps)) < 0) >> goto fail; >> } >> - av_opt_set_defaults(*caps); >> + av_opt_set_defaults(caps); >> return 0; >> fail: >> av_freep(caps); >> + *opaque = NULL; >> return ret; >> } >> -void avdevice_capabilities_free(AVDeviceCapabilitiesQuery **caps, >> AVFormatContext *s) >> +void avdevice_capabilities_free(void **opaque, AVFormatContext *s) >> { >> - if (!s || !caps || !(*caps)) >> + AVDeviceCapabilitiesQuery *caps; >> + if (!s || !opaque) >> + return; >> + caps = *(AVDeviceCapabilitiesQuery **) opaque; >> + if (!caps) >> return; >> av_assert0(s->iformat || s->oformat); >> if (s->iformat) { >> if (s->iformat->free_device_capabilities) >> - s->iformat->free_device_capabilities(s, *caps); >> + s->iformat->free_device_capabilities(s, caps); >> } else { >> if (s->oformat->free_device_capabilities) >> - s->oformat->free_device_capabilities(s, *caps); >> + s->oformat->free_device_capabilities(s, caps); >> } >> - av_freep(caps); >> + av_freep(opaque); >> } >> int avdevice_list_devices(AVFormatContext *s, AVDeviceInfoList >> **device_list) >> diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h >> index 7c5e77df00..389ac0b5f2 100644 >> --- a/libavdevice/avdevice.h >> +++ b/libavdevice/avdevice.h >> @@ -401,40 +401,15 @@ int avdevice_dev_to_app_control_message(struct >> AVFormatContext *s, >> * @endcode >> */ >> -/** >> - * Structure describes device capabilities. >> - * >> - * It is used by devices in conjunction with av_device_capabilities >> AVOption table >> - * to implement capabilities probing API based on AVOption API. >> Should not be used directly. >> - */ >> -typedef struct AVDeviceCapabilitiesQuery { >> - const AVClass *av_class; >> - AVFormatContext *device_context; >> - enum AVCodecID codec; >> - enum AVSampleFormat sample_format; >> - enum AVPixelFormat pixel_format; >> - int sample_rate; >> - int channels; >> - int64_t channel_layout; >> - int window_width; >> - int window_height; >> - int frame_width; >> - int frame_height; >> - AVRational fps; >> -} AVDeviceCapabilitiesQuery; > > Instead of removing the struct altogether, just keep its typedef here. > That way the functions below and any libavformat struct can still use > AVDeviceCapabilitiesQuery as an incomplete type. > > So in short: > > typedef struct AVDeviceCapabilitiesQuery AVDeviceCapabilitiesQuery; > > This is nonetheless technically an API break, but since nothing used > this stuff, i guess we could make an exception. Not sure what other > developers think. > See
Re: [FFmpeg-devel] [PATCH 05/35] avdevice/dshow: set no-seek flags
Actually I do not know how well will this work. Did you ever play any stream? Even if you play it without forcing seeking you are allowed to search forth due to how latency works. That problem with latency was only fixed in CMAF. ONE must to accelerate decoding forward in time to get low latency. Now hardware devices are different. But still, what about pause? What about seeking in the end which was BTW broken: see in https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210604062818.2099-1-val.zapod...@gmail.com/ I mean, I agree this should be the default. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] fftools/ffplay: 240M matrix is not the same as BT.601
I'll just chime in and say: FIXME comments aren't that helpful. It would be more helpful to av_log when you detect you've hit an unsupported situation. As for SMPTE 240M vs BT.601 Y'CbCr matrices: yes, they're different. But SDL doesn't support SMPTE 240M. It only supports: SDL_YUV_CONVERSION_JPEG, /**< Full range JPEG */ SDL_YUV_CONVERSION_BT601, /**< BT.601 (the default) */ SDL_YUV_CONVERSION_BT709, /**< BT.709 */ (and automatic, but that's just BT.601 + BT.709) It's probably better to fall back to using BT.709 matrix for SMPTE 240M (with a warning log) since BT.709 is closer to SMPTE 240M than BT.601 is. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH]avfilter: add Intel IPP library based x86 optimized video scaling filter
On Mon, 7 Jun 2021, at 23:49, Jan Ekström wrote: > If you just go without any rhetoric and just look at what "nonfree" > > We can start with the history of the option - originally added in > 3fe142e2555ec8b527f2ff4cc517c015a114e91a (Jan, 2008) - to denote that > due to the libamrnb/libamrwb wrappers being based on reference code, > > Then if we look at what the nonfree option is currently utilized for: > > capture card hardware integration (1): > decklink > > open source that just happens to have incompatible licensing with > regards to GPL (3): > libfdk_aac > openssl > libtls > > (old) CUDA SDK things (3): > cuda_nvcc > cuda_sdk > libnpp > > Thus looking at both historical point of that option, as well as its > current uses, I don't see there's any reason to include a wrapper for > a closed source scaling library that does not benefit the project (it > re-implements already existing capability). I very much approve of Jan's email who has given a good summary, and whose opinion I share. jb -- Jean-Baptiste Kempf - President +33 672 704 734 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 1/2] hwcontext_vulkan: dynamically load functions
> Apr 29, 2021, 03:52 by d...@lynne.ee: > > > This patch allows for alternative loader implementations. > > > > Patch attached. > > > > Forgot to fix a flag, v2 attached. Hi Lynne: I tried the following command: "ffmpeg -init_hw_device vulkan=vul:0 -filter_hw_device vul -i 1080p.264 -vf "hwupload=extra_hw_frames=16,scale_vulkan=w=1920:h1080" -f null" It report a segmentation fault at https://github.com/FFmpeg/FFmpeg/blob/282b9f4cba7ca361c43ac9f94031a43109df0a4f/libavutil/hwcontext_vulkan.c#L1018 The function pointer vk->CreateCommandPool is NULL. I build on ffmpeg master. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] ffbuild/common.mak: explicitly pass windres preprocessor args
Binutils 2.36 no longer supports bundling args with the preprocessor option. --- ffbuild/common.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffbuild/common.mak b/ffbuild/common.mak index 32f5b997b5..9fbbf89130 100644 --- a/ffbuild/common.mak +++ b/ffbuild/common.mak @@ -90,7 +90,7 @@ COMPILE_MSA = $(call COMPILE,CC,MSAFLAGS) -$(if $(ASMSTRIPFLAGS), $(STRIP) $(ASMSTRIPFLAGS) $@) %.o: %.rc - $(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES) -E -xc-header -DRC_INVOKED $(CC_DEPFLAGS)" -o $@ $< + $(WINDRES) $(IFLAGS) --preprocessor "$(DEPWINDRES)" $(foreach ARG,-E -xc-header -DRC_INVOKED $(CC_DEPFLAGS),--preprocessor-arg "$(ARG)") -o $@ $< %.i: %.c $(CC) $(CCFLAGS) $(CC_E) $< -- 2.31.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 21/35] avdevice: capabilities API details no longer public
On Tue, Jun 8, 2021 at 1:26 AM James Almer wrote: > On 6/7/2021 8:04 PM, Diederick Niehorster wrote: > Instead of removing the struct altogether, just keep its typedef here. > That way the functions below and any libavformat struct can still use > AVDeviceCapabilitiesQuery as an incomplete type. > > So in short: > > typedef struct AVDeviceCapabilitiesQuery AVDeviceCapabilitiesQuery; > Will do. > This is nonetheless technically an API break, but since nothing used > this stuff, i guess we could make an exception. Not sure what other > developers think. > That was my thinking, and I see Andreas agrees with this too, good. > > I assume you intend to also undo the deprecation? > Yes, thats patch 19/35 in this series. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 21/35] avdevice: capabilities API details no longer public
On Tue, Jun 8, 2021 at 1:54 AM Andreas Rheinhardt < andreas.rheinha...@outlook.com> wrote: > Diederick Niehorster: > > NB: will break build, makes needed corresponding changes to avformat. > > > > Then said changes should be part of this patch. Patches should be > logically self-contained and atomic; this is not the same as splitting > by file/library. > > But that is a moot point: James already told you a better way to fix this. > Made sense. But indeed, James' way of doing it obviates that next patch changing avformat.h > > --- a/libavdevice/internal.h > > +++ b/libavdevice/internal.h > > We prefer the order libavutil-libavcodec-libavformat (the reverse of > linking order). > fixed. > > + * AVOption table used by devices to implement device capabilities API. > Should not be used by a user. > > That last part is superfluous, as (external) users by definition have no > business looking into internal.h. > Ah yes, copy paste.. Fixed. > > + */ > > +extern const AVOption av_device_capabilities[]; > > Don't use this name: av_* is our namespace for public symbols. Our > linker script makes sure that all symbols that start with av_* are > exported; whether they are in a public header is irrelevant. > Not exporting the symbol in the first place also solves the problem of > users using it despite it not being part of the API. > (I btw don't know whether said linker script is used on Windows.) > I changed it to a ff_ prefix. Is that correct? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avfilter/vf_overlay_cuda: support expression of x y position
Signed-off-by: Steven Liu --- libavfilter/vf_overlay_cuda.c | 129 +++--- 1 file changed, 120 insertions(+), 9 deletions(-) diff --git a/libavfilter/vf_overlay_cuda.c b/libavfilter/vf_overlay_cuda.c index 8a4d2c4312..9980b0137e 100644 --- a/libavfilter/vf_overlay_cuda.c +++ b/libavfilter/vf_overlay_cuda.c @@ -30,6 +30,7 @@ #include "libavutil/hwcontext.h" #include "libavutil/hwcontext_cuda_internal.h" #include "libavutil/cuda_check.h" +#include "libavutil/eval.h" #include "avfilter.h" #include "framesync.h" @@ -41,6 +42,9 @@ #define BLOCK_X 32 #define BLOCK_Y 16 +#define MAIN0 +#define OVERLAY 1 + static const enum AVPixelFormat supported_main_formats[] = { AV_PIX_FMT_NV12, AV_PIX_FMT_YUV420P, @@ -54,6 +58,32 @@ static const enum AVPixelFormat supported_overlay_formats[] = { AV_PIX_FMT_NONE, }; +enum var_name { +VAR_MAIN_W,VAR_MW, +VAR_MAIN_H,VAR_MH, +VAR_OVERLAY_W, VAR_OW, +VAR_OVERLAY_H, VAR_OH, +VAR_X, +VAR_Y, +VAR_N, +VAR_POS, +VAR_T, +VAR_VARS_NB +}; + +static const char *const var_names[] = { +"main_w","W", ///< width of the mainvideo +"main_h","H", ///< height of the mainvideo +"overlay_w", "w", ///< width of the overlay video +"overlay_h", "h", ///< height of the overlay video +"x", +"y", +"n",///< number of frame +"pos", ///< position in the file +"t",///< timestamp expressed in seconds +NULL +}; + /** * OverlayCUDAContext */ @@ -76,6 +106,10 @@ typedef struct OverlayCUDAContext { int x_position; int y_position; +double var_values[VAR_VARS_NB]; +char *x_expr, *y_expr; + +AVExpr *x_pexpr, *y_pexpr; } OverlayCUDAContext; /** @@ -89,6 +123,49 @@ static int format_is_supported(const enum AVPixelFormat formats[], enum AVPixelF return 0; } +static inline int normalize_xy(double d, int chroma_sub) +{ +if (isnan(d)) +return INT_MAX; +return (int)d & ~((1 << chroma_sub) - 1); +} + +static void eval_expr(AVFilterContext *ctx) +{ +OverlayCUDAContext *s = ctx->priv; + +s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, NULL); +s->var_values[VAR_Y] = av_expr_eval(s->y_pexpr, s->var_values, NULL); +/* It is necessary if x is expressed from y */ +s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, NULL); + +s->x_position = normalize_xy(s->var_values[VAR_X], 1); + +/* the cuda pixel format is using hwaccel, y_position unnecessary normalize y */ +s->y_position = s->var_values[VAR_Y]; +} + +static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void *log_ctx) +{ +int ret; +AVExpr *old = NULL; + +if (*pexpr) +old = *pexpr; +ret = av_expr_parse(pexpr, expr, var_names, +NULL, NULL, NULL, NULL, 0, log_ctx); +if (ret < 0) { +av_log(log_ctx, AV_LOG_ERROR, + "Error when evaluating the expression '%s' for %s\n", + expr, option); +*pexpr = old; +return ret; +} + +av_expr_free(old); +return 0; +} + /** * Helper checks if we can process main and overlay pixel formats */ @@ -151,10 +228,8 @@ static int overlay_cuda_blend(FFFrameSync *fs) CUcontext dummy, cuda_ctx = ctx->hwctx->cuda_ctx; AVFrame *input_main, *input_overlay; -const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); -int hsub = pix_desc->log2_chroma_w; -int vsub = pix_desc->log2_chroma_h; +int pos = 0; ctx->cu_ctx = cuda_ctx; @@ -183,8 +258,17 @@ static int overlay_cuda_blend(FFFrameSync *fs) return ret; } -ctx->x_position &= (1 << hsub) - 1; -ctx->y_position &= (1 << vsub) - 1; +pos = input_main->pkt_pos; +ctx->var_values[VAR_N] = inlink->frame_count_out; +ctx->var_values[VAR_T] = input_main->pts == AV_NOPTS_VALUE ? +NAN : input_main->pts * av_q2d(inlink->time_base); +ctx->var_values[VAR_POS] = pos == -1 ? NAN : pos; +ctx->var_values[VAR_OVERLAY_W] = ctx->var_values[VAR_OW] = input_overlay->width; +ctx->var_values[VAR_OVERLAY_H] = ctx->var_values[VAR_OH] = input_overlay->height; +ctx->var_values[VAR_MAIN_W ] = ctx->var_values[VAR_MW] = input_main->width; +ctx->var_values[VAR_MAIN_H ] = ctx->var_values[VAR_MH] = input_main->height; + +eval_expr(avctx); // overlay first plane @@ -238,6 +322,32 @@ static int overlay_cuda_blend(FFFrameSync *fs) return ff_filter_frame(outlink, input_main); } +static int config_input_overlay(AVFilterLink *inlink) +{ +AVFilterContext *ctx = inlink->dst; +OverlayCUDAContext *s = inlink->dst->priv; +int ret; + + +/* Finish the configuration by evaluating the expressions + now when both inputs are configured. */ +s->var_values[VAR_MAIN_W ] = s->var_values[VAR_MW] = ctx->inputs[MAIN ]->w; +s->var_values[V
Re: [FFmpeg-devel] [PATCH 24/35] avutil/opt: AVOptionRange gains is_set field.
On Tue, Jun 8, 2021 at 1:45 AM Andreas Rheinhardt < andreas.rheinha...@outlook.com> wrote: > This has absolutely nothing to do with full/limited range, but rather > whether the AVOptionRange contains an interval or a single value. > (Not that I know why this needs to be set explicitly and not implicitly > via is_range = value_min < value_max.) > Yes, the is_range field seems superfluous, but its already there. What are your thoughts on the is_set field? For usage example, see patch device_get_capabilities.c in patch 32/35 in this series. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 01/35] avdevice/dshow: implement option to use device video timestamps
On Tue, Jun 8, 2021 at 1:29 AM Valerii Zapodovnikov wrote: > Who knows what BS code "TODO figure out math. For now just drop them." > means? Is PTS of the mentioned there can be even theoretically valid or > not? > No, I don't know. I am guessing it refers to wraparound? I also don't understand why a negative time would lead to a large positive value, since a signed integer is used. So i just left this intact. Without a test case/device producing this, there's little that can be done i guess. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 05/35] avdevice/dshow: set no-seek flags
On Tue, Jun 8, 2021 at 2:13 AM Valerii Zapodovnikov wrote: > Actually I do not know how well will this work. Did you ever play any > stream? Even if you play it without forcing seeking you are allowed to > search forth due to how latency works. That problem with latency was only > fixed in CMAF. ONE must to accelerate decoding forward in time to get low > latency. > > Now hardware devices are different. But still, what about pause? What about > seeking in the end which was BTW broken: see in > > https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210604062818.2099-1-val.zapod...@gmail.com/ > > I mean, I agree this should be the default. > In its current state, dshow (and from a quick look) many other devices do not support any seeking in either direction. So i think they should be properly flagged as such, at least to get a meaningful error when attempting to seek. By the way, despite using git send-email to send the whole series at once, it seems that they didn't end up in a nice thread (even though headers with in-reply-to were correct), nor did patchworks pick up all the patches (it missed 2/35 [and 5/35], so only attempted to build the first). What could be the issue here, should i throttle send-email somehow for instance? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [discussion] AVOptionRange fields
FWIW, On Sat, Jun 5, 2021 at 11:36 PM Diederick C. Niehorster wrote: > When implementing the avdevice capabilities API, I have run into three > things regarding the AVOptionRange fields (libavutil/opt.h, lines > 310-328) > > 1. an enum AVOptionType field "type" should be added. Else user cannot > know how to interpret the returned value(s), which are all doubles. > NB: for the avdevice capabilities API, option type is an > implementation detail, and cannot be queried by the user. > I turned out to be wrong on this one, the option itself is queryable when the option range is queryable, of course... > 2. a field "is_set" should be added. When querying a range of formats > of an avdevice, sometimes for a given format the queried option is not > available. This is not an error as the user is asking for a valid > capability, it just doesn't always apply to all the matching formats > of the device. This is now communicated through a special value (like > 0 or -1), but that is not ideal. an is_set field would alleviate the > use of special values. > Added in https://ffmpeg.org/pipermail/ffmpeg-devel/2021-June/281123.html > 3. the component_min, component_max fields should be documented > better. "Value's component range" is not informative and the only use > of it in the codebase (av_opt_query_ranges_default() in opt.c, lines > 1848--1918 or the original commit adding it, a8e0d51b, does not help > elucidate what its for). for e.g. an fps, the value range would be > from min_fps to max_fps. What would the associated component range > (min/max) be? > This remains open. Cheers, Dee ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".