Re: [FFmpeg-devel] [PATCH V1] avcodec/cbs_vp8: Add support for VP8 codec bitstream READ methods
Dai, Jianhui J: > This commit adds VP8 into cbs supported codec list, and enables the > `trace_headers` bitstream filters to support VP8, besides existing AV1, > H.264, H.265 and VP9. It can be useful to debug VP8 stream issues. > > Only the READ methods `read_unit` and `split_fragment` are implemented, > the WRITE methods `write_unit` and `assemble_fragment` return > `AVERROR_PATCHWELCOME` error code. It is because the CBS VP8 WRITE is > unlikely used by any applications at the moment. The WRITE methods can > be added later if there are real requirments. > > TESTS: ffmpeg -i fate-suite/vp8/frame_size_change.webm -vcodec copy > -bsf:v trace_headers -f null - > > Signed-off-by: Jianhui Dai > --- > configure| 4 +- > libavcodec/Makefile | 1 + > libavcodec/cbs.c | 6 + > libavcodec/cbs_internal.h| 1 + > libavcodec/cbs_vp8.c | 259 +++ > libavcodec/cbs_vp8.h | 116 +++ > libavcodec/cbs_vp8_syntax_template.c | 294 +++ > 7 files changed, 680 insertions(+), 1 deletion(-) > create mode 100644 libavcodec/cbs_vp8.c > create mode 100644 libavcodec/cbs_vp8.h > create mode 100644 libavcodec/cbs_vp8_syntax_template.c > > diff --git a/configure b/configure > index bb7be67676..6ba7759e34 100755 > --- a/configure > +++ b/configure > @@ -2433,6 +2433,7 @@ CONFIG_EXTRA=" > cbs_jpeg > cbs_mpeg2 > cbs_vp9 > +cbs_vp8 vp8 should be before vp9 in all these lists. > deflate_wrapper > dirac_parse > dnn > @@ -2714,6 +2715,7 @@ cbs_h265_select="cbs" > cbs_jpeg_select="cbs" > cbs_mpeg2_select="cbs" > cbs_vp9_select="cbs" > +cbs_vp8_select="cbs" > dct_select="rdft" > deflate_wrapper_deps="zlib" > dirac_parse_select="golomb" > @@ -3284,7 +3286,7 @@ h264_redundant_pps_bsf_select="cbs_h264" > hevc_metadata_bsf_select="cbs_h265" > mjpeg2jpeg_bsf_select="jpegtables" > mpeg2_metadata_bsf_select="cbs_mpeg2" > -trace_headers_bsf_select="cbs" > +trace_headers_bsf_select="cbs cbs_vp8" > vp9_metadata_bsf_select="cbs_vp9" > > # external libraries > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 3cfb7e..a4e5d7d7a5 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -79,6 +79,7 @@ OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o > cbs_sei.o h2645_parse.o > OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o > OBJS-$(CONFIG_CBS_MPEG2) += cbs_mpeg2.o > OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o > +OBJS-$(CONFIG_CBS_VP8) += cbs_vp8.o vpx_rac.o > OBJS-$(CONFIG_CRYSTALHD) += crystalhd.o > OBJS-$(CONFIG_DCT) += dct.o dct32_fixed.o dct32_float.o > OBJS-$(CONFIG_DEFLATE_WRAPPER) += zlib_wrapper.o > diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c > index 504197e06d..f4ff05181f 100644 > --- a/libavcodec/cbs.c > +++ b/libavcodec/cbs.c > @@ -49,6 +49,9 @@ static const CodedBitstreamType *const cbs_type_table[] = { > #if CONFIG_CBS_VP9 > &ff_cbs_type_vp9, > #endif > +#if CONFIG_CBS_VP8 > +&ff_cbs_type_vp8, > +#endif > }; > > const enum AVCodecID ff_cbs_all_codec_ids[] = { > @@ -69,6 +72,9 @@ const enum AVCodecID ff_cbs_all_codec_ids[] = { > #endif > #if CONFIG_CBS_VP9 > AV_CODEC_ID_VP9, > +#endif > +#if CONFIG_CBS_VP8 > +AV_CODEC_ID_VP8, > #endif > AV_CODEC_ID_NONE > }; > diff --git a/libavcodec/cbs_internal.h b/libavcodec/cbs_internal.h > index e585c77934..9ea6393a9f 100644 > --- a/libavcodec/cbs_internal.h > +++ b/libavcodec/cbs_internal.h > @@ -248,6 +248,7 @@ extern const CodedBitstreamType ff_cbs_type_h265; > extern const CodedBitstreamType ff_cbs_type_jpeg; > extern const CodedBitstreamType ff_cbs_type_mpeg2; > extern const CodedBitstreamType ff_cbs_type_vp9; > +extern const CodedBitstreamType ff_cbs_type_vp8; > > > #endif /* AVCODEC_CBS_INTERNAL_H */ > diff --git a/libavcodec/cbs_vp8.c b/libavcodec/cbs_vp8.c > new file mode 100644 > index 00..ee5c5cbceb > --- /dev/null > +++ b/libavcodec/cbs_vp8.c > @@ -0,0 +1,259 @@ > +/* > + * 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 "libavutil/avassert
[FFmpeg-devel] [PATCH] lavc/av1*: fix exporting framerate
* take num_ticks_per_picture_minus_1 into account, since that is a part of the framerate computation * stop exporting num_ticks_per_picture_minus_1 into AVCodecContext.ticks_per_frame, as that field is used for other purposes (in conjunction with repeat_pict, which is not used at all by av1) --- libavcodec/Makefile | 2 +- libavcodec/av1_parse.c | 14 ++ libavcodec/av1_parse.h | 3 +++ libavcodec/av1_parser.c | 11 ++- libavcodec/av1dec.c | 14 +- 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 3cfb7e..9587e56493 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1143,7 +1143,7 @@ OBJS-$(CONFIG_AC3_PARSER) += aac_ac3_parser.o ac3tab.o \ ac3_channel_layout_tab.o OBJS-$(CONFIG_ADX_PARSER) += adx_parser.o OBJS-$(CONFIG_AMR_PARSER) += amr_parser.o -OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o +OBJS-$(CONFIG_AV1_PARSER) += av1_parser.o av1_parse.o OBJS-$(CONFIG_AVS2_PARSER) += avs2.o avs2_parser.o OBJS-$(CONFIG_AVS3_PARSER) += avs3_parser.o OBJS-$(CONFIG_BMP_PARSER) += bmp_parser.o diff --git a/libavcodec/av1_parse.c b/libavcodec/av1_parse.c index 59ea0bc6e7..136ad1a58f 100644 --- a/libavcodec/av1_parse.c +++ b/libavcodec/av1_parse.c @@ -108,3 +108,17 @@ void ff_av1_packet_uninit(AV1Packet *pkt) av_freep(&pkt->obus); pkt->obus_allocated = pkt->obus_allocated_size = 0; } + +AVRational ff_av1_framerate(int64_t ticks_per_frame, int64_t units_per_tick, +int64_t time_scale) +{ +AVRational fr; + +if (ticks_per_frame && units_per_tick && time_scale && +ticks_per_frame < INT64_MAX / units_per_tick&& +av_reduce(&fr.den, &fr.num, units_per_tick * ticks_per_frame, + time_scale, INT_MAX)) +return fr; + +return (AVRational){ 0, 1 }; +} diff --git a/libavcodec/av1_parse.h b/libavcodec/av1_parse.h index f4a5d2830e..1f3001d2a5 100644 --- a/libavcodec/av1_parse.h +++ b/libavcodec/av1_parse.h @@ -181,4 +181,7 @@ static inline int get_obu_bit_length(const uint8_t *buf, int size, int type) return size; } +AVRational ff_av1_framerate(int64_t ticks_per_frame, int64_t units_per_tick, +int64_t time_scale); + #endif /* AVCODEC_AV1_PARSE_H */ diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c index 14dae92fe9..2b79493bf8 100644 --- a/libavcodec/av1_parser.c +++ b/libavcodec/av1_parser.c @@ -21,6 +21,8 @@ */ #include "libavutil/avassert.h" + +#include "av1_parse.h" #include "cbs.h" #include "cbs_av1.h" #include "parser.h" @@ -162,11 +164,10 @@ static int av1_parser_parse(AVCodecParserContext *ctx, avctx->color_trc = (enum AVColorTransferCharacteristic) color->transfer_characteristics; avctx->color_range = color->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; -if (seq->timing_info_present_flag) { -const AV1RawTimingInfo *timing = &seq->timing_info; -av_reduce(&avctx->framerate.den, &avctx->framerate.num, - timing->num_units_in_display_tick, timing->time_scale, INT_MAX); -} +if (seq->timing_info_present_flag) +avctx->framerate = ff_av1_framerate(1LL + seq->timing_info.num_ticks_per_picture_minus_1, + seq->timing_info.num_units_in_display_tick, +seq->timing_info.time_scale); end: ff_cbs_fragment_reset(td); diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index c90c9c1a69..d46ee48335 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -26,6 +26,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/opt.h" #include "avcodec.h" +#include "av1_parse.h" #include "av1dec.h" #include "atsc_a53.h" #include "bytestream.h" @@ -709,15 +710,10 @@ static int set_context_with_sequence(AVCodecContext *avctx, } avctx->sample_aspect_ratio = (AVRational) { 1, 1 }; -if (seq->timing_info.num_units_in_display_tick && -seq->timing_info.time_scale) { -av_reduce(&avctx->framerate.den, &avctx->framerate.num, - seq->timing_info.num_units_in_display_tick, - seq->timing_info.time_scale, - INT_MAX); -if (seq->timing_info.equal_picture_interval) -avctx->ticks_per_frame = seq->timing_info.num_ticks_per_picture_minus_1 + 1; -} +if (seq->timing_info_present_flag) +avctx->framerate = ff_av1_framerate(1LL + seq->timing_info.num_ticks_per_picture_minus_1, + seq->timing_info.num_units_in_display_tick, +seq->timing_info.time_scale); return 0; } -- 2.39.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg
[FFmpeg-devel] [PATCH] lavc/libdav1d: fix exporting framerate
Same issues as in the previous commit. --- Updated for changes in previous patch. --- libavcodec/Makefile | 2 +- libavcodec/libdav1d.c | 10 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9587e56493..4d59411662 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1086,7 +1086,7 @@ OBJS-$(CONFIG_LIBARIBCAPTION_DECODER) += libaribcaption.o ass.o OBJS-$(CONFIG_LIBCELT_DECODER)+= libcelt_dec.o OBJS-$(CONFIG_LIBCODEC2_DECODER) += libcodec2.o OBJS-$(CONFIG_LIBCODEC2_ENCODER) += libcodec2.o -OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o +OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o av1_parse.o OBJS-$(CONFIG_LIBDAVS2_DECODER) += libdavs2.o OBJS-$(CONFIG_LIBFDK_AAC_DECODER) += libfdk-aacdec.o OBJS-$(CONFIG_LIBFDK_AAC_ENCODER) += libfdk-aacenc.o diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index af072da681..0320ae7c6c 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -30,6 +30,7 @@ #include "libavutil/opt.h" #include "atsc_a53.h" +#include "av1_parse.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" @@ -154,12 +155,9 @@ static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *s else c->pix_fmt = pix_fmt[seq->layout][seq->hbd]; -if (seq->num_units_in_tick && seq->time_scale) { -av_reduce(&c->framerate.den, &c->framerate.num, - seq->num_units_in_tick, seq->time_scale, INT_MAX); -if (seq->equal_picture_interval) -c->ticks_per_frame = seq->num_ticks_per_picture; -} +c->framerate = ff_av1_framerate(seq->num_ticks_per_picture, +seq->num_units_in_tick, +seq->time_scale); if (seq->film_grain_present) c->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; -- 2.39.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] [PATCH v10 0/6] Support enhanced flv in FFmpeg
Reference file: https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js. you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp. The enhanced flv documentation contributors include Jean-Baptiste Kempf (FFmpeg, VideoLAN). So this should be support by ffmpeg too. v8: Support vp9 codec according to enhanced flv. Support PacketTypeCodedFrames type for hevc in flv. v9: Add dependency codec object files for flvenc in Makefile. Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL. v10: modify first patch comment like the others before commit. exheader mode should only happened in video stream this patchset. Steven Liu (6): avformat/flvenc: support mux hevc in enhanced flv avformat/flvdec: support demux hevc in enhanced flv avformat/flvenc: support mux av1 in enhanced flv avformat/flvdec: support demux av1 in enhanced flv avformat/flvenc: support mux vp9 in enhanced flv avformat/flvdec: support demux vp9 in enhanced flv libavformat/Makefile | 2 +- libavformat/flv.h| 15 + libavformat/flvdec.c | 73 +++- libavformat/flvenc.c | 58 +-- 4 files changed, 130 insertions(+), 18 deletions(-) -- 2.40.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 v10 1/6] avformat/flvenc: support mux hevc in enhanced flv
Signed-off-by: Steven Liu --- libavformat/Makefile | 2 +- libavformat/flv.h| 15 +++ libavformat/flvenc.c | 38 +- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index f8ad7c6a11..1ef3d15467 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -214,7 +214,7 @@ OBJS-$(CONFIG_FLAC_MUXER)+= flacenc.o flacenc_header.o \ OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o OBJS-$(CONFIG_LIVE_FLV_DEMUXER) += flvdec.o -OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o +OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o OBJS-$(CONFIG_FOURXM_DEMUXER)+= 4xm.o OBJS-$(CONFIG_FRAMECRC_MUXER)+= framecrcenc.o framehash.o OBJS-$(CONFIG_FRAMEHASH_MUXER) += hashenc.o framehash.o diff --git a/libavformat/flv.h b/libavformat/flv.h index 3571b90279..91e0a4140c 100644 --- a/libavformat/flv.h +++ b/libavformat/flv.h @@ -35,6 +35,12 @@ #define FLV_VIDEO_FRAMETYPE_OFFSET 4 +/* Extended VideoTagHeader + * defined in reference link: + * https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf + * */ +#define FLV_IS_EX_HEADER 0x80 + /* bitmasks to isolate specific values */ #define FLV_AUDIO_CHANNEL_MASK0x01 #define FLV_AUDIO_SAMPLESIZE_MASK 0x02 @@ -112,6 +118,15 @@ enum { FLV_CODECID_MPEG4 = 9, }; +enum { +PacketTypeSequenceStart = 0, +PacketTypeCodedFrames = 1, +PacketTypeSequenceEnd = 2, +PacketTypeCodedFramesX = 3, +PacketTypeMetadata = 4, +PacketTypeMPEG2TSSequenceStart = 5, +}; + enum { FLV_FRAME_KEY= 1 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< key frame (for AVC, a seekable frame) FLV_FRAME_INTER = 2 << FLV_VIDEO_FRAMETYPE_OFFSET, ///< inter frame (for AVC, a non-seekable frame) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 721f062811..35e198fa15 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -28,6 +28,7 @@ #include "libavcodec/mpeg4audio.h" #include "avio.h" #include "avc.h" +#include "hevc.h" #include "avformat.h" #include "flv.h" #include "internal.h" @@ -46,6 +47,7 @@ static const AVCodecTag flv_video_codec_ids[] = { { AV_CODEC_ID_VP6, FLV_CODECID_VP6 }, { AV_CODEC_ID_VP6A, FLV_CODECID_VP6A }, { AV_CODEC_ID_H264, FLV_CODECID_H264 }, +{ AV_CODEC_ID_HEVC, MKBETAG('h', 'v', 'c', '1') }, { AV_CODEC_ID_NONE, 0 } }; @@ -489,7 +491,7 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i FLVContext *flv = s->priv_data; if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 -|| par->codec_id == AV_CODEC_ID_MPEG4) { +|| par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { int64_t pos; avio_w8(pb, par->codec_type == AVMEDIA_TYPE_VIDEO ? @@ -532,10 +534,19 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i } avio_write(pb, par->extradata, par->extradata_size); } else { -avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags -avio_w8(pb, 0); // AVC sequence header -avio_wb24(pb, 0); // composition time -ff_isom_write_avcc(pb, par->extradata, par->extradata_size); +if (par->codec_id == AV_CODEC_ID_HEVC) { +avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeSequenceStart); // ExVideoTagHeader mode with PacketTypeSequenceStart +avio_write(pb, "hvc1", 4); +} else { +avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags +avio_w8(pb, 0); // AVC sequence header +avio_wb24(pb, 0); // composition time +} + +if (par->codec_id == AV_CODEC_ID_HEVC) +ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0); +else +ff_isom_write_avcc(pb, par->extradata, par->extradata_size); } data_size = avio_tell(pb) - pos; avio_seek(pb, -data_size - 10, SEEK_CUR); @@ -832,13 +843,13 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A || par->codec_id == AV_CODEC_ID_VP6 || par->codec_id == AV_CODEC_ID_AAC) flags_size = 2; -else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4) +else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) flags_size = 5; else flags_size = 1; if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 -|| par->codec_id == AV
[FFmpeg-devel] [PATCH v10 2/6] avformat/flvdec: support demux hevc in enhanced flv
Signed-off-by: Steven Liu --- libavformat/flvdec.c | 58 ++-- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index d83edff727..c8e6cadf1c 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -79,6 +79,8 @@ typedef struct FLVContext { int64_t last_ts; int64_t time_offset; int64_t time_pos; + +uint8_t exheader; } FLVContext; /* AMF date type */ @@ -302,13 +304,25 @@ static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, } } -static int flv_same_video_codec(AVCodecParameters *vpar, int flags) +static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, int flags) { int flv_codecid = flags & FLV_VIDEO_CODECID_MASK; +FLVContext *flv = s->priv_data; if (!vpar->codec_id && !vpar->codec_tag) return 1; +if (flv->exheader) { +uint8_t *codec_id_str = (uint8_t *)s->pb->buf_ptr; +uint32_t codec_id = codec_id_str[3] | codec_id_str[2] << 8 | codec_id_str[1] << 16 | codec_id_str[0] << 24; +switch(codec_id) { +case MKBETAG('h', 'v', 'c', '1'): +return vpar->codec_id == AV_CODEC_ID_HEVC; +default: +break; +} +} + switch (flv_codecid) { case FLV_CODECID_H263: return vpar->codec_id == AV_CODEC_ID_FLV1; @@ -331,9 +345,24 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, int flv_codecid, int read) { FFStream *const vstreami = ffstream(vstream); +FLVContext *flv = s->priv_data; int ret = 0; AVCodecParameters *par = vstream->codecpar; enum AVCodecID old_codec_id = vstream->codecpar->codec_id; +flv_codecid &= FLV_VIDEO_CODECID_MASK; + +if (flv->exheader) { +uint32_t codec_id = avio_rb32(s->pb); + +switch(codec_id) { +case MKBETAG('h', 'v', 'c', '1'): +par->codec_id = AV_CODEC_ID_HEVC; +vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; +return 4; +default: +break; +} +} switch (flv_codecid) { case FLV_CODECID_H263: par->codec_id = AV_CODEC_ID_FLV1; @@ -796,6 +825,7 @@ static int flv_read_header(AVFormatContext *s) s->start_time = 0; flv->sum_flv_tag_size = 0; flv->last_keyframe_stream_index = -1; +flv->exheader = 0; return 0; } @@ -1071,6 +1101,11 @@ retry: } else if (type == FLV_TAG_TYPE_VIDEO) { stream_type = FLV_STREAM_TYPE_VIDEO; flags= avio_r8(s->pb); +/* + * Reference Enhancing FLV 2023-03-v1.0.0-B.8 + * https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf + * */ +flv->exheader = (flags >> 7) & 1; size--; if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_VIDEO_INFO_CMD) goto skip; @@ -1129,7 +1164,7 @@ skip: break; } else if (stream_type == FLV_STREAM_TYPE_VIDEO) { if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && -(s->video_codec_id || flv_same_video_codec(st->codecpar, flags))) +(s->video_codec_id || flv_same_video_codec(s, st->codecpar, flags))) break; } else if (stream_type == FLV_STREAM_TYPE_SUBTITLE) { if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) @@ -1230,7 +1265,7 @@ retry_duration: avcodec_parameters_free(&par); } } else if (stream_type == FLV_STREAM_TYPE_VIDEO) { -int ret = flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK, 1); +int ret = flv_set_video_codec(s, st, flags, 1); if (ret < 0) return ret; size -= ret; @@ -1242,16 +1277,23 @@ retry_duration: if (st->codecpar->codec_id == AV_CODEC_ID_AAC || st->codecpar->codec_id == AV_CODEC_ID_H264 || -st->codecpar->codec_id == AV_CODEC_ID_MPEG4) { -int type = avio_r8(s->pb); -size--; +st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || +st->codecpar->codec_id == AV_CODEC_ID_HEVC) { +int type = 0; +if (flv->exheader && stream_type == FLV_STREAM_TYPE_VIDEO) { +type = flags & 0x0F; +} else { +type = avio_r8(s->pb); +size--; +} if (size < 0) { ret = AVERROR_INVALIDDATA; goto leave; } -if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4) { +if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || +(st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) { // sign extension int32_t cts = (avio_rb24(s->pb) + 0xff80) ^ 0xff80; pts = av_sat_add64(dts, ct
[FFmpeg-devel] [PATCH v10 3/6] avformat/flvenc: support mux av1 in enhanced flv
Signed-off-by: Steven Liu --- libavformat/Makefile | 2 +- libavformat/flvenc.c | 22 ++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index 1ef3d15467..c868e1626c 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -214,7 +214,7 @@ OBJS-$(CONFIG_FLAC_MUXER)+= flacenc.o flacenc_header.o \ OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o OBJS-$(CONFIG_LIVE_FLV_DEMUXER) += flvdec.o -OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o +OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o av1.o OBJS-$(CONFIG_FOURXM_DEMUXER)+= 4xm.o OBJS-$(CONFIG_FRAMECRC_MUXER)+= framecrcenc.o framehash.o OBJS-$(CONFIG_FRAMEHASH_MUXER) += hashenc.o framehash.o diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 35e198fa15..c1784b332d 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -28,6 +28,7 @@ #include "libavcodec/mpeg4audio.h" #include "avio.h" #include "avc.h" +#include "av1.h" #include "hevc.h" #include "avformat.h" #include "flv.h" @@ -48,6 +49,7 @@ static const AVCodecTag flv_video_codec_ids[] = { { AV_CODEC_ID_VP6A, FLV_CODECID_VP6A }, { AV_CODEC_ID_H264, FLV_CODECID_H264 }, { AV_CODEC_ID_HEVC, MKBETAG('h', 'v', 'c', '1') }, +{ AV_CODEC_ID_AV1, MKBETAG('a', 'v', '0', '1') }, { AV_CODEC_ID_NONE, 0 } }; @@ -491,7 +493,8 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i FLVContext *flv = s->priv_data; if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 -|| par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { +|| par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC +|| par->codec_id == AV_CODEC_ID_AV1) { int64_t pos; avio_w8(pb, par->codec_type == AVMEDIA_TYPE_VIDEO ? @@ -537,6 +540,9 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i if (par->codec_id == AV_CODEC_ID_HEVC) { avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeSequenceStart); // ExVideoTagHeader mode with PacketTypeSequenceStart avio_write(pb, "hvc1", 4); +} else if (par->codec_id == AV_CODEC_ID_AV1) { +avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeSequenceStart); +avio_write(pb, "av01", 4); } else { avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags avio_w8(pb, 0); // AVC sequence header @@ -545,6 +551,8 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i if (par->codec_id == AV_CODEC_ID_HEVC) ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0); +else if (par->codec_id == AV_CODEC_ID_AV1) +ff_isom_write_av1c(pb, par->extradata, par->extradata_size, 1); else ff_isom_write_avcc(pb, par->extradata, par->extradata_size); } @@ -843,13 +851,15 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) if (par->codec_id == AV_CODEC_ID_VP6F || par->codec_id == AV_CODEC_ID_VP6A || par->codec_id == AV_CODEC_ID_VP6 || par->codec_id == AV_CODEC_ID_AAC) flags_size = 2; -else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) +else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || + par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1) flags_size = 5; else flags_size = 1; if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 -|| par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { +|| par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC +|| par->codec_id == AV_CODEC_ID_AV1) { size_t side_size; uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size); if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) { @@ -869,7 +879,8 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) "Packets are not in the proper order with respect to DTS\n"); return AVERROR(EINVAL); } -if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC) { +if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || +par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1) { if (pkt->pts == AV_NOPTS_VALUE) { av_log(s, AV_LOG_ERROR, "Packet is
[FFmpeg-devel] [PATCH v10 4/6] avformat/flvdec: support demux av1 in enhanced flv
Signed-off-by: Steven Liu --- libavformat/flvdec.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index c8e6cadf1c..a0362ff11c 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -318,6 +318,8 @@ static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, int switch(codec_id) { case MKBETAG('h', 'v', 'c', '1'): return vpar->codec_id == AV_CODEC_ID_HEVC; +case MKBETAG('a', 'v', '0', '1'): +return vpar->codec_id == AV_CODEC_ID_AV1; default: break; } @@ -359,6 +361,10 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, par->codec_id = AV_CODEC_ID_HEVC; vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; return 4; +case MKBETAG('a', 'v', '0', '1'): +par->codec_id = AV_CODEC_ID_AV1; +vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; +return 4; default: break; } @@ -1278,7 +1284,8 @@ retry_duration: if (st->codecpar->codec_id == AV_CODEC_ID_AAC || st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || -st->codecpar->codec_id == AV_CODEC_ID_HEVC) { +st->codecpar->codec_id == AV_CODEC_ID_HEVC || +st->codecpar->codec_id == AV_CODEC_ID_AV1) { int type = 0; if (flv->exheader && stream_type == FLV_STREAM_TYPE_VIDEO) { type = flags & 0x0F; @@ -1309,7 +1316,8 @@ retry_duration: } } if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC || -st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC)) { +st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC || +st->codecpar->codec_id == AV_CODEC_ID_AV1)) { AVDictionaryEntry *t; if (st->codecpar->extradata) { -- 2.40.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 v10 5/6] avformat/flvenc: support mux vp9 in enhanced flv
Signed-off-by: Steven Liu --- libavformat/Makefile | 2 +- libavformat/flvenc.c | 22 ++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/libavformat/Makefile b/libavformat/Makefile index c868e1626c..16cfe107ea 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -214,7 +214,7 @@ OBJS-$(CONFIG_FLAC_MUXER)+= flacenc.o flacenc_header.o \ OBJS-$(CONFIG_FLIC_DEMUXER) += flic.o OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o OBJS-$(CONFIG_LIVE_FLV_DEMUXER) += flvdec.o -OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o av1.o +OBJS-$(CONFIG_FLV_MUXER) += flvenc.o avc.o hevc.o av1.o vpcc.o OBJS-$(CONFIG_FOURXM_DEMUXER)+= 4xm.o OBJS-$(CONFIG_FRAMECRC_MUXER)+= framecrcenc.o framehash.o OBJS-$(CONFIG_FRAMEHASH_MUXER) += hashenc.o framehash.o diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index c1784b332d..475dd0bf44 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -29,6 +29,7 @@ #include "avio.h" #include "avc.h" #include "av1.h" +#include "vpcc.h" #include "hevc.h" #include "avformat.h" #include "flv.h" @@ -50,6 +51,7 @@ static const AVCodecTag flv_video_codec_ids[] = { { AV_CODEC_ID_H264, FLV_CODECID_H264 }, { AV_CODEC_ID_HEVC, MKBETAG('h', 'v', 'c', '1') }, { AV_CODEC_ID_AV1, MKBETAG('a', 'v', '0', '1') }, +{ AV_CODEC_ID_VP9, MKBETAG('v', 'p', '0', '9') }, { AV_CODEC_ID_NONE, 0 } }; @@ -494,7 +496,7 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC -|| par->codec_id == AV_CODEC_ID_AV1) { +|| par->codec_id == AV_CODEC_ID_AV1 || par->codec_id == AV_CODEC_ID_VP9) { int64_t pos; avio_w8(pb, par->codec_type == AVMEDIA_TYPE_VIDEO ? @@ -540,9 +542,9 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i if (par->codec_id == AV_CODEC_ID_HEVC) { avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeSequenceStart); // ExVideoTagHeader mode with PacketTypeSequenceStart avio_write(pb, "hvc1", 4); -} else if (par->codec_id == AV_CODEC_ID_AV1) { +} else if (par->codec_id == AV_CODEC_ID_AV1 || par->codec_id == AV_CODEC_ID_VP9) { avio_w8(pb, FLV_IS_EX_HEADER | PacketTypeSequenceStart); -avio_write(pb, "av01", 4); +avio_write(pb, par->codec_id == AV_CODEC_ID_AV1 ? "av01" : "vp09", 4); } else { avio_w8(pb, par->codec_tag | FLV_FRAME_KEY); // flags avio_w8(pb, 0); // AVC sequence header @@ -553,6 +555,8 @@ static void flv_write_codec_header(AVFormatContext* s, AVCodecParameters* par, i ff_isom_write_hvcc(pb, par->extradata, par->extradata_size, 0); else if (par->codec_id == AV_CODEC_ID_AV1) ff_isom_write_av1c(pb, par->extradata, par->extradata_size, 1); +else if (par->codec_id == AV_CODEC_ID_VP9) +ff_isom_write_vpcc(s, pb, par->extradata, par->extradata_size, par); else ff_isom_write_avcc(pb, par->extradata, par->extradata_size); } @@ -852,14 +856,15 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) par->codec_id == AV_CODEC_ID_VP6 || par->codec_id == AV_CODEC_ID_AAC) flags_size = 2; else if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || - par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1) + par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1 || + par->codec_id == AV_CODEC_ID_VP9) flags_size = 5; else flags_size = 1; if (par->codec_id == AV_CODEC_ID_AAC || par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || par->codec_id == AV_CODEC_ID_HEVC -|| par->codec_id == AV_CODEC_ID_AV1) { +|| par->codec_id == AV_CODEC_ID_AV1 || par->codec_id == AV_CODEC_ID_VP9) { size_t side_size; uint8_t *side = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size); if (side && side_size > 0 && (side_size != par->extradata_size || memcmp(side, par->extradata, side_size))) { @@ -880,7 +885,8 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR(EINVAL); } if (par->codec_id == AV_CODEC_ID_H264 || par->codec_id == AV_CODEC_ID_MPEG4 || -par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1) { +par->codec_id == AV_CODEC_ID_HEVC || par->codec_id == AV_CODEC_ID_AV1 || +par->codec_id == AV_CODEC_ID_VP
[FFmpeg-devel] [PATCH v10 6/6] avformat/flvdec: support demux vp9 in enhanced flv
Signed-off-by: Steven Liu --- libavformat/flvdec.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index a0362ff11c..a6a94a4021 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -320,6 +320,8 @@ static int flv_same_video_codec(AVFormatContext *s, AVCodecParameters *vpar, int return vpar->codec_id == AV_CODEC_ID_HEVC; case MKBETAG('a', 'v', '0', '1'): return vpar->codec_id == AV_CODEC_ID_AV1; +case MKBETAG('v', 'p', '0', '9'): +return vpar->codec_id == AV_CODEC_ID_VP9; default: break; } @@ -365,6 +367,10 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream, par->codec_id = AV_CODEC_ID_AV1; vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; return 4; +case MKBETAG('v', 'p', '0', '9'): +par->codec_id = AV_CODEC_ID_VP9; +vstreami->need_parsing = AVSTREAM_PARSE_HEADERS; +return 4; default: break; } @@ -1285,7 +1291,8 @@ retry_duration: st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 || st->codecpar->codec_id == AV_CODEC_ID_HEVC || -st->codecpar->codec_id == AV_CODEC_ID_AV1) { +st->codecpar->codec_id == AV_CODEC_ID_AV1 || +st->codecpar->codec_id == AV_CODEC_ID_VP9) { int type = 0; if (flv->exheader && stream_type == FLV_STREAM_TYPE_VIDEO) { type = flags & 0x0F; @@ -1317,7 +1324,7 @@ retry_duration: } if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC || st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_HEVC || -st->codecpar->codec_id == AV_CODEC_ID_AV1)) { +st->codecpar->codec_id == AV_CODEC_ID_AV1 || st->codecpar->codec_id == AV_CODEC_ID_VP9)) { AVDictionaryEntry *t; if (st->codecpar->extradata) { -- 2.40.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".
Re: [FFmpeg-devel] [PATCH v9 0/6] Support enhanced flv in FFmpeg
Neal Gompa 于2023年5月13日周六 10:41写道: Hi Neal, > > > I've applied your patch set to Fedora's ffmpeg 6.0 on Fedora 38 and > attempted to test it. It seems to mostly work now, except that AAC > audio doesn't play in the AV1+AAC sample remuxed from MKV to FLV. My > H264+AAC sample seems to work properly though. > > Here are reproducer samples: > https://ngompa.fedorapeople.org/obs-recording-samples.tar > > My command for remuxing them is simple: > > $ ffmpeg -i "input.mkv" -vcodec copy -acodec copy "output.flv" Thanks for your test, that because the exheader flag is used in audio stream too, It should used in video stream and exheader mode. Thanks Steven ___ 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] lavc/qsv: fallback to the default mfx implementation for internal session on Windows
On Ma, 2023-05-15 at 08:33 +0200, Hendrik Leppkes wrote: > On Mon, May 15, 2023 at 8:04 AM Xiang, Haihao > wrote: > > > > From: Haihao Xiang > > > > The mfx implementation based on D3D11 is expected for an internal > > session on Windows, however sometimes this implemntation is not > > supported [1]. A fallback to the default mfx implementation is added in > > this patch. > > > > [1] https://github.com/intel/cartwheel-ffmpeg/issues/246 > > > > From the issue description, the user is trying to use it a as software > library, not a hardware one? Yes, because the user has sw library only. > I don't think software fallback, especially an automatic one, is > really quite appropriate. When someone requests a "qsv" encoder, they > expect hardware. It is not a software fallback. it is a fallback to the default one (which might be hw based or sw based, it is up to user's hw and media stack). Thanks Haihao > > - Hendrik > ___ > 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] tests/fate: add simple tests for libx264 and libx265
Since libx265 has issues (leaks, invalid reads), and I don't have time to craft supressions files right now, I pushed just the x264 part of this patch for now. -- Anton Khirnov ___ 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/cavs_parser: fix finding the end of a frame
Quoting Zhao Zhili (2023-05-15 13:49:30) > From: Zhao Zhili > > Use the next I/P/B or start code as the end of current frame. > > Signed-off-by: Zhao Zhili > --- > libavcodec/cavs_parser.c | 11 +-- > 1 file changed, 5 insertions(+), 6 deletions(-) Do you have a test case? Would be nice to make it into a FATE test. -- Anton Khirnov ___ 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] lavfi/vf_libplacebo: switch to new gamut mapping API
From: Niklas Haas Upstream deprecated the old ad-hoc, enum/intent-based gamut mapping API and added a new API based on colorimetrically accurate gamut mapping functions. The relevant change for us is the addition of several new modes, as well as deprecation of the old options. Update the documentation accordingly. --- doc/filters.texi| 47 ++- libavfilter/vf_libplacebo.c | 92 ++--- 2 files changed, 98 insertions(+), 41 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index d935e62b3f..14cb31b95c 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16332,37 +16332,36 @@ gamut-mapping when dealing with mismatches between wide-gamut or HDR content. In general, libplacebo relies on accurate source tagging and mastering display gamut information to produce the best results. @table @option -@item intent -Rendering intent to use when adapting between different primary color gamuts -(after tone-mapping). -@table @samp -@item perceptual -Perceptual gamut mapping. Currently equivalent to relative colorimetric. -@item relative -Relative colorimetric. This is the default. -@item absolute -Absolute colorimetric. -@item saturation -Saturation mapping. Forcibly stretches the source gamut to the target gamut. -@end table - @item gamut_mode How to handle out-of-gamut colors that can occur as a result of colorimetric gamut mapping. @table @samp @item clip -Do nothing, simply clip out-of-range colors to the RGB volume. This is the -default. -@item warn -Highlight out-of-gamut pixels (by coloring them pink). -@item darken -Linearly reduces content brightness to preserves saturated details, followed by -clipping the remaining out-of-gamut colors. As the name implies, this makes -everything darker, but provides a good balance between preserving details and -colors. +Do nothing, simply clip out-of-range colors to the RGB volume. Low quality but +extremely fast. +@item perceptual +Perceptually soft-clip colors to the gamut volume. This is the default. +@item relative +Relative colorimetric hard-clip. Similar to @code{perceptual} but without +the soft knee. +@item saturation +Saturation mapping, maps primaries directly to primaries in RGB space. +Not recommended except for artificial computer graphics for which a bright, +saturated display is desired. +@item absolute +Absolute colorimetric hard-clip. Performs no adjustment of the white point. @item desaturate Hard-desaturates out-of-gamut colors towards white, while preserving the -luminance. Has a tendency to shift colors. +luminance. Has a tendency to distort the visual appearance of bright objects. +@item darken +Linearly reduces content brightness to preserves saturated details, followed by +clipping the remaining out-of-gamut colors. +@item warn +Highlight out-of-gamut pixels (by inverting/marking them). +@item linear +Linearly reduces chromaticity of the entire image to make it fit within the +target color volume. Be careful when using this on BT.2020 sources without +proper mastering metadata, as doing so will lead to excessive desaturation. @end table @item tonemapping diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 94e49aa465..fde8da0b9b 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -56,6 +56,19 @@ enum { TONE_MAP_COUNT, }; +enum { +GAMUT_MAP_CLIP, +GAMUT_MAP_PERCEPTUAL, +GAMUT_MAP_RELATIVE, +GAMUT_MAP_SATURATION, +GAMUT_MAP_ABSOLUTE, +GAMUT_MAP_DESATURATE, +GAMUT_MAP_DARKEN, +GAMUT_MAP_HIGHLIGHT, +GAMUT_MAP_LINEAR, +GAMUT_MAP_COUNT, +}; + static const struct pl_tone_map_function * const tonemapping_funcs[TONE_MAP_COUNT] = { [TONE_MAP_AUTO] = &pl_tone_map_auto, [TONE_MAP_CLIP] = &pl_tone_map_clip, @@ -73,6 +86,36 @@ static const struct pl_tone_map_function * const tonemapping_funcs[TONE_MAP_COUN [TONE_MAP_LINEAR]= &pl_tone_map_linear, }; +#if PL_API_VER >= 269 +static const struct pl_gamut_map_function * const gamut_funcs[GAMUT_MAP_COUNT] = { +[GAMUT_MAP_CLIP]= &pl_gamut_map_clip, +[GAMUT_MAP_PERCEPTUAL] = &pl_gamut_map_perceptual, +[GAMUT_MAP_RELATIVE]= &pl_gamut_map_relative, +[GAMUT_MAP_SATURATION] = &pl_gamut_map_saturation, +[GAMUT_MAP_ABSOLUTE]= &pl_gamut_map_absolute, +[GAMUT_MAP_DESATURATE] = &pl_gamut_map_desaturate, +[GAMUT_MAP_DARKEN] = &pl_gamut_map_darken, +[GAMUT_MAP_HIGHLIGHT] = &pl_gamut_map_highlight, +[GAMUT_MAP_LINEAR] = &pl_gamut_map_linear, +}; +#else +static const enum pl_gamut_mode gamut_modes[GAMUT_MAP_COUNT] = { +[GAMUT_MAP_CLIP]= PL_GAMUT_CLIP, +[GAMUT_MAP_PERCEPTUAL] = PL_GAMUT_CLIP, +[GAMUT_MAP_DESATURATE] = PL_GAMUT_DESATURATE, +[GAMUT_MAP_DARKEN] = PL_GAMUT_DARKEN, +[GAMUT_MAP_HIGHLIGHT] = PL_GAMUT_WARN, +/* Everything else defaults to PL_GAMUT_CLIP */ +}; + +static const enum pl_rendering_intent i
[FFmpeg-devel] [PATCH 2/3] lavfi/vf_libplacebo: update for new tone mapping API
From: Niklas Haas This algorithm has once again been refactored, this time leading to a dropping of the old `tone_mapping_mode` field, to be replaced by a single tunable hybrid mode with configurable strength. We can approximately map the old modes onto the new API for backwards compatibility. Replace deprecated enums by their integer equivalents to safely preserve this API until the next bump. --- doc/filters.texi| 34 +- libavfilter/vf_libplacebo.c | 48 - 2 files changed, 32 insertions(+), 50 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 14cb31b95c..510aefc6c9 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16440,42 +16440,20 @@ For tunable tone mapping functions, this parameter can be used to fine-tune the curve behavior. Refer to the documentation of @code{tonemapping}. The default value of @code{0.0} is replaced by the curve's preferred default setting. -@item tonemapping_mode -This option determines how the tone mapping function specified by -@code{tonemapping} is applied to the colors in a scene. Possible values are: -@table @samp -@item auto -Automatic selection based on internal heuristics. This is the default. -@item rgb -Apply the function per-channel in the RGB colorspace. -Per-channel tone-mapping in RGB. Guarantees no clipping and heavily desaturates -the output, but distorts the colors quite significantly. Very similar to the -"Hollywood" look and feel. -@item max -Tone-mapping is performed on the brightest component found in the signal. Good -at preserving details in highlights, but has a tendency to crush blacks. -@item hybrid -Tone-map per-channel for highlights and linearly (luma-based) for -midtones/shadows, based on a fixed gamma @code{2.4} coefficient curve. -@item luma -Tone-map linearly on the luma component (CIE Y), and adjust (desaturate) the -chromaticities to compensate using a simple constant factor. This is -essentially the mode used in ITU-R BT.2446 method A. -@end table - @item inverse_tonemapping If enabled, this filter will also attempt stretching SDR signals to fill HDR output color volumes. Disabled by default. -@item tonemapping_crosstalk -Extra tone-mapping crosstalk factor, between @code{0.0} and @code{0.3}. This -can help reduce issues tone-mapping certain bright spectral colors. Defaults to -@code{0.04}. - @item tonemapping_lut_size Size of the tone-mapping LUT, between @code{2} and @code{1024}. Defaults to @code{256}. Note that this figure is squared when combined with @code{peak_detect}. + +@item hybrid_mix +If nonzero, this much of the upper range of the tone-mapped result is smoothly +mixed with a per-channel (LMS) tone-mapped version. Helps avoid unnatural +blown-out highlights when tone-mapping very bright, strongly saturated colors. +Defaults to @code{0.2}. @end table @subsubsection Dithering diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index fde8da0b9b..85e431402f 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -249,10 +249,9 @@ typedef struct LibplaceboContext { int gamut_mode; int tonemapping; float tonemapping_param; -int tonemapping_mode; int inverse_tonemapping; -float crosstalk; int tonemapping_lut_size; +float hybrid_mix; #if FF_API_LIBPLACEBO_OPTS /* for backwards compatibility */ @@ -262,6 +261,8 @@ typedef struct LibplaceboContext { int gamut_clipping; int force_icc_lut; int intent; +int tonemapping_mode; +float crosstalk; #endif /* pl_dither_params */ @@ -356,24 +357,23 @@ static int update_settings(AVFilterContext *ctx) { int err = 0; LibplaceboContext *s = ctx->priv; -enum pl_tone_map_mode tonemapping_mode = s->tonemapping_mode; int gamut_mode = s->gamut_mode; +float hybrid_mix = s->hybrid_mix; uint8_t color_rgba[4]; RET(av_parse_color(color_rgba, s->fillcolor, -1, s)); #if FF_API_LIBPLACEBO_OPTS /* backwards compatibility with older API */ -if (!tonemapping_mode && (s->desat_str >= 0.0f || s->desat_exp >= 0.0f)) { -float str = s->desat_str < 0.0f ? 0.9f : s->desat_str; -float exp = s->desat_exp < 0.0f ? 0.2f : s->desat_exp; -if (str >= 0.9f && exp <= 0.1f) { -tonemapping_mode = PL_TONE_MAP_RGB; -} else if (str > 0.1f) { -tonemapping_mode = PL_TONE_MAP_HYBRID; -} else { -tonemapping_mode = PL_TONE_MAP_LUMA; -} +switch (s->tonemapping_mode) { +case 0: /*PL_TONE_MAP_AUTO*/ +if (s->desat_str >= 0.0f) +hybrid_mix = s->desat_str; +break; +case 1: /*PL_TONE_MAP_RGB*/ hybrid_mix = 1.0f; break; +case 2: /*PL_TONE_MAP_HYBRID*/ hybrid_mix = 0.2f; break; +case 3: /*PL_TONE_MAP_LUMA*/hybrid_mix = 0.0f; break; +case 4: /*PL_TONE_MAP_MAX*/ hybrid_mix = 0.0f; break; } switch (s->intent) { @@ -414,15 +
[FFmpeg-devel] [PATCH 3/3] lavfi/vf_libplacebo: update peak detection options
From: Niklas Haas Upstream peak detection lost one option and gained one option. Update code and documentation as required. --- doc/filters.texi| 9 + libavfilter/vf_libplacebo.c | 11 +-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 510aefc6c9..3cd978e751 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16320,10 +16320,11 @@ logarithmic scale between @code{0.0} and @code{100.0}. Default to @code{5.5} and @code{10.0}, respectively. Setting either to a negative value disables this functionality. -@item overshoot -Peak smoothing overshoot margin, between @code{0.0} and @code{1.0}. Provides a -safety margin to prevent clipping as a result of peak smoothing. Defaults to -@code{0.05}, corresponding to a margin of 5%. +@item percentile +Which percentile of the frame brightness histogram to use as the source peak +for tone-mapping. Defaults to @code{99.995}, a fairly conservative value. +Setting this to @code{100.0} disables frame histogram measurement and instead +uses the true peak brightness for tone-mapping. @end table @subsubsection Tone mapping diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 85e431402f..96822d0e57 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -242,7 +242,7 @@ typedef struct LibplaceboContext { float min_peak; float scene_low; float scene_high; -float overshoot; +float percentile; /* pl_color_map_params */ struct pl_color_map_params color_map_params; @@ -263,6 +263,7 @@ typedef struct LibplaceboContext { int intent; int tonemapping_mode; float crosstalk; +float overshoot; #endif /* pl_dither_params */ @@ -408,7 +409,12 @@ static int update_settings(AVFilterContext *ctx) .minimum_peak = s->min_peak, .scene_threshold_low = s->scene_low, .scene_threshold_high = s->scene_high, +#if PL_API_VER >= 263 +.percentile = s->percentile, +#endif +#if FF_API_LIBPLACEBO_OPTS && PL_API_VER < 256 .overshoot_margin = s->overshoot, +#endif ); s->color_map_params = *pl_color_map_params( @@ -1194,7 +1200,7 @@ static const AVOption libplacebo_options[] = { { "minimum_peak", "Peak detection minimum peak", OFFSET(min_peak), AV_OPT_TYPE_FLOAT, {.dbl = 1.0}, 0.0, 100.0, DYNAMIC }, { "scene_threshold_low", "Scene change low threshold", OFFSET(scene_low), AV_OPT_TYPE_FLOAT, {.dbl = 5.5}, -1.0, 100.0, DYNAMIC }, { "scene_threshold_high", "Scene change high threshold", OFFSET(scene_high), AV_OPT_TYPE_FLOAT, {.dbl = 10.0}, -1.0, 100.0, DYNAMIC }, -{ "overshoot", "Tone-mapping overshoot margin", OFFSET(overshoot), AV_OPT_TYPE_FLOAT, {.dbl = 0.05}, 0.0, 1.0, DYNAMIC }, +{ "percentile", "Peak detection percentile", OFFSET(percentile), AV_OPT_TYPE_FLOAT, {.dbl = 99.995}, 0.0, 100.0, DYNAMIC }, { "gamut_mode", "Gamut-mapping mode", OFFSET(gamut_mode), AV_OPT_TYPE_INT, {.i64 = GAMUT_MAP_PERCEPTUAL}, 0, GAMUT_MAP_COUNT - 1, DYNAMIC, "gamut_mode" }, { "clip", "Hard-clip (RGB per-channel)", 0, AV_OPT_TYPE_CONST, {.i64 = GAMUT_MAP_CLIP}, 0, 0, STATIC, "gamut_mode" }, @@ -1244,6 +1250,7 @@ static const AVOption libplacebo_options[] = { { "hybrid", "Hybrid of Luma/RGB", 0, AV_OPT_TYPE_CONST, {.i64 = 3}, 0, 0, STATIC, "tonemap_mode" }, { "luma", "Luminance", 0, AV_OPT_TYPE_CONST, {.i64 = 4}, 0, 0, STATIC, "tonemap_mode" }, { "tonemapping_crosstalk", "Crosstalk factor for tone-mapping", OFFSET(crosstalk), AV_OPT_TYPE_FLOAT, {.dbl = 0.04}, 0.0, 0.30, DYNAMIC | AV_OPT_FLAG_DEPRECATED }, +{ "overshoot", "Tone-mapping overshoot margin", OFFSET(overshoot), AV_OPT_TYPE_FLOAT, {.dbl = 0.05}, 0.0, 1.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED }, #endif { "dithering", "Dither method to use", OFFSET(dithering), AV_OPT_TYPE_INT, {.i64 = PL_DITHER_BLUE_NOISE}, -1, PL_DITHER_METHOD_COUNT - 1, DYNAMIC, "dither" }, -- 2.40.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] avformat/mov: Correctly read EIA608 packets if multiple boxes or non-field 1 data is present
From: Sebastian Dröge The payload of EIA608 samples in MOV is one or more cdat or cdt2 boxes. cdat contains EIA608 byte pairs for field 1, cdt2 for field 2. Previously any box following the first was treated as EIA608 byte pairs instead of parsing them correctly, and all data was handled as field 1. --- libavformat/mov.c | 30 -- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 9fdeef057e..edd14701bf 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8868,22 +8868,40 @@ static int mov_change_extradata(MOVStreamContext *sc, AVPacket *pkt) static int get_eia608_packet(AVIOContext *pb, AVPacket *pkt, int size) { -int new_size, ret; +const uint32_t cdat_fourcc = AV_RL32("cdat"); +const uint32_t cdt2_fourcc = AV_RL32("cdt2"); +int new_size, write_size, ret; if (size <= 8) return AVERROR_INVALIDDATA; + new_size = ((size - 8) / 2) * 3; ret = av_new_packet(pkt, new_size); if (ret < 0) return ret; -avio_skip(pb, 8); -for (int j = 0; j < new_size; j += 3) { -pkt->data[j] = 0xFC; -pkt->data[j+1] = avio_r8(pb); -pkt->data[j+2] = avio_r8(pb); +write_size = 0; +while (size > 8) { + uint32_t box_size = avio_rb32(pb); + uint32_t box_fourcc = avio_rl32(pb); + + if (box_size <= 8 || (box_size & 1) != 0 || box_size > size) +return AVERROR_INVALIDDATA; + if (box_fourcc != cdat_fourcc && box_fourcc != cdt2_fourcc) +return AVERROR_INVALIDDATA; + + for (int j = 8; j < box_size; j += 2) { + pkt->data[write_size] = box_fourcc == cdat_fourcc ? 0xFC : 0xFF; + pkt->data[write_size+1] = avio_r8(pb); + pkt->data[write_size+2] = avio_r8(pb); + } + + write_size += box_size; + size -= box_size; } +av_shrink_packet(pkt, write_size); + return 0; } -- 2.40.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 3/3] avformat/hls: Try to implement RFC8216 playlist refusal
On Mon, 15 May 2023 at 02:06, Michael Niedermayer wrote: > > This is not well tested and can likely be improved, just a > hotfix for hls probe failures since 6b1f68ccb04d791f0250e05687c346a99ff47ea1 > > Should fix Ticket10353 (please test and report cases that still fail) > > Signed-off-by: Michael Niedermayer > --- > libavformat/hls.c | 11 ++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/libavformat/hls.c b/libavformat/hls.c > index df2442c376..790ae7a96a 100644 > --- a/libavformat/hls.c > +++ b/libavformat/hls.c > @@ -2534,7 +2534,16 @@ static int hls_probe(const AVProbeData *p) > strstr(p->buf, "#EXT-X-TARGETDURATION:") || > strstr(p->buf, "#EXT-X-MEDIA-SEQUENCE:")) { > > -if (!av_match_ext(p->filename, "m3u8,hls,m3u")) { > +int mime_ok = p->mime_type && !( > +av_strcasecmp(p->mime_type, "application/vnd.apple.mpegurl") && > +av_strcasecmp(p->mime_type, "audio/mpegurl") && > +av_strcasecmp(p->mime_type, "audio/x-mpegurl") && > +av_strcasecmp(p->mime_type, "application/x-mpegurl") How about we AV_LOG_WARNING when non-standard/deprecated mime type is used? If we want to be strict about rfc8216 only two first should be supported. Of course for compatibility reasons likely we need to support all of them, but warn about it would be nice touch. > +); > + > +if (!av_match_ext(p->filename, "m3u8,hls,m3u") && > + ff_match_url_ext(p->filename, "m3u8,hls,m3u") <= 0 && Where '.hls' came from? I don't think those are in fact used in the wild? Maybe we can be strict and use only "m3u8,m3u"? > +!mime_ok) { > av_log(NULL, AV_LOG_ERROR, "Not detecting m3u8/hls with non > standard extension\n"); This log wording is little bit off now, when there is no extension and only mime matching. > return 0; > } > -- > 2.17.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". Minor remarks, but funcionally the patch resolves the issue. Thanks. - Kacper ___ 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/nvdec_mpeg2: fix order of quant matrix coefficients
mpeg2dec stores them permutated for the IDCT, nvdec expects them in plain raster order. --- libavcodec/nvdec_mpeg12.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c index e10735587d..3b9ff60734 100644 --- a/libavcodec/nvdec_mpeg12.c +++ b/libavcodec/nvdec_mpeg12.c @@ -83,8 +83,9 @@ static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buffer }; for (i = 0; i < 64; ++i) { -ppc->QuantMatrixIntra[i] = s->intra_matrix[i]; -ppc->QuantMatrixInter[i] = s->inter_matrix[i]; +int n = s->idsp.idct_permutation[i]; +ppc->QuantMatrixIntra[i] = s->intra_matrix[n]; +ppc->QuantMatrixInter[i] = s->inter_matrix[n]; } return 0; -- 2.40.1.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] avcodec/nvdec_mpeg2: fix order of quant matrix coefficients
On Mon, May 15, 2023 at 12:51 PM Hendrik Leppkes wrote: > > mpeg2dec stores them permutated for the IDCT, nvdec expects them in > plain raster order. > --- > libavcodec/nvdec_mpeg12.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c > index e10735587d..3b9ff60734 100644 > --- a/libavcodec/nvdec_mpeg12.c > +++ b/libavcodec/nvdec_mpeg12.c > @@ -83,8 +83,9 @@ static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, > const uint8_t *buffer > }; > > for (i = 0; i < 64; ++i) { > -ppc->QuantMatrixIntra[i] = s->intra_matrix[i]; > -ppc->QuantMatrixInter[i] = s->inter_matrix[i]; > +int n = s->idsp.idct_permutation[i]; > +ppc->QuantMatrixIntra[i] = s->intra_matrix[n]; > +ppc->QuantMatrixInter[i] = s->inter_matrix[n]; > } > > return 0; > -- > 2.40.1.windows.1 > Apparently mpeg4 and VDPAU have the same issue. I can test and fix mpeg4, but do not have VDPAU setup, so .. untested commits incoming? - Hendrik ___ 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/4] avcodec/nvdec_mpeg2: fix order of quant matrix coefficients
The matrix coefficients are stored permutated for the IDCT, rather then in plain raster order, and need to be un-permutated for the hardware. --- libavcodec/nvdec_mpeg12.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvdec_mpeg12.c b/libavcodec/nvdec_mpeg12.c index e10735587d..3b9ff60734 100644 --- a/libavcodec/nvdec_mpeg12.c +++ b/libavcodec/nvdec_mpeg12.c @@ -83,8 +83,9 @@ static int nvdec_mpeg12_start_frame(AVCodecContext *avctx, const uint8_t *buffer }; for (i = 0; i < 64; ++i) { -ppc->QuantMatrixIntra[i] = s->intra_matrix[i]; -ppc->QuantMatrixInter[i] = s->inter_matrix[i]; +int n = s->idsp.idct_permutation[i]; +ppc->QuantMatrixIntra[i] = s->intra_matrix[n]; +ppc->QuantMatrixInter[i] = s->inter_matrix[n]; } return 0; -- 2.40.1.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 2/4] avcodec/nvdec_mpeg4: fix order of quant matrix coefficients
The matrix coefficients are stored permutated for the IDCT, rather then in plain raster order, and need to be un-permutated for the hardware. --- libavcodec/nvdec_mpeg4.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvdec_mpeg4.c b/libavcodec/nvdec_mpeg4.c index eac138cc38..c193f6b6e4 100644 --- a/libavcodec/nvdec_mpeg4.c +++ b/libavcodec/nvdec_mpeg4.c @@ -88,8 +88,9 @@ static int nvdec_mpeg4_start_frame(AVCodecContext *avctx, const uint8_t *buffer, }; for (i = 0; i < 64; ++i) { -ppc->QuantMatrixIntra[i] = s->intra_matrix[i]; -ppc->QuantMatrixInter[i] = s->inter_matrix[i]; +int n = s->idsp.idct_permutation[i]; +ppc->QuantMatrixIntra[i] = s->intra_matrix[n]; +ppc->QuantMatrixInter[i] = s->inter_matrix[n]; } // We need to pass the full frame buffer and not just the slice -- 2.40.1.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 3/4] avcodec/vdpau_mpeg12: fix order of quant matrix coefficients
The matrix coefficients are stored permutated for the IDCT, rather then in plain raster order, and need to be un-permutated for the hardware. --- libavcodec/vdpau_mpeg12.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/vdpau_mpeg12.c b/libavcodec/vdpau_mpeg12.c index 354239cad5..79007aa1a8 100644 --- a/libavcodec/vdpau_mpeg12.c +++ b/libavcodec/vdpau_mpeg12.c @@ -75,8 +75,9 @@ static int vdpau_mpeg_start_frame(AVCodecContext *avctx, info->f_code[1][0] = s->mpeg_f_code[1][0]; info->f_code[1][1] = s->mpeg_f_code[1][1]; for (i = 0; i < 64; ++i) { -info->intra_quantizer_matrix[i] = s->intra_matrix[i]; -info->non_intra_quantizer_matrix[i] = s->inter_matrix[i]; +int n = s->idsp.idct_permutation[i]; +info->intra_quantizer_matrix[i] = s->intra_matrix[n]; +info->non_intra_quantizer_matrix[i] = s->inter_matrix[n]; } return ff_vdpau_common_start_frame(pic_ctx, buffer, size); -- 2.40.1.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 4/4] avcodec/vdpau_mpeg4: fix order of quant matrix coefficients
The matrix coefficients are stored permutated for the IDCT, rather then in plain raster order, and need to be un-permutated for the hardware. --- libavcodec/vdpau_mpeg4.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/vdpau_mpeg4.c b/libavcodec/vdpau_mpeg4.c index 6e082eefc6..1211b1df2c 100644 --- a/libavcodec/vdpau_mpeg4.c +++ b/libavcodec/vdpau_mpeg4.c @@ -74,8 +74,9 @@ static int vdpau_mpeg4_start_frame(AVCodecContext *avctx, info->alternate_vertical_scan_flag = s->alternate_scan; info->top_field_first = s->top_field_first; for (i = 0; i < 64; ++i) { -info->intra_quantizer_matrix[i] = s->intra_matrix[i]; -info->non_intra_quantizer_matrix[i] = s->inter_matrix[i]; +int n = s->idsp.idct_permutation[i]; +info->intra_quantizer_matrix[i] = s->intra_matrix[n]; +info->non_intra_quantizer_matrix[i] = s->inter_matrix[n]; } ff_vdpau_common_start_frame(pic_ctx, buffer, size); -- 2.40.1.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] lavc/av1*: fix exporting framerate
On 5/15/2023 5:22 AM, Anton Khirnov wrote: * take num_ticks_per_picture_minus_1 into account, since that is a part of the framerate computation * stop exporting num_ticks_per_picture_minus_1 into AVCodecContext.ticks_per_frame, as that field is used for other purposes (in conjunction with repeat_pict, which is not used at all by av1) --- libavcodec/Makefile | 2 +- libavcodec/av1_parse.c | 14 ++ libavcodec/av1_parse.h | 3 +++ libavcodec/av1_parser.c | 11 ++- libavcodec/av1dec.c | 14 +- 5 files changed, 29 insertions(+), 15 deletions(-) LGTM ___ 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] lavc/libdav1d: fix exporting framerate
On 5/15/2023 5:22 AM, Anton Khirnov wrote: Same issues as in the previous commit. --- Updated for changes in previous patch. --- libavcodec/Makefile | 2 +- libavcodec/libdav1d.c | 10 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9587e56493..4d59411662 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1086,7 +1086,7 @@ OBJS-$(CONFIG_LIBARIBCAPTION_DECODER) += libaribcaption.o ass.o OBJS-$(CONFIG_LIBCELT_DECODER)+= libcelt_dec.o OBJS-$(CONFIG_LIBCODEC2_DECODER) += libcodec2.o OBJS-$(CONFIG_LIBCODEC2_ENCODER) += libcodec2.o -OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o +OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o av1_parse.o OBJS-$(CONFIG_LIBDAVS2_DECODER) += libdavs2.o OBJS-$(CONFIG_LIBFDK_AAC_DECODER) += libfdk-aacdec.o OBJS-$(CONFIG_LIBFDK_AAC_ENCODER) += libfdk-aacenc.o diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index af072da681..0320ae7c6c 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -30,6 +30,7 @@ #include "libavutil/opt.h" #include "atsc_a53.h" +#include "av1_parse.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" @@ -154,12 +155,9 @@ static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *s else c->pix_fmt = pix_fmt[seq->layout][seq->hbd]; -if (seq->num_units_in_tick && seq->time_scale) { -av_reduce(&c->framerate.den, &c->framerate.num, - seq->num_units_in_tick, seq->time_scale, INT_MAX); -if (seq->equal_picture_interval) -c->ticks_per_frame = seq->num_ticks_per_picture; -} +c->framerate = ff_av1_framerate(seq->num_ticks_per_picture, +seq->num_units_in_tick, +seq->time_scale); libdav1d unfortunately is currently exporting num_units_in_tick and time_scale as int, so in the (very unlikely but valid) case a value was > INT_MAX in the bitstream, it will be stored in those as a negative value. I suppose casting them to unsigned here should be enough. if (seq->film_grain_present) c->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; ___ 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/nvdec_mpeg2: fix order of quant matrix coefficients
On Mon, May 15, 2023 at 1:30 PM Hendrik Leppkes wrote: > > Apparently mpeg4 and VDPAU have the same issue. I can test and fix > mpeg4, but do not have VDPAU setup, so .. untested commits incoming? > Tested and confirmed mpeg2 and mpeg4 are fixed for NVDEC, and elenril tested VDPAU with the same result. OK'ed by BtbN on IRC. Going to push later today. - Hendrik ___ 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] lavc/libdav1d: fix exporting framerate
Same issues as in the previous commit. --- libavcodec/Makefile | 2 +- libavcodec/libdav1d.c | 10 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9587e56493..4d59411662 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1086,7 +1086,7 @@ OBJS-$(CONFIG_LIBARIBCAPTION_DECODER) += libaribcaption.o ass.o OBJS-$(CONFIG_LIBCELT_DECODER)+= libcelt_dec.o OBJS-$(CONFIG_LIBCODEC2_DECODER) += libcodec2.o OBJS-$(CONFIG_LIBCODEC2_ENCODER) += libcodec2.o -OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o +OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o av1_parse.o OBJS-$(CONFIG_LIBDAVS2_DECODER) += libdavs2.o OBJS-$(CONFIG_LIBFDK_AAC_DECODER) += libfdk-aacdec.o OBJS-$(CONFIG_LIBFDK_AAC_ENCODER) += libfdk-aacenc.o diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index af072da681..4c48f0099a 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -30,6 +30,7 @@ #include "libavutil/opt.h" #include "atsc_a53.h" +#include "av1_parse.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" @@ -154,12 +155,9 @@ static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *s else c->pix_fmt = pix_fmt[seq->layout][seq->hbd]; -if (seq->num_units_in_tick && seq->time_scale) { -av_reduce(&c->framerate.den, &c->framerate.num, - seq->num_units_in_tick, seq->time_scale, INT_MAX); -if (seq->equal_picture_interval) -c->ticks_per_frame = seq->num_ticks_per_picture; -} +c->framerate = ff_av1_framerate(seq->num_ticks_per_picture, +(unsigned)seq->num_units_in_tick, +(unsigned)seq->time_scale); if (seq->film_grain_present) c->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; -- 2.39.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] lavc/libdav1d: fix exporting framerate
On 5/15/2023 9:22 AM, Anton Khirnov wrote: Same issues as in the previous commit. --- libavcodec/Makefile | 2 +- libavcodec/libdav1d.c | 10 -- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 9587e56493..4d59411662 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1086,7 +1086,7 @@ OBJS-$(CONFIG_LIBARIBCAPTION_DECODER) += libaribcaption.o ass.o OBJS-$(CONFIG_LIBCELT_DECODER)+= libcelt_dec.o OBJS-$(CONFIG_LIBCODEC2_DECODER) += libcodec2.o OBJS-$(CONFIG_LIBCODEC2_ENCODER) += libcodec2.o -OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o +OBJS-$(CONFIG_LIBDAV1D_DECODER) += libdav1d.o av1_parse.o OBJS-$(CONFIG_LIBDAVS2_DECODER) += libdavs2.o OBJS-$(CONFIG_LIBFDK_AAC_DECODER) += libfdk-aacdec.o OBJS-$(CONFIG_LIBFDK_AAC_ENCODER) += libfdk-aacenc.o diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index af072da681..4c48f0099a 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -30,6 +30,7 @@ #include "libavutil/opt.h" #include "atsc_a53.h" +#include "av1_parse.h" #include "avcodec.h" #include "bytestream.h" #include "codec_internal.h" @@ -154,12 +155,9 @@ static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *s else c->pix_fmt = pix_fmt[seq->layout][seq->hbd]; -if (seq->num_units_in_tick && seq->time_scale) { -av_reduce(&c->framerate.den, &c->framerate.num, - seq->num_units_in_tick, seq->time_scale, INT_MAX); -if (seq->equal_picture_interval) -c->ticks_per_frame = seq->num_ticks_per_picture; -} +c->framerate = ff_av1_framerate(seq->num_ticks_per_picture, +(unsigned)seq->num_units_in_tick, +(unsigned)seq->time_scale); if (seq->film_grain_present) c->properties |= FF_CODEC_PROPERTY_FILM_GRAIN; LGTM ___ 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/2] avformat/avcodec: Add DTS-UHD demuxer and parser, movenc support.
On 5/13/23 12:28 AM, Paul B Mahol wrote: > How to test this additions, any samples available? Hi, I have uploaded a DTS:X audio sample to google drive: drive. google. com /drive/folders/ 1jbfsZvnrBDmgQS0VLKBAnsZaxgf28vYh?usp=sharing Thanks for looking this over, -Roy ___ 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 v1 1/2] fate/imf: fix memory leak
From: Pierre-Anthony Lemieux --- libavformat/tests/imf.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c index cfd84fb8c8..a5bdf16645 100644 --- a/libavformat/tests/imf.c +++ b/libavformat/tests/imf.c @@ -402,6 +402,9 @@ static int test_bad_cpl_parsing(FFIMFCPL **cpl) return ret; } +ff_imf_cpl_free(*cpl); +*cpl = NULL; + return 0; } @@ -423,6 +426,9 @@ static int test_bad_resource_cpl_parsing(FFIMFCPL **cpl) return ret; } +ff_imf_cpl_free(*cpl); +*cpl = NULL; + return 0; } @@ -594,8 +600,12 @@ int main(int argc, char *argv[]) printf(" End failing test \n"); printf(" The following should emit errors \n"); -if (test_bad_resource_cpl_parsing(&cpl) != 0) +if (test_bad_resource_cpl_parsing(&cpl) != 0) { +ret = 1; +} else if (cpl) { +printf("Improper cleanup after failed CPL parsing\n"); ret = 1; +} printf(" End emission of errors \n"); return ret; -- 2.25.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 v1 2/2] fate/imf: remove redundant code
From: Pierre-Anthony Lemieux --- libavformat/tests/imf.c | 38 +- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c index a5bdf16645..a23b687c3d 100644 --- a/libavformat/tests/imf.c +++ b/libavformat/tests/imf.c @@ -257,7 +257,7 @@ const char *cpl_doc = "" ""; -const char *cpl_bad_doc = ""; +const char *cpl_bad_empty_doc = ""; const char *asset_map_doc = "" @@ -384,36 +384,11 @@ static int test_cpl_parsing(void) return 0; } -static int test_bad_cpl_parsing(FFIMFCPL **cpl) -{ -xmlDocPtr doc; -int ret; - -doc = xmlReadMemory(cpl_bad_doc, strlen(cpl_bad_doc), NULL, NULL, 0); -if (doc == NULL) { -printf("XML parsing failed.\n"); -return 1; -} - -ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl); -xmlFreeDoc(doc); -if (ret) { -printf("CPL parsing failed.\n"); -return ret; -} - -ff_imf_cpl_free(*cpl); -*cpl = NULL; - -return 0; -} - -static int test_bad_resource_cpl_parsing(FFIMFCPL **cpl) -{ +static int test_bad_cpl(FFIMFCPL **cpl, const char* bad_cpl_doc) { xmlDocPtr doc; int ret; -doc = xmlReadMemory(cpl_bad_resource_doc, strlen(cpl_bad_resource_doc), NULL, NULL, 0); +doc = xmlReadMemory(bad_cpl_doc, strlen(bad_cpl_doc), NULL, NULL, 0); if (doc == NULL) { printf("XML parsing failed.\n"); return 1; @@ -591,7 +566,7 @@ int main(int argc, char *argv[]) ret = 1; printf(" The following should fail \n"); -if (test_bad_cpl_parsing(&cpl) == 0) { +if (test_bad_cpl(&cpl, cpl_bad_empty_doc) == 0) { ret = 1; } else if (cpl) { printf("Improper cleanup after failed CPL parsing\n"); @@ -600,10 +575,7 @@ int main(int argc, char *argv[]) printf(" End failing test \n"); printf(" The following should emit errors \n"); -if (test_bad_resource_cpl_parsing(&cpl) != 0) { -ret = 1; -} else if (cpl) { -printf("Improper cleanup after failed CPL parsing\n"); +if (test_bad_cpl(&cpl, cpl_bad_resource_doc) != 0) { ret = 1; } printf(" End emission of errors \n"); -- 2.25.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 v3 1/2] fate/imf: fix memory leak
From: Pierre-Anthony Lemieux --- libavformat/tests/imf.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c index cfd84fb8c8..c02cd87ceb 100644 --- a/libavformat/tests/imf.c +++ b/libavformat/tests/imf.c @@ -402,6 +402,9 @@ static int test_bad_cpl_parsing(FFIMFCPL **cpl) return ret; } +ff_imf_cpl_free(*cpl); +*cpl = NULL; + return 0; } @@ -423,6 +426,9 @@ static int test_bad_resource_cpl_parsing(FFIMFCPL **cpl) return ret; } +ff_imf_cpl_free(*cpl); +*cpl = NULL; + return 0; } @@ -594,8 +600,11 @@ int main(int argc, char *argv[]) printf(" End failing test \n"); printf(" The following should emit errors \n"); -if (test_bad_resource_cpl_parsing(&cpl) != 0) +if (test_bad_resource_cpl_parsing(&cpl) != 0) { +if (cpl) +printf("Improper cleanup after failed CPL parsing\n"); ret = 1; +} printf(" End emission of errors \n"); return ret; -- 2.25.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 v3 2/2] fate/imf: remove redundant code
From: Pierre-Anthony Lemieux --- libavformat/tests/imf.c | 52 ++--- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/libavformat/tests/imf.c b/libavformat/tests/imf.c index c02cd87ceb..068ee6c58a 100644 --- a/libavformat/tests/imf.c +++ b/libavformat/tests/imf.c @@ -257,7 +257,7 @@ const char *cpl_doc = "" ""; -const char *cpl_bad_doc = ""; +const char *cpl_bad_empty_doc = ""; const char *asset_map_doc = "" @@ -384,52 +384,31 @@ static int test_cpl_parsing(void) return 0; } -static int test_bad_cpl_parsing(FFIMFCPL **cpl) -{ -xmlDocPtr doc; -int ret; - -doc = xmlReadMemory(cpl_bad_doc, strlen(cpl_bad_doc), NULL, NULL, 0); -if (doc == NULL) { -printf("XML parsing failed.\n"); -return 1; -} - -ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl); -xmlFreeDoc(doc); -if (ret) { -printf("CPL parsing failed.\n"); -return ret; -} - -ff_imf_cpl_free(*cpl); -*cpl = NULL; - -return 0; -} - -static int test_bad_resource_cpl_parsing(FFIMFCPL **cpl) -{ +static int test_cpl_from_doc(FFIMFCPL **cpl, const char* cpl_doc, int should_pass) { xmlDocPtr doc; int ret; -doc = xmlReadMemory(cpl_bad_resource_doc, strlen(cpl_bad_resource_doc), NULL, NULL, 0); +doc = xmlReadMemory(cpl_doc, strlen(cpl_doc), NULL, NULL, 0); if (doc == NULL) { printf("XML parsing failed.\n"); -return 1; +return should_pass; } ret = ff_imf_parse_cpl_from_xml_dom(doc, cpl); xmlFreeDoc(doc); if (ret) { printf("CPL parsing failed.\n"); -return ret; +if (*cpl) { +printf("Improper cleanup after failed CPL parsing\n"); +return 1; +} +return should_pass; } ff_imf_cpl_free(*cpl); *cpl = NULL; -return 0; +return !should_pass; } static int check_asset_locator_attributes(IMFAssetLocator *asset, IMFAssetLocator *expected_asset) @@ -591,20 +570,13 @@ int main(int argc, char *argv[]) ret = 1; printf(" The following should fail \n"); -if (test_bad_cpl_parsing(&cpl) == 0) { +if (test_cpl_from_doc(&cpl, cpl_bad_empty_doc, 0) != 0) ret = 1; -} else if (cpl) { -printf("Improper cleanup after failed CPL parsing\n"); -ret = 1; -} printf(" End failing test \n"); printf(" The following should emit errors \n"); -if (test_bad_resource_cpl_parsing(&cpl) != 0) { -if (cpl) -printf("Improper cleanup after failed CPL parsing\n"); +if (test_cpl_from_doc(&cpl, cpl_bad_resource_doc, 1) != 0) ret = 1; -} printf(" End emission of errors \n"); return ret; -- 2.25.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] Global variables in FFmpeg command expressions?
Hi all, I recently made a feature request to one of the community members. I was ready to pay a reasonable amount for it, but as it was a relatively quick fix, he was kind enough to implement it on his own, and I made a donation to the community instead. The feature I refer to is the “keep” parameter on the mpdecimate filter, which was implemented by Thilo Borgmann. I am a retired software developer and although I embraced some really complex projects in the past (including occasional code contributions to the LLVM compiler project) I am not currently in the disposition to do it anymore due to several reasons mostly related to age. So, I just joined this mailing list because I want to suggest a further improvement to FFmpeg, or otherwise ask for workarounds. The problem I want to solve is to trim duplicated frames of a video clip, in the same exact way that the mpdecimate does, but preserving the corresponding audio sections of the preserved video frames in correct sync on the output video. Or in other words, trim duplicated frames from a video input, while also trimming the corresponding audio, in sync. To accomplish this, I attempted commands such as this one: ffmpeg -i $INPUT -vf "select='if( gt(scene,0.1), (st(1,t);st(2,1)), if(lte(t-ld(1),${KEEP}),st(2,1),st(2,0)) )', setpts=N/FRAME_RATE/TB" -af "aselect='ld(2)', asetpts=N/SR/TB” $OUTPUT The trick here is (or would be) to use variable number 2 from the video section to tell the audio section which frames to select (based on what the video section is selecting). However, this won't work because ‘variable’ number 2 from the first ‘select’ expression is out of scope on the ‘aselect’ expression. Therefore it always evaluates to 0 in the ‘aselect’ expression and the output goes with no audio. I think that having a way to specify ‘global’ variables, with valid scope through the entire ffmpeg command, featuring 'store global' and 'load global’ semantics, would be very helpful and would enormously increase the use cases for this library. So it would be nice if somebody would look at implementing it. I understand this is far from straightforward, but It would be game changing if done in my opinion. As said, my current use case is trimming the audio stream in sync with the video stream as described above. So alternatively, I would appreciate any hints on how to accomplish this if this is /already/ possible. Thanks John LLuch ___ 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 04/13] lavf: use AV_CODEC_PROP_FIELDS where appropriate
On Tue, May 09, 2023 at 10:44:50AM +0200, Anton Khirnov wrote: > Quoting Michael Niedermayer (2023-05-08 16:15:42) > > On Sun, May 07, 2023 at 03:32:46PM +0200, Anton Khirnov wrote: > > > H.264 and mpeg12 parsers need to be adjusted at the same time to stop > > > using the value of AVCodecContext.ticks_per_frame, because it is not set > > > correctly unless the codec has been opened. Previously this would result > > > in both the parser and lavf seeing the same incorrect value, which would > > > cancel out. > > > Updating lavf and not the parsers would result in correct value in lavf, > > > but the wrong one in parsers, which would break some tests. > > > --- > > > libavcodec/h264_parser.c | 4 ++-- > > > libavcodec/mpegvideo_parser.c | 2 +- > > > libavformat/avformat.c| 9 ++--- > > > libavformat/demux.c | 29 +++-- > > > libavformat/internal.h| 3 +++ > > > 5 files changed, 31 insertions(+), 16 deletions(-) > > > > Doesnt this sort of change need a major ABI bump ? > > it sounds like lavc and lavf interdepend here both ways > > No, we do not guarantee bug compatibility. > > Libavformat seeing ticks_per_frame=1 for codecs that set it to 2 upon > being opened is a bug. Same for the parser. > > It just so happens that libavformat AND its internal parser instance see > the same incorrect value and this cancels out in cases that are tested > by FATE (it would break if we had more thorough tests for repeating > single fields). This patch seems to change tbr ./ffmpeg -i fate-suite//h264/lossless.h264 Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv420p(progressive), 640x480, 25 fps, 60 tbr, 1200k tbn vs. Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv420p(progressive), 640x480, 25 fps, 120 tbr, 1200k tbn with ./ffmpeg -i fate-suite//h264/lossless.h264 -f framecrc - The output uses 1/60 thats odd because if every frame can be represented in 1/60 then tbr is 1/60 or more course OTOH if tbr is finer than 1/60 then not every frame can be represented in 1/60 maybe iam missing something but the new value seems worse and also not consistent with what ffmpeg actually uses thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Avoid a single point of failure, be that a person or equipment. 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 2/3] avformat: add ff_match_url_ext()
On Sun, May 14, 2023 at 11:10:00PM -0400, Leo Izen wrote: > On 5/14/23 20:05, Michael Niedermayer wrote: > > Match url against a list of extensions similar to av_match_ext() > > > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/format.c | 25 + > > libavformat/internal.h | 9 + > > 2 files changed, 34 insertions(+) > > > > diff --git a/libavformat/format.c b/libavformat/format.c > > index 52b814e67d..04fdbacec0 100644 > > --- a/libavformat/format.c > > +++ b/libavformat/format.c > > @@ -50,6 +50,31 @@ int av_match_ext(const char *filename, const char > > *extensions) > > return 0; > > } > > +int ff_match_url_ext(const char *url, const char *extensions) > > +{ > > +const char *ext; > > +URLComponents uc; > > +int ret; > > +char scratchpad[128]; > > + > > +if (!url) > > +return 0; > > + > > +ret = ff_url_decompose(&uc, url, NULL); > > +if (ret < 0 || !URL_COMPONENT_HAVE(uc, scheme)) > > +return ret; > > +for (ext = uc.query; *ext != '.' && ext > uc.path; ext--) > > +; > + > > +if (*ext != '.') > > +return 0; > > +if (uc.query - ext > sizeof(scratchpad)) > > +return AVERROR(ENOMEM); //not enough memory in our scratchpad > > +av_strlcpy(scratchpad, ext + 1, FFMIN(sizeof(scratchpad), uc.query - > > ext)); > > This FFMIN is superfluous as sizeof(scratchpad) will always be greater than > or equal to uc.query - ext after the check above it. yes, ill remove it, if noone else did it before me > > > + > > +return av_match_name(scratchpad, extensions); > > +} > > + > > const AVOutputFormat *av_guess_format(const char *short_name, const char > > *filename, > > const char *mime_type) > > { > > diff --git a/libavformat/internal.h b/libavformat/internal.h > > index f575064e8f..43466fbe6d 100644 > > --- a/libavformat/internal.h > > +++ b/libavformat/internal.h > > @@ -705,6 +705,15 @@ int ff_unlock_avformat(void); > >*/ > > void ff_format_set_url(AVFormatContext *s, char *url); > > +/** > > + * Return a positive value if the given url has one of the given > > + * extensions, 0 otherwise. > > + * > > + * @param filename file name to check against the given extensions > > Copy/paste error, this should be @param url. too late, ive already pushed the patch with this fixed thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User questions about the command line tools should be sent to the ffmpeg-user ML. And questions about how to use libav* should be sent to the libav-user ML. 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] avformat/hls: Try to implement RFC8216 playlist refusal
On Sun, May 14, 2023 at 11:14:12PM -0400, Leo Izen wrote: > > > On 5/14/23 20:05, Michael Niedermayer wrote: > > This is not well tested and can likely be improved, just a > > hotfix for hls probe failures since 6b1f68ccb04d791f0250e05687c346a99ff47ea1 > > > > Should fix Ticket10353 (please test and report cases that still fail) > > > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/hls.c | 11 ++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/hls.c b/libavformat/hls.c > > index df2442c376..790ae7a96a 100644 > > --- a/libavformat/hls.c > > +++ b/libavformat/hls.c > > @@ -2534,7 +2534,16 @@ static int hls_probe(const AVProbeData *p) > > strstr(p->buf, "#EXT-X-TARGETDURATION:") || > > strstr(p->buf, "#EXT-X-MEDIA-SEQUENCE:")) { > > -if (!av_match_ext(p->filename, "m3u8,hls,m3u")) { > > +int mime_ok = p->mime_type && !( > > +av_strcasecmp(p->mime_type, "application/vnd.apple.mpegurl") && > > +av_strcasecmp(p->mime_type, "audio/mpegurl") && > > +av_strcasecmp(p->mime_type, "audio/x-mpegurl") && > > +av_strcasecmp(p->mime_type, "application/x-mpegurl") > > +); > > + > > +if (!av_match_ext(p->filename, "m3u8,hls,m3u") && > > + ff_match_url_ext(p->filename, "m3u8,hls,m3u") <= 0 && > What's the point of checking both av_match_ext and ff_match_url_ext here? > Should only want one or the other. is p->filename a URL ? > > +!mime_ok) { > > Put !mime_ok first to take advantage of lazy &&, as it will usually be okay > in practice. ok, will reorder it thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Homeopathy is like voting while filling the ballot out with transparent ink. Sometimes the outcome one wanted occurs. Rarely its worse than filling out a ballot properly. 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] avformat/hls: Try to implement RFC8216 playlist refusal
On Mon, May 15, 2023 at 11:58:16AM +0200, Kacper Michajlow wrote: > On Mon, 15 May 2023 at 02:06, Michael Niedermayer > wrote: > > > > This is not well tested and can likely be improved, just a > > hotfix for hls probe failures since 6b1f68ccb04d791f0250e05687c346a99ff47ea1 > > > > Should fix Ticket10353 (please test and report cases that still fail) > > > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/hls.c | 11 ++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/libavformat/hls.c b/libavformat/hls.c > > index df2442c376..790ae7a96a 100644 > > --- a/libavformat/hls.c > > +++ b/libavformat/hls.c > > @@ -2534,7 +2534,16 @@ static int hls_probe(const AVProbeData *p) > > strstr(p->buf, "#EXT-X-TARGETDURATION:") || > > strstr(p->buf, "#EXT-X-MEDIA-SEQUENCE:")) { > > > > -if (!av_match_ext(p->filename, "m3u8,hls,m3u")) { > > +int mime_ok = p->mime_type && !( > > +av_strcasecmp(p->mime_type, "application/vnd.apple.mpegurl") && > > +av_strcasecmp(p->mime_type, "audio/mpegurl") && > > +av_strcasecmp(p->mime_type, "audio/x-mpegurl") && > > +av_strcasecmp(p->mime_type, "application/x-mpegurl") > > How about we AV_LOG_WARNING when non-standard/deprecated mime type is > used? If we want to be strict about rfc8216 only two first should be > supported. Of course for compatibility reasons likely we need to > support all of them, but warn about it would be nice touch. ok > > > +); > > + > > +if (!av_match_ext(p->filename, "m3u8,hls,m3u") && > > + ff_match_url_ext(p->filename, "m3u8,hls,m3u") <= 0 && > > Where '.hls' came from? I don't think those are in fact used in the > wild? Maybe we can be strict and use only "m3u8,m3u"? i was thinking of it but i left them in yesterday. Ill post a patch that would remove them. I have a few files ending in hls but none of them qualify as "in the wild" > > > +!mime_ok) { > > av_log(NULL, AV_LOG_ERROR, "Not detecting m3u8/hls with non > > standard extension\n"); > > This log wording is little bit off now, when there is no extension and > only mime matching. will post a patch thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB It is dangerous to be right in matters on which the established authorities are wrong. -- Voltaire 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] Global variables in FFmpeg command expressions?
On Mon, May 15, 2023 at 8:45 PM Joan Lluch wrote: > Hi all, > > I recently made a feature request to one of the community members. I was > ready to pay a reasonable amount for it, but as it was a relatively quick > fix, he was kind enough to implement it on his own, and I made a donation > to the community instead. The feature I refer to is the “keep” parameter on > the mpdecimate filter, which was implemented by Thilo Borgmann. > > I am a retired software developer and although I embraced some really > complex projects in the past (including occasional code contributions to > the LLVM compiler project) I am not currently in the disposition to do it > anymore due to several reasons mostly related to age. > > So, I just joined this mailing list because I want to suggest a further > improvement to FFmpeg, or otherwise ask for workarounds. > > The problem I want to solve is to trim duplicated frames of a video clip, > in the same exact way that the mpdecimate does, but preserving the > corresponding audio sections of the preserved video frames in correct sync > on the output video. Or in other words, trim duplicated frames from a video > input, while also trimming the corresponding audio, in sync. > > To accomplish this, I attempted commands such as this one: > > ffmpeg -i $INPUT -vf "select='if( gt(scene,0.1), (st(1,t);st(2,1)), > if(lte(t-ld(1),${KEEP}),st(2,1),st(2,0)) )', setpts=N/FRAME_RATE/TB" -af > "aselect='ld(2)', asetpts=N/SR/TB” $OUTPUT > > The trick here is (or would be) to use variable number 2 from the video > section to tell the audio section which frames to select (based on what the > video section is selecting). However, this won't work because ‘variable’ > number 2 from the first ‘select’ expression is out of scope on the > ‘aselect’ expression. Therefore it always evaluates to 0 in the ‘aselect’ > expression and the output goes with no audio. > > I think that having a way to specify ‘global’ variables, with valid scope > through the entire ffmpeg command, featuring 'store global' and 'load > global’ semantics, would be very helpful and would enormously increase the > use cases for this library. So it would be nice if somebody would look at > implementing it. I understand this is far from straightforward, but It > would be game changing if done in my opinion. > > As said, my current use case is trimming the audio stream in sync with the > video stream as described above. So alternatively, I would appreciate any > hints on how to accomplish this if this is /already/ possible. > That approach is prone to many errors and makes it useless if frame threading is added to libavfilter. Instead filter that takes both A and V stream and outputs A and V stream is more solid approach. > > Thanks > > John LLuch > > > ___ > 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/2] avformat/avcodec: Add DTS-UHD demuxer and parser, movenc support.
On Mon, May 15, 2023 at 07:50:27AM -0700, Roy Funderburk wrote: > On 5/13/23 12:28 AM, Paul B Mahol wrote: > > How to test this additions, any samples available? > > > Hi, > > I have uploaded a DTS:X audio sample to google drive: > > drive. google. com /drive/folders/ > 1jbfsZvnrBDmgQS0VLKBAnsZaxgf28vYh?usp=sharing Seems iam unable to download this. google complains about some 3rd party cookies being disabled when i try to download. This seems new Which is kind of odd and lame from google I think getting googles surveliance machienery working in my browser is too much work, so ill hope this file will find its way to samples or something thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Observe your enemies, for they first find out your faults. -- Antisthenes signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org 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 v10 0/6] Support enhanced flv in FFmpeg
On Mon, May 15, 2023 at 4:32 AM Steven Liu wrote: > > Reference file: > https://github.com/veovera/enhanced-rtmp/blob/main/enhanced-rtmp-v1.pdf > The Enhanced flv has been supported by OBS, Simple Realtime Server, mpegts.js. > you can publish hevc, av1 or vp9 codec stream to Youtube over rtmp. > The enhanced flv documentation contributors include > Jean-Baptiste Kempf (FFmpeg, VideoLAN). > So this should be support by ffmpeg too. > > v8: > Support vp9 codec according to enhanced flv. > Support PacketTypeCodedFrames type for hevc in flv. > v9: > Add dependency codec object files for flvenc in Makefile. > Move the hevc,av1,vp9 codec out of FF_COMPLIANCE_UNOFFICIAL. > > v10: > modify first patch comment like the others before commit. > exheader mode should only happened in video stream this patchset. > > Steven Liu (6): > avformat/flvenc: support mux hevc in enhanced flv > avformat/flvdec: support demux hevc in enhanced flv > avformat/flvenc: support mux av1 in enhanced flv > avformat/flvdec: support demux av1 in enhanced flv > avformat/flvenc: support mux vp9 in enhanced flv > avformat/flvdec: support demux vp9 in enhanced flv > > libavformat/Makefile | 2 +- > libavformat/flv.h| 15 + > libavformat/flvdec.c | 73 +++- > libavformat/flvenc.c | 58 +-- > 4 files changed, 130 insertions(+), 18 deletions(-) > This version works for me. Thanks for this work! Tested-by: Neal Gompa Reviewed-by: Neal Gompa -- 真実はいつも一つ!/ Always, there's only one truth! ___ 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 04/13] lavf: use AV_CODEC_PROP_FIELDS where appropriate
Quoting Michael Niedermayer (2023-05-15 20:59:42) > On Tue, May 09, 2023 at 10:44:50AM +0200, Anton Khirnov wrote: > > Quoting Michael Niedermayer (2023-05-08 16:15:42) > > > On Sun, May 07, 2023 at 03:32:46PM +0200, Anton Khirnov wrote: > > > > H.264 and mpeg12 parsers need to be adjusted at the same time to stop > > > > using the value of AVCodecContext.ticks_per_frame, because it is not set > > > > correctly unless the codec has been opened. Previously this would result > > > > in both the parser and lavf seeing the same incorrect value, which would > > > > cancel out. > > > > Updating lavf and not the parsers would result in correct value in lavf, > > > > but the wrong one in parsers, which would break some tests. > > > > --- > > > > libavcodec/h264_parser.c | 4 ++-- > > > > libavcodec/mpegvideo_parser.c | 2 +- > > > > libavformat/avformat.c| 9 ++--- > > > > libavformat/demux.c | 29 +++-- > > > > libavformat/internal.h| 3 +++ > > > > 5 files changed, 31 insertions(+), 16 deletions(-) > > > > > > Doesnt this sort of change need a major ABI bump ? > > > it sounds like lavc and lavf interdepend here both ways > > > > No, we do not guarantee bug compatibility. > > > > Libavformat seeing ticks_per_frame=1 for codecs that set it to 2 upon > > being opened is a bug. Same for the parser. > > > > It just so happens that libavformat AND its internal parser instance see > > the same incorrect value and this cancels out in cases that are tested > > by FATE (it would break if we had more thorough tests for repeating > > single fields). > > This patch seems to change tbr > ./ffmpeg -i fate-suite//h264/lossless.h264 > Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv420p(progressive), > 640x480, 25 fps, 60 tbr, 1200k tbn > vs. > Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv420p(progressive), > 640x480, 25 fps, 120 tbr, 1200k tbn > > with > ./ffmpeg -i fate-suite//h264/lossless.h264 -f framecrc - > > The output uses 1/60 thats odd because if every frame can be represented in > 1/60 then tbr is 1/60 or more course > OTOH if tbr is finer than 1/60 then not every frame can be represented in 1/60 > > maybe iam missing something but the new value seems worse and also > not consistent with what ffmpeg actually uses ticks_per_frame was added by you in 3797c74ba53, and according to your code it's supposed to be 2 for H.264. It just so happens that for this specific sample libavformat invokes the parser without opening the decoder, so it sees the default value of 1. If it did open the decoder, it would see 2. This patch at least makes it consistent, even if it might not always be the optimal choice. As far as I'm concerned, the entire notion of 'tbr' is fundamentally flawed and should be abandoned. There is no magical way for the code to know what timebase is truly the right one here, without reading the whole file. Furthermore, the entire approach of "some sample X is now getting slightly worse arbitrary numbers than before" seems highly questionable to me. Our timestamps code is a unholy mess of hacks upon hacks upon hacks. For pretty much ANY change one can find or construct a sample that decodes worse after it. We should stop focusing on individual samples and prioritize overall consistency and correctness. -- Anton Khirnov ___ 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/src_movie: switch to activate()
Attached. From a5bfd2e0856a02989ce7f1d2a4f3b9f45c77189f Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sat, 2 Apr 2022 14:06:22 +0200 Subject: [PATCH 1/3] avfilter/src_movie: switch to activate() Signed-off-by: Paul B Mahol --- libavfilter/src_movie.c | 91 + 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index 5937613d13..a7d7c188e6 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -46,6 +46,7 @@ #include "audio.h" #include "avfilter.h" +#include "filters.h" #include "formats.h" #include "internal.h" #include "video.h" @@ -55,6 +56,7 @@ typedef struct MovieStream { AVCodecContext *codec_ctx; int64_t discontinuity_threshold; int64_t last_pts; +int got_eof; } MovieStream; typedef struct MovieContext { @@ -70,6 +72,7 @@ typedef struct MovieContext { int64_t discontinuity_threshold; int64_t ts_offset; int dec_threads; +int got_eagain; AVFormatContext *format_ctx; @@ -100,7 +103,6 @@ static const AVOption movie_options[]= { }; static int movie_config_output_props(AVFilterLink *outlink); -static int movie_request_frame(AVFilterLink *outlink); static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) { @@ -314,7 +316,6 @@ static av_cold int movie_common_init(AVFilterContext *ctx) if (!pad.name) return AVERROR(ENOMEM); pad.config_props = movie_config_output_props; -pad.request_frame = movie_request_frame; if ((ret = ff_append_outpad_free_name(ctx, &pad)) < 0) return ret; if ( movie->st[i].st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && @@ -551,50 +552,70 @@ static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) if (ret < 0) return ret; -return 0; +return 1; } -static int movie_request_frame(AVFilterLink *outlink) +static int activate(AVFilterContext *ctx) { -AVFilterContext *ctx = outlink->src; MovieContext *movie = ctx->priv; -unsigned out_id = FF_OUTLINK_IDX(outlink); +int ret = 0; -while (1) { -int got_eagain = 0, got_eof = 0; -int ret = 0; +/* check all decoders for available output */ +for (int i = 0; i < ctx->nb_outputs; i++) { +if (movie->st[i].got_eof) +continue; -/* check all decoders for available output */ -for (int i = 0; i < ctx->nb_outputs; i++) { + +if (ff_outlink_frame_wanted(ctx->outputs[i])) ret = movie_push_frame(ctx, i); -if (ret == AVERROR(EAGAIN)) -got_eagain++; -else if (ret == AVERROR_EOF) -got_eof++; -else if (ret < 0) -return ret; -else if (i == out_id) -return 0; +if (ret == AVERROR(EAGAIN)) +movie->got_eagain++; +else if (ret == AVERROR_EOF) +movie->st[i].got_eof = 1; +else if (ret < 0) +return ret; +else if (ret == 1) +return 0; +} + +if (movie->got_eagain) { +/* all decoders require more input -> read a new packet */ +movie->got_eagain = 0; +ret = movie_decode_packet(ctx); +if (ret < 0 && ret != AVERROR(EAGAIN)) +return ret; +ff_filter_set_ready(ctx, 100); +return 0; +} else { +int nb_eofs = 0; + +for (int i = 0; i < ctx->nb_outputs; i++) { +if (movie->st[i].got_eof) { +if (movie->loop_count == 1) +ff_outlink_set_status(ctx->outputs[i], AVERROR_EOF, movie->st[i].last_pts); +nb_eofs++; +} +} + +if (nb_eofs != ctx->nb_outputs) { +ff_filter_set_ready(ctx, 100); +return 0; } -if (got_eagain) { -/* all decoders require more input -> read a new packet */ -ret = movie_decode_packet(ctx); +if (movie->loop_count != 1) { +ret = rewind_file(ctx); if (ret < 0) return ret; -} else if (got_eof) { -/* all decoders flushed */ -if (movie->loop_count != 1) { -ret = rewind_file(ctx); -if (ret < 0) -return ret; -movie->loop_count -= movie->loop_count > 1; -av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n"); -continue; -} -return AVERROR_EOF; +movie->loop_count -= movie->loop_count > 1; +av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n"); +for (int i = 0; i < ctx->nb_outputs; i++) +movie->st[i].got_eof = 0; +ff_filter_set_ready(ctx, 100); } +return 0; } + +return FFERROR_NOT_READY; } static int process_command(AVFilterContext *ctx
Re: [FFmpeg-devel] [PATCH v3 1/2] avformat/avcodec: Add DTS-UHD demuxer and parser, movenc support.
On 5/15/23 1:35 PM, Michael Niedermayer wrote: > Seems iam unable to download this. google complains about some 3rd party > cookies > being disabled when i try to download. This seems new Hi, Since google drive is not working out, I am uploading a small 78k (under the 100k limit) audio file here. The following ffmpeg command will invoke the code in the patches. ffmpeg -i short.dtsx -c copy -y out.mp4 Regards, -Roy short.dtsx Description: Binary data ___ 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/src_movie: dr support
Attached. From 6fddad6ea2abf91a7378fb367a439441ef8f32b4 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 15 May 2023 21:54:25 +0200 Subject: [PATCH 2/3] avfilter/src_movie: dr support Signed-off-by: Paul B Mahol --- libavfilter/src_movie.c | 32 ++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index a7d7c188e6..0629030f91 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -23,7 +23,6 @@ * @file * movie video source * - * @todo use direct rendering (no allocation of a new frame) * @todo support a PTS correction mechanism */ @@ -158,6 +157,31 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) return found; } +static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) +{ +AVFrame *new; + +if (flags & AV_GET_BUFFER_FLAG_REF) +return avcodec_default_get_buffer2(avctx, frame, flags); + +switch (avctx->codec_type) { +case AVMEDIA_TYPE_VIDEO: +new = ff_get_video_buffer(frame->opaque, frame->width, frame->height); +break; +case AVMEDIA_TYPE_AUDIO: +new = ff_get_audio_buffer(frame->opaque, frame->nb_samples); +break; +default: +return -1; +} + +av_frame_unref(frame); +av_frame_move_ref(frame, new); +av_frame_free(&new); + +return 0; +} + static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) { const AVCodec *codec; @@ -173,6 +197,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) if (!st->codec_ctx) return AVERROR(ENOMEM); +st->codec_ctx->flags |= AV_CODEC_FLAG_COPY_OPAQUE; +st->codec_ctx->get_buffer2 = get_buffer; ret = avcodec_parameters_to_context(st->codec_ctx, st->st->codecpar); if (ret < 0) return ret; @@ -480,8 +506,10 @@ static int movie_decode_packet(AVFilterContext *ctx) /* send the packet to its decoder, if any */ pkt_out_id = pkt.stream_index > movie->max_stream_index ? -1 : movie->out_index[pkt.stream_index]; -if (pkt_out_id >= 0) +if (pkt_out_id >= 0) { +pkt.opaque = ctx->outputs[pkt_out_id]; ret = avcodec_send_packet(movie->st[pkt_out_id].codec_ctx, &pkt); +} av_packet_unref(&pkt); return ret; -- 2.39.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] avfilter: add more usage of ff_null_get_*_buffer()
Attached. From 27c37fe14f6e631e581002ef8fa942095efe0338 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 15 May 2023 22:30:07 +0200 Subject: [PATCH 3/3] avfilter: add more usage of ff_null_get_*_buffer() Signed-off-by: Paul B Mahol --- libavfilter/af_aformat.c | 1 + libavfilter/af_anull.c | 1 + libavfilter/af_astats.c | 1 + libavfilter/f_loop.c | 1 + libavfilter/settb.c | 2 ++ libavfilter/trim.c | 1 + libavfilter/vf_fps.c | 1 + libavfilter/vf_null.c| 1 + libavfilter/vf_scale.c | 10 ++ libavfilter/vf_tpad.c| 10 ++ 10 files changed, 29 insertions(+) diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index a14e4c1240..ce061ffc56 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -180,6 +180,7 @@ static const AVFilterPad avfilter_af_aformat_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, +.get_buffer.audio = ff_null_get_audio_buffer, }, }; diff --git a/libavfilter/af_anull.c b/libavfilter/af_anull.c index 78c5faeb23..d0f32bac19 100644 --- a/libavfilter/af_anull.c +++ b/libavfilter/af_anull.c @@ -31,6 +31,7 @@ static const AVFilterPad avfilter_af_anull_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, +.get_buffer.audio = ff_null_get_audio_buffer, }, }; diff --git a/libavfilter/af_astats.c b/libavfilter/af_astats.c index f3f2bd743b..0354a20a8b 100644 --- a/libavfilter/af_astats.c +++ b/libavfilter/af_astats.c @@ -833,6 +833,7 @@ static const AVFilterPad astats_inputs[] = { .name = "default", .type = AVMEDIA_TYPE_AUDIO, .filter_frame = filter_frame, +.get_buffer.audio = ff_null_get_audio_buffer, }, }; diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c index 33b66fa534..1ad9ef84be 100644 --- a/libavfilter/f_loop.c +++ b/libavfilter/f_loop.c @@ -481,6 +481,7 @@ static const AVFilterPad inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, +.get_buffer.video = ff_null_get_video_buffer, }, }; diff --git a/libavfilter/settb.c b/libavfilter/settb.c index 23cb02689b..7e5793b50c 100644 --- a/libavfilter/settb.c +++ b/libavfilter/settb.c @@ -169,6 +169,7 @@ static const AVFilterPad avfilter_vf_settb_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, +.get_buffer.video = ff_null_get_video_buffer, }, }; @@ -201,6 +202,7 @@ static const AVFilterPad avfilter_af_asettb_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, +.get_buffer.audio = ff_null_get_audio_buffer, }, }; diff --git a/libavfilter/trim.c b/libavfilter/trim.c index ee6e821cd2..d5181e2c49 100644 --- a/libavfilter/trim.c +++ b/libavfilter/trim.c @@ -195,6 +195,7 @@ static const AVFilterPad trim_inputs[] = { .type = AVMEDIA_TYPE_VIDEO, .filter_frame = trim_filter_frame, .config_props = config_input, +.get_buffer.video = ff_null_get_video_buffer, }, }; diff --git a/libavfilter/vf_fps.c b/libavfilter/vf_fps.c index 2bfb6d29e7..65a1eecb99 100644 --- a/libavfilter/vf_fps.c +++ b/libavfilter/vf_fps.c @@ -380,6 +380,7 @@ static const AVFilterPad avfilter_vf_fps_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, +.get_buffer.video = ff_null_get_video_buffer, }, }; diff --git a/libavfilter/vf_null.c b/libavfilter/vf_null.c index fa80e2a102..7bc201595d 100644 --- a/libavfilter/vf_null.c +++ b/libavfilter/vf_null.c @@ -30,6 +30,7 @@ static const AVFilterPad avfilter_vf_null_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, +.get_buffer.video = ff_null_get_video_buffer, }, }; diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index b0221e8538..6fb8d5ca94 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -988,6 +988,15 @@ static void *child_next(void *obj, void *prev) return NULL; } +static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h) +{ +ScaleContext *s = inlink->dst->priv; + +return !s->sws ? +ff_null_get_video_buffer (inlink, w, h) : +ff_default_get_video_buffer(inlink, w, h); +} + #define OFFSET(x) offsetof(ScaleContext, x) #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM #define TFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM @@ -1053,6 +1062,7 @@ static const AVFilterPad avfilter_vf_scale_inputs[] = { .name = "default", .type = AVMEDIA_TYPE_VIDEO, .filter_frame = filter_frame, +.get_buffer.video = get_video_buffer, }, }; diff --git a/libavfilter/vf_tpad.c b/libavfilter/vf_tpad.c index f0c065f0c3..420ff9aede 100644 --- a/libavfilter/vf_tpad.c +++ b/libavfilter/vf_t
Re: [FFmpeg-devel] [PATCH] avfilter/src_movie: dr support
From 6fddad6ea2abf91a7378fb367a439441ef8f32b4 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Mon, 15 May 2023 21:54:25 +0200 Subject: [PATCH 2/3] avfilter/src_movie: dr support Signed-off-by: Paul B Mahol --- libavfilter/src_movie.c | 32 ++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index a7d7c188e6..0629030f91 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -23,7 +23,6 @@ * @file * movie video source * - * @todo use direct rendering (no allocation of a new frame) * @todo support a PTS correction mechanism */ @@ -158,6 +157,31 @@ static AVStream *find_stream(void *log, AVFormatContext *avf, const char *spec) return found; } +static int get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) +{ +AVFrame *new; + +if (flags & AV_GET_BUFFER_FLAG_REF) +return avcodec_default_get_buffer2(avctx, frame, flags); Why? The frames returned by ff_get_{audio,video}_buffer() are refcounted and writable. You should however use avcodec_default_get_buffer2() for non AV_CODEC_CAP_DR1 decoders. Also, you need to use avcodec_align_dimensions2() to get the correct dimensions. + +switch (avctx->codec_type) { +case AVMEDIA_TYPE_VIDEO: +new = ff_get_video_buffer(frame->opaque, frame->width, frame->height); +break; +case AVMEDIA_TYPE_AUDIO: +new = ff_get_audio_buffer(frame->opaque, frame->nb_samples); +break; +default: +return -1; +} + +av_frame_unref(frame); The documentation for get_buffer2() says: * The following fields will be set in the frame before this callback is * called: * - format * - width, height (video only) * - sample_rate, channel_layout, nb_samples (audio only) * Their values may differ from the corresponding values in * AVCodecContext. This callback must use the frame values, not the codec * context values, to calculate the required buffer size. So you're not really supposed to touch anything else than data, buf, extended_data, extended_buf, and linesize, which an unref call will do. But as long as the necessary values in the AVFilterLink match those in the frame, i guess it should be ok. +av_frame_move_ref(frame, new); +av_frame_free(&new); + +return 0; +} + static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) { const AVCodec *codec; @@ -173,6 +197,8 @@ static int open_stream(AVFilterContext *ctx, MovieStream *st, int dec_threads) if (!st->codec_ctx) return AVERROR(ENOMEM); +st->codec_ctx->flags |= AV_CODEC_FLAG_COPY_OPAQUE; +st->codec_ctx->get_buffer2 = get_buffer; ret = avcodec_parameters_to_context(st->codec_ctx, st->st->codecpar); if (ret < 0) return ret; @@ -480,8 +506,10 @@ static int movie_decode_packet(AVFilterContext *ctx) /* send the packet to its decoder, if any */ pkt_out_id = pkt.stream_index > movie->max_stream_index ? -1 : movie->out_index[pkt.stream_index]; -if (pkt_out_id >= 0) +if (pkt_out_id >= 0) { +pkt.opaque = ctx->outputs[pkt_out_id]; ret = avcodec_send_packet(movie->st[pkt_out_id].codec_ctx, &pkt); +} av_packet_unref(&pkt); return ret; -- 2.39.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 1/4] avformat/format: Remove redundant FFMIN() in ff_match_url_ext()
Found-by: Leo Izen Signed-off-by: Michael Niedermayer --- libavformat/format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/format.c b/libavformat/format.c index d9135854de..c91f71057a 100644 --- a/libavformat/format.c +++ b/libavformat/format.c @@ -70,7 +70,7 @@ int ff_match_url_ext(const char *url, const char *extensions) return 0; if (uc.query - ext > sizeof(scratchpad)) return AVERROR(ENOMEM); //not enough memory in our scratchpad -av_strlcpy(scratchpad, ext + 1, FFMIN(sizeof(scratchpad), uc.query - ext)); +av_strlcpy(scratchpad, ext + 1, uc.query - ext); return av_match_name(scratchpad, extensions); } -- 2.17.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 2/4] avformat/hls: Check mime_ok first
This should be a few nano seconds faster (not measureable) But Collectively the whole humankind watching hls will safe a minute Found-by: Leo Izen Signed-off-by: Michael Niedermayer --- libavformat/hls.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 425df3b26b..fc29ef0ca9 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -2541,9 +2541,9 @@ static int hls_probe(const AVProbeData *p) av_strcasecmp(p->mime_type, "application/x-mpegurl") ); -if (!av_match_ext(p->filename, "m3u8,hls,m3u") && - ff_match_url_ext(p->filename, "m3u8,hls,m3u") <= 0 && -!mime_ok) { +if (!mime_ok && +!av_match_ext(p->filename, "m3u8,hls,m3u") && + ff_match_url_ext(p->filename, "m3u8,hls,m3u") <= 0) { av_log(NULL, AV_LOG_ERROR, "Not detecting m3u8/hls with non standard extension\n"); return 0; } -- 2.17.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 3/4] avformat/hls: Better message from hls_probe()
Found-by: Kacper Michajlow Signed-off-by: Michael Niedermayer --- libavformat/hls.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index fc29ef0ca9..2bc142510e 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -2536,17 +2536,23 @@ static int hls_probe(const AVProbeData *p) int mime_ok = p->mime_type && !( av_strcasecmp(p->mime_type, "application/vnd.apple.mpegurl") && -av_strcasecmp(p->mime_type, "audio/mpegurl") && +av_strcasecmp(p->mime_type, "audio/mpegurl") +); + +int mime_x = p->mime_type && !( av_strcasecmp(p->mime_type, "audio/x-mpegurl") && av_strcasecmp(p->mime_type, "application/x-mpegurl") ); if (!mime_ok && +!mime_x && !av_match_ext(p->filename, "m3u8,hls,m3u") && ff_match_url_ext(p->filename, "m3u8,hls,m3u") <= 0) { -av_log(NULL, AV_LOG_ERROR, "Not detecting m3u8/hls with non standard extension\n"); +av_log(NULL, AV_LOG_ERROR, "Not detecting m3u8/hls with non standard extension and non standard mime type\n"); return 0; } +if (mime_x) +av_log(NULL, AV_LOG_WARNING, "mime type is not rfc8216 compliant\n"); return AVPROBE_SCORE_MAX; } -- 2.17.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 4/4] avformat/hls: remove non standard hls extension
Suggested-by: Kacper Michajlow Signed-off-by: Michael Niedermayer --- libavformat/hls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 2bc142510e..4fff4405e8 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -2546,8 +2546,8 @@ static int hls_probe(const AVProbeData *p) if (!mime_ok && !mime_x && -!av_match_ext(p->filename, "m3u8,hls,m3u") && - ff_match_url_ext(p->filename, "m3u8,hls,m3u") <= 0) { +!av_match_ext(p->filename, "m3u8,m3u") && + ff_match_url_ext(p->filename, "m3u8,m3u") <= 0) { av_log(NULL, AV_LOG_ERROR, "Not detecting m3u8/hls with non standard extension and non standard mime type\n"); return 0; } -- 2.17.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 1/3] lavu/frame: add av_frame_get_buffer2
From: Haihao Xiang Intel MediaSDK and oneVPL expect continuous allocation for data[i], however there are mandatory padding bytes between data[i] and data[i+1]. when calling av_frame_get_buffer. So adding av_frame_get_buffer2 to allow caller to specify the length of padding bytes. Signed-off-by: Haihao Xiang --- doc/APIchanges | 3 +++ libavutil/frame.c | 12 libavutil/frame.h | 31 +++ libavutil/version.h | 2 +- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 20ab4709e7..6a2c3b6270 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-05-09 - xx - lavu 58.8.100 - frame.h + Add av_frame_get_buffer2 + 2023-05-xx - xx - lavc 60.11.100 - codec_par.h Add AVCodecParameters.framerate. diff --git a/libavutil/frame.c b/libavutil/frame.c index 97d40208c8..5c9e740c6b 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -106,11 +106,10 @@ void av_frame_free(AVFrame **frame) av_freep(frame); } -static int get_video_buffer(AVFrame *frame, int align) +static int get_video_buffer(AVFrame *frame, int align, int plane_padding) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); int ret, padded_height, total_size; -int plane_padding = FFMAX(16 + 16/*STRIDE_ALIGN*/, align); ptrdiff_t linesizes[4]; size_t sizes[4]; @@ -240,14 +239,14 @@ FF_ENABLE_DEPRECATION_WARNINGS } -int av_frame_get_buffer(AVFrame *frame, int align) +int av_frame_get_buffer2(AVFrame *frame, int align, int plane_padding) { if (frame->format < 0) return AVERROR(EINVAL); FF_DISABLE_DEPRECATION_WARNINGS if (frame->width > 0 && frame->height > 0) -return get_video_buffer(frame, align); +return get_video_buffer(frame, align, plane_padding); else if (frame->nb_samples > 0 && (av_channel_layout_check(&frame->ch_layout) #if FF_API_OLD_CHANNEL_LAYOUT @@ -260,6 +259,11 @@ FF_ENABLE_DEPRECATION_WARNINGS return AVERROR(EINVAL); } +int av_frame_get_buffer(AVFrame *frame, int align) +{ +return av_frame_get_buffer2(frame, align, FFMAX(16 + 16/*STRIDE_ALIGN*/, align)); +} + static int frame_copy_props(AVFrame *dst, const AVFrame *src, int force_copy) { int ret; diff --git a/libavutil/frame.h b/libavutil/frame.h index f2b56beebb..197bcfeef2 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -867,6 +867,37 @@ void av_frame_move_ref(AVFrame *dst, AVFrame *src); */ int av_frame_get_buffer(AVFrame *frame, int align); +/** + * Allocate new buffer(s) for audio or video data. + * + * The following fields must be set on frame before calling this function: + * - format (pixel format for video, sample format for audio) + * - width and height for video + * - nb_samples and ch_layout for audio + * + * This function will fill AVFrame.data and AVFrame.buf arrays and, if + * necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf. + * For planar formats, one buffer will be allocated for each plane. + * + * @warning: if frame already has been allocated, calling this function will + * leak memory. In addition, undefined behavior can occur in certain + * cases. + * + * @param frame frame in which to store the new buffers. + * @param align Required buffer size alignment. If equal to 0, alignment will be + * chosen automatically for the current CPU. It is highly + * recommended to pass 0 here unless you know what you are doing. + * @param plane_padding The length of padding bytes between two video planes. It is + * ignored for audio data. + * + * @return 0 on success, a negative AVERROR on error. + * + * @note It is recommended that you use av_frame_get_buffer instead if you do not + * care about the length of padding bytes. + * @see av_frame_get_buffer() + */ +int av_frame_get_buffer2(AVFrame *frame, int align, int plane_padding); + /** * Check if the frame data is writable. * diff --git a/libavutil/version.h b/libavutil/version.h index 341bcbf188..a4177aa137 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 58 -#define LIBAVUTIL_VERSION_MINOR 7 +#define LIBAVUTIL_VERSION_MINOR 8 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.34.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 2/3] lavu/hwcontext_qsv: call av_frame_get_buffer2 instead of av_frame_get_buffer
From: Haihao Xiang Signed-off-by: Haihao Xiang --- libavutil/hwcontext_qsv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 4ed4242ddf..3d094c7239 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -1631,7 +1631,7 @@ static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, tmp_frame->format = dst->format; tmp_frame->width = FFALIGN(dst->linesize[0], 16); tmp_frame->height = FFALIGN(dst->height, 16); -ret = av_frame_get_buffer(tmp_frame, 0); +ret = av_frame_get_buffer2(tmp_frame, 0, 0); if (ret < 0) return ret; } @@ -1715,7 +1715,7 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst, tmp_frame->format = src->format; tmp_frame->width = FFALIGN(src->width, 16); tmp_frame->height = FFALIGN(src->height, 16); -ret = av_frame_get_buffer(tmp_frame, 0); +ret = av_frame_get_buffer2(tmp_frame, 0, 0); if (ret < 0) return ret; } -- 2.34.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 3/3] lavc/qsvenc: call av_frame_get_buffer2 instead of av_frame_get_buffer
From: Haihao Xiang Signed-off-by: Haihao Xiang --- libavcodec/qsvenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 0ed1f757d4..0f9442296d 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -1918,7 +1918,7 @@ static int submit_frame(QSVEncContext *q, const AVFrame *frame, qf->frame->format = frame->format; if (!qf->frame->data[0]) { -ret = av_frame_get_buffer(qf->frame, q->width_align); +ret = av_frame_get_buffer2(qf->frame, q->width_align, 0); if (ret < 0) return ret; } -- 2.34.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 v2] avcodec/cavs_parser: fix finding the end of a frame
From: Zhao Zhili Use the next I/P/B or start code as the end of current frame. Before the patch, extension start code, user data start code, sequence end code and so on are treated as the start of next frame. Signed-off-by: Zhao Zhili --- v2: add fate test The sample has been sent to samples-request. libavcodec/cavs_parser.c | 11 --- tests/fate/demux.mak | 3 ++ tests/ref/fate/cavs-demux | 62 +++ 3 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 tests/ref/fate/cavs-demux diff --git a/libavcodec/cavs_parser.c b/libavcodec/cavs_parser.c index 03f392c2e5..4a03effd0f 100644 --- a/libavcodec/cavs_parser.c +++ b/libavcodec/cavs_parser.c @@ -59,12 +59,11 @@ static int cavs_find_frame_end(ParseContext *pc, const uint8_t *buf, return 0; for(; i SLICE_MAX_START_CODE){ -pc->frame_start_found=0; -pc->state=-1; -return i-3; -} +if (state == PIC_I_START_CODE || state == PIC_PB_START_CODE || +state == CAVS_START_CODE) { +pc->frame_start_found=0; +pc->state=-1; +return i-3; } } } diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak index 2c508a42aa..c9387b4c0a 100644 --- a/tests/fate/demux.mak +++ b/tests/fate/demux.mak @@ -29,6 +29,9 @@ fate-bcstm: CMD = crc -i $(TARGET_SAMPLES)/bfstm/loz-mm-mikau.bcstm -c:a copy FATE_SAMPLES_DEMUX-$(CONFIG_BRSTM_DEMUXER) += fate-brstm fate-brstm: CMD = crc -i $(TARGET_SAMPLES)/brstm/lozswd_partial.brstm -c:a copy +FATE_FFPROBE_DEMUX-$(call ALLYES, CAVSVIDEO_DEMUXER CAVSVIDEO_PARSER) += fate-cavs-demux +fate-cavs-demux: CMD = ffprobe_demux $(TARGET_SAMPLES)/cavs/bunny.cavs + FATE_SAMPLES_DEMUX-$(CONFIG_CDXL_DEMUXER) += fate-cdxl-demux fate-cdxl-demux: CMD = framecrc -i $(TARGET_SAMPLES)/cdxl/mirage.cdxl -c:v copy -c:a copy diff --git a/tests/ref/fate/cavs-demux b/tests/ref/fate/cavs-demux new file mode 100644 index 00..8ad7ec2fe1 --- /dev/null +++ b/tests/ref/fate/cavs-demux @@ -0,0 +1,62 @@ +packet|codec_type=video|stream_index=0|pts=0|pts_time=0.00|dts=0|dts_time=0.00|duration=48000|duration_time=0.04|size=14447|pos=0|flags=K__|data_hash=CRC32:83f257c0 +packet|codec_type=video|stream_index=0|pts=48000|pts_time=0.04|dts=48000|dts_time=0.04|duration=48000|duration_time=0.04|size=483|pos=14447|flags=K__|data_hash=CRC32:5abb82f8 +packet|codec_type=video|stream_index=0|pts=96000|pts_time=0.08|dts=96000|dts_time=0.08|duration=48000|duration_time=0.04|size=18|pos=14930|flags=K__|data_hash=CRC32:b8b123d8 +packet|codec_type=video|stream_index=0|pts=144000|pts_time=0.12|dts=144000|dts_time=0.12|duration=48000|duration_time=0.04|size=18|pos=14948|flags=K__|data_hash=CRC32:19180fa8 +packet|codec_type=video|stream_index=0|pts=192000|pts_time=0.16|dts=192000|dts_time=0.16|duration=48000|duration_time=0.04|size=18|pos=14966|flags=K__|data_hash=CRC32:cf501647 +packet|codec_type=video|stream_index=0|pts=24|pts_time=0.20|dts=24|dts_time=0.20|duration=4|duration_time=0.03|size=1807|pos=14984|flags=K__|data_hash=CRC32:4267e1d5 +packet|codec_type=video|stream_index=0|pts=28|pts_time=0.23|dts=28|dts_time=0.23|duration=4|duration_time=0.03|size=28|pos=16791|flags=K__|data_hash=CRC32:c223285a +packet|codec_type=video|stream_index=0|pts=32|pts_time=0.27|dts=32|dts_time=0.27|duration=4|duration_time=0.03|size=25|pos=16819|flags=K__|data_hash=CRC32:2565cc9e +packet|codec_type=video|stream_index=0|pts=36|pts_time=0.30|dts=36|dts_time=0.30|duration=4|duration_time=0.03|size=22|pos=16844|flags=K__|data_hash=CRC32:7fbf36ac +packet|codec_type=video|stream_index=0|pts=40|pts_time=0.33|dts=40|dts_time=0.33|duration=4|duration_time=0.03|size=23884|pos=16866|flags=K__|data_hash=CRC32:d61430fd +packet|codec_type=video|stream_index=0|pts=44|pts_time=0.37|dts=44|dts_time=0.37|duration=4|duration_time=0.03|size=265|pos=40750|flags=K__|data_hash=CRC32:d64145a0 +packet|codec_type=video|stream_index=0|pts=48|pts_time=0.40|dts=48|dts_time=0.40|duration=4|duration_time=0.03|size=393|pos=41015|flags=K__|data_hash=CRC32:32c020e2 +packet|codec_type=video|stream_index=0|pts=52|pts_time=0.43|dts=52|dts_time=0.43|duration=4|duration_time=0.03|size=656|pos=41408|flags=K__|data_hash=CRC32:965c7846 +packet|codec_type=video|stream_index=0|pts=56|pts_time=0.47|dts=56|dts_time=0.47|duration=4|duration_time=0.03|size=3500|pos=42064|flags=K__|data_hash=CRC32:ddf731de +packet|codec_type=video|stream_index=0|pts=60|pts_time=0.50|dts=60|dts_time=0.50|duration=4|duration_time=0.03|size=68|pos=45564|flags=K__|data_hash=CRC32:f8c8ba07 +packet|codec_type=v