Re: [FFmpeg-devel] [PATCH v2 3/3] hwcontext_vaapi: #if guard VAAPI_DRM specifics
Quoting Emil Velikov (2022-07-22 15:27:26) > > Assuming I'm reading the code correctly, currently when both are > undefined vaapi_device_create() will be basically a dummy, doing some > basic malloc + opts parsing and erroring out. > > So as-is functions like av_hwdevice_ctx_alloc() will return success, > although as av_hwdevice_ctx_create() is called later on it will always > fail. > My aim was to effectively omit the HWContextType vaapi instance in the > final libavutil, since it cannot work. Perhaps there's a better way to > achieve that? You seem to have missed that av_hwdevice_ctx_create() is entirely optional. The users _can_ call it to avoid some boilerplate, but they can just as well use av_hwdevice_ctx_alloc()+av_hwdevice_ctx_init(), while opening the device themselves using whatever other means. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v1] ffmpeg: add optional JSON output of inputs, outputs, mapping, and progress
Sorry, I do not like your patch. The problem is that this essentialy codifies ffmpeg's internal structure and makes into a kind of a public interface, which makes it harder for us to change it. Given that I'm currently in the middle of a big reshuffle of ffmpeg's internals, this patch would conflict with my work. And even after I'm done, we should think very carefully about exactly which parts of ffmpeg behaviour (if any at all) we want to guarantee. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] Make implicit void pointer cast explicit
Quoting Amir Mazzarella (2022-07-19 23:21:00) > Thank you for your response! A C++ compiler can't do implicit casts like a > C compiler can, in this instance. This is fine for most of FFmpeg's > codebase, since these tricks are in C source files, but in this instance it > is in a header file. If any C++ code includes this header file, even with > extern "C", it won't be able to be compiled. This header is private, no external c++ code should be including it. -- Anton Khirnov ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] lavc/libx264: support AV_CODEC_CAP_ENCODER_RECON_FRAME
Bump the version requirement to 122, which introduced b_full_recon. --- configure| 2 +- libavcodec/libx264.c | 55 +++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 6629d14099..50d73a5325 100755 --- a/configure +++ b/configure @@ -6674,7 +6674,7 @@ enabled libwebp && { enabled libwebp_encoder && require_pkg_config libwebp "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; } enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode && - require_cpp_condition libx264 x264.h "X264_BUILD >= 118" && { + require_cpp_condition libx264 x264.h "X264_BUILD >= 122" && { [ "$toolchain" != "msvc" ] || require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } && check_cpp_condition libx262 x264.h "X264_MPEG2" diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index e8c1fb2106..6afa3cdadb 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -311,6 +311,28 @@ static void free_picture(AVCodecContext *ctx) pic->extra_sei.num_payloads = 0; } +static enum AVPixelFormat csp_to_pixfmt(int csp) +{ +switch (csp) { +#ifdef X264_CSP_I400 +case X264_CSP_I400: return AV_PIX_FMT_GRAY8; +case X264_CSP_I400 | X264_CSP_HIGH_DEPTH: return AV_PIX_FMT_GRAY10; +#endif +case X264_CSP_I420: return AV_PIX_FMT_YUV420P; +case X264_CSP_I420 | X264_CSP_HIGH_DEPTH: return AV_PIX_FMT_YUV420P10; +case X264_CSP_I422: return AV_PIX_FMT_YUV422P; +case X264_CSP_I422 | X264_CSP_HIGH_DEPTH: return AV_PIX_FMT_YUV422P10; +case X264_CSP_I444: return AV_PIX_FMT_YUV444P; +case X264_CSP_I444 | X264_CSP_HIGH_DEPTH: return AV_PIX_FMT_YUV444P10; +case X264_CSP_NV12: return AV_PIX_FMT_NV12; +#ifdef X264_CSP_NV21 +case X264_CSP_NV21: return AV_PIX_FMT_NV21; +#endif +case X264_CSP_NV16: return AV_PIX_FMT_NV16; +}; +return AV_PIX_FMT_NONE; +} + static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { @@ -496,6 +518,33 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0) return AVERROR_EXTERNAL; +if (nnal && (ctx->flags & AV_CODEC_FLAG_RECON_FRAME)) { +AVCodecInternal *avci = ctx->internal; + +av_frame_unref(avci->recon_frame); + +avci->recon_frame->format = csp_to_pixfmt(pic_out.img.i_csp); +if (avci->recon_frame->format == AV_PIX_FMT_NONE) { +av_log(ctx, AV_LOG_ERROR, + "Unhandled reconstructed frame colorspace: %d\n", + pic_out.img.i_csp); +return AVERROR(ENOSYS); +} + +avci->recon_frame->width = ctx->width; +avci->recon_frame->height = ctx->height; +for (int i = 0; i < pic_out.img.i_plane; i++) { +avci->recon_frame->data[i] = pic_out.img.plane[i]; +avci->recon_frame->linesize[i] = pic_out.img.i_stride[i]; +} + +ret = av_frame_make_writable(avci->recon_frame); +if (ret < 0) { +av_frame_unref(avci->recon_frame); +return ret; +} +} + ret = encode_nals(ctx, pkt, nal, nnal); if (ret < 0) return ret; @@ -928,6 +977,9 @@ static av_cold int X264_init(AVCodecContext *avctx) if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) x4->params.b_repeat_headers = 0; +if (avctx->flags & AV_CODEC_FLAG_RECON_FRAME) +x4->params.b_full_recon = 1; + if(x4->x264opts){ const char *p= x4->x264opts; while(p){ @@ -1223,7 +1275,8 @@ FFCodec ff_libx264_encoder = { .p.id = AV_CODEC_ID_H264, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | -AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, +AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE | +AV_CODEC_CAP_ENCODER_RECON_FRAME, .p.priv_class = &x264_class, .p.wrapper_name = "libx264", .priv_data_size = sizeof(X264Context), -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or
Re: [FFmpeg-devel] [PATCH] lavc/libx264: support AV_CODEC_CAP_ENCODER_RECON_FRAME
On 7/28/2022 11:24 AM, Anton Khirnov wrote: Bump the version requirement to 122, which introduced b_full_recon. --- configure| 2 +- libavcodec/libx264.c | 55 +++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 6629d14099..50d73a5325 100755 --- a/configure +++ b/configure @@ -6674,7 +6674,7 @@ enabled libwebp && { enabled libwebp_encoder && require_pkg_config libwebp "libwebp >= 0.2.0" webp/encode.h WebPGetEncoderVersion enabled libwebp_anim_encoder && check_pkg_config libwebp_anim_encoder "libwebpmux >= 0.4.0" webp/mux.h WebPAnimEncoderOptionsInit; } enabled libx264 && require_pkg_config libx264 x264 "stdint.h x264.h" x264_encoder_encode && - require_cpp_condition libx264 x264.h "X264_BUILD >= 118" && { + require_cpp_condition libx264 x264.h "X264_BUILD >= 122" && { [ "$toolchain" != "msvc" ] || require_cpp_condition libx264 x264.h "X264_BUILD >= 158"; } && check_cpp_condition libx262 x264.h "X264_MPEG2" diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index e8c1fb2106..6afa3cdadb 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -311,6 +311,28 @@ static void free_picture(AVCodecContext *ctx) pic->extra_sei.num_payloads = 0; } +static enum AVPixelFormat csp_to_pixfmt(int csp) +{ +switch (csp) { +#ifdef X264_CSP_I400 +case X264_CSP_I400: return AV_PIX_FMT_GRAY8; +case X264_CSP_I400 | X264_CSP_HIGH_DEPTH: return AV_PIX_FMT_GRAY10; +#endif +case X264_CSP_I420: return AV_PIX_FMT_YUV420P; +case X264_CSP_I420 | X264_CSP_HIGH_DEPTH: return AV_PIX_FMT_YUV420P10; +case X264_CSP_I422: return AV_PIX_FMT_YUV422P; +case X264_CSP_I422 | X264_CSP_HIGH_DEPTH: return AV_PIX_FMT_YUV422P10; +case X264_CSP_I444: return AV_PIX_FMT_YUV444P; +case X264_CSP_I444 | X264_CSP_HIGH_DEPTH: return AV_PIX_FMT_YUV444P10; +case X264_CSP_NV12: return AV_PIX_FMT_NV12; +#ifdef X264_CSP_NV21 +case X264_CSP_NV21: return AV_PIX_FMT_NV21; +#endif +case X264_CSP_NV16: return AV_PIX_FMT_NV16; +}; +return AV_PIX_FMT_NONE; +} + static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { @@ -496,6 +518,33 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, const AVFrame *frame, if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0) return AVERROR_EXTERNAL; +if (nnal && (ctx->flags & AV_CODEC_FLAG_RECON_FRAME)) { +AVCodecInternal *avci = ctx->internal; + +av_frame_unref(avci->recon_frame); + +avci->recon_frame->format = csp_to_pixfmt(pic_out.img.i_csp); +if (avci->recon_frame->format == AV_PIX_FMT_NONE) { +av_log(ctx, AV_LOG_ERROR, + "Unhandled reconstructed frame colorspace: %d\n", + pic_out.img.i_csp); +return AVERROR(ENOSYS); +} + +avci->recon_frame->width = ctx->width; +avci->recon_frame->height = ctx->height; +for (int i = 0; i < pic_out.img.i_plane; i++) { +avci->recon_frame->data[i] = pic_out.img.plane[i]; +avci->recon_frame->linesize[i] = pic_out.img.i_stride[i]; +} + +ret = av_frame_make_writable(avci->recon_frame); +if (ret < 0) { +av_frame_unref(avci->recon_frame); +return ret; +} +} + ret = encode_nals(ctx, pkt, nal, nnal); if (ret < 0) return ret; @@ -928,6 +977,9 @@ static av_cold int X264_init(AVCodecContext *avctx) if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) x4->params.b_repeat_headers = 0; +if (avctx->flags & AV_CODEC_FLAG_RECON_FRAME) +x4->params.b_full_recon = 1; + if(x4->x264opts){ const char *p= x4->x264opts; while(p){ @@ -1223,7 +1275,8 @@ FFCodec ff_libx264_encoder = { .p.id = AV_CODEC_ID_H264, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS | -AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, +AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE | +AV_CODEC_CAP_ENCODER_RECON_FRAME, .p.priv_class = &x264_class, > .p.wrapper_name = "libx264", .priv_data_size = sizeof(X264Context), LGTM. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https
Re: [FFmpeg-devel] [PATCH] avcodec/mjpegdec: Continue if a block fails to decode correctly
On Thu, Jul 28, 2022 at 01:18:07AM +0300, Mohammad AlSaleh wrote: > Don't give up on the whole frame just because a block failed to > decode correctly. > > Try to continue decoding if the AV_EF_EXPLODE flag is not set. > > Signed-off-by: Mohammad AlSaleh > --- > libavcodec/mjpegdec.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c > index 816eb1ce5d..edefc35cb3 100644 > --- a/libavcodec/mjpegdec.c > +++ b/libavcodec/mjpegdec.c > @@ -1504,7 +1504,8 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int > nb_components, int Ah, > > s->quant_matrixes[s->quant_sindex[i]]) < 0) { > av_log(s->avctx, AV_LOG_ERROR, > "error y=%d x=%d\n", mb_y, mb_x); > -return AVERROR_INVALIDDATA; > +if (s->avctx->err_recognition & > AV_EF_EXPLODE) > +return AVERROR_INVALIDDATA; > } > if (ptr) { > s->idsp.idct_put(ptr, linesize[c], s->block); decoding should stop at an error and resume at a reset marker or some other marker where resync is possible otherwise chances are there will be alot of random trash. If there are no reset markers, it may be possible to match the end of decoding up to the frame end, this would be difficult but could allow a bit extra recovery of image data. also bit errors tend to be uncommon so if you encounter something looking like a bit error, consider that may be a encoder or decoder bug. I dont know what your case is but if it is a encoder bug or some odd quirk of some encoder it may be possible to add some special case and decode that better than just handling it like an error If you really have a file that benefits still after all above from continued blind decoding after an error then something like your patch can be considered iam not against it. Can you share the jpeg this helps ? thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Opposition brings concord. Out of discord comes the fairest harmony. -- Heraclitus signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 1/7] fflcms2: move to libavcodec
From: Niklas Haas We will need this helper inside libavcodec in the future, so move it there, leaving behind an #include to the raw source file in its old location in libvfilter. This approach is inspired by the handling of vulkan.c, and avoids us needing to expose any of it publicly (or semi-publicly) in e.g. libavutil, thus avoiding any ABI headaches. It's debatable whether the actual code belongs in libavcodec or libavfilter, but I decided to put it into libavcodec because it conceptually deals with encoding and decoding ICC profiles, and will be used to decode embedded ICC profiles in image files. Signed-off-by: Niklas Haas --- libavcodec/Makefile | 1 + libavcodec/fflcms2.c | 311 ++ libavcodec/fflcms2.h | 87 libavfilter/fflcms2.c | 294 +-- libavfilter/fflcms2.h | 65 + 5 files changed, 401 insertions(+), 357 deletions(-) create mode 100644 libavcodec/fflcms2.c create mode 100644 libavcodec/fflcms2.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index a4fab108d6..6751b6b591 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1240,6 +1240,7 @@ SKIPHEADERS-$(CONFIG_AMF) += amfenc.h SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h SKIPHEADERS-$(CONFIG_JNI) += ffjni.h +SKIPHEADERS-$(CONFIG_LCMS2)+= fflcms2.h SKIPHEADERS-$(CONFIG_LIBJXL) += libjxl.h SKIPHEADERS-$(CONFIG_LIBVPX) += libvpx.h SKIPHEADERS-$(CONFIG_LIBWEBP_ENCODER) += libwebpenc_common.h diff --git a/libavcodec/fflcms2.c b/libavcodec/fflcms2.c new file mode 100644 index 00..fd370fb310 --- /dev/null +++ b/libavcodec/fflcms2.c @@ -0,0 +1,311 @@ +/* + * Copyright (c) 2022 Niklas Haas + * 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/color_utils.h" +#include "libavutil/csp.h" + +#include "fflcms2.h" + +static void log_cb(cmsContext ctx, cmsUInt32Number error, const char *str) +{ +FFIccContext *s = cmsGetContextUserData(ctx); +av_log(s->avctx, AV_LOG_ERROR, "lcms2: [%"PRIu32"] %s\n", error, str); +} + +int ff_icc_context_init(FFIccContext *s, void *avctx) +{ +memset(s, 0, sizeof(*s)); +s->avctx = avctx; +s->ctx = cmsCreateContext(NULL, s); +if (!s->ctx) +return AVERROR(ENOMEM); + +cmsSetLogErrorHandlerTHR(s->ctx, log_cb); +return 0; +} + +void ff_icc_context_uninit(FFIccContext *s) +{ +for (int i = 0; i < FF_ARRAY_ELEMS(s->curves); i++) +cmsFreeToneCurve(s->curves[i]); +cmsDeleteContext(s->ctx); +memset(s, 0, sizeof(*s)); +} + +static int get_curve(FFIccContext *s, enum AVColorTransferCharacteristic trc, + cmsToneCurve **out_curve) +{ +if (trc >= AVCOL_TRC_NB) +return AVERROR_INVALIDDATA; + +if (s->curves[trc]) +goto done; + +switch (trc) { +case AVCOL_TRC_LINEAR: +s->curves[trc] = cmsBuildGamma(s->ctx, 1.0); +break; +case AVCOL_TRC_GAMMA22: +s->curves[trc] = cmsBuildGamma(s->ctx, 2.2); +break; +case AVCOL_TRC_GAMMA28: +s->curves[trc] = cmsBuildGamma(s->ctx, 2.8); +break; +case AVCOL_TRC_BT709: +case AVCOL_TRC_SMPTE170M: +case AVCOL_TRC_BT2020_10: +case AVCOL_TRC_BT2020_12: +s->curves[trc] = cmsBuildParametricToneCurve(s->ctx, 4, (double[5]) { +/* γ = */ 1/0.45, +/* a = */ 1/1.099296826809442, +/* b = */ 1 - 1/1.099296826809442, +/* c = */ 1/4.5, +/* d = */ 4.5 * 0.018053968510807, +}); +break; +case AVCOL_TRC_SMPTE240M: +s->curves[trc] = cmsBuildParametricToneCurve(s->ctx, 4, (double[5]) { +/* γ = */ 1/0.45, +/* a = */ 1/1.1115, +/* b = */ 1 - 1/1.1115, +/* c = */ 1/4.0, +/* d = */ 4.0 * 0.0228, +}); +break; +case AVCOL_TRC_LOG: +s->curves[trc] = cmsBuildParametricToneCurve(s->ctx, 8, (double[5]) { +/* a = */ 1.0, +/* b = */ 10.0, +/* c = */ 2.0, +/* d = */ -1.0, +/* e = */ 0.0 +}); +brea
[FFmpeg-devel] [PATCH v4 0/7] ICC profile support in avcodec
This tidies up the previous patchset slightly and adds the necessary user-facing bits to make it actually usable, plus tests. Will merge this soon since there was no additional feedback on v3. Changes in v4: - add the "icc_profiles" option to "flags2", and document it - fix the corresponding check in avcodec/decode.c - add FATE test for the new functionality Changes in v3: - switch from `int icc_profiles` to a new AV_CODEC_FLAG2 to avoid ABI break - rebased onto master and fixed merge conflicts Changes in v2: - remove unnecessary import - fixed assignment-instead-of-equality - fixed #ifdef -> #if ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 2/7] avcodec/codec_internal: add cap for ICC profile support
From: Niklas Haas Codecs that can read/write ICC profiles deserve a special capability so the common logic in encode.c/decode.c can decide whether or not there needs to be any special handling for ICC profiles. The motivation here is to be able to use it to decide whether or not an ICC profile needs to be generated in the encode path, but it might as well get added to decoders as well for purely informative reasons. It's not entirely clear to me whether the "thp" and "smvjpeg" variants of "mjpeg" should have this capability set or not, given that the code technically supports it but I somehow doubt these files may contain them. In either case, this cap is purely informative for decoders so it doesn't matter too much either way. It's also not entirely clear whether the "amv" encoder should signal ICC profile support, but again erring on the side of caution, we probably *shouldn't* be generating (and encoding!) ICC profiles for this type of media file. Signed-off-by: Niklas Haas --- libavcodec/codec_internal.h | 4 libavcodec/libjxldec.c | 3 ++- libavcodec/libjxlenc.c | 3 ++- libavcodec/mjpegdec.c | 4 +++- libavcodec/mjpegenc.c | 2 +- libavcodec/pngdec.c | 6 -- libavcodec/pngenc.c | 2 ++ libavcodec/tiff.c | 2 +- libavcodec/webp.c | 1 + 9 files changed, 20 insertions(+), 7 deletions(-) diff --git a/libavcodec/codec_internal.h b/libavcodec/codec_internal.h index 3619d04090..62ea91cf4d 100644 --- a/libavcodec/codec_internal.h +++ b/libavcodec/codec_internal.h @@ -75,6 +75,10 @@ * internal logic derive them from AVCodecInternal.last_pkt_props. */ #define FF_CODEC_CAP_SETS_FRAME_PROPS (1 << 8) +/** + * Codec supports embedded ICC profiles (AV_FRAME_DATA_ICC_PROFILE). + */ +#define FF_CODEC_CAP_ICC_PROFILES (1 << 9) /** * FFCodec.codec_tags termination value diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c index b9322b082a..f54701596b 100644 --- a/libavcodec/libjxldec.c +++ b/libavcodec/libjxldec.c @@ -456,6 +456,7 @@ const FFCodec ff_libjxl_decoder = { .close= libjxl_decode_close, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS, .caps_internal= FF_CODEC_CAP_NOT_INIT_THREADSAFE | -FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP, +FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP | +FF_CODEC_CAP_ICC_PROFILES, .p.wrapper_name = "libjxl", }; diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c index dd85fcbc8e..7e97237cd1 100644 --- a/libavcodec/libjxlenc.c +++ b/libavcodec/libjxlenc.c @@ -469,7 +469,8 @@ const FFCodec ff_libjxl_encoder = { .close= libjxl_encode_close, .p.capabilities = AV_CODEC_CAP_OTHER_THREADS, .caps_internal= FF_CODEC_CAP_NOT_INIT_THREADSAFE | -FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP, +FF_CODEC_CAP_AUTO_THREADS | FF_CODEC_CAP_INIT_CLEANUP | +FF_CODEC_CAP_ICC_PROFILES, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_RGB24, AV_PIX_FMT_RGBA, AV_PIX_FMT_RGB48, AV_PIX_FMT_RGBA64, diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index 816eb1ce5d..5f058d026f 100644 --- a/libavcodec/mjpegdec.c +++ b/libavcodec/mjpegdec.c @@ -3027,7 +3027,9 @@ const FFCodec ff_mjpeg_decoder = { .p.priv_class = &mjpegdec_class, .p.profiles = NULL_IF_CONFIG_SMALL(ff_mjpeg_profiles), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | - FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | FF_CODEC_CAP_SETS_PKT_DTS, + FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM | + FF_CODEC_CAP_SETS_PKT_DTS | + FF_CODEC_CAP_ICC_PROFILES, .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_MJPEG_NVDEC_HWACCEL HWACCEL_NVDEC(mjpeg), diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c index 63862a5043..3df0b51bb4 100644 --- a/libavcodec/mjpegenc.c +++ b/libavcodec/mjpegenc.c @@ -652,7 +652,7 @@ const FFCodec ff_mjpeg_encoder = { FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), .close = mjpeg_encode_close, .p.capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, -.caps_internal = FF_CODEC_CAP_INIT_CLEANUP, +.caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ICC_PROFILES, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index 6e1214401d..3b888199d4 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -1727,7 +1727,8 @@ const FFCodec ff_apng_decoder = { .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context),
[FFmpeg-devel] [PATCH v4 6/7] avcodec/encode:: generate ICC profiles
From: Niklas Haas Only if requested, and only if the codec signals support for ICC profiles. Implementation roughly matches the functionality of the existing vf_iccgen filter, albeit with some reduced flexibility and no caching. Ideally, we'd also only do this on the first frame (e.g. mjpeg, apng), but there's no meaningful way for us to distinguish between this case and e.g. somebody using the image2 muxer, in which case we'd want to attach ICC profiles to every frame in the stream. Closes: #9672 Signed-off-by: Niklas Haas --- libavcodec/encode.c | 53 + 1 file changed, 53 insertions(+) diff --git a/libavcodec/encode.c b/libavcodec/encode.c index 310fe20777..7cf13bf6d6 100644 --- a/libavcodec/encode.c +++ b/libavcodec/encode.c @@ -308,6 +308,53 @@ static int encode_receive_packet_internal(AVCodecContext *avctx, AVPacket *avpkt return ret; } +#if CONFIG_LCMS2 +static int encode_generate_icc_profile(AVCodecContext *avctx, AVFrame *frame) +{ +enum AVColorTransferCharacteristic trc = frame->color_trc; +enum AVColorPrimaries prim = frame->color_primaries; +const FFCodec *const codec = ffcodec(avctx->codec); +AVCodecInternal *avci = avctx->internal; +cmsHPROFILE profile; +int ret; + +/* don't generate ICC profiles if disabled or unsupported */ +if (!(avctx->flags2 & AV_CODEC_FLAG2_ICC_PROFILES)) +return 0; +if (!(codec->caps_internal & FF_CODEC_CAP_ICC_PROFILES)) +return 0; + +if (trc == AVCOL_TRC_UNSPECIFIED) +trc = avctx->color_trc; +if (prim == AVCOL_PRI_UNSPECIFIED) +prim = avctx->color_primaries; +if (trc == AVCOL_TRC_UNSPECIFIED || prim == AVCOL_PRI_UNSPECIFIED) +return 0; /* can't generate ICC profile with missing csp tags */ + +if (av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE)) +return 0; /* don't overwrite existing ICC profile */ + +if (!avci->icc.avctx) { +ret = ff_icc_context_init(&avci->icc, avctx); +if (ret < 0) +return ret; +} + +ret = ff_icc_profile_generate(&avci->icc, prim, trc, &profile); +if (ret < 0) +return ret; + +ret = ff_icc_profile_attach(&avci->icc, profile, frame); +cmsCloseProfile(profile); +return ret; +} +#else /* !CONFIG_LCMS2 */ +static int encode_generate_icc_profile(av_unused AVCodecContext *c, av_unused AVFrame *f) +{ +return 0; +} +#endif + static int encode_send_frame_internal(AVCodecContext *avctx, const AVFrame *src) { AVCodecInternal *avci = avctx->internal; @@ -360,6 +407,12 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif +if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) { +ret = encode_generate_icc_profile(avctx, dst); +if (ret < 0) +return ret; +} + return 0; } -- 2.37.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 7/7] fate/png: add test for ICC profile parsing
From: Niklas Haas This tests the new "-flags2 icc_profiles" option by making sure the embedded ICC profile gets correctly detected as sRGB. Signed-off-by: Niklas Haas --- tests/fate/image.mak | 4 +++ tests/ref/fate/png-icc-parse | 48 2 files changed, 52 insertions(+) create mode 100644 tests/ref/fate/png-icc-parse diff --git a/tests/fate/image.mak b/tests/fate/image.mak index fca4eaf60a..03e794dc48 100644 --- a/tests/fate/image.mak +++ b/tests/fate/image.mak @@ -392,6 +392,10 @@ fate-png-side-data: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_frames \ FATE_PNG_TRANSCODE-$(call TRANSCODE, PNG, IMAGE2 IMAGE_PNG_PIPE) += fate-png-icc fate-png-icc: CMD = transcode png_pipe $(TARGET_SAMPLES)/png1/lena-int_rgb24.png image2 "-c png" "" "-show_frames" +FATE_PNG_PROBE-$(call ALLYES, LCMS2) += fate-png-icc-parse +fate-png-icc-parse: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_frames \ +-flags2 icc_profiles $(TARGET_SAMPLES)/png1/lena-int_rgb24.png + FATE_PNG-$(call DEMDEC, IMAGE2, PNG) += $(FATE_PNG) FATE_PNG_PROBE-$(call DEMDEC, IMAGE2, PNG) += $(FATE_PNG_PROBE) FATE_IMAGE_FRAMECRC += $(FATE_PNG-yes) diff --git a/tests/ref/fate/png-icc-parse b/tests/ref/fate/png-icc-parse new file mode 100644 index 00..18bb18a804 --- /dev/null +++ b/tests/ref/fate/png-icc-parse @@ -0,0 +1,48 @@ +[FRAME] +media_type=video +stream_index=0 +key_frame=1 +pts=0 +pts_time=0.00 +pkt_dts=0 +pkt_dts_time=0.00 +best_effort_timestamp=0 +best_effort_timestamp_time=0.00 +pkt_duration=1 +pkt_duration_time=0.04 +duration=1 +duration_time=0.04 +pkt_pos=0 +pkt_size=40194 +width=128 +height=128 +pix_fmt=rgb24 +sample_aspect_ratio=1:1 +pict_type=I +coded_picture_number=0 +display_picture_number=0 +interlaced_frame=1 +top_field_first=0 +repeat_pict=0 +color_range=pc +color_space=unknown +color_primaries=bt709 +color_transfer=iec61966-2-1 +chroma_location=unspecified +[SIDE_DATA] +side_data_type=ICC profile +name=Photoshop ICC profile +size=3144 +[/SIDE_DATA] +[SIDE_DATA] +side_data_type=Mastering display metadata +red_x=63999/10 +red_y=33001/10 +green_x=3/10 +green_y=6/10 +blue_x=15000/10 +blue_y=5999/10 +white_point_x=31269/10 +white_point_y=32899/10 +[/SIDE_DATA] +[/FRAME] -- 2.37.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 5/7] avcodec/decode: parse ICC profiles
From: Niklas Haas Implementation for the decode side of the ICC profile API, roughly matching the behavior of the existing vf_iccdetect filter. Closes: #9673 Signed-off-by: Niklas Haas --- libavcodec/decode.c | 61 + 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 892271..92958745df 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -49,10 +49,6 @@ #include "internal.h" #include "thread.h" -#if CONFIG_LCMS2 -# include "fflcms2.h" -#endif - static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt) { int ret; @@ -508,6 +504,54 @@ FF_ENABLE_DEPRECATION_WARNINGS return ret < 0 ? ret : 0; } +#if CONFIG_LCMS2 +static int detect_colorspace(AVCodecContext *avctx, AVFrame *frame) +{ +AVCodecInternal *avci = avctx->internal; +enum AVColorTransferCharacteristic trc; +AVColorPrimariesDesc coeffs; +enum AVColorPrimaries prim; +cmsHPROFILE profile; +AVFrameSideData *sd; +int ret; +if (!(avctx->flags2 & AV_CODEC_FLAG2_ICC_PROFILES)) +return 0; + +sd = av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE); +if (!sd || !sd->size) +return 0; + +if (!avci->icc.avctx) { +ret = ff_icc_context_init(&avci->icc, avctx); +if (ret < 0) +return ret; +} + +profile = cmsOpenProfileFromMemTHR(avci->icc.ctx, sd->data, sd->size); +if (!profile) +return AVERROR_INVALIDDATA; + +ret = ff_icc_profile_read_primaries(&avci->icc, profile, &coeffs); +if (!ret) +ret = ff_icc_profile_detect_transfer(&avci->icc, profile, &trc); +cmsCloseProfile(profile); +if (ret < 0) +return ret; + +prim = av_csp_primaries_id_from_desc(&coeffs); +if (prim != AVCOL_PRI_UNSPECIFIED) +frame->color_primaries = prim; +if (trc != AVCOL_TRC_UNSPECIFIED) +frame->color_trc = trc; +return 0; +} +#else /* !CONFIG_LCMS2 */ +static int detect_colorspace(av_unused AVCodecContext *c, av_unused AVFrame *f) +{ +return 0; +} +#endif + static int decode_simple_receive_frame(AVCodecContext *avctx, AVFrame *frame) { int ret; @@ -528,7 +572,7 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) { AVCodecInternal *avci = avctx->internal; const FFCodec *const codec = ffcodec(avctx->codec); -int ret; +int ret, ok; av_assert0(!frame->buf[0]); @@ -542,6 +586,13 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) if (ret == AVERROR_EOF) avci->draining_done = 1; +/* preserve ret */ +ok = detect_colorspace(avctx, frame); +if (ok < 0) { +av_frame_unref(frame); +return ok; +} + if (!(codec->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS) && IS_EMPTY(avci->last_pkt_props)) { // May fail if the FIFO is empty. -- 2.37.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 3/7] avcodec: add API for automatic handling of icc profiles
From: Niklas Haas This functionally already exists, but as pointed out in #9672 and #9673, requiring users to manually include filters is clumsy, error-prone and hard to use together with tools like ffplay. To streamline ICC profile support, add a new AVCodecContext flag to globally enable reading and writing ICC profiles, automatically, for all appropriate media types. Note that this commit only includes the new API. The implementation is split off to separate commits for readability. Signed-off-by: Niklas Haas --- doc/APIchanges | 5 + doc/codecs.texi| 2 ++ libavcodec/avcodec.h | 6 ++ libavcodec/options_table.h | 1 + libavcodec/version.h | 2 +- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index b3563cd528..e374f3ca81 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,11 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-07-xx - x - lavc 59.40.100 - avcodec.h + Add the AV_CODEC_FLAG2_ICC_PROFILES flag to AVCodecContext, to enable + automatic reading and writing of embedded ICC profiles in image files. + The "flags2" option now supports the corresponding flag "icc_profiles". + 2022-07-xx - xx - lavu 57.30.100 - frame.h Add AVFrame.duration, deprecate AVFrame.pkt_duration. diff --git a/doc/codecs.texi b/doc/codecs.texi index 5e10020900..1adacd2b59 100644 --- a/doc/codecs.texi +++ b/doc/codecs.texi @@ -644,6 +644,8 @@ for codecs that support it. See also @file{doc/examples/export_mvs.c}. Do not skip samples and export skip information as frame side data. @item ass_ro_flush_noop Do not reset ASS ReadOrder field on flush. +@item icc_profiles +Generate/parse embedded ICC profiles from/to colorimetry tags. @end table @item export_side_data @var{flags} (@emph{decoding/encoding,audio,video,subtitles}) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index cb5c25bf63..60b215d2e9 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -331,6 +331,12 @@ typedef struct RcOverride{ * Do not reset ASS ReadOrder field on flush (subtitles decoding) */ #define AV_CODEC_FLAG2_RO_FLUSH_NOOP (1 << 30) +/** + * Generate/parse ICC profiles on encode/decode, as appropriate for the type of + * file. No effect on codecs which cannot contain embedded ICC profiles, or + * when compiled without support for lcms2. + */ +#define AV_CODEC_FLAG2_ICC_PROFILES (1U << 31) /* Unsupported options : * Syntax Arithmetic coding (SAC) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index e72b4d12b6..a72085ac90 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -83,6 +83,7 @@ static const AVOption avcodec_options[] = { {"export_mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_EXPORT_MVS}, INT_MIN, INT_MAX, V|D, "flags2"}, {"skip_manual", "do not skip samples and export skip information as frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_SKIP_MANUAL}, INT_MIN, INT_MAX, A|D, "flags2"}, {"ass_ro_flush_noop", "do not reset ASS ReadOrder field on flush", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_RO_FLUSH_NOOP}, INT_MIN, INT_MAX, S|D, "flags2"}, +{"icc_profiles", "generate/parse embedded ICC profiles from/to colorimetry tags", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_FLAG2_ICC_PROFILES}, INT_MIN, INT_MAX, S|D, "flags2"}, {"export_side_data", "Export metadata as side data", OFFSET(export_side_data), AV_OPT_TYPE_FLAGS, {.i64 = DEFAULT}, 0, UINT_MAX, A|V|S|D|E, "export_side_data"}, {"mvs", "export motion vectors through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_MVS}, INT_MIN, INT_MAX, V|D, "export_side_data"}, {"prft", "export Producer Reference Time through packet side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, A|V|S|E, "export_side_data"}, diff --git a/libavcodec/version.h b/libavcodec/version.h index f2f14eaed1..19f3f4a272 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #include "version_major.h" -#define LIBAVCODEC_VERSION_MINOR 39 +#define LIBAVCODEC_VERSION_MINOR 40 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ -- 2.37.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v4 4/7] avcodec: add common fflcms2 boilerplate
From: Niklas Haas Handling this in general code makes more sense than handling it in individual codec files, because it would be a lot of unnecessary code duplication for the plenty of formats that support exporting ICC profiles (jpg, png, tiff, webp, jxl, ...). encode.c and decode.c will be in charge of initializing this state as needed, so we merely need to make sure to uninit it afterwards from the common destructor path. Signed-off-by: Niklas Haas --- configure | 2 +- libavcodec/Makefile | 1 + libavcodec/avcodec.c | 4 libavcodec/decode.c | 4 libavcodec/internal.h | 8 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 6629d14099..8c7e8c9d1d 100755 --- a/configure +++ b/configure @@ -3814,7 +3814,7 @@ swresample_suggest="libm libsoxr stdatomic" swscale_deps="avutil" swscale_suggest="libm stdatomic" -avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs" +avcodec_extralibs="pthreads_extralibs iconv_extralibs dxva2_extralibs lcms2_extralibs" avfilter_extralibs="pthreads_extralibs" avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi_drm_extralibs vaapi_x11_extralibs vdpau_x11_extralibs" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 6751b6b591..aff7752856 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -114,6 +114,7 @@ OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o msmpeg4data.o OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o OBJS-$(CONFIG_JNI) += ffjni.o jni.o OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o +OBJS-$(CONFIG_LCMS2) += fflcms2.o OBJS-$(CONFIG_LLAUDDSP)+= lossless_audiodsp.o OBJS-$(CONFIG_LLVIDDSP)+= lossless_videodsp.o OBJS-$(CONFIG_LLVIDENCDSP) += lossless_videoencdsp.o diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c index 4bc18183a9..c9105c5df2 100644 --- a/libavcodec/avcodec.c +++ b/libavcodec/avcodec.c @@ -479,6 +479,10 @@ av_cold int avcodec_close(AVCodecContext *avctx) av_channel_layout_uninit(&avci->initial_ch_layout); +#if CONFIG_LCMS2 +ff_icc_context_uninit(&avci->icc); +#endif + av_freep(&avctx->internal); } diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 0613681f89..892271 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -49,6 +49,10 @@ #include "internal.h" #include "thread.h" +#if CONFIG_LCMS2 +# include "fflcms2.h" +#endif + static int apply_param_change(AVCodecContext *avctx, const AVPacket *avpkt) { int ret; diff --git a/libavcodec/internal.h b/libavcodec/internal.h index 6fb4e1b9af..8809a7079a 100644 --- a/libavcodec/internal.h +++ b/libavcodec/internal.h @@ -33,6 +33,10 @@ #include "avcodec.h" #include "config.h" +#if CONFIG_LCMS2 +# include "fflcms2.h" +#endif + #define FF_SANE_NB_CHANNELS 512U #if HAVE_SIMD_ALIGN_64 @@ -146,6 +150,10 @@ typedef struct AVCodecInternal { uint64_t initial_channel_layout; #endif AVChannelLayout initial_ch_layout; + +#if CONFIG_LCMS2 +FFIccContext icc; /* used to read and write embedded ICC profiles */ +#endif } AVCodecInternal; /** -- 2.37.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] qsv: Update ffmpeg qsv_errors to recognize GPU hang and other statuses
GPU hang is one of the most typical errors on Intel GPUs in case something goes wrong. It's important to recognize it explicitly for easier bugs triage. Also, this error code can be used to trigger GPU recovery path in self-written applications. There were 2 other statuses which MediaSDK can ppotentially return, MFX_ERR_NONE_PARTIAL_OUTPUT and MFX_ERR_REALLOC_SURFACE. Adding them as well. v2: move MFX_ERR_NONE_PARTIAL_OUTPUT next to MFX_WRN_* (Haihao) Signed-off-by: Hon Wai Chow Signed-off-by: Dmitry Rogozhkin --- libavcodec/qsv.c | 6 ++ libavfilter/qsvvpp.c | 6 ++ 2 files changed, 12 insertions(+) diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 385b43b..d660920 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -125,6 +125,8 @@ static const struct { { MFX_ERR_INVALID_VIDEO_PARAM, AVERROR(EINVAL), "invalid video parameters" }, { MFX_ERR_UNDEFINED_BEHAVIOR, AVERROR_BUG, "undefined behavior" }, { MFX_ERR_DEVICE_FAILED,AVERROR(EIO),"device failed" }, +{ MFX_ERR_GPU_HANG, AVERROR(EIO),"GPU Hang" }, +{ MFX_ERR_REALLOC_SURFACE, AVERROR_UNKNOWN, "need bigger surface for output" }, { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio parameters"}, { MFX_ERR_INVALID_AUDIO_PARAM, AVERROR(EINVAL), "invalid audio parameters" }, @@ -137,6 +139,10 @@ static const struct { { MFX_WRN_OUT_OF_RANGE, 0, "value out of range" }, { MFX_WRN_FILTER_SKIPPED, 0, "filter skipped" }, { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0, "incompatible audio parameters"}, + +#if QSV_VERSION_ATLEAST(1, 31) +{ MFX_ERR_NONE_PARTIAL_OUTPUT, 0, "partial output" }, +#endif }; /** diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 954f882..16d6163 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -100,6 +100,8 @@ static const struct { { MFX_ERR_INVALID_VIDEO_PARAM, AVERROR(EINVAL), "invalid video parameters" }, { MFX_ERR_UNDEFINED_BEHAVIOR, AVERROR_BUG, "undefined behavior" }, { MFX_ERR_DEVICE_FAILED,AVERROR(EIO),"device failed" }, +{ MFX_ERR_GPU_HANG, AVERROR(EIO),"GPU Hang" }, +{ MFX_ERR_REALLOC_SURFACE, AVERROR_UNKNOWN, "need bigger surface for output" }, { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio parameters"}, { MFX_ERR_INVALID_AUDIO_PARAM, AVERROR(EINVAL), "invalid audio parameters" }, @@ -112,6 +114,10 @@ static const struct { { MFX_WRN_OUT_OF_RANGE, 0, "value out of range" }, { MFX_WRN_FILTER_SKIPPED, 0, "filter skipped" }, { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0, "incompatible audio parameters"}, + +#if QSV_VERSION_ATLEAST(1, 31) +{ MFX_ERR_NONE_PARTIAL_OUTPUT, 0, "partial output" }, +#endif }; static int qsv_map_error(mfxStatus mfx_err, const char **desc) -- 1.8.3.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] Allow exporting of RGB and BGR images to CUDA.
> -Original Message- > From: ffmpeg-devel On Behalf Of > dpeeters@MRU.MEDICAL.CANON > Sent: Friday, July 8, 2022 4:51 PM > To: ffmpeg-devel@ffmpeg.org > Subject: [EXTERNAL] [FFmpeg-devel] [PATCH] Allow exporting of RGB and > BGR images to CUDA. > > Use the step size when calculating the number of channels to allow for more > than two channels per plane. This allows the use of AV_PIX_FMT_0BGR32 > when using av_hwframe_transfer_data to transfer data from a Vulkan frame > to a CUDA frame. > > Signed-off-by: David Peeters > --- > libavutil/hwcontext_vulkan.c | 8 +++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c > index 237caa4bc0..05e8fc5268 100644 > --- a/libavutil/hwcontext_vulkan.c > +++ b/libavutil/hwcontext_vulkan.c > @@ -2992,6 +2992,8 @@ static int > vulkan_export_to_cuda(AVHWFramesContext *hwfc, > const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(hwfc- > >sw_format); > VulkanDevicePriv *p = ctx->internal->priv; > FFVulkanFunctions *vk = &p->vkfn; > +int max_pixsteps[4]; > +int max_pixstep_comps[4]; > > AVHWFramesContext *cuda_fc = (AVHWFramesContext*)cuda_hwfc- > >data; > AVHWDeviceContext *cuda_cu = cuda_fc->device_ctx; @@ -3001,6 > +3003,8 @@ static int vulkan_export_to_cuda(AVHWFramesContext *hwfc, > CUarray_format cufmt = desc->comp[0].depth > 8 ? > CU_AD_FORMAT_UNSIGNED_INT16 : > > CU_AD_FORMAT_UNSIGNED_INT8; > > +av_image_fill_max_pixsteps(max_pixsteps, max_pixstep_comps, desc); > + > dst_f = (AVVkFrame *)frame->data[0]; > > dst_int = dst_f->internal; > @@ -3023,7 +3027,9 @@ static int > vulkan_export_to_cuda(AVHWFramesContext *hwfc, > .arrayDesc = { > .Depth = 0, > .Format = cufmt, > -.NumChannels = 1 + ((planes == 2) && i), > +.NumChannels = desc->comp[max_pixstep_comps[i]].depth > 8 > +? max_pixsteps[i] / 2 > +: max_pixsteps[i], > .Flags = 0, > }, > .numLevels = 1, > -- > 2.36.1 > > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://urldefense.com/v3/__https://ffmpeg.org/mailman/listinfo/ffmpeg- > devel__;!!Ai2CFrZnFhI!6NGwn- > Nv1AZn7qfPlMbwKHeDqU79spui_ApfLibprH2k3cVnA6ayxejFpL_xrg- > 8adz1jY9btFkZrg33AWLLDsXfE_uWCpvx$ > > To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org > with subject "unsubscribe". Ping. Are there any changes needed for this? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avcodec/aacdec: print a log message when treating mono HE-AAC as stereo
Since this behavior is intentional, use the VERBOSE level instead of WARNING as it's nothing the user should worry about. Signed-off-by: James Almer --- libavcodec/aac.h | 1 + libavcodec/aacdec_template.c | 4 libavcodec/aacsbr_template.c | 2 ++ 3 files changed, 7 insertions(+) diff --git a/libavcodec/aac.h b/libavcodec/aac.h index 53be546857..c8d6b17710 100644 --- a/libavcodec/aac.h +++ b/libavcodec/aac.h @@ -366,6 +366,7 @@ struct AACContext { int warned_960_sbr; unsigned warned_71_wide; int warned_gain_control; +int warned_he_aac_mono; /* aacdec functions pointers */ void (*imdct_and_windowing)(AACContext *ac, SingleChannelElement *sce); diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 119976aa19..4266d89c6d 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -2584,6 +2584,10 @@ static int decode_extension_payload(AACContext *ac, GetBitContext *gb, int cnt, ac->avctx->profile = FF_PROFILE_AAC_HE; } res = AAC_RENAME(ff_decode_sbr_extension)(ac, &che->sbr, gb, crc_flag, cnt, elem_type); +if (ac->oc[1].m4ac.ps == 1 && !ac->warned_he_aac_mono) { +av_log(ac->avctx, AV_LOG_VERBOSE, "Treating HE-AAC mono as stereo.\n"); +ac->warned_he_aac_mono = 1; +} break; case EXT_DYNAMIC_RANGE: res = decode_dynamic_range(&ac->che_drc, gb); diff --git a/libavcodec/aacsbr_template.c b/libavcodec/aacsbr_template.c index b72c94b76d..dccae0526e 100644 --- a/libavcodec/aacsbr_template.c +++ b/libavcodec/aacsbr_template.c @@ -955,6 +955,8 @@ static void read_sbr_extension(AACContext *ac, SpectralBandReplication *sbr, } else { *num_bits_left -= ff_ps_read_data(ac->avctx, gb, &sbr->ps.common, *num_bits_left); ac->avctx->profile = FF_PROFILE_AAC_HE_V2; +// ensure the warning is not printed if PS extension is present +ac->warned_he_aac_mono = 1; } break; default: -- 2.37.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 1/2] avformat/mov: Rework the AVIF parser to handle multiple items
On Wed, Jul 27, 2022 at 12:40 PM Andreas Rheinhardt wrote: > > Vignesh Venkatasubramanian: > > Stores the item ids of all the items found in the file and > > processes the primary item at the end of the meta box. This patch > > does not change any behavior. It sets up the code for parsing > > alpha channel (and possibly images with 'grid') in follow up > > patches. > > > > Signed-off-by: Vignesh Venkatasubramanian > > --- > > libavformat/isom.h | 4 ++ > > libavformat/mov.c | 146 - > > 2 files changed, 95 insertions(+), 55 deletions(-) > > > > diff --git a/libavformat/isom.h b/libavformat/isom.h > > index f05c2d9c28..d8b262e915 100644 > > --- a/libavformat/isom.h > > +++ b/libavformat/isom.h > > @@ -318,6 +318,10 @@ typedef struct MOVContext { > > uint32_t max_stts_delta; > > int is_still_picture_avif; > > int primary_item_id; > > +int *avif_item_ids; > > +int avif_item_ids_size; > > +int *avif_extent_lengths; > > +int64_t *avif_extent_offsets; > > Why are these three different buffers instead of one buffer of struct { > int avif_item_ids; int avif_extent_lengths; int64_t avif_extent_offsets;}? > Ah good point. Updated to use a struct and a size field. > > } MOVContext; > > > > int ff_mp4_read_descr_len(AVIOContext *pb); > > diff --git a/libavformat/mov.c b/libavformat/mov.c > > index a09a762d91..fc6a691da4 100644 > > --- a/libavformat/mov.c > > +++ b/libavformat/mov.c > > @@ -4698,6 +4698,69 @@ static int mov_read_custom(MOVContext *c, > > AVIOContext *pb, MOVAtom atom) > > return ret; > > } > > > > +static int avif_add_stream(MOVContext *c, int item_id) > > +{ > > +MOVStreamContext *sc; > > +AVStream *st; > > +int item_index = -1; > > +for (int i = 0; i < c->avif_item_ids_size; i++) > > +if (c->avif_item_ids[i] == item_id) { > > +item_index = i; > > +break; > > +} > > +if (item_index < 0) > > +return AVERROR_INVALIDDATA; > > +st = avformat_new_stream(c->fc, NULL); > > +if (!st) > > +return AVERROR(ENOMEM); > > +st->id = c->fc->nb_streams; > > +sc = av_mallocz(sizeof(MOVStreamContext)); > > +if (!sc) > > +return AVERROR(ENOMEM); > > + > > +st->priv_data = sc; > > +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; > > +st->codecpar->codec_id = AV_CODEC_ID_AV1; > > +sc->ffindex = st->index; > > +c->trak_index = st->index; > > +st->avg_frame_rate.num = st->avg_frame_rate.den = 1; > > +st->time_base.num = st->time_base.den = 1; > > +st->nb_frames = 1; > > +sc->time_scale = 1; > > +sc = st->priv_data; > > +sc->pb = c->fc->pb; > > +sc->pb_is_copied = 1; > > + > > +// Populate the necessary fields used by mov_build_index. > > +sc->stsc_count = 1; > > +sc->stsc_data = av_malloc_array(1, sizeof(*sc->stsc_data)); > > +if (!sc->stsc_data) > > +return AVERROR(ENOMEM); > > +sc->stsc_data[0].first = 1; > > +sc->stsc_data[0].count = 1; > > +sc->stsc_data[0].id = 1; > > +sc->chunk_count = 1; > > +sc->chunk_offsets = av_malloc_array(1, sizeof(*sc->chunk_offsets)); > > +if (!sc->chunk_offsets) > > +return AVERROR(ENOMEM); > > +sc->sample_count = 1; > > +sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes)); > > +if (!sc->sample_sizes) > > +return AVERROR(ENOMEM); > > +sc->stts_count = 1; > > +sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data)); > > +if (!sc->stts_data) > > +return AVERROR(ENOMEM); > > +sc->stts_data[0].count = 1; > > +// Not used for still images. But needed by mov_build_index. > > +sc->stts_data[0].duration = 0; > > +sc->sample_sizes[0] = c->avif_extent_lengths[item_index]; > > +sc->chunk_offsets[0] = c->avif_extent_offsets[item_index]; > > + > > +mov_build_index(c, st); > > +return 0; > > +} > > + > > static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) > > { > > while (atom.size > 8) { > > @@ -4707,9 +4770,23 @@ static int mov_read_meta(MOVContext *c, AVIOContext > > *pb, MOVAtom atom) > > tag = avio_rl32(pb); > > atom.size -= 4; > > if (tag == MKTAG('h','d','l','r')) { > > +int ret; > > avio_seek(pb, -8, SEEK_CUR); > > atom.size += 8; > > -return mov_read_default(c, pb, atom); > > +if ((ret = mov_read_default(c, pb, atom)) < 0) > > +return ret; > > +if (c->is_still_picture_avif) { > > +int ret; > > +// Add a stream for the YUV planes (primary item). > > +if ((ret = avif_add_stream(c, c->primary_item_id)) < 0) > > +return ret; > > +// For still AVIF images, the meta box contains all the > > +// necessary information that would generally be provided > > by the > > +// moov
[FFmpeg-devel] [PATCH 1/2] avformat/mov: Rework the AVIF parser to handle multiple items
Stores the item ids of all the items found in the file and processes the primary item at the end of the meta box. This patch does not change any behavior. It sets up the code for parsing alpha channel (and possibly images with 'grid') in follow up patches. Signed-off-by: Vignesh Venkatasubramanian --- libavformat/isom.h | 6 ++ libavformat/mov.c | 143 +++-- 2 files changed, 92 insertions(+), 57 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index f05c2d9c28..9d8646d2ea 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -318,6 +318,12 @@ typedef struct MOVContext { uint32_t max_stts_delta; int is_still_picture_avif; int primary_item_id; +struct { +int item_id; +int extent_length; +int64_t extent_offset; +} *avif_info; +int avif_info_size; } MOVContext; int ff_mp4_read_descr_len(AVIOContext *pb); diff --git a/libavformat/mov.c b/libavformat/mov.c index a09a762d91..6ee6ed0950 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4698,6 +4698,69 @@ static int mov_read_custom(MOVContext *c, AVIOContext *pb, MOVAtom atom) return ret; } +static int avif_add_stream(MOVContext *c, int item_id) +{ +MOVStreamContext *sc; +AVStream *st; +int item_index = -1; +for (int i = 0; i < c->avif_info_size; i++) +if (c->avif_info[i].item_id == item_id) { +item_index = i; +break; +} +if (item_index < 0) +return AVERROR_INVALIDDATA; +st = avformat_new_stream(c->fc, NULL); +if (!st) +return AVERROR(ENOMEM); +st->id = c->fc->nb_streams; +sc = av_mallocz(sizeof(MOVStreamContext)); +if (!sc) +return AVERROR(ENOMEM); + +st->priv_data = sc; +st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO; +st->codecpar->codec_id = AV_CODEC_ID_AV1; +sc->ffindex = st->index; +c->trak_index = st->index; +st->avg_frame_rate.num = st->avg_frame_rate.den = 1; +st->time_base.num = st->time_base.den = 1; +st->nb_frames = 1; +sc->time_scale = 1; +sc = st->priv_data; +sc->pb = c->fc->pb; +sc->pb_is_copied = 1; + +// Populate the necessary fields used by mov_build_index. +sc->stsc_count = 1; +sc->stsc_data = av_malloc_array(1, sizeof(*sc->stsc_data)); +if (!sc->stsc_data) +return AVERROR(ENOMEM); +sc->stsc_data[0].first = 1; +sc->stsc_data[0].count = 1; +sc->stsc_data[0].id = 1; +sc->chunk_count = 1; +sc->chunk_offsets = av_malloc_array(1, sizeof(*sc->chunk_offsets)); +if (!sc->chunk_offsets) +return AVERROR(ENOMEM); +sc->sample_count = 1; +sc->sample_sizes = av_malloc_array(1, sizeof(*sc->sample_sizes)); +if (!sc->sample_sizes) +return AVERROR(ENOMEM); +sc->stts_count = 1; +sc->stts_data = av_malloc_array(1, sizeof(*sc->stts_data)); +if (!sc->stts_data) +return AVERROR(ENOMEM); +sc->stts_data[0].count = 1; +// Not used for still images. But needed by mov_build_index. +sc->stts_data[0].duration = 0; +sc->sample_sizes[0] = c->avif_info[item_index].extent_length; +sc->chunk_offsets[0] = c->avif_info[item_index].extent_offset; + +mov_build_index(c, st); +return 0; +} + static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) { while (atom.size > 8) { @@ -4707,9 +4770,23 @@ static int mov_read_meta(MOVContext *c, AVIOContext *pb, MOVAtom atom) tag = avio_rl32(pb); atom.size -= 4; if (tag == MKTAG('h','d','l','r')) { +int ret; avio_seek(pb, -8, SEEK_CUR); atom.size += 8; -return mov_read_default(c, pb, atom); +if ((ret = mov_read_default(c, pb, atom)) < 0) +return ret; +if (c->is_still_picture_avif) { +int ret; +// Add a stream for the YUV planes (primary item). +if ((ret = avif_add_stream(c, c->primary_item_id)) < 0) +return ret; +// For still AVIF images, the meta box contains all the +// necessary information that would generally be provided by the +// moov box. So simply mark that we have found the moov box so +// that parsing can continue. +c->found_moov = 1; +} +return ret; } } return 0; @@ -7478,8 +7555,6 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) int item_count, extent_count; uint64_t base_offset, extent_offset, extent_length; uint8_t value; -AVStream *st; -MOVStreamContext *sc; if (!c->is_still_picture_avif) { // * For non-avif, we simply ignore the iloc box. @@ -7493,27 +7568,6 @@ static int mov_read_iloc(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } -st = avformat_new_stream(c->fc, NULL); -if (!st) -return
Re: [FFmpeg-devel] [PATCH 39/39] avcodec/mpegvideo: Inline values in ff_update_block_index()
On Wed, Jul 27, 2022 at 12:08:14AM +0200, Andreas Rheinhardt wrote: > This is possible for most of the callers, because e.g. only > the MPEG-4 decoder can have bits_per_raw_sample > 8. > Also most mpegvideo-based codecs are 420 only. > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/h261dec.c | 4 ++-- > libavcodec/h261enc.c | 2 +- > libavcodec/h263dec.c | 3 ++- > libavcodec/mpeg4videodec.c | 6 -- > libavcodec/mpeg_er.c | 3 ++- > libavcodec/mpegvideo.h | 12 +++- > libavcodec/mpegvideo_enc.c | 2 +- > libavcodec/rv10.c | 2 +- > libavcodec/rv34.c | 2 +- > libavcodec/vc1_block.c | 17 - > 10 files changed, 33 insertions(+), 20 deletions(-) ok [...] -- 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 37/39] avcodec/mpegvideo_motion: Constify ff_mpv_motion
On Wed, Jul 27, 2022 at 12:08:12AM +0200, Andreas Rheinhardt wrote: > Also constify the corresponding code in mpegvideo.c that handles > lowres. > (Unfortunately, not everything that is const could be constified: > ref_picture could be made const uint8_t* const* if C allowed the > safe automatic conversion from uint8_t**; and pix_op, qpix_op > could be made to point to const function pointers, but C's handling > of const in pointers to arrays is broken.) > > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/mpegvideo.c| 24 ++-- > libavcodec/mpegvideo.h| 2 +- > libavcodec/mpegvideo_motion.c | 41 ++- > libavcodec/wmv2.c | 4 ++-- > libavcodec/wmv2.h | 2 +- > 5 files changed, 37 insertions(+), 36 deletions(-) LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If you drop bombs on a foreign country and kill a hundred thousand innocent people, expect your government to call the consequence "unprovoked inhuman terrorist attacks" and use it to justify dropping more bombs and killing more people. The technology changed, the idea is old. 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 36/39] avcodec/motion_est: Constify pointers to frame data
On Wed, Jul 27, 2022 at 12:08:11AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/motion_est.c | 31 +-- > libavcodec/motion_est.h | 4 ++-- > 2 files changed, 19 insertions(+), 16 deletions(-) LGTM thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB You can kill me, but you cannot change the truth. 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 34/39] avcodec/mpegvideoencdsp: Allow pointers to const where possible
On Wed, Jul 27, 2022 at 12:08:09AM +0200, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/arm/mpegvideoencdsp_init_arm.c | 4 ++-- > libavcodec/mips/h263dsp_mips.h | 2 +- > libavcodec/mips/mpegvideoencdsp_msa.c | 4 ++-- > libavcodec/mpegvideoencdsp.c | 10 +- > libavcodec/mpegvideoencdsp.h | 10 +- > libavcodec/ppc/mpegvideoencdsp.c | 8 > libavcodec/x86/mpegvideoenc_qns_template.c | 4 ++-- > libavcodec/x86/mpegvideoencdsp.asm | 4 ++-- > libavcodec/x86/mpegvideoencdsp_init.c | 6 +++--- > 9 files changed, 26 insertions(+), 26 deletions(-) LGTM, also all similar things should be ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Any man who breaks a law that conscience tells him is unjust and willingly accepts the penalty by staying in jail in order to arouse the conscience of the community on the injustice of the law is at that moment expressing the very highest respect for law. - Martin Luther King Jr 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 1/3] avformat/mxfdec: SMPTE RDD 48:2018 support
On Tue, Jul 19, 2022 at 03:48:59PM +0200, Tomas Härdin wrote: > mån 2022-07-11 klockan 23:44 +0200 skrev Michael Niedermayer: > > > > + { { > > 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03,0x09 > > ,0x01,0x00 }, 15, AV_CODEC_ID_FFV1 }, /*FFV1 V0 */ > > + { { > > 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03,0x09 > > ,0x02,0x00 }, 15, AV_CODEC_ID_FFV1 }, /*FFV1 V1 */ > > + { { > > Double-checked, these are correct > > > +typedef struct MXFFFV1SubDescriptor { > > + MXFMetadataSet meta; > > + uint8_t *extradata; > > + int extradata_size; > > Is FFV1 extradata size bounded? It so we could avoid an allocation. > Either way the local set syntax limits this to 64k, see below. the extradata is extensible so future versions can be bigger. For the current version there should be a maximum. As the extradata uses an adaptive range coder it is not trivial to give a tight limit. It would be easy to give some non tight limit. But iam not sure this has any point as future versions can be bigger > > > +static const uint8_t mxf_ffv1_extradata[] = { > > 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x0e,0x04,0x01,0x06,0x0c,0x01,0x00 > > ,0x00,0x00 }; > > Maybe add a comment // FFV1InitializationMetadata done > > > +static int mxf_read_ffv1_sub_descriptor(void *arg, AVIOContext *pb, > > int tag, int size, UID uid, int64_t klv_offset) > > +{ > > + MXFFFV1SubDescriptor *ffv1_sub_descriptor = arg; > > + > > + if (IS_KLV_KEY(uid, mxf_ffv1_extradata)) { > > + if (ffv1_sub_descriptor->extradata) > > + av_log(NULL, AV_LOG_WARNING, "Duplicate > > ffv1_extradata\n"); > > Perhaps we should pass AVFormatContext* along with these functions to > enable proper logging. Doesn't need to hold up this patch though. > > > + av_free(ffv1_sub_descriptor->extradata); > > + ffv1_sub_descriptor->extradata_size = 0; > > + ffv1_sub_descriptor->extradata = av_malloc(size); > > + if (!ffv1_sub_descriptor->extradata) > > + return AVERROR(ENOMEM); > > + ffv1_sub_descriptor->extradata_size = size; > > This could be simplified with av_fast_malloc(), or no allocation at all > if we use a static sized array. this was missing AV_INPUT_BUFFER_PADDING_SIZE, added that. I dont think av_fast_malloc() is a good idea, its a once per stream allocation, i also dont think a static array is a good idea, there is no size limit unless you want to limit to a specific version and compute a worst case bound on a adaptive coder. And then that worst case would be orders of magnitude bigger than real extradata because real extradata compresses quite well. While the worst case would be the case that is biggest and compresses worst. So a static array would waste space > > > + avio_read(pb, ffv1_sub_descriptor->extradata, size); > > + } > > I presume the other items (GOP size, version number etc) are of no > interest and can be probed by the decoder. They are of no interrest to me ATM. Maybe there is some use case for parsing some mroe values, i do not really know. I would say we add them when we understand what to do with them. I presume theres at least one person who saw a use in them being stored there so i presume theres someone in some standard committee who saw some use in it. It seems that usecase did not make it into writing in the part of the specification that i did read [...] > > > + { { > > 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01 > > ,0x81,0x03 }, mxf_read_ffv1_sub_descriptor, > > sizeof(MXFFFV1SubDescriptor), FFV1SubDescriptor }, > > The spec says 0x7F not 0x53. 0x53 is used in groups with 2-byte tags If i put 0x7F with no other change there, it will break demuxing the files i have I guess i must have copied this from the files without noticing it mismatches the spec > rather than full KLVs. The intent here seems to be to use local tags, > which fortuitously limits extradata_size to 64k. This makes me think > Amendment 1:2022 is wrong or that 0x7F is just to signal private use > until it gets rolled into the next version of RDD 48. > > Tables 18 and 23 in S377m-1-2009 say that 0x7F corresponds to "Abstract > Groups" which are "never encoded as Metadata Sets". > > Reading S336m-2007 it seems one can actually use various lengths and > tag sizes. 0x53 corresponds to 2 byte length and 2 byte tag. S377m says > that in addition to this, 0x13 is allowed in MXF which uses ASN.1 BER > encoded lengths. Don't know if any files in the wild use that. Probably > not. couldnt they make this more complex and bizarr? 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/listin
Re: [FFmpeg-devel] [PATCH 1/3] avformat/mxfdec: SMPTE RDD 48:2018 support
fre 2022-07-29 klockan 01:18 +0200 skrev Michael Niedermayer: > On Tue, Jul 19, 2022 at 03:48:59PM +0200, Tomas Härdin wrote: > > mån 2022-07-11 klockan 23:44 +0200 skrev Michael Niedermayer: > > > > > > + { { > > > 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03, > > > 0x09 > > > ,0x01,0x00 }, 15, AV_CODEC_ID_FFV1 }, /*FFV1 V0 */ > > > + { { > > > 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x0D,0x04,0x01,0x02,0x02,0x03, > > > 0x09 > > > ,0x02,0x00 }, 15, AV_CODEC_ID_FFV1 }, /*FFV1 V1 */ > > > + { { > > > > Double-checked, these are correct > > > > > +typedef struct MXFFFV1SubDescriptor { > > > + MXFMetadataSet meta; > > > + uint8_t *extradata; > > > + int extradata_size; > > > > Is FFV1 extradata size bounded? It so we could avoid an allocation. > > Either way the local set syntax limits this to 64k, see below. > > the extradata is extensible so future versions can be bigger. > For the current version there should be a maximum. As the extradata > uses > an adaptive range coder it is not trivial to give a tight limit. It > would > be easy to give some non tight limit. But iam not sure this has any > point > as future versions can be bigger > [...] > i also dont think a static array is a good idea, there is > no size limit unless you want to limit to a specific version and > compute a worst case bound on a adaptive coder. And then > that worst case would be orders of magnitude bigger than real > extradata > because real extradata compresses quite well. While the worst case > would > be the case that is biggest and compresses worst. So a static array > would waste space Values in (0x53) local sets are limited to 64k, so it should be fine in this context > > > > > + { { > > > 0x06,0x0e,0x2b,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01, > > > 0x01 > > > ,0x81,0x03 }, mxf_read_ffv1_sub_descriptor, > > > sizeof(MXFFFV1SubDescriptor), FFV1SubDescriptor }, > > > > The spec says 0x7F not 0x53. 0x53 is used in groups with 2-byte > > tags > > If i put 0x7F with no other change there, it will break demuxing the > files i have > I guess i must have copied this from the files without noticing it > mismatches > the spec Yeah I would expect it to break with 0x7F. Perhaps this will change when the spec becomes official. If you have contact with the people involved in this then I suggest asking them about this. It could also be a typo in the spec. > > > > rather than full KLVs. The intent here seems to be to use local > > tags, > > which fortuitously limits extradata_size to 64k. This makes me > > think > > Amendment 1:2022 is wrong or that 0x7F is just to signal private > > use > > until it gets rolled into the next version of RDD 48. > > > > Tables 18 and 23 in S377m-1-2009 say that 0x7F corresponds to > > "Abstract > > Groups" which are "never encoded as Metadata Sets". > > > > Reading S336m-2007 it seems one can actually use various lengths > > and > > tag sizes. 0x53 corresponds to 2 byte length and 2 byte tag. S377m > > says > > that in addition to this, 0x13 is allowed in MXF which uses ASN.1 > > BER > > encoded lengths. Don't know if any files in the wild use that. > > Probably > > not. > > couldnt they make this more complex and bizarr? Welcome to the world of MXF. The flip side here is that extradata over 64k *can* be encoded legally, but I have never seen it in the wild and mxfdec doesn't support it (yet). In that light it makes sense to keep the extradata allocation dynamic /Tomas ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 0/3] avformat/flv: fix timestamps of key frame index
From: Zhao Zhili v2: Simplify patch 2/3 as Michael's suggestion. Zhao Zhili (3): avformat/flvenc: fix timestamp of key frame index avformat/flvdec: make key frame timestamps more accurate avformat/flvenc: fix shadowed variable ts libavformat/flvdec.c | 13 +++-- libavformat/flvenc.c | 14 -- tests/ref/fate/flv-add_keyframe_index | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 1/3] avformat/flvenc: fix timestamp of key frame index
From: Zhao Zhili Firstly, the timestamps generated from framerate are inaccurate for variable framerate mode. Secondly, the timestamps always start from zero, while pts/dts can start from nonzero. FLV demuxer rejects such index with message: "Found invalid index entries, clearing the index". --- libavformat/flvenc.c | 5 + tests/ref/fate/flv-add_keyframe_index | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 770ca319ed..1c4ffb985a 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -104,7 +104,6 @@ typedef struct FLVContext { int64_t lastkeyframelocation_offset; int64_t lastkeyframelocation; -int acurframeindex; int64_t keyframes_info_offset; int64_t filepositions_count; @@ -391,7 +390,6 @@ static void write_metadata(AVFormatContext *s, unsigned int ts) } if (flv->flags & FLV_ADD_KEYFRAME_INDEX) { -flv->acurframeindex = 0; flv->keyframe_index_size = 0; put_amf_string(pb, "hasVideo"); @@ -993,8 +991,7 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) switch (par->codec_type) { case AVMEDIA_TYPE_VIDEO: flv->videosize += (avio_tell(pb) - cur_offset); -flv->lasttimestamp = flv->acurframeindex / flv->framerate; -flv->acurframeindex++; +flv->lasttimestamp = pkt->dts / 1000.0; if (pkt->flags & AV_PKT_FLAG_KEY) { double ts = flv->lasttimestamp; int64_t pos = cur_offset; diff --git a/tests/ref/fate/flv-add_keyframe_index b/tests/ref/fate/flv-add_keyframe_index index 39c4bed85a..6549170a68 100644 --- a/tests/ref/fate/flv-add_keyframe_index +++ b/tests/ref/fate/flv-add_keyframe_index @@ -1,4 +1,4 @@ -5f38d76da3ed4a5be06ca604c53666f2 *tests/data/fate/flv-add_keyframe_index.flv +9f3d6de74f3329651a4c515c20cea00f *tests/data/fate/flv-add_keyframe_index.flv 630192 tests/data/fate/flv-add_keyframe_index.flv #tb 0: 1/1000 #media_type 0: video -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 3/3] avformat/flvenc: fix shadowed variable ts
From: Zhao Zhili --- libavformat/flvenc.c | 9 +++-- 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 1c4ffb985a..5d574fa790 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -993,12 +993,9 @@ static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) flv->videosize += (avio_tell(pb) - cur_offset); flv->lasttimestamp = pkt->dts / 1000.0; if (pkt->flags & AV_PKT_FLAG_KEY) { -double ts = flv->lasttimestamp; -int64_t pos = cur_offset; - -flv->lastkeyframetimestamp = ts; -flv->lastkeyframelocation = pos; -ret = flv_append_keyframe_info(s, flv, ts, pos); +flv->lastkeyframetimestamp = flv->lasttimestamp; +flv->lastkeyframelocation = cur_offset; +ret = flv_append_keyframe_info(s, flv, flv->lasttimestamp, cur_offset); if (ret < 0) goto fail; } -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2 2/3] avformat/flvdec: make key frame timestamps more accurate
From: Zhao Zhili There was an implicit cast from double to int64_t in time unit of second. --- libavformat/flvdec.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 8dba92661b..10f0ea7736 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -146,9 +146,9 @@ static void add_keyframes_index(AVFormatContext *s) if (ffstream(stream)->nb_index_entries == 0) { for (i = 0; i < flv->keyframe_count; i++) { av_log(s, AV_LOG_TRACE, "keyframe filepositions = %"PRId64" times = %"PRId64"\n", - flv->keyframe_filepositions[i], flv->keyframe_times[i] * 1000); + flv->keyframe_filepositions[i], flv->keyframe_times[i]); av_add_index_entry(stream, flv->keyframe_filepositions[i], -flv->keyframe_times[i] * 1000, 0, 0, AVINDEX_KEYFRAME); +flv->keyframe_times[i], 0, 0, AVINDEX_KEYFRAME); } } else av_log(s, AV_LOG_WARNING, "Skipping duplicate index\n"); @@ -428,6 +428,7 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m amf_get_string(ioc, str_val, sizeof(str_val)) > 0) { int64_t **current_array; unsigned int arraylen; +int factor; // Expect array object in context if (avio_r8(ioc) != AMF_DATA_TYPE_ARRAY) @@ -440,10 +441,12 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m if (!strcmp(KEYFRAMES_TIMESTAMP_TAG , str_val) && !times) { current_array = × timeslen = arraylen; +factor = 1000; } else if (!strcmp(KEYFRAMES_BYTEOFFSET_TAG, str_val) && !filepositions) { current_array = &filepositions; fileposlen= arraylen; +factor = 1; } else // unexpected metatag inside keyframes, will not use such // metadata for indexing @@ -458,11 +461,9 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m double d; if (avio_r8(ioc) != AMF_DATA_TYPE_NUMBER) goto invalid; -d = av_int2double(avio_rb64(ioc)); +d = av_int2double(avio_rb64(ioc)) * factor; if (isnan(d) || d < INT64_MIN || d > INT64_MAX) goto invalid; -if (current_array == × && (d <= INT64_MIN / 1000 || d >= INT64_MAX / 1000)) -goto invalid; if (avio_feof(ioc)) goto invalid; current_array[0][i] = d; @@ -478,7 +479,7 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m if (timeslen == fileposlen && fileposlen>1 && max_pos <= filepositions[0]) { for (i = 0; i < FFMIN(2,fileposlen); i++) { flv->validate_index[i].pos = filepositions[i]; -flv->validate_index[i].dts = times[i] * 1000; +flv->validate_index[i].dts = times[i]; flv->validate_count= i + 1; } flv->keyframe_times = times; -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 2/3] avcodec/videodsp: Constify buf in VideoDSPContext.prefetch
Signed-off-by: Andreas Rheinhardt --- libavcodec/aarch64/videodsp_init.c | 2 +- libavcodec/arm/videodsp_init_armv5te.c | 2 +- libavcodec/loongarch/videodsp_init.c | 2 +- libavcodec/mips/videodsp_init.c| 2 +- libavcodec/ppc/videodsp.c | 2 +- libavcodec/videodsp.c | 2 +- libavcodec/videodsp.h | 2 +- libavcodec/x86/videodsp_init.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libavcodec/aarch64/videodsp_init.c b/libavcodec/aarch64/videodsp_init.c index 6f667a6d3e..1f77a918d7 100644 --- a/libavcodec/aarch64/videodsp_init.c +++ b/libavcodec/aarch64/videodsp_init.c @@ -21,7 +21,7 @@ #include "libavutil/aarch64/cpu.h" #include "libavcodec/videodsp.h" -void ff_prefetch_aarch64(uint8_t *mem, ptrdiff_t stride, int h); +void ff_prefetch_aarch64(const uint8_t *mem, ptrdiff_t stride, int h); av_cold void ff_videodsp_init_aarch64(VideoDSPContext *ctx, int bpc) { diff --git a/libavcodec/arm/videodsp_init_armv5te.c b/libavcodec/arm/videodsp_init_armv5te.c index 1ea1f3438d..eaa8c5bbf8 100644 --- a/libavcodec/arm/videodsp_init_armv5te.c +++ b/libavcodec/arm/videodsp_init_armv5te.c @@ -23,7 +23,7 @@ #include "libavcodec/videodsp.h" #include "videodsp_arm.h" -void ff_prefetch_arm(uint8_t *mem, ptrdiff_t stride, int h); +void ff_prefetch_arm(const uint8_t *mem, ptrdiff_t stride, int h); av_cold void ff_videodsp_init_armv5te(VideoDSPContext *ctx, int bpc) { diff --git a/libavcodec/loongarch/videodsp_init.c b/libavcodec/loongarch/videodsp_init.c index 6cbb7763ff..92ade4f846 100644 --- a/libavcodec/loongarch/videodsp_init.c +++ b/libavcodec/loongarch/videodsp_init.c @@ -22,7 +22,7 @@ #include "libavcodec/videodsp.h" #include "libavutil/attributes.h" -static void prefetch_loongarch(uint8_t *mem, ptrdiff_t stride, int h) +static void prefetch_loongarch(const uint8_t *mem, ptrdiff_t stride, int h) { register const uint8_t *p = mem; diff --git a/libavcodec/mips/videodsp_init.c b/libavcodec/mips/videodsp_init.c index 07c23bcf7e..89409fc8fd 100644 --- a/libavcodec/mips/videodsp_init.c +++ b/libavcodec/mips/videodsp_init.c @@ -24,7 +24,7 @@ #include "libavutil/mips/asmdefs.h" #include "libavcodec/videodsp.h" -static void prefetch_mips(uint8_t *mem, ptrdiff_t stride, int h) +static void prefetch_mips(const uint8_t *mem, ptrdiff_t stride, int h) { register const uint8_t *p = mem; diff --git a/libavcodec/ppc/videodsp.c b/libavcodec/ppc/videodsp.c index 915702252e..a7ab5a6a42 100644 --- a/libavcodec/ppc/videodsp.c +++ b/libavcodec/ppc/videodsp.c @@ -21,7 +21,7 @@ #include "libavutil/attributes.h" #include "libavcodec/videodsp.h" -static void prefetch_ppc(uint8_t *mem, ptrdiff_t stride, int h) +static void prefetch_ppc(const uint8_t *mem, ptrdiff_t stride, int h) { register const uint8_t *p = mem; do { diff --git a/libavcodec/videodsp.c b/libavcodec/videodsp.c index 90dc1aacbd..bdff2e76f5 100644 --- a/libavcodec/videodsp.c +++ b/libavcodec/videodsp.c @@ -32,7 +32,7 @@ #include "videodsp_template.c" #undef BIT_DEPTH -static void just_return(uint8_t *buf, ptrdiff_t stride, int h) +static void just_return(const uint8_t *buf, ptrdiff_t stride, int h) { } diff --git a/libavcodec/videodsp.h b/libavcodec/videodsp.h index b5219d236c..e8960b609d 100644 --- a/libavcodec/videodsp.h +++ b/libavcodec/videodsp.h @@ -72,7 +72,7 @@ typedef struct VideoDSPContext { * @param stride distance between two lines of buf (in bytes) * @param h number of lines to prefetch */ -void (*prefetch)(uint8_t *buf, ptrdiff_t stride, int h); +void (*prefetch)(const uint8_t *buf, ptrdiff_t stride, int h); } VideoDSPContext; void ff_videodsp_init(VideoDSPContext *ctx, int bpc); diff --git a/libavcodec/x86/videodsp_init.c b/libavcodec/x86/videodsp_init.c index a14c9635fb..ae9db95624 100644 --- a/libavcodec/x86/videodsp_init.c +++ b/libavcodec/x86/videodsp_init.c @@ -215,7 +215,7 @@ static av_noinline void emulated_edge_mc_avx2(uint8_t *buf, const uint8_t *src, #endif /* HAVE_AVX2_EXTERNAL */ #endif /* HAVE_X86ASM */ -void ff_prefetch_mmxext(uint8_t *buf, ptrdiff_t stride, int h); +void ff_prefetch_mmxext(const uint8_t *buf, ptrdiff_t stride, int h); av_cold void ff_videodsp_init_x86(VideoDSPContext *ctx, int bpc) { -- 2.34.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v3 3/3] avcodec/h264chroma: Constify src in h264_chroma_mc_func
Signed-off-by: Andreas Rheinhardt --- libavcodec/aarch64/h264chroma_init_aarch64.c | 12 +- libavcodec/aarch64/h264cmc_neon.S| 4 +- libavcodec/aarch64/rv40dsp_init_aarch64.c| 8 +- libavcodec/aarch64/vc1dsp_init_aarch64.c | 8 +- libavcodec/arm/h264chroma_init_arm.c | 12 +- libavcodec/arm/h264cmc_neon.S| 4 +- libavcodec/arm/rv40dsp_init_arm.c| 8 +- libavcodec/arm/vc1dsp_init_neon.c| 8 +- libavcodec/h264chroma.h | 2 +- libavcodec/h264chroma_template.c | 16 +-- libavcodec/loongarch/h264chroma_lasx.c | 82 +-- libavcodec/loongarch/h264chroma_lasx.h | 6 +- libavcodec/loongarch/vc1dsp_lasx.c | 2 +- libavcodec/loongarch/vc1dsp_loongarch.h | 2 +- libavcodec/mips/h264chroma_mips.h| 20 +-- libavcodec/mips/h264chroma_mmi.c | 8 +- libavcodec/mips/h264chroma_msa.c | 142 +-- libavcodec/mips/vc1dsp_mips.h| 8 +- libavcodec/mips/vc1dsp_mmi.c | 8 +- libavcodec/ppc/h264chroma_template.c | 4 +- libavcodec/rv40dsp.c | 4 +- libavcodec/vc1dsp.c | 8 +- libavcodec/x86/h264_chromamc.asm | 2 +- libavcodec/x86/h264_chromamc_10bit.asm | 4 +- libavcodec/x86/h264chroma_init.c | 22 +-- libavcodec/x86/rv40dsp_init.c| 8 +- libavcodec/x86/vc1dsp_init.c | 8 +- 27 files changed, 210 insertions(+), 210 deletions(-) diff --git a/libavcodec/aarch64/h264chroma_init_aarch64.c b/libavcodec/aarch64/h264chroma_init_aarch64.c index fa6e0eaf15..00fc7b20f1 100644 --- a/libavcodec/aarch64/h264chroma_init_aarch64.c +++ b/libavcodec/aarch64/h264chroma_init_aarch64.c @@ -28,18 +28,18 @@ #include "config.h" -void ff_put_h264_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, +void ff_put_h264_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y); -void ff_put_h264_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, +void ff_put_h264_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y); -void ff_put_h264_chroma_mc2_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, +void ff_put_h264_chroma_mc2_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y); -void ff_avg_h264_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, +void ff_avg_h264_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y); -void ff_avg_h264_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, +void ff_avg_h264_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y); -void ff_avg_h264_chroma_mc2_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, +void ff_avg_h264_chroma_mc2_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y); av_cold void ff_h264chroma_init_aarch64(H264ChromaContext *c, int bit_depth) diff --git a/libavcodec/aarch64/h264cmc_neon.S b/libavcodec/aarch64/h264cmc_neon.S index f8e9407854..88ccd727d0 100644 --- a/libavcodec/aarch64/h264cmc_neon.S +++ b/libavcodec/aarch64/h264cmc_neon.S @@ -23,7 +23,7 @@ #include "libavutil/aarch64/asm.S" -/* chroma_mc8(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y) */ +/* chroma_mc8(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y) */ .macro h264_chroma_mc8 type, codec=h264 function ff_\type\()_\codec\()_chroma_mc8_neon, export=1 .ifc \type,avg @@ -193,7 +193,7 @@ function ff_\type\()_\codec\()_chroma_mc8_neon, export=1 endfunc .endm -/* chroma_mc4(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y) */ +/* chroma_mc4(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y) */ .macro h264_chroma_mc4 type, codec=h264 function ff_\type\()_\codec\()_chroma_mc4_neon, export=1 .ifc \type,avg diff --git a/libavcodec/aarch64/rv40dsp_init_aarch64.c b/libavcodec/aarch64/rv40dsp_init_aarch64.c index 142705db98..2b91d6835a 100644 --- a/libavcodec/aarch64/rv40dsp_init_aarch64.c +++ b/libavcodec/aarch64/rv40dsp_init_aarch64.c @@ -25,14 +25,14 @@ #include "config.h" -void ff_put_rv40_chroma_mc8_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, +void ff_put_rv40_chroma_mc8_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y); -void ff_put_rv40_chroma_mc4_neon(uint8_t *dst, uint8_t *src, ptrdiff_t stride, +void ff_put_rv40_chroma_mc4_neon(uint8_t *dst, const uint8_t *src, ptrdiff_t stride, int h, int x, int y); -void ff_av
Re: [FFmpeg-devel] [PATCH] qsv: Update ffmpeg qsv_errors to recognize GPU hang and other statuses
On Thu, 2022-07-28 at 08:19 -0700, Dmitry Rogozhkin wrote: > GPU hang is one of the most typical errors on Intel GPUs in > case something goes wrong. It's important to recognize it > explicitly for easier bugs triage. Also, this error code > can be used to trigger GPU recovery path in self-written > applications. > > There were 2 other statuses which MediaSDK can ppotentially return, > MFX_ERR_NONE_PARTIAL_OUTPUT and MFX_ERR_REALLOC_SURFACE. Adding > them as well. > > v2: move MFX_ERR_NONE_PARTIAL_OUTPUT next to MFX_WRN_* (Haihao) > > Signed-off-by: Hon Wai Chow > Signed-off-by: Dmitry Rogozhkin > --- > libavcodec/qsv.c | 6 ++ > libavfilter/qsvvpp.c | 6 ++ > 2 files changed, 12 insertions(+) > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c > index 385b43b..d660920 100644 > --- a/libavcodec/qsv.c > +++ b/libavcodec/qsv.c > @@ -125,6 +125,8 @@ static const struct { > { MFX_ERR_INVALID_VIDEO_PARAM, AVERROR(EINVAL), "invalid video > parameters" }, > { MFX_ERR_UNDEFINED_BEHAVIOR, AVERROR_BUG, "undefined > behavior" }, > { MFX_ERR_DEVICE_FAILED,AVERROR(EIO),"device > failed"}, > +{ MFX_ERR_GPU_HANG, AVERROR(EIO),"GPU > Hang" }, > +{ MFX_ERR_REALLOC_SURFACE, AVERROR_UNKNOWN, "need bigger surface > for output" }, > { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio > parameters"}, > { MFX_ERR_INVALID_AUDIO_PARAM, AVERROR(EINVAL), "invalid audio > parameters" }, > > @@ -137,6 +139,10 @@ static const struct { > { MFX_WRN_OUT_OF_RANGE, 0, "value out of > range" }, > { MFX_WRN_FILTER_SKIPPED, 0, "filter > skipped" }, > { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0, "incompatible audio > parameters"}, > + > +#if QSV_VERSION_ATLEAST(1, 31) > +{ MFX_ERR_NONE_PARTIAL_OUTPUT, 0, "partial > output" }, > +#endif > }; > > /** > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c > index 954f882..16d6163 100644 > --- a/libavfilter/qsvvpp.c > +++ b/libavfilter/qsvvpp.c > @@ -100,6 +100,8 @@ static const struct { > { MFX_ERR_INVALID_VIDEO_PARAM, AVERROR(EINVAL), "invalid video > parameters" }, > { MFX_ERR_UNDEFINED_BEHAVIOR, AVERROR_BUG, "undefined > behavior" }, > { MFX_ERR_DEVICE_FAILED,AVERROR(EIO),"device > failed"}, > +{ MFX_ERR_GPU_HANG, AVERROR(EIO),"GPU > Hang" }, > +{ MFX_ERR_REALLOC_SURFACE, AVERROR_UNKNOWN, "need bigger surface > for output" }, > { MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio > parameters"}, > { MFX_ERR_INVALID_AUDIO_PARAM, AVERROR(EINVAL), "invalid audio > parameters" }, > > @@ -112,6 +114,10 @@ static const struct { > { MFX_WRN_OUT_OF_RANGE, 0, "value out of > range" }, > { MFX_WRN_FILTER_SKIPPED, 0, "filter > skipped" }, > { MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0, "incompatible audio > parameters"}, > + > +#if QSV_VERSION_ATLEAST(1, 31) > +{ MFX_ERR_NONE_PARTIAL_OUTPUT, 0, "partial > output" }, > +#endif > }; > > static int qsv_map_error(mfxStatus mfx_err, const char **desc) Applied, thx -Haihao ___ 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".