Re: [FFmpeg-devel] [PATCH 1/6] qsv: add ${includedir}/mfx to the search path for old versions of libmfx
On Tue, 2020-09-29 at 16:21 +0100, Mark Thompson wrote: > On 16/09/2020 07:44, Haihao Xiang wrote: > > ${includedir}/mfx has been added to Cflags in libmfx.pc for the current > > libmfx. We may add ${includedir}/mfx to the search path for olda > > versions of libmfx so that we may include foo.h instead of mfx/foo.h > > > > After applying this change, we won't need to change #include to include > > the right header files when the mfx header files are installed to a new > > directory for a new version of libmfx. E.g. for libmfx 2.0 (oneVPL, > > https://github.com/oneapi-src/oneVPL), the header files will be > > installed in vpl directory > > > > If your libmfx comes without pkg-config support, this patch requires a > > small change to your environment setting (e.g. adding > > /opt/intel/mediasdk/include/mfx instead of /opt/intel/mediasdk/include > > to CFLAGS) so that the build can find the headers > > --- > > configure| 15 --- > > fftools/ffmpeg_qsv.c | 2 +- > > libavcodec/qsv.c | 8 > > libavcodec/qsv.h | 2 +- > > libavcodec/qsv_internal.h| 2 +- > > libavcodec/qsvdec.c | 2 +- > > libavcodec/qsvdec.h | 2 +- > > libavcodec/qsvdec_h2645.c| 2 +- > > libavcodec/qsvdec_other.c| 2 +- > > libavcodec/qsvenc.c | 2 +- > > libavcodec/qsvenc.h | 2 +- > > libavcodec/qsvenc_h264.c | 2 +- > > libavcodec/qsvenc_hevc.c | 2 +- > > libavcodec/qsvenc_jpeg.c | 2 +- > > libavcodec/qsvenc_mpeg2.c| 2 +- > > libavcodec/qsvenc_vp9.c | 2 +- > > libavfilter/qsvvpp.h | 2 +- > > libavfilter/vf_deinterlace_qsv.c | 2 +- > > libavfilter/vf_scale_qsv.c | 2 +- > > libavutil/hwcontext_opencl.c | 2 +- > > libavutil/hwcontext_qsv.c| 2 +- > > libavutil/hwcontext_qsv.h| 2 +- > > 22 files changed, 36 insertions(+), 27 deletions(-) > > > > diff --git a/configure b/configure > > index 5d68695192..767bc4ca69 100755 > > --- a/configure > > +++ b/configure > > @@ -1458,6 +1458,14 @@ check_pkg_config(){ > > eval add_cflags \$${name}_cflags > > } > > > > +append_subdir_to_pkg_includedir(){ > > +log append_subdir_to_pkg_includedir "$@" > > +name="$1" > > +subdir="$2" > > +incdir=$($pkg_config --variable=includedir $name) > > +add_cflags -I$incdir/$subdir > > +} > > Adding this hack as a separate function makes it look like other people would > not be insane to use it, which is probably bad. I was thinking that this function might be used in future if someone want to append a subdir to includedir. > > > + > > test_exec(){ > > test_ld "cc" "$@" && { enabled cross_compile || $TMPE >> $logfile > > 2>&1; } > > } > > @@ -6355,10 +6363,11 @@ enabled liblensfun&& require_pkg_config > > liblensfun lensfun lensfun.h lf_ > > # Media SDK or Intel Media Server Studio, these don't come with > > # pkg-config support. Instead, users should make sure that the build > > # can find the libraries and headers through other means. > > -enabled libmfx&& { check_pkg_config libmfx libmfx > > "mfx/mfxvideo.h" MFXInit || > > - { require libmfx "mfx/mfxvideo.h" MFXInit "- > > llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } > > +enabled libmfx&& { check_pkg_config libmfx libmfx "mfxvideo.h" > > MFXInit || > > + { check_pkg_config libmfx libmfx > > "mfx/mfxvideo.h" MFXInit && append_subdir_to_pkg_includedir libmfx mfx; } || > > + { require libmfx "mfxvideo.h" MFXInit "- > > llibmfx $advapi32_extralibs" && warn "using libmfx without pkg-config"; } } > > Checks for different ways of installing the same thing are very frowned > upon. Who actually breaks if you convert completely to the new style? > > (Also consider the comment immediately above. Is that still true?) If I remembered correctly, some old versions of MSDK have the following settings in libmfx.pc: includedir=/usr/include Cflags: -I${includedir} But the header files are installed under /usr/include/mfx. The old style works because 'mfx/foo.h' is included in source files, but for the new style, it doesn't work if we don't add -I/usr/include/mfx to Cflags. Thanks Haihao > > > if enabled libmfx; then > > - check_cc MFX_CODEC_VP9 "mfx/mfxvp9.h mfx/mfxstructures.h" > > "MFX_CODEC_VP9" > > + check_cc MFX_CODEC_VP9 "mfxvp9.h mfxstructures.h" "MFX_CODEC_VP9" > > fi > > > > - Mark > ___ > 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
[FFmpeg-devel] [PATCH 2/2] avcodec/sheervideo: Inline compile-time constants
Signed-off-by: Andreas Rheinhardt --- libavcodec/sheervideo.c | 343 1 file changed, 172 insertions(+), 171 deletions(-) diff --git a/libavcodec/sheervideo.c b/libavcodec/sheervideo.c index 3f9b299a1e..e1a203d361 100644 --- a/libavcodec/sheervideo.c +++ b/libavcodec/sheervideo.c @@ -24,6 +24,7 @@ #include #define CACHED_BITSTREAM_READER !ARCH_X86_32 +#define SHEER_VLC_BITS 12 #include "libavutil/intreadwrite.h" #include "avcodec.h" @@ -64,10 +65,10 @@ static void decode_ca4i(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) for (x = 0; x < avctx->width; x++) { int y, u, v, a; -a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); -y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2); -u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); -v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); +a = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); +y = get_vlc2(gb, s->vlc[0].table, SHEER_VLC_BITS, 2); +u = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); +v = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); dst_a[x] = pred[3] = (a + pred[3]) & 0x3ff; dst_y[x] = pred[0] = (y + pred[0]) & 0x3ff; @@ -107,10 +108,10 @@ static void decode_ca4p(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) for (x = 0; x < avctx->width; x++) { int y, u, v, a; -a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); -y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2); -u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); -v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); +a = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); +y = get_vlc2(gb, s->vlc[0].table, SHEER_VLC_BITS, 2); +u = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); +v = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); dst_a[x] = pred[3] = (a + pred[3]) & 0x3ff; dst_y[x] = pred[0] = (y + pred[0]) & 0x3ff; @@ -147,10 +148,10 @@ static void decode_ca4p(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) pred_T[2] = dst_v[-p->linesize[2] / 2 + x]; pred_T[3] = dst_a[-p->linesize[3] / 2 + x]; -a = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); -y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2); -u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); -v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); +a = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); +y = get_vlc2(gb, s->vlc[0].table, SHEER_VLC_BITS, 2); +u = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); +v = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); dst_a[x] = pred_L[3] = (a + ((3 * (pred_T[3] + pred_L[3]) - 2 * pred_TL[3]) >> 2)) & 0x3ff; dst_y[x] = pred_L[0] = (y + ((3 * (pred_T[0] + pred_L[0]) - 2 * pred_TL[0]) >> 2)) & 0x3ff; @@ -194,9 +195,9 @@ static void decode_ybr10i(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) for (x = 0; x < avctx->width; x++) { int y, u, v; -y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2); -u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); -v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); +y = get_vlc2(gb, s->vlc[0].table, SHEER_VLC_BITS, 2); +u = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); +v = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); dst_y[x] = pred[0] = (y + pred[0]) & 0x3ff; dst_u[x] = pred[1] = (u + pred[1]) & 0x3ff; @@ -232,9 +233,9 @@ static void decode_ybr10(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) for (x = 0; x < avctx->width; x++) { int y, u, v; -y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2); -u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); -v = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits, 2); +y = get_vlc2(gb, s->vlc[0].table, SHEER_VLC_BITS, 2); +u = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); +v = get_vlc2(gb, s->vlc[1].table, SHEER_VLC_BITS, 2); dst_y[x] = pred[0] = (y + pred[0]) & 0x3ff; dst_u[x] = pred[1] = (u + pred[1]) & 0x3ff; @@ -266,9 +267,9 @@ static void decode_ybr10(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) pred_T[1] = dst_u[-p->linesize[1] / 2 + x]; pred_T[2] = dst_v[-p->linesize[2] / 2 + x]; -y = get_vlc2(gb, s->vlc[0].table, s->vlc[0].bits, 2); -u = get_vlc2(gb, s->vlc[1].table, s->vlc[1].bits,
[FFmpeg-devel] [PATCH 1/2] avcodec/sheervideo: Improve creating VLC tables
Don't needlessly copy an array around; don't create a table with default symbols; and use smaller types to save stack space: The longest code here is 16 bits, so one can store the codes in this type. Signed-off-by: Andreas Rheinhardt --- libavcodec/sheervideo.c | 19 +++ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/libavcodec/sheervideo.c b/libavcodec/sheervideo.c index ba9aecbb11..3f9b299a1e 100644 --- a/libavcodec/sheervideo.c +++ b/libavcodec/sheervideo.c @@ -1782,25 +1782,20 @@ static void decode_rgb(AVCodecContext *avctx, AVFrame *p, GetBitContext *gb) static int build_vlc(VLC *vlc, const uint8_t *len, int count) { -uint32_t codes[1024]; -uint8_t bits[1024]; -uint16_t syms[1024]; -uint64_t index; +uint16_t codes[1024]; +unsigned index; int i; index = 0; for (i = 0; i < count; i++) { -codes[i] = index >> (32 - len[i]); -bits[i] = len[i]; -syms[i] = i; -index += 1ULL << (32 - len[i]); +codes[i] = index >> (32 - len[i]); +index += 1U<< (32 - len[i]); } ff_free_vlc(vlc); -return ff_init_vlc_sparse(vlc, 12, count, - bits, sizeof(*bits), sizeof(*bits), - codes, sizeof(*codes), sizeof(*codes), - syms, sizeof(*syms), sizeof(*syms), 0); +return init_vlc(vlc, 12, count, +len, sizeof(*len), sizeof(*len), +codes, sizeof(*codes), sizeof(*codes), 0); } static int decode_frame(AVCodecContext *avctx, -- 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".
Re: [FFmpeg-devel] [PATCH 0/6] qsv: Fix compiler errors when using libmfx 2.0 (oneVPL)
On Tue, 2020-09-29 at 16:09 +0100, Mark Thompson wrote: > On 16/09/2020 07:44, Haihao Xiang wrote: > > The oneAPI Video Processing Library (oneVPL) is a single interface for > > encode, decode and video processing, the obsolete features in Intel > > Media Software Development Kit are removed from oneVPL. > > > > The oneVPL specification: > > https://spec.oneapi.com/versions/latest/elements/oneVPL/source/index.html > > The oneVPL source code: > > https://github.com/oneapi-src/oneVPL > > > > This patchset fixes compiler errors when building FFmpeg against oneVPL > > > > Note this patchset includes some patches in the FFmpeg archives: > > http://ffmpeg.org/pipermail/ffmpeg-devel/2020-August/268141.html > > http://ffmpeg.org/pipermail/ffmpeg-devel/2020-September/269334.html > > > > Haihao Xiang (6): > >qsv: add ${includedir}/mfx to the search path for old versions of > > libmfx > >qsv: libmfx no longer supports user plugin since version 2.0 (oneVPL) > >qsv: libmfx no longer supports audio since version 2.0 (oneVPL) > >qsvenc: libmfx no longer supports multi-frame encode since version 2.0 > > (oneVPL) > >qsvenc: libmfx no longer supports MFX_RATECONTROL_LA_EXT since version > > 2.0 (oneVPL) > >qsv: libmfx no longer supports OPAQUE memory since version 2.0 > > (oneVPL) > > > > configure| 15 +-- > > fftools/ffmpeg_qsv.c | 2 +- > > libavcodec/qsv.c | 21 +++-- > > libavcodec/qsv.h | 4 +- > > libavcodec/qsv_internal.h| 4 +- > > libavcodec/qsvdec.c | 11 - > > libavcodec/qsvdec.h | 2 +- > > libavcodec/qsvdec_h2645.c| 2 +- > > libavcodec/qsvdec_other.c| 2 +- > > libavcodec/qsvenc.c | 25 ++- > > libavcodec/qsvenc.h | 6 ++- > > libavcodec/qsvenc_h264.c | 2 +- > > libavcodec/qsvenc_hevc.c | 2 +- > > libavcodec/qsvenc_jpeg.c | 2 +- > > libavcodec/qsvenc_mpeg2.c| 2 +- > > libavcodec/qsvenc_vp9.c | 2 +- > > libavfilter/qsvvpp.c | 24 +- > > libavfilter/qsvvpp.h | 4 +- > > libavfilter/vf_deinterlace_qsv.c | 58 +--- > > libavfilter/vf_scale_qsv.c | 76 ++-- > > libavutil/hwcontext_opencl.c | 2 +- > > libavutil/hwcontext_qsv.c| 58 +--- > > libavutil/hwcontext_qsv.h| 2 +- > > 23 files changed, 225 insertions(+), 103 deletions(-) > > Can you explain the compatibility effects here? In particular: > > If you build against oneVPL, does everything still work on old MSDK > setups? (In particular, those like Haswell which are technically out of > support but still very widely used.) > > If you build against MSDK, does everything still work on a oneVPL setup? The mfx dispatcher from oneVPL works well with the legacy MSDK implementation (E.g. libmfxhw64.so) except the removed features. The soname is libmfx.so.2 for oneVPL dispatcher, libmfx.so.1 for legacy MedSDK, you can't use legacy MSDK dispatcher at runtime if you build FFmpeg against oneVPL. It doesn't work too if building against legacy MSDK and use oneVPL dispatcher at runtime. Thanks Haihao > > - Mark > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 6/6] tools/target_dec_fuzzer: remove calls to avcodec_register*()
They are no-ops. Signed-off-by: James Almer --- tools/target_dec_fuzzer.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/target_dec_fuzzer.c b/tools/target_dec_fuzzer.c index 7bea736fcf..39d4bb5647 100644 --- a/tools/target_dec_fuzzer.c +++ b/tools/target_dec_fuzzer.c @@ -118,17 +118,14 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { #define DECODER_SYMBOL(CODEC) DECODER_SYMBOL0(CODEC) extern AVCodec DECODER_SYMBOL(FFMPEG_DECODER); codec_list[0] = _SYMBOL(FFMPEG_DECODER); -avcodec_register(_SYMBOL(FFMPEG_DECODER)); #if FFMPEG_DECODER == tiff || FFMPEG_DECODER == tdsc extern AVCodec DECODER_SYMBOL(mjpeg); codec_list[1] = _SYMBOL(mjpeg); -avcodec_register(_SYMBOL(mjpeg)); #endif c = _SYMBOL(FFMPEG_DECODER); #else -avcodec_register_all(); c = AVCodecInitialize(FFMPEG_CODEC); // Done once. #endif av_log_set_level(AV_LOG_PANIC); -- 2.27.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 5/6] tools/target_dem_fuzzer: switch to the iterate API
Signed-off-by: James Almer --- tools/target_dem_fuzzer.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/target_dem_fuzzer.c b/tools/target_dem_fuzzer.c index eefb5c5fa3..10082993fe 100644 --- a/tools/target_dem_fuzzer.c +++ b/tools/target_dem_fuzzer.c @@ -105,8 +105,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { int ret; if (!c) { -av_register_all(); -avcodec_register_all(); av_log_set_level(AV_LOG_PANIC); c=1; } @@ -132,15 +130,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { filesize = bytestream2_get_le64() & 0x7FFF; if ((flags & 2) && strlen(filename) < sizeof(filename) / 2) { -AVInputFormat *avif = NULL; +const AVInputFormat *avif = NULL; +void *avif_iter = NULL; int avif_count = 0; -while ((avif = av_iformat_next(avif))) { +while ((avif = av_demuxer_iterate(_iter))) { if (avif->extensions) avif_count ++; } avif_count = bytestream2_get_le32() % avif_count; -while ((avif = av_iformat_next(avif))) { +avif_iter = NULL; +while ((avif = av_demuxer_iterate(_iter))) { if (avif->extensions) if (!avif_count--) break; -- 2.27.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 4/6] avformat/options: use the iterate API in format_child_class_next()
Signed-off-by: James Almer --- libavformat/options.c | 23 +-- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/libavformat/options.c b/libavformat/options.c index 3160904fda..59e0389815 100644 --- a/libavformat/options.c +++ b/libavformat/options.c @@ -55,35 +55,38 @@ static void *format_child_next(void *obj, void *prev) } #if FF_API_CHILD_CLASS_NEXT -FF_DISABLE_DEPRECATION_WARNINGS static const AVClass *format_child_class_next(const AVClass *prev) { -AVInputFormat *ifmt = NULL; -AVOutputFormat *ofmt = NULL; +const AVInputFormat *ifmt = NULL; +const AVOutputFormat *ofmt = NULL; +void *ifmt_iter = NULL, *ofmt_iter = NULL; if (!prev) return _avio_class; -while ((ifmt = av_iformat_next(ifmt))) +while ((ifmt = av_demuxer_iterate(_iter))) if (ifmt->priv_class == prev) break; -if (!ifmt) -while ((ofmt = av_oformat_next(ofmt))) +if (!ifmt) { +ifmt_iter = NULL; +while ((ofmt = av_muxer_iterate(_iter))) if (ofmt->priv_class == prev) break; -if (!ofmt) -while (ifmt = av_iformat_next(ifmt)) +} +if (!ofmt) { +ofmt_iter = NULL; +while ((ifmt = av_demuxer_iterate(_iter))) if (ifmt->priv_class) return ifmt->priv_class; +} -while (ofmt = av_oformat_next(ofmt)) +while ((ofmt = av_muxer_iterate(_iter))) if (ofmt->priv_class) return ofmt->priv_class; return NULL; } -FF_ENABLE_DEPRECATION_WARNINGS #endif enum { -- 2.27.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 3/3] avcodec/mpeg12dec: Optimize reading mpeg2 intra escape codes
Michael Niedermayer: > On Thu, Oct 08, 2020 at 09:53:13PM +0200, Andreas Rheinhardt wrote: >> Said escape code is only six bits long, so that one has at least 25 - 6 >> bits in the bitstream reader's cache after reading it; therefore the >> whole following 18 bits (containing the actual code) are already in the >> bitstream reader's cache, making it unnecessary to reload the cache. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavcodec/mpeg12dec.c | 10 -- >> 1 file changed, 4 insertions(+), 6 deletions(-) > > Interresting that this was not noticed before but > LGTM > > thx > There is actually more like this: The GET_VLC macro (which is used internally by get_vlc2() unless one uses the cached bitstream reader) currently always reloads the cache after every read, although one can omit the first reload if one only reads at most 12 bits at a time as is done in most usages of get_vlc2() in the codebase. For the cached bitstream reader one could even ensure that >= 32 bits are initially in the cache and then only read from the cache; currently the code for refilling the code (quite big in terms of size) exists multiple times in the binaries. Will take care of it. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] Ticket #8750 Add inline function for the vec_xl intrinsic in non-VSX environments
From: Chip Kerchner --- libswscale/ppc/yuv2rgb_altivec.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c index 536545293d..930ef6b98f 100644 --- a/libswscale/ppc/yuv2rgb_altivec.c +++ b/libswscale/ppc/yuv2rgb_altivec.c @@ -283,6 +283,16 @@ static inline void cvtyuvtoRGB(SwsContext *c, vector signed short Y, * -- */ +#if !HAVE_VSX +static inline vector unsigned char vec_xl(signed long long offset, const ubyte *addr) +{ +const vector unsigned char *v_addr = (const vector unsigned char *) (addr + offset); +vector unsigned char align_perm = vec_lvsl(offset, addr); + +return (vector unsigned char) vec_perm(v_addr[0], v_addr[1], align_perm); +} +#endif /* !HAVE_VSX */ + #define DEFCSP420_CVT(name, out_pixels) \ static int altivec_ ## name(SwsContext *c, const unsigned char **in, \ int *instrides, int srcSliceY, int srcSliceH, \ -- 2.28.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 1/2] swscale/utils: split range override check into its own function
--- libswscale/utils.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 9ca378bd3b..832c9f873c 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -864,6 +864,11 @@ static void fill_xyztables(struct SwsContext *c) } } +static int range_override_needed(enum AVPixelFormat format) +{ +return !isYUV(format) && !isGray(format); +} + int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], int srcRange, const int table[4], int dstRange, int brightness, int contrast, int saturation) @@ -876,9 +881,9 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4], desc_dst = av_pix_fmt_desc_get(c->dstFormat); desc_src = av_pix_fmt_desc_get(c->srcFormat); -if(!isYUV(c->dstFormat) && !isGray(c->dstFormat)) +if(range_override_needed(c->dstFormat)) dstRange = 0; -if(!isYUV(c->srcFormat) && !isGray(c->srcFormat)) +if(range_override_needed(c->srcFormat)) srcRange = 0; if (c->srcRange != srcRange || -- 2.26.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 2/2] swscale/utils: override forced-zero formats back to full range
Fixes vf_scale outputting RGB AVFrames with limited range flagged in case either input or output specifically sets the range. This is the reverse of the logic utilized for RGB and PAL8 content in sws_setColorspaceDetails. --- libswscale/utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libswscale/utils.c b/libswscale/utils.c index 832c9f873c..352a8ed116 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -1013,8 +1013,8 @@ int sws_getColorspaceDetails(struct SwsContext *c, int **inv_table, *inv_table = c->srcColorspaceTable; *table = c->dstColorspaceTable; -*srcRange = c->srcRange; -*dstRange = c->dstRange; +*srcRange = range_override_needed(c->srcFormat) ? 1 : c->srcRange; +*dstRange = range_override_needed(c->dstFormat) ? 1 : c->dstRange; *brightness = c->brightness; *contrast = c->contrast; *saturation = c->saturation; -- 2.26.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] avcodec/h2645_parse: remove initial skipped_bytes_pos buffer
On 10/9/2020 7:43 PM, Andreas Rheinhardt wrote: > James Almer: >> Allocate it only when it's needed. >> >> Fixes: OOM >> Fixes: >> 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960 >> >> Found-by: continuous fuzzing process >> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg >> Signed-off-by: James Almer >> --- >> libavcodec/h2645_parse.c | 28 ++-- >> 1 file changed, 10 insertions(+), 18 deletions(-) >> >> diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c >> index 0f98b49fbe..929fb34eef 100644 >> --- a/libavcodec/h2645_parse.c >> +++ b/libavcodec/h2645_parse.c >> @@ -108,22 +108,20 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int >> length, >> dst[di++] = 0; >> si += 3; >> >> -if (nal->skipped_bytes_pos) { >> -nal->skipped_bytes++; >> -if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { >> -nal->skipped_bytes_pos_size *= 2; >> -av_assert0(nal->skipped_bytes_pos_size >= >> nal->skipped_bytes); >> -av_reallocp_array(>skipped_bytes_pos, >> +nal->skipped_bytes++; >> +if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { >> +nal->skipped_bytes_pos_size = nal->skipped_bytes * 2; >> +av_assert0(nal->skipped_bytes_pos_size >= >> nal->skipped_bytes); >> +av_reallocp_array(>skipped_bytes_pos, >> nal->skipped_bytes_pos_size, >> sizeof(*nal->skipped_bytes_pos)); >> -if (!nal->skipped_bytes_pos) { >> -nal->skipped_bytes_pos_size = 0; >> -return AVERROR(ENOMEM); >> -} >> +if (!nal->skipped_bytes_pos) { >> +nal->skipped_bytes_pos_size = 0; >> +return AVERROR(ENOMEM); >> } >> -if (nal->skipped_bytes_pos) >> -nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - >> 1; >> } >> +if (nal->skipped_bytes_pos) >> +nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; >> continue; >> } else // next start code >> goto nsc; >> @@ -466,12 +464,6 @@ int ff_h2645_packet_split(H2645Packet *pkt, const >> uint8_t *buf, int length, >> pkt->nals = tmp; >> memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals)); >> >> -nal = >nals[pkt->nb_nals]; >> -nal->skipped_bytes_pos_size = 1024; // initial buffer size >> -nal->skipped_bytes_pos = >> av_malloc_array(nal->skipped_bytes_pos_size, >> sizeof(*nal->skipped_bytes_pos)); >> -if (!nal->skipped_bytes_pos) >> -return AVERROR(ENOMEM); >> - >> pkt->nals_allocated = new_size; >> } >> nal = >nals[pkt->nb_nals]; >> > This has the disadvantage that it always keeps the position of the 0x03 > even when the caller does not want it; most callers don't want it, the > only exception is the HEVC decoder. Your patch will lead to memleaks for > the users that use ff_h2645_extract_rbsp() directly. Those users can be adapted to free the buffer, but then again a flag can be added to ff_h2645_extract_rbsp() for this purpose, i guess. > > - Andreas > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel 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/h2645_parse: remove initial skipped_bytes_pos buffer
On 10/9/2020 7:41 PM, Andreas Rheinhardt wrote: > Andreas Rheinhardt: >> James Almer: >>> On 10/9/2020 1:36 PM, Michael Niedermayer wrote: On Thu, Oct 08, 2020 at 10:25:11AM -0300, James Almer wrote: > Allocate it only when needed, and instead of giving it a fixed initial > size > that's doubled on each realloc, ensure it's always big enough for the NAL > currently being parsed. > > Fixes: OOM > Fixes: > 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: James Almer > --- > libavcodec/h2645_parse.c | 28 ++-- > 1 file changed, 10 insertions(+), 18 deletions(-) > > diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c > index 0f98b49fbe..f5c76323c1 100644 > --- a/libavcodec/h2645_parse.c > +++ b/libavcodec/h2645_parse.c > @@ -108,22 +108,20 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int > length, > dst[di++] = 0; > si += 3; > > -if (nal->skipped_bytes_pos) { > -nal->skipped_bytes++; > -if (nal->skipped_bytes_pos_size < > nal->skipped_bytes) { > -nal->skipped_bytes_pos_size *= 2; > -av_assert0(nal->skipped_bytes_pos_size >= > nal->skipped_bytes); > -av_reallocp_array(>skipped_bytes_pos, > +nal->skipped_bytes++; > +if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { > +nal->skipped_bytes_pos_size = length / 3; This would allocate a much larger than needed skipped_bytes_pos for probably nearly all of the real world h264 files to fix an issue with crafted streams. The initial size should be choosen so as to be large enough for real world streams. If that turns out to be too small then length /3 sounds reasonable as the first reallocation. >>> >>> At most 1/3 of the bytes in a NAL would be removed by this code, hence >>> length / 3. I could make it length / 16 like in your fix if you prefer, >>> or maybe nal->skipped_bytes * 2 to keep it closer to the current >>> behavior, but real world samples don't have more than a handful of NALs >>> per packet, and not all have escaped bytes that need to be removed (If >>> there are none, nothing will be allocated). >>> >>> I looked at a 2160p hevc sample, and the biggest packet is about 26kb, >>> which assuming it's a single slice NAL, it will be about 8kb for the >>> skipped_bytes_pos buffer with length / 3. >>> >> Your calculation seems to be off by a factor of four because you ignore >> that every byte removed needs an entry of type int*. Furthermore 26kB (I >> presume you meant kB and not kb) seems very, very small for a normal >> file these days; it feels more like 320p streaming or so. >> >> Furthermore, there is a bigger issue with your patch: It can lead to >> quadratic memory consumption for annex B input: Because the length of >> the NAL units is not known in advance, length in the above code refers >> to the length from the beginning of the NAL unit to the end of the >> packet. So this code will allocate gigantic amounts of memory for a >> packet containing lots of small NAL units, each with a single 0x03. >> This is an issue similar to the one fixed by >> 03b82b3ab9883cef017e513c7d0b3b986b3b3e7b. >> > > How about the following approach which mimics 03b82b3ab: Just like the > RBSP buffer the skipped_bytes_pos buffer is owned by an H2645Packet and > shared between its NALs; each NAL only retains the index of the first > entry in the list that belongs to it and the amount of entries of the > list that belong to it. H2645Packet gets a struct equivalent to > H2645RBSP for it and ff_h2645_extract_rbsp() gets a pointer to this as > new parameter; if it is NULL, it means that the caller does not want to > know the position of the removed 0x03. If not, the buffer is reallocated > as needed (with overallocating, of course). > > decode_nal_unit() as well as hls_slice_data_wpp() in hevcdec.c would > need to be adapted to accept the skipped_bytes_pos buffer via other > newly added function parameters. Patch welcome. That seems overdesigned to maybe save some memory and I'm not interested in implementing it. > > - Andreas > > PS: Orthogonally to this, one could add a flag to > ff_h2645_packet_split() to disable skipped_bytes_pos altogether. ff_h2645_packet_split() already has two optional functionality arguments, so a third will make the signature really bloated. Maybe they can all be replaced by a single flags argument, and use constants to request small_padding, use_ref and this new one. ___ ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] avcodec/h2645_parse: remove initial skipped_bytes_pos buffer
Andreas Rheinhardt: > James Almer: >> On 10/9/2020 1:36 PM, Michael Niedermayer wrote: >>> On Thu, Oct 08, 2020 at 10:25:11AM -0300, James Almer wrote: Allocate it only when needed, and instead of giving it a fixed initial size that's doubled on each realloc, ensure it's always big enough for the NAL currently being parsed. Fixes: OOM Fixes: 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: James Almer --- libavcodec/h2645_parse.c | 28 ++-- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c index 0f98b49fbe..f5c76323c1 100644 --- a/libavcodec/h2645_parse.c +++ b/libavcodec/h2645_parse.c @@ -108,22 +108,20 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int length, dst[di++] = 0; si += 3; -if (nal->skipped_bytes_pos) { -nal->skipped_bytes++; -if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { -nal->skipped_bytes_pos_size *= 2; -av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); -av_reallocp_array(>skipped_bytes_pos, +nal->skipped_bytes++; +if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { +nal->skipped_bytes_pos_size = length / 3; >>> >>> This would allocate a much larger than needed skipped_bytes_pos for >>> probably nearly all of the real world h264 files to fix an issue with >>> crafted streams. >>> >>> The initial size should be choosen so as to be large enough for real world >>> streams. If that turns out to be too small then length /3 sounds reasonable >>> as the first reallocation. >> >> At most 1/3 of the bytes in a NAL would be removed by this code, hence >> length / 3. I could make it length / 16 like in your fix if you prefer, >> or maybe nal->skipped_bytes * 2 to keep it closer to the current >> behavior, but real world samples don't have more than a handful of NALs >> per packet, and not all have escaped bytes that need to be removed (If >> there are none, nothing will be allocated). >> >> I looked at a 2160p hevc sample, and the biggest packet is about 26kb, >> which assuming it's a single slice NAL, it will be about 8kb for the >> skipped_bytes_pos buffer with length / 3. >> > Your calculation seems to be off by a factor of four because you ignore > that every byte removed needs an entry of type int*. Furthermore 26kB (I > presume you meant kB and not kb) seems very, very small for a normal > file these days; it feels more like 320p streaming or so. > > Furthermore, there is a bigger issue with your patch: It can lead to > quadratic memory consumption for annex B input: Because the length of > the NAL units is not known in advance, length in the above code refers > to the length from the beginning of the NAL unit to the end of the > packet. So this code will allocate gigantic amounts of memory for a > packet containing lots of small NAL units, each with a single 0x03. > This is an issue similar to the one fixed by > 03b82b3ab9883cef017e513c7d0b3b986b3b3e7b. > How about the following approach which mimics 03b82b3ab: Just like the RBSP buffer the skipped_bytes_pos buffer is owned by an H2645Packet and shared between its NALs; each NAL only retains the index of the first entry in the list that belongs to it and the amount of entries of the list that belong to it. H2645Packet gets a struct equivalent to H2645RBSP for it and ff_h2645_extract_rbsp() gets a pointer to this as new parameter; if it is NULL, it means that the caller does not want to know the position of the removed 0x03. If not, the buffer is reallocated as needed (with overallocating, of course). decode_nal_unit() as well as hls_slice_data_wpp() in hevcdec.c would need to be adapted to accept the skipped_bytes_pos buffer via other newly added function parameters. - Andreas PS: Orthogonally to this, one could add a flag to ff_h2645_packet_split() to disable skipped_bytes_pos altogether. ___ 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/h2645_parse: remove initial skipped_bytes_pos buffer
James Almer: > Allocate it only when it's needed. > > Fixes: OOM > Fixes: > 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: James Almer > --- > libavcodec/h2645_parse.c | 28 ++-- > 1 file changed, 10 insertions(+), 18 deletions(-) > > diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c > index 0f98b49fbe..929fb34eef 100644 > --- a/libavcodec/h2645_parse.c > +++ b/libavcodec/h2645_parse.c > @@ -108,22 +108,20 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int > length, > dst[di++] = 0; > si += 3; > > -if (nal->skipped_bytes_pos) { > -nal->skipped_bytes++; > -if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { > -nal->skipped_bytes_pos_size *= 2; > -av_assert0(nal->skipped_bytes_pos_size >= > nal->skipped_bytes); > -av_reallocp_array(>skipped_bytes_pos, > +nal->skipped_bytes++; > +if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { > +nal->skipped_bytes_pos_size = nal->skipped_bytes * 2; > +av_assert0(nal->skipped_bytes_pos_size >= > nal->skipped_bytes); > +av_reallocp_array(>skipped_bytes_pos, > nal->skipped_bytes_pos_size, > sizeof(*nal->skipped_bytes_pos)); > -if (!nal->skipped_bytes_pos) { > -nal->skipped_bytes_pos_size = 0; > -return AVERROR(ENOMEM); > -} > +if (!nal->skipped_bytes_pos) { > +nal->skipped_bytes_pos_size = 0; > +return AVERROR(ENOMEM); > } > -if (nal->skipped_bytes_pos) > -nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - > 1; > } > +if (nal->skipped_bytes_pos) > +nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; > continue; > } else // next start code > goto nsc; > @@ -466,12 +464,6 @@ int ff_h2645_packet_split(H2645Packet *pkt, const > uint8_t *buf, int length, > pkt->nals = tmp; > memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals)); > > -nal = >nals[pkt->nb_nals]; > -nal->skipped_bytes_pos_size = 1024; // initial buffer size > -nal->skipped_bytes_pos = > av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); > -if (!nal->skipped_bytes_pos) > -return AVERROR(ENOMEM); > - > pkt->nals_allocated = new_size; > } > nal = >nals[pkt->nb_nals]; > This has the disadvantage that it always keeps the position of the 0x03 even when the caller does not want it; most callers don't want it, the only exception is the HEVC decoder. Your patch will lead to memleaks for the users that use ff_h2645_extract_rbsp() directly. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/h2645_parse: remove initial skipped_bytes_pos buffer
On 10/9/2020 6:16 PM, Andreas Rheinhardt wrote: > James Almer: >> On 10/9/2020 1:36 PM, Michael Niedermayer wrote: >>> On Thu, Oct 08, 2020 at 10:25:11AM -0300, James Almer wrote: Allocate it only when needed, and instead of giving it a fixed initial size that's doubled on each realloc, ensure it's always big enough for the NAL currently being parsed. Fixes: OOM Fixes: 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: James Almer --- libavcodec/h2645_parse.c | 28 ++-- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c index 0f98b49fbe..f5c76323c1 100644 --- a/libavcodec/h2645_parse.c +++ b/libavcodec/h2645_parse.c @@ -108,22 +108,20 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int length, dst[di++] = 0; si += 3; -if (nal->skipped_bytes_pos) { -nal->skipped_bytes++; -if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { -nal->skipped_bytes_pos_size *= 2; -av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); -av_reallocp_array(>skipped_bytes_pos, +nal->skipped_bytes++; +if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { +nal->skipped_bytes_pos_size = length / 3; >>> >>> This would allocate a much larger than needed skipped_bytes_pos for >>> probably nearly all of the real world h264 files to fix an issue with >>> crafted streams. >>> >>> The initial size should be choosen so as to be large enough for real world >>> streams. If that turns out to be too small then length /3 sounds reasonable >>> as the first reallocation. >> >> At most 1/3 of the bytes in a NAL would be removed by this code, hence >> length / 3. I could make it length / 16 like in your fix if you prefer, >> or maybe nal->skipped_bytes * 2 to keep it closer to the current >> behavior, but real world samples don't have more than a handful of NALs >> per packet, and not all have escaped bytes that need to be removed (If >> there are none, nothing will be allocated). >> >> I looked at a 2160p hevc sample, and the biggest packet is about 26kb, >> which assuming it's a single slice NAL, it will be about 8kb for the >> skipped_bytes_pos buffer with length / 3. >> > Your calculation seems to be off by a factor of four because you ignore > that every byte removed needs an entry of type int*. True, forgot each byte position was saved as an int in the array. > Furthermore 26kB (I > presume you meant kB and not kb) seems very, very small for a normal > file these days; it feels more like 320p streaming or so. Yes, kilobytes. And as i said, it was a 2160p sample where the biggest packet was 26kB. Maybe it's not the most complex stream out there, i don't know. > > Furthermore, there is a bigger issue with your patch: It can lead to > quadratic memory consumption for annex B input: Because the length of > the NAL units is not known in advance, length in the above code refers > to the length from the beginning of the NAL unit to the end of the > packet. So this code will allocate gigantic amounts of memory for a > packet containing lots of small NAL units, each with a single 0x03. > This is an issue similar to the one fixed by > 03b82b3ab9883cef017e513c7d0b3b986b3b3e7b. Alright, will use nal->skipped_bytes * 2 then. > > - Andreas > > *: Yes, I know there is no guarantee that sizeof(int) is four. > ___ > 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 2/3] avcodec/mpeg12: Don't pretend reading dct_dc_size_* VLCs can fail
Michael Niedermayer: > On Thu, Oct 08, 2020 at 09:53:12PM +0200, Andreas Rheinhardt wrote: >> It can't because the corresponding trees don't have any loose ends. >> >> Removing the checks also removed an instance of av_log(NULL (with a >> nonsense message) from the codebase. >> >> Signed-off-by: Andreas Rheinhardt >> --- >> libavcodec/mdec.c | 2 -- >> libavcodec/mpeg12.h| 4 >> libavcodec/mpeg12dec.c | 4 >> 3 files changed, 10 deletions(-) > > It is possible to encode nonsensical dc differnces, these could be checked > for and trigger errors. Not in the current codebase no, but one could add > a check for it > Without such checks, your patch is probably ok > It is not possible to encode a nonsense difference. The standard has a requirement that predictor (last_dc[component] in our code) + diff be in a certain range, but that is a check that should be performed at the place where the addition is performed; decode_dc() (in its current form) simply lacks the context to know whether the diff it parsed will make the sum violate this requirement. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 18/18] lavf: document some AVStream fields as private
On 10/9/2020 6:57 PM, James Almer wrote: > On 10/9/2020 6:55 PM, Michael Niedermayer wrote: >> On Fri, Oct 09, 2020 at 03:04:30PM +0200, Anton Khirnov wrote: >>> Specifically: pts_wrap_bits, first_dts, cur_dts. >>> They are supposed to be private and are located in the private section >>> of AVStream, but ffmpeg.c currently accesses them regardless. They >>> should be moved to AVStreamInternal once that bug is fixed. >>> >>> Remove the marker for the private AVStream section, as there are no >>> other accessible fields left there. It has proven highly confusing and >>> people kept adding supposedly-public fields into the private section. >>> New private per-stream fields should be added to AVStreamInternal. >>> --- >>> libavformat/avformat.h | 20 +--- >>> 1 file changed, 9 insertions(+), 11 deletions(-) >>> >>> diff --git a/libavformat/avformat.h b/libavformat/avformat.h >>> index a01912d654..612791a2eb 100644 >>> --- a/libavformat/avformat.h >>> +++ b/libavformat/avformat.h >>> @@ -1013,22 +1013,16 @@ typedef struct AVStream { >>> */ >>> AVCodecParameters *codecpar; >>> >>> -/* >>> - * All fields below this line are not part of the public API. They >>> - * may not be used outside of libavformat and can be changed and >>> - * removed at will. >>> - * Internal note: be aware that physically removing these fields >>> - * will break ABI. Replace removed fields with dummy fields, and >>> - * add new fields to AVStreamInternal. >>> - * >>> - */ >>> - >>> #if LIBAVFORMAT_VERSION_MAJOR < 59 >>> // kept for ABI compatibility only, do not access in any way >>> void *unused; >>> #endif >>> >> >>> -int pts_wrap_bits; /**< number of bits in pts (used for wrapping >>> control) */ >>> +/** >>> + * number of bits in pts (used for wrapping control) >>> + * private, do not access from outside libavformat. >>> + */ >>> +int pts_wrap_bits; >> >> This is maybe a really bad way to export "pts_wrap_bits" but i think >> User applications could quite reasonably need to know at which point pts >> wrap. >> Or whats the max duration for a timebase where pts are still unique or valid. >> >> Based on this a user app might warn the user at the begin of transcoding that >> timestamps will wrap and that with non streaming output, wrap might equal >> fail. >> >> so maybe this should not be declared private without replacement. > > It already is private. This commit doesn't change that. I'm not saying that introducing a proper way to export this same information is a bad idea (It would in fact simply "fixing" the relevant code in ffmpeg.c), just that this commit is merely moving a notification from one part of the struct to another. The field itself remains unaffected after this change. > >> >> thx >> >> [...] >> >> >> ___ >> 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 v2] swscale: separate exported and internal range flags
On Fri, Oct 9, 2020 at 10:02 PM Michael Niedermayer wrote: > > On Wed, Oct 07, 2020 at 09:27:20PM +0300, Jan Ekström wrote: > > Fixes vf_scale outputting RGB AVFrames with limited range in > > case either input or output specifically sets the range. > > > > Keeps the external interfaces the same, but allows us to retrieve > > and set nonzero value for RGB. Additionally defines the default > > value of the AVOption as -1 so we can differentiate between > > attempting to force limited range and requesting the default. > > --- > > libswscale/options.c | 4 +- > > libswscale/swscale_internal.h | 3 + > > libswscale/utils.c| 160 +++--- > > 3 files changed, 114 insertions(+), 53 deletions(-) > > This changes the output for: > ./ffmpeg -i ~/tickets/4926/5611842b1f09f2_20295212.png -vf scale=34:44 > file.tga > same with png output > > That is the red looks a bit different, the filesize also changes > file should be here: > https://trac.ffmpeg.org/attachment/ticket/4926/5611842b1f09f2_20295212.png > > I dont know if the one after the patch is more or less correct, but why > does your patch change this ? > is that change intentional ? > Had a look at the stuff that happens by adding a bunch of debug logging: before: [Parsed_scale_0 @ 0x61101080] w:34 h:33 flags:'bicubic' interl:0 [graph 0 input from stream 0:0 @ 0x611011c0] w:2200 h:2827 pixfmt:rgba tb:1/25 fr:25/1 sar:0/1 [swscaler @ 0x62f0e400] sws_init_context: Initial configured range values: src: 0, dst: 0 [swscaler @ 0x62f0e400] sws_init_context: color ranges: src (rgba): 0 dst (rgba): 0 [swscaler @ 0x62f0e400] sws_setColorspaceDetails: color ranges: src (rgba): 0, dst (rgba): 0 (given arguments: src: 0, dst: 0) [swscaler @ 0x62f1c400] sws_init_context: Initial configured range values: src: 0, dst: 0 [swscaler @ 0x62f1c400] sws_init_context: color ranges: src (rgba): 0 dst (yuva420p): 0 [swscaler @ 0x62f1c400] sws_setColorspaceDetails: color ranges: src (rgba): 0, dst (yuva420p): 0 (given arguments: src: 0, dst: 0) [swscaler @ 0x62f2a400] sws_init_context: Initial configured range values: src: 0, dst: 0 [swscaler @ 0x62f2a400] sws_init_context: color ranges: src (yuva420p): 0 dst (rgba): 0 [swscaler @ 0x62f2a400] sws_setColorspaceDetails: color ranges: src (yuva420p): 0, dst (rgba): 0 (given arguments: src: 0, dst: 0) [Parsed_scale_0 @ 0x61101080] w:2200 h:2827 fmt:rgba sar:0/1 -> w:34 h:33 fmt:rgba sar:0/1 flags:0x4 [Parsed_scale_0 @ 0x61101080] scale_frame: received range info: 0, dst: 0 [Parsed_scale_0 @ 0x61101080] scale_frame: filter chain logic range info: 1, dst: 0 [swscaler @ 0x62f0e400] sws_setColorspaceDetails: color ranges: src (rgba): 0, dst (rgba): 0 (given arguments: src: 1, dst: 0) [swscaler @ 0x62f1c400] sws_setColorspaceDetails: color ranges: src (rgba): 0, dst (yuva420p): 0 (given arguments: src: 0, dst: 0) before with 'scale=w=34:h=33:out_range=full' filter chain: [Parsed_scale_0 @ 0x61101080] w:34 h:33 flags:'bicubic' interl:0 [graph 0 input from stream 0:0 @ 0x611011c0] w:2200 h:2827 pixfmt:rgba tb:1/25 fr:25/1 sar:0/1 [swscaler @ 0x62f0e400] sws_init_context: Initial configured range values: src: 0, dst: 1 [swscaler @ 0x62f0e400] sws_init_context: color ranges: src (rgba): 0 dst (rgba): 1 [swscaler @ 0x62f0e400] sws_setColorspaceDetails: color ranges: src (rgba): 0, dst (rgba): 0 (given arguments: src: 0, dst: 1) [swscaler @ 0x62f1c400] sws_init_context: Initial configured range values: src: 0, dst: 0 [swscaler @ 0x62f1c400] sws_init_context: color ranges: src (rgba): 0 dst (yuva420p): 0 [swscaler @ 0x62f1c400] sws_setColorspaceDetails: color ranges: src (rgba): 0, dst (yuva420p): 0 (given arguments: src: 0, dst: 0) [swscaler @ 0x62f2a400] sws_init_context: Initial configured range values: src: 0, dst: 0 [swscaler @ 0x62f2a400] sws_init_context: color ranges: src (yuva420p): 0 dst (rgba): 0 [swscaler @ 0x62f2a400] sws_setColorspaceDetails: color ranges: src (yuva420p): 0, dst (rgba): 0 (given arguments: src: 0, dst: 0) [Parsed_scale_0 @ 0x61101080] w:2200 h:2827 fmt:rgba sar:0/1 -> w:34 h:33 fmt:rgba sar:0/1 flags:0x4 [Parsed_scale_0 @ 0x61101080] scale_frame: received range info: 0, dst: 0 [Parsed_scale_0 @ 0x61101080] scale_frame: filter chain logic range info: 1, dst: 1 [swscaler @ 0x62f0e400] sws_setColorspaceDetails: color ranges: src (rgba): 0, dst (rgba): 0 (given arguments: src: 1, dst: 1) [swscaler @ 0x62f1c400] sws_setColorspaceDetails: color ranges: src (rgba): 0, dst (yuva420p): 0 (given arguments: src: 0, dst: 0) after: [Parsed_scale_0 @ 0x61101080] w:34 h:33 flags:'bicubic' interl:0 [graph 0 input from stream 0:0 @ 0x611011c0] w:2200 h:2827 pixfmt:rgba tb:1/25 fr:25/1 sar:0/1 [swscaler @ 0x62f0e400] sws_init_context: Initial configured range values: src: -1, dst: -1 [swscaler @ 0x62f0e400] sws_init_context: color
Re: [FFmpeg-devel] [PATCH 11/18] lavf: move AVStream.pts_buffer to AVStreamInternal
On Fri, Oct 09, 2020 at 03:04:23PM +0200, Anton Khirnov wrote: > Those are private fields, no reason to have them exposed in a public > header. > --- > libavformat/avformat.h | 3 +-- > libavformat/internal.h | 4 > libavformat/mux.c | 12 ++-- > libavformat/utils.c| 14 +++--- > 4 files changed, 18 insertions(+), 15 deletions(-) probably ok thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope 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 18/18] lavf: document some AVStream fields as private
On 10/9/2020 6:55 PM, Michael Niedermayer wrote: > On Fri, Oct 09, 2020 at 03:04:30PM +0200, Anton Khirnov wrote: >> Specifically: pts_wrap_bits, first_dts, cur_dts. >> They are supposed to be private and are located in the private section >> of AVStream, but ffmpeg.c currently accesses them regardless. They >> should be moved to AVStreamInternal once that bug is fixed. >> >> Remove the marker for the private AVStream section, as there are no >> other accessible fields left there. It has proven highly confusing and >> people kept adding supposedly-public fields into the private section. >> New private per-stream fields should be added to AVStreamInternal. >> --- >> libavformat/avformat.h | 20 +--- >> 1 file changed, 9 insertions(+), 11 deletions(-) >> >> diff --git a/libavformat/avformat.h b/libavformat/avformat.h >> index a01912d654..612791a2eb 100644 >> --- a/libavformat/avformat.h >> +++ b/libavformat/avformat.h >> @@ -1013,22 +1013,16 @@ typedef struct AVStream { >> */ >> AVCodecParameters *codecpar; >> >> -/* >> - * All fields below this line are not part of the public API. They >> - * may not be used outside of libavformat and can be changed and >> - * removed at will. >> - * Internal note: be aware that physically removing these fields >> - * will break ABI. Replace removed fields with dummy fields, and >> - * add new fields to AVStreamInternal. >> - * >> - */ >> - >> #if LIBAVFORMAT_VERSION_MAJOR < 59 >> // kept for ABI compatibility only, do not access in any way >> void *unused; >> #endif >> > >> -int pts_wrap_bits; /**< number of bits in pts (used for wrapping >> control) */ >> +/** >> + * number of bits in pts (used for wrapping control) >> + * private, do not access from outside libavformat. >> + */ >> +int pts_wrap_bits; > > This is maybe a really bad way to export "pts_wrap_bits" but i think > User applications could quite reasonably need to know at which point pts wrap. > Or whats the max duration for a timebase where pts are still unique or valid. > > Based on this a user app might warn the user at the begin of transcoding that > timestamps will wrap and that with non streaming output, wrap might equal > fail. > > so maybe this should not be declared private without replacement. It already is private. This commit doesn't change that. > > thx > > [...] > > > ___ > 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 13/18] lavf: move AVStream.last_in_packet_buffer to AVStreamInternal
On Fri, Oct 09, 2020 at 03:04:25PM +0200, Anton Khirnov wrote: > Those are private fields, no reason to have them exposed in a public > header. > --- > libavformat/avformat.h | 6 +- > libavformat/internal.h | 5 + > libavformat/mux.c | 18 +- > libavformat/mxfenc.c | 10 +- > 4 files changed, 20 insertions(+), 19 deletions(-) probably ok thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you fake or manipulate statistics in a paper in physics you will never get a job again. If you fake or manipulate statistics in a paper in medicin you will get a job for life at the pharma industry. 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 18/18] lavf: document some AVStream fields as private
On Fri, Oct 09, 2020 at 03:04:30PM +0200, Anton Khirnov wrote: > Specifically: pts_wrap_bits, first_dts, cur_dts. > They are supposed to be private and are located in the private section > of AVStream, but ffmpeg.c currently accesses them regardless. They > should be moved to AVStreamInternal once that bug is fixed. > > Remove the marker for the private AVStream section, as there are no > other accessible fields left there. It has proven highly confusing and > people kept adding supposedly-public fields into the private section. > New private per-stream fields should be added to AVStreamInternal. > --- > libavformat/avformat.h | 20 +--- > 1 file changed, 9 insertions(+), 11 deletions(-) > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index a01912d654..612791a2eb 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -1013,22 +1013,16 @@ typedef struct AVStream { > */ > AVCodecParameters *codecpar; > > -/* > - * All fields below this line are not part of the public API. They > - * may not be used outside of libavformat and can be changed and > - * removed at will. > - * Internal note: be aware that physically removing these fields > - * will break ABI. Replace removed fields with dummy fields, and > - * add new fields to AVStreamInternal. > - * > - */ > - > #if LIBAVFORMAT_VERSION_MAJOR < 59 > // kept for ABI compatibility only, do not access in any way > void *unused; > #endif > > -int pts_wrap_bits; /**< number of bits in pts (used for wrapping > control) */ > +/** > + * number of bits in pts (used for wrapping control) > + * private, do not access from outside libavformat. > + */ > +int pts_wrap_bits; This is maybe a really bad way to export "pts_wrap_bits" but i think User applications could quite reasonably need to know at which point pts wrap. Or whats the max duration for a timebase where pts are still unique or valid. Based on this a user app might warn the user at the begin of transcoding that timestamps will wrap and that with non streaming output, wrap might equal fail. so maybe this should not be declared private without replacement. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No great genius has ever existed without some touch of madness. -- Aristotle signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avformat/libsrt: fix cleanups on failed libsrt_open() and libsrt_setup()
- Call srt_epoll_release() to avoid fd leak on libsrt_setup() error. - Call srt_cleanup() on libsrt_open() failure. - Fix return value and method on mode parsing failure. Based on a patch by Nicolas Sugino . Signed-off-by: Marton Balint --- libavformat/libsrt.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 4025b24976..f73e7dbfa5 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -373,11 +373,6 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) int64_t open_timeout = 0; int eid; -eid = srt_epoll_create(); -if (eid < 0) -return libsrt_neterrno(h); -s->eid = eid; - av_url_split(proto, sizeof(proto), NULL, 0, hostname, sizeof(hostname), , path, sizeof(path), uri); if (strcmp(proto, "srt")) @@ -413,6 +408,11 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) cur_ai = ai; +eid = srt_epoll_create(); +if (eid < 0) +return libsrt_neterrno(h); +s->eid = eid; + restart: fd = srt_socket(cur_ai->ai_family, cur_ai->ai_socktype, 0); @@ -495,6 +495,7 @@ static int libsrt_setup(URLContext *h, const char *uri, int flags) if (listen_fd >= 0) srt_close(listen_fd); freeaddrinfo(ai); +srt_epoll_release(s->eid); return ret; } @@ -584,7 +585,8 @@ static int libsrt_open(URLContext *h, const char *uri, int flags) } else if (!strcmp(buf, "rendezvous")) { s->mode = SRT_MODE_RENDEZVOUS; } else { -return AVERROR(EIO); +ret = AVERROR(EINVAL); +goto err; } } if (av_find_info_tag(buf, sizeof(buf), "sndbuf", p)) { @@ -632,10 +634,15 @@ static int libsrt_open(URLContext *h, const char *uri, int flags) s->linger = strtol(buf, NULL, 10); } } -return libsrt_setup(h, uri, flags); +ret = libsrt_setup(h, uri, flags); +if (ret < 0) +goto err; +return 0; + err: av_freep(>smoother); av_freep(>streamid); +srt_cleanup(); return ret; } -- 2.26.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] avcodec/h2645_parse: remove initial skipped_bytes_pos buffer
Allocate it only when it's needed. Fixes: OOM Fixes: 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: James Almer --- libavcodec/h2645_parse.c | 28 ++-- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c index 0f98b49fbe..929fb34eef 100644 --- a/libavcodec/h2645_parse.c +++ b/libavcodec/h2645_parse.c @@ -108,22 +108,20 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int length, dst[di++] = 0; si += 3; -if (nal->skipped_bytes_pos) { -nal->skipped_bytes++; -if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { -nal->skipped_bytes_pos_size *= 2; -av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); -av_reallocp_array(>skipped_bytes_pos, +nal->skipped_bytes++; +if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { +nal->skipped_bytes_pos_size = nal->skipped_bytes * 2; +av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); +av_reallocp_array(>skipped_bytes_pos, nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); -if (!nal->skipped_bytes_pos) { -nal->skipped_bytes_pos_size = 0; -return AVERROR(ENOMEM); -} +if (!nal->skipped_bytes_pos) { +nal->skipped_bytes_pos_size = 0; +return AVERROR(ENOMEM); } -if (nal->skipped_bytes_pos) -nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; } +if (nal->skipped_bytes_pos) +nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; continue; } else // next start code goto nsc; @@ -466,12 +464,6 @@ int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, pkt->nals = tmp; memset(pkt->nals + pkt->nals_allocated, 0, sizeof(*pkt->nals)); -nal = >nals[pkt->nb_nals]; -nal->skipped_bytes_pos_size = 1024; // initial buffer size -nal->skipped_bytes_pos = av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); -if (!nal->skipped_bytes_pos) -return AVERROR(ENOMEM); - pkt->nals_allocated = new_size; } nal = >nals[pkt->nb_nals]; -- 2.27.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 2/3] avcodec/mpeg12: Don't pretend reading dct_dc_size_* VLCs can fail
On Thu, Oct 08, 2020 at 09:53:12PM +0200, Andreas Rheinhardt wrote: > It can't because the corresponding trees don't have any loose ends. > > Removing the checks also removed an instance of av_log(NULL (with a > nonsense message) from the codebase. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mdec.c | 2 -- > libavcodec/mpeg12.h| 4 > libavcodec/mpeg12dec.c | 4 > 3 files changed, 10 deletions(-) It is possible to encode nonsensical dc differnces, these could be checked for and trigger errors. Not in the current codebase no, but one could add a check for it Without such checks, your patch is probably ok thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Republics decline into democracies and democracies degenerate into despotisms. -- Aristotle 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] avcodec/mpeg12dec: Optimize reading mpeg2 intra escape codes
On Thu, Oct 08, 2020 at 09:53:13PM +0200, Andreas Rheinhardt wrote: > Said escape code is only six bits long, so that one has at least 25 - 6 > bits in the bitstream reader's cache after reading it; therefore the > whole following 18 bits (containing the actual code) are already in the > bitstream reader's cache, making it unnecessary to reload the cache. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mpeg12dec.c | 10 -- > 1 file changed, 4 insertions(+), 6 deletions(-) Interresting that this was not noticed before but LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB During times of universal deceit, telling the truth becomes a revolutionary act. -- George Orwell signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/h2645_parse: remove initial skipped_bytes_pos buffer
James Almer: > On 10/9/2020 1:36 PM, Michael Niedermayer wrote: >> On Thu, Oct 08, 2020 at 10:25:11AM -0300, James Almer wrote: >>> Allocate it only when needed, and instead of giving it a fixed initial size >>> that's doubled on each realloc, ensure it's always big enough for the NAL >>> currently being parsed. >>> >>> Fixes: OOM >>> Fixes: >>> 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960 >>> >>> Found-by: continuous fuzzing process >>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg >>> Signed-off-by: James Almer >>> --- >>> libavcodec/h2645_parse.c | 28 ++-- >>> 1 file changed, 10 insertions(+), 18 deletions(-) >>> >>> diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c >>> index 0f98b49fbe..f5c76323c1 100644 >>> --- a/libavcodec/h2645_parse.c >>> +++ b/libavcodec/h2645_parse.c >>> @@ -108,22 +108,20 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int >>> length, >>> dst[di++] = 0; >>> si += 3; >>> >>> -if (nal->skipped_bytes_pos) { >>> -nal->skipped_bytes++; >>> -if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { >>> -nal->skipped_bytes_pos_size *= 2; >>> -av_assert0(nal->skipped_bytes_pos_size >= >>> nal->skipped_bytes); >>> -av_reallocp_array(>skipped_bytes_pos, >>> +nal->skipped_bytes++; >>> +if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { >>> +nal->skipped_bytes_pos_size = length / 3; >> >> This would allocate a much larger than needed skipped_bytes_pos for >> probably nearly all of the real world h264 files to fix an issue with >> crafted streams. >> >> The initial size should be choosen so as to be large enough for real world >> streams. If that turns out to be too small then length /3 sounds reasonable >> as the first reallocation. > > At most 1/3 of the bytes in a NAL would be removed by this code, hence > length / 3. I could make it length / 16 like in your fix if you prefer, > or maybe nal->skipped_bytes * 2 to keep it closer to the current > behavior, but real world samples don't have more than a handful of NALs > per packet, and not all have escaped bytes that need to be removed (If > there are none, nothing will be allocated). > > I looked at a 2160p hevc sample, and the biggest packet is about 26kb, > which assuming it's a single slice NAL, it will be about 8kb for the > skipped_bytes_pos buffer with length / 3. > Your calculation seems to be off by a factor of four because you ignore that every byte removed needs an entry of type int*. Furthermore 26kB (I presume you meant kB and not kb) seems very, very small for a normal file these days; it feels more like 320p streaming or so. Furthermore, there is a bigger issue with your patch: It can lead to quadratic memory consumption for annex B input: Because the length of the NAL units is not known in advance, length in the above code refers to the length from the beginning of the NAL unit to the end of the packet. So this code will allocate gigantic amounts of memory for a packet containing lots of small NAL units, each with a single 0x03. This is an issue similar to the one fixed by 03b82b3ab9883cef017e513c7d0b3b986b3b3e7b. - Andreas *: Yes, I know there is no guarantee that sizeof(int) is four. ___ 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/h2645_parse: remove initial skipped_bytes_pos buffer
On 10/9/2020 1:36 PM, Michael Niedermayer wrote: > On Thu, Oct 08, 2020 at 10:25:11AM -0300, James Almer wrote: >> Allocate it only when needed, and instead of giving it a fixed initial size >> that's doubled on each realloc, ensure it's always big enough for the NAL >> currently being parsed. >> >> Fixes: OOM >> Fixes: >> 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960 >> >> Found-by: continuous fuzzing process >> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg >> Signed-off-by: James Almer >> --- >> libavcodec/h2645_parse.c | 28 ++-- >> 1 file changed, 10 insertions(+), 18 deletions(-) >> >> diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c >> index 0f98b49fbe..f5c76323c1 100644 >> --- a/libavcodec/h2645_parse.c >> +++ b/libavcodec/h2645_parse.c >> @@ -108,22 +108,20 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int >> length, >> dst[di++] = 0; >> si += 3; >> >> -if (nal->skipped_bytes_pos) { >> -nal->skipped_bytes++; >> -if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { >> -nal->skipped_bytes_pos_size *= 2; >> -av_assert0(nal->skipped_bytes_pos_size >= >> nal->skipped_bytes); >> -av_reallocp_array(>skipped_bytes_pos, >> +nal->skipped_bytes++; >> +if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { >> +nal->skipped_bytes_pos_size = length / 3; > > This would allocate a much larger than needed skipped_bytes_pos for > probably nearly all of the real world h264 files to fix an issue with > crafted streams. > > The initial size should be choosen so as to be large enough for real world > streams. If that turns out to be too small then length /3 sounds reasonable > as the first reallocation. At most 1/3 of the bytes in a NAL would be removed by this code, hence length / 3. I could make it length / 16 like in your fix if you prefer, or maybe nal->skipped_bytes * 2 to keep it closer to the current behavior, but real world samples don't have more than a handful of NALs per packet, and not all have escaped bytes that need to be removed (If there are none, nothing will be allocated). I looked at a 2160p hevc sample, and the biggest packet is about 26kb, which assuming it's a single slice NAL, it will be about 8kb for the skipped_bytes_pos buffer with length / 3. > > thx > [...] > > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3 v2] cmdutils: use the new device iteration API to list devices
Signed-off-by: James Almer --- fftools/cmdutils.c | 32 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 88fdbeaf1e..ba25e5c884 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -2302,7 +2302,8 @@ static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionar int show_sources(void *optctx, const char *opt, const char *arg) { -AVInputFormat *fmt = NULL; +const AVInputFormat *fmt = NULL; +void *fmt_iter = NULL; char *dev = NULL; AVDictionary *opts = NULL; int ret = 0; @@ -2314,21 +2315,11 @@ int show_sources(void *optctx, const char *opt, const char *arg) goto fail; do { -fmt = av_input_audio_device_next(fmt); +fmt = av_indev_iterate(_iter); if (fmt) { -if (!strcmp(fmt->name, "lavfi")) -continue; //it's pointless to probe lavfi if (dev && !av_match_name(dev, fmt->name)) continue; -print_device_sources(fmt, opts); -} -} while (fmt); -do { -fmt = av_input_video_device_next(fmt); -if (fmt) { -if (dev && !av_match_name(dev, fmt->name)) -continue; -print_device_sources(fmt, opts); +print_device_sources((AVInputFormat *)fmt, opts); } } while (fmt); fail: @@ -2340,7 +2331,8 @@ int show_sources(void *optctx, const char *opt, const char *arg) int show_sinks(void *optctx, const char *opt, const char *arg) { -AVOutputFormat *fmt = NULL; +const AVOutputFormat *fmt = NULL; +void *fmt_iter = NULL; char *dev = NULL; AVDictionary *opts = NULL; int ret = 0; @@ -2352,19 +2344,11 @@ int show_sinks(void *optctx, const char *opt, const char *arg) goto fail; do { -fmt = av_output_audio_device_next(fmt); -if (fmt) { -if (dev && !av_match_name(dev, fmt->name)) -continue; -print_device_sinks(fmt, opts); -} -} while (fmt); -do { -fmt = av_output_video_device_next(fmt); +fmt = av_outdev_iterate(_iter); if (fmt) { if (dev && !av_match_name(dev, fmt->name)) continue; -print_device_sinks(fmt, opts); +print_device_sinks((AVOutputFormat *)fmt, opts); } } while (fmt); fail: -- 2.27.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] avfilter/vf_bwdif_cuda: CUDA implementation of bwdif
I've been sitting on this for a couple of years now, and I figured I should just send it out. This is what I believe is a conceptually correct port of bwdif to cuda (modulo edge handling which is not done in the same way because the conditional checks for edges are expensive in cuda, but that's the same as for yadif_cuda). However, I see glitches in some samples where black or white pixels appear in white or black areas respectively. This seems like some sort of under/overflow. I've tried to use the largest cuda types everywhere, and that did appear to improve things but didn't make it go away. This is what led to me never sending this diff over the years, but maybe someone else has insights about this. --- configure| 2 + libavfilter/Makefile | 2 + libavfilter/allfilters.c | 1 + libavfilter/vf_bwdif_cuda.c | 394 +++ libavfilter/vf_bwdif_cuda.cu | 290 ++ 5 files changed, 689 insertions(+) create mode 100644 libavfilter/vf_bwdif_cuda.c create mode 100644 libavfilter/vf_bwdif_cuda.cu diff --git a/configure b/configure index 75f0a0fcaa..4e7a97b17e 100755 --- a/configure +++ b/configure @@ -3511,6 +3511,8 @@ bm3d_filter_select="dct" boxblur_filter_deps="gpl" boxblur_opencl_filter_deps="opencl gpl" bs2b_filter_deps="libbs2b" +bwdif_cuda_filter_deps="ffnvcodec" +bwdif_cuda_filter_deps_any="cuda_nvcc cuda_llvm" chromaber_vulkan_filter_deps="vulkan libglslang" colorkey_opencl_filter_deps="opencl" colormatrix_filter_deps="gpl" diff --git a/libavfilter/Makefile b/libavfilter/Makefile index e6d3c283da..db99238fce 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -178,6 +178,8 @@ OBJS-$(CONFIG_BOXBLUR_FILTER)+= vf_boxblur.o boxblur.o OBJS-$(CONFIG_BOXBLUR_OPENCL_FILTER) += vf_avgblur_opencl.o opencl.o \ opencl/avgblur.o boxblur.o OBJS-$(CONFIG_BWDIF_FILTER) += vf_bwdif.o yadif_common.o +OBJS-$(CONFIG_BWDIF_CUDA_FILTER) += vf_bwdif_cuda.o vf_bwdif_cuda.ptx.o \ +yadif_common.o OBJS-$(CONFIG_CAS_FILTER)+= vf_cas.o OBJS-$(CONFIG_CHROMABER_VULKAN_FILTER) += vf_chromaber_vulkan.o vulkan.o OBJS-$(CONFIG_CHROMAHOLD_FILTER) += vf_chromakey.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index fa91e608e4..2da43166a5 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -169,6 +169,7 @@ extern AVFilter ff_vf_bm3d; extern AVFilter ff_vf_boxblur; extern AVFilter ff_vf_boxblur_opencl; extern AVFilter ff_vf_bwdif; +extern AVFilter ff_vf_bwdif_cuda; extern AVFilter ff_vf_cas; extern AVFilter ff_vf_chromahold; extern AVFilter ff_vf_chromakey; diff --git a/libavfilter/vf_bwdif_cuda.c b/libavfilter/vf_bwdif_cuda.c new file mode 100644 index 00..7651a869d5 --- /dev/null +++ b/libavfilter/vf_bwdif_cuda.c @@ -0,0 +1,394 @@ +/* + * Copyright (C) 2018 Philip Langdale + * + * 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.h" +#include "libavutil/hwcontext_cuda_internal.h" +#include "libavutil/cuda_check.h" +#include "internal.h" +#include "yadif.h" + +extern char vf_bwdif_cuda_ptx[]; + +typedef struct DeintCUDAContext { +YADIFContext yadif; + +AVCUDADeviceContext *hwctx; +AVBufferRef *device_ref; +AVBufferRef *input_frames_ref; +AVHWFramesContext *input_frames; + +CUcontext cu_ctx; +CUstreamstream; +CUmodulecu_module; +CUfunction cu_func_uchar; +CUfunction cu_func_uchar2; +CUfunction cu_func_ushort; +CUfunction cu_func_ushort2; +} DeintCUDAContext; + +#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) ) +#define ALIGN_UP(a, b) (((a) + (b) - 1) & ~((b) - 1)) +#define BLOCKX 32 +#define BLOCKY 16 + +#define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x) + +static CUresult call_kernel(AVFilterContext *ctx, CUfunction func, +CUdeviceptr prev, CUdeviceptr cur, CUdeviceptr next, +CUarray_format format, int channels, +int src_width, // Width is pixels per channel +
Re: [FFmpeg-devel] [PATCH 3/3] cmdutils: use the new device iteration API to list devices
James Almer: > Signed-off-by: James Almer > --- > fftools/cmdutils.c | 28 ++-- > 1 file changed, 6 insertions(+), 22 deletions(-) > > diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c > index 88fdbeaf1e..83989b8190 100644 > --- a/fftools/cmdutils.c > +++ b/fftools/cmdutils.c > @@ -2302,7 +2302,8 @@ static int show_sinks_sources_parse_arg(const char > *arg, char **dev, AVDictionar > > int show_sources(void *optctx, const char *opt, const char *arg) > { > -AVInputFormat *fmt = NULL; > +const AVInputFormat *fmt = NULL; > +void *fmt_iter = NULL; > char *dev = NULL; > AVDictionary *opts = NULL; > int ret = 0; > @@ -2314,17 +2315,7 @@ int show_sources(void *optctx, const char *opt, const > char *arg) > goto fail; > > do { > -fmt = av_input_audio_device_next(fmt); > -if (fmt) { > -if (!strcmp(fmt->name, "lavfi")) > -continue; //it's pointless to probe lavfi > -if (dev && !av_match_name(dev, fmt->name)) > -continue; > -print_device_sources(fmt, opts); > -} > -} while (fmt); > -do { > -fmt = av_input_video_device_next(fmt); > +fmt = av_indev_iterate(_iter); > if (fmt) { > if (dev && !av_match_name(dev, fmt->name)) > continue; > @@ -2340,7 +2331,8 @@ int show_sources(void *optctx, const char *opt, const > char *arg) > > int show_sinks(void *optctx, const char *opt, const char *arg) > { > -AVOutputFormat *fmt = NULL; > +const AVInputFormat *fmt = NULL; AVOutputFormat > +void *fmt_iter = NULL; > char *dev = NULL; > AVDictionary *opts = NULL; > int ret = 0; > @@ -2352,15 +2344,7 @@ int show_sinks(void *optctx, const char *opt, const > char *arg) > goto fail; > > do { > -fmt = av_output_audio_device_next(fmt); > -if (fmt) { > -if (dev && !av_match_name(dev, fmt->name)) > -continue; > -print_device_sinks(fmt, opts); > -} > -} while (fmt); > -do { > -fmt = av_output_video_device_next(fmt); > +fmt = av_outdev_iterate(_iter); > if (fmt) { > if (dev && !av_match_name(dev, fmt->name)) > continue; > ___ 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] avdevice: add new API for iterating input and output devices
And deprecate the linked list based one. Based on a patch by Josh de Kock. Signed-off-by: James Almer --- doc/APIchanges | 5 + libavdevice/alldevices.c | 22 ++ libavdevice/avdevice.h | 36 libavdevice/version.h| 7 +-- 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index f2830968bb..ae1f9ace77 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -15,6 +15,11 @@ libavutil: 2017-10-21 API changes, most recent first: +2020-10-xx - xx - lavd 58.12.100 - avdevice.h + Deprecate use of av_input_audio_device_next(), av_input_video_device_next(), + av_output_audio_device_next(), av_output_video_device_next(). + Add av_indev_iterate(), and av_outdev_iterate(). + 2020-xx-xx - xx - lavu 56.60.100 - buffer.h Add a av_buffer_replace() convenience function. diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c index 4137f60109..2f17e9f33b 100644 --- a/libavdevice/alldevices.c +++ b/libavdevice/alldevices.c @@ -63,11 +63,32 @@ extern AVInputFormat ff_libdc1394_demuxer; #include "libavdevice/outdev_list.c" #include "libavdevice/indev_list.c" +const AVOutputFormat *av_outdev_iterate(void **opaque) +{ +uintptr_t i = (uintptr_t)*opaque; +const AVOutputFormat *f = outdev_list[i]; + +if (f) +*opaque = (void*)(i + 1); +return f; +} + +const AVInputFormat *av_indev_iterate(void **opaque) +{ +uintptr_t i = (uintptr_t)*opaque; +const AVInputFormat *f = indev_list[i]; + +if (f) +*opaque = (void*)(i + 1); +return f; +} + void avdevice_register_all(void) { avpriv_register_devices(outdev_list, indev_list); } +#if FF_API_DEVICE_NEXT static void *next_input(AVInputFormat *prev, AVClassCategory c2) { const AVClass *pc; @@ -143,3 +164,4 @@ AVOutputFormat *av_output_video_device_next(AVOutputFormat *d) { return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT); } +#endif diff --git a/libavdevice/avdevice.h b/libavdevice/avdevice.h index ee9462480e..388f93c155 100644 --- a/libavdevice/avdevice.h +++ b/libavdevice/avdevice.h @@ -70,13 +70,39 @@ const char *avdevice_license(void); */ void avdevice_register_all(void); +/** + * Iterate over all registered output devices. + * + * @param opaque a pointer where libavdevice will store the iteration state. Must + * point to NULL to start the iteration. + * + * @return the next registered output device or NULL when the iteration is + * finished + */ +const AVOutputFormat *av_outdev_iterate(void **opaque); + +/** + * Iterate over all registered input devices. + * + * @param opaque a pointer where libavdevice will store the iteration state. Must + * point to NULL to start the iteration. + * + * @return the next registered input device or NULL when the iteration is + * finished + */ +const AVInputFormat *av_indev_iterate(void **opaque); + +#if FF_API_DEVICE_NEXT /** * Audio input devices iterator. * * If d is NULL, returns the first registered input audio/video device, * if d is non-NULL, returns the next registered input audio/video device after d * or NULL if d is the last one. + * + * @deprecated use av_indev_iterate() instead */ +attribute_deprecated AVInputFormat *av_input_audio_device_next(AVInputFormat *d); /** @@ -85,7 +111,10 @@ AVInputFormat *av_input_audio_device_next(AVInputFormat *d); * If d is NULL, returns the first registered input audio/video device, * if d is non-NULL, returns the next registered input audio/video device after d * or NULL if d is the last one. + * + * @deprecated use av_indev_iterate() instead */ +attribute_deprecated AVInputFormat *av_input_video_device_next(AVInputFormat *d); /** @@ -94,7 +123,10 @@ AVInputFormat *av_input_video_device_next(AVInputFormat *d); * If d is NULL, returns the first registered output audio/video device, * if d is non-NULL, returns the next registered output audio/video device after d * or NULL if d is the last one. + * + * @deprecated use av_outdev_iterate() instead */ +attribute_deprecated AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d); /** @@ -103,8 +135,12 @@ AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d); * If d is NULL, returns the first registered output audio/video device, * if d is non-NULL, returns the next registered output audio/video device after d * or NULL if d is the last one. + * + * @deprecated use av_outdev_iterate() instead */ +attribute_deprecated AVOutputFormat *av_output_video_device_next(AVOutputFormat *d); +#endif typedef struct AVDeviceRect { int x; /**< x coordinate of top left corner */ diff --git a/libavdevice/version.h b/libavdevice/version.h index e3aca9e3d2..7f5f46e428 100644 --- a/libavdevice/version.h +++ b/libavdevice/version.h @@ -28,8 +28,8 @@ #include "libavutil/version.h" #define
[FFmpeg-devel] [PATCH 3/3] cmdutils: use the new device iteration API to list devices
Signed-off-by: James Almer --- fftools/cmdutils.c | 28 ++-- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 88fdbeaf1e..83989b8190 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -2302,7 +2302,8 @@ static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionar int show_sources(void *optctx, const char *opt, const char *arg) { -AVInputFormat *fmt = NULL; +const AVInputFormat *fmt = NULL; +void *fmt_iter = NULL; char *dev = NULL; AVDictionary *opts = NULL; int ret = 0; @@ -2314,17 +2315,7 @@ int show_sources(void *optctx, const char *opt, const char *arg) goto fail; do { -fmt = av_input_audio_device_next(fmt); -if (fmt) { -if (!strcmp(fmt->name, "lavfi")) -continue; //it's pointless to probe lavfi -if (dev && !av_match_name(dev, fmt->name)) -continue; -print_device_sources(fmt, opts); -} -} while (fmt); -do { -fmt = av_input_video_device_next(fmt); +fmt = av_indev_iterate(_iter); if (fmt) { if (dev && !av_match_name(dev, fmt->name)) continue; @@ -2340,7 +2331,8 @@ int show_sources(void *optctx, const char *opt, const char *arg) int show_sinks(void *optctx, const char *opt, const char *arg) { -AVOutputFormat *fmt = NULL; +const AVInputFormat *fmt = NULL; +void *fmt_iter = NULL; char *dev = NULL; AVDictionary *opts = NULL; int ret = 0; @@ -2352,15 +2344,7 @@ int show_sinks(void *optctx, const char *opt, const char *arg) goto fail; do { -fmt = av_output_audio_device_next(fmt); -if (fmt) { -if (dev && !av_match_name(dev, fmt->name)) -continue; -print_device_sinks(fmt, opts); -} -} while (fmt); -do { -fmt = av_output_video_device_next(fmt); +fmt = av_outdev_iterate(_iter); if (fmt) { if (dev && !av_match_name(dev, fmt->name)) continue; -- 2.27.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 1/3] avdevice/alldevices: stop using deprecated linked list API
Signed-off-by: James Almer --- libavdevice/alldevices.c | 76 libavdevice/avdevice.c | 46 2 files changed, 76 insertions(+), 46 deletions(-) diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c index a6f68dd3bb..4137f60109 100644 --- a/libavdevice/alldevices.c +++ b/libavdevice/alldevices.c @@ -67,3 +67,79 @@ void avdevice_register_all(void) { avpriv_register_devices(outdev_list, indev_list); } + +static void *next_input(AVInputFormat *prev, AVClassCategory c2) +{ +const AVClass *pc; +const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_INPUT; +AVClassCategory category = AV_CLASS_CATEGORY_NA; +const AVInputFormat *fmt = NULL; +int i = 0; + +if (prev) { +while (fmt = indev_list[i]) { +i++; +if (av_match_name(prev->name, fmt->name)) +break; +} +} + +do { +fmt = indev_list[i++]; +if (!fmt) +break; +pc = fmt->priv_class; +if (!pc) +continue; +category = pc->category; +} while (category != c1 && category != c2); +return (AVInputFormat *)fmt; +} + +static void *next_output(AVOutputFormat *prev, AVClassCategory c2) +{ +const AVClass *pc; +const AVClassCategory c1 = AV_CLASS_CATEGORY_DEVICE_OUTPUT; +AVClassCategory category = AV_CLASS_CATEGORY_NA; +const AVOutputFormat *fmt = NULL; +int i = 0; + +if (prev) { +while (fmt = outdev_list[i]) { +i++; +if (av_match_name(prev->name, fmt->name)) +break; +} +} + +do { +fmt = outdev_list[i++]; +if (!fmt) +break; +pc = fmt->priv_class; +if (!pc) +continue; +category = pc->category; +} while (category != c1 && category != c2); +return (AVOutputFormat *)fmt; +} + +AVInputFormat *av_input_audio_device_next(AVInputFormat *d) +{ +return next_input(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT); +} + +AVInputFormat *av_input_video_device_next(AVInputFormat *d) +{ +return next_input(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT); +} + +AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d) +{ +return next_output(d, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT); +} + +AVOutputFormat *av_output_video_device_next(AVOutputFormat *d) +{ +return next_output(d, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT); +} diff --git a/libavdevice/avdevice.c b/libavdevice/avdevice.c index 3d03d89f04..ec84d3b990 100644 --- a/libavdevice/avdevice.c +++ b/libavdevice/avdevice.c @@ -78,52 +78,6 @@ const char * avdevice_license(void) return _PREFIX FFMPEG_LICENSE[sizeof(LICENSE_PREFIX) - 1]; } -static void *device_next(void *prev, int output, - AVClassCategory c1, AVClassCategory c2) -{ -const AVClass *pc; -AVClassCategory category = AV_CLASS_CATEGORY_NA; -do { -if (output) { -if (!(prev = av_oformat_next(prev))) -break; -pc = ((AVOutputFormat *)prev)->priv_class; -} else { -if (!(prev = av_iformat_next(prev))) -break; -pc = ((AVInputFormat *)prev)->priv_class; -} -if (!pc) -continue; -category = pc->category; -} while (category != c1 && category != c2); -return prev; -} - -AVInputFormat *av_input_audio_device_next(AVInputFormat *d) -{ -return device_next(d, 0, AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT, - AV_CLASS_CATEGORY_DEVICE_INPUT); -} - -AVInputFormat *av_input_video_device_next(AVInputFormat *d) -{ -return device_next(d, 0, AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT, - AV_CLASS_CATEGORY_DEVICE_INPUT); -} - -AVOutputFormat *av_output_audio_device_next(AVOutputFormat *d) -{ -return device_next(d, 1, AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT, - AV_CLASS_CATEGORY_DEVICE_OUTPUT); -} - -AVOutputFormat *av_output_video_device_next(AVOutputFormat *d) -{ -return device_next(d, 1, AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT, - AV_CLASS_CATEGORY_DEVICE_OUTPUT); -} - int avdevice_app_to_dev_control_message(struct AVFormatContext *s, enum AVAppToDevMessageType type, void *data, size_t data_size) { -- 2.27.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 9/9] avformat/aviobuf: increase default read buffer size to 2*max_buffer_size for streamed data
On Thu, 8 Oct 2020, Marton Balint wrote: On Tue, 6 Oct 2020, Marton Balint wrote: On Wed, 30 Sep 2020, Paul B Mahol wrote: On Tue, Sep 29, 2020 at 11:10:21PM +0200, Marton Balint wrote: This should increase the effectiveness of ffio_ensure_seekback by reducing the number of buffer reallocations and memmoves/memcpys because even a small seekback window requires max_buffer_size+window_size buffer space. Signed-off-by: Marton Balint --- libavformat/aviobuf.c | 5 + 1 file changed, 5 insertions(+) This patch set fixes demuxing chained oggs via pipe, so I'm not against it. Thanks for testing. Is there anybody who would like to comment on the patch series before I push it? I know that some regression tests for avio would be good, but it is not something I plan working on. Last ping, will apply soon. Applied the series. Regards, Marton ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] swscale: separate exported and internal range flags
On Wed, Oct 07, 2020 at 09:27:20PM +0300, Jan Ekström wrote: > Fixes vf_scale outputting RGB AVFrames with limited range in > case either input or output specifically sets the range. > > Keeps the external interfaces the same, but allows us to retrieve > and set nonzero value for RGB. Additionally defines the default > value of the AVOption as -1 so we can differentiate between > attempting to force limited range and requesting the default. > --- > libswscale/options.c | 4 +- > libswscale/swscale_internal.h | 3 + > libswscale/utils.c| 160 +++--- > 3 files changed, 114 insertions(+), 53 deletions(-) This changes the output for: ./ffmpeg -i ~/tickets/4926/5611842b1f09f2_20295212.png -vf scale=34:44 file.tga same with png output That is the red looks a bit different, the filesize also changes file should be here: https://trac.ffmpeg.org/attachment/ticket/4926/5611842b1f09f2_20295212.png I dont know if the one after the patch is more or less correct, but why does your patch change this ? is that change intentional ? thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt. 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 14/18] lavf: move AVStream.{need_parsing, parser} to AVStreamInternal
Paul B Mahol: > On Fri, Oct 09, 2020 at 04:36:27PM +0200, Andreas Rheinhardt wrote: >> Anton Khirnov: >>> Those are private fields, no reason to have them exposed in a public >>> header. >>> --- >>> libavdevice/v4l2.c | 2 +- >> >> This is a problem: There is no requirement to update libavdevice at the >> same time as libavformat; one might use a newer version of libavformat >> together with an older version of libavdevice. This effectively makes >> the offsets of all the fields accessed by libavdevice avpriv, regardless >> of whether they are in AVStream or AVStreamInternal. > > Then same can be said for libavcodec and libavformat, thus all my > contributions are thereby declared invalid. If any of your contributions accesses internal fields of libavcodec in libavformat or vice versa, then yes. Do they? AFAIK no. The libavformat/libavdevice situation meanwhile is special, because libavdevice uses (and is supposed to use) internal fields of another library and even defines its own instances of objects whose sizes are not part of ABI/API (namely AVInputFormat and AVOutputFormat). This does not happen with the other libraries as far as I see. - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 14/18] lavf: move AVStream.{need_parsing, parser} to AVStreamInternal
On Fri, Oct 09, 2020 at 04:36:27PM +0200, Andreas Rheinhardt wrote: > Anton Khirnov: > > Those are private fields, no reason to have them exposed in a public > > header. > > --- > > libavdevice/v4l2.c | 2 +- > > This is a problem: There is no requirement to update libavdevice at the > same time as libavformat; one might use a newer version of libavformat > together with an older version of libavdevice. This effectively makes > the offsets of all the fields accessed by libavdevice avpriv, regardless > of whether they are in AVStream or AVStreamInternal. Then same can be said for libavcodec and libavformat, thus all my contributions are thereby declared invalid. ___ 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 15/18] ffmpeg: stop using non-public AVStream fields
On Fri, Oct 09, 2020 at 03:04:27PM +0200, Anton Khirnov wrote: > This effectively reverts ae2cb9290ac and 52c5521877a. > --- > fftools/ffmpeg_opt.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) breaks: ./ffmpeg -ss 2:16 -i ~/tickets/2687/Thailand-Wave.wmv last2sec-of-source.asf with the patch the video stream is empty i suspect that is the input file: http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2639/Thailand-Wave.wmv [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Whats the most studid thing your enemy could do ? Blow himself up Whats the most studid thing you could do ? Give up your rights and freedom because your enemy blew himself up. 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 4/7] lavfi/vf_spp: convert to the video_enc_params API
On Fri, Oct 09, 2020 at 08:13:24AM +0200, Anton Khirnov wrote: > Quoting Michael Niedermayer (2020-10-06 00:15:06) > > On Mon, Oct 05, 2020 at 10:26:24AM +0200, Anton Khirnov wrote: > > > Quoting Michael Niedermayer (2020-10-03 20:23:02) > > > > On Fri, Oct 02, 2020 at 08:03:28PM +0200, Anton Khirnov wrote: > > > > > --- > > > > > libavfilter/Makefile| 2 +- > > > > > libavfilter/vf_spp.c| 57 > > > > > - > > > > > libavfilter/vf_spp.h| 3 +- > > > > > tests/fate/filter-video.mak | 4 +-- > > > > > 4 files changed, 29 insertions(+), 37 deletions(-) > > > > > > > > > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > > > > > index d20f2937b6..2669d7b84b 100644 > > > > > --- a/libavfilter/Makefile > > > > > +++ b/libavfilter/Makefile > > > > > @@ -404,7 +404,7 @@ OBJS-$(CONFIG_SOBEL_FILTER) += > > > > > vf_convolution.o > > > > > OBJS-$(CONFIG_SOBEL_OPENCL_FILTER) += > > > > > vf_convolution_opencl.o opencl.o \ > > > > > opencl/convolution.o > > > > > OBJS-$(CONFIG_SPLIT_FILTER) += split.o > > > > > -OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o > > > > > +OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o qp_table.o > > > > > OBJS-$(CONFIG_SR_FILTER) += vf_sr.o > > > > > OBJS-$(CONFIG_SSIM_FILTER) += vf_ssim.o framesync.o > > > > > OBJS-$(CONFIG_STEREO3D_FILTER) += vf_stereo3d.o > > > > > diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c > > > > > index 4bcc6429e0..2eb383be03 100644 > > > > > --- a/libavfilter/vf_spp.c > > > > > +++ b/libavfilter/vf_spp.c > > > > > @@ -36,6 +36,7 @@ > > > > > #include "libavutil/opt.h" > > > > > #include "libavutil/pixdesc.h" > > > > > #include "internal.h" > > > > > +#include "qp_table.h" > > > > > #include "vf_spp.h" > > > > > > > > > > enum mode { > > > > > @@ -289,7 +290,7 @@ static void filter(SPPContext *p, uint8_t *dst, > > > > > uint8_t *src, > > > > > } else{ > > > > > const int qps = 3 + is_luma; > > > > > qp = qp_table[(FFMIN(x, width - 1) >> qps) + > > > > > (FFMIN(y, height - 1) >> qps) * qp_stride]; > > > > > -qp = FFMAX(1, ff_norm_qscale(qp, p->qscale_type)); > > > > > +qp = FFMAX(1, ff_norm_qscale(qp, > > > > > FF_QSCALE_TYPE_MPEG2)); > > > > > > > > wouldnt this break the cases where qscale_type is not > > > > FF_QSCALE_TYPE_MPEG2 ? > > > > > > There should be no such cases - in the new API, only TYPE_MPEG2 exists > > > (disregarding newer codecs that were not supported by this filter > > > anyway). > > > > before the patch the code was intended to convert the quantization step size > > used in the codec to the same scale as the filter used. disregarding if the > > codec was 8x8 dct based. In fact spp should not require the input to be 8x8 > > dct > > based at all, why should it? It uses the DCT as a means to favor real images > > and remove "noise" that is not part of real images. It should for example > > also > > work if a image has blocking artifacts that look like hexagons or triangles > > > > I never tried but H264 with disabled loop filter should benefit from spp in > > terms of subjective quality as long as the filter strength is set > > appropriately > > That is for streams where the bitrate is low enough to see artifacts > > Are you saying I should expand this filter to support new codecs? That > does not seem appropriate for a patch that only adapts it to new API. no but before your patch theres a central place ff_norm_qscale() that has access to both the QP type (codec type) and the QP and can produce a standarized QP So someone who wanted to SPP support some random new codec could do it there and at the same time have 4 other filters for free also support the new codec. The patch does not replace the qp type by its replacement AVVideoEncParamsType but instead a wrong hardcoded value If you use AVVideoEncParamsType or something equivalent to it / qp_type then that resolves this concern unless iam missing something of course ... thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato 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 v2] swscale: separate exported and internal range flags
On Wed, Oct 7, 2020 at 9:27 PM Jan Ekström wrote: > > Fixes vf_scale outputting RGB AVFrames with limited range in > case either input or output specifically sets the range. > > Keeps the external interfaces the same, but allows us to retrieve > and set nonzero value for RGB. Additionally defines the default > value of the AVOption as -1 so we can differentiate between > attempting to force limited range and requesting the default. > --- > libswscale/options.c | 4 +- > libswscale/swscale_internal.h | 3 + > libswscale/utils.c| 160 +++--- > 3 files changed, 114 insertions(+), 53 deletions(-) > Ping. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 2/3] avcodec/pgxdec: Check depth more completely
On Thu, Oct 08, 2020 at 09:48:41PM +0200, Andreas Rheinhardt wrote: > Michael Niedermayer: > > Fixes: shift exponent -1 is negative > > Fixes: > > 26107/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PGX_fuzzer-5378790047612928 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavcodec/pgxdec.c | 6 +++--- > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > > diff --git a/libavcodec/pgxdec.c b/libavcodec/pgxdec.c > > index 150f8bbf66..5c735894ab 100644 > > --- a/libavcodec/pgxdec.c > > +++ b/libavcodec/pgxdec.c > > @@ -133,14 +133,14 @@ static int pgx_decode_frame(AVCodecContext *avctx, > > void *data, > > if ((ret = ff_set_dimensions(avctx, width, height)) < 0) > > return ret; > > > > -if (depth <= 8) { > > +if (depth > 0 && depth <= 8) { > > avctx->pix_fmt = AV_PIX_FMT_GRAY8; > > bpp = 8; > > -} else if (depth <= 16) { > > +} else if (depth > 0 && depth <= 16) { > > avctx->pix_fmt = AV_PIX_FMT_GRAY16; > > bpp = 16; > > } else { > > -av_log(avctx, AV_LOG_ERROR, "Maximum depth of 16 bits > > supported.\n"); > > +av_log(avctx, AV_LOG_ERROR, "depth %d is invalid or > > unsupported.\n", depth); > > return AVERROR_PATCHWELCOME; > > } > > if (bytestream2_get_bytes_left() < width * height * (bpp >> 3)) > > > I presume the parsed depth to be zero in your testcase. Said number > comes from pgx_get_number() which is only used to parse values for which > a value of zero makes no sense. Wouldn't it make more sense to error out > there if the number is zero? I was considering that too when i wrote the patch the reason why i picked this is thats where depth is checked already. Checking for depth == 0 in one function and depth > 16 in another feels like its not the clearest way to implement that ... thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct answer. 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/flvdec: Check for EOF in amf_parse_object()
On Fri, Oct 09, 2020 at 10:37:20PM +0800, Steven Liu wrote: > > > > 在 2020年10月9日,03:19,Michael Niedermayer 写道: > > > > Fixes: Timeout (too long -> 1ms) > > Fixes: > > 26108/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5653887668977664 > > > > Found-by: continuous fuzzing process > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > > Signed-off-by: Michael Niedermayer > > --- > > libavformat/flvdec.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > > index d480d0bc67..e6786e8b38 100644 > > --- a/libavformat/flvdec.c > > +++ b/libavformat/flvdec.c > > @@ -493,8 +493,11 @@ static int amf_parse_object(AVFormatContext *s, > > AVStream *astream, > > double num_val; > > amf_date date; > > > > + > empty line? removed thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB "I am not trying to be anyone's saviour, I'm trying to think about the future and not be sad" - Elon Musk signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/h2645_parse: remove initial skipped_bytes_pos buffer
On Thu, Oct 08, 2020 at 10:25:11AM -0300, James Almer wrote: > Allocate it only when needed, and instead of giving it a fixed initial size > that's doubled on each realloc, ensure it's always big enough for the NAL > currently being parsed. > > Fixes: OOM > Fixes: > 23817/clusterfuzz-testcase-minimized-ffmpeg_BSF_H264_METADATA_fuzzer-6300869057576960 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: James Almer > --- > libavcodec/h2645_parse.c | 28 ++-- > 1 file changed, 10 insertions(+), 18 deletions(-) > > diff --git a/libavcodec/h2645_parse.c b/libavcodec/h2645_parse.c > index 0f98b49fbe..f5c76323c1 100644 > --- a/libavcodec/h2645_parse.c > +++ b/libavcodec/h2645_parse.c > @@ -108,22 +108,20 @@ int ff_h2645_extract_rbsp(const uint8_t *src, int > length, > dst[di++] = 0; > si += 3; > > -if (nal->skipped_bytes_pos) { > -nal->skipped_bytes++; > -if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { > -nal->skipped_bytes_pos_size *= 2; > -av_assert0(nal->skipped_bytes_pos_size >= > nal->skipped_bytes); > -av_reallocp_array(>skipped_bytes_pos, > +nal->skipped_bytes++; > +if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { > +nal->skipped_bytes_pos_size = length / 3; This would allocate a much larger than needed skipped_bytes_pos for probably nearly all of the real world h264 files to fix an issue with crafted streams. The initial size should be choosen so as to be large enough for real world streams. If that turns out to be too small then length /3 sounds reasonable as the first reallocation. thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many things microsoft did are stupid, but not doing something just because microsoft did it is even more stupid. If everything ms did were stupid they would be bankrupt already. 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] libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header
From: ffmpeg-devel on behalf of Andreas Rheinhardt Sent: Friday, October 9, 2020 8:11 PM To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header Nachiket Tarate: > @James Almer > > Kindly merge this patch if it looks fine. > Can we see the supposed applications first? - Andreas Actually, I am adding support for SAMPLE-AES decryption in HLS demuxer. So, while decrypting AAC audio frames, frame_length is required. I will submit that patch in couple of days. Apple HTTP Live Streaming Sample Decryption: https://developer.apple.com/library/ios/documentation/AudioVideo/Conceptual/HLS_Sample_Encryption -- Nachiket Tarate ___ 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] libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header
Nachiket Tarate: > @James Almer > > Kindly merge this patch if it looks fine. > Can we see the supposed applications first? - Andreas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header
@James Almer Kindly merge this patch if it looks fine. -- Thanks & Regards, Nachiket Tarate From: ffmpeg-devel on behalf of Nachiket Tarate Sent: Thursday, October 8, 2020 8:02 PM To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] libavcodec/adts_header: add frame_length field and avpriv function to parse AAC ADTS header These will be used by HLS demuxer in case of SAMPLE-AES encryption. Signed-off-by: Nachiket Tarate --- libavcodec/adts_header.c | 1 + libavcodec/adts_header.h | 1 + libavcodec/adts_parser.c | 29 - libavcodec/adts_parser.h | 4 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/libavcodec/adts_header.c b/libavcodec/adts_header.c index 0889820f8a..c6680b0fc8 100644 --- a/libavcodec/adts_header.c +++ b/libavcodec/adts_header.c @@ -66,6 +66,7 @@ int ff_adts_header_parse(GetBitContext *gbc, AACADTSHeaderInfo *hdr) hdr->sample_rate= avpriv_mpeg4audio_sample_rates[sr]; hdr->samples= (rdb + 1) * 1024; hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples; +hdr->frame_length = size; return size; } diff --git a/libavcodec/adts_header.h b/libavcodec/adts_header.h index f615f6a9f9..c362ce46a5 100644 --- a/libavcodec/adts_header.h +++ b/libavcodec/adts_header.h @@ -34,6 +34,7 @@ typedef struct AACADTSHeaderInfo { uint8_t sampling_index; uint8_t chan_config; uint8_t num_aac_frames; +uint32_t frame_length; } AACADTSHeaderInfo; /** diff --git a/libavcodec/adts_parser.c b/libavcodec/adts_parser.c index 5c9f8ff6f2..7513b64181 100644 --- a/libavcodec/adts_parser.c +++ b/libavcodec/adts_parser.c @@ -21,7 +21,6 @@ #include #include -#include "adts_header.h" #include "adts_parser.h" int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t *frames) @@ -42,3 +41,31 @@ int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t *frames) return AVERROR(ENOSYS); #endif } + +int avpriv_adts_header_parse (AACADTSHeaderInfo **phdr, const uint8_t *buf, size_t size) +{ +#if CONFIG_ADTS_HEADER +int ret = 0; +GetBitContext gb; + +if (size < AV_AAC_ADTS_HEADER_SIZE) +return AVERROR_INVALIDDATA; + +if (!*phdr) +*phdr = av_mallocz(sizeof(AACADTSHeaderInfo)); +if (!*phdr) +return AVERROR(ENOMEM); + +ret = init_get_bits8(, buf, AV_AAC_ADTS_HEADER_SIZE); +if (ret < 0) +return ret; + +ret = ff_adts_header_parse(, *phdr); +if (ret < 0) +return ret; + +return 0; +#else +return AVERROR(ENOSYS); +#endif +} diff --git a/libavcodec/adts_parser.h b/libavcodec/adts_parser.h index f85becd131..faa6e47426 100644 --- a/libavcodec/adts_parser.h +++ b/libavcodec/adts_parser.h @@ -22,6 +22,8 @@ #include #include +#include "adts_header.h" + #define AV_AAC_ADTS_HEADER_SIZE 7 /** @@ -34,4 +36,6 @@ int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t *frames); +int avpriv_adts_header_parse (AACADTSHeaderInfo **phdr, const uint8_t *buf, size_t size); + #endif /* AVCODEC_ADTS_PARSER_H */ -- 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 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/flvdec: Check for EOF in amf_parse_object()
> 在 2020年10月9日,03:19,Michael Niedermayer 写道: > > Fixes: Timeout (too long -> 1ms) > Fixes: > 26108/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5653887668977664 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavformat/flvdec.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c > index d480d0bc67..e6786e8b38 100644 > --- a/libavformat/flvdec.c > +++ b/libavformat/flvdec.c > @@ -493,8 +493,11 @@ static int amf_parse_object(AVFormatContext *s, AVStream > *astream, > double num_val; > amf_date date; > > + empty line? > num_val = 0; > ioc = s->pb; > +if (avio_feof(ioc)) > +return AVERROR_EOF; > amf_type = avio_r8(ioc); > > switch (amf_type) { > -- > 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". 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 14/18] lavf: move AVStream.{need_parsing, parser} to AVStreamInternal
Anton Khirnov: > Those are private fields, no reason to have them exposed in a public > header. > --- > libavdevice/v4l2.c | 2 +- This is a problem: There is no requirement to update libavdevice at the same time as libavformat; one might use a newer version of libavformat together with an older version of libavdevice. This effectively makes the offsets of all the fields accessed by libavdevice avpriv, regardless of whether they are in AVStream or AVStreamInternal. > libavformat/aacdec.c | 2 +- > libavformat/aadec.c | 6 +- > libavformat/acm.c| 2 +- > libavformat/asfdec_f.c | 10 ++-- > libavformat/av1dec.c | 2 +- > libavformat/avformat.h | 6 +- > libavformat/avidec.c | 16 ++--- > libavformat/dtshddec.c | 2 +- > libavformat/electronicarts.c | 2 +- > libavformat/flacdec.c| 2 +- > libavformat/flvdec.c | 4 +- > libavformat/gxf.c| 6 +- > libavformat/img2dec.c| 4 +- > libavformat/internal.h | 4 ++ > libavformat/ipudec.c | 2 +- > libavformat/iv8.c| 2 +- > libavformat/ivfdec.c | 2 +- > libavformat/lmlm4.c | 4 +- > libavformat/loasdec.c| 2 +- > libavformat/lxfdec.c | 2 +- > libavformat/matroskadec.c| 6 +- > libavformat/mgsts.c | 2 +- > libavformat/mov.c| 18 +++--- > libavformat/mp3dec.c | 2 +- > libavformat/mpeg.c | 2 +- > libavformat/mpegts.c | 14 ++--- > libavformat/msf.c| 2 +- > libavformat/mtv.c| 2 +- > libavformat/mxfdec.c | 8 +-- > libavformat/ncdec.c | 2 +- > libavformat/nsvdec.c | 4 +- > libavformat/nuv.c| 2 +- > libavformat/oggparseflac.c | 2 +- > libavformat/oggparseogm.c| 4 +- > libavformat/oggparsetheora.c | 2 +- > libavformat/oggparsevp8.c| 2 +- > libavformat/omadec.c | 2 +- > libavformat/pva.c| 4 +- > libavformat/rawdec.c | 4 +- > libavformat/rmdec.c | 8 +-- > libavformat/rtpdec_asf.c | 4 +- > libavformat/rtsp.c | 2 +- > libavformat/sdr2.c | 2 +- > libavformat/segafilm.c | 2 +- > libavformat/swfdec.c | 2 +- > libavformat/takdec.c | 2 +- > libavformat/ty.c | 4 +- > libavformat/utils.c | 112 +-- > libavformat/wavdec.c | 6 +- > libavformat/wtvdec.c | 2 +- > libavformat/xvag.c | 2 +- > libavformat/xwma.c | 2 +- > 53 files changed, 160 insertions(+), 158 deletions(-) > > diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c > index 365bacd771..960929aec3 100644 > --- a/libavdevice/v4l2.c > +++ b/libavdevice/v4l2.c > @@ -961,7 +961,7 @@ static int v4l2_read_header(AVFormatContext *ctx) > st->codecpar->codec_tag = > avcodec_pix_fmt_to_codec_tag(st->codecpar->format); > else if (codec_id == AV_CODEC_ID_H264) { > -st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; > +st->internal->need_parsing = AVSTREAM_PARSE_FULL_ONCE; > } > if (desired_format == V4L2_PIX_FMT_YVU420) > st->codecpar->codec_tag = MKTAG('Y', 'V', '1', '2'); > diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c > index a0aa112a8a..70427e222b 100644 > --- a/libavformat/aacdec.c > +++ b/libavformat/aacdec.c > @@ -112,7 +112,7 @@ static int adts_aac_read_header(AVFormatContext *s) > > st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; > st->codecpar->codec_id = s->iformat->raw_codec_id; > -st->need_parsing = AVSTREAM_PARSE_FULL_RAW; > +st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW; > > ff_id3v1_read(s); > if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && > diff --git a/libavformat/aadec.c b/libavformat/aadec.c > index 63f8176a57..7ada6ab07a 100644 > --- a/libavformat/aadec.c > +++ b/libavformat/aadec.c > @@ -182,7 +182,7 @@ static int aa_read_header(AVFormatContext *s) > if (!strcmp(codec_name, "mp332")) { > st->codecpar->codec_id = AV_CODEC_ID_MP3; > st->codecpar->sample_rate = 22050; > -st->need_parsing = AVSTREAM_PARSE_FULL_RAW; > +st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW; > avpriv_set_pts_info(st, 64, 8, 32000 * TIMEPREC); > // encoded audio frame is MP3_FRAME_SIZE bytes (+1 with padding, > unlikely) > } else if (!strcmp(codec_name, "acelp85")) { > @@ -191,7 +191,7 @@ static int aa_read_header(AVFormatContext *s) > st->codecpar->channels = 1; > st->codecpar->sample_rate = 8500; > st->codecpar->bit_rate = 8500; > -st->need_parsing = AVSTREAM_PARSE_FULL_RAW; > +st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW; > avpriv_set_pts_info(st, 64, 8, 8500 * TIMEPREC); > } else if (!strcmp(codec_name,
[FFmpeg-devel] [PATCH 16/18] lavf: move AVStream.{probe_packets, codec_info_nb_frames} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 12 ++--- libavformat/dump.c | 3 ++- libavformat/internal.h | 10 +++ libavformat/mpegts.c | 2 +- libavformat/sbgdec.c | 2 +- libavformat/tedcaptionsdec.c | 2 +- libavformat/utils.c | 46 libavformat/wavdec.c | 2 +- tests/api/api-codec-param-test.c | 5 ++-- 9 files changed, 44 insertions(+), 40 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index b1aab0c8ea..6168062ce1 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1043,18 +1043,10 @@ typedef struct AVStream { int64_t last_IP_pts; int last_IP_duration; -/** - * Number of packets to buffer for codec probing - */ -int probe_packets; - -/** - * Number of frames that have been demuxed during avformat_find_stream_info() - */ -int codec_info_nb_frames; - #if LIBAVFORMAT_VERSION_MAJOR < 59 // kept for ABI compatibility only, do not access in any way +int unused10; +int unused11; int unused8; void*unused9; void*unused7; diff --git a/libavformat/dump.c b/libavformat/dump.c index fe628010d3..0554bf667d 100644 --- a/libavformat/dump.c +++ b/libavformat/dump.c @@ -37,6 +37,7 @@ #include "libavutil/timecode.h" #include "avformat.h" +#include "internal.h" #define HEXDUMP_PRINT(...)\ do { \ @@ -551,7 +552,7 @@ FF_ENABLE_DEPRECATION_WARNINGS av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id); if (lang) av_log(NULL, AV_LOG_INFO, "(%s)", lang->value); -av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames, +av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->internal->codec_info_nb_frames, st->time_base.num, st->time_base.den); av_log(NULL, AV_LOG_INFO, ": %s", buf); diff --git a/libavformat/internal.h b/libavformat/internal.h index 496bd46ef0..edc8bbae80 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -347,6 +347,16 @@ struct AVStreamInternal { /* av_read_frame() support */ enum AVStreamParseType need_parsing; struct AVCodecParserContext *parser; + +/** + * Number of packets to buffer for codec probing + */ +int probe_packets; + +/** + * Number of frames that have been demuxed during avformat_find_stream_info() + */ +int codec_info_nb_frames; }; #ifdef __GNUC__ diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 6135d05477..86f943375a 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -953,7 +953,7 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes, } if ((st->codecpar->codec_id == AV_CODEC_ID_NONE || (st->internal->request_probe > 0 && st->internal->request_probe < AVPROBE_SCORE_STREAM_RETRY / 5)) && -st->probe_packets > 0 && +st->internal->probe_packets > 0 && stream_type == STREAM_TYPE_PRIVATE_DATA) { st->codecpar->codec_type = AVMEDIA_TYPE_DATA; st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA; diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c index c11244ef3d..d8efb9d9fb 100644 --- a/libavformat/sbgdec.c +++ b/libavformat/sbgdec.c @@ -1423,7 +1423,7 @@ static av_cold int sbg_read_header(AVFormatContext *avf) st->codecpar->sample_rate= sbg->sample_rate; st->codecpar->frame_size = sbg->frame_size; avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); -st->probe_packets = 0; +st->internal->probe_packets = 0; st->start_time= av_rescale(script.start_ts, sbg->sample_rate, AV_TIME_BASE); st->duration = script.end_ts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE : diff --git a/libavformat/tedcaptionsdec.c b/libavformat/tedcaptionsdec.c index 6c25d602d6..9ccb1f886d 100644 --- a/libavformat/tedcaptionsdec.c +++ b/libavformat/tedcaptionsdec.c @@ -297,7 +297,7 @@ static av_cold int tedcaptions_read_header(AVFormatContext *avf) st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; st->codecpar->codec_id = AV_CODEC_ID_TEXT; avpriv_set_pts_info(st, 64, 1, 1000); -st->probe_packets = 0; +st->internal->probe_packets = 0; st->start_time= 0; st->duration = last->pts + last->duration; st->cur_dts = 0; diff --git a/libavformat/utils.c b/libavformat/utils.c index 4d281a9ce8..c0ba07d288 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -358,7 +358,7 @@ static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st, int i; av_log(s, AV_LOG_DEBUG, "Probe with size=%d, packets=%d detected %s with score=%d\n", -
[FFmpeg-devel] [PATCH 08/18] lavf: move AVStream.{request_probe, skip_to_keyframe} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/asfdec_f.c| 2 +- libavformat/avformat.h| 13 - libavformat/avidec.c | 2 +- libavformat/internal.h| 13 + libavformat/matroskadec.c | 8 libavformat/mpeg.c| 2 +- libavformat/mpegts.c | 26 +- libavformat/utils.c | 24 libavformat/wavdec.c | 2 +- 9 files changed, 46 insertions(+), 46 deletions(-) diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index 103155e9e7..b92434db9e 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -479,7 +479,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) if (is_dvr_ms_audio) { // codec_id and codec_tag are unreliable in dvr_ms // files. Set them later by probing stream. -st->request_probe= 1; +st->internal->request_probe= 1; st->codecpar->codec_tag = 0; } if (st->codecpar->codec_id == AV_CODEC_ID_AAC) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8028b1b558..ed0ed0d3e1 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1087,19 +1087,6 @@ typedef struct AVStream { int64_t interleaver_chunk_size; int64_t interleaver_chunk_duration; -/** - * stream probing state - * -1 -> probing finished - * 0 -> no probing requested - * rest -> perform probing with request_probe being the minimum score to accept. - */ -int request_probe; -/** - * Indicates that everything up to the next keyframe - * should be discarded. - */ -int skip_to_keyframe; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 9765e5e7b2..89a9443821 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -901,7 +901,7 @@ static int avi_read_header(AVFormatContext *s) break; case AVMEDIA_TYPE_SUBTITLE: st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE; -st->request_probe= 1; +st->internal->request_probe= 1; avio_skip(pb, size); break; default: diff --git a/libavformat/internal.h b/libavformat/internal.h index 12105aa7d0..d8ceebb26e 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -225,6 +225,19 @@ struct AVStreamInternal { } *info; +/** + * stream probing state + * -1 -> probing finished + * 0 -> no probing requested + * rest -> perform probing with request_probe being the minimum score to accept. + */ +int request_probe; +/** + * Indicates that everything up to the next keyframe + * should be discarded. + */ +int skip_to_keyframe; + /** * Number of samples to skip at the start of the frame decoded from the next packet. */ diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 545559423c..a183026359 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -3597,7 +3597,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, AVBufferRef *buf return res; if (is_keyframe) matroska->skip_to_keyframe = 0; -else if (!st->skip_to_keyframe) { +else if (!st->internal->skip_to_keyframe) { av_log(matroska->ctx, AV_LOG_ERROR, "File is broken, keyframes not correctly marked!\n"); matroska->skip_to_keyframe = 0; } @@ -3794,10 +3794,10 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index, /* We seek to a level 1 element, so set the appropriate status. */ matroska_reset_status(matroska, 0, st->index_entries[index].pos); if (flags & AVSEEK_FLAG_ANY) { -st->skip_to_keyframe = 0; +st->internal->skip_to_keyframe = 0; matroska->skip_to_timecode = timestamp; } else { -st->skip_to_keyframe = 1; +st->internal->skip_to_keyframe = 1; matroska->skip_to_timecode = st->index_entries[index].timestamp; } matroska->skip_to_keyframe = 1; @@ -3810,7 +3810,7 @@ err: matroska_reset_status(matroska, 0, -1); matroska->resync_pos = -1; matroska_clear_queue(matroska); -st->skip_to_keyframe = +st->internal->skip_to_keyframe = matroska->skip_to_keyframe = 0; matroska->done = 0; return -1; diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index a5e17925ce..20d1e10168 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -622,7 +622,7 @@ skip: st->codecpar->channel_layout = AV_CH_LAYOUT_MONO; st->codecpar->sample_rate = 8000; } -st->request_probe = request_probe; +st->internal->request_probe
[FFmpeg-devel] [PATCH 12/18] lavf: move AVStream.probe_data to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 2 +- libavformat/internal.h | 2 ++ libavformat/utils.c| 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index ef6d673699..c99449e121 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1061,10 +1061,10 @@ typedef struct AVStream { * last packet in packet_buffer for this stream when muxing. */ struct AVPacketList *last_in_packet_buffer; -AVProbeData probe_data; #if LIBAVFORMAT_VERSION_MAJOR < 59 // kept for ABI compatibility only, do not access in any way +AVProbeData unused6; int64_t unused5[16+1]; void *unused2; int unused3; diff --git a/libavformat/internal.h b/libavformat/internal.h index 23c2ce0dc3..b8e662b96e 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -336,6 +336,8 @@ struct AVStreamInternal { * - decoding: Set by libavformat to calculate sample_aspect_ratio internally */ AVRational display_aspect_ratio; + +AVProbeData probe_data; }; #ifdef __GNUC__ diff --git a/libavformat/utils.c b/libavformat/utils.c index 6cba0cce8f..27b7b62b1a 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -676,7 +676,7 @@ static void force_codec_ids(AVFormatContext *s, AVStream *st) static int probe_codec(AVFormatContext *s, AVStream *st, const AVPacket *pkt) { if (st->internal->request_probe>0) { -AVProbeData *pd = >probe_data; +AVProbeData *pd = >internal->probe_data; int end; av_log(s, AV_LOG_DEBUG, "probing stream %d pp:%d\n", st->index, st->probe_packets); --st->probe_packets; @@ -4342,6 +4342,8 @@ static void free_stream(AVStream **pst) av_bsf_free(>internal->bsfc); av_freep(>internal->priv_pts); av_freep(>internal->index_entries); +av_freep(>internal->probe_data.buf); + av_bsf_free(>internal->extract_extradata.bsf); av_packet_free(>internal->extract_extradata.pkt); @@ -4353,7 +4355,6 @@ static void free_stream(AVStream **pst) av_dict_free(>metadata); avcodec_parameters_free(>codecpar); -av_freep(>probe_data.buf); #if FF_API_LAVF_AVCTX FF_DISABLE_DEPRECATION_WARNINGS avcodec_free_context(>codec); -- 2.28.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 07/18] lavf: move AVStream.{*skip_samples.*_discard_sample} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 29 - libavformat/internal.h | 29 + libavformat/mov.c | 12 ++-- libavformat/mp3dec.c | 8 libavformat/swfdec.c | 2 +- libavformat/utils.c| 26 +- 6 files changed, 53 insertions(+), 53 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 977680ec83..8028b1b558 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1100,35 +1100,6 @@ typedef struct AVStream { */ int skip_to_keyframe; -/** - * Number of samples to skip at the start of the frame decoded from the next packet. - */ -int skip_samples; - -/** - * If not 0, the number of samples that should be skipped from the start of - * the stream (the samples are removed from packets with pts==0, which also - * assumes negative timestamps do not happen). - * Intended for use with formats such as mp3 with ad-hoc gapless audio - * support. - */ -int64_t start_skip_samples; - -/** - * If not 0, the first audio sample that should be discarded from the stream. - * This is broken by design (needs global sample count), but can't be - * avoided for broken by design formats such as mp3 with ad-hoc gapless - * audio support. - */ -int64_t first_discard_sample; - -/** - * The sample after last sample that is intended to be discarded after - * first_discard_sample. Works on frame boundaries only. Used to prevent - * early EOF if the gapless info is broken (considered concatenated mp3s). - */ -int64_t last_discard_sample; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/internal.h b/libavformat/internal.h index b1112fe463..12105aa7d0 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -225,6 +225,35 @@ struct AVStreamInternal { } *info; +/** + * Number of samples to skip at the start of the frame decoded from the next packet. + */ +int skip_samples; + +/** + * If not 0, the number of samples that should be skipped from the start of + * the stream (the samples are removed from packets with pts==0, which also + * assumes negative timestamps do not happen). + * Intended for use with formats such as mp3 with ad-hoc gapless audio + * support. + */ +int64_t start_skip_samples; + +/** + * If not 0, the first audio sample that should be discarded from the stream. + * This is broken by design (needs global sample count), but can't be + * avoided for broken by design formats such as mp3 with ad-hoc gapless + * audio support. + */ +int64_t first_discard_sample; + +/** + * The sample after last sample that is intended to be discarded after + * first_discard_sample. Works on frame boundaries only. Used to prevent + * early EOF if the gapless info is broken (considered concatenated mp3s). + */ +int64_t last_discard_sample; + /** * Number of internally decoded frames, used internally in libavformat, do not access * its lifetime differs from info which is why it is not in that structure. diff --git a/libavformat/mov.c b/libavformat/mov.c index 82fd1d74f6..6103678cdb 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3550,7 +3550,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) } if (first_non_zero_audio_edit > 0) -st->skip_samples = msc->start_pad = 0; +st->internal->skip_samples = msc->start_pad = 0; } // While reordering frame index according to edit list we must handle properly @@ -3625,7 +3625,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) curr_cts < edit_list_media_time && curr_cts + frame_duration > edit_list_media_time && first_non_zero_audio_edit > 0) { packet_skip_samples = edit_list_media_time - curr_cts; -st->skip_samples += packet_skip_samples; +st->internal->skip_samples += packet_skip_samples; // Shift the index entry timestamp by packet_skip_samples to be correct. edit_list_dts_counter -= packet_skip_samples; @@ -3658,7 +3658,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) // Increment skip_samples for the first non-zero audio edit list if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && first_non_zero_audio_edit > 0 && st->codecpar->codec_id != AV_CODEC_ID_VORBIS) { -st->skip_samples += frame_duration; +st->internal->skip_samples += frame_duration;
[FFmpeg-devel] [PATCH 11/18] lavf: move AVStream.pts_buffer to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 3 +-- libavformat/internal.h | 4 libavformat/mux.c | 12 ++-- libavformat/utils.c| 14 +++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index dbef1b21dd..ef6d673699 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1062,11 +1062,10 @@ typedef struct AVStream { */ struct AVPacketList *last_in_packet_buffer; AVProbeData probe_data; -#define MAX_REORDER_DELAY 16 -int64_t pts_buffer[MAX_REORDER_DELAY+1]; #if LIBAVFORMAT_VERSION_MAJOR < 59 // kept for ABI compatibility only, do not access in any way +int64_t unused5[16+1]; void *unused2; int unused3; unsigned int unused4; diff --git a/libavformat/internal.h b/libavformat/internal.h index ce79da8000..23c2ce0dc3 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -308,12 +308,16 @@ struct AVStreamInternal { */ int update_initial_durations_done; +#define MAX_REORDER_DELAY 16 + /** * Internal data to generate dts from pts */ int64_t pts_reorder_error[MAX_REORDER_DELAY+1]; uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]; +int64_t pts_buffer[MAX_REORDER_DELAY+1]; + /** * Internal data to analyze DTS and detect faulty mpeg streams */ diff --git a/libavformat/mux.c b/libavformat/mux.c index 1cf885fbea..1a34ee7e96 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -595,13 +595,13 @@ static int compute_muxer_pkt_fields(AVFormatContext *s, AVStream *st, AVPacket * //calculate dts from pts if (pkt->pts != AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) { -st->pts_buffer[0] = pkt->pts; -for (i = 1; i < delay + 1 && st->pts_buffer[i] == AV_NOPTS_VALUE; i++) -st->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration; -for (i = 0; ipts_buffer[i] > st->pts_buffer[i + 1]; i++) -FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]); +st->internal->pts_buffer[0] = pkt->pts; +for (i = 1; i < delay + 1 && st->internal->pts_buffer[i] == AV_NOPTS_VALUE; i++) +st->internal->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration; +for (i = 0; iinternal->pts_buffer[i] > st->internal->pts_buffer[i + 1]; i++) +FFSWAP(int64_t, st->internal->pts_buffer[i], st->internal->pts_buffer[i + 1]); -pkt->dts = st->pts_buffer[0]; +pkt->dts = st->internal->pts_buffer[0]; } if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE && diff --git a/libavformat/utils.c b/libavformat/utils.c index 1e53cae103..6cba0cce8f 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1358,12 +1358,12 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, } if (pkt->pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) { -st->pts_buffer[0] = pkt->pts; -for (i = 0; ipts_buffer[i] > st->pts_buffer[i + 1]; i++) -FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]); +st->internal->pts_buffer[0] = pkt->pts; +for (i = 0; iinternal->pts_buffer[i] > st->internal->pts_buffer[i + 1]; i++) +FFSWAP(int64_t, st->internal->pts_buffer[i], st->internal->pts_buffer[i + 1]); if(has_decode_delay_been_guessed(st)) -pkt->dts = select_from_pts_buffer(st, st->pts_buffer, pkt->dts); +pkt->dts = select_from_pts_buffer(st, st->internal->pts_buffer, pkt->dts); } // We skipped it above so we try here. if (!onein_oneout) @@ -1885,7 +1885,7 @@ void ff_read_frame_flush(AVFormatContext *s) st->probe_packets = s->max_probe_packets; for (j = 0; j < MAX_REORDER_DELAY + 1; j++) -st->pts_buffer[j] = AV_NOPTS_VALUE; +st->internal->pts_buffer[j] = AV_NOPTS_VALUE; if (s->internal->inject_global_side_data) st->internal->inject_global_side_data = 1; @@ -2866,7 +2866,7 @@ skip_duration_calc: st->last_IP_pts = AV_NOPTS_VALUE; st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; for (j = 0; j < MAX_REORDER_DELAY + 1; j++) -st->pts_buffer[j] = AV_NOPTS_VALUE; +st->internal->pts_buffer[j] = AV_NOPTS_VALUE; } } @@ -4525,7 +4525,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st->last_IP_pts = AV_NOPTS_VALUE; st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; for (i = 0; i < MAX_REORDER_DELAY + 1; i++) -st->pts_buffer[i] = AV_NOPTS_VALUE; +st->internal->pts_buffer[i] = AV_NOPTS_VALUE; st->sample_aspect_ratio = (AVRational) { 0, 1 }; -- 2.28.0 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To
[FFmpeg-devel] [PATCH 01/18] lavf: move AVStream.info to AVStreamInternal
This struct is for internal use of avformat_find_stream_info(), so it should not be exposed in public headers. Keep a stub pointer in its place to avoid changing AVStream layout, since e.g. ffmpeg.c accesses some fields located after it (even though they are marked as private). --- libavformat/avformat.h | 36 +-- libavformat/internal.h | 33 ++ libavformat/utils.c| 228 - 3 files changed, 151 insertions(+), 146 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index c8c0b6c08d..8eff5b8eaa 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1023,38 +1023,10 @@ typedef struct AVStream { * */ -#define MAX_STD_TIMEBASES (30*12+30+3+6) -/** - * Stream information used internally by avformat_find_stream_info() - */ -struct { -int64_t last_dts; -int64_t duration_gcd; -int duration_count; -int64_t rfps_duration_sum; -double (*duration_error)[2][MAX_STD_TIMEBASES]; -int64_t codec_info_duration; -int64_t codec_info_duration_fields; -int frame_delay_evidence; - -/** - * 0 -> decoder has not been searched for yet. - * >0 -> decoder found - * <0 -> decoder with codec_id == -found_decoder has not been found - */ -int found_decoder; - -int64_t last_duration; - -/** - * Those are used for average framerate estimation. - */ -int64_t fps_first_dts; -int fps_first_dts_idx; -int64_t fps_last_dts; -int fps_last_dts_idx; - -} *info; +#if LIBAVFORMAT_VERSION_MAJOR < 59 +// kept for ABI compatibility only, do not access in any way +void *unused; +#endif int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ diff --git a/libavformat/internal.h b/libavformat/internal.h index f4174628e0..30b4df9181 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -191,6 +191,39 @@ struct AVStreamInternal { int is_intra_only; FFFrac *priv_pts; + +#define MAX_STD_TIMEBASES (30*12+30+3+6) +/** + * Stream information used internally by avformat_find_stream_info() + */ +struct { +int64_t last_dts; +int64_t duration_gcd; +int duration_count; +int64_t rfps_duration_sum; +double (*duration_error)[2][MAX_STD_TIMEBASES]; +int64_t codec_info_duration; +int64_t codec_info_duration_fields; +int frame_delay_evidence; + +/** + * 0 -> decoder has not been searched for yet. + * >0 -> decoder found + * <0 -> decoder with codec_id == -found_decoder has not been found + */ +int found_decoder; + +int64_t last_duration; + +/** + * Those are used for average framerate estimation. + */ +int64_t fps_first_dts; +int fps_first_dts_idx; +int64_t fps_last_dts; +int fps_last_dts_idx; + +} *info; }; #ifdef __GNUC__ diff --git a/libavformat/utils.c b/libavformat/utils.c index a2e701ea1a..a13f31dccf 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -992,7 +992,7 @@ int ff_is_intra_only(enum AVCodecID id) static int has_decode_delay_been_guessed(AVStream *st) { if (st->codecpar->codec_id != AV_CODEC_ID_H264) return 1; -if (!st->info) // if we have left find_stream_info then nb_decoded_frames won't increase anymore for stream copy +if (!st->internal->info) // if we have left find_stream_info then nb_decoded_frames won't increase anymore for stream copy return 1; #if CONFIG_H264_DECODER if (st->internal->avctx->has_b_frames && @@ -1539,7 +1539,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) if (avcodec_is_open(st->internal->avctx)) { av_log(s, AV_LOG_DEBUG, "Demuxer context update while decoder is open, closing and trying to re-open\n"); avcodec_close(st->internal->avctx); -st->info->found_decoder = 0; +st->internal->info->found_decoder = 0; } /* close parser, because it depends on the codec */ @@ -2812,10 +2812,10 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) else duration -= st->first_dts; if (duration > 0) { -if (st->duration == AV_NOPTS_VALUE || st->info->last_duration<= 0 || -(st->duration < duration && FFABS(duration - st->info->last_duration) < 60LL*st->time_base.den / st->time_base.num)) +if (st->duration == AV_NOPTS_VALUE || st->internal->info->last_duration<= 0 || +(st->duration < duration && FFABS(duration - st->internal->info->last_duration) < 60LL*st->time_base.den /
[FFmpeg-devel] [PATCH 14/18] lavf: move AVStream.{need_parsing, parser} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavdevice/v4l2.c | 2 +- libavformat/aacdec.c | 2 +- libavformat/aadec.c | 6 +- libavformat/acm.c| 2 +- libavformat/asfdec_f.c | 10 ++-- libavformat/av1dec.c | 2 +- libavformat/avformat.h | 6 +- libavformat/avidec.c | 16 ++--- libavformat/dtshddec.c | 2 +- libavformat/electronicarts.c | 2 +- libavformat/flacdec.c| 2 +- libavformat/flvdec.c | 4 +- libavformat/gxf.c| 6 +- libavformat/img2dec.c| 4 +- libavformat/internal.h | 4 ++ libavformat/ipudec.c | 2 +- libavformat/iv8.c| 2 +- libavformat/ivfdec.c | 2 +- libavformat/lmlm4.c | 4 +- libavformat/loasdec.c| 2 +- libavformat/lxfdec.c | 2 +- libavformat/matroskadec.c| 6 +- libavformat/mgsts.c | 2 +- libavformat/mov.c| 18 +++--- libavformat/mp3dec.c | 2 +- libavformat/mpeg.c | 2 +- libavformat/mpegts.c | 14 ++--- libavformat/msf.c| 2 +- libavformat/mtv.c| 2 +- libavformat/mxfdec.c | 8 +-- libavformat/ncdec.c | 2 +- libavformat/nsvdec.c | 4 +- libavformat/nuv.c| 2 +- libavformat/oggparseflac.c | 2 +- libavformat/oggparseogm.c| 4 +- libavformat/oggparsetheora.c | 2 +- libavformat/oggparsevp8.c| 2 +- libavformat/omadec.c | 2 +- libavformat/pva.c| 4 +- libavformat/rawdec.c | 4 +- libavformat/rmdec.c | 8 +-- libavformat/rtpdec_asf.c | 4 +- libavformat/rtsp.c | 2 +- libavformat/sdr2.c | 2 +- libavformat/segafilm.c | 2 +- libavformat/swfdec.c | 2 +- libavformat/takdec.c | 2 +- libavformat/ty.c | 4 +- libavformat/utils.c | 112 +-- libavformat/wavdec.c | 6 +- libavformat/wtvdec.c | 2 +- libavformat/xvag.c | 2 +- libavformat/xwma.c | 2 +- 53 files changed, 160 insertions(+), 158 deletions(-) diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 365bacd771..960929aec3 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -961,7 +961,7 @@ static int v4l2_read_header(AVFormatContext *ctx) st->codecpar->codec_tag = avcodec_pix_fmt_to_codec_tag(st->codecpar->format); else if (codec_id == AV_CODEC_ID_H264) { -st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; +st->internal->need_parsing = AVSTREAM_PARSE_FULL_ONCE; } if (desired_format == V4L2_PIX_FMT_YVU420) st->codecpar->codec_tag = MKTAG('Y', 'V', '1', '2'); diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c index a0aa112a8a..70427e222b 100644 --- a/libavformat/aacdec.c +++ b/libavformat/aacdec.c @@ -112,7 +112,7 @@ static int adts_aac_read_header(AVFormatContext *s) st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_id = s->iformat->raw_codec_id; -st->need_parsing = AVSTREAM_PARSE_FULL_RAW; +st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW; ff_id3v1_read(s); if ((s->pb->seekable & AVIO_SEEKABLE_NORMAL) && diff --git a/libavformat/aadec.c b/libavformat/aadec.c index 63f8176a57..7ada6ab07a 100644 --- a/libavformat/aadec.c +++ b/libavformat/aadec.c @@ -182,7 +182,7 @@ static int aa_read_header(AVFormatContext *s) if (!strcmp(codec_name, "mp332")) { st->codecpar->codec_id = AV_CODEC_ID_MP3; st->codecpar->sample_rate = 22050; -st->need_parsing = AVSTREAM_PARSE_FULL_RAW; +st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW; avpriv_set_pts_info(st, 64, 8, 32000 * TIMEPREC); // encoded audio frame is MP3_FRAME_SIZE bytes (+1 with padding, unlikely) } else if (!strcmp(codec_name, "acelp85")) { @@ -191,7 +191,7 @@ static int aa_read_header(AVFormatContext *s) st->codecpar->channels = 1; st->codecpar->sample_rate = 8500; st->codecpar->bit_rate = 8500; -st->need_parsing = AVSTREAM_PARSE_FULL_RAW; +st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW; avpriv_set_pts_info(st, 64, 8, 8500 * TIMEPREC); } else if (!strcmp(codec_name, "acelp16")) { st->codecpar->codec_id = AV_CODEC_ID_SIPR; @@ -199,7 +199,7 @@ static int aa_read_header(AVFormatContext *s) st->codecpar->channels = 1; st->codecpar->sample_rate = 16000; st->codecpar->bit_rate = 16000; -st->need_parsing = AVSTREAM_PARSE_FULL_RAW; +st->internal->need_parsing = AVSTREAM_PARSE_FULL_RAW; avpriv_set_pts_info(st, 64, 8, 16000 * TIMEPREC); } diff --git a/libavformat/acm.c b/libavformat/acm.c index 5e03cf8bff..91f14e43aa 100644 --- a/libavformat/acm.c +++ b/libavformat/acm.c
[FFmpeg-devel] [PATCH 10/18] lavf: move AVStream.*index_entries* to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. Since there are some (semi-)public fields located after these, even though this section is supposed to be private, keep some dummy padding there until the next major bump to preserve ABI compatibility. --- libavformat/ape.c | 2 +- libavformat/asfdec_f.c| 4 +- libavformat/asfdec_o.c| 6 +- libavformat/avformat.h| 10 +- libavformat/avidec.c | 100 ++-- libavformat/bink.c| 10 +- libavformat/cafdec.c | 22 ++--- libavformat/cinedec.c | 2 +- libavformat/dhav.c| 4 +- libavformat/flacdec.c | 8 +- libavformat/flic.c| 6 +- libavformat/flvdec.c | 10 +- libavformat/gxf.c | 6 +- libavformat/ifv.c | 8 +- libavformat/img2dec.c | 2 +- libavformat/internal.h| 5 + libavformat/jvdec.c | 28 +++--- libavformat/matroskadec.c | 40 libavformat/mlvdec.c | 20 ++-- libavformat/mov.c | 190 +++--- libavformat/mp3dec.c | 6 +- libavformat/mpc.c | 4 +- libavformat/mpc8.c| 4 +- libavformat/mux.c | 2 +- libavformat/mvdec.c | 4 +- libavformat/nsvdec.c | 4 +- libavformat/nutdec.c | 6 +- libavformat/nutenc.c | 12 +-- libavformat/rl2.c | 8 +- libavformat/rpl.c | 4 +- libavformat/segafilm.c| 2 +- libavformat/tta.c | 8 +- libavformat/utils.c | 46 - libavformat/vocdec.c | 8 +- 34 files changed, 304 insertions(+), 297 deletions(-) diff --git a/libavformat/ape.c b/libavformat/ape.c index d92cb2867d..33b7237fb0 100644 --- a/libavformat/ape.c +++ b/libavformat/ape.c @@ -469,7 +469,7 @@ static int ape_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp if (index < 0) return -1; -if ((ret = avio_seek(s->pb, st->index_entries[index].pos, SEEK_SET)) < 0) +if ((ret = avio_seek(s->pb, st->internal->index_entries[index].pos, SEEK_SET)) < 0) return ret; ape->currentframe = index; return 0; diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index b92434db9e..deb7c266ed 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -1678,11 +1678,11 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, asf->index_read = -1; } -if (asf->index_read > 0 && st->index_entries) { +if (asf->index_read > 0 && st->internal->index_entries) { int index = av_index_search_timestamp(st, pts, flags); if (index >= 0) { /* find the position */ -uint64_t pos = st->index_entries[index].pos; +uint64_t pos = st->internal->index_entries[index].pos; /* do the seek */ av_log(s, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos); diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c index 1b10e47907..b142f83541 100644 --- a/libavformat/asfdec_o.c +++ b/libavformat/asfdec_o.c @@ -1640,11 +1640,11 @@ static int asf_read_seek(AVFormatContext *s, int stream_index, ASFContext *asf = s->priv_data; int idx, ret; -if (s->streams[stream_index]->nb_index_entries && asf->is_simple_index) { +if (s->streams[stream_index]->internal->nb_index_entries && asf->is_simple_index) { idx = av_index_search_timestamp(s->streams[stream_index], timestamp, flags); -if (idx < 0 || idx >= s->streams[stream_index]->nb_index_entries) +if (idx < 0 || idx >= s->streams[stream_index]->internal->nb_index_entries) return AVERROR_INVALIDDATA; -avio_seek(s->pb, s->streams[stream_index]->index_entries[idx].pos, SEEK_SET); +avio_seek(s->pb, s->streams[stream_index]->internal->index_entries[idx].pos, SEEK_SET); } else { if ((ret = ff_seek_frame_binary(s, stream_index, timestamp, flags)) < 0) return ret; diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 1253021452..dbef1b21dd 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1065,10 +1065,12 @@ typedef struct AVStream { #define MAX_REORDER_DELAY 16 int64_t pts_buffer[MAX_REORDER_DELAY+1]; -AVIndexEntry *index_entries; /**< Only used if the format does not -support seeking natively. */ -int nb_index_entries; -unsigned int index_entries_allocated_size; +#if LIBAVFORMAT_VERSION_MAJOR < 59 +// kept for ABI compatibility only, do not access in any way +void *unused2; +int unused3; +unsigned int unused4; +#endif /** * Stream Identifier diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 89a9443821..80e5563bc6 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -272,7 +272,7 @@ static void clean_index(AVFormatContext *s) for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i];
[FFmpeg-devel] [PATCH 15/18] ffmpeg: stop using non-public AVStream fields
This effectively reverts ae2cb9290ac and 52c5521877a. --- fftools/ffmpeg_opt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 19f719e3ff..a5c92bf461 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -2215,7 +2215,7 @@ static int open_output_file(OptionsContext *o, const char *filename) for (i = 0; i < nb_input_streams; i++) { int new_area; ist = input_streams[i]; -new_area = ist->st->codecpar->width * ist->st->codecpar->height + 1*!!ist->st->codec_info_nb_frames +new_area = ist->st->codecpar->width * ist->st->codecpar->height + 500*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); if (ist->user_set_discard == AVDISCARD_ALL) continue; @@ -2239,7 +2239,7 @@ static int open_output_file(OptionsContext *o, const char *filename) for (i = 0; i < nb_input_streams; i++) { int score; ist = input_streams[i]; -score = ist->st->codecpar->channels + 1*!!ist->st->codec_info_nb_frames +score = ist->st->codecpar->channels + 500*!!(ist->st->disposition & AV_DISPOSITION_DEFAULT); if (ist->user_set_discard == AVDISCARD_ALL) continue; -- 2.28.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 18/18] lavf: document some AVStream fields as private
Specifically: pts_wrap_bits, first_dts, cur_dts. They are supposed to be private and are located in the private section of AVStream, but ffmpeg.c currently accesses them regardless. They should be moved to AVStreamInternal once that bug is fixed. Remove the marker for the private AVStream section, as there are no other accessible fields left there. It has proven highly confusing and people kept adding supposedly-public fields into the private section. New private per-stream fields should be added to AVStreamInternal. --- libavformat/avformat.h | 20 +--- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index a01912d654..612791a2eb 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1013,22 +1013,16 @@ typedef struct AVStream { */ AVCodecParameters *codecpar; -/* - * All fields below this line are not part of the public API. They - * may not be used outside of libavformat and can be changed and - * removed at will. - * Internal note: be aware that physically removing these fields - * will break ABI. Replace removed fields with dummy fields, and - * add new fields to AVStreamInternal. - * - */ - #if LIBAVFORMAT_VERSION_MAJOR < 59 // kept for ABI compatibility only, do not access in any way void *unused; #endif -int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ +/** + * number of bits in pts (used for wrapping control) + * private, do not access from outside libavformat. + */ +int pts_wrap_bits; // Timestamp generation support: /** @@ -1037,8 +1031,12 @@ typedef struct AVStream { * Initialized when AVCodecParserContext.dts_sync_point >= 0 and * a DTS is received from the underlying container. Otherwise set to * AV_NOPTS_VALUE by default. + * private, do not access from outside libavformat. */ int64_t first_dts; +/** + * private, do not access from outside libavformat. + */ int64_t cur_dts; #if LIBAVFORMAT_VERSION_MAJOR < 59 -- 2.28.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 13/18] lavf: move AVStream.last_in_packet_buffer to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 6 +- libavformat/internal.h | 5 + libavformat/mux.c | 18 +- libavformat/mxfenc.c | 10 +- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index c99449e121..9c0b25d37b 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1057,13 +1057,9 @@ typedef struct AVStream { enum AVStreamParseType need_parsing; struct AVCodecParserContext *parser; -/** - * last packet in packet_buffer for this stream when muxing. - */ -struct AVPacketList *last_in_packet_buffer; - #if LIBAVFORMAT_VERSION_MAJOR < 59 // kept for ABI compatibility only, do not access in any way +void*unused7; AVProbeData unused6; int64_t unused5[16+1]; void *unused2; diff --git a/libavformat/internal.h b/libavformat/internal.h index b8e662b96e..49e82bfbca 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -338,6 +338,11 @@ struct AVStreamInternal { AVRational display_aspect_ratio; AVProbeData probe_data; + +/** + * last packet in packet_buffer for this stream when muxing. + */ +struct AVPacketList *last_in_packet_buffer; }; #ifdef __GNUC__ diff --git a/libavformat/mux.c b/libavformat/mux.c index 1a34ee7e96..d2a56d216b 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -831,8 +831,8 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, av_packet_move_ref(_pktl->pkt, pkt); pkt = _pktl->pkt; -if (st->last_in_packet_buffer) { -next_point = &(st->last_in_packet_buffer->next); +if (st->internal->last_in_packet_buffer) { +next_point = &(st->internal->last_in_packet_buffer->next); } else { next_point = >internal->packet_buffer; } @@ -876,7 +876,7 @@ next_non_null: this_pktl->next = *next_point; -st->last_in_packet_buffer = *next_point = this_pktl; +st->internal->last_in_packet_buffer = *next_point = this_pktl; return 0; } @@ -926,7 +926,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, } for (i = 0; i < s->nb_streams; i++) { -if (s->streams[i]->last_in_packet_buffer) { +if (s->streams[i]->internal->last_in_packet_buffer) { ++stream_count; } else if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_ATTACHMENT && s->streams[i]->codecpar->codec_id != AV_CODEC_ID_VP8 && @@ -951,7 +951,7 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, for (i = 0; i < s->nb_streams; i++) { int64_t last_dts; -const AVPacketList *last = s->streams[i]->last_in_packet_buffer; +const AVPacketList *last = s->streams[i]->internal->last_in_packet_buffer; if (!last) continue; @@ -1000,8 +1000,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, if (!s->internal->packet_buffer) s->internal->packet_buffer_end = NULL; -if (st->last_in_packet_buffer == pktl) -st->last_in_packet_buffer = NULL; +if (st->internal->last_in_packet_buffer == pktl) +st->internal->last_in_packet_buffer = NULL; av_packet_unref(>pkt); av_freep(); @@ -1019,8 +1019,8 @@ int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, if (!s->internal->packet_buffer) s->internal->packet_buffer_end = NULL; -if (st->last_in_packet_buffer == pktl) -st->last_in_packet_buffer = NULL; +if (st->internal->last_in_packet_buffer == pktl) +st->internal->last_in_packet_buffer = NULL; av_freep(); return 1; diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c index cbb0fc5a6a..d8678c9d25 100644 --- a/libavformat/mxfenc.c +++ b/libavformat/mxfenc.c @@ -3050,7 +3050,7 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket int i, stream_count = 0; for (i = 0; i < s->nb_streams; i++) -stream_count += !!s->streams[i]->last_in_packet_buffer; +stream_count += !!s->streams[i]->internal->last_in_packet_buffer; if (stream_count && (s->nb_streams == stream_count || flush)) { AVPacketList *pktl = s->internal->packet_buffer; @@ -3061,8 +3061,8 @@ static int mxf_interleave_get_packet(AVFormatContext *s, AVPacket *out, AVPacket if (!stream_count || pktl->pkt.stream_index == 0) break; // update last packet in packet buffer -if (s->streams[pktl->pkt.stream_index]->last_in_packet_buffer != pktl) -s->streams[pktl->pkt.stream_index]->last_in_packet_buffer = pktl; +if
[FFmpeg-devel] [PATCH 09/18] lavf: move AVStream.interleaver_chunk_* to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 3 --- libavformat/internal.h | 3 +++ libavformat/mux.c | 16 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index ed0ed0d3e1..1253021452 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1084,9 +1084,6 @@ typedef struct AVStream { int pmt_version; int pmt_stream_idx; -int64_t interleaver_chunk_size; -int64_t interleaver_chunk_duration; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/internal.h b/libavformat/internal.h index d8ceebb26e..87d62c51b2 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -225,6 +225,9 @@ struct AVStreamInternal { } *info; +int64_t interleaver_chunk_size; +int64_t interleaver_chunk_duration; + /** * stream probing state * -1 -> probing finished diff --git a/libavformat/mux.c b/libavformat/mux.c index 8a2d6370f6..8a53f0feeb 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -839,19 +839,19 @@ int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, if (chunked) { uint64_t max= av_rescale_q_rnd(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base, AV_ROUND_UP); -st->interleaver_chunk_size += pkt->size; -st->interleaver_chunk_duration += pkt->duration; -if ( (s->max_chunk_size && st->interleaver_chunk_size > s->max_chunk_size) -|| (max && st->interleaver_chunk_duration > max)) { -st->interleaver_chunk_size = 0; +st->internal->interleaver_chunk_size += pkt->size; +st->internal->interleaver_chunk_duration += pkt->duration; +if ( (s->max_chunk_size && st->internal->interleaver_chunk_size > s->max_chunk_size) +|| (max && st->internal->interleaver_chunk_duration > max)) { +st->internal->interleaver_chunk_size = 0; pkt->flags |= CHUNK_START; -if (max && st->interleaver_chunk_duration > max) { +if (max && st->internal->interleaver_chunk_duration > max) { int64_t syncoffset = (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)*max/2; int64_t syncto = av_rescale(pkt->dts + syncoffset, 1, max)*max - syncoffset; -st->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max; +st->internal->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max; } else -st->interleaver_chunk_duration = 0; +st->internal->interleaver_chunk_duration = 0; } } if (*next_point) { -- 2.28.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 02/18] lavf: move AVStream.{inject_global_side_data, display_aspect_ratio} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 12 libavformat/internal.h | 12 libavformat/mov.c | 4 ++-- libavformat/mxfdec.c | 2 +- libavformat/utils.c| 14 +++--- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 8eff5b8eaa..c93f9d65a6 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1175,18 +1175,6 @@ typedef struct AVStream { uint8_t dts_ordered; uint8_t dts_misordered; -/** - * Internal data to inject global side data - */ -int inject_global_side_data; - -/** - * display aspect ratio (0 if unknown) - * - encoding: unused - * - decoding: Set by libavformat to calculate sample_aspect_ratio internally - */ -AVRational display_aspect_ratio; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/internal.h b/libavformat/internal.h index 30b4df9181..09bab4796d 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -224,6 +224,18 @@ struct AVStreamInternal { int fps_last_dts_idx; } *info; + +/** + * Internal data to inject global side data + */ +int inject_global_side_data; + +/** + * display aspect ratio (0 if unknown) + * - encoding: unused + * - decoding: Set by libavformat to calculate sample_aspect_ratio internally + */ +AVRational display_aspect_ratio; }; #ifdef __GNUC__ diff --git a/libavformat/mov.c b/libavformat/mov.c index 4f64e96bc0..82fd1d74f6 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1767,8 +1767,8 @@ static int mov_read_ares(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; den *= 2; case 1: -c->fc->streams[c->fc->nb_streams-1]->display_aspect_ratio.num = num; -c->fc->streams[c->fc->nb_streams-1]->display_aspect_ratio.den = den; + c->fc->streams[c->fc->nb_streams-1]->internal->display_aspect_ratio.num = num; + c->fc->streams[c->fc->nb_streams-1]->internal->display_aspect_ratio.den = den; default: return 0; } diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index d16a7af0df..1f79f3d3cd 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2586,7 +2586,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) av_dict_set_int(>metadata, "source_track_origin", source_track->sequence->origin, 0); } if (descriptor->aspect_ratio.num && descriptor->aspect_ratio.den) -st->display_aspect_ratio = descriptor->aspect_ratio; +st->internal->display_aspect_ratio = descriptor->aspect_ratio; st->codecpar->color_range = mxf_get_color_range(mxf, descriptor); st->codecpar->color_primaries = mxf_get_codec_ul(ff_mxf_color_primaries_uls, >color_primaries_ul)->id; st->codecpar->color_trc = mxf_get_codec_ul(ff_mxf_color_trc_uls, >color_trc_ul)->id; diff --git a/libavformat/utils.c b/libavformat/utils.c index a13f31dccf..625d8d69f3 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -153,7 +153,7 @@ void av_format_inject_global_side_data(AVFormatContext *s) s->internal->inject_global_side_data = 1; for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; -st->inject_global_side_data = 1; +st->internal->inject_global_side_data = 1; } } @@ -1659,7 +1659,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st->skip_samples = 0; } -if (st->inject_global_side_data) { +if (st->internal->inject_global_side_data) { for (i = 0; i < st->nb_side_data; i++) { AVPacketSideData *src_sd = >side_data[i]; uint8_t *dst_data; @@ -1675,7 +1675,7 @@ FF_ENABLE_DEPRECATION_WARNINGS memcpy(dst_data, src_sd->data, src_sd->size); } -st->inject_global_side_data = 0; +st->internal->inject_global_side_data = 0; } } @@ -1888,7 +1888,7 @@ void ff_read_frame_flush(AVFormatContext *s) st->pts_buffer[j] = AV_NOPTS_VALUE; if (s->internal->inject_global_side_data) -st->inject_global_side_data = 1; +st->internal->inject_global_side_data = 1; st->skip_samples = 0; } @@ -4007,9 +4007,9 @@ FF_ENABLE_DEPRECATION_WARNINGS st->r_frame_rate.den = st->time_base.num; } } -if (st->display_aspect_ratio.num && st->display_aspect_ratio.den) { +if (st->internal->display_aspect_ratio.num && st->internal->display_aspect_ratio.den) { AVRational hw_ratio = { avctx->height,
[FFmpeg-devel] [PATCH 17/18] lavf: move AVStream.last_IP_* to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 4 ++-- libavformat/internal.h | 3 +++ libavformat/nutdec.c | 2 +- libavformat/utils.c| 20 ++-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6168062ce1..a01912d654 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1040,10 +1040,10 @@ typedef struct AVStream { */ int64_t first_dts; int64_t cur_dts; -int64_t last_IP_pts; -int last_IP_duration; #if LIBAVFORMAT_VERSION_MAJOR < 59 +int64_t unused12; +int unused13; // kept for ABI compatibility only, do not access in any way int unused10; int unused11; diff --git a/libavformat/internal.h b/libavformat/internal.h index edc8bbae80..a8c8a10d4b 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -357,6 +357,9 @@ struct AVStreamInternal { * Number of frames that have been demuxed during avformat_find_stream_info() */ int codec_info_nb_frames; + +int64_t last_IP_pts; +int last_IP_duration; }; #ifdef __GNUC__ diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c index 53a052503e..f8c11d270f 100644 --- a/libavformat/nutdec.c +++ b/libavformat/nutdec.c @@ -1086,7 +1086,7 @@ static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code) stc->skip_until_key_frame = 0; discard = s->streams[stream_id]->discard; -last_IP_pts = s->streams[stream_id]->last_IP_pts; +last_IP_pts = s->streams[stream_id]->internal->last_IP_pts; if ((discard >= AVDISCARD_NONKEY && !(stc->last_flags & FLAG_KEY)) || (discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts) || diff --git a/libavformat/utils.c b/libavformat/utils.c index c0ba07d288..8be6400f11 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1316,28 +1316,28 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, /* DTS = decompression timestamp */ /* PTS = presentation timestamp */ if (pkt->dts == AV_NOPTS_VALUE) -pkt->dts = st->last_IP_pts; +pkt->dts = st->internal->last_IP_pts; update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts, pkt); if (pkt->dts == AV_NOPTS_VALUE) pkt->dts = st->cur_dts; /* This is tricky: the dts must be incremented by the duration * of the frame we are displaying, i.e. the last I- or P-frame. */ -if (st->last_IP_duration == 0 && (uint64_t)pkt->duration <= INT32_MAX) -st->last_IP_duration = pkt->duration; +if (st->internal->last_IP_duration == 0 && (uint64_t)pkt->duration <= INT32_MAX) +st->internal->last_IP_duration = pkt->duration; if (pkt->dts != AV_NOPTS_VALUE) -st->cur_dts = av_sat_add64(pkt->dts, st->last_IP_duration); +st->cur_dts = av_sat_add64(pkt->dts, st->internal->last_IP_duration); if (pkt->dts != AV_NOPTS_VALUE && pkt->pts == AV_NOPTS_VALUE && -st->last_IP_duration > 0 && +st->internal->last_IP_duration > 0 && ((uint64_t)st->cur_dts - (uint64_t)next_dts + 1) <= 2 && next_dts != next_pts && next_pts != AV_NOPTS_VALUE) pkt->pts = next_dts; if ((uint64_t)pkt->duration <= INT32_MAX) -st->last_IP_duration = pkt->duration; -st->last_IP_pts = pkt->pts; +st->internal->last_IP_duration = pkt->duration; +st->internal->last_IP_pts = pkt->pts; /* Cannot compute PTS if not present (we can compute it only * by knowing the future. */ } else if (pkt->pts != AV_NOPTS_VALUE || @@ -1874,7 +1874,7 @@ void ff_read_frame_flush(AVFormatContext *s) av_parser_close(st->internal->parser); st->internal->parser = NULL; } -st->last_IP_pts = AV_NOPTS_VALUE; +st->internal->last_IP_pts = AV_NOPTS_VALUE; st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; if (st->first_dts == AV_NOPTS_VALUE) st->cur_dts = RELATIVE_TS_BASE; @@ -2863,7 +2863,7 @@ skip_duration_calc: st = ic->streams[i]; st->cur_dts = st->first_dts; -st->last_IP_pts = AV_NOPTS_VALUE; +st->internal->last_IP_pts = AV_NOPTS_VALUE; st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; for (j = 0; j < MAX_REORDER_DELAY + 1; j++) st->internal->pts_buffer[j] = AV_NOPTS_VALUE; @@ -4523,7 +4523,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st->internal->pts_wrap_reference = AV_NOPTS_VALUE; st->internal->pts_wrap_behavior =
[FFmpeg-devel] [PATCH 03/18] lavf: move AVStream.{last_dts_for_order_check, dts_[mis]ordered} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 7 --- libavformat/internal.h | 7 +++ libavformat/utils.c| 28 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index c93f9d65a6..7da67d961d 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1168,13 +1168,6 @@ typedef struct AVStream { int64_t pts_reorder_error[MAX_REORDER_DELAY+1]; uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]; -/** - * Internal data to analyze DTS and detect faulty mpeg streams - */ -int64_t last_dts_for_order_check; -uint8_t dts_ordered; -uint8_t dts_misordered; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/internal.h b/libavformat/internal.h index 09bab4796d..c9eca1babb 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -225,6 +225,13 @@ struct AVStreamInternal { } *info; +/** + * Internal data to analyze DTS and detect faulty mpeg streams + */ +int64_t last_dts_for_order_check; +uint8_t dts_ordered; +uint8_t dts_misordered; + /** * Internal data to inject global side data */ diff --git a/libavformat/utils.c b/libavformat/utils.c index 625d8d69f3..04f2b24b72 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1210,24 +1210,24 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, return; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && pkt->dts != AV_NOPTS_VALUE) { -if (pkt->dts == pkt->pts && st->last_dts_for_order_check != AV_NOPTS_VALUE) { -if (st->last_dts_for_order_check <= pkt->dts) { -st->dts_ordered++; +if (pkt->dts == pkt->pts && st->internal->last_dts_for_order_check != AV_NOPTS_VALUE) { +if (st->internal->last_dts_for_order_check <= pkt->dts) { +st->internal->dts_ordered++; } else { -av_log(s, st->dts_misordered ? AV_LOG_DEBUG : AV_LOG_WARNING, +av_log(s, st->internal->dts_misordered ? AV_LOG_DEBUG : AV_LOG_WARNING, "DTS %"PRIi64" < %"PRIi64" out of order\n", pkt->dts, - st->last_dts_for_order_check); -st->dts_misordered++; + st->internal->last_dts_for_order_check); +st->internal->dts_misordered++; } -if (st->dts_ordered + st->dts_misordered > 250) { -st->dts_ordered>>= 1; -st->dts_misordered >>= 1; +if (st->internal->dts_ordered + st->internal->dts_misordered > 250) { +st->internal->dts_ordered>>= 1; +st->internal->dts_misordered >>= 1; } } -st->last_dts_for_order_check = pkt->dts; -if (st->dts_ordered < 8*st->dts_misordered && pkt->dts == pkt->pts) +st->internal->last_dts_for_order_check = pkt->dts; +if (st->internal->dts_ordered < 8*st->internal->dts_misordered && pkt->dts == pkt->pts) pkt->dts = AV_NOPTS_VALUE; } @@ -1875,7 +1875,7 @@ void ff_read_frame_flush(AVFormatContext *s) st->parser = NULL; } st->last_IP_pts = AV_NOPTS_VALUE; -st->last_dts_for_order_check = AV_NOPTS_VALUE; +st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; if (st->first_dts == AV_NOPTS_VALUE) st->cur_dts = RELATIVE_TS_BASE; else @@ -2864,7 +2864,7 @@ skip_duration_calc: st = ic->streams[i]; st->cur_dts = st->first_dts; st->last_IP_pts = AV_NOPTS_VALUE; -st->last_dts_for_order_check = AV_NOPTS_VALUE; +st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; for (j = 0; j < MAX_REORDER_DELAY + 1; j++) st->pts_buffer[j] = AV_NOPTS_VALUE; } @@ -4523,7 +4523,7 @@ FF_ENABLE_DEPRECATION_WARNINGS st->pts_wrap_behavior = AV_PTS_WRAP_IGNORE; st->last_IP_pts = AV_NOPTS_VALUE; -st->last_dts_for_order_check = AV_NOPTS_VALUE; +st->internal->last_dts_for_order_check = AV_NOPTS_VALUE; for (i = 0; i < MAX_REORDER_DELAY + 1; i++) st->pts_buffer[i] = AV_NOPTS_VALUE; -- 2.28.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 06/18] lavf: move AVStream.{nb_decoded_frames, mux_ts_offset} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 11 --- libavformat/internal.h | 11 +++ libavformat/mux.c | 6 +++--- libavformat/utils.c| 10 +- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 7383d0b6e5..977680ec83 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1129,17 +1129,6 @@ typedef struct AVStream { */ int64_t last_discard_sample; -/** - * Number of internally decoded frames, used internally in libavformat, do not access - * its lifetime differs from info which is why it is not in that structure. - */ -int nb_decoded_frames; - -/** - * Timestamp offset added to timestamps before muxing - */ -int64_t mux_ts_offset; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/internal.h b/libavformat/internal.h index efa5a8b238..b1112fe463 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -225,6 +225,17 @@ struct AVStreamInternal { } *info; +/** + * Number of internally decoded frames, used internally in libavformat, do not access + * its lifetime differs from info which is why it is not in that structure. + */ +int nb_decoded_frames; + +/** + * Timestamp offset added to timestamps before muxing + */ +int64_t mux_ts_offset; + /** * Internal data to check for wrapping of the time stamp */ diff --git a/libavformat/mux.c b/libavformat/mux.c index 44d5e5d1c0..8a2d6370f6 100644 --- a/libavformat/mux.c +++ b/libavformat/mux.c @@ -678,7 +678,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) if (s->avoid_negative_ts > 0) { AVStream *st = s->streams[pkt->stream_index]; -int64_t offset = st->mux_ts_offset; +int64_t offset = st->internal->mux_ts_offset; int64_t ts = s->internal->avoid_negative_ts_use_pts ? pkt->pts : pkt->dts; if (s->internal->offset == AV_NOPTS_VALUE && ts != AV_NOPTS_VALUE && @@ -688,7 +688,7 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt) } if (s->internal->offset != AV_NOPTS_VALUE && !offset) { -offset = st->mux_ts_offset = +offset = st->internal->mux_ts_offset = av_rescale_q_rnd(s->internal->offset, s->internal->offset_timebase, st->time_base, @@ -1038,7 +1038,7 @@ int ff_interleaved_peek(AVFormatContext *s, int stream, *pkt = pktl->pkt; if (add_offset) { AVStream *st = s->streams[pkt->stream_index]; -int64_t offset = st->mux_ts_offset; +int64_t offset = st->internal->mux_ts_offset; if (s->output_ts_offset) offset += av_rescale_q(s->output_ts_offset, AV_TIME_BASE_Q, st->time_base); diff --git a/libavformat/utils.c b/libavformat/utils.c index e3f909a252..ae7e91171e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1000,11 +1000,11 @@ static int has_decode_delay_been_guessed(AVStream *st) return 1; #endif if (st->internal->avctx->has_b_frames<3) -return st->nb_decoded_frames >= 7; +return st->internal->nb_decoded_frames >= 7; else if (st->internal->avctx->has_b_frames<4) -return st->nb_decoded_frames >= 18; +return st->internal->nb_decoded_frames >= 18; else -return st->nb_decoded_frames >= 20; +return st->internal->nb_decoded_frames >= 20; } static AVPacketList *get_next_pkt(AVFormatContext *s, AVStream *st, AVPacketList *pktl) @@ -2959,7 +2959,7 @@ static int has_codec_parameters(AVStream *st, const char **errmsg_ptr) FAIL("unspecified sample rate"); if (!avctx->channels) FAIL("unspecified number of channels"); -if (st->internal->info->found_decoder >= 0 && !st->nb_decoded_frames && avctx->codec_id == AV_CODEC_ID_DTS) +if (st->internal->info->found_decoder >= 0 && !st->internal->nb_decoded_frames && avctx->codec_id == AV_CODEC_ID_DTS) FAIL("no decodable DTS frames"); break; case AVMEDIA_TYPE_VIDEO: @@ -3066,7 +3066,7 @@ static int try_decode_frame(AVFormatContext *s, AVStream *st, } if (ret >= 0) { if (got_picture) -st->nb_decoded_frames++; +st->internal->nb_decoded_frames++; ret = got_picture; } } -- 2.28.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 04/18] lavf: move AVStream.pts_reorder_error[_count] to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 6 -- libavformat/internal.h | 6 ++ libavformat/utils.c| 18 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 7da67d961d..3d7fe4aadf 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1162,12 +1162,6 @@ typedef struct AVStream { */ int update_initial_durations_done; -/** - * Internal data to generate dts from pts - */ -int64_t pts_reorder_error[MAX_REORDER_DELAY+1]; -uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/internal.h b/libavformat/internal.h index c9eca1babb..95cb5b5d60 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -225,6 +225,12 @@ struct AVStreamInternal { } *info; +/** + * Internal data to generate dts from pts + */ +int64_t pts_reorder_error[MAX_REORDER_DELAY+1]; +uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]; + /** * Internal data to analyze DTS and detect faulty mpeg streams */ diff --git a/libavformat/utils.c b/libavformat/utils.c index 04f2b24b72..3c4d13e1c1 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1027,8 +1027,8 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t if (dts == AV_NOPTS_VALUE) { int64_t best_score = INT64_MAX; for (i = 0; ipts_reorder_error_count[i]) { -int64_t score = st->pts_reorder_error[i] / st->pts_reorder_error_count[i]; +if (st->internal->pts_reorder_error_count[i]) { +int64_t score = st->internal->pts_reorder_error[i] / st->internal->pts_reorder_error_count[i]; if (score < best_score) { best_score = score; dts = pts_buffer[i]; @@ -1039,13 +1039,13 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t for (i = 0; ipts_reorder_error[i]; -diff = FFMAX(diff, st->pts_reorder_error[i]); -st->pts_reorder_error[i] = diff; -st->pts_reorder_error_count[i]++; -if (st->pts_reorder_error_count[i] > 250) { -st->pts_reorder_error[i] >>= 1; -st->pts_reorder_error_count[i] >>= 1; ++ (uint64_t)st->internal->pts_reorder_error[i]; +diff = FFMAX(diff, st->internal->pts_reorder_error[i]); +st->internal->pts_reorder_error[i] = diff; +st->internal->pts_reorder_error_count[i]++; +if (st->internal->pts_reorder_error_count[i] > 250) { +st->internal->pts_reorder_error[i] >>= 1; +st->internal->pts_reorder_error_count[i] >>= 1; } } } -- 2.28.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 05/18] lavf: move AVStream.{pts_wrap_*, update_initial_durations_done} to AVStreamInternal
Those are private fields, no reason to have them exposed in a public header. --- libavformat/avformat.h | 22 -- libavformat/internal.h | 22 ++ libavformat/mpegts.c | 4 ++-- libavformat/utils.c| 38 +++--- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 3d7fe4aadf..7383d0b6e5 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1140,28 +1140,6 @@ typedef struct AVStream { */ int64_t mux_ts_offset; -/** - * Internal data to check for wrapping of the time stamp - */ -int64_t pts_wrap_reference; - -/** - * Options for behavior, when a wrap is detected. - * - * Defined by AV_PTS_WRAP_ values. - * - * If correction is enabled, there are two possibilities: - * If the first time stamp is near the wrap point, the wrap offset - * will be subtracted, which will create negative time stamps. - * Otherwise the offset will be added. - */ -int pts_wrap_behavior; - -/** - * Internal data to prevent doing update_initial_durations() twice - */ -int update_initial_durations_done; - /** * An opaque field for libavformat internal usage. * Must not be accessed in any way by callers. diff --git a/libavformat/internal.h b/libavformat/internal.h index 95cb5b5d60..efa5a8b238 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -225,6 +225,28 @@ struct AVStreamInternal { } *info; +/** + * Internal data to check for wrapping of the time stamp + */ +int64_t pts_wrap_reference; + +/** + * Options for behavior, when a wrap is detected. + * + * Defined by AV_PTS_WRAP_ values. + * + * If correction is enabled, there are two possibilities: + * If the first time stamp is near the wrap point, the wrap offset + * will be subtracted, which will create negative time stamps. + * Otherwise the offset will be added. + */ +int pts_wrap_behavior; + +/** + * Internal data to prevent doing update_initial_durations() twice + */ +int update_initial_durations_done; + /** * Internal data to generate dts from pts */ diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 50d4d5e9bc..b1b65d3887 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -1325,8 +1325,8 @@ skip: int64_t pcr = f->last_pcr / 300; pcr_found = 1; if (st) { -pes->st->pts_wrap_reference = st->pts_wrap_reference; -pes->st->pts_wrap_behavior = st->pts_wrap_behavior; +pes->st->internal->pts_wrap_reference = st->internal->pts_wrap_reference; +pes->st->internal->pts_wrap_behavior = st->internal->pts_wrap_behavior; } if (pes->dts == AV_NOPTS_VALUE || pes->dts < pcr) { pes->pts = pes->dts = pcr; diff --git a/libavformat/utils.c b/libavformat/utils.c index 3c4d13e1c1..e3f909a252 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -101,13 +101,13 @@ static int is_relative(int64_t ts) { */ static int64_t wrap_timestamp(const AVStream *st, int64_t timestamp) { -if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && -st->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) { -if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET && -timestamp < st->pts_wrap_reference) +if (st->internal->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && +st->internal->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) { +if (st->internal->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET && +timestamp < st->internal->pts_wrap_reference) return timestamp + (1ULL << st->pts_wrap_bits); -else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET && -timestamp >= st->pts_wrap_reference) +else if (st->internal->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET && +timestamp >= st->internal->pts_wrap_reference) return timestamp - (1ULL << st->pts_wrap_bits); } return timestamp; @@ -732,7 +732,7 @@ static int update_wrap_reference(AVFormatContext *s, AVStream *st, int stream_in if (ref == AV_NOPTS_VALUE) ref = pkt->pts; -if (st->pts_wrap_reference != AV_NOPTS_VALUE || st->pts_wrap_bits >= 63 || ref == AV_NOPTS_VALUE || !s->correct_ts_overflow) +if (st->internal->pts_wrap_reference != AV_NOPTS_VALUE || st->pts_wrap_bits >= 63 || ref == AV_NOPTS_VALUE || !s->correct_ts_overflow) return 0; ref &= (1LL << st->pts_wrap_bits)-1; @@ -747,17
Re: [FFmpeg-devel] [PATCH] avcodec/dpxenc: stop hardcoding color trc/primaries
On Fri, Oct 09, 2020 at 01:48:46PM +0100, Kieran O Leary wrote: > On Fri, Oct 9, 2020 at 12:10 PM Paul B Mahol wrote: > > > On Fri, Oct 09, 2020 at 10:08:45AM +0100, Kieran O Leary wrote: > > > Pinging as I think my comment got lost in the conversation, my main > > concern > > > is about the Printing Density value aka 1, > > > > This patch is for encoder, not for decoder (well decoder also need fixing > > but later). > > > > The meaning of 1 value is same as 0 IMHO. > > > > http://www.simplesystems.org/users/bfriesen/dpx/S268M_Revised.pdf > I know it's an older version of the spec but pretty sure new one still has > a value of 1 being Printing Density in tables 5a and 5b. I never claimed different. Issue is that there is nothing like printing density in either standardised transfer characteristic of transffer primaries. ___ 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/dpxenc: stop hardcoding color trc/primaries
On Fri, Oct 9, 2020 at 12:10 PM Paul B Mahol wrote: > On Fri, Oct 09, 2020 at 10:08:45AM +0100, Kieran O Leary wrote: > > Pinging as I think my comment got lost in the conversation, my main > concern > > is about the Printing Density value aka 1, > > This patch is for encoder, not for decoder (well decoder also need fixing > but later). > > The meaning of 1 value is same as 0 IMHO. > http://www.simplesystems.org/users/bfriesen/dpx/S268M_Revised.pdf I know it's an older version of the spec but pretty sure new one still has a value of 1 being Printing Density in tables 5a and 5b. Best, Kieran ___ 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/dpxenc: stop hardcoding color trc/primaries
On Fri, Oct 09, 2020 at 10:08:45AM +0100, Kieran O Leary wrote: > Pinging as I think my comment got lost in the conversation, my main concern > is about the Printing Density value aka 1, This patch is for encoder, not for decoder (well decoder also need fixing but later). The meaning of 1 value is same as 0 IMHO. > > K > > On Thu, Oct 8, 2020 at 10:25 AM Kieran O Leary > wrote: > > > Woah, more amazing film preservation patches, thank you! > > From my uninformed reading of the code, does this only support the > > detection of Linear, 709, 240M, 170M, Gamm22? The reason I ask is that you > > frequently see Printing Density appear as well, which has a value of '1' > > in the 801/802 offset.. > > > > Best, > > > > Kieran O'Leary, > > National Library of Ireland > > > ___ > 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 4/4] avcodec/apedec: use ff_clz() instead of while loop
On Thu, Oct 08, 2020 at 09:33:35PM +0200, Michael Niedermayer wrote: > On Wed, Oct 07, 2020 at 05:12:47PM +0200, Paul B Mahol wrote: > > On Wed, Oct 07, 2020 at 04:45:56PM +0200, Michael Niedermayer wrote: > > > On Tue, Oct 06, 2020 at 12:08:27PM +0200, Anton Khirnov wrote: > > > > Quoting Paul B Mahol (2020-10-06 10:19:13) > > > > > On Tue, Oct 06, 2020 at 10:08:58AM +0200, Anton Khirnov wrote: > > > > > > Quoting Paul B Mahol (2020-10-06 02:17:14) > > > > > > > Signed-off-by: Paul B Mahol > > > > > > > --- > > > > > > > libavcodec/apedec.c | 10 +++--- > > > > > > > 1 file changed, 3 insertions(+), 7 deletions(-) > > > > > > > > > > > > > > diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c > > > > > > > index 8fe7b5ee86..ea36247eb9 100644 > > > > > > > --- a/libavcodec/apedec.c > > > > > > > +++ b/libavcodec/apedec.c > > > > > > > @@ -575,14 +575,10 @@ static inline int > > > > > > > ape_decode_value_3990(APEContext *ctx, APERice *rice) > > > > > > > base = range_decode_culfreq(ctx, pivot); > > > > > > > range_decode_update(ctx, 1, base); > > > > > > > } else { > > > > > > > -int base_hi = pivot, base_lo; > > > > > > > -int bbits = 0; > > > > > > > +int base_hi, base_lo; > > > > > > > +int bbits = 16 - ff_clz(pivot); > > > > > > > > > > > > This assumes unsigned is always 32bit, no? > > > > > > > > > > ksum is 32 bit, from which pivot is derived. > > > > > > > > > > Should I use explicitly uint32_t type instead? > > > > > Where is unsigned not 32bit? > > > > > > > > I don't think uint32_t would help, as ff_clz() can expand to a compiler > > > > builtin. > > > > > > > > What I'm concerned about is the unstated assumption about > > > > sizeof(int/unsigned) == 4 spreading through the codebase. It's already > > > > present in plenty of places, so I certainly don't intend to block your > > > > patch over this. But we should consider explitly documenting this, and > > > > maybe testing in configure. > > > > > > At least in code i wrote and write i consider it a bug if it would > > > assume sizeof(int/unsigned) == 4 > > > > > > We also could add a ILP64 fate target, that way we would better understand > > > how much really assumes 32bit int > > > > So you basically saying we should not use ff_clz() at all because of this. > > Then we should remove it from our code. > > i guess thats the conclusion yes or > the hardcoded 32 that is used by code calling it would need to be changed Will apply this ape patchset soon, without this last controversial patch. > > thx > > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > Rewriting code that is poorly written but fully understood is good. > Rewriting code that one doesnt understand is a sign that one is less smart > then the original author, trying to rewrite it will not make it better. > ___ > 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 1/3] avformat/mspdec: Microsoft Paint (MSP) demuxer
On Thu, Oct 08, 2020 at 22:02:02 +1100, Peter Ross wrote: > Week nine or so of lockdown... What, wait. I'm like week thirty or so. ;) > OBJS-$(CONFIG_MPJPEG_DEMUXER)+= mpjpegdec.o > OBJS-$(CONFIG_MPJPEG_MUXER) += mpjpeg.o > OBJS-$(CONFIG_MPL2_DEMUXER) += mpl2dec.o subtitles.o > +OBJS-$(CONFIG_MSP_DEMUXER) += mspdec.o rawdec.o > OBJS-$(CONFIG_MSF_DEMUXER) += msf.o > OBJS-$(CONFIG_MPSUB_DEMUXER) += mpsubdec.o subtitles.o The alphabetical order was already broken by CONFIG_MSF_DEMUXER, but you broke it even more. > extern AVInputFormat ff_mpl2_demuxer; > extern AVInputFormat ff_mpsub_demuxer; > +extern AVInputFormat ff_msp_demuxer; > extern AVInputFormat ff_msf_demuxer; > extern AVInputFormat ff_msnwc_tcp_demuxer; Ditto. Moritz ___ 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/dpxenc: stop hardcoding color trc/primaries
Pinging as I think my comment got lost in the conversation, my main concern is about the Printing Density value aka 1, K On Thu, Oct 8, 2020 at 10:25 AM Kieran O Leary wrote: > Woah, more amazing film preservation patches, thank you! > From my uninformed reading of the code, does this only support the > detection of Linear, 709, 240M, 170M, Gamm22? The reason I ask is that you > frequently see Printing Density appear as well, which has a value of '1' > in the 801/802 offset.. > > Best, > > Kieran O'Leary, > National Library of Ireland > ___ 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 4/7] lavfi/vf_spp: convert to the video_enc_params API
Quoting Michael Niedermayer (2020-10-06 00:15:06) > On Mon, Oct 05, 2020 at 10:26:24AM +0200, Anton Khirnov wrote: > > Quoting Michael Niedermayer (2020-10-03 20:23:02) > > > On Fri, Oct 02, 2020 at 08:03:28PM +0200, Anton Khirnov wrote: > > > > --- > > > > libavfilter/Makefile| 2 +- > > > > libavfilter/vf_spp.c| 57 - > > > > libavfilter/vf_spp.h| 3 +- > > > > tests/fate/filter-video.mak | 4 +-- > > > > 4 files changed, 29 insertions(+), 37 deletions(-) > > > > > > > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile > > > > index d20f2937b6..2669d7b84b 100644 > > > > --- a/libavfilter/Makefile > > > > +++ b/libavfilter/Makefile > > > > @@ -404,7 +404,7 @@ OBJS-$(CONFIG_SOBEL_FILTER) += > > > > vf_convolution.o > > > > OBJS-$(CONFIG_SOBEL_OPENCL_FILTER) += > > > > vf_convolution_opencl.o opencl.o \ > > > > opencl/convolution.o > > > > OBJS-$(CONFIG_SPLIT_FILTER) += split.o > > > > -OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o > > > > +OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o qp_table.o > > > > OBJS-$(CONFIG_SR_FILTER) += vf_sr.o > > > > OBJS-$(CONFIG_SSIM_FILTER) += vf_ssim.o framesync.o > > > > OBJS-$(CONFIG_STEREO3D_FILTER) += vf_stereo3d.o > > > > diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c > > > > index 4bcc6429e0..2eb383be03 100644 > > > > --- a/libavfilter/vf_spp.c > > > > +++ b/libavfilter/vf_spp.c > > > > @@ -36,6 +36,7 @@ > > > > #include "libavutil/opt.h" > > > > #include "libavutil/pixdesc.h" > > > > #include "internal.h" > > > > +#include "qp_table.h" > > > > #include "vf_spp.h" > > > > > > > > enum mode { > > > > @@ -289,7 +290,7 @@ static void filter(SPPContext *p, uint8_t *dst, > > > > uint8_t *src, > > > > } else{ > > > > const int qps = 3 + is_luma; > > > > qp = qp_table[(FFMIN(x, width - 1) >> qps) + (FFMIN(y, > > > > height - 1) >> qps) * qp_stride]; > > > > -qp = FFMAX(1, ff_norm_qscale(qp, p->qscale_type)); > > > > +qp = FFMAX(1, ff_norm_qscale(qp, > > > > FF_QSCALE_TYPE_MPEG2)); > > > > > > wouldnt this break the cases where qscale_type is not > > > FF_QSCALE_TYPE_MPEG2 ? > > > > There should be no such cases - in the new API, only TYPE_MPEG2 exists > > (disregarding newer codecs that were not supported by this filter > > anyway). > > before the patch the code was intended to convert the quantization step size > used in the codec to the same scale as the filter used. disregarding if the > codec was 8x8 dct based. In fact spp should not require the input to be 8x8 > dct > based at all, why should it? It uses the DCT as a means to favor real images > and remove "noise" that is not part of real images. It should for example also > work if a image has blocking artifacts that look like hexagons or triangles > > I never tried but H264 with disabled loop filter should benefit from spp in > terms of subjective quality as long as the filter strength is set > appropriately > That is for streams where the bitrate is low enough to see artifacts Are you saying I should expand this filter to support new codecs? That does not seem appropriate for a patch that only adapts it to new API. -- 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".