Re: [FFmpeg-devel] [PATCH] avformat/movenc: Don't auto flush fragment if no frame available
Thank you for your detailed explaination. Now I agree your patch is better. On Mon, Aug 09, 2021 at 09:36:12PM +0300, Martin Storsjö wrote: > Hi, > > On Mon, 9 Aug 2021, Hu Weiwen wrote: > > > Even if FF_MOV_FLAG_FRAG_EVERY_FRAME is set, don't flush if no frame > > available. > > > > This fixes an issue that we overwrite the track duration, causing it to be > > out-of-sync with the last written packet in previous fragment. > > > > Signed-off-by: Hu Weiwen > > --- > > Hi Martin, > > > > I can confirm your patch "movenc: Don't try to fix the fragment end > > duration if none will be written"[1] does fix my issue reported in [2]. > > But I think my current patch would be a better fix. It is more > > self-explanatory, and more consistent in the case of > > FF_MOV_FLAG_FRAG_KEYFRAME. > > This patch is indeed more straightforward, but it misses a couple cases. If > the current muxed packet is a keyframe, but we have no queued packets in > this track, we'd end up with the same bug again. I don't get this. We already checked trk->entry in the FF_MOV_FLAG_FRAG_KEYFRAME case. > And the other way around, > if we'd have a packet queued in another track, we won't flush that fragment > right here, which is a notable behaviour change from how > FF_MOV_FLAG_FRAG_EVERY_FRAME behaves right now. I agree. > > Also, I think my original patch [2] still has its value. "frag_start" > > seems to be redundant, and it is only updated relative to its previous > > value. This is bad because any potential error updating it will have > > infinite impact on future packets. > > I disagree here. If we have a bug where we update things making them > inconsistent, we should fix that bug. These other patches that are discussed > is one case of that. > > This code is quite complex and it's almost a decade since I wrote most of > it, so I don't recall offhand exactly how it behaves in all cases - but it's > designed to try to make the output consistent and correct for a number of > weird cases. > > If the variable really is strictly redundant, you can send a patch which can > be proven to not alter behaviour anywhere under any circumstances. But if > it's made with the intent to be more robust, then it's also a possible > behaviour change, and in that case I prefer not changing behaviour blindly. I agree. I will try to prove. > But separately, as I said, I'm totally open to a patch to add an option to > make it stop adjusting the start of the next fragment (making tfdt the > authoritative source, possibly differing from the sum of earlier durations). > > // Martin ___ 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] avformat/movenc: Don't auto flush fragment if no frame available
On Tue, 10 Aug 2021, 胡玮文 wrote: Thank you for your detailed explaination. Now I agree your patch is better. Ok, I pushed that one then. // Martin ___ 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] libavcodec/qsvence: Use QSV encoder defaults as ffmpeg defaults
Signed-off-by: softworkz --- libavcodec/qsvenc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index fc8a14143e..58984f996f 100644 --- a/libavcodec/qsvenc.h +++ b/libavcodec/qsvenc.h @@ -76,8 +76,8 @@ #define QSV_COMMON_OPTS \ { "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VE }, \ -{ "avbr_accuracy","Accuracy of the AVBR ratecontrol", OFFSET(qsv.avbr_accuracy),AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, \ -{ "avbr_convergence", "Convergence of the AVBR ratecontrol", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE }, \ +{ "avbr_accuracy","Accuracy of the AVBR ratecontrol (unit of tenth of percent)",OFFSET(qsv.avbr_accuracy),AV_OPT_TYPE_INT, { .i64 = 1 }, 1, UINT16_MAX, VE }, \ +{ "avbr_convergence", "Convergence of the AVBR ratecontrol (unit of 100 frames)", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, UINT16_MAX, VE }, \ { "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = MFX_TARGETUSAGE_BALANCED }, MFX_TARGETUSAGE_BEST_QUALITY, MFX_TARGETUSAGE_BEST_SPEED, VE, "preset" }, \ { "veryfast",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" }, \ { "faster", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_TARGETUSAGE_6 }, INT_MIN, INT_MAX, VE, "preset" }, \ -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] configure: [loongson] adjust MMI check in configure
Ping. "yinshiyou-hf"写道: > > -原始邮件- > > 发件人: "Jin Bo" > > 发送时间: 2021-08-03 12:05:21 (星期二) > > 收件人: ffmpeg-devel@ffmpeg.org > > 抄送: > > 主题: [FFmpeg-devel] [PATCH v2] configure: [loongson] adjust MMI check in > > configure > > > > After standardizing the use of 'pxor' in commit 'ebedd26', FFmpeg > > build failed with upstream compiler, for 'pxor' is not supported > > in time. This patch helps to workaround the build failure by > > checking whether 'pxor' is supported during configuration, if not, > > MMI will be disabled. > > --- > > configure | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/configure b/configure > > index 94b30afe74..2aea0f841a 100755 > > --- a/configure > > +++ b/configure > > @@ -5951,7 +5951,7 @@ elif enabled mips; then > > enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, > > $3)"' '-mloongson-ext' && append MMIFLAGS '-mloongson-ext' > > > > # MMI can be detected at runtime too > > -enabled mmi && check_inline_asm mmi '"punpcklhw $f0, $f0, $f0"' > > '-mloongson-mmi' && append MMIFLAGS '-mloongson-mmi' > > +enabled mmi && check_inline_asm mmi '"pxor $f0, $f0, $f0"' > > '-mloongson-mmi' && append MMIFLAGS '-mloongson-mmi' > > > > if enabled bigendian && enabled msa; then > > disable msa > > -- > > 2.20.1 > > > LGTM > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
> -Original Message- > From: ffmpeg-devel On Behalf Of > Nicolas George > Sent: Monday, 9 August 2021 10:28 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH v4 1/2] libavutil/log: Add capability to > prefix loglines with current time or current date+time > > Soft Works (12021-08-09): > > Signed-off-by: softworkz > > --- > > v2: split commits differently, fix AVBPrint finalization > > doc/APIchanges | 3 +++ > > libavutil/log.c | 33 ++--- > > libavutil/log.h | 10 ++ > > libavutil/version.h | 2 +- > > 4 files changed, 44 insertions(+), 4 deletions(-) Hi Nicholas, I'm not sure whether it's OK to strip all content when there's nothing new inside..? I made all of your suggested changes. Thanks a lot for your review. softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
Soft Works (12021-08-10): > I'm not sure whether it's OK to strip all content when there's nothing > new inside..? I do not understand what you are talking about, sorry. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avutils/hwcontext: When deriving a hwdevice, search for existing device in both directions
> -Original Message- > From: ffmpeg-devel On Behalf Of > Xiang, Haihao > Sent: Monday, 9 August 2021 09:27 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH] avutils/hwcontext: When deriving a > hwdevice, search for existing device in both directions > > On Sat, 2021-08-07 at 01:46 +, Soft Works wrote: [...] > > if (ret == 0) { > > dst_ctx->internal->source_device = > > av_buffer_ref(src_ref); > > +tmp_ctx->internal->derived_device = > > + av_buffer_ref(dst_ref); > > if (!dst_ctx->internal->source_device) { > > Need to check tmp_ctx->internal->derived_device too. > > > ret = AVERROR(ENOMEM); > > goto fail; > > diff --git a/libavutil/hwcontext_internal.h > > b/libavutil/hwcontext_internal.h index e6266494ac..cfe525d20c 100644 > > --- a/libavutil/hwcontext_internal.h > > +++ b/libavutil/hwcontext_internal.h > > @@ -109,6 +109,12 @@ struct AVHWDeviceInternal { > > * context it was derived from. > > */ > > AVBufferRef *source_device; > > + > > +/** > > + * A reference to a device context which > > + * was derived from this device. > > + */ > > +AVBufferRef *derived_device; > > }; > > > > struct AVHWFramesInternal { > > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c > > index 08a6e0ee1c..27d96d116f 100644 > > --- a/libavutil/hwcontext_qsv.c > > +++ b/libavutil/hwcontext_qsv.c > > @@ -1268,8 +1268,13 @@ static int > qsv_device_create(AVHWDeviceContext > > *ctx, const char *device, > > child_device = (AVHWDeviceContext*)priv->child_device_ctx->data; > > > > impl = choose_implementation(device); > > +ret = qsv_device_derive_from_child(ctx, impl, child_device, 0); > > +if (ret >= 0) { > > +ctx->internal->source_device = av_buffer_ref(priv- > >child_device_ctx); > > +child_device->internal->derived_device = > > av_buffer_create((uint8_t*)ctx, sizeof(*ctx), 0, ctx, 0); > > Need to check the new references here. Added checks in the next update. Thanks a lot for reviewing. softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
> -Original Message- > From: ffmpeg-devel On Behalf Of > Nicolas George > Sent: Tuesday, 10 August 2021 11:06 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH v4 1/2] libavutil/log: Add capability to > prefix loglines with current time or current date+time > > Soft Works (12021-08-10): > > I'm not sure whether it's OK to strip all content when there's nothing > > new inside..? > > I do not understand what you are talking about, sorry. I meant the e-mail body of the previous conversation. ___ 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] Mail quoting (was: 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time)
Soft Works (12021-08-10): > I meant the e-mail body of the previous conversation. Well, it is my mail, I put what I want in it, and you do what you want with yours. But ask yourself: which one do you find easier to read: one where you have to scroll half a dozen pages of old mail just to get to the new bits, or one where you have enough quoted context to remember what the discussion is about but not too much? For me, the answer is the second, and since I prefer this for myself I have toe courtesy to do the same for the mails I send, even if it takes a few more keystrokes. A lot of people do not bother, and even many more people bother even less and top-post. Compare with a hand-written letter: you would never copy all the missive you are replying to, you would just quote a little bit to give context, “regarding you calling on me tomorrow”… The full context is always available in mail archives, of course, nobody can prevent that, especially if you have full archives of your own somewhere. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time)
> -Original Message- > From: ffmpeg-devel On Behalf Of > Nicolas George > Sent: Tuesday, 10 August 2021 11:16 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add capability > to prefix loglines with current time or current date+time) > > Soft Works (12021-08-10): > > I meant the e-mail body of the previous conversation. > > Well, it is my mail, I put what I want in it, and you do what you want with > yours. > > But ask yourself: which one do you find easier to read: one where you have > to scroll half a dozen pages of old mail just to get to the new bits, or one > where you have enough quoted context to remember what the discussion is > about but not too much? > > For me, the answer is the second, and since I prefer this for myself Totally agree. > I have toe > courtesy to do the same for the mails I send, even if it takes a few more > keystrokes. A lot of people do not bother, Yes, that made me wonder whether shortening would be against any rule or guideline. One of the most annoying things with that mailing-list-style development is the requirement to scroll through every single message of concern while trying to spot all lines that do not have a '> ' prefix. As some do not even put a blank line before and after a comment, you cannot rely on that, meaning that you have to look very carefully while scrolling. It's surely OK for regular conversations, but for working with code... Kind regards, softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v2] avutils/hwcontext: When deriving a hwdevice, search for existing device in both directions
The test /libavutil/tests/hwdevice checks that when deriving a device from a source device and then deriving back to the type of the source device, the result is matching the original source device, i.e. the derivation mechanism doesn't create a new device in this case. Previously, this test was usually passed, but only due to two different kind of flaws: 1. The test covers only a single level of derivation (and back) It derives device Y from device X and then Y back to the type of X and checks whether the result matches X. What it doesn't check for, are longer chains of derivation like: CUDA1 > OpenCL2 > CUDA3 and then back to OpenCL4 In that case, the second derivation returns the first device (CUDA3 == CUDA1), but when deriving OpenCL4, hwcontext.c was creating a new OpenCL4 context instead of returning OpenCL2, because there was no link from CUDA1 to OpenCL2 (only backwards from OpenCL2 to CUDA1) If the test would check for two levels of derivation, it would have failed. This patch fixes those (yet untested) cases by introducing forward references (derived_device) in addition to the existing back references (source_device). 2. hwcontext_qsv didn't properly set the source_device In case of QSV, hwcontext_qsv creates a source context internally (vaapi, dxva2 or d3d11va) without calling av_hwdevice_ctx_create_derived and without setting source_device. This way, the hwcontext test ran successful, but what practically happened, was that - for example - deriving vaapi from qsv didn't return the original underlying vaapi device and a new one was created instead: Exactly what the test is intended to detect and prevent. It just couldn't do so, because the original device was hidden (= not set as the source_device of the QSV device). This patch properly makes these setting and fixes all derivation scenarios. (at a later stage, /libavutil/tests/hwdevice should be extended to check longer derivation chains as well) Signed-off-by: softworkz --- v2: allow storing multiple derived devices in a device ctx; add checks for oom libavutil/hwcontext.c | 38 ++ libavutil/hwcontext.h | 1 + libavutil/hwcontext_internal.h | 6 ++ libavutil/hwcontext_qsv.c | 10 - 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c index d13d0f7c9b..7f4e541553 100644 --- a/libavutil/hwcontext.c +++ b/libavutil/hwcontext.c @@ -122,6 +122,7 @@ static const AVClass hwdevice_ctx_class = { static void hwdevice_ctx_free(void *opaque, uint8_t *data) { AVHWDeviceContext *ctx = (AVHWDeviceContext*)data; +int i; /* uninit might still want access the hw context and the user * free() callback might destroy it, so uninit has to be called first */ @@ -132,6 +133,8 @@ static void hwdevice_ctx_free(void *opaque, uint8_t *data) ctx->free(ctx); av_buffer_unref(&ctx->internal->source_device); +for (i = 0; i < AV_HWDEVICE_TYPE_NB; i++) +av_buffer_unref(&ctx->internal->derived_devices[i]); av_freep(&ctx->hwctx); av_freep(&ctx->internal->priv); @@ -643,6 +646,26 @@ fail: return ret; } +static AVBufferRef* find_derived_hwdevice_ctx(AVBufferRef *src_ref, enum AVHWDeviceType type) +{ +AVBufferRef *tmp_ref; +AVHWDeviceContext *src_ctx; +int i; + +src_ctx = (AVHWDeviceContext*)src_ref->data; +if (src_ctx->type == type) +return src_ref; + +for (i = 0; i < AV_HWDEVICE_TYPE_NB; i++) +if (src_ctx->internal->derived_devices[i]) { +tmp_ref = find_derived_hwdevice_ctx(src_ctx->internal->derived_devices[i], type); +if (tmp_ref) +return tmp_ref; +} + +return 0; +} + int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr, enum AVHWDeviceType type, AVBufferRef *src_ref, @@ -666,6 +689,16 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr, tmp_ref = tmp_ctx->internal->source_device; } +tmp_ref = find_derived_hwdevice_ctx(src_ref, type); +if (tmp_ref) { +dst_ref = av_buffer_ref(tmp_ref); +if (!dst_ref) { +ret = AVERROR(ENOMEM); +goto fail; +} +goto done; +} + dst_ref = av_hwdevice_ctx_alloc(type); if (!dst_ref) { ret = AVERROR(ENOMEM); @@ -687,6 +720,11 @@ int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr, ret = AVERROR(ENOMEM); goto fail; } +tmp_ctx->internal->derived_devices[type] = av_buffer_ref(dst_ref); +if (!tmp_ctx->internal->derived_devices[type]) { +ret = AVERROR(ENOMEM); +goto fail; +} ret = av_hwdevice_ctx_init(dst_ref); if (ret < 0) goto fai
[FFmpeg-devel] [PATCH v5 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
Signed-off-by: softworkz --- doc/APIchanges | 3 +++ libavutil/log.c | 35 ++- libavutil/log.h | 10 ++ libavutil/version.h | 2 +- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 6eefc7fc33..be707314f3 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-08-09 - xx - lavu 57.4.100 - log.h + Add new defines: AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME + 2021-08-02 - xx - lavc 59.4.100 - packet.h Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base. diff --git a/libavutil/log.c b/libavutil/log.c index 66defa9c42..34af1da60c 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -40,6 +40,8 @@ #include "internal.h" #include "log.h" #include "thread.h" +#include "time.h" +#include "time_internal.h" static AVMutex mutex = AV_MUTEX_INITIALIZER; @@ -289,19 +291,36 @@ static const char *get_level_str(int level) } } +static void format_date_now(AVBPrint *timeBuf, int include_date) +{ +struct tm *ptm, tmbuf; +const int64_t time_ms = av_gettime() / 1000; +const time_t time_s = time_ms / 1000; +const int millisec = time_ms % 1000; +ptm = localtime_r(&time_s, &tmbuf); +if (ptm) { +if (include_date) +av_bprint_strftime(timeBuf, "%Y-%m-%d ", ptm); + +av_bprint_strftime(timeBuf, "%H:%M:%S", ptm); +av_bprintf(timeBuf, ".%03d ", millisec); +} +} + static void format_line(void *avcl, int level, const char *fmt, va_list vl, -AVBPrint part[4], int *print_prefix, int type[2]) +AVBPrint part[5], int *print_prefix, int type[2]) { -AVClass* avc = avcl ? *(AVClass **) avcl : NULL; +AVClass *avc = avcl ? *(AVClass **) avcl : NULL; av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(part+3, 0, 65536); +av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC); if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16; if (*print_prefix && avc) { if (avc->parent_log_context_offset) { -AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) + +AVClass **parent = *(AVClass ***) (((uint8_t *) avcl) + avc->parent_log_context_offset); if (parent && *parent) { av_bprintf(part+0, "[%s @ %p] ", @@ -314,6 +333,10 @@ static void format_line(void *avcl, int level, const char *fmt, va_list vl, if(type) type[1] = get_category(avcl); } +if (*print_prefix +&& (flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME))) +format_date_now(&part[4], flags & AV_LOG_PRINT_DATETIME); + if (*print_prefix && (level > AV_LOG_QUIET) && (flags & AV_LOG_PRINT_LEVEL)) av_bprintf(part+2, "[%s] ", get_level_str(level)); @@ -334,7 +357,7 @@ void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix) { -AVBPrint part[4]; +AVBPrint part[5]; int ret; format_line(ptr, level, fmt, vl, part, print_prefix, NULL); @@ -348,7 +371,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) static int print_prefix = 1; static int count; static char prev[LINE_SZ]; -AVBPrint part[4]; +AVBPrint part[5]; char line[LINE_SZ]; static int is_atty; int type[2]; @@ -383,6 +406,8 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) count = 0; } strcpy(prev, line); + +colored_fputs(7, 0, part[4].str); sanitize(part[0].str); colored_fputs(type[0], 0, part[0].str); sanitize(part[1].str); diff --git a/libavutil/log.h b/libavutil/log.h index 8727c38afc..b071f0f1eb 100644 --- a/libavutil/log.h +++ b/libavutil/log.h @@ -377,6 +377,16 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, */ #define AV_LOG_PRINT_LEVEL 2 +/** + * Include local time in log output. + */ +#define AV_LOG_PRINT_TIME 4 + +/** + * Include local date and time in log output. + */ +#define AV_LOG_PRINT_DATETIME 8 + void av_log_set_flags(int arg); int av_log_get_flags(void); diff --git a/libavutil/version.h b/libavutil/version.h index 6b4a265457..201b012596 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 3 +#define LIBAVUTIL_VERSION_MINOR 4 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.28.0.windows.1 ___ ffmpeg-
[FFmpeg-devel] [PATCH v5 2/2] fftools: Add option to log timing
This commit adds two logging flags: 'timing' and 'datetiming'. Usage: ffmpeg -loglevel +timing or ffmpeg -loglevel +datetiming Signed-off-by: softworkz --- doc/fftools-common-opts.texi | 4 fftools/cmdutils.c | 21 + fftools/ffmpeg.c | 6 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi index 7643dd8396..aae26c28d0 100644 --- a/doc/fftools-common-opts.texi +++ b/doc/fftools-common-opts.texi @@ -198,6 +198,10 @@ and the "Last message repeated n times" line will be omitted. Indicates that log output should add a @code{[level]} prefix to each message line. This can be used as an alternative to log coloring, e.g. when dumping the log to file. +@item time +Prefixes each log line with the local time. +@item datetime +Same as time but also prints the current date in each line. @end table Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single flag without affecting other @var{flags} or changing @var{loglevel}. When diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 912e881174..7918078766 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -918,6 +918,27 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg) flags |= AV_LOG_PRINT_LEVEL; } arg = token + 5; +} else if (av_strstart(token, "time", NULL)) { +if (cmd == '-') { +flags &= ~AV_LOG_PRINT_TIME; +} else { +flags |= AV_LOG_PRINT_TIME; +} +arg = token + 4; +} else if (av_strstart(token, "timing", NULL)) { +if (cmd == '-') { +flags &= ~AV_LOG_PRINT_TIME; +} else { +flags |= AV_LOG_PRINT_TIME; +} +arg = token + 6; +} else if (av_strstart(token, "datetime", NULL)) { +if (cmd == '-') { +flags &= ~AV_LOG_PRINT_DATETIME; +} else { +flags |= AV_LOG_PRINT_DATETIME; +} +arg = token + 8; } else { break; } diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index b0ce7c7c32..b0b105be1c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4983,7 +4983,7 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl) int main(int argc, char **argv) { -int i, ret; +int i, ret, log_flags; BenchmarkTimeStamps ti; init_dynload(); @@ -5049,6 +5049,10 @@ int main(int argc, char **argv) if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < decode_error_stat[1]) exit_program(69); +log_flags = av_log_get_flags(); +if (log_flags & AV_LOG_PRINT_TIME || log_flags & AV_LOG_PRINT_DATETIME) +av_log(NULL, AV_LOG_INFO, "\n"); /* end with line break to avoid mixing up with shell prompt */ + exit_program(received_nb_signals ? 255 : main_return_code); return main_return_code; } -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] imgutils: expose av_image_copy_plane_uc_from()
The reason why the generic av_image_copy_uc_from() doesn't really fit in the case for Vulkan is because some planes may be copied via other methods (such as mapping GPU memory), and if they don't satisfy the strict alignment requirements, a gpu image->gpu buffer->cpu ram copy is performed. We need this for hwcontext_vulkan, and I think this will also be useful to API users like libplacebo who would rather not write a custom SIMD memcpy. Patch attached. >From f4682c5fc135dc314f012c18ec63fccfb9a7380c Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 10 Aug 2021 12:38:49 +0200 Subject: [PATCH 1/2] imgutils: expose av_image_copy_plane_uc_from() The reason why the generic av_image_copy_uc_from() doesn't really fit in the case for Vulkan is because some planes may be copied via other methods (such as mapping GPU memory), and if they don't satisfy the strict alignment requirements, a gpu image->gpu buffer->cpu ram copy is performed. We need this for hwcontext_vulkan, and I think this will also be useful to API users like libplacebo who would rather not write a custom SIMD memcpy. --- doc/APIchanges | 3 +++ libavutil/imgutils.c | 8 libavutil/imgutils.h | 18 ++ libavutil/version.h | 2 +- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 6eefc7fc33..0367d39923 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-08-10 - xx - lavu 57.3.101 - imgutils.h + Add av_image_copy_plane_uc_from() + 2021-08-02 - xx - lavc 59.4.100 - packet.h Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base. diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 6c32a71cc5..9ab5757cf6 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -356,9 +356,9 @@ static void image_copy_plane(uint8_t *dst, ptrdiff_t dst_linesize, } } -static void image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize, - const uint8_t *src, ptrdiff_t src_linesize, - ptrdiff_t bytewidth, int height) +void av_image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize, + const uint8_t *src, ptrdiff_t src_linesize, + ptrdiff_t bytewidth, int height) { int ret = -1; @@ -440,7 +440,7 @@ void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4 enum AVPixelFormat pix_fmt, int width, int height) { image_copy(dst_data, dst_linesizes, src_data, src_linesizes, pix_fmt, - width, height, image_copy_plane_uc_from); + width, height, av_image_copy_plane_uc_from); } int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4], diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index 5eccbf0bf7..cb2d74728e 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -124,6 +124,24 @@ void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height); +/** + * Copy image data located in uncacheable (e.g. GPU mapped) memory. Where + * available, this function will use special functionality for reading from such + * memory, which may result in greatly improved performance compared to plain + * av_image_copy_plane(). + * + * bytewidth must be contained by both absolute values of dst_linesize + * and src_linesize, otherwise the function behavior is undefined. + * + * @note The linesize parameters have the type ptrdiff_t here, while they are + * int for av_image_copy_plane(). + * @note On x86, the linesizes currently need to be aligned to the cacheline + * size (i.e. 64) to get improved performance. + */ +void av_image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize, + const uint8_t *src, ptrdiff_t src_linesize, + ptrdiff_t bytewidth, int height); + /** * Copy image in src_data to dst_data. * diff --git a/libavutil/version.h b/libavutil/version.h index 6b4a265457..678cb9bfa6 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -80,7 +80,7 @@ #define LIBAVUTIL_VERSION_MAJOR 57 #define LIBAVUTIL_VERSION_MINOR 3 -#define LIBAVUTIL_VERSION_MICRO 100 +#define LIBAVUTIL_VERSION_MICRO 101 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ LIBAVUTIL_VERSION_MINOR, \ -- 2.32.0.272.g935e593368 ___ 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] hwcontext_vulkan: use GPU memcpy when copying to system RAM
This should speed it up significantly on systems where it matters. Patch attached. >From b904c881ba23230dc86d0d34d6de0649c8d9c0cc Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 10 Aug 2021 12:47:06 +0200 Subject: [PATCH 2/2] hwcontext_vulkan: use GPU memcpy when copying to system RAM This should speed it up significantly on systems where it matters. --- libavutil/hwcontext_vulkan.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index b7da6a7e32..92b2c236c8 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -3424,7 +3424,7 @@ static int vulkan_transfer_data(AVHWFramesContext *hwfc, const AVFrame *vkf, } if (!from) { -/* Map, copy image to buffer, unmap */ +/* Map, copy image from buffer, unmap */ if ((err = map_buffers(dev_ctx, bufs, tmp.data, planes, 0))) goto end; @@ -3434,10 +3434,10 @@ static int vulkan_transfer_data(AVHWFramesContext *hwfc, const AVFrame *vkf, get_plane_wh(&p_w, &p_h, swf->format, swf->width, swf->height, i); -av_image_copy_plane(tmp.data[i], tmp.linesize[i], -(const uint8_t *)swf->data[i], swf->linesize[i], -FFMIN(tmp.linesize[i], FFABS(swf->linesize[i])), -p_h); +av_image_copy_plane_uc_from(tmp.data[i], tmp.linesize[i], +(const uint8_t *)swf->data[i], swf->linesize[i], +FFMIN(tmp.linesize[i], FFABS(swf->linesize[i])), +p_h); } if ((err = unmap_buffers(dev_ctx, bufs, planes, 1))) -- 2.32.0.272.g935e593368 ___ 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/nvdec: Do not exceed 32 surfaces when initializing hw_frames_ctx
On 10.08.2021 04:37, Ameer J wrote: From: ameerj <52414509+ame...@users.noreply.github.com> nvdec is likely to fail when the initial pool size exceeds 32. This change ensures we don't exceed the limit when initializing a new hw_frames_ctx Signed-off-by: ameerj <52414509+ame...@users.noreply.github.com> --- libavcodec/nvdec.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c index 251be039a8..bef33dbae9 100644 --- a/libavcodec/nvdec.c +++ b/libavcodec/nvdec.c @@ -303,8 +303,10 @@ static int nvdec_init_hwframes(AVCodecContext *avctx, AVBufferRef **out_frames_r frames_ctx = (AVHWFramesContext*)(*out_frames_ref)->data; if (dummy) { -// Copied from ff_decode_get_hw_frames_ctx for compatibility -frames_ctx->initial_pool_size += 3; +// The function above guarantees 1 work surface, We must guarantee 4 work surfaces. +// (the absolute minimum), so add the missing count without exceeding the maximum +// recommended for nvdec. +frames_ctx->initial_pool_size = min(frames_ctx->initial_pool_size + 3, 32); Where does this min() function come from? frames_ctx->free = nvdec_free_dummy; frames_ctx->pool = av_buffer_pool_init(0, nvdec_alloc_dummy); So far, the 32 surface limit has only ever been enforced as a soft limit, and a warning printed when exceeded. Since it being a limit is not strictly documented and it might be risen in the future. Also, if the pool is limited in size, something is likely to fail due to that further down the chain. So I'm not sure if this is a better solution. smime.p7s Description: S/MIME Cryptographic Signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavcodec/nvdec: Do not exceed 32 surfaces when initializing hw_frames_ctx
On Tue, 10 Aug 2021 at 15:04, Timo Rothenpieler wrote: > On 10.08.2021 04:37, Ameer J wrote: > > From: ameerj <52414509+ame...@users.noreply.github.com> > > > > nvdec is likely to fail when the initial pool size exceeds 32. This > change ensures we don't exceed the limit when initializing a new > hw_frames_ctx > > > > Signed-off-by: ameerj <52414509+ame...@users.noreply.github.com> > > --- > > libavcodec/nvdec.c | 6 -- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c > > index 251be039a8..bef33dbae9 100644 > > --- a/libavcodec/nvdec.c > > +++ b/libavcodec/nvdec.c > > @@ -303,8 +303,10 @@ static int nvdec_init_hwframes(AVCodecContext > *avctx, AVBufferRef **out_frames_r > > frames_ctx = (AVHWFramesContext*)(*out_frames_ref)->data; > > > > if (dummy) { > > -// Copied from ff_decode_get_hw_frames_ctx for compatibility > > -frames_ctx->initial_pool_size += 3; > > +// The function above guarantees 1 work surface, We must > guarantee 4 work surfaces. > > +// (the absolute minimum), so add the missing count without > exceeding the maximum > > +// recommended for nvdec. > > +frames_ctx->initial_pool_size = > min(frames_ctx->initial_pool_size + 3, 32); > > Where does this min() function come from? > > > frames_ctx->free = nvdec_free_dummy; > > frames_ctx->pool = av_buffer_pool_init(0, nvdec_alloc_dummy); > > > > So far, the 32 surface limit has only ever been enforced as a soft > limit, and a warning printed when exceeded. Since it being a limit is > not strictly documented and it might be risen in the future. > > Also, if the pool is limited in size, something is likely to fail due to > that further down the chain. > So I'm not sure if this is a better solution. Related, Can the pool surface setting be made configurable? The older CUVID based wrappers expose it as an option (via -surfaces) as does the NVENC encoder wrapper implementation. This would be useful in cases where lower VRAM foot print is required (for multiple transcodes on the same GPU) and at the same time, tunable enough to prevent downstream failures if surfaces are insufficient. > ___ 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] avcodec/h264_picture: split copying some H264Picture fields into a separate function
On 8/8/2021 7:56 PM, James Almer wrote: Signed-off-by: James Almer --- libavcodec/h264_picture.c | 57 ++- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c index eec5e9fb9a..89aef37edd 100644 --- a/libavcodec/h264_picture.c +++ b/libavcodec/h264_picture.c @@ -63,6 +63,38 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic) memset((uint8_t*)pic + off, 0, sizeof(*pic) - off); } Will apply set. ___ 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/h264_slice: clear old slice POC values on parsing failure
On 8/8/2021 3:38 PM, James Almer wrote: If a slice header fails to parse, and the next one uses different Sequence and Picture parameter sets, certain values may not be read if they are not coded, resulting in the previous slice values being used. Signed-off-by: James Almer --- libavcodec/h264_slice.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 41338fbcb6..a31e804620 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1897,6 +1897,8 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, if (nal->type == H264_NAL_IDR_SLICE) get_ue_golomb_long(&sl->gb); /* idr_pic_id */ +sl->poc_lsb = 0; +sl->delta_poc_bottom = 0; if (sps->poc_type == 0) { sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); @@ -1904,6 +1906,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, sl->delta_poc_bottom = get_se_golomb(&sl->gb); } +sl->delta_poc[0] = sl->delta_poc[1] = 0; if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) { sl->delta_poc[0] = get_se_golomb(&sl->gb); Will apply. ___ 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] avcodec/cbs: add a helper to read extradata within packet side data
On 8/5/2021 12:24 PM, James Almer wrote: Using ff_cbs_read() on the raw buffer will not parse it as extradata, resulting in parsing errors for example when handling ISOBMFF avcC. This helper works around that. Signed-off-by: James Almer --- libavcodec/cbs.c | 13 + libavcodec/cbs.h | 4 2 files changed, 17 insertions(+) diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c index 8d50ea1432..f6e371ddef 100644 --- a/libavcodec/cbs.c +++ b/libavcodec/cbs.c @@ -294,6 +294,19 @@ int ff_cbs_read_packet(CodedBitstreamContext *ctx, pkt->data, pkt->size, 0); } +int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVPacket *pkt) +{ +size_t side_data_size; +const uint8_t *side_data = +av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, +&side_data_size); + +return cbs_read_data(ctx, frag, NULL, + side_data, side_data_size, 1); +} + int ff_cbs_read(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const uint8_t *data, size_t size) diff --git a/libavcodec/cbs.h b/libavcodec/cbs.h index b7acf98347..bd97d163b1 100644 --- a/libavcodec/cbs.h +++ b/libavcodec/cbs.h @@ -276,6 +276,10 @@ int ff_cbs_read_extradata_from_codec(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, const struct AVCodecContext *avctx); +int ff_cbs_read_packet_side_data(CodedBitstreamContext *ctx, + CodedBitstreamFragment *frag, + const AVPacket *pkt); + /** * Read the data bitstream from a packet into a fragment, then * split into units and decompose. Will apply set. ___ 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] Mail quoting (was: 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time)
On Tue, Aug 10, 2021 at 09:47:31AM +, Soft Works wrote: > > > > -Original Message- > > From: ffmpeg-devel On Behalf Of > > Nicolas George > > Sent: Tuesday, 10 August 2021 11:16 > > To: FFmpeg development discussions and patches > de...@ffmpeg.org> > > Subject: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add > > capability > > to prefix loglines with current time or current date+time) > > > > Soft Works (12021-08-10): > > > I meant the e-mail body of the previous conversation. > > > > Well, it is my mail, I put what I want in it, and you do what you want with > > yours. > > > > But ask yourself: which one do you find easier to read: one where you have > > to scroll half a dozen pages of old mail just to get to the new bits, or one > > where you have enough quoted context to remember what the discussion is > > about but not too much? > > > > For me, the answer is the second, and since I prefer this for myself > > Totally agree. > > > I have toe > > courtesy to do the same for the mails I send, even if it takes a few more > > keystrokes. A lot of people do not bother, > > Yes, that made me wonder whether shortening would be against any rule or > guideline. > > One of the most annoying things with that mailing-list-style development > is the requirement to scroll through every single message of concern > while trying to spot all lines that do not have a '> ' prefix. As some do not > even put a blank line before and after a comment, you cannot rely on that, > meaning that you have to look very carefully while scrolling. if your MUA doesnt color the text to make it easy, maybe you should consider a different MUA for example mutt can color code text based on how many ">" are there at the begin in fact mutt lets you write your own rules for how to color the mails I would assume any half decent MUA should be able to do something similar Thanks [...] -- 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] Mail quoting (was: libavutil/log: Add capability to prefix loglines with current time or current date+time)
Michael Niedermayer (12021-08-10): > if your MUA doesnt color the text to make it easy, > maybe you should consider a different MUA This is good advice in this specific instance, but I would not consider it an excuse for myself not to properly trim the replies I make, on the principle that I should not demand many people to change their habits just to accommodate mine. A little effort by one person is better than a tiny effort by many. > for example mutt can color code text based on how many ">" are there at the > begin > in fact mutt lets you write your own rules for how to color the mails > I would assume any half decent MUA should be able to do something similar Mutt also has a short-cut (S by default) to skip until the first line of non-quoted text. It is a life-saver when you all do not trim your mails. Regards, -- Nicolas George signature.asc Description: PGP signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time)
> -Original Message- > From: ffmpeg-devel On Behalf Of Michael > Niedermayer > Sent: Tuesday, 10 August 2021 16:03 > To: FFmpeg development discussions and patches > Subject: Re: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add > capability to prefix loglines with current time or current date+time) > > On Tue, Aug 10, 2021 at 09:47:31AM +, Soft Works wrote: > > > > > > > -Original Message- > > > From: ffmpeg-devel On Behalf Of > > > Nicolas George > > > Sent: Tuesday, 10 August 2021 11:16 > > > To: FFmpeg development discussions and patches > > de...@ffmpeg.org> > > > Subject: [FFmpeg-devel] Mail quoting (was: 1/2] libavutil/log: Add > capability > > > to prefix loglines with current time or current date+time) > > > > > > Soft Works (12021-08-10): > > > > I meant the e-mail body of the previous conversation. > > > > > > Well, it is my mail, I put what I want in it, and you do what you want > with > > > yours. > > > > > > But ask yourself: which one do you find easier to read: one where you > have > > > to scroll half a dozen pages of old mail just to get to the new bits, > or one > > > where you have enough quoted context to remember what the discussion > is > > > about but not too much? > > > > > > For me, the answer is the second, and since I prefer this for myself > > > > Totally agree. > > > > > I have toe > > > courtesy to do the same for the mails I send, even if it takes a few > more > > > keystrokes. A lot of people do not bother, > > > > Yes, that made me wonder whether shortening would be against any rule or > > guideline. > > > > One of the most annoying things with that mailing-list-style development > > is the requirement to scroll through every single message of concern > > while trying to spot all lines that do not have a '> ' prefix. As some > do not > > even put a blank line before and after a comment, you cannot rely on > that, > > meaning that you have to look very carefully while scrolling. > > if your MUA doesnt color the text to make it easy, > maybe you should consider a different MUA > for example mutt can color code text based on how many ">" are there at > the begin > in fact mutt lets you write your own rules for how to color the mails > I would assume any half decent MUA should be able to do something similar Thanks a lot for your suggestion. I have no doubt that for that specific task a different mail client would be better than Outlook. But it would fail to fulfill many of the other requirements that I have, including extensions that I've developed that allow me to integrate my e-mail processing with other programs and automate certain tasks. Kind regards, softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] Mail quoting (was: libavutil/log: Add capability to prefix loglines with current time or current date+time)
> -Original Message- > From: ffmpeg-devel On Behalf Of Nicolas > George > Sent: Tuesday, 10 August 2021 16:28 > To: FFmpeg development discussions and patches > Subject: Re: [FFmpeg-devel] Mail quoting (was: libavutil/log: Add > capability to prefix loglines with current time or current date+time) > > Michael Niedermayer (12021-08-10): > > if your MUA doesnt color the text to make it easy, > > maybe you should consider a different MUA > > This is good advice in this specific instance, but I would not consider > it an excuse for myself not to properly trim the replies I make, on the > principle that I should not demand many people to change their habits > just to accommodate mine. > > A little effort by one person is better than a tiny effort by many. > > > for example mutt can color code text based on how many ">" are there at > the begin > > in fact mutt lets you write your own rules for how to color the mails > > I would assume any half decent MUA should be able to do something > similar > > Mutt also has a short-cut (S by default) to skip until the first line of > non-quoted text. It is a life-saver when you all do not trim your mails. I knew you must have some "tricks" in place :-) softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2] configure: [loongson] adjust MMI check in configure
On Tue, Aug 10, 2021 at 05:01:13PM +0800, 金波 wrote: > Ping. will apply thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Nations do behave wisely once they have exhausted all other alternatives. -- Abba Eban 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] [RFC] Suggestion for a Nicer Integration with GitHub
Hi, A while ago there was a discussion about moving forward and migrating the ffmpeg development process from the mailing list to another platform (like GitLab). That discussion had died without further results and an important takeaway for me was that there are just too many that love this way of interaction and operation and would argue till the end of time against such changes. That’s not meant as a kind of criticism, just an assessment. There a those and those people with different preferences and no doubt that others, who are preferring a more modern and integrated approach like GitHub provides, would be as much rejective when told about having to switch to a mailing list based process. But without doubt, a lot more developers could be attracted to participate in ffmpeg development when it would be accessible in a way like many developers are used to work these days. The ffmpeg mirror on GitHub has 354 PR’s (25k stars, 8k forks!) even though that there’s a big and clear warning shown that PRs won’t be accepted this way. I wonder how many PRs might get submitted once we could actually accept PRs from there. My conclusion from the recent discussion was, that the only way to make a change that could find a larger base of agreement would be a solution that doesn’t make a change at all. What I mean by that is: no moving of the repository, no migration to another platform, no replacement of the mailing-list and leaving everything working as-is. Instead, just add something on-top of it that will allow all those “others” to better accommodate with ffmpeg development. I had the idea to build some synchronization between Patchwork and GitHub in a way that it would mirror submitted patches as GitHub pull requests, I didn’t have the time to get on it. Just recently, I discovered a very interesting project: https://gitgitgadget.github.io/ This is all about the development of Git itself, which is done via mailing list and they had the same problem, namely developers that could never be convinced of using GitHub instead of the mailing list. That’s how GitGitGadget came to life: https://github.com/gitgitgadget/gitgitgadget/blob/main/DESIGN.md Now my suggestion – obviously – is: Adapt the GitGitGadget implementation and employ it for ffmpeg development. Please let me know what you think about it. softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] avcodec/h264_slice: clear old slice POC values on parsing failure
James Almer: > If a slice header fails to parse, and the next one uses different Sequence and > Picture parameter sets, certain values may not be read if they are not coded, > resulting in the previous slice values being used. > > Signed-off-by: James Almer > --- > libavcodec/h264_slice.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c > index 41338fbcb6..a31e804620 100644 > --- a/libavcodec/h264_slice.c > +++ b/libavcodec/h264_slice.c > @@ -1897,6 +1897,8 @@ static int h264_slice_header_parse(const H264Context > *h, H264SliceContext *sl, > if (nal->type == H264_NAL_IDR_SLICE) > get_ue_golomb_long(&sl->gb); /* idr_pic_id */ > > +sl->poc_lsb = 0; > +sl->delta_poc_bottom = 0; > if (sps->poc_type == 0) { > sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); > > @@ -1904,6 +1906,7 @@ static int h264_slice_header_parse(const H264Context > *h, H264SliceContext *sl, > sl->delta_poc_bottom = get_se_golomb(&sl->gb); > } > > +sl->delta_poc[0] = sl->delta_poc[1] = 0; > if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) { > sl->delta_poc[0] = get_se_golomb(&sl->gb); > > Does this patch actually change anything when all SPS use pic_ordering_cnt_type 0? - 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/h264_slice: clear old slice POC values on parsing failure
On 8/10/2021 12:04 PM, Andreas Rheinhardt wrote: James Almer: If a slice header fails to parse, and the next one uses different Sequence and Picture parameter sets, certain values may not be read if they are not coded, resulting in the previous slice values being used. Signed-off-by: James Almer --- libavcodec/h264_slice.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 41338fbcb6..a31e804620 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -1897,6 +1897,8 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, if (nal->type == H264_NAL_IDR_SLICE) get_ue_golomb_long(&sl->gb); /* idr_pic_id */ +sl->poc_lsb = 0; +sl->delta_poc_bottom = 0; if (sps->poc_type == 0) { sl->poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); @@ -1904,6 +1906,7 @@ static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, sl->delta_poc_bottom = get_se_golomb(&sl->gb); } +sl->delta_poc[0] = sl->delta_poc[1] = 0; if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) { sl->delta_poc[0] = get_se_golomb(&sl->gb); Does this patch actually change anything when all SPS use pic_ordering_cnt_type 0? No, all these fields are zero initialized by the decoder, and inferred to 0 when not present. - 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 1/2] imgutils: expose av_image_copy_plane_uc_from()
Lynne: > diff --git a/libavutil/version.h b/libavutil/version.h > index 6b4a265457..678cb9bfa6 100644 > --- a/libavutil/version.h > +++ b/libavutil/version.h > @@ -80,7 +80,7 @@ > > #define LIBAVUTIL_VERSION_MAJOR 57 > #define LIBAVUTIL_VERSION_MINOR 3 > -#define LIBAVUTIL_VERSION_MICRO 100 > +#define LIBAVUTIL_VERSION_MICRO 101 > > #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ > LIBAVUTIL_VERSION_MINOR, \ An new function always needs a minor bump. - 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/faxcompr: Check for end of input in cmode == 1 in decode_group3_2d_line()
On Sat, Jul 31, 2021 at 09:26:49PM +0200, Michael Niedermayer wrote: > Fixes: Infinite loop > Fixes: > 35591/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4503764022198272 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/faxcompr.c | 2 ++ > 1 file changed, 2 insertions(+) will apply [...] -- 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 1/3] avcodec/sbrdsp_fixed: Fix negation overflow in sbr_neg_odd_64_c()
On Sat, Jul 31, 2021 at 07:48:42PM +0200, Michael Niedermayer wrote: > Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to > an unsigned type to negate this value to itself > Fixes: > 35593/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AAC_FIXED_fuzzer-5182217725804544 > > Found-by: continuous fuzzing process > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg > Signed-off-by: Michael Niedermayer > --- > libavcodec/sbrdsp_fixed.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) will apply patchset [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes 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 v5 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
Soft Works: > Signed-off-by: softworkz > --- > doc/APIchanges | 3 +++ > libavutil/log.c | 35 ++- > libavutil/log.h | 10 ++ > libavutil/version.h | 2 +- > 4 files changed, 44 insertions(+), 6 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index 6eefc7fc33..be707314f3 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -14,6 +14,9 @@ libavutil: 2021-04-27 > > API changes, most recent first: > > +2021-08-09 - xx - lavu 57.4.100 - log.h > + Add new defines: AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME Add new logging flags > + > 2021-08-02 - xx - lavc 59.4.100 - packet.h >Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base. > > diff --git a/libavutil/log.c b/libavutil/log.c > index 66defa9c42..34af1da60c 100644 > --- a/libavutil/log.c > +++ b/libavutil/log.c > static void format_line(void *avcl, int level, const char *fmt, va_list vl, > -AVBPrint part[4], int *print_prefix, int type[2]) > +AVBPrint part[5], int *print_prefix, int type[2]) > { > -AVClass* avc = avcl ? *(AVClass **) avcl : NULL; > +AVClass *avc = avcl ? *(AVClass **) avcl : NULL; > av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC); > av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC); > av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC); > av_bprint_init(part+3, 0, 65536); > +av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC); > > if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16; > if (*print_prefix && avc) { > if (avc->parent_log_context_offset) { > -AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) + > +AVClass **parent = *(AVClass ***) (((uint8_t *) avcl) + Nicolas wanted you to not add new code with the * not attached to the variable; he did not ask you to change existing code in the same patch. Spurious changes are frowned upon, as they impair reviewability. > avc->parent_log_context_offset); > if (parent && *parent) { > av_bprintf(part+0, "[%s @ %p] ", - 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 1/2] imgutils: expose av_image_copy_plane_uc_from()
10 Aug 2021, 17:29 by andreas.rheinha...@outlook.com: > Lynne: > >> diff --git a/libavutil/version.h b/libavutil/version.h >> >> index 6b4a265457..678cb9bfa6 100644 >> >> --- a/libavutil/version.h >> >> +++ b/libavutil/version.h >> >> @@ -80,7 +80,7 @@ >> >> >> >> #define LIBAVUTIL_VERSION_MAJOR 57 >> >> #define LIBAVUTIL_VERSION_MINOR 3 >> >> -#define LIBAVUTIL_VERSION_MICRO 100 >> >> +#define LIBAVUTIL_VERSION_MICRO 101 >> >> >> >> #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ >> >> LIBAVUTIL_VERSION_MINOR, \ >> > > An new function always needs a minor bump. > > - Andreas > Thanks, changed locally to a minor bump instead. ___ 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 v5 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
> -Original Message- > From: ffmpeg-devel On Behalf Of Andreas > Rheinhardt > Sent: Tuesday, 10 August 2021 17:33 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v5 1/2] libavutil/log: Add capability > to prefix loglines with current time or current date+time > > Soft Works: > > Signed-off-by: softworkz > > --- > > doc/APIchanges | 3 +++ > > libavutil/log.c | 35 ++- > > libavutil/log.h | 10 ++ > > libavutil/version.h | 2 +- > > 4 files changed, 44 insertions(+), 6 deletions(-) > > > > diff --git a/libavutil/log.c b/libavutil/log.c > > index 66defa9c42..34af1da60c 100644 > > --- a/libavutil/log.c > > +++ b/libavutil/log.c > > static void format_line(void *avcl, int level, const char *fmt, va_list > vl, > > -AVBPrint part[4], int *print_prefix, int > type[2]) > > +AVBPrint part[5], int *print_prefix, int > type[2]) > > { > > -AVClass* avc = avcl ? *(AVClass **) avcl : NULL; > > +AVClass *avc = avcl ? *(AVClass **) avcl : NULL; > > av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC); > > av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC); > > av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC); > > av_bprint_init(part+3, 0, 65536); > > +av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC); > > > > if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16; > > if (*print_prefix && avc) { > > if (avc->parent_log_context_offset) { > > -AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) + > > +AVClass **parent = *(AVClass ***) (((uint8_t *) avcl) + > > Nicolas wanted you to not add new code with the * not attached to the > variable; he did not ask you to change existing code in the same patch. > Spurious changes are frowned upon, as they impair reviewability. Updated. Time's too precious to start arguing about such things... softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v6 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
Signed-off-by: softworkz --- doc/APIchanges | 3 +++ libavutil/log.c | 33 + libavutil/log.h | 10 ++ libavutil/version.h | 2 +- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 6eefc7fc33..e64f34d677 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-08-09 - xx - lavu 57.4.100 - log.h + Add new logging flags: AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME + 2021-08-02 - xx - lavc 59.4.100 - packet.h Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base. diff --git a/libavutil/log.c b/libavutil/log.c index 66defa9c42..36dd5759ae 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -40,6 +40,8 @@ #include "internal.h" #include "log.h" #include "thread.h" +#include "time.h" +#include "time_internal.h" static AVMutex mutex = AV_MUTEX_INITIALIZER; @@ -289,14 +291,31 @@ static const char *get_level_str(int level) } } +static void format_date_now(AVBPrint *timeBuf, int include_date) +{ +struct tm *ptm, tmbuf; +const int64_t time_ms = av_gettime() / 1000; +const time_t time_s = time_ms / 1000; +const int millisec = time_ms % 1000; +ptm = localtime_r(&time_s, &tmbuf); +if (ptm) { +if (include_date) +av_bprint_strftime(timeBuf, "%Y-%m-%d ", ptm); + +av_bprint_strftime(timeBuf, "%H:%M:%S", ptm); +av_bprintf(timeBuf, ".%03d ", millisec); +} +} + static void format_line(void *avcl, int level, const char *fmt, va_list vl, -AVBPrint part[4], int *print_prefix, int type[2]) +AVBPrint part[5], int *print_prefix, int type[2]) { -AVClass* avc = avcl ? *(AVClass **) avcl : NULL; +AVClass *avc = avcl ? *(AVClass **) avcl : NULL; av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(part+3, 0, 65536); +av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC); if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16; if (*print_prefix && avc) { @@ -314,6 +333,10 @@ static void format_line(void *avcl, int level, const char *fmt, va_list vl, if(type) type[1] = get_category(avcl); } +if (*print_prefix +&& (flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME))) +format_date_now(&part[4], flags & AV_LOG_PRINT_DATETIME); + if (*print_prefix && (level > AV_LOG_QUIET) && (flags & AV_LOG_PRINT_LEVEL)) av_bprintf(part+2, "[%s] ", get_level_str(level)); @@ -334,7 +357,7 @@ void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix) { -AVBPrint part[4]; +AVBPrint part[5]; int ret; format_line(ptr, level, fmt, vl, part, print_prefix, NULL); @@ -348,7 +371,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) static int print_prefix = 1; static int count; static char prev[LINE_SZ]; -AVBPrint part[4]; +AVBPrint part[5]; char line[LINE_SZ]; static int is_atty; int type[2]; @@ -383,6 +406,8 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) count = 0; } strcpy(prev, line); + +colored_fputs(7, 0, part[4].str); sanitize(part[0].str); colored_fputs(type[0], 0, part[0].str); sanitize(part[1].str); diff --git a/libavutil/log.h b/libavutil/log.h index 8727c38afc..b071f0f1eb 100644 --- a/libavutil/log.h +++ b/libavutil/log.h @@ -377,6 +377,16 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, */ #define AV_LOG_PRINT_LEVEL 2 +/** + * Include local time in log output. + */ +#define AV_LOG_PRINT_TIME 4 + +/** + * Include local date and time in log output. + */ +#define AV_LOG_PRINT_DATETIME 8 + void av_log_set_flags(int arg); int av_log_get_flags(void); diff --git a/libavutil/version.h b/libavutil/version.h index 6b4a265457..201b012596 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 3 +#define LIBAVUTIL_VERSION_MINOR 4 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v6 2/2] fftools: Add option to log timing
This commit adds two logging flags: 'timing' and 'datetiming'. Usage: ffmpeg -loglevel +timing or ffmpeg -loglevel +datetiming Signed-off-by: softworkz --- doc/fftools-common-opts.texi | 4 fftools/cmdutils.c | 21 + fftools/ffmpeg.c | 6 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi index 7643dd8396..aae26c28d0 100644 --- a/doc/fftools-common-opts.texi +++ b/doc/fftools-common-opts.texi @@ -198,6 +198,10 @@ and the "Last message repeated n times" line will be omitted. Indicates that log output should add a @code{[level]} prefix to each message line. This can be used as an alternative to log coloring, e.g. when dumping the log to file. +@item time +Prefixes each log line with the local time. +@item datetime +Same as time but also prints the current date in each line. @end table Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single flag without affecting other @var{flags} or changing @var{loglevel}. When diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 912e881174..7918078766 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -918,6 +918,27 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg) flags |= AV_LOG_PRINT_LEVEL; } arg = token + 5; +} else if (av_strstart(token, "time", NULL)) { +if (cmd == '-') { +flags &= ~AV_LOG_PRINT_TIME; +} else { +flags |= AV_LOG_PRINT_TIME; +} +arg = token + 4; +} else if (av_strstart(token, "timing", NULL)) { +if (cmd == '-') { +flags &= ~AV_LOG_PRINT_TIME; +} else { +flags |= AV_LOG_PRINT_TIME; +} +arg = token + 6; +} else if (av_strstart(token, "datetime", NULL)) { +if (cmd == '-') { +flags &= ~AV_LOG_PRINT_DATETIME; +} else { +flags |= AV_LOG_PRINT_DATETIME; +} +arg = token + 8; } else { break; } diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index b0ce7c7c32..b0b105be1c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4983,7 +4983,7 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl) int main(int argc, char **argv) { -int i, ret; +int i, ret, log_flags; BenchmarkTimeStamps ti; init_dynload(); @@ -5049,6 +5049,10 @@ int main(int argc, char **argv) if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < decode_error_stat[1]) exit_program(69); +log_flags = av_log_get_flags(); +if (log_flags & AV_LOG_PRINT_TIME || log_flags & AV_LOG_PRINT_DATETIME) +av_log(NULL, AV_LOG_INFO, "\n"); /* end with line break to avoid mixing up with shell prompt */ + exit_program(received_nb_signals ? 255 : main_return_code); return main_return_code; } -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] libavformat/file.c: 'file_delete()' and 'file_move()' require 'CONFIG_FILE_PROTOCOL'
This quashes 2 warnings when the 'file' protocol is not enabled. --- libavformat/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/file.c b/libavformat/file.c index 8303436be0..9c23f680cd 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -167,6 +167,8 @@ static int file_check(URLContext *h, int mask) return ret; } +#if CONFIG_FILE_PROTOCOL + static int file_delete(URLContext *h) { #if HAVE_UNISTD_H @@ -203,8 +205,6 @@ static int file_move(URLContext *h_src, URLContext *h_dst) return 0; } -#if CONFIG_FILE_PROTOCOL - static int file_open(URLContext *h, const char *filename, int flags) { FileContext *c = h->priv_data; -- 2.22.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 v6 2/2] fftools: Add option to log timing
10 Aug 2021, 18:12 by softwo...@hotmail.com: > This commit adds two logging flags: 'timing' and 'datetiming'. > > Usage: > > ffmpeg -loglevel +timing > > or > > ffmpeg -loglevel +datetiming > 'timing'? 'datetiming'? Just name them 'time' and 'datetime'. ___ 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_scale: Avoid unnecessary indirection
Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_scale.c | 42 +- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index aa855b894a..160ad8b584 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -530,31 +530,31 @@ static int config_props(AVFilterLink *outlink) for (i = 0; i < 3; i++) { int in_v_chr_pos = scale->in_v_chr_pos, out_v_chr_pos = scale->out_v_chr_pos; -struct SwsContext **s = swscs[i]; -*s = sws_alloc_context(); -if (!*s) +struct SwsContext *const s = sws_alloc_context(); +if (!s) return AVERROR(ENOMEM); - -av_opt_set_int(*s, "srcw", inlink0 ->w, 0); -av_opt_set_int(*s, "srch", inlink0 ->h >> !!i, 0); -av_opt_set_int(*s, "src_format", inlink0->format, 0); -av_opt_set_int(*s, "dstw", outlink->w, 0); -av_opt_set_int(*s, "dsth", outlink->h >> !!i, 0); -av_opt_set_int(*s, "dst_format", outfmt, 0); -av_opt_set_int(*s, "sws_flags", scale->flags, 0); -av_opt_set_int(*s, "param0", scale->param[0], 0); -av_opt_set_int(*s, "param1", scale->param[1], 0); +*swscs[i] = s; + +av_opt_set_int(s, "srcw", inlink0 ->w, 0); +av_opt_set_int(s, "srch", inlink0 ->h >> !!i, 0); +av_opt_set_int(s, "src_format", inlink0->format, 0); +av_opt_set_int(s, "dstw", outlink->w, 0); +av_opt_set_int(s, "dsth", outlink->h >> !!i, 0); +av_opt_set_int(s, "dst_format", outfmt, 0); +av_opt_set_int(s, "sws_flags", scale->flags, 0); +av_opt_set_int(s, "param0", scale->param[0], 0); +av_opt_set_int(s, "param1", scale->param[1], 0); if (scale->in_range != AVCOL_RANGE_UNSPECIFIED) -av_opt_set_int(*s, "src_range", +av_opt_set_int(s, "src_range", scale->in_range == AVCOL_RANGE_JPEG, 0); if (scale->out_range != AVCOL_RANGE_UNSPECIFIED) -av_opt_set_int(*s, "dst_range", +av_opt_set_int(s, "dst_range", scale->out_range == AVCOL_RANGE_JPEG, 0); if (scale->opts) { AVDictionaryEntry *e = NULL; while ((e = av_dict_get(scale->opts, "", e, AV_DICT_IGNORE_SUFFIX))) { -if ((ret = av_opt_set(*s, e->key, e->value, 0)) < 0) +if ((ret = av_opt_set(s, e->key, e->value, 0)) < 0) return ret; } } @@ -569,12 +569,12 @@ static int config_props(AVFilterLink *outlink) out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; } -av_opt_set_int(*s, "src_h_chr_pos", scale->in_h_chr_pos, 0); -av_opt_set_int(*s, "src_v_chr_pos", in_v_chr_pos, 0); -av_opt_set_int(*s, "dst_h_chr_pos", scale->out_h_chr_pos, 0); -av_opt_set_int(*s, "dst_v_chr_pos", out_v_chr_pos, 0); +av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0); +av_opt_set_int(s, "src_v_chr_pos", in_v_chr_pos, 0); +av_opt_set_int(s, "dst_h_chr_pos", scale->out_h_chr_pos, 0); +av_opt_set_int(s, "dst_v_chr_pos", out_v_chr_pos, 0); -if ((ret = sws_init_context(*s, NULL, NULL)) < 0) +if ((ret = sws_init_context(s, NULL, NULL)) < 0) return ret; if (!scale->interlaced) break; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v6 2/2] fftools: Add option to log timing
> -Original Message- > From: ffmpeg-devel On Behalf Of > Lynne > Sent: Tuesday, 10 August 2021 19:07 > To: FFmpeg development discussions and patches de...@ffmpeg.org> > Subject: Re: [FFmpeg-devel] [PATCH v6 2/2] fftools: Add option to log > timing > > 10 Aug 2021, 18:12 by softwo...@hotmail.com: > > > This commit adds two logging flags: 'timing' and 'datetiming'. > > > > Usage: > > > > ffmpeg -loglevel +timing > > > > or > > > > ffmpeg -loglevel +datetiming > > > > 'timing'? 'datetiming'? Just name them 'time' and 'datetime'. Already changed that. Just forgot to update the commit message.. sw ___ 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 v7 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
Signed-off-by: softworkz --- doc/APIchanges | 3 +++ libavutil/log.c | 33 + libavutil/log.h | 10 ++ libavutil/version.h | 2 +- 4 files changed, 43 insertions(+), 5 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 6eefc7fc33..e64f34d677 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-08-09 - xx - lavu 57.4.100 - log.h + Add new logging flags: AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME + 2021-08-02 - xx - lavc 59.4.100 - packet.h Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base. diff --git a/libavutil/log.c b/libavutil/log.c index 66defa9c42..36dd5759ae 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -40,6 +40,8 @@ #include "internal.h" #include "log.h" #include "thread.h" +#include "time.h" +#include "time_internal.h" static AVMutex mutex = AV_MUTEX_INITIALIZER; @@ -289,14 +291,31 @@ static const char *get_level_str(int level) } } +static void format_date_now(AVBPrint *timeBuf, int include_date) +{ +struct tm *ptm, tmbuf; +const int64_t time_ms = av_gettime() / 1000; +const time_t time_s = time_ms / 1000; +const int millisec = time_ms % 1000; +ptm = localtime_r(&time_s, &tmbuf); +if (ptm) { +if (include_date) +av_bprint_strftime(timeBuf, "%Y-%m-%d ", ptm); + +av_bprint_strftime(timeBuf, "%H:%M:%S", ptm); +av_bprintf(timeBuf, ".%03d ", millisec); +} +} + static void format_line(void *avcl, int level, const char *fmt, va_list vl, -AVBPrint part[4], int *print_prefix, int type[2]) +AVBPrint part[5], int *print_prefix, int type[2]) { -AVClass* avc = avcl ? *(AVClass **) avcl : NULL; +AVClass *avc = avcl ? *(AVClass **) avcl : NULL; av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC); av_bprint_init(part+3, 0, 65536); +av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC); if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16; if (*print_prefix && avc) { @@ -314,6 +333,10 @@ static void format_line(void *avcl, int level, const char *fmt, va_list vl, if(type) type[1] = get_category(avcl); } +if (*print_prefix +&& (flags & (AV_LOG_PRINT_TIME | AV_LOG_PRINT_DATETIME))) +format_date_now(&part[4], flags & AV_LOG_PRINT_DATETIME); + if (*print_prefix && (level > AV_LOG_QUIET) && (flags & AV_LOG_PRINT_LEVEL)) av_bprintf(part+2, "[%s] ", get_level_str(level)); @@ -334,7 +357,7 @@ void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix) { -AVBPrint part[4]; +AVBPrint part[5]; int ret; format_line(ptr, level, fmt, vl, part, print_prefix, NULL); @@ -348,7 +371,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) static int print_prefix = 1; static int count; static char prev[LINE_SZ]; -AVBPrint part[4]; +AVBPrint part[5]; char line[LINE_SZ]; static int is_atty; int type[2]; @@ -383,6 +406,8 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) count = 0; } strcpy(prev, line); + +colored_fputs(7, 0, part[4].str); sanitize(part[0].str); colored_fputs(type[0], 0, part[0].str); sanitize(part[1].str); diff --git a/libavutil/log.h b/libavutil/log.h index 8727c38afc..b071f0f1eb 100644 --- a/libavutil/log.h +++ b/libavutil/log.h @@ -377,6 +377,16 @@ int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, */ #define AV_LOG_PRINT_LEVEL 2 +/** + * Include local time in log output. + */ +#define AV_LOG_PRINT_TIME 4 + +/** + * Include local date and time in log output. + */ +#define AV_LOG_PRINT_DATETIME 8 + void av_log_set_flags(int arg); int av_log_get_flags(void); diff --git a/libavutil/version.h b/libavutil/version.h index 6b4a265457..201b012596 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 57 -#define LIBAVUTIL_VERSION_MINOR 3 +#define LIBAVUTIL_VERSION_MINOR 4 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH v7 2/2] fftools: Add option to log timing
This commit adds two logging flags: 'time' and 'datetime'. Usage: ffmpeg -loglevel +time or ffmpeg -loglevel +datetime Signed-off-by: softworkz --- doc/fftools-common-opts.texi | 4 fftools/cmdutils.c | 21 + fftools/ffmpeg.c | 6 +- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi index 7643dd8396..aae26c28d0 100644 --- a/doc/fftools-common-opts.texi +++ b/doc/fftools-common-opts.texi @@ -198,6 +198,10 @@ and the "Last message repeated n times" line will be omitted. Indicates that log output should add a @code{[level]} prefix to each message line. This can be used as an alternative to log coloring, e.g. when dumping the log to file. +@item time +Prefixes each log line with the local time. +@item datetime +Same as time but also prints the current date in each line. @end table Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single flag without affecting other @var{flags} or changing @var{loglevel}. When diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 912e881174..7918078766 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -918,6 +918,27 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg) flags |= AV_LOG_PRINT_LEVEL; } arg = token + 5; +} else if (av_strstart(token, "time", NULL)) { +if (cmd == '-') { +flags &= ~AV_LOG_PRINT_TIME; +} else { +flags |= AV_LOG_PRINT_TIME; +} +arg = token + 4; +} else if (av_strstart(token, "timing", NULL)) { +if (cmd == '-') { +flags &= ~AV_LOG_PRINT_TIME; +} else { +flags |= AV_LOG_PRINT_TIME; +} +arg = token + 6; +} else if (av_strstart(token, "datetime", NULL)) { +if (cmd == '-') { +flags &= ~AV_LOG_PRINT_DATETIME; +} else { +flags |= AV_LOG_PRINT_DATETIME; +} +arg = token + 8; } else { break; } diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index b0ce7c7c32..b0b105be1c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4983,7 +4983,7 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl) int main(int argc, char **argv) { -int i, ret; +int i, ret, log_flags; BenchmarkTimeStamps ti; init_dynload(); @@ -5049,6 +5049,10 @@ int main(int argc, char **argv) if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < decode_error_stat[1]) exit_program(69); +log_flags = av_log_get_flags(); +if (log_flags & AV_LOG_PRINT_TIME || log_flags & AV_LOG_PRINT_DATETIME) +av_log(NULL, AV_LOG_INFO, "\n"); /* end with line break to avoid mixing up with shell prompt */ + exit_program(received_nb_signals ? 255 : main_return_code); return main_return_code; } -- 2.28.0.windows.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 1/2] avformat/oggdec: Use av_realloc_array()
Signed-off-by: Andreas Rheinhardt --- This also removes the last user of av_size_mult from libavformat (indeed, from anything outside of mem.c), so this removes one entry from the list of dynamic symbols (if using a shared build). libavformat/oggdec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index bb289e0756..5afbae2147 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -251,7 +251,6 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t serial) int idx = ogg->nstreams; AVStream *st; struct ogg_stream *os; -size_t size; if (ogg->state) { av_log(s, AV_LOG_ERROR, "New streams are not supposed to be added " @@ -260,8 +259,8 @@ static int ogg_new_stream(AVFormatContext *s, uint32_t serial) } /* Allocate and init a new Ogg Stream */ -if (av_size_mult(ogg->nstreams + 1, sizeof(*ogg->streams), &size) < 0 || -!(os = av_realloc(ogg->streams, size))) +if (!(os = av_realloc_array(ogg->streams, ogg->nstreams + 1, +sizeof(*ogg->streams return AVERROR(ENOMEM); ogg->streams = os; os = ogg->streams + idx; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/2] avutil/mem: Reinline av_size_mult() internally
Since 580e168a945b65100ec2c25433f33bfacfe9f7be, av_size_mult() is no longer inlined; on systems where interposing is a thing, this also inhibits the compiler from inlining said function into the internal callers of said function, although inlining such a small function is typically beneficial: With GCC 10.3 on Ubuntu x64 and -O3 this decreases the size of av_realloc_array from 91B to 23B, from 129B to 81B for av_realloc_f and from 77B to 23B for each of av_malloc_array, av_mallocz_array and av_calloc. Signed-off-by: Andreas Rheinhardt --- libavutil/mem.c | 43 --- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/libavutil/mem.c b/libavutil/mem.c index 0969749077..dcc75945d4 100644 --- a/libavutil/mem.c +++ b/libavutil/mem.c @@ -74,6 +74,24 @@ void av_max_alloc(size_t max){ atomic_store_explicit(&max_alloc_size, max, memory_order_relaxed); } +static int size_mult(size_t a, size_t b, size_t *r) +{ +size_t t; + +#if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_mul_overflow) +if (__builtin_mul_overflow(a, b, &t)) +return AVERROR(EINVAL); +#else +t = a * b; +/* Hack inspired from glibc: don't try the division if nelem and elsize + * are both less than sqrt(SIZE_MAX). */ +if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b) +return AVERROR(EINVAL); +#endif +*r = t; +return 0; +} + void *av_malloc(size_t size) { void *ptr = NULL; @@ -154,7 +172,7 @@ void *av_realloc_f(void *ptr, size_t nelem, size_t elsize) size_t size; void *r; -if (av_size_mult(elsize, nelem, &size)) { +if (size_mult(elsize, nelem, &size)) { av_free(ptr); return NULL; } @@ -188,7 +206,7 @@ int av_reallocp(void *ptr, size_t size) void *av_malloc_array(size_t nmemb, size_t size) { size_t result; -if (av_size_mult(nmemb, size, &result) < 0) +if (size_mult(nmemb, size, &result) < 0) return NULL; return av_malloc(result); } @@ -196,7 +214,7 @@ void *av_malloc_array(size_t nmemb, size_t size) void *av_mallocz_array(size_t nmemb, size_t size) { size_t result; -if (av_size_mult(nmemb, size, &result) < 0) +if (size_mult(nmemb, size, &result) < 0) return NULL; return av_mallocz(result); } @@ -204,7 +222,7 @@ void *av_mallocz_array(size_t nmemb, size_t size) void *av_realloc_array(void *ptr, size_t nmemb, size_t size) { size_t result; -if (av_size_mult(nmemb, size, &result) < 0) +if (size_mult(nmemb, size, &result) < 0) return NULL; return av_realloc(ptr, result); } @@ -251,7 +269,7 @@ void *av_mallocz(size_t size) void *av_calloc(size_t nmemb, size_t size) { size_t result; -if (av_size_mult(nmemb, size, &result) < 0) +if (size_mult(nmemb, size, &result) < 0) return NULL; return av_mallocz(result); } @@ -549,18 +567,5 @@ void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size) int av_size_mult(size_t a, size_t b, size_t *r) { -size_t t; - -#if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_mul_overflow) -if (__builtin_mul_overflow(a, b, &t)) -return AVERROR(EINVAL); -#else -t = a * b; -/* Hack inspired from glibc: don't try the division if nelem and elsize - * are both less than sqrt(SIZE_MAX). */ -if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b) -return AVERROR(EINVAL); -#endif -*r = t; -return 0; +return size_mult(a, b, r); } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] avutil/mem: Correct av_calloc() documentation
Incorrect since 4959f18a8e11ad7d3529b1c4fc429f1b6b76ad7c. Signed-off-by: Andreas Rheinhardt --- Do we even need both av_mallocz_array and av_calloc given that they do exactly the same? I'd like to deprecate one, namely av_mallocz_array() (it has the longer name). libavutil/mem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/mem.h b/libavutil/mem.h index e9d343eaf0..c7f8867a13 100644 --- a/libavutil/mem.h +++ b/libavutil/mem.h @@ -240,7 +240,7 @@ av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size); av_alloc_size(1, 2) void *av_mallocz_array(size_t nmemb, size_t size); /** - * Non-inlined equivalent of av_mallocz_array(). + * Equivalent of av_mallocz_array(). * * Created for symmetry with the calloc() C function. */ -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH] fftools/cmdutils: Use av_strstart() instead of strncmp()
This also avoids hardcoding lengths. Signed-off-by: Andreas Rheinhardt --- Will apply this tomorrow unless there are objections in order not to block Soft Works' patch. fftools/cmdutils.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 64237a4796..6d0bcd6085 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -903,20 +903,18 @@ int opt_loglevel(void *optctx, const char *opt, const char *arg) if (!i && !cmd) { flags = 0; /* missing relative prefix, build absolute value */ } -if (!strncmp(token, "repeat", 6)) { +if (av_strstart(token, "repeat", &arg)) { if (cmd == '-') { flags |= AV_LOG_SKIP_REPEATED; } else { flags &= ~AV_LOG_SKIP_REPEATED; } -arg = token + 6; -} else if (!strncmp(token, "level", 5)) { +} else if (av_strstart(token, "level", &arg)) { if (cmd == '-') { flags &= ~AV_LOG_PRINT_LEVEL; } else { flags |= AV_LOG_PRINT_LEVEL; } -arg = token + 5; } else { break; } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v7 2/2] fftools: Add option to log timing
Soft Works: > This commit adds two logging flags: 'time' and 'datetime'. > > Usage: > > ffmpeg -loglevel +time > > or > > ffmpeg -loglevel +datetime > > Signed-off-by: softworkz > --- > doc/fftools-common-opts.texi | 4 > fftools/cmdutils.c | 21 + > fftools/ffmpeg.c | 6 +- > 3 files changed, 30 insertions(+), 1 deletion(-) > > diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common-opts.texi > index 7643dd8396..aae26c28d0 100644 > --- a/doc/fftools-common-opts.texi > +++ b/doc/fftools-common-opts.texi > @@ -198,6 +198,10 @@ and the "Last message repeated n times" line will be > omitted. > Indicates that log output should add a @code{[level]} prefix to each message > line. This can be used as an alternative to log coloring, e.g. when dumping > the > log to file. > +@item time > +Prefixes each log line with the local time. > +@item datetime > +Same as time but also prints the current date in each line. > @end table > Flags can also be used alone by adding a '+'/'-' prefix to set/reset a single > flag without affecting other @var{flags} or changing @var{loglevel}. When > diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c > index 912e881174..7918078766 100644 > --- a/fftools/cmdutils.c > +++ b/fftools/cmdutils.c > @@ -918,6 +918,27 @@ int opt_loglevel(void *optctx, const char *opt, const > char *arg) > flags |= AV_LOG_PRINT_LEVEL; > } > arg = token + 5; > +} else if (av_strstart(token, "time", NULL)) { > +if (cmd == '-') { > +flags &= ~AV_LOG_PRINT_TIME; > +} else { > +flags |= AV_LOG_PRINT_TIME; > +} > +arg = token + 4; > +} else if (av_strstart(token, "timing", NULL)) { Why are you recognizing an undocumented and redundant command? Just remove this. > +if (cmd == '-') { > +flags &= ~AV_LOG_PRINT_TIME; > +} else { > +flags |= AV_LOG_PRINT_TIME; > +} > +arg = token + 6; > +} else if (av_strstart(token, "datetime", NULL)) { > +if (cmd == '-') { > +flags &= ~AV_LOG_PRINT_DATETIME; > +} else { > +flags |= AV_LOG_PRINT_DATETIME; > +} > +arg = token + 8; This still hardcodes the lengths of the strings, resulting in potential breakage if one is updated and the other is forgotten. See my patch for how to avoid this. > } else { > break; > } > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c > index b0ce7c7c32..b0b105be1c 100644 > --- a/fftools/ffmpeg.c > +++ b/fftools/ffmpeg.c > @@ -4983,7 +4983,7 @@ static void log_callback_null(void *ptr, int level, > const char *fmt, va_list vl) > > int main(int argc, char **argv) > { > -int i, ret; > +int i, ret, log_flags; > BenchmarkTimeStamps ti; > > init_dynload(); > @@ -5049,6 +5049,10 @@ int main(int argc, char **argv) > if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < > decode_error_stat[1]) > exit_program(69); > > +log_flags = av_log_get_flags(); > +if (log_flags & AV_LOG_PRINT_TIME || log_flags & AV_LOG_PRINT_DATETIME) You can check both flags at once (as Nicolas has already pointed out). > +av_log(NULL, AV_LOG_INFO, "\n"); /* end with line break to avoid > mixing up with shell prompt */ > + > exit_program(received_nb_signals ? 255 : main_return_code); > return main_return_code; > } > ___ 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 v7 1/2] libavutil/log: Add capability to prefix loglines with current time or current date+time
Soft Works: > Signed-off-by: softworkz > --- > doc/APIchanges | 3 +++ > libavutil/log.c | 33 + > libavutil/log.h | 10 ++ > libavutil/version.h | 2 +- > 4 files changed, 43 insertions(+), 5 deletions(-) > > diff --git a/doc/APIchanges b/doc/APIchanges > index 6eefc7fc33..e64f34d677 100644 > --- a/doc/APIchanges > +++ b/doc/APIchanges > @@ -14,6 +14,9 @@ libavutil: 2021-04-27 > > API changes, most recent first: > > +2021-08-09 - xx - lavu 57.4.100 - log.h > + Add new logging flags: AV_LOG_PRINT_TIME and AV_LOG_PRINT_DATETIME > + > 2021-08-02 - xx - lavc 59.4.100 - packet.h >Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base. > > diff --git a/libavutil/log.c b/libavutil/log.c > index 66defa9c42..36dd5759ae 100644 > --- a/libavutil/log.c > +++ b/libavutil/log.c > static void format_line(void *avcl, int level, const char *fmt, va_list vl, > -AVBPrint part[4], int *print_prefix, int type[2]) > +AVBPrint part[5], int *print_prefix, int type[2]) > { > -AVClass* avc = avcl ? *(AVClass **) avcl : NULL; > +AVClass *avc = avcl ? *(AVClass **) avcl : NULL; Still a spurious change. > av_bprint_init(part+0, 0, AV_BPRINT_SIZE_AUTOMATIC); > av_bprint_init(part+1, 0, AV_BPRINT_SIZE_AUTOMATIC); > av_bprint_init(part+2, 0, AV_BPRINT_SIZE_AUTOMATIC); > av_bprint_init(part+3, 0, 65536); > +av_bprint_init(part+4, 0, AV_BPRINT_SIZE_AUTOMATIC); > ___ 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 v7 2/2] fftools: Add option to log timing
> -Original Message- > From: ffmpeg-devel On Behalf Of > Andreas Rheinhardt > Sent: Tuesday, 10 August 2021 20:49 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v7 2/2] fftools: Add option to log > timing > > Soft Works: > > This commit adds two logging flags: 'time' and 'datetime'. > > > > Usage: > > > > ffmpeg -loglevel +time > > > > or > > > > ffmpeg -loglevel +datetime > > > > Signed-off-by: softworkz > > --- > > doc/fftools-common-opts.texi | 4 > > fftools/cmdutils.c | 21 + > > fftools/ffmpeg.c | 6 +- > > 3 files changed, 30 insertions(+), 1 deletion(-) > > > > diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common- > opts.texi > > index 7643dd8396..aae26c28d0 100644 > > --- a/doc/fftools-common-opts.texi > > +++ b/doc/fftools-common-opts.texi > > @@ -198,6 +198,10 @@ and the "Last message repeated n times" line > will be omitted. > > Indicates that log output should add a @code{[level]} prefix to > each message > > line. This can be used as an alternative to log coloring, e.g. > when dumping the > > log to file. > > +@item time > > +Prefixes each log line with the local time. > > +@item datetime > > +Same as time but also prints the current date in each line. > > @end table > > Flags can also be used alone by adding a '+'/'-' prefix to > set/reset a single > > flag without affecting other @var{flags} or changing > @var{loglevel}. When > > diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c > > index 912e881174..7918078766 100644 > > --- a/fftools/cmdutils.c > > +++ b/fftools/cmdutils.c > > @@ -918,6 +918,27 @@ int opt_loglevel(void *optctx, const char > *opt, const char *arg) > > flags |= AV_LOG_PRINT_LEVEL; > > } > > arg = token + 5; > > +} else if (av_strstart(token, "time", NULL)) { > > +if (cmd == '-') { > > +flags &= ~AV_LOG_PRINT_TIME; > > +} else { > > +flags |= AV_LOG_PRINT_TIME; > > +} > > +arg = token + 4; > > +} else if (av_strstart(token, "timing", NULL)) { > > Why are you recognizing an undocumented and redundant command? Just > remove this. My mistake, this should only go into my fork where I'm having this for years already. > > > +if (cmd == '-') { > > +flags &= ~AV_LOG_PRINT_TIME; > > +} else { > > +flags |= AV_LOG_PRINT_TIME; > > +} > > +arg = token + 6; > > +} else if (av_strstart(token, "datetime", NULL)) { > > +if (cmd == '-') { > > +flags &= ~AV_LOG_PRINT_DATETIME; > > +} else { > > +flags |= AV_LOG_PRINT_DATETIME; > > +} > > +arg = token + 8; > > This still hardcodes the lengths of the strings, resulting in > potential > breakage if one is updated and the other is forgotten. See my patch > for > how to avoid this. Yes, but ALL the code is doing like this. Why should I just change the new code and mix it up with the existing code, resulting in a weird mashup that is much worse IMO than that tiny caveat that you are mentioning. > > > } else { > > break; > > } > > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c > > index b0ce7c7c32..b0b105be1c 100644 > > --- a/fftools/ffmpeg.c > > +++ b/fftools/ffmpeg.c > > @@ -4983,7 +4983,7 @@ static void log_callback_null(void *ptr, int > level, const char *fmt, va_list vl) > > > > int main(int argc, char **argv) > > { > > -int i, ret; > > +int i, ret, log_flags; > > BenchmarkTimeStamps ti; > > > > init_dynload(); > > @@ -5049,6 +5049,10 @@ int main(int argc, char **argv) > > if ((decode_error_stat[0] + decode_error_stat[1]) * > max_error_rate < decode_error_stat[1]) > > exit_program(69); > > > > +log_flags = av_log_get_flags(); > > +if (log_flags & AV_LOG_PRINT_TIME || log_flags & > AV_LOG_PRINT_DATETIME) > > You can check both flags at once (as Nicolas has already pointed > out). I had made that change. No idea where it got lost. That ML+Patch stuff is turning me mad. Sigh.. Thanks for your patience, softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH] libavcodec/nvdec: Do not exceed 32 surfaces when initializing hw_frames_ctx
Turns out the issue I was facing which prompted this patch request stemmed from improper usage of the APIs, and this patch was a workaround that was hiding the proper fix. Please feel free to reject this patch request, especially if it is likely to cause unforeseen issues down the line. Thanks -Ameer On Tue, Aug 10, 2021 at 8:14 AM Dennis Mungai wrote: > On Tue, 10 Aug 2021 at 15:04, Timo Rothenpieler > wrote: > > > On 10.08.2021 04:37, Ameer J wrote: > > > From: ameerj <52414509+ame...@users.noreply.github.com> > > > > > > nvdec is likely to fail when the initial pool size exceeds 32. This > > change ensures we don't exceed the limit when initializing a new > > hw_frames_ctx > > > > > > Signed-off-by: ameerj <52414509+ame...@users.noreply.github.com> > > > --- > > > libavcodec/nvdec.c | 6 -- > > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > > > diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c > > > index 251be039a8..bef33dbae9 100644 > > > --- a/libavcodec/nvdec.c > > > +++ b/libavcodec/nvdec.c > > > @@ -303,8 +303,10 @@ static int nvdec_init_hwframes(AVCodecContext > > *avctx, AVBufferRef **out_frames_r > > > frames_ctx = (AVHWFramesContext*)(*out_frames_ref)->data; > > > > > > if (dummy) { > > > -// Copied from ff_decode_get_hw_frames_ctx for compatibility > > > -frames_ctx->initial_pool_size += 3; > > > +// The function above guarantees 1 work surface, We must > > guarantee 4 work surfaces. > > > +// (the absolute minimum), so add the missing count without > > exceeding the maximum > > > +// recommended for nvdec. > > > +frames_ctx->initial_pool_size = > > min(frames_ctx->initial_pool_size + 3, 32); > > > > Where does this min() function come from? > > > > > frames_ctx->free = nvdec_free_dummy; > > > frames_ctx->pool = av_buffer_pool_init(0, nvdec_alloc_dummy); > > > > > > > So far, the 32 surface limit has only ever been enforced as a soft > > limit, and a warning printed when exceeded. Since it being a limit is > > not strictly documented and it might be risen in the future. > > > > Also, if the pool is limited in size, something is likely to fail due to > > that further down the chain. > > So I'm not sure if this is a better solution. > > > > Related, > > Can the pool surface setting be made configurable? > The older CUVID based wrappers expose it as an option (via -surfaces) as > does the NVENC encoder wrapper implementation. This would be useful in > cases where lower VRAM foot print is required (for multiple transcodes on > the same GPU) and at the same time, tunable enough to prevent downstream > failures if surfaces are insufficient. > > > > ___ > 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 v7 2/2] fftools: Add option to log timing
Soft Works: > > >> -Original Message- >> From: ffmpeg-devel On Behalf Of >> Andreas Rheinhardt >> Sent: Tuesday, 10 August 2021 20:49 >> To: ffmpeg-devel@ffmpeg.org >> Subject: Re: [FFmpeg-devel] [PATCH v7 2/2] fftools: Add option to log >> timing >> >> Soft Works: >>> This commit adds two logging flags: 'time' and 'datetime'. >>> >>> Usage: >>> >>> ffmpeg -loglevel +time >>> >>> or >>> >>> ffmpeg -loglevel +datetime >>> >>> Signed-off-by: softworkz >>> --- >>> doc/fftools-common-opts.texi | 4 >>> fftools/cmdutils.c | 21 + >>> fftools/ffmpeg.c | 6 +- >>> 3 files changed, 30 insertions(+), 1 deletion(-) >>> >>> diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common- >> opts.texi >>> index 7643dd8396..aae26c28d0 100644 >>> --- a/doc/fftools-common-opts.texi >>> +++ b/doc/fftools-common-opts.texi >>> @@ -198,6 +198,10 @@ and the "Last message repeated n times" line >> will be omitted. >>> Indicates that log output should add a @code{[level]} prefix to >> each message >>> line. This can be used as an alternative to log coloring, e.g. >> when dumping the >>> log to file. >>> +@item time >>> +Prefixes each log line with the local time. >>> +@item datetime >>> +Same as time but also prints the current date in each line. >>> @end table >>> Flags can also be used alone by adding a '+'/'-' prefix to >> set/reset a single >>> flag without affecting other @var{flags} or changing >> @var{loglevel}. When >>> diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c >>> index 912e881174..7918078766 100644 >>> --- a/fftools/cmdutils.c >>> +++ b/fftools/cmdutils.c >>> @@ -918,6 +918,27 @@ int opt_loglevel(void *optctx, const char >> *opt, const char *arg) >>> flags |= AV_LOG_PRINT_LEVEL; >>> } >>> arg = token + 5; >>> +} else if (av_strstart(token, "time", NULL)) { >>> +if (cmd == '-') { >>> +flags &= ~AV_LOG_PRINT_TIME; >>> +} else { >>> +flags |= AV_LOG_PRINT_TIME; >>> +} >>> +arg = token + 4; >>> +} else if (av_strstart(token, "timing", NULL)) { >> >> Why are you recognizing an undocumented and redundant command? Just >> remove this. > > My mistake, this should only go into my fork where I'm having this > for years already. > >> >>> +if (cmd == '-') { >>> +flags &= ~AV_LOG_PRINT_TIME; >>> +} else { >>> +flags |= AV_LOG_PRINT_TIME; >>> +} >>> +arg = token + 6; >>> +} else if (av_strstart(token, "datetime", NULL)) { >>> +if (cmd == '-') { >>> +flags &= ~AV_LOG_PRINT_DATETIME; >>> +} else { >>> +flags |= AV_LOG_PRINT_DATETIME; >>> +} >>> +arg = token + 8; >> >> This still hardcodes the lengths of the strings, resulting in >> potential >> breakage if one is updated and the other is forgotten. See my patch >> for >> how to avoid this. > > Yes, but ALL the code is doing like this. Why should I just change > the new code and mix it up with the existing code, resulting in > a weird mashup that is much worse IMO than that tiny caveat that you > are mentioning. > I actually intended my patch (https://ffmpeg.org/pipermail/ffmpeg-devel/2021-August/283439.html) which deals with the legacy flags to be applied first, so there will be no mashup. - 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 v7 2/2] fftools: Add option to log timing
> -Original Message- > From: ffmpeg-devel On Behalf Of > Andreas Rheinhardt > Sent: Tuesday, 10 August 2021 21:09 > To: ffmpeg-devel@ffmpeg.org > Subject: Re: [FFmpeg-devel] [PATCH v7 2/2] fftools: Add option to log > timing > > Soft Works: > > > > > >> -Original Message- > >> From: ffmpeg-devel On Behalf Of > >> Andreas Rheinhardt > >> Sent: Tuesday, 10 August 2021 20:49 > >> To: ffmpeg-devel@ffmpeg.org > >> Subject: Re: [FFmpeg-devel] [PATCH v7 2/2] fftools: Add option to > log > >> timing > >> > >> Soft Works: > >>> This commit adds two logging flags: 'time' and 'datetime'. > >>> > >>> Usage: > >>> > >>> ffmpeg -loglevel +time > >>> > >>> or > >>> > >>> ffmpeg -loglevel +datetime > >>> > >>> Signed-off-by: softworkz > >>> --- > >>> doc/fftools-common-opts.texi | 4 > >>> fftools/cmdutils.c | 21 + > >>> fftools/ffmpeg.c | 6 +- > >>> 3 files changed, 30 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/doc/fftools-common-opts.texi b/doc/fftools-common- > >> opts.texi > >>> index 7643dd8396..aae26c28d0 100644 > >>> --- a/doc/fftools-common-opts.texi > >>> +++ b/doc/fftools-common-opts.texi > >>> @@ -198,6 +198,10 @@ and the "Last message repeated n times" line > >> will be omitted. > >>> Indicates that log output should add a @code{[level]} prefix to > >> each message > >>> line. This can be used as an alternative to log coloring, e.g. > >> when dumping the > >>> log to file. > >>> +@item time > >>> +Prefixes each log line with the local time. > >>> +@item datetime > >>> +Same as time but also prints the current date in each line. > >>> @end table > >>> Flags can also be used alone by adding a '+'/'-' prefix to > >> set/reset a single > >>> flag without affecting other @var{flags} or changing > >> @var{loglevel}. When > >>> diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c > >>> index 912e881174..7918078766 100644 > >>> --- a/fftools/cmdutils.c > >>> +++ b/fftools/cmdutils.c > >>> @@ -918,6 +918,27 @@ int opt_loglevel(void *optctx, const char > >> *opt, const char *arg) > >>> flags |= AV_LOG_PRINT_LEVEL; > >>> } > >>> arg = token + 5; > >>> +} else if (av_strstart(token, "time", NULL)) { > >>> +if (cmd == '-') { > >>> +flags &= ~AV_LOG_PRINT_TIME; > >>> +} else { > >>> +flags |= AV_LOG_PRINT_TIME; > >>> +} > >>> +arg = token + 4; > >>> +} else if (av_strstart(token, "timing", NULL)) { > >> > >> Why are you recognizing an undocumented and redundant command? > Just > >> remove this. > > > > My mistake, this should only go into my fork where I'm having this > > for years already. > > > >> > >>> +if (cmd == '-') { > >>> +flags &= ~AV_LOG_PRINT_TIME; > >>> +} else { > >>> +flags |= AV_LOG_PRINT_TIME; > >>> +} > >>> +arg = token + 6; > >>> +} else if (av_strstart(token, "datetime", NULL)) { > >>> +if (cmd == '-') { > >>> +flags &= ~AV_LOG_PRINT_DATETIME; > >>> +} else { > >>> +flags |= AV_LOG_PRINT_DATETIME; > >>> +} > >>> +arg = token + 8; > >> > >> This still hardcodes the lengths of the strings, resulting in > >> potential > >> breakage if one is updated and the other is forgotten. See my > patch > >> for > >> how to avoid this. > > > > Yes, but ALL the code is doing like this. Why should I just change > > the new code and mix it up with the existing code, resulting in > > a weird mashup that is much worse IMO than that tiny caveat that > you > > are mentioning. > > I actually intended my patch > (https://ffmpeg.org/pipermail/ffmpeg-devel/2021-August/283439.html) > which deals with the legacy flags to be applied first, so there will > be > no mashup. You could have done this after merging my patch and do everything exactly as you want it to have. I have oriented my patch based on the existing code and when you find that incorrect, you'll have to change it anyway, so you could have also changed the parts that I'm adding afterwards. Instead you force me to wait for your patch, rebase and adapt my patch based on your change. I'm afraid, the number of hoops I'm ready to jump through is exhausted. Kind regards, softworkz ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [FFmpeg-cvslog] avformat/mxfdec: prefer footer and complete partitions for metadata
On Sun, Aug 01, 2021 at 01:15:32AM +, Marton Balint wrote: > ffmpeg | branch: master | Marton Balint | Sun Jun 27 > 22:59:49 2021 +0200| [7b4bdcd68e1e0abfab21a8be81789531d649c1ff] | committer: > Marton Balint > > avformat/mxfdec: prefer footer and complete partitions for metadata > > Also do not store inferior metadata with the same UID. > > Signed-off-by: Marton Balint > > > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7b4bdcd68e1e0abfab21a8be81789531d649c1ff > --- > > libavformat/mxfdec.c | 51 +++ > 1 file changed, 47 insertions(+), 4 deletions(-) [...] > @@ -842,10 +855,39 @@ static int mxf_read_partition_pack(void *arg, > AVIOContext *pb, int tag, int size > return 0; > } > > +static int partition_score(MXFPartition *p) > +{ > +if (p->type == Footer) This can fail both as null pointer dereference from mxf->current_partition being NULL as well as a read after free from a realloc here are the 2 traces: ==15334==ERROR: AddressSanitizer: SEGV on unknown address 0x0008 (pc 0x00cb211e bp 0x7ffde58f6780 sp 0x7ffde58f6760 T0) ==15334==The signal is caused by a READ memory access. ==15334==Hint: address points to the zero page. #0 0xcb211d in partition_score ffmpeg/libavformat/mxfdec.c:860:12 #1 0xcb149e in mxf_add_metadata_set ffmpeg/libavformat/mxfdec.c:882:29 #2 0xc7e98c in mxf_read_local_tags ffmpeg/libavformat/mxfdec.c:3004:19 #3 0xc7e98c in mxf_parse_klv ffmpeg/libavformat/mxfdec.c:3031 #4 0xc69296 in mxf_read_header ffmpeg/libavformat/mxfdec.c:3445:28 #5 0xff3e67 in avformat_open_input ffmpeg/libavformat/utils.c:571:20 #6 0x4c779c in LLVMFuzzerTestOneInput ffmpeg/tools/target_dem_fuzzer.c:187:11 #7 0x271b34d in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) Fuzzer/build/../FuzzerLoop.cpp:495:13 #8 0x270ff22 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) Fuzzer/build/../FuzzerDriver.cpp:273:6 #9 0x2715121 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) Fuzzer/build/../FuzzerDriver.cpp:690:9 #10 0x270fc00 in main Fuzzer/build/../FuzzerMain.cpp:20:10 #11 0x7ff2d603ebf6 in __libc_start_main /build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:310 #12 0x41fb79 in _start (ffmpeg/tools/target_io_dem_fuzzer+0x41fb79) = ==15313==ERROR: AddressSanitizer: heap-use-after-free on address 0x612006d8 at pc 0x00d6eca2 bp 0x7ffd92ec0950 sp 0x7ffd92ec0948 READ of size 4 at 0x612006d8 thread T0 #0 0xd6eca1 in partition_score ffmpeg/libavformat/mxfdec.c:860:12 #1 0xd6deee in mxf_add_metadata_set ffmpeg/libavformat/mxfdec.c:882:29 #2 0xd3b3dc in mxf_read_local_tags ffmpeg/libavformat/mxfdec.c:3004:19 #3 0xd3b3dc in mxf_parse_klv ffmpeg/libavformat/mxfdec.c:3031 #4 0xd25ce6 in mxf_read_header ffmpeg/libavformat/mxfdec.c:3445:28 #5 0x4f2707 in avformat_open_input ffmpeg/libavformat/utils.c:571:20 #6 0x4c6c35 in LLVMFuzzerTestOneInput ffmpeg/tools/target_dem_fuzzer.c:187:11 #7 0x271a86d in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) Fuzzer/build/../FuzzerLoop.cpp:495:13 #8 0x270f442 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) Fuzzer/build/../FuzzerDriver.cpp:273:6 #9 0x2714641 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) Fuzzer/build/../FuzzerDriver.cpp:690:9 #10 0x270f120 in main Fuzzer/build/../FuzzerMain.cpp:20:10 #11 0x7fbf99d16bf6 in __libc_start_main /build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:310 #12 0x41fb79 in _start (ffmpeg/tools/target_dem_fuzzer+0x41fb79) 0x612006d8 is located 152 bytes inside of 288-byte region [0x61200640,0x61200760) freed by thread T0 here: #0 0x497e19 in realloc /b/swarming/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/asan/asan_malloc_linux.cc:164:3 #1 0xd5e0f4 in mxf_read_partition_pack ffmpeg/libavformat/mxfdec.c:700:16 #2 0xd3a842 in mxf_parse_klv ffmpeg/libavformat/mxfdec.c:3034:15 #3 0xd25ce6 in mxf_read_header ffmpeg/libavformat/mxfdec.c:3445:28 #4 0x4f2707 in avformat_open_input ffmpeg/libavformat/utils.c:571:20 #5 0x4c6c35 in LLVMFuzzerTestOneInput ffmpeg/tools/target_dem_fuzzer.c:187:11 #6 0x271a86d in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) Fuzzer/build/../FuzzerLoop.cpp:495:13 #7 0x270f442 in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) Fuzzer/build/../FuzzerDriver.cpp:273:6 #8 0x2714641 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) Fuzzer/build/../FuzzerDriver.cpp:690:9 #9 0x270f120 in main Fuzzer/build/../FuzzerMain.cpp:20:10 #10 0x7fbf99d16bf6 in __libc_start_main /build/glibc-S9d2JN/glibc-2.27/csu/../csu/libc-start.c:310 previously allocated by thread T
[FFmpeg-devel] [PATCH 1/3] avutil/frame: add av_frame_replace
Signed-off-by: James Almer --- Not going to bother with implementing replace for side data, since it's IMO not worth it, but patches are welcome of course. Missing version bump and APIchanges entry. libavutil/frame.c | 98 +++ libavutil/frame.h | 18 + 2 files changed, 116 insertions(+) diff --git a/libavutil/frame.c b/libavutil/frame.c index b0ceaf7145..035a48eb48 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -421,6 +421,104 @@ fail: return ret; } +int av_frame_replace(AVFrame *dst, const AVFrame *src) +{ +int i, ret = 0; + +if (!src->buf[0]) { +if ((src->extended_data && src->extended_data[0]) || src->data[0]) +ret = AVERROR(EINVAL); + +goto fail; +} + +dst->format = src->format; +dst->width = src->width; +dst->height = src->height; +dst->channels = src->channels; +dst->channel_layout = src->channel_layout; +dst->nb_samples = src->nb_samples; + +wipe_side_data(dst); +av_dict_free(&dst->metadata); +ret = frame_copy_props(dst, src, 0); +if (ret < 0) +goto fail; + +/* replace the buffers */ +for (i = 0; i < FF_ARRAY_ELEMS(src->buf); i++) { +ret = av_buffer_replace(&dst->buf[i], src->buf[i]); +if (ret < 0) +goto fail; +} + +if (src->extended_buf) { +if (dst->nb_extended_buf != src->nb_extended_buf) { +int nb_extended_buf = FFMIN(dst->nb_extended_buf, src->nb_extended_buf); +void *tmp; + +for (i = nb_extended_buf; i < dst->nb_extended_buf; i++) +av_buffer_unref(&dst->extended_buf[i]); + +tmp = av_realloc_array(dst->extended_buf, sizeof(*dst->extended_buf), + src->nb_extended_buf); +if (!tmp) { +ret = AVERROR(ENOMEM); +goto fail; +} +dst->extended_buf = tmp; +dst->nb_extended_buf = src->nb_extended_buf; + +memset(&dst->extended_buf[nb_extended_buf], 0, + (src->nb_extended_buf - nb_extended_buf) * sizeof(*dst->extended_buf)); +} + +for (i = 0; i < src->nb_extended_buf; i++) { +ret = av_buffer_replace(&dst->extended_buf[i], src->extended_buf[i]); +if (ret < 0) +goto fail; +} +} else if (dst->extended_buf) { +for (i = 0; i < dst->nb_extended_buf; i++) +av_buffer_unref(&dst->extended_buf[i]); +av_freep(&dst->extended_buf); +} + +ret = av_buffer_replace(&dst->hw_frames_ctx, src->hw_frames_ctx); +if (ret < 0) +goto fail; + +if (dst->extended_data != dst->data) +av_freep(&dst->extended_data); + +if (src->extended_data != src->data) { +int ch = src->channels; + +if (!ch) { +ret = AVERROR(EINVAL); +goto fail; +} +CHECK_CHANNELS_CONSISTENCY(src); + +dst->extended_data = av_malloc_array(sizeof(*dst->extended_data), ch); +if (!dst->extended_data) { +ret = AVERROR(ENOMEM); +goto fail; +} +memcpy(dst->extended_data, src->extended_data, sizeof(*src->extended_data) * ch); +} else +dst->extended_data = dst->data; + +memcpy(dst->data, src->data, sizeof(src->data)); +memcpy(dst->linesize, src->linesize, sizeof(src->linesize)); + +return 0; + +fail: +av_frame_unref(dst); +return ret; +} + AVFrame *av_frame_clone(const AVFrame *src) { AVFrame *ret = av_frame_alloc(); diff --git a/libavutil/frame.h b/libavutil/frame.h index ff2540a20f..36ed128886 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -695,6 +695,24 @@ void av_frame_free(AVFrame **frame); */ int av_frame_ref(AVFrame *dst, const AVFrame *src); +/** + * Ensure the destination frame refers to the same data described by the source + * frame. + * + * Copy frame properties from src to dst and create a new reference for each + * AVBufferRef from src if they differ from those in dst. + * + * src must be reference counted. + * + * @param src The source frame. If there's data described in it, it must be + *reference counted. + * @param dst The destination frame. + * + * @return 0 on success, a negative AVERROR on error. On error, dst is + * unreferenced. + */ +int av_frame_replace(AVFrame *dst, const AVFrame *src); + /** * Create a new frame that references the same data as src. * -- 2.32.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 2/3] avcodec/pthread_frame: add ff_thread_replace_frame()
Signed-off-by: James Almer --- libavcodec/pthread_frame.c | 29 + libavcodec/thread.h| 2 ++ libavcodec/utils.c | 20 3 files changed, 51 insertions(+) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 2ff71ca39e..1480269671 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -1162,3 +1162,32 @@ fail: } #endif } + +int ff_thread_replace_frame(AVCodecContext *avctx, ThreadFrame *dst, const ThreadFrame *src) +{ +int ret; +#if FF_API_THREAD_SAFE_CALLBACKS +FF_DISABLE_DEPRECATION_WARNINGS +int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) || + THREAD_SAFE_CALLBACKS(avctx); +FF_ENABLE_DEPRECATION_WARNINGS + +if (!can_direct_free) +ff_thread_release_buffer(avctx, dst); +#endif + +dst->owner[0] = src->owner[0]; +dst->owner[1] = src->owner[1]; + +ret = av_frame_replace(dst->f, src->f); +if (ret < 0) +return ret; + +ret = av_buffer_replace(&dst->progress, src->progress); +if (ret < 0) { +ff_thread_release_buffer(dst->owner[0], dst); +return ret; +} + +return 0; +} diff --git a/libavcodec/thread.h b/libavcodec/thread.h index d7d2ddd8f1..5fef42e16f 100644 --- a/libavcodec/thread.h +++ b/libavcodec/thread.h @@ -135,6 +135,8 @@ void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f); int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src); +int ff_thread_replace_frame(AVCodecContext *avctx, ThreadFrame *dst, const ThreadFrame *src); + int ff_thread_init(AVCodecContext *s); int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx, int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr), diff --git a/libavcodec/utils.c b/libavcodec/utils.c index cfc07cbcb8..cd322ff6a9 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -917,6 +917,26 @@ void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) av_frame_unref(f->f); } +int ff_thread_replace_frame(AVCodecContext *avctx, ThreadFrame *dst, const ThreadFrame *src) +{ +int ret; + +dst->owner[0] = src->owner[0]; +dst->owner[1] = src->owner[1]; + +ret = av_frame_replace(dst->f, src->f); +if (ret < 0) +return ret; + +ret = av_buffer_replace(&dst->progress, src->progress); +if (ret < 0) { +ff_thread_release_buffer(dst->owner[0], dst); +return ret; +} + +return 0; +} + void ff_thread_finish_setup(AVCodecContext *avctx) { } -- 2.32.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 3/3] avcodech/h264_picture: use ff_thread_replace_frame()
Signed-off-by: James Almer --- libavcodec/h264_picture.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c index ff30166b4d..109a8ff31d 100644 --- a/libavcodec/h264_picture.c +++ b/libavcodec/h264_picture.c @@ -154,8 +154,7 @@ int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture av_assert0(src->tf.f == src->f); dst->tf.f = dst->f; -ff_thread_release_buffer(h->avctx, &dst->tf); -ret = ff_thread_ref_frame(&dst->tf, &src->tf); +ret = ff_thread_replace_frame(h->avctx, &dst->tf, &src->tf); if (ret < 0) goto fail; -- 2.32.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] avcodech/h264_picture: use ff_thread_replace_frame()
James Almer: > Signed-off-by: James Almer > --- > libavcodec/h264_picture.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c > index ff30166b4d..109a8ff31d 100644 > --- a/libavcodec/h264_picture.c > +++ b/libavcodec/h264_picture.c > @@ -154,8 +154,7 @@ int ff_h264_replace_picture(H264Context *h, H264Picture > *dst, const H264Picture > av_assert0(src->tf.f == src->f); > > dst->tf.f = dst->f; > -ff_thread_release_buffer(h->avctx, &dst->tf); > -ret = ff_thread_ref_frame(&dst->tf, &src->tf); > +ret = ff_thread_replace_frame(h->avctx, &dst->tf, &src->tf); > if (ret < 0) > goto fail; > > Is there a reason that you only intend to use this here? Couldn't one replace all occurrences of ff_thread_ref_frame() with this (and remove ff_thread_ref_frame())? - 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 3/3] avcodech/h264_picture: use ff_thread_replace_frame()
On 8/10/2021 7:16 PM, Andreas Rheinhardt wrote: James Almer: Signed-off-by: James Almer --- libavcodec/h264_picture.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c index ff30166b4d..109a8ff31d 100644 --- a/libavcodec/h264_picture.c +++ b/libavcodec/h264_picture.c @@ -154,8 +154,7 @@ int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture av_assert0(src->tf.f == src->f); dst->tf.f = dst->f; -ff_thread_release_buffer(h->avctx, &dst->tf); -ret = ff_thread_ref_frame(&dst->tf, &src->tf); +ret = ff_thread_replace_frame(h->avctx, &dst->tf, &src->tf); if (ret < 0) goto fail; Is there a reason that you only intend to use this here? Couldn't one replace all occurrences of ff_thread_ref_frame() with this (and remove ff_thread_ref_frame())? I didn't look into it. Also, it would probably only make sense to replace the relevant calls in update_thread_context() implementations, since every other use of av_frame_ref() and ff_thread_ref_frame() will be for non matching frames where it makes no difference. - 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".
[FFmpeg-devel] [PATCH 1/3] avfilter/avfilter: Fix leaks upon filter creation error
Both the name as well as the options need to be freed. (Right now there is no option for the AVFilterContext itself that could leak, but some filters have options (e.g. of type AV_OPT_TYPE_STRING) that can leak.) Signed-off-by: Andreas Rheinhardt --- I intend to remove this duplicated freeing code and call avfilter_free() directly once it is ensured that it is safe to do so; a few checks will have to be added to it and the filters will have to be checked to be compatible with it. The only thing I already found out is that libvamf is buggy (even without calling avfilter_free), because it just presumes that a mutex and a condition variable have always been properly initialized. libavfilter/avfilter.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 358bf8a853..908e812b5c 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -684,13 +684,19 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) err: if (preinited) filter->uninit(ret); +av_freep(&ret->name); av_freep(&ret->inputs); av_freep(&ret->input_pads); ret->nb_inputs = 0; av_freep(&ret->outputs); av_freep(&ret->output_pads); ret->nb_outputs = 0; -av_freep(&ret->priv); +if (ret->priv) { +if (filter->priv_class) +av_opt_free(ret->priv); +av_freep(&ret->priv); +} +av_opt_free(ret); av_freep(&ret->internal); av_free(ret); return NULL; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 2/3] avfilter/avfilter: Use av_memdup where appropriate
Signed-off-by: Andreas Rheinhardt --- libavfilter/avfilter.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 908e812b5c..c04aefcaa8 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -659,10 +659,9 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) ret->nb_inputs = avfilter_pad_count(filter->inputs); if (ret->nb_inputs ) { -ret->input_pads = av_malloc_array(ret->nb_inputs, sizeof(AVFilterPad)); +ret->input_pads = av_memdup(filter->inputs, ret->nb_inputs * sizeof(*filter->inputs)); if (!ret->input_pads) goto err; -memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->nb_inputs); ret->inputs = av_mallocz_array(ret->nb_inputs, sizeof(AVFilterLink*)); if (!ret->inputs) goto err; @@ -670,10 +669,9 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) ret->nb_outputs = avfilter_pad_count(filter->outputs); if (ret->nb_outputs) { -ret->output_pads = av_malloc_array(ret->nb_outputs, sizeof(AVFilterPad)); +ret->output_pads = av_memdup(filter->outputs, ret->nb_outputs * sizeof(*filter->outputs)); if (!ret->output_pads) goto err; -memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->nb_outputs); ret->outputs = av_mallocz_array(ret->nb_outputs, sizeof(AVFilterLink*)); if (!ret->outputs) goto err; -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 3/3] avfilter/vf_(guided|program_opencl): Add missing dynamic inputs flag
Signed-off-by: Andreas Rheinhardt --- libavfilter/vf_guided.c | 3 ++- libavfilter/vf_program_opencl.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_guided.c b/libavfilter/vf_guided.c index 202a6a0586..e2bf08f5c3 100644 --- a/libavfilter/vf_guided.c +++ b/libavfilter/vf_guided.c @@ -500,6 +500,7 @@ const AVFilter ff_vf_guided = { .activate= activate, .inputs = NULL, .outputs = guided_outputs, -.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC | AVFILTER_FLAG_SLICE_THREADS, +.flags = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_SLICE_THREADS | + AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, .process_command = process_command, }; diff --git a/libavfilter/vf_program_opencl.c b/libavfilter/vf_program_opencl.c index 4b38baeb3c..3af1485d53 100644 --- a/libavfilter/vf_program_opencl.c +++ b/libavfilter/vf_program_opencl.c @@ -367,6 +367,7 @@ const AVFilter ff_vf_program_opencl = { .description= NULL_IF_CONFIG_SMALL("Filter video using an OpenCL program"), .priv_size = sizeof(ProgramOpenCLContext), .priv_class = &program_opencl_class, +.flags = AVFILTER_FLAG_DYNAMIC_INPUTS, .preinit= &program_opencl_framesync_preinit, .init = &program_opencl_init, .uninit = &program_opencl_uninit, @@ -420,6 +421,7 @@ const AVFilter ff_vsrc_openclsrc = { .description= NULL_IF_CONFIG_SMALL("Generate video using an OpenCL program"), .priv_size = sizeof(ProgramOpenCLContext), .priv_class = &openclsrc_class, +.flags = AVFILTER_FLAG_DYNAMIC_INPUTS, .init = &program_opencl_init, .uninit = &program_opencl_uninit, .query_formats = &ff_opencl_filter_query_formats, -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v2 1/5] libavfilter/x86/vf_gblur: add ff_postscale_slice_avx512()
Ping > -Original Message- > From: Wu, Jianhua > Sent: Wednesday, August 4, 2021 10:06 AM > To: ffmpeg-devel@ffmpeg.org > Cc: Wu, Jianhua > Subject: [PATCH v2 1/5] libavfilter/x86/vf_gblur: add > ff_postscale_slice_avx512() > > Co-authored-by: Cheng Yanfei > Co-authored-by: Jin Jun > Signed-off-by: Wu Jianhua > --- > libavfilter/x86/vf_gblur.asm| 21 - > libavfilter/x86/vf_gblur_init.c | 4 > 2 files changed, 16 insertions(+), 9 deletions(-) > > diff --git a/libavfilter/x86/vf_gblur.asm b/libavfilter/x86/vf_gblur.asm index > 4d84e6d011..276fe347f5 100644 > --- a/libavfilter/x86/vf_gblur.asm > +++ b/libavfilter/x86/vf_gblur.asm > @@ -194,19 +194,17 @@ cglobal postscale_slice, 2, 2, 4, ptr, length, > postscale, > min, max > VBROADCASTSS m1, minm > VBROADCASTSS m2, maxm > %elif WIN64 > -SWAP 0, 2 > -SWAP 1, 3 > -VBROADCASTSS m0, xm0 > -VBROADCASTSS m1, xm1 > +VBROADCASTSS m0, xmm2 > +VBROADCASTSS m1, xmm3 > VBROADCASTSS m2, maxm > -%else ; UNIX64 > -VBROADCASTSS m0, xm0 > -VBROADCASTSS m1, xm1 > -VBROADCASTSS m2, xm2 > +%else ; UNIX > +VBROADCASTSS m0, xmm0 > +VBROADCASTSS m1, xmm1 > +VBROADCASTSS m2, xmm2 > %endif > > .loop: > -%if cpuflag(avx2) > +%if cpuflag(avx2) || cpuflag(avx512) > mulps m3, m0, [ptrq + lengthq] > %else > movu m3, [ptrq + lengthq] > @@ -229,3 +227,8 @@ POSTSCALE_SLICE > INIT_YMM avx2 > POSTSCALE_SLICE > %endif > + > +%if HAVE_AVX512_EXTERNAL > +INIT_ZMM avx512 > +POSTSCALE_SLICE > +%endif > diff --git a/libavfilter/x86/vf_gblur_init.c b/libavfilter/x86/vf_gblur_init.c > index d80fb46fe4..34aba4ca6e 100644 > --- a/libavfilter/x86/vf_gblur_init.c > +++ b/libavfilter/x86/vf_gblur_init.c > @@ -29,6 +29,7 @@ void ff_horiz_slice_avx2(float *ptr, int width, int height, > int steps, float nu, > > void ff_postscale_slice_sse(float *ptr, int length, float postscale, float > min, > float max); void ff_postscale_slice_avx2(float *ptr, int length, float > postscale, > float min, float max); > +void ff_postscale_slice_avx512(float *ptr, int length, float postscale, > +float min, float max); > > av_cold void ff_gblur_init_x86(GBlurContext *s) { @@ -47,5 +48,8 @@ > av_cold void ff_gblur_init_x86(GBlurContext *s) > if (EXTERNAL_AVX2(cpu_flags)) { > s->horiz_slice = ff_horiz_slice_avx2; > } > +if (EXTERNAL_AVX512(cpu_flags)) { > +s->postscale_slice = ff_postscale_slice_avx512; > +} > #endif > } > -- > 2.17.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 05/10] avfilter/af_loudnorm: Simplify setting common samplerates
This filter has only one input and output, so what it does can be more easily achieved by using ff_set_common_samplerates(). Signed-off-by: Andreas Rheinhardt --- libavfilter/af_loudnorm.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c index 54a58bb9a1..8bfb5ccc74 100644 --- a/libavfilter/af_loudnorm.c +++ b/libavfilter/af_loudnorm.c @@ -684,9 +684,6 @@ static int request_frame(AVFilterLink *outlink) static int query_formats(AVFilterContext *ctx) { LoudNormContext *s = ctx->priv; -AVFilterFormats *formats; -AVFilterLink *inlink = ctx->inputs[0]; -AVFilterLink *outlink = ctx->outputs[0]; static const int input_srate[] = {192000, -1}; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, @@ -701,13 +698,7 @@ static int query_formats(AVFilterContext *ctx) return ret; if (s->frame_type != LINEAR_MODE) { -formats = ff_make_format_list(input_srate); -if (!formats) -return AVERROR(ENOMEM); -ret = ff_formats_ref(formats, &inlink->outcfg.samplerates); -if (ret < 0) -return ret; -ret = ff_formats_ref(formats, &outlink->incfg.samplerates); +ret = ff_set_common_samplerates_from_list(ctx, input_srate); if (ret < 0) return ret; } -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 06/10] avfilter: Avoid allocation of AVFilterGraphInternal
This can be achieved by allocating it together with AVFilterGraph, with the public AVFilterGraph as first element in the new structure. Given that said structure is now more than just the internal, it has been renamed to FFFilterGraph. Accessing it is not type-safe, so this unsafety has been confined to a single function. This breaks ABI due to the removal of the removal of the AVFilterGraph.internal pointer. Signed-off-by: Andreas Rheinhardt --- This one is fairly easy due to the internal not being used much; I also followed Nicolas suggestion to factor the unsafe code out into a dedicated function. libavfilter/avfilter.c | 6 +++--- libavfilter/avfilter.h | 7 --- libavfilter/avfiltergraph.c | 21 +++-- libavfilter/internal.h | 10 -- libavfilter/pthread.c | 20 +++- 5 files changed, 29 insertions(+), 35 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index c04aefcaa8..7e48ff14c5 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -167,7 +167,7 @@ int avfilter_link(AVFilterContext *src, unsigned srcpad, link->type= src->output_pads[srcpad].type; av_assert0(AV_PIX_FMT_NONE == -1 && AV_SAMPLE_FMT_NONE == -1); link->format = -1; -ff_framequeue_init(&link->fifo, &src->graph->internal->frame_queues); +ff_framequeue_init(&link->fifo, &filtergraph(src->graph)->frame_queues); return 0; } @@ -868,9 +868,9 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) if (ctx->filter->flags & AVFILTER_FLAG_SLICE_THREADS && ctx->thread_type & ctx->graph->thread_type & AVFILTER_THREAD_SLICE && -ctx->graph->internal->thread_execute) { +filtergraph(ctx->graph)->thread_execute) { ctx->thread_type = AVFILTER_THREAD_SLICE; -ctx->internal->execute = ctx->graph->internal->thread_execute; +ctx->internal->execute = filtergraph(ctx->graph)->thread_execute; } else { ctx->thread_type = 0; } diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 360f63bc45..4436eb7d2d 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -758,8 +758,6 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, */ const AVClass *avfilter_get_class(void); -typedef struct AVFilterGraphInternal AVFilterGraphInternal; - /** * A function pointer passed to the @ref AVFilterGraph.execute callback to be * executed multiple times, possibly in parallel. @@ -817,11 +815,6 @@ typedef struct AVFilterGraph { */ int nb_threads; -/** - * Opaque object for libavfilter internal use. - */ -AVFilterGraphInternal *internal; - /** * Opaque user data. May be set by the caller to an arbitrary value, e.g. to * be used from callbacks like @ref AVFilterGraph.execute. diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index f6bbcd8578..f8a2426c46 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -82,21 +82,15 @@ int ff_graph_thread_init(AVFilterGraph *graph) AVFilterGraph *avfilter_graph_alloc(void) { -AVFilterGraph *ret = av_mallocz(sizeof(*ret)); +FFFilterGraph *const ret = av_mallocz(sizeof(*ret)); if (!ret) return NULL; -ret->internal = av_mallocz(sizeof(*ret->internal)); -if (!ret->internal) { -av_freep(&ret); -return NULL; -} +ret->pub.av_class = &filtergraph_class; +av_opt_set_defaults(&ret->pub); +ff_framequeue_global_init(&ret->frame_queues); -ret->av_class = &filtergraph_class; -av_opt_set_defaults(ret); -ff_framequeue_global_init(&ret->internal->frame_queues); - -return ret; +return &ret->pub; } void ff_filter_graph_remove_filter(AVFilterGraph *graph, AVFilterContext *filter) @@ -132,7 +126,6 @@ void avfilter_graph_free(AVFilterGraph **graph) av_freep(&(*graph)->scale_sws_opts); av_freep(&(*graph)->aresample_swr_opts); av_freep(&(*graph)->filters); -av_freep(&(*graph)->internal); av_freep(graph); } @@ -170,9 +163,9 @@ AVFilterContext *avfilter_graph_alloc_filter(AVFilterGraph *graph, { AVFilterContext **filters, *s; -if (graph->thread_type && !graph->internal->thread_execute) { +if (graph->thread_type && !filtergraph(graph)->thread_execute) { if (graph->execute) { -graph->internal->thread_execute = graph->execute; +filtergraph(graph)->thread_execute = graph->execute; } else { int ret = ff_graph_thread_init(graph); if (ret < 0) { diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 6c908690b4..2d1dab5788 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -122,11 +122,17 @@ struct AVFilterPad { int needs_writable; }; -struct AVFilterGraphInternal { +typedef struct FFFilterGraph { +AVFilterGraph pub; void *thread; avfilter_execute
[FFmpeg-devel] [PATCH 08/10] avfilter: Avoid allocation of AVFilterInternal
This can be achieved by allocating it together with AVFilterContext, with the public AVFilterContext as first element in the new structure. Given that said structure is now more than just the internal, it has been renamed to FFFilterContext. Accessing it is not type-safe, so this unsafety has been confined to a single function. This break ABI due to the removal of the AVFilterContext.internal pointer. Signed-off-by: Andreas Rheinhardt --- libavfilter/avfilter.c | 15 ++- libavfilter/avfilter.h | 7 --- libavfilter/internal.h | 12 +--- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 7e48ff14c5..6925d99659 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -623,14 +623,16 @@ static int default_execute(AVFilterContext *ctx, avfilter_action_func *func, voi AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) { AVFilterContext *ret; +FFFilterContext *ctx; int preinited = 0; if (!filter) return NULL; -ret = av_mallocz(sizeof(AVFilterContext)); -if (!ret) +ctx = av_mallocz(sizeof(*ctx)); +if (!ctx) return NULL; +ret = &ctx->pub; ret->av_class = &avfilter_class; ret->filter = filter; @@ -652,10 +654,7 @@ AVFilterContext *ff_filter_alloc(const AVFilter *filter, const char *inst_name) av_opt_set_defaults(ret->priv); } -ret->internal = av_mallocz(sizeof(*ret->internal)); -if (!ret->internal) -goto err; -ret->internal->execute = default_execute; +ctx->execute = default_execute; ret->nb_inputs = avfilter_pad_count(filter->inputs); if (ret->nb_inputs ) { @@ -695,7 +694,6 @@ err: av_freep(&ret->priv); } av_opt_free(ret); -av_freep(&ret->internal); av_free(ret); return NULL; } @@ -759,7 +757,6 @@ void avfilter_free(AVFilterContext *filter) av_expr_free(filter->enable); filter->enable = NULL; av_freep(&filter->var_values); -av_freep(&filter->internal); av_free(filter); } @@ -870,7 +867,7 @@ int avfilter_init_dict(AVFilterContext *ctx, AVDictionary **options) ctx->thread_type & ctx->graph->thread_type & AVFILTER_THREAD_SLICE && filtergraph(ctx->graph)->thread_execute) { ctx->thread_type = AVFILTER_THREAD_SLICE; -ctx->internal->execute = filtergraph(ctx->graph)->thread_execute; +filtercontext(ctx)->execute = filtergraph(ctx->graph)->thread_execute; } else { ctx->thread_type = 0; } diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 4436eb7d2d..26a849f955 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -327,8 +327,6 @@ typedef struct AVFilter { */ #define AVFILTER_THREAD_SLICE (1 << 0) -typedef struct AVFilterInternal AVFilterInternal; - /** An instance of a filter */ struct AVFilterContext { const AVClass *av_class;///< needed for av_log() and filters common options @@ -367,11 +365,6 @@ struct AVFilterContext { */ int thread_type; -/** - * An opaque struct for libavfilter internal use. - */ -AVFilterInternal *internal; - struct AVFilterCommand *command_queue; char *enable_str; ///< enable expression string diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 48a911f082..040ce6dee8 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -134,14 +134,20 @@ static av_always_inline FFFilterGraph *filtergraph(AVFilterGraph *graph) return (FFFilterGraph*)graph; } -struct AVFilterInternal { +typedef struct FFFilterContext { +AVFilterContextpub; avfilter_execute_func *execute; -}; +} FFFilterContext; + +static av_always_inline FFFilterContext *filtercontext(AVFilterContext *ctx) +{ +return (FFFilterContext*)ctx; +} static av_always_inline int ff_filter_execute(AVFilterContext *ctx, avfilter_action_func *func, void *arg, int *ret, int nb_jobs) { -return ctx->internal->execute(ctx, func, arg, ret, nb_jobs); +return filtercontext(ctx)->execute(ctx, func, arg, ret, nb_jobs); } /** -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 09/10] avfilter/avfilter: Make ff_update_link_current_pts static
Only used here. Signed-off-by: Andreas Rheinhardt --- libavfilter/avfilter.c | 10 ++ libavfilter/internal.h | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 6925d99659..ef049fe9b6 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -47,6 +47,8 @@ #include "libavutil/ffversion.h" const char av_filter_ffversion[] = "FFmpeg version " FFMPEG_VERSION; +static void update_link_current_pts(AVFilterLink *link, int64_t pts); + void ff_tlog_ref(void *ctx, AVFrame *ref, int end) { av_unused char buf[16]; @@ -220,7 +222,7 @@ void ff_avfilter_link_set_out_status(AVFilterLink *link, int status, int64_t pts av_assert0(!link->status_out); link->status_out = status; if (pts != AV_NOPTS_VALUE) -ff_update_link_current_pts(link, pts); +update_link_current_pts(link, pts); filter_unblock(link->dst); ff_filter_set_ready(link->src, 200); } @@ -513,7 +515,7 @@ static int set_enable_expr(AVFilterContext *ctx, const char *expr) return 0; } -void ff_update_link_current_pts(AVFilterLink *link, int64_t pts) +static void update_link_current_pts(AVFilterLink *link, int64_t pts) { if (pts == AV_NOPTS_VALUE) return; @@ -1340,7 +1342,7 @@ int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts if (!link->status_in) return *rstatus = 0; *rstatus = link->status_out = link->status_in; -ff_update_link_current_pts(link, link->status_in_pts); +update_link_current_pts(link, link->status_in_pts); *rpts = link->current_pts; return 1; } @@ -1369,7 +1371,7 @@ int ff_inlink_check_available_samples(AVFilterLink *link, unsigned min) static void consume_update(AVFilterLink *link, const AVFrame *frame) { -ff_update_link_current_pts(link, frame->pts); +update_link_current_pts(link, frame->pts); ff_inlink_process_commands(link, frame); link->dst->is_disabled = !ff_inlink_evaluate_timeline_at_frame(link, frame); link->frame_count_out++; diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 040ce6dee8..505d2d4952 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -199,8 +199,6 @@ av_warn_unused_result int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg, void *log_ctx); -void ff_update_link_current_pts(AVFilterLink *link, int64_t pts); - /** * Set the status field of a link from the source filter. * The pts should reflect the timestamp of the status change, -- 2.30.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-devel] [PATCH 07/10] avfilter/internal: Factor out executing a filter's execute_func
The current way of doing it involves writing the ctx parameter twice. Signed-off-by: Andreas Rheinhardt --- libavfilter/af_acrossover.c| 2 +- libavfilter/af_adeclick.c | 2 +- libavfilter/af_adenorm.c | 2 +- libavfilter/af_aemphasis.c | 2 +- libavfilter/af_afftdn.c| 2 +- libavfilter/af_afir.c | 2 +- libavfilter/af_afreqshift.c| 2 +- libavfilter/af_afwtdn.c| 2 +- libavfilter/af_aiir.c | 2 +- libavfilter/af_anequalizer.c | 2 +- libavfilter/af_anlmdn.c| 2 +- libavfilter/af_anlms.c | 2 +- libavfilter/af_arnndn.c| 2 +- libavfilter/af_asoftclip.c | 4 ++-- libavfilter/af_astats.c| 2 +- libavfilter/af_asubboost.c | 2 +- libavfilter/af_asupercut.c | 2 +- libavfilter/af_biquads.c | 2 +- libavfilter/af_crystalizer.c | 2 +- libavfilter/af_headphone.c | 4 ++-- libavfilter/af_sofalizer.c | 4 ++-- libavfilter/af_surround.c | 4 ++-- libavfilter/avf_showspatial.c | 2 +- libavfilter/avf_showspectrum.c | 10 +- libavfilter/internal.h | 6 ++ libavfilter/vf_amplify.c | 2 +- libavfilter/vf_atadenoise.c| 2 +- libavfilter/vf_avgblur.c | 4 ++-- libavfilter/vf_blackdetect.c | 2 +- libavfilter/vf_blend.c | 2 +- libavfilter/vf_bm3d.c | 2 +- libavfilter/vf_bwdif.c | 2 +- libavfilter/vf_cas.c | 2 +- libavfilter/vf_chromakey.c | 2 +- libavfilter/vf_chromanr.c | 2 +- libavfilter/vf_chromashift.c | 2 +- libavfilter/vf_colorbalance.c | 2 +- libavfilter/vf_colorchannelmixer.c | 2 +- libavfilter/vf_colorconstancy.c| 8 libavfilter/vf_colorcontrast.c | 2 +- libavfilter/vf_colorcorrect.c | 2 +- libavfilter/vf_colorize.c | 2 +- libavfilter/vf_colorkey.c | 2 +- libavfilter/vf_colorlevels.c | 2 +- libavfilter/vf_colormatrix.c | 8 libavfilter/vf_colorspace.c| 2 +- libavfilter/vf_colortemperature.c | 2 +- libavfilter/vf_convolution.c | 2 +- libavfilter/vf_convolve.c | 14 +++--- libavfilter/vf_curves.c| 2 +- libavfilter/vf_datascope.c | 2 +- libavfilter/vf_dctdnoiz.c | 2 +- libavfilter/vf_deband.c| 2 +- libavfilter/vf_dedot.c | 6 +++--- libavfilter/vf_despill.c | 2 +- libavfilter/vf_epx.c | 2 +- libavfilter/vf_estdif.c| 2 +- libavfilter/vf_exposure.c | 2 +- libavfilter/vf_fade.c | 8 libavfilter/vf_framerate.c | 2 +- libavfilter/vf_gblur.c | 6 +++--- libavfilter/vf_geq.c | 2 +- libavfilter/vf_guided.c| 12 ++-- libavfilter/vf_hflip.c | 2 +- libavfilter/vf_hqdn3d.c| 2 +- libavfilter/vf_hqx.c | 2 +- libavfilter/vf_identity.c | 2 +- libavfilter/vf_lagfun.c| 2 +- libavfilter/vf_lenscorrection.c| 2 +- libavfilter/vf_lensfun.c | 4 ++-- libavfilter/vf_limiter.c | 2 +- libavfilter/vf_lumakey.c | 2 +- libavfilter/vf_lut.c | 8 libavfilter/vf_lut2.c | 4 ++-- libavfilter/vf_lut3d.c | 4 ++-- libavfilter/vf_maskedclamp.c | 2 +- libavfilter/vf_maskedmerge.c | 2 +- libavfilter/vf_maskedminmax.c | 2 +- libavfilter/vf_maskedthreshold.c | 2 +- libavfilter/vf_maskfun.c | 2 +- libavfilter/vf_median.c| 2 +- libavfilter/vf_mix.c | 4 ++-- libavfilter/vf_monochrome.c| 4 ++-- libavfilter/vf_neighbor.c | 2 +- libavfilter/vf_nlmeans.c | 2 +- libavfilter/vf_nnedi.c | 2 +- libavfilter/vf_noise.c | 2 +- libavfilter/vf_overlay.c | 2 +- libavfilter/vf_perspective.c | 2 +- libavfilter/vf_photosensitivity.c | 4 ++-- libavfilter/vf_premultiply.c | 2 +- libavfilter/vf_pseudocolor.c | 2 +- libavfilter/vf_psnr.c | 2 +- libavfilter/vf_readeia608.c| 2 +- libavfilter/vf_remap.c | 2 +- libavfilter/vf_removegrain.c | 2 +- libavfilter/vf_rotate.c| 2 +- libavfilter/vf_scroll.c| 2 +- libavfilter/vf_selectivecolor.c| 2 +- libavfilter/vf_shear.c | 2 +- libavfilter/vf_shufflepixels.c | 2 +- libavfilter/vf_signalstats.c | 8 libavfilter/vf_ssim.c | 2 +- libavfilter/vf_stack.c | 2 +- libavfilter/vf_stereo3d.c | 2 +- libavfilter/vf_super2xsai.c| 2 +- libavfilter/vf_threshold.c | 2 +- libavfilter/vf_tonemap.c | 2 +- libavfilter/vf_transpose.c | 2 +-
[FFmpeg-devel] [PATCH 10/10] avfilter/avfilter: Hide most internal AVFilterLink fields
AVFilterLink does not have a separate structure for its internal fields. Instead these fields are in the public avfilter.h header together with a typical public/private separation line. But because one of these fields (not a pointer) has a non-public type, they are #ifdef'ed away and need to be made visible by a magic define. This is very ugly. This commit changes this: Most of these internal fields are moved to a new structure which also contains the public AVFilterLink as its first member, so that they can be allocated together. The fields that have been moved are those for which most uses happen in the libavfilter core and not in the filters themselves. The latter will be dealt with later. Signed-off-by: Andreas Rheinhardt --- I have not found a truely good way of moving the other fields without using filterlink() everywhere; I try to concentrate this as much as possible in libavfilter's core files (as opposed to the actual filters). libavfilter/af_firequalizer.c | 6 +- libavfilter/af_loudnorm.c | 9 +- libavfilter/af_lv2.c | 2 +- libavfilter/af_replaygain.c | 4 +- libavfilter/audio.c | 23 ++-- libavfilter/avf_aphasemeter.c | 4 +- libavfilter/avfilter.c| 211 ++ libavfilter/avfilter.h| 106 - libavfilter/avfiltergraph.c | 58 +- libavfilter/buffersink.c | 9 +- libavfilter/f_ebur128.c | 4 +- libavfilter/f_graphmonitor.c | 13 ++- libavfilter/f_sendcmd.c | 2 +- libavfilter/f_zmq.c | 2 +- libavfilter/filters.h | 2 +- libavfilter/internal.h| 110 +- libavfilter/tests/filtfmts.c | 5 +- libavfilter/video.c | 19 +-- 18 files changed, 311 insertions(+), 278 deletions(-) diff --git a/libavfilter/af_firequalizer.c b/libavfilter/af_firequalizer.c index b8ec20f5ae..463276a8ee 100644 --- a/libavfilter/af_firequalizer.c +++ b/libavfilter/af_firequalizer.c @@ -823,8 +823,10 @@ static int config_input(AVFilterLink *inlink) av_log(ctx, AV_LOG_DEBUG, "sample_rate = %d, channels = %d, analysis_rdft_len = %d, rdft_len = %d, fir_len = %d, nsamples_max = %d.\n", inlink->sample_rate, inlink->channels, s->analysis_rdft_len, s->rdft_len, s->fir_len, s->nsamples_max); -if (s->fixed) -inlink->min_samples = inlink->max_samples = s->nsamples_max; +if (s->fixed) { +FFFilterLink *const link = filterlink(inlink); +link->min_samples = link->max_samples = s->nsamples_max; +} return generate_kernel(ctx, SELECT_GAIN(s), SELECT_GAIN_ENTRY(s)); } diff --git a/libavfilter/af_loudnorm.c b/libavfilter/af_loudnorm.c index 8bfb5ccc74..24c24bad3d 100644 --- a/libavfilter/af_loudnorm.c +++ b/libavfilter/af_loudnorm.c @@ -503,8 +503,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) s->pts += out->nb_samples = -inlink->min_samples = -inlink->max_samples = subframe_length; +filterlink(inlink)->min_samples = +filterlink(inlink)->max_samples = subframe_length; s->frame_type = INNER_FRAME; break; @@ -741,8 +741,9 @@ static int config_input(AVFilterLink *inlink) init_gaussian_filter(s); if (s->frame_type != LINEAR_MODE) { -inlink->min_samples = -inlink->max_samples = frame_size(inlink->sample_rate, 3000); +FFFilterLink *const link = filterlink(inlink); +link->min_samples = +link->max_samples = frame_size(inlink->sample_rate, 3000); } s->pts = AV_NOPTS_VALUE; diff --git a/libavfilter/af_lv2.c b/libavfilter/af_lv2.c index e39efa5c41..fac3cae786 100644 --- a/libavfilter/af_lv2.c +++ b/libavfilter/af_lv2.c @@ -378,7 +378,7 @@ static int config_output(AVFilterLink *outlink) (lilv_plugin_has_feature(s->plugin, s->powerOf2BlockLength) || lilv_plugin_has_feature(s->plugin, s->fixedBlockLength) || lilv_plugin_has_feature(s->plugin, s->boundedBlockLength))) { -AVFilterLink *inlink = ctx->inputs[0]; +FFFilterLink *const inlink = filterlink(ctx->inputs[0]); inlink->min_samples = inlink->max_samples = 4096; } diff --git a/libavfilter/af_replaygain.c b/libavfilter/af_replaygain.c index fd642297f8..8cd225242d 100644 --- a/libavfilter/af_replaygain.c +++ b/libavfilter/af_replaygain.c @@ -359,8 +359,8 @@ static int config_input(AVFilterLink *inlink) s->yule_hist_i = 20; s->butter_hist_i = 4; -inlink->min_samples = -inlink->max_samples = inlink->sample_rate / 20; +filterlink(inlink)->min_samples = +filterlink(inlink)->max_samples = inlink->sample_rate / 20; return 0; } diff --git a/libavfilter/audio.c b/libavfilter/audio.c index 0deed5683b..29ac54f824 100644 --- a/libavfilter/audio.c +++ b/libavfilter/audio.c @@ -36,16 +36,18 @@ AVFrame *ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples) return ff_get_audio_buffer(link->dst->outputs[0], n
[FFmpeg-devel] [PATCH 4/4] avcodec/vp9: use ff_thread_replace_frame()
Signed-off-by: James Almer --- libavcodec/vp9.c | 67 ++-- 1 file changed, 42 insertions(+), 25 deletions(-) diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 874005a5ae..85f44b9d8c 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -186,6 +186,35 @@ fail: return AVERROR(ENOMEM); } +static int vp9_frame_replace(AVCodecContext *avctx, VP9Frame *dst, VP9Frame *src) +{ +int ret; + +ret = ff_thread_replace_frame(avctx, &dst->tf, &src->tf); +if (ret < 0) +return ret; + +ret = av_buffer_replace(&dst->extradata, src->extradata); +if (ret < 0) +goto fail; + +dst->segmentation_map = src->segmentation_map; +dst->mv = src->mv; +dst->uses_2pass = src->uses_2pass; + +ret = av_buffer_replace(&dst->hwaccel_priv_buf, src->hwaccel_priv_buf); +if (ret < 0) +goto fail; + +dst->hwaccel_picture_private = src->hwaccel_picture_private; + +return 0; + +fail: +vp9_frame_unref(avctx, dst); +return ret; +} + static int update_size(AVCodecContext *avctx, int w, int h) { #define HWACCEL_MAX (CONFIG_VP9_DXVA2_HWACCEL + \ @@ -1574,10 +1603,8 @@ static int vp9_decode_frame(AVCodecContext *avctx, void *frame, ((AVFrame *)frame)->pts = pkt->pts; ((AVFrame *)frame)->pkt_dts = pkt->dts; for (i = 0; i < 8; i++) { -if (s->next_refs[i].f->buf[0]) -ff_thread_release_buffer(avctx, &s->next_refs[i]); -if (s->s.refs[i].f->buf[0] && -(ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.refs[i])) < 0) +ret = ff_thread_replace_frame(avctx, &s->next_refs[i], &s->s.refs[i]); +if (ret < 0) return ret; } *got_frame = 1; @@ -1614,12 +1641,10 @@ static int vp9_decode_frame(AVCodecContext *avctx, void *frame, // ref frame setup for (i = 0; i < 8; i++) { -if (s->next_refs[i].f->buf[0]) -ff_thread_release_buffer(avctx, &s->next_refs[i]); if (s->s.h.refreshrefmask & (1 << i)) { -ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.frames[CUR_FRAME].tf); -} else if (s->s.refs[i].f->buf[0]) { -ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.refs[i]); +ret = ff_thread_replace_frame(avctx, &s->next_refs[i], &s->s.frames[CUR_FRAME].tf); +} else { +ret = ff_thread_replace_frame(avctx, &s->next_refs[i], &s->s.refs[i]); } if (ret < 0) return ret; @@ -1763,10 +1788,8 @@ static int vp9_decode_frame(AVCodecContext *avctx, void *frame, finish: // ref frame setup for (i = 0; i < 8; i++) { -if (s->s.refs[i].f->buf[0]) -ff_thread_release_buffer(avctx, &s->s.refs[i]); -if (s->next_refs[i].f->buf[0] && -(ret = ff_thread_ref_frame(&s->s.refs[i], &s->next_refs[i])) < 0) +ret = ff_thread_replace_frame(avctx, &s->s.refs[i], &s->next_refs[i]); +if (ret < 0) return ret; } @@ -1818,20 +1841,14 @@ static int vp9_decode_update_thread_context(AVCodecContext *dst, const AVCodecCo VP9Context *s = dst->priv_data, *ssrc = src->priv_data; for (i = 0; i < 3; i++) { -if (s->s.frames[i].tf.f->buf[0]) -vp9_frame_unref(dst, &s->s.frames[i]); -if (ssrc->s.frames[i].tf.f->buf[0]) { -if ((ret = vp9_frame_ref(dst, &s->s.frames[i], &ssrc->s.frames[i])) < 0) -return ret; -} +ret = vp9_frame_replace(dst, &s->s.frames[i], &ssrc->s.frames[i]); +if (ret < 0) +return ret; } for (i = 0; i < 8; i++) { -if (s->s.refs[i].f->buf[0]) -ff_thread_release_buffer(dst, &s->s.refs[i]); -if (ssrc->next_refs[i].f->buf[0]) { -if ((ret = ff_thread_ref_frame(&s->s.refs[i], &ssrc->next_refs[i])) < 0) -return ret; -} +ret = ff_thread_replace_frame(dst, &s->s.refs[i], &ssrc->next_refs[i]); +if (ret < 0) +return ret; } s->s.h.invisible = ssrc->s.h.invisible; -- 2.32.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 v2] libavcodec/qsvence: Use QSV encoder defaults as ffmpeg defaults
On Tue, 2021-08-10 at 08:53 +, Soft Works wrote: > Signed-off-by: softworkz > --- > libavcodec/qsvenc.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h > index fc8a14143e..58984f996f 100644 > --- a/libavcodec/qsvenc.h > +++ b/libavcodec/qsvenc.h > @@ -76,8 +76,8 @@ > > #define QSV_COMMON_OPTS \ > { "async_depth", "Maximum processing parallelism", OFFSET(qsv.async_depth), > AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VE > }, \ > -{ "avbr_accuracy","Accuracy of the AVBR > ratecontrol",OFFSET(qsv.avbr_accuracy),AV_OPT_TYPE_INT, { .i64 = 0 }, > 0, INT_MAX, VE }, \ > -{ "avbr_convergence", "Convergence of the AVBR ratecontrol", > OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE > }, \ > +{ "avbr_accuracy","Accuracy of the AVBR ratecontrol (unit of tenth of > percent)",OFFSET(qsv.avbr_accuracy),AV_OPT_TYPE_INT, { .i64 = 1 }, 1, > UINT16_MAX, VE }, \ > +{ "avbr_convergence", "Convergence of the AVBR ratecontrol (unit of 100 > frames)", OFFSET(qsv.avbr_convergence), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, > UINT16_MAX, VE }, \ > { "preset", NULL, OFFSET(qsv.preset), AV_OPT_TYPE_INT, { .i64 = > MFX_TARGETUSAGE_BALANCED }, MFX_TARGETUSAGE_BEST_QUALITY, > MFX_TARGETUSAGE_BEST_SPEED, VE, "preset" }, \ > { "veryfast",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = > MFX_TARGETUSAGE_BEST_SPEED }, INT_MIN, INT_MAX, VE, "preset" > },\ > { "faster", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = > MFX_TARGETUSAGE_6 },INT_MIN, INT_MAX, VE, "preset" > }, lgtm. 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] [PATCH v3 1/2] qsvdec: add support for HW_DEVICE_CTX method
This allows user set hw_device_ctx instead of hw_frames_ctx for QSV decoders, hence we may remove the ad-hoc libmfx setup code from FFmpeg. "-hwaccel_output_format format" is applied to QSV decoders after removing the ad-hoc libmfx code. In order to keep compatibility with old commandlines, the default format is set to AV_PIX_FMT_QSV, but this behavior will be removed in the future. Please set "-hwaccel_output_format qsv" explicitly if AV_PIX_FMT_QSV is expected. The normal device stuff works for QSV decoders now, user may use "-init_hw_device args" to initialise device and "-hwaccel_device devicename" to select a device for QSV decoders. "-qsv_device device" which was added for workarounding device selection in the ad-hoc libmfx code still works For example: $> ffmpeg -init_hw_device qsv=qsv:hw_any,child_device=/dev/dri/card0 -hwaccel qsv -c:v h264_qsv -i input.h264 -f null - /dev/dri/renderD128 is actually open for h264_qsv decoder in the above command without this patch. After applying this patch, /dev/dri/card0 is used. $> ffmpeg -init_hw_device vaapi=va:/dev/dri/card0 -init_hw_device qsv=hw@va -hwaccel_device hw -hwaccel qsv -c:v h264_qsv -i input.h264 -f null - device hw of type qsv is not usable in the above command without this patch. After applying this patch, this command works as expected. --- v3: Don't deprecate -qsv_device option Use single-shot device initialization to implement qsv_device option Update the commit log fftools/Makefile | 1 - fftools/ffmpeg.h | 1 - fftools/ffmpeg_hw.c | 12 + fftools/ffmpeg_opt.c | 28 +-- fftools/ffmpeg_qsv.c | 109 --- libavcodec/qsvdec.c | 31 +++- 6 files changed, 66 insertions(+), 116 deletions(-) delete mode 100644 fftools/ffmpeg_qsv.c diff --git a/fftools/Makefile b/fftools/Makefile index 5affaa3f56..5234932ab0 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -10,7 +10,6 @@ ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF)) ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF)) OBJS-ffmpeg+= fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o -OBJS-ffmpeg-$(CONFIG_LIBMFX) += fftools/ffmpeg_qsv.o ifndef CONFIG_VIDEOTOOLBOX OBJS-ffmpeg-$(CONFIG_VDA) += fftools/ffmpeg_videotoolbox.o endif diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index d9c0628657..d2dd7ca092 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -61,7 +61,6 @@ enum HWAccelID { HWACCEL_AUTO, HWACCEL_GENERIC, HWACCEL_VIDEOTOOLBOX, -HWACCEL_QSV, }; typedef struct HWAccel { diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index fc4a5d31d6..6923c4c5a1 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -339,6 +339,18 @@ int hw_device_setup_for_decode(InputStream *ist) } else if (ist->hwaccel_id == HWACCEL_GENERIC) { type = ist->hwaccel_device_type; dev = hw_device_get_by_type(type); + +// When "-qsv_device device" is used, an internal QSV device named +// as "__qsv_device" is created. Another QSV device is created too +// if "-init_hw_device qsv=name:device" is used. There are 2 QSV devices +// if both "-qsv_device device" and "-init_hw_device qsv=name:device" +// are used, hw_device_get_by_type(AV_HWDEVICE_TYPE_QSV) returns NULL. +// To keep back-compatibility with the removed ad-hoc libmfx setup code, +// call hw_device_get_by_name("__qsv_device") to select the internal QSV +// device. +if (!dev && type == AV_HWDEVICE_TYPE_QSV) +dev = hw_device_get_by_name("__qsv_device"); + if (!dev) err = hw_device_init_from_type(type, NULL, &dev); } else { diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 34cc6c4fd3..428934a3d8 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -137,9 +137,6 @@ static const char *const opt_name_enc_time_bases[] = {"enc_time_base" const HWAccel hwaccels[] = { #if CONFIG_VIDEOTOOLBOX { "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX }, -#endif -#if CONFIG_LIBMFX -{ "qsv", qsv_init, HWACCEL_QSV, AV_PIX_FMT_QSV }, #endif { 0 }, }; @@ -571,6 +568,23 @@ static int opt_vaapi_device(void *optctx, const char *opt, const char *arg) } #endif +#if CONFIG_QSV +static int opt_qsv_device(void *optctx, const char *opt, const char *arg) +{ +const char *prefix = "qsv=__qsv_device:hw_any,child_device="; +int err; +char *tmp = av_asprintf("%s%s", prefix, arg); + +if (!tmp) +return AVERROR(ENOMEM); + +err = hw_device_init_from_string(tmp, NULL); +av_free(tmp); + +return err; +} +#endif + static int opt_init_hw_device(void *optctx, const char *opt, const char *arg) { if (!strcmp(arg, "list")) { @@ -898,6 +912,12 @@ static void add_input_streams(O
[FFmpeg-devel] [PATCH v3 2/2] doc/examples/qsvdec: simplify this example via hw_device_ctx interface
--- doc/examples/qsvdec.c | 45 +-- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/doc/examples/qsvdec.c b/doc/examples/qsvdec.c index 7415eefca5..571d868f93 100644 --- a/doc/examples/qsvdec.c +++ b/doc/examples/qsvdec.c @@ -44,38 +44,10 @@ #include "libavutil/hwcontext_qsv.h" #include "libavutil/mem.h" -typedef struct DecodeContext { -AVBufferRef *hw_device_ref; -} DecodeContext; - static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts) { while (*pix_fmts != AV_PIX_FMT_NONE) { if (*pix_fmts == AV_PIX_FMT_QSV) { -DecodeContext *decode = avctx->opaque; -AVHWFramesContext *frames_ctx; -AVQSVFramesContext *frames_hwctx; -int ret; - -/* create a pool of surfaces to be used by the decoder */ -avctx->hw_frames_ctx = av_hwframe_ctx_alloc(decode->hw_device_ref); -if (!avctx->hw_frames_ctx) -return AV_PIX_FMT_NONE; -frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; -frames_hwctx = frames_ctx->hwctx; - -frames_ctx->format= AV_PIX_FMT_QSV; -frames_ctx->sw_format = avctx->sw_pix_fmt; -frames_ctx->width = FFALIGN(avctx->coded_width, 32); -frames_ctx->height= FFALIGN(avctx->coded_height, 32); -frames_ctx->initial_pool_size = 32; - -frames_hwctx->frame_type = MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET; - -ret = av_hwframe_ctx_init(avctx->hw_frames_ctx); -if (ret < 0) -return AV_PIX_FMT_NONE; - return AV_PIX_FMT_QSV; } @@ -87,7 +59,7 @@ static int get_format(AVCodecContext *avctx, const enum AVPixelFormat *pix_fmts) return AV_PIX_FMT_NONE; } -static int decode_packet(DecodeContext *decode, AVCodecContext *decoder_ctx, +static int decode_packet(AVCodecContext *decoder_ctx, AVFrame *frame, AVFrame *sw_frame, AVPacket *pkt, AVIOContext *output_ctx) { @@ -144,12 +116,12 @@ int main(int argc, char **argv) AVPacket pkt = { 0 }; AVFrame *frame = NULL, *sw_frame = NULL; -DecodeContext decode = { NULL }; - AVIOContext *output_ctx = NULL; int ret, i; +AVBufferRef *device_ref = NULL; + if (argc < 3) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; @@ -177,7 +149,7 @@ int main(int argc, char **argv) } /* open the hardware device */ -ret = av_hwdevice_ctx_create(&decode.hw_device_ref, AV_HWDEVICE_TYPE_QSV, +ret = av_hwdevice_ctx_create(&device_ref, AV_HWDEVICE_TYPE_QSV, "auto", NULL, 0); if (ret < 0) { fprintf(stderr, "Cannot open the hardware device\n"); @@ -209,7 +181,8 @@ int main(int argc, char **argv) decoder_ctx->extradata_size = video_st->codecpar->extradata_size; } -decoder_ctx->opaque = &decode; + +decoder_ctx->hw_device_ctx = av_buffer_ref(device_ref); decoder_ctx->get_format = get_format; ret = avcodec_open2(decoder_ctx, NULL, NULL); @@ -239,7 +212,7 @@ int main(int argc, char **argv) break; if (pkt.stream_index == video_st->index) -ret = decode_packet(&decode, decoder_ctx, frame, sw_frame, &pkt, output_ctx); +ret = decode_packet(decoder_ctx, frame, sw_frame, &pkt, output_ctx); av_packet_unref(&pkt); } @@ -247,7 +220,7 @@ int main(int argc, char **argv) /* flush the decoder */ pkt.data = NULL; pkt.size = 0; -ret = decode_packet(&decode, decoder_ctx, frame, sw_frame, &pkt, output_ctx); +ret = decode_packet(decoder_ctx, frame, sw_frame, &pkt, output_ctx); finish: if (ret < 0) { @@ -263,7 +236,7 @@ finish: avcodec_free_context(&decoder_ctx); -av_buffer_unref(&decode.hw_device_ref); +av_buffer_unref(&device_ref); avio_close(output_ctx); -- 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] [RFC PATCH] avformat/mov: add AVFMT_SHOW_IDS flag
The MOV muxer can store streamids as track ids but they aren't visible when probing the result via lavf/dump or ffprobe due to lack of this flag in the demuxer. This current submission is just to get Patchwork FATE results. Will be updated with changed refs, if any. --- libavformat/mov.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 46bc7b5aa3..c556390525 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -8216,5 +8216,5 @@ const AVInputFormat ff_mov_demuxer = { .read_packet= mov_read_packet, .read_close = mov_read_close, .read_seek = mov_read_seek, -.flags = AVFMT_NO_BYTE_SEEK | AVFMT_SEEK_TO_PTS, +.flags = AVFMT_NO_BYTE_SEEK | AVFMT_SEEK_TO_PTS | AVFMT_SHOW_IDS, }; -- 2.32.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] ffmpeg_hw: Don't ignore key parameters when initializing a hw device
Currently user may use '-init_hw_device type=name' to initialize a hw device, however the key parameter is ignored when use '-init_hw_device type=name,key=value'. After applying this patch, user may set key parameter if needed. --- fftools/ffmpeg_hw.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg_hw.c b/fftools/ffmpeg_hw.c index fc4a5d31d6..c55c459aa7 100644 --- a/fftools/ffmpeg_hw.c +++ b/fftools/ffmpeg_hw.c @@ -93,6 +93,8 @@ static char *hw_device_default_name(enum AVHWDeviceType type) int hw_device_init_from_string(const char *arg, HWDevice **dev_out) { +// "type=name" +// "type=name,key=value,key2=value2" // "type=name:device,key=value,key2=value2" // "type:device,key=value,key2=value2" // -> av_hwdevice_ctx_create() @@ -124,7 +126,7 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out) } if (*p == '=') { -k = strcspn(p + 1, ":@"); +k = strcspn(p + 1, ":@,"); name = av_strndup(p + 1, k); if (!name) { @@ -190,6 +192,18 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out) src->device_ref, 0); if (err < 0) goto fail; +} else if (*p == ',') { +err = av_dict_parse_string(&options, p + 1, "=", ",", 0); + +if (err < 0) { +errmsg = "failed to parse options"; +goto invalid; +} + +err = av_hwdevice_ctx_create(&device_ref, type, + NULL, options, 0); +if (err < 0) +goto fail; } else { errmsg = "parse error"; goto invalid; -- 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".