Re: [FFmpeg-devel] [PATCH] libavcodec: add bit-rate support to RoQ video encoder
On Thu, Jan 25, 2024 at 1:27 AM Tomas Härdin wrote: > tor 2024-01-25 klockan 01:09 +0300 skrev Victor Luchitz: > > In our case, the machine we're targeting (the Sega 32X) has only > > 256KB > > of RAM. Even more modern consoles such as XBOX or even PS3 didn't > > have enough RAM to hold an entire CD-ROM.. > > > > We also have to be concerned about how fast we can move data to the > > main CPU. Say you make the first frame BIG to make it look its best, > > then > > compensate with much smaller delta frames... is the first frame too > > much > > data to move to the CPU quick enough? Well, maybe not an issue for > > the > > first frame, but definitely an issue for keyframes in the middle of > > the > > stream. > > Ah, that makes a lot more sense. Yeah I can see that being an issue. > And decoding time probably depends on packet size as well, so even if > you could move data around in advance, this still doesn't help that > keyframe decode any faster. I've seen similar behavior with JPEG2000 > where decode time scales linearly with bitrate (plus a fixed overhead). > > One thing that strikes me is if you're only aiming for linear playback > then you can set the GOP size large enough that the encoder is never > forced to insert a keyframe. > > I think my main issue then comes down to the qscale search being way > too slow, especially the fact that it can effectively hang. I would > suggest a binary search using the heuristic I derived for the first > split, or something similar. Searching between 1 and 1 seems > excessive in most cases. It should be possible to box that interval in > quickly, again using the heuristic. > Alright, we'll look into it, thanks! > > /Tomas > ___ > 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". > -- Best regards, Victor Luchitz ___ 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 v2 1/2] avcodec/s302m: enable non-PCM decoding
Set up framework for non-PCM decoding in-place and add support for Dolby-E decoding. Useful for direct transcoding of non-PCM audio in live inputs. --- configure | 1 + doc/decoders.texi | 40 +++ libavcodec/s302m.c | 596 + 3 files changed, 530 insertions(+), 107 deletions(-) v2: switch to pointer for non-pcm sync search use intreadwrite macro for writing frame data remove unneeded free of non-pcm dec opts diff --git a/configure b/configure index 21663000f8..4d7cd83247 100755 --- a/configure +++ b/configure @@ -2980,6 +2980,7 @@ rv20_decoder_select="h263_decoder" rv20_encoder_select="h263_encoder" rv30_decoder_select="golomb h264pred h264qpel mpegvideodec rv34dsp" rv40_decoder_select="golomb h264pred h264qpel mpegvideodec rv34dsp" +s302m_decoder_select="dolby_e_decoder" screenpresso_decoder_deps="zlib" shorten_decoder_select="bswapdsp" sipr_decoder_select="lsp" diff --git a/doc/decoders.texi b/doc/decoders.texi index 293c82c2ba..9f85c876bf 100644 --- a/doc/decoders.texi +++ b/doc/decoders.texi @@ -347,6 +347,46 @@ configuration. You need to explicitly configure the build with An FFmpeg native decoder for Opus exists, so users can decode Opus without this library. +@section s302m + +SMPTE ST 302 decoder. + +SMPTE ST 302 is a method for storing AES3 data format within an MPEG Transport +Stream. AES3 streams can contain LPCM streams of 2, 4, 6 or 8 channels with a +bit depth of 16, 20 or 24-bits at a sample rate of 48 kHz. +They can also contain non-PCM codec streams such as AC-3 or Dolby-E. + +Decoding non-PCM streams directly requires that the necessary stream decoder be +present in the build. At present, only Dolby-E decoding is supported. + +@subsection Options + +The following options are supported by the s302m decoder. + +@table @option +@item non_pcm_mode @var{mode} +Specify how to process non-PCM streams + +@table @samp +@item copy +Treat data as if it were LPCM. +@item drop +Discard the stream. +@item decode_copy +Decode if possible eise treat the same as @code{copy}. +@item decode_drop +Decode if possible eise treat the same as @code{drop}. +@end table + +The default value is @code{decode_drop}. This option does not affect the processing of +LPCM streams. + +@item non_pcm_options @var{options} +Set options for non-PCM decoder using a list of key=value pairs separated by ":". +Consult the docs for the non-PCM decoder for its options. + +@end table + @c man end AUDIO DECODERS @chapter Subtitles Decoders diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c index f1b41608f3..d890b6f117 100644 --- a/libavcodec/s302m.c +++ b/libavcodec/s302m.c @@ -24,21 +24,264 @@ #include "libavutil/intreadwrite.h" #include "libavutil/opt.h" #include "libavutil/log.h" +#include "libavutil/dict.h" #include "libavutil/reverse.h" #include "avcodec.h" #include "codec_internal.h" +#include "get_bits.h" #include "decode.h" #define AES3_HEADER_LEN 4 +#define NONPCMSYNC_16MARKER 0x4E1F0F8720 +#define NONPCMSYNC_20MARKER 0x4E1F60F872A0 +#define NONPCMSYNC_24MARKER 0x7E1F690F872A50 + +#define NONPCMSYNC_16_IN_20MARKER 0x04E1F00F8720 +#define NONPCMSYNC_20_IN_24MARKER 0x04E1F600F872A0 + +#define IS_NONPCMSYNC_16(state) ((state & 0x00) == NONPCMSYNC_16MARKER) +#define IS_NONPCMSYNC_20(state) ((state & 0xF0F0) == NONPCMSYNC_20MARKER) +#define IS_NONPCMSYNC_24(state) ((state & 0xFF0FF0) == NONPCMSYNC_24MARKER) + +#define IS_NONPCMSYNC_16_IN_20(state) ((state & 0x0000) == NONPCMSYNC_16_IN_20MARKER) +#define IS_NONPCMSYNC_20_IN_24(state) ((state & 0x0F00F0) == NONPCMSYNC_20_IN_24MARKER) + +#define IS_NONPCMSYNC(bit,state) ( ((bit == 16) && IS_NONPCMSYNC_16(state)) || \ +((bit == 20) && (IS_NONPCMSYNC_20(state) || IS_NONPCMSYNC_16_IN_20(state))) || \ +((bit == 24) && (IS_NONPCMSYNC_24(state) || IS_NONPCMSYNC_20_IN_24(state))) \ + ) + +enum non_pcm_modes { +NON_PCM_COPY, +NON_PCM_DROP, +NON_PCM_DEC_ELSE_COPY, +NON_PCM_DEC_ELSE_DROP, +}; + typedef struct S302Context { AVClass *class; + +int avctx_props_set; + +int channels; +int bits; + int non_pcm_mode; +int non_pcm_data_type; +int non_pcm_bits; +int non_pcm_dec; + +AVCodecContext *non_pcm_ctx; +AVDictionary *non_pcm_opts; +AVPacket *packet; +AVFrame *frame; } S302Context; +static av_cold int s302m_init(AVCodecContext *avctx) +{ +S302Context *s = avctx->priv_data; + +s->non_pcm_data_type = -1; + +return 0; +} + +static int s302m_non_pcm_inspect(AVCodecContext *avctx, const uint8_t *buf, int buf_size, + int *offset, int *length) +{ +S302Context *s = avctx->priv_data; +const uint8_t *pos = buf; +int ret, aes_frm_size, data_type, length_code = 0, pkt_left = buf_size; +uint64_
[FFmpeg-devel] [PATCH v2 2/2] fate: add tests for dolby_e decoding in s302m
Three tests, one each for 1) 16-bit Dolby-E words in 20-bits AES3 words 2) 20-bit Dolby-E words in 20-bits AES3 words 3) 20-bit Dolby-E words in 24-bits AES3 words --- tests/fate/acodec.mak | 15 ++ tests/ref/acodec/s302m-20-dolbye-16 | 221 tests/ref/acodec/s302m-20-dolbye-20 | 127 tests/ref/acodec/s302m-24-dolbye-20 | 170 + 4 files changed, 533 insertions(+) create mode 100644 tests/ref/acodec/s302m-20-dolbye-16 create mode 100644 tests/ref/acodec/s302m-20-dolbye-20 create mode 100644 tests/ref/acodec/s302m-24-dolbye-20 diff --git a/tests/fate/acodec.mak b/tests/fate/acodec.mak index 7b09e3bd63..60d3b8515b 100644 --- a/tests/fate/acodec.mak +++ b/tests/fate/acodec.mak @@ -165,6 +165,21 @@ fate-acodec-s302m: CODEC = s302m fate-acodec-s302m: ENCOPTS = -af aresample=48000:tsf=s16p -strict -2 fate-acodec-s302m: DECOPTS = -af aresample=44100:tsf=s16p +FATE_ACODEC-$(call FRAMECRC, MPEGTS, S302M DOLBY_E) += fate-acodec-s302m-20-dolbye-16 +fate-acodec-s302m-20-dolbye-16: CMD = framecrc -auto_conversion_filters \ + -non_pcm_mode decode_copy -i $(TARGET_SAMPLES)/s302m/s302_20bits_DolbyE_16bits.ts \ + -vn -c:a pcm_s16le + +FATE_ACODEC-$(call FRAMECRC, MPEGTS, S302M DOLBY_E) += fate-acodec-s302m-20-dolbye-20 +fate-acodec-s302m-20-dolbye-20: CMD = framecrc -auto_conversion_filters \ + -non_pcm_mode decode_copy -i $(TARGET_SAMPLES)/s302m/s302_20bits_DolbyE_20bits.ts \ + -vn -c:a pcm_s16le + +FATE_ACODEC-$(call FRAMECRC, MPEGTS, S302M DOLBY_E) += fate-acodec-s302m-24-dolbye-20 +fate-acodec-s302m-24-dolbye-20: CMD = framecrc -auto_conversion_filters \ + -non_pcm_mode decode_copy -i $(TARGET_SAMPLES)/s302m/s302_24bits_DolbyE_20bits.ts \ + -vn -c:a pcm_s16le + FATE_ACODEC-$(call ENCDEC, WAVPACK, WV, ARESAMPLE_FILTER) += fate-acodec-wavpack fate-acodec-wavpack: FMT = wv fate-acodec-wavpack: CODEC = wavpack -compression_level 1 diff --git a/tests/ref/acodec/s302m-20-dolbye-16 b/tests/ref/acodec/s302m-20-dolbye-16 new file mode 100644 index 00..e0c7b9e13b --- /dev/null +++ b/tests/ref/acodec/s302m-20-dolbye-16 @@ -0,0 +1,221 @@ +#tb 0: 1/44800 +#media_type 0: audio +#codec_id 0: pcm_s16le +#sample_rate 0: 44800 +#channel_layout_name 0: 5.1(side) +0, 0, 0, 1792,21504, 0x9136aa8a +0, 1792, 1792, 1792,21504, 0x6b8b42f0 +0, 3584, 3584, 1792,21504, 0xc73c0342 +0, 5376, 5376, 1792,21504, 0x9d777e2a +0, 7168, 7168, 1792,21504, 0x2ee86c97 +0, 8960, 8960, 1792,21504, 0xfdd41829 +0, 10752, 10752, 1792,21504, 0x58ea1b12 +0, 12544, 12544, 1792,21504, 0xa81a35f4 +0, 14336, 14336, 1792,21504, 0x2bd9bb62 +0, 16128, 16128, 1792,21504, 0x0648940e +0, 17920, 17920, 1792,21504, 0x377452f9 +0, 19712, 19712, 1792,21504, 0xf50f26b9 +0, 21504, 21504, 1792,21504, 0x935e7c69 +0, 23296, 23296, 1792,21504, 0x99363659 +0, 25088, 25088, 1792,21504, 0x78212dd2 +0, 26880, 26880, 1792,21504, 0x687f5776 +0, 28672, 28672, 1792,21504, 0xd6d3320c +0, 30464, 30464, 1792,21504, 0x96e1b731 +0, 32256, 32256, 1792,21504, 0xbb0b9cd9 +0, 34048, 34048, 1792,21504, 0x819db403 +0, 35840, 35840, 1792,21504, 0xa95c859a +0, 37632, 37632, 1792,21504, 0xd9cd11cc +0, 39424, 39424, 1792,21504, 0xe7a3abbf +0, 41216, 41216, 1792,21504, 0x975e4ddc +0, 43008, 43008, 1792,21504, 0x329af143 +0, 44800, 44800, 1792,21504, 0x9bb6281b +0, 46592, 46592, 1792,21504, 0x96cc0fa8 +0, 48384, 48384, 1792,21504, 0xaae03a7d +0, 50176, 50176, 1792,21504, 0x2a5d6225 +0, 51968, 51968, 1792,21504, 0xf7cc19f5 +0, 53760, 53760, 1792,21504, 0x89e85e67 +0, 2, 2, 1792,21504, 0x607ab65e +0, 57344, 57344, 1792,21504, 0x95c0ad8f +0, 59136, 59136, 1792,21504, 0x6b9e8b96 +0, 60928, 60928, 1792,21504, 0x7b83696c +0, 62720, 62720, 1792,21504, 0xac0b6fbf +0, 64512, 64512, 1792,21504, 0xfa249f22 +0, 66304, 66304, 1792,21504, 0x51acbb93 +0, 68096, 68096, 1792,21504, 0xd77b34be +0, 69888, 69888, 1792,21504, 0xd5494a86 +0, 71680, 71680, 1792,21504, 0xd83c3d91 +0, 73472, 73472, 1792,21504, 0xa476ccd8 +0, 75264, 75264, 1792,21504, 0x2aafc337 +0, 77056, 77056, 1792,21504, 0xeee70084 +0, 78848, 78848, 1792,21504, 0xd60a3c93 +0, 80640, 80640, 1792,21504, 0x43ac0f84 +0
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_h266_syntax_template: sanity check num_multi_layer_olss
On 1/26/2024 6:46 PM, Michael Niedermayer wrote: It is not possible to encode a index into an empty list. Thus this must be invalid at this point or before. Its likely a broader earlier check can be used here, someone knowing VVC should look at that. Its not immedeatly obvious from the spec by looking for numlayerolss Can you check if the following fixes it? diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c index 549d021211..40572dadb5 100644 --- a/libavcodec/cbs_h266_syntax_template.c +++ b/libavcodec/cbs_h266_syntax_template.c @@ -793,6 +793,7 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, RWContext *rw, { //calc NumMultiLayerOlss int m; +int num_layers_in_ols = 0; uint8_t dependency_flag[VVC_MAX_LAYERS][VVC_MAX_LAYERS]; uint16_t num_output_layers_in_ols[VVC_MAX_TOTAL_NUM_OLSS]; uint8_t num_sub_layers_in_layer_in_ols[VVC_MAX_TOTAL_NUM_OLSS][VVC_MAX_TOTAL_NUM_OLSS]; @@ -895,7 +896,6 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, RWContext *rw, return AVERROR_INVALIDDATA; } for (i = 1; i < total_num_olss; i++) { -int num_layers_in_ols = 0; if (current->vps_each_layer_is_an_ols_flag) { num_layers_in_ols = 1; } else if (current->vps_ols_mode_idc == 0 || num_layers_in_ols is not meant to be reset on every loop. ___ 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 v3 1/6] avformat: add muxer support for H266/VVC
On 1/27/2024 1:15 AM, Nuo Mi wrote: diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c index a575b7c160..705811e950 100644 --- a/libavformat/isom_tags.c +++ b/libavformat/isom_tags.c @@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = { { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based Dolby Vision derived from hev1 */ /* dvh1 is handled within mov.c */ +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') }, /* VVC/H.266 which indicates parameter sets may be in ES */ +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'c', '1') }, /* VVC/H.266 which indicates parameter shall not be in ES */ + { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */ { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '2') }, { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '3') }, This list is for mov only, not mp4. You're already adding these two entries to codec_mp4_tags[] bellow, for ISOBMFF. Are these defined anywhere in Apple's documentation? ___ 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 v3 2/6] avformat/mpegtsenc: refact mpegts_check_bitstream to loop up table
Nuo Mi: > --- > libavformat/mpegtsenc.c | 33 ++--- > 1 file changed, 18 insertions(+), 15 deletions(-) > > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c > index 84edd418f0..418fa08ad5 100644 > --- a/libavformat/mpegtsenc.c > +++ b/libavformat/mpegtsenc.c > @@ -2257,23 +2257,26 @@ static void mpegts_deinit(AVFormatContext *s) > static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st, >const AVPacket *pkt) > { > -int ret = 1; > +struct Entry { > +enum AVCodecID id; > +const char *bsf_name; No relocations please. > +uint8_t m; > +uint8_t v; m? (Mask?) v? (Version?) Don't be so cryptic. > +} list[] = { > +{ AV_CODEC_ID_H264, "h264_mp4toannexb", 0xff, 0x01 }, > +{ AV_CODEC_ID_HEVC, "hevc_mp4toannexb", 0xff, 0x01 }, > +}; > > -if (st->codecpar->codec_id == AV_CODEC_ID_H264) { > -if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 && > - (AV_RB24(pkt->data) != 0x01 || > - (st->codecpar->extradata_size > 0 && > - st->codecpar->extradata[0] == 1))) > -ret = ff_stream_add_bitstream_filter(st, "h264_mp4toannexb", > NULL); > -} else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) { > -if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 && > - (AV_RB24(pkt->data) != 0x01 || > - (st->codecpar->extradata_size > 0 && > - st->codecpar->extradata[0] == 1))) > -ret = ff_stream_add_bitstream_filter(st, "hevc_mp4toannexb", > NULL); > +for (int i = 0; i < FF_ARRAY_ELEMS(list); i++) { > +struct Entry *e = list + i; > +if (e->id == st->codecpar->codec_id && > +pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 && > +(AV_RB24(pkt->data) != 0x01 || > +(st->codecpar->extradata_size > 0 && > +(st->codecpar->extradata[0] & e->m == e->v > +return ff_stream_add_bitstream_filter(st, e->bsf_name, NULL); > } > - > -return ret; > +return 1; > } > > #define OFFSET(x) offsetof(MpegTSWrite, x) ___ 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 v3 2/6] avformat/mpegtsenc: refact mpegts_check_bitstream to loop up table
Hi Andreas, thank you for the review On Sat, Jan 27, 2024 at 10:44 PM Andreas Rheinhardt < andreas.rheinha...@outlook.com> wrote: > Nuo Mi: > > --- > > libavformat/mpegtsenc.c | 33 ++--- > > 1 file changed, 18 insertions(+), 15 deletions(-) > > > > diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c > > index 84edd418f0..418fa08ad5 100644 > > --- a/libavformat/mpegtsenc.c > > +++ b/libavformat/mpegtsenc.c > > @@ -2257,23 +2257,26 @@ static void mpegts_deinit(AVFormatContext *s) > > static int mpegts_check_bitstream(AVFormatContext *s, AVStream *st, > >const AVPacket *pkt) > > { > > -int ret = 1; > > +struct Entry { > > +enum AVCodecID id; > > +const char *bsf_name; > > No relocations please. > Could you give me more clues about this? > > > +uint8_t m; > > +uint8_t v; > > m? (Mask?) v? (Version?) Don't be so cryptic. > m is a mask. for h264, hevc, v is the version for vvc, v is reserved 5 bits (1). I will change v to value. > > +} list[] = { > > +{ AV_CODEC_ID_H264, "h264_mp4toannexb", 0xff, 0x01 }, > > +{ AV_CODEC_ID_HEVC, "hevc_mp4toannexb", 0xff, 0x01 }, > > +}; > > > > -if (st->codecpar->codec_id == AV_CODEC_ID_H264) { > > -if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 && > > - (AV_RB24(pkt->data) != 0x01 || > > - (st->codecpar->extradata_size > 0 && > > - st->codecpar->extradata[0] == 1))) > > -ret = ff_stream_add_bitstream_filter(st, > "h264_mp4toannexb", NULL); > > -} else if (st->codecpar->codec_id == AV_CODEC_ID_HEVC) { > > -if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 && > > - (AV_RB24(pkt->data) != 0x01 || > > - (st->codecpar->extradata_size > 0 && > > - st->codecpar->extradata[0] == 1))) > > -ret = ff_stream_add_bitstream_filter(st, > "hevc_mp4toannexb", NULL); > > +for (int i = 0; i < FF_ARRAY_ELEMS(list); i++) { > > +struct Entry *e = list + i; > > +if (e->id == st->codecpar->codec_id && > > +pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 && > > +(AV_RB24(pkt->data) != 0x01 || > > +(st->codecpar->extradata_size > 0 && > > +(st->codecpar->extradata[0] & e->m == e->v > > +return ff_stream_add_bitstream_filter(st, e->bsf_name, > NULL); > > } > > - > > -return ret; > > +return 1; > > } > > > > #define OFFSET(x) offsetof(MpegTSWrite, x) > > ___ > 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 v3 1/6] avformat: add muxer support for H266/VVC
On Sat, Jan 27, 2024 at 10:38 PM James Almer wrote: > On 1/27/2024 1:15 AM, Nuo Mi wrote: > > diff --git a/libavformat/isom_tags.c b/libavformat/isom_tags.c > > index a575b7c160..705811e950 100644 > > --- a/libavformat/isom_tags.c > > +++ b/libavformat/isom_tags.c > > @@ -123,6 +123,9 @@ const AVCodecTag ff_codec_movvideo_tags[] = { > > { AV_CODEC_ID_HEVC, MKTAG('d', 'v', 'h', 'e') }, /* HEVC-based > Dolby Vision derived from hev1 */ > >/* dvh1 is > handled within mov.c */ > > > > +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'i', '1') }, /* VVC/H.266 which > indicates parameter sets may be in ES */ > > +{ AV_CODEC_ID_VVC, MKTAG('v', 'v', 'c', '1') }, /* VVC/H.266 which > indicates parameter shall not be in ES */ > > + > > { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */ > > { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '2') }, > > { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '3') }, > > > This list is for mov only, not mp4. You're already adding these two > entries to codec_mp4_tags[] bellow, for ISOBMFF. > Hi James, Thank you for the review. I guess not, @Thomas Siedel , could you give us some insights? thank you. > > Are these defined anywhere in Apple's documentation? > ___ > 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".
[FFmpeg-devel] [PATCH v3 0/1] avfilter/vf_vpp_qsv: apply 3D LUT from file.
This version of PATCH use `QSV_RUNTIME_VERSION_ATLEAST` to apply 3D LUT when libvpl runtime API version >= 2.11. Chen Yufei (1): avfilter/vf_vpp_qsv: apply 3D LUT from file. libavfilter/Makefile | 8 +- libavfilter/lut3d.c | 669 +++ libavfilter/lut3d.h | 13 + libavfilter/vf_lut3d.c | 590 +- libavfilter/vf_vpp_qsv.c | 119 ++- 5 files changed, 807 insertions(+), 592 deletions(-) create mode 100644 libavfilter/lut3d.c -- 2.43.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".
[FFmpeg-devel] [PATCH v3 1/1] avfilter/vf_vpp_qsv: apply 3D LUT from file.
Usage: "vpp_qsv=lut3d_file=" Requires oneVPL, using system memory 3D LUT surface. Signed-off-by: Chen Yufei --- libavfilter/Makefile | 8 +- libavfilter/lut3d.c | 669 +++ libavfilter/lut3d.h | 13 + libavfilter/vf_lut3d.c | 590 +- libavfilter/vf_vpp_qsv.c | 119 ++- 5 files changed, 807 insertions(+), 592 deletions(-) create mode 100644 libavfilter/lut3d.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index bba0219876..f682ea53c2 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -332,7 +332,7 @@ OBJS-$(CONFIG_GRAPHMONITOR_FILTER) += f_graphmonitor.o OBJS-$(CONFIG_GRAYWORLD_FILTER) += vf_grayworld.o OBJS-$(CONFIG_GREYEDGE_FILTER) += vf_colorconstancy.o OBJS-$(CONFIG_GUIDED_FILTER) += vf_guided.o -OBJS-$(CONFIG_HALDCLUT_FILTER) += vf_lut3d.o framesync.o +OBJS-$(CONFIG_HALDCLUT_FILTER) += vf_lut3d.o lut3d.o framesync.o OBJS-$(CONFIG_HFLIP_FILTER) += vf_hflip.o OBJS-$(CONFIG_HFLIP_VULKAN_FILTER) += vf_flip_vulkan.o vulkan.o OBJS-$(CONFIG_HISTEQ_FILTER) += vf_histeq.o @@ -370,10 +370,10 @@ OBJS-$(CONFIG_LIMITDIFF_FILTER) += vf_limitdiff.o framesync.o OBJS-$(CONFIG_LIMITER_FILTER)+= vf_limiter.o OBJS-$(CONFIG_LOOP_FILTER) += f_loop.o OBJS-$(CONFIG_LUMAKEY_FILTER)+= vf_lumakey.o -OBJS-$(CONFIG_LUT1D_FILTER) += vf_lut3d.o +OBJS-$(CONFIG_LUT1D_FILTER) += vf_lut3d.o lut3d.o OBJS-$(CONFIG_LUT_FILTER)+= vf_lut.o OBJS-$(CONFIG_LUT2_FILTER) += vf_lut2.o framesync.o -OBJS-$(CONFIG_LUT3D_FILTER) += vf_lut3d.o framesync.o +OBJS-$(CONFIG_LUT3D_FILTER) += vf_lut3d.o lut3d.o framesync.o OBJS-$(CONFIG_LUTRGB_FILTER) += vf_lut.o OBJS-$(CONFIG_LUTYUV_FILTER) += vf_lut.o OBJS-$(CONFIG_MASKEDCLAMP_FILTER)+= vf_maskedclamp.o framesync.o @@ -553,7 +553,7 @@ OBJS-$(CONFIG_VIDSTABTRANSFORM_FILTER) += vidstabutils.o vf_vidstabtransfo OBJS-$(CONFIG_VIF_FILTER)+= vf_vif.o framesync.o OBJS-$(CONFIG_VIGNETTE_FILTER) += vf_vignette.o OBJS-$(CONFIG_VMAFMOTION_FILTER) += vf_vmafmotion.o framesync.o -OBJS-$(CONFIG_VPP_QSV_FILTER)+= vf_vpp_qsv.o +OBJS-$(CONFIG_VPP_QSV_FILTER)+= vf_vpp_qsv.o lut3d.o OBJS-$(CONFIG_VSTACK_FILTER) += vf_stack.o framesync.o OBJS-$(CONFIG_W3FDIF_FILTER) += vf_w3fdif.o OBJS-$(CONFIG_WAVEFORM_FILTER) += vf_waveform.o diff --git a/libavfilter/lut3d.c b/libavfilter/lut3d.c new file mode 100644 index 00..173979adcc --- /dev/null +++ b/libavfilter/lut3d.c @@ -0,0 +1,669 @@ +/* + * Copyright (c) 2013 Clément Bœsch + * Copyright (c) 2018 Paul B Mahol + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "lut3d.h" + +#include + +#include "libavutil/avstring.h" +#include "libavutil/file_open.h" + +#define EXPONENT_MASK 0x7F80 +#define MANTISSA_MASK 0x007F +#define SIGN_MASK 0x8000 + +static inline float sanitizef(float f) +{ +union av_intfloat32 t; +t.f = f; + +if ((t.i & EXPONENT_MASK) == EXPONENT_MASK) { +if ((t.i & MANTISSA_MASK) != 0) { +// NAN +return 0.0f; +} else if (t.i & SIGN_MASK) { +// -INF +return -FLT_MAX; +} else { +// +INF +return FLT_MAX; +} +} +return f; +} + +static inline float lerpf(float v0, float v1, float f) +{ +return v0 + (v1 - v0) * f; +} + +static inline struct rgbvec lerp(const struct rgbvec *v0, const struct rgbvec *v1, float f) +{ +struct rgbvec v = { +lerpf(v0->r, v1->r, f), lerpf(v0->g, v1->g, f), lerpf(v0->b, v1->b, f) +}; +return v; +} + +int ff_allocate_3dlut(AVFilterContext *ctx, LUT3DContext *lut3d, int lutsize, int prelut) +{ +int i; +if (lutsize < 2 || lutsize > MAX_LEVEL) { +av_log(ctx, AV_LOG_ERROR, "Too large or invalid 3D LUT size\n"); +return AVERROR(EINVAL); +
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_h266_syntax_template: sanity check num_multi_layer_olss
On Sat, Jan 27, 2024 at 09:25:16AM -0300, James Almer wrote: > On 1/26/2024 6:46 PM, Michael Niedermayer wrote: > > It is not possible to encode a index into an empty list. Thus > > this must be invalid at this point or before. > > Its likely a broader earlier check can be used here, someone knowing > > VVC should look at that. Its not immedeatly obvious from the spec > > by looking for numlayerolss > > Can you check if the following fixes it? > > > diff --git a/libavcodec/cbs_h266_syntax_template.c > > b/libavcodec/cbs_h266_syntax_template.c > > index 549d021211..40572dadb5 100644 > > --- a/libavcodec/cbs_h266_syntax_template.c > > +++ b/libavcodec/cbs_h266_syntax_template.c > > @@ -793,6 +793,7 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, > > RWContext *rw, > > { > > //calc NumMultiLayerOlss > > int m; > > +int num_layers_in_ols = 0; > > uint8_t dependency_flag[VVC_MAX_LAYERS][VVC_MAX_LAYERS]; > > uint16_t num_output_layers_in_ols[VVC_MAX_TOTAL_NUM_OLSS]; > > uint8_t > > num_sub_layers_in_layer_in_ols[VVC_MAX_TOTAL_NUM_OLSS][VVC_MAX_TOTAL_NUM_OLSS]; > > @@ -895,7 +896,6 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, > > RWContext *rw, > > return AVERROR_INVALIDDATA; > > } > > for (i = 1; i < total_num_olss; i++) { > > -int num_layers_in_ols = 0; > > if (current->vps_each_layer_is_an_ols_flag) { > > num_layers_in_ols = 1; > > } else if (current->vps_ols_mode_idc == 0 || > > num_layers_in_ols is not meant to be reset on every loop. replacing my patch by yours does not change num_multi_layer_olss from being 0 and if its 0 then "num_multi_layer_olss - 1" causes problems as a limit more precissely this: i can also send you the file if you want? tools/target_bsf_vvc_metadata_fuzzer: Running 1 inputs 1 time(s) each. Running: /home/michael/libfuzz-repro/65160/clusterfuzz-testcase-minimized-ffmpeg_BSF_VVC_METADATA_fuzzer-4665241535119360 libavcodec/cbs_h266_syntax_template.c:1001:21: runtime error: index 257 out of bounds for type 'uint8_t [257]' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior libavcodec/cbs_h266_syntax_template.c:1001:21 in libavcodec/cbs_h266_syntax_template.c:1004:38: runtime error: index 257 out of bounds for type 'uint8_t [257]' SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior libavcodec/cbs_h266_syntax_template.c:1004:38 in = ==29823==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7ff104e7ca18 at pc 0x006a4fdb bp 0x7fffd376e7f0 sp 0x7fffd376e7e8 WRITE of size 1 at 0x7ff104e7ca18 thread T0 #0 0x6a4fda in cbs_h266_read_vps libavcodec/cbs_h266_syntax_template.c:1001:21 #1 0x5c87bc in cbs_h266_read_nal_unit libavcodec/cbs_h2645.c:1071:19 #2 0x4ff3aa in cbs_read_fragment_content libavcodec/cbs.c:215:15 #3 0x4ff3aa in cbs_read_data libavcodec/cbs.c:282 #4 0x5a53ea in ff_cbs_bsf_generic_filter libavcodec/cbs_bsf.c:75:11 #5 0x4c9b48 in LLVMFuzzerTestOneInput tools/target_bsf_fuzzer.c:154:16 #6 0x138eb7d in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) Fuzzer/build/../FuzzerLoop.cpp:495:13 #7 0x1383752 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) Fuzzer/build/../FuzzerDriver.cpp:273:6 #8 0x1388951 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) Fuzzer/build/../FuzzerDriver.cpp:690:9 #9 0x1383430 in main Fuzzer/build/../FuzzerMain.cpp:20:10 #10 0x7ff10889ac86 in __libc_start_main /build/glibc-WcQU6j/glibc-2.27/csu/../csu/libc-start.c:310 #11 0x41f429 in _start (tools/target_bsf_vvc_metadata_fuzzer+0x41f429) 0x7ff104e7ca18 is located 0 bytes to the right of 393752-byte region [0x7ff104e1c800,0x7ff104e7ca18) allocated by thread T0 here: #0 0x497e47 in posix_memalign /b/swarming/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/asan/asan_malloc_linux.cc:226:3 #1 0x130d3a8 in av_malloc libavutil/mem.c:105:9 #2 0x8fe1c5 in ff_refstruct_alloc_ext_c libavcodec/refstruct.c:109:11 #3 0x50c2bb in ff_cbs_alloc_unit_content libavcodec/cbs.c:933:25 #4 0x5c864f in cbs_h266_read_nal_unit libavcodec/cbs_h2645.c:1046:11 #5 0x4ff3aa in cbs_read_fragment_content libavcodec/cbs.c:215:15 #6 0x4ff3aa in cbs_read_data libavcodec/cbs.c:282 #7 0x5a53ea in ff_cbs_bsf_generic_filter libavcodec/cbs_bsf.c:75:11 #8 0x4c9b48 in LLVMFuzzerTestOneInput tools/target_bsf_fuzzer.c:154:16 #9 0x138eb7d in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) Fuzzer/build/../FuzzerLoop.cpp:495:13 #10 0x1383752 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) Fuzzer/build/../FuzzerDriver.cpp:273:6 #11 0x1388951 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) Fuzzer/build/../FuzzerDriver.cpp:690:9 #12 0x1383
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/cbs_h266_syntax_template: sanity check num_multi_layer_olss
On 1/27/2024 8:56 PM, Michael Niedermayer wrote: On Sat, Jan 27, 2024 at 09:25:16AM -0300, James Almer wrote: On 1/26/2024 6:46 PM, Michael Niedermayer wrote: It is not possible to encode a index into an empty list. Thus this must be invalid at this point or before. Its likely a broader earlier check can be used here, someone knowing VVC should look at that. Its not immedeatly obvious from the spec by looking for numlayerolss Can you check if the following fixes it? diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c index 549d021211..40572dadb5 100644 --- a/libavcodec/cbs_h266_syntax_template.c +++ b/libavcodec/cbs_h266_syntax_template.c @@ -793,6 +793,7 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, RWContext *rw, { //calc NumMultiLayerOlss int m; +int num_layers_in_ols = 0; uint8_t dependency_flag[VVC_MAX_LAYERS][VVC_MAX_LAYERS]; uint16_t num_output_layers_in_ols[VVC_MAX_TOTAL_NUM_OLSS]; uint8_t num_sub_layers_in_layer_in_ols[VVC_MAX_TOTAL_NUM_OLSS][VVC_MAX_TOTAL_NUM_OLSS]; @@ -895,7 +896,6 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, RWContext *rw, return AVERROR_INVALIDDATA; } for (i = 1; i < total_num_olss; i++) { -int num_layers_in_ols = 0; if (current->vps_each_layer_is_an_ols_flag) { num_layers_in_ols = 1; } else if (current->vps_ols_mode_idc == 0 || num_layers_in_ols is not meant to be reset on every loop. replacing my patch by yours does not change num_multi_layer_olss from being 0 and if its 0 then "num_multi_layer_olss - 1" causes problems as a limit more precissely this: i can also send you the file if you want? No, this should be looked at by someone more familiar with VVC. And my patch should be applied either way. The current code is wrong. ___ 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] avcodec/cbs_h266_syntax_template: sanity check num_multi_layer_olss
On Sat, Jan 27, 2024 at 09:02:30PM -0300, James Almer wrote: > On 1/27/2024 8:56 PM, Michael Niedermayer wrote: > > On Sat, Jan 27, 2024 at 09:25:16AM -0300, James Almer wrote: > > > On 1/26/2024 6:46 PM, Michael Niedermayer wrote: > > > > It is not possible to encode a index into an empty list. Thus > > > > this must be invalid at this point or before. > > > > Its likely a broader earlier check can be used here, someone knowing > > > > VVC should look at that. Its not immedeatly obvious from the spec > > > > by looking for numlayerolss > > > > > > Can you check if the following fixes it? > > > > > > > diff --git a/libavcodec/cbs_h266_syntax_template.c > > > > b/libavcodec/cbs_h266_syntax_template.c > > > > index 549d021211..40572dadb5 100644 > > > > --- a/libavcodec/cbs_h266_syntax_template.c > > > > +++ b/libavcodec/cbs_h266_syntax_template.c > > > > @@ -793,6 +793,7 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, > > > > RWContext *rw, > > > > { > > > > //calc NumMultiLayerOlss > > > > int m; > > > > +int num_layers_in_ols = 0; > > > > uint8_t dependency_flag[VVC_MAX_LAYERS][VVC_MAX_LAYERS]; > > > > uint16_t num_output_layers_in_ols[VVC_MAX_TOTAL_NUM_OLSS]; > > > > uint8_t > > > > num_sub_layers_in_layer_in_ols[VVC_MAX_TOTAL_NUM_OLSS][VVC_MAX_TOTAL_NUM_OLSS]; > > > > @@ -895,7 +896,6 @@ static int FUNC(vps) (CodedBitstreamContext *ctx, > > > > RWContext *rw, > > > > return AVERROR_INVALIDDATA; > > > > } > > > > for (i = 1; i < total_num_olss; i++) { > > > > -int num_layers_in_ols = 0; > > > > if (current->vps_each_layer_is_an_ols_flag) { > > > > num_layers_in_ols = 1; > > > > } else if (current->vps_ols_mode_idc == 0 || > > > > > > num_layers_in_ols is not meant to be reset on every loop. > > > > replacing my patch by yours does not change > > num_multi_layer_olss from being 0 > > and if its 0 then "num_multi_layer_olss - 1" causes problems as a limit > > > > more precissely this: > > i can also send you the file if you want? > > No, this should be looked at by someone more familiar with VVC. ive already sent the fuzzer samples to nuomi and frank plowman > And my patch should be applied either way. The current code is wrong. I did not suggest not to do that :) just that it alone was not enough to fix this thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Take away the freedom of one citizen and you will be jailed, take away the freedom of all citizens and you will be congratulated by your peers in Parliament. 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 3/3] libavfilter/vf_dnn_detect: Use class confidence to filt boxes
> -Original Message- > From: ffmpeg-devel On Behalf Of > wenbin.chen-at-intel@ffmpeg.org > Sent: Wednesday, January 17, 2024 3:22 PM > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH 3/3] libavfilter/vf_dnn_detect: Use class > confidence to filt boxes > > From: Wenbin Chen > > Use class confidence instead of box_score to filt boxes, which is more > accurate. Class confidence is obtained by multiplying class probability > distribution and box_score. > > Signed-off-by: Wenbin Chen > --- Looks good to me, will push soon. ___ 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 1/3] avutil/rational: increase av_d2q precision
Fixes parsing small timebases from expressions (where the expression API converts the result to double), like in this command line: ffprobe -f lavfi -i testsrc=d=1,settb=1/20 -show_streams -show_entries stream=time_base Before the patch timebase was parsed as 1/19. Signed-off-by: Marton Balint --- libavutil/rational.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/rational.c b/libavutil/rational.c index eb148ddb12..329fbf3302 100644 --- a/libavutil/rational.c +++ b/libavutil/rational.c @@ -114,7 +114,7 @@ AVRational av_d2q(double d, int max) return (AVRational) { d < 0 ? -1 : 1, 0 }; frexp(d, &exponent); exponent = FFMAX(exponent-1, 0); -den = 1LL << (61 - exponent); +den = 1LL << (62 - exponent); // (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64, // see Ticket2713 for affected gcc/glibc versions av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max); -- 2.35.3 ___ 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 2/3] avfilter/yadif_common: factorize some part of the config_output and the uninit functions
This unifies slightly diverged code and ensures that cc_fifo is always initialized. Signed-off-by: Marton Balint --- libavfilter/vf_bwdif.c | 30 +++--- libavfilter/vf_bwdif_cuda.c | 15 +++ libavfilter/vf_bwdif_vulkan.c | 12 - libavfilter/vf_yadif.c | 33 +++- libavfilter/vf_yadif_cuda.c | 27 +++ libavfilter/vf_yadif_videotoolbox.m | 19 +++--- libavfilter/yadif.h | 4 +++ libavfilter/yadif_common.c | 40 + 8 files changed, 66 insertions(+), 114 deletions(-) diff --git a/libavfilter/vf_bwdif.c b/libavfilter/vf_bwdif.c index 353cd0b61a..9042db8d7f 100644 --- a/libavfilter/vf_bwdif.c +++ b/libavfilter/vf_bwdif.c @@ -137,17 +137,6 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic, } } -static av_cold void uninit(AVFilterContext *ctx) -{ -BWDIFContext *bwdif = ctx->priv; -YADIFContext *yadif = &bwdif->yadif; - -av_frame_free(&yadif->prev); -av_frame_free(&yadif->cur ); -av_frame_free(&yadif->next); -ff_ccfifo_uninit(&yadif->cc_fifo); -} - static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUV444P, @@ -176,20 +165,9 @@ static int config_props(AVFilterLink *link) YADIFContext *yadif = &s->yadif; int ret; -link->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2}); -link->w = link->src->inputs[0]->w; -link->h = link->src->inputs[0]->h; - -if(yadif->mode&1) -link->frame_rate = av_mul_q(link->src->inputs[0]->frame_rate, (AVRational){2,1}); -else -link->frame_rate = ctx->inputs[0]->frame_rate; - -ret = ff_ccfifo_init(&yadif->cc_fifo, link->frame_rate, ctx); -if (ret < 0 ) { -av_log(ctx, AV_LOG_ERROR, "Failure to setup CC FIFO queue\n"); -return ret; -} +ret = ff_yadif_config_output_common(link); +if (ret < 0) +return AVERROR(EINVAL); yadif->csp = av_pix_fmt_desc_get(link->format); yadif->filter = filter; @@ -251,7 +229,7 @@ const AVFilter ff_vf_bwdif = { .description = NULL_IF_CONFIG_SMALL("Deinterlace the input image."), .priv_size = sizeof(BWDIFContext), .priv_class= &bwdif_class, -.uninit= uninit, +.uninit= ff_yadif_uninit, FILTER_INPUTS(avfilter_vf_bwdif_inputs), FILTER_OUTPUTS(avfilter_vf_bwdif_outputs), FILTER_PIXFMTS_ARRAY(pix_fmts), diff --git a/libavfilter/vf_bwdif_cuda.c b/libavfilter/vf_bwdif_cuda.c index 418f15f989..7585d1fe25 100644 --- a/libavfilter/vf_bwdif_cuda.c +++ b/libavfilter/vf_bwdif_cuda.c @@ -208,9 +208,7 @@ static av_cold void deint_cuda_uninit(AVFilterContext *ctx) CHECK_CU(cu->cuCtxPopCurrent(&dummy)); } -av_frame_free(&y->prev); -av_frame_free(&y->cur); -av_frame_free(&y->next); +ff_yadif_uninit(ctx); av_buffer_unref(&s->device_ref); s->hwctx = NULL; @@ -288,14 +286,9 @@ static int config_output(AVFilterLink *link) goto exit; } -link->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2}); -link->w = ctx->inputs[0]->w; -link->h = ctx->inputs[0]->h; - -if(y->mode & 1) -link->frame_rate = av_mul_q(ctx->inputs[0]->frame_rate, -(AVRational){2, 1}); - +ret = ff_yadif_config_output_common(link); +if (ret < 0) +goto exit; y->csp = av_pix_fmt_desc_get(output_frames->sw_format); y->filter = filter; diff --git a/libavfilter/vf_bwdif_vulkan.c b/libavfilter/vf_bwdif_vulkan.c index c51df9aa26..57711fb672 100644 --- a/libavfilter/vf_bwdif_vulkan.c +++ b/libavfilter/vf_bwdif_vulkan.c @@ -296,6 +296,8 @@ static void bwdif_vulkan_uninit(AVFilterContext *avctx) ff_vk_uninit(&s->vkctx); +ff_yadif_uninit(avctx); + s->initialized = 0; } @@ -354,13 +356,9 @@ static int bwdif_vulkan_config_output(AVFilterLink *outlink) if (!outlink->hw_frames_ctx) return AVERROR(ENOMEM); -outlink->time_base = av_mul_q(avctx->inputs[0]->time_base, (AVRational){1, 2}); -outlink->w = vkctx->output_width; -outlink->h = vkctx->output_height; - -if (y->mode & 1) -outlink->frame_rate = av_mul_q(avctx->inputs[0]->frame_rate, - (AVRational){2, 1}); +err = ff_yadif_config_output_common(outlink); +if (err < 0) +return err; y->csp = av_pix_fmt_desc_get(vkctx->frames->sw_format); y->filter = bwdif_vulkan_filter_frame; diff --git a/libavfilter/vf_yadif.c b/libavfilter/vf_yadif.c index a5a856bf5f..aa5ca4a889 100644 --- a/libavfilter/vf_yadif.c +++ b/libavfilter/vf_yadif.c @@ -251,16 +251,6 @@ static void filter(AVFilterContext *ctx, AVFrame *dstpic, } } -static av_cold void uninit(AV
[FFmpeg-devel] [PATCH 3/3] avfilter/yadif_common: fix timestamps with very small timebases
Yadif filter assumed that the output timebase is always half of the input timebase. This is not true if halving the input time base is not representable as an AVRational causing the output timestamps to be invalidly scaled in such a case. So let's use av_reduce instead of av_mul_q when calculating the output time base and if the conversion is inexact then let's fall back to the original timebase which probably makes more parctical sense than using x/INT_MAX. Fixes invalidly scaled pts_time values in this command line: ffmpeg -f lavfi -i testsrc -vf settb=tb=1/20,yadif,showinfo -f null none Signed-off-by: Marton Balint --- libavfilter/yadif.h| 2 ++ libavfilter/yadif_common.c | 20 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libavfilter/yadif.h b/libavfilter/yadif.h index 2c4fed62d2..c144568242 100644 --- a/libavfilter/yadif.h +++ b/libavfilter/yadif.h @@ -86,6 +86,8 @@ typedef struct YADIFContext { * the first field. */ int current_field; ///< YADIFCurrentField + +int pts_divisor; } YADIFContext; void ff_yadif_init_x86(YADIFContext *yadif); diff --git a/libavfilter/yadif_common.c b/libavfilter/yadif_common.c index 933372529e..90a5cffc2d 100644 --- a/libavfilter/yadif_common.c +++ b/libavfilter/yadif_common.c @@ -61,7 +61,7 @@ FF_ENABLE_DEPRECATION_WARNINGS int64_t next_pts = yadif->next->pts; if (next_pts != AV_NOPTS_VALUE && cur_pts != AV_NOPTS_VALUE) { -yadif->out->pts = cur_pts + next_pts; +yadif->out->pts = (cur_pts + next_pts) / yadif->pts_divisor; } else { yadif->out->pts = AV_NOPTS_VALUE; } @@ -150,8 +150,8 @@ int ff_yadif_filter_frame(AVFilterLink *link, AVFrame *frame) ff_ccfifo_inject(&yadif->cc_fifo, yadif->out); av_frame_free(&yadif->prev); if (yadif->out->pts != AV_NOPTS_VALUE) -yadif->out->pts *= 2; -yadif->out->duration *= 2; +yadif->out->pts *= 2 / yadif->pts_divisor; +yadif->out->duration *= 2 / yadif->pts_divisor; return ff_filter_frame(ctx->outputs[0], yadif->out); } @@ -168,9 +168,9 @@ FF_ENABLE_DEPRECATION_WARNINGS yadif->out->flags &= ~AV_FRAME_FLAG_INTERLACED; if (yadif->out->pts != AV_NOPTS_VALUE) -yadif->out->pts *= 2; +yadif->out->pts *= 2 / yadif->pts_divisor; if (!(yadif->mode & 1)) -yadif->out->duration *= 2; +yadif->out->duration *= 2 / yadif->pts_divisor; return return_frame(ctx, 0); } @@ -213,9 +213,17 @@ int ff_yadif_config_output_common(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; YADIFContext *yadif = ctx->priv; +AVRational tb = ctx->inputs[0]->time_base; int ret; -outlink->time_base = av_mul_q(ctx->inputs[0]->time_base, (AVRational){1, 2}); +if (av_reduce(&outlink->time_base.num, &outlink->time_base.den, tb.num, tb.den * 2LL, INT_MAX)) { +yadif->pts_divisor = 1; +} else { +av_log(ctx, AV_LOG_WARNING, "Cannot use exact output timebase\n"); +outlink->time_base = tb; +yadif->pts_divisor = 2; +} + outlink->w = ctx->inputs[0]->w; outlink->h = ctx->inputs[0]->h; -- 2.35.3 ___ 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] Sovereign Tech Fund
Hi all We are offered to apply for a sponsorship of FFmpeg by the Sovereign Tech Fund (STF). Please read the following to get a better understanding what STF is about: (In short it is about maintenance and sustainability, not features) https://www.sovereigntechfund.de/programs/applications As some probably already know, Thilo has worked with STF to work out many details of this. SPI will handle the financials for FFmpeg. Everyone willing to benefit from this sponsorship must not be a US sanctioned entity or in a US sanctioned country. And must sign a contractor agreement and simplified SoW with SPI. "A SOW purpose is to protect the contracted from doing a work and not getting paid, and to protect the contractor from paying for a work which wasn't wanted" At this point, what we need is a list of Projects so we can submit an application to STF at or before 12th Feb. (at the 14th they have a meeting and will review our submission) What STF told us, they need ATM is: - A scope of work for the project to defined before hand for the upcoming review and eventually a contract. It doesn’t have to be tied to specific people. - The contract STF will sign with SPI will be a service agreement based on that SOW and milestones. Payment of invoices will be contingent and after delivery (aka performance) of agreed upon milestones. My suggestion is that we create a Trac WIKI page similar to the ideas page for GSoC. On that page everyone can add a project idea. The requirement is that 1. it must fit in the goals and mission and all of STF 2. it must be about FFmpeg (IIUC non coding tasks are ok) 3. it must have a developer willing to do the work and a monetary amount as well as a expected time frame. Of course these don't need to be added at the same time you can add an idea and someone else can add herself as person doing the work. But for consideration it needs to contain all parts 4. The developer doing the work must be qualified. An easy way to ensure this, is that (s)he has at least 100 authored commits in FFmpeg. According to STF, April 1st is a possible start date for the work and STF would also like to know if the work will be finished in 2024 or 2025 for their budget. the SoW can be for example: "do X by date Y to receive Z", but according to SPI it can also be "only tasks X are eligible, invoices should be sent by date Y, and payment will not exceed the budget Z" "Ideally, it should also mention the parameters for how much each thing done is worth — eg. If you're paying for hours or for tasks, and how much — as the SOW is supposed to give the contracted person means to know how much they'll be paid for what they do." "SOW should also note that if no valid tasks are performed, no payment will be made." Next step. For each Project suggestion from the wiki page we will send a mail to the ML with a copy and paste of the project suggestion. Once an apparent consensus is reached. This is the communities opportunity to object or approve the suggestion. Anyone can call for a formal vote of the GA here too if they do not want to object/approve in public. But i hope we can avoid that overhead. All suggested project ideas will then be submitted to STF We have never done STF before so there likely will be some surprises and we may need to adjust in case we hit any issues. and I also didn't expect to be involved in this but i don't want to stand around and have the opportunity for FFmpeg lost There can be no late objections here to any project suggestions. Objections must be before a project suggestion is submitted to STF, objections after that cannot be considered! Also once the person doing the work reaches the agreed milestone. She will submit an invoice with stefano and my help to SPI/STF. (in the unlikely case of a dispute on reaching a milestone it would be decided by the technical committee if the milestone has been reached from FFmpegs point of view) Thanks -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is what and why we do it that matters, not just one of them. 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] libavfi/dnn: add LibTorch as one of DNN backend
> -Original Message- > From: ffmpeg-devel On Behalf Of > wenbin.chen-at-intel@ffmpeg.org > Sent: Monday, January 22, 2024 2:11 PM > To: ffmpeg-devel@ffmpeg.org > Subject: [FFmpeg-devel] [PATCH] libavfi/dnn: add LibTorch as one of DNN > backend > > From: Wenbin Chen > > PyTorch is an open source machine learning framework that accelerates the > path from research prototyping to production deployment. Official > websit: https://pytorch.org/. We call the C++ library of PyTorch as LibTorch, > the same below. > > To build FFmpeg with LibTorch, please take following steps as reference: > 1. download LibTorch C++ library in https://pytorch.org/get-started/locally/, > please select C++/Java for language, and other options as your need. > 2. unzip the file to your own dir, with command unzip libtorch-shared-with- > deps-latest.zip -d your_dir 3. export libtorch_root/libtorch/include and > libtorch_root/libtorch/include/torch/csrc/api/include to $PATH export > libtorch_root/libtorch/lib/ to $LD_LIBRARY_PATH 4. config FFmpeg > with ../configure --enable-libtorch --extra-cflag=- > I/libtorch_root/libtorch/include --extra-cflag=- > I/libtorch_root/libtorch/include/torch/csrc/api/include --extra-ldflags=- > L/libtorch_root/libtorch/lib/ > 5. make > > To run FFmpeg DNN inference with LibTorch backend: > ./ffmpeg -i input.jpg -vf > dnn_processing=dnn_backend=torch:model=LibTorch_model.pt -y output.jpg > The LibTorch_model.pt can be generated by Python with torch.jit.script() api. > Please note, torch.jit.trace() is not recommanded, since it does not support > ambiguous input size. > > Signed-off-by: Ting Fu > Signed-off-by: Wenbin Chen > --- > configure | 5 +- > libavfilter/dnn/Makefile | 1 + > libavfilter/dnn/dnn_backend_torch.cpp | 585 ++ > libavfilter/dnn/dnn_interface.c | 5 + > libavfilter/dnn_filter_common.c | 31 +- > libavfilter/dnn_interface.h | 2 +- > libavfilter/vf_dnn_processing.c | 3 + > 7 files changed, 621 insertions(+), 11 deletions(-) create mode 100644 > libavfilter/dnn/dnn_backend_torch.cpp > I'm glad to see the libtorch as a new dnn backend personally, due to the fact that more and more deep learning models are trained with PyTorch. PyTorch is a necessary in the AI domain, including analysis/processing of image, video, audio and subtitle (text) and even putting them together. ___ 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".