Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.

2022-05-01 Thread Simone Karin Lehmann
Hi,

… I’m so sorry, the patch I recently sent didn’t test the prio_speed bool. This 
corrects it.

I really sorry. :-/

Regards
Simone



0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch
Description: Binary data


> Am 01.05.2022 um 20:25 schrieb Richard Kern :
> 
> 
> 
>> On May 1, 2022, at 1:31 PM, Simone Karin Lehmann  wrote:
>> 
>> Hi,
>> 
>> may I kindly ask you to check, if this patch could now be applied? 
> I’ll look at it today. 
> 
>> 
>> Regards
>> Simone
>> 
>> Von meinem iPad gesendet
>> 
>>> Am 25.04.2022 um 22:33 schrieb Simone Karin Lehmann :
>>> 
>>> 
>>> 
>>>>>> Am 25.04.2022 um 21:14 schrieb Rick Kern :
>>>>>> 
>>>>>> 
>>>>>> { "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc),
>>>>>> AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, VE },
>>>>>> +{ "prio_speed", "prioritize encoding speed", OFFSET(prio_speed),
>>>>>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
>>>>>> 
>>>> It might be simpler to make the default value of prio_speed -1, and set
>>>> this property on the encoder session only when it's non-negative. Then we
>>>> won't need to worry about the default value changing for different codecs
>>>> or different OS versions. It could also be moved into COMMON_OPTIONS in
>>>> this case.
>>> 
>>> oh yes, that’s way better. I didn’t think of that in the first place. 
>>> Thanks for the hint.
>>> 
>>> Here’s the modified patch
>>> 
>>> Simone
>>> 
> <0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch>
>> 
>>> 
>>> ___
>>> 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 mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.

2022-05-01 Thread Simone Karin Lehmann
Hi,

may I kindly ask you to check, if this patch could now be applied? 

Regards
Simone

Von meinem iPad gesendet

> Am 25.04.2022 um 22:33 schrieb Simone Karin Lehmann :
> 
> 
> 
>>> Am 25.04.2022 um 21:14 schrieb Rick Kern :
>>> 
>>> 
>>>   { "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc),
>>> AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, VE },
>>> +{ "prio_speed", "prioritize encoding speed", OFFSET(prio_speed),
>>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
>>> 
>> It might be simpler to make the default value of prio_speed -1, and set
>> this property on the encoder session only when it's non-negative. Then we
>> won't need to worry about the default value changing for different codecs
>> or different OS versions. It could also be moved into COMMON_OPTIONS in
>> this case.
> 
> oh yes, that’s way better. I didn’t think of that in the first place. Thanks 
> for the hint.
> 
> Here’s the modified patch
> 
> Simone
> 


0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch
Description: Binary data
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


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/videotoolboxenc.c: add option to hevc encoder to prioritize speed.

2022-04-25 Thread Simone Karin Lehmann


> Am 25.04.2022 um 21:14 schrieb Rick Kern :
> 
>> 
>>{ "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc),
>> AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, VE },
>> +{ "prio_speed", "prioritize encoding speed", OFFSET(prio_speed),
>> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
>> 
> It might be simpler to make the default value of prio_speed -1, and set
> this property on the encoder session only when it's non-negative. Then we
> won't need to worry about the default value changing for different codecs
> or different OS versions. It could also be moved into COMMON_OPTIONS in
> this case.

oh yes, that’s way better. I didn’t think of that in the first place. Thanks 
for the hint.

Here’s the modified patch

Simone



0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.

2022-04-23 Thread Simone Karin Lehmann


> Am 23.04.2022 um 21:56 schrieb Thilo Borgmann :
> 
> Am 23.04.22 um 17:42 schrieb Simone Karin Lehmann:
>>> Am 23.04.2022 um 17:07 schrieb Thilo Borgmann :
>>> 
>>> 
>>> If that works I'd be happy. Does not apply for me anymore (on HEAD), though?
>>> 
>>> 
>> hhmm, the patch applies for me on current HEAD. I’ve tested it a few moments 
>> ago on a fresh downloaded git snapshot.
>> Maybe a former patch from me still there in your source tree?
> 
> Also cloned into a new one, but corrupt @75:
> 

Weird. Apple Mail seems to somehow change the encoding of the mail and I 
couldn’t get the *.eml to apply correctly too. Never encountered that before. 

I've attached the patch as a file. Hope that’s ok on this mailing list.
Sorry for the inconvenience.

Simone



0001-add-options-to-h264-hevc-and-prores-encoders-to-prio.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.

2022-04-23 Thread Simone Karin Lehmann


> Am 23.04.2022 um 17:07 schrieb Thilo Borgmann :
> 
> 
> If that works I'd be happy. Does not apply for me anymore (on HEAD), though?
> 
> 

hhmm, the patch applies for me on current HEAD. I’ve tested it a few moments 
ago on a fresh downloaded git snapshot.

Maybe a former patch from me still there in your source tree? 

Simone
___
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/videotoolboxenc.c: add option to hevc encoder to prioritize speed.

2022-04-23 Thread Simone Karin Lehmann


> Am 22.04.2022 um 18:52 schrieb Thilo Borgmann :
> 
> 

> For that version I get:
> 
> libavcodec/videotoolboxenc.c:1153:39: error: use of undeclared identifier 
> 'kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality'
>  
> kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
>  ^
> 
> Should require some OSX version dependency via #if'ery somewhere sane. Like
> #if !TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
> 
> or similar.

If I understand the code correctly, it seems to me to be bettter to add 
kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality to the compat_keys 
struct. 

And digging through the SDK headers I’ve found that this property is available 
for h264 and ProRes encoders too. But since the SDK states that this property 
defaults to FALSE for h264 and hevc and to TRUE for ProRes I didn’t add it to 
the COMMON_OPTIONS but to each encoder options, because I didn’t want to make a 
regression to the ProRes or enabling it by default for h264 and hevc. Hope 
that’s ok.

Here’s the resulting patch

Regards
Simone


Signed-off-by: Simone Karin Lehmann mailto:sim...@lisanet.de>>
---
libavcodec/videotoolboxenc.c | 18 ++
1 file changed, 18 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 270496b7a7..462d2a8fb6 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -100,6 +100,7 @@ static struct{

CFStringRef kVTCompressionPropertyKey_RealTime;
CFStringRef kVTCompressionPropertyKey_TargetQualityForAlpha;
+CFStringRef kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality;

CFStringRef 
kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder;
CFStringRef 
kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder;
@@ -161,6 +162,8 @@ static void loadVTEncSymbols(){
GET_SYM(kVTCompressionPropertyKey_RealTime, "RealTime");
GET_SYM(kVTCompressionPropertyKey_TargetQualityForAlpha,
"TargetQualityForAlpha");
+GET_SYM(kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
+"PrioritizeEncodingSpeedOverQuality");

GET_SYM(kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder,
"EnableHardwareAcceleratedVideoEncoder");
@@ -237,6 +240,7 @@ typedef struct VTEncContext {
int allow_sw;
int require_sw;
double alpha_quality;
+int prio_speed;

bool flushing;
int has_b_frames;
@@ -1146,6 +1150,16 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
return AVERROR_EXTERNAL;
}

+// prioritize speed over quality
+if (vtctx->prio_speed) {
+status = VTSessionSetProperty(vtctx->session,
+  
compat_keys.kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
+  kCFBooleanTrue);
+if (status) {
+av_log(avctx, AV_LOG_WARNING, "PrioritizeEncodingSpeedOverQuality 
property is not supported on this device. Ignoring.\n");
+}
+}
+
if ((vtctx->codec_id == AV_CODEC_ID_H264 || vtctx->codec_id == 
AV_CODEC_ID_HEVC)
&& max_rate > 0) {
bytes_per_second_value = max_rate >> 3;
@@ -2711,6 +2725,7 @@ static const AVOption h264_options[] = {
{ "ac","CABAC entropy coding", 0, AV_OPT_TYPE_CONST, { .i64 = VT_CABAC 
}, INT_MIN, INT_MAX, VE, "coder" },

{ "a53cc", "Use A53 Closed Captions (if available)", OFFSET(a53_cc), 
AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, VE },
+{ "prio_speed", "prioritize encoding speed", OFFSET(prio_speed), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },

COMMON_OPTIONS
{ NULL },
@@ -2745,6 +2760,7 @@ static const AVOption hevc_options[] = {
{ "main10",   "Main10 Profile",   0, AV_OPT_TYPE_CONST, { .i64 = 
HEVC_PROF_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" },

{ "alpha_quality", "Compression quality for the alpha channel", 
OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE },
+{ "prio_speed", "prioritize encoding speed", OFFSET(prio_speed), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },

COMMON_OPTIONS
{ NULL },
@@ -2785,6 +2801,8 @@ static const AVOption prores_options[] = {
{ "", "ProRes ",   0, 
AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_ },INT_MIN, INT_MAX, 
VE, "profile" },
{ "xq",   "ProRes  XQ",0, 
AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_XQ },  INT_MIN, INT_MAX, 
VE, "profile" },

+  { &quo

Re: [FFmpeg-devel] [PATCH] libavcodec/videotoolboxenc.c: add option to hevc encoder to prioritize speed.

2022-04-21 Thread Simone Karin Lehmann


> Am 14.04.2022 um 10:13 schrieb Thilo Borgmann :
> 
> Hi,
> 
>>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>>> index 418ff00b8d..ab0dad6cbc 100644
>>> --- a/libavcodec/videotoolboxenc.c
>>> +++ b/libavcodec/videotoolboxenc.c
>>> @@ -236,6 +236,7 @@ typedef struct VTEncContext {
>>> int allow_sw;
>>> int require_sw;
>>> double alpha_quality;
>>> +int64_t prio_speed;
> 
> int64_t is definitely overkill.

I just wanted to make it consistent with hevc_options[] and other variables of 
AV_OPT_TYPE_BOOL. these are noted as .i64. 
Anyway, I changed it to int.

> 
>>> 
>>> bool flushing;
>>> int has_b_frames;
>>> @@ -1145,6 +1146,17 @@ static int vtenc_create_encoder(AVCodecContext   
>>> *avctx,
>>> return AVERROR_EXTERNAL;
>>> }
>>> 
>>> +// prioritize speed over quality
>>> +if (vtctx->prio_speed) {
>>> +status = VTSessionSetProperty(vtctx->session,
>>> +  
>>> kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
>>> +  kCFBooleanTrue);
>>> +if (status) {
>>> +av_log(avctx, AV_LOG_ERROR, "Error setting 
>>> PrioritizeEncodingSpeedOverQuality property: %d\n", status);
>>> +    return AVERROR_EXTERNAL;
>>> +}
> 
> If its called to priotize speed over qual, why not just print a warning and 
> continue without this option?

You’re right. A warning seems much better. Changed this too.

Here’s the modified patch. 

Signed-off-by: Simone Karin Lehmann 
---
 libavcodec/videotoolboxenc.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 270496b7a7..cf931569d1 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -237,6 +237,7 @@ typedef struct VTEncContext {
 int allow_sw;
 int require_sw;
 double alpha_quality;
+int prio_speed;
 
 bool flushing;
 int has_b_frames;
@@ -1146,6 +1147,16 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
 return AVERROR_EXTERNAL;
 }
 
+// prioritize speed over quality
+if (vtctx->prio_speed) {
+status = VTSessionSetProperty(vtctx->session,
+  
kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
+  kCFBooleanTrue);
+if (status) {
+av_log(avctx, AV_LOG_WARNING, "PrioritizeEncodingSpeedOverQuality 
property is not supported on this device. Ignoring.\n");
+}
+}
+
 if ((vtctx->codec_id == AV_CODEC_ID_H264 || vtctx->codec_id == 
AV_CODEC_ID_HEVC)
 && max_rate > 0) {
 bytes_per_second_value = max_rate >> 3;
@@ -2745,6 +2756,7 @@ static const AVOption hevc_options[] = {
 { "main10",   "Main10 Profile",   0, AV_OPT_TYPE_CONST, { .i64 = 
HEVC_PROF_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" },
 
 { "alpha_quality", "Compression quality for the alpha channel", 
OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE },
+{ "prio_speed", "prioritize encoding speed", OFFSET(prio_speed), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
 
 COMMON_OPTIONS
 { NULL },
-- 
2.32.0 (Apple Git-132)


___
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/videotoolboxenc.c: add option to hevc encoder to prioritize speed.

2022-04-13 Thread Simone Karin Lehmann
Somehow it seems, that this patch never got onto the mailing list. So may I 
kindly ask you to review it. 

--
Stay hungry, stay foolish 

> Am 26.01.2022 um 17:31 schrieb Simone Karin Lehmann :
> 
> 
> The patch adds an option to the hevc_videotoolbox encoder to prioritize speed 
> for Macs with Apple Silicon CPU.
> 
> This speeds up encodings up to 50% - 70%. In conjunction with the qcale 
> option -q, visible quality will be unchanged. The increase in file size is 
> very moderate, although still depending on the source material.
> 
> 
> Signed-off-by: Simone Karin Lehmann 
> ---
> libavcodec/videotoolboxenc.c | 13 +
> 1 file changed, 13 insertions(+)
> 
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 418ff00b8d..ab0dad6cbc 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -236,6 +236,7 @@ typedef struct VTEncContext {
> int allow_sw;
> int require_sw;
> double alpha_quality;
> +int64_t prio_speed;
> 
> bool flushing;
> int has_b_frames;
> @@ -1145,6 +1146,17 @@ static int vtenc_create_encoder(AVCodecContext   
> *avctx,
> return AVERROR_EXTERNAL;
> }
> 
> +// prioritize speed over quality
> +if (vtctx->prio_speed) {
> +status = VTSessionSetProperty(vtctx->session,
> +  
> kVTCompressionPropertyKey_PrioritizeEncodingSpeedOverQuality,
> +  kCFBooleanTrue);
> +if (status) {
> +av_log(avctx, AV_LOG_ERROR, "Error setting 
> PrioritizeEncodingSpeedOverQuality property: %d\n", status);
> +return AVERROR_EXTERNAL;
> +}
> +}
> +
> if ((vtctx->codec_id == AV_CODEC_ID_H264 || vtctx->codec_id == 
> AV_CODEC_ID_HEVC)
> && max_rate > 0) {
> bytes_per_second_value = max_rate >> 3;
> @@ -2744,6 +2756,7 @@ static const AVOption hevc_options[] = {
> { "main10",   "Main10 Profile",   0, AV_OPT_TYPE_CONST, { .i64 = 
> HEVC_PROF_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" },
> 
> { "alpha_quality", "Compression quality for the alpha channel", 
> OFFSET(alpha_quality), AV_OPT_TYPE_DOUBLE, { .dbl = 0.0 }, 0.0, 1.0, VE },
> +{ "prio_speed", "prioritize encoding speed", OFFSET(prio_speed), 
> AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
> 
> COMMON_OPTIONS
> { NULL },
> -- 
> 2.32.0 (Apple Git-132)
___
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".