Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder
@ 2023-09-04  3:53 Jun Zhao
  2023-09-04  3:53 ` [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties Jun Zhao
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jun Zhao @ 2023-09-04  3:53 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jun Zhao, Jun Zhao

Dump the encoder, it's will help debug some case

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavcodec/videotoolboxenc.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index bfc03787a0..5633640a30 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1110,6 +1110,26 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
         return AVERROR_EXTERNAL;
     }
 
+    // Dump the init encoder
+    {
+        CFStringRef encoderID = NULL;
+        status = VTSessionCopyProperty(vtctx->session,
+                                       kVTCompressionPropertyKey_EncoderID,
+                                       kCFAllocatorDefault,
+                                       &encoderID);
+        if (status == noErr) {
+            char names[256] = { 0 };
+
+            CFStringGetCString(encoderID,
+                               names,
+                               255,
+                               kCFStringEncodingUTF8);
+            av_log(avctx, AV_LOG_INFO, "Init the encoder: %s\n", names);
+        }
+        if (encoderID != NULL)
+            CFRelease(encoderID);
+    }
+
     if (avctx->flags & AV_CODEC_FLAG_QSCALE && !vtenc_qscale_enabled()) {
         av_log(avctx, AV_LOG_ERROR, "Error: -q:v qscale not available for encoder. Use -b:v bitrate instead.\n");
         return AVERROR_EXTERNAL;
-- 
2.25.1

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

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties
  2023-09-04  3:53 [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder Jun Zhao
@ 2023-09-04  3:53 ` Jun Zhao
  2023-09-05  7:52   ` Tomas Härdin
  2023-09-05  7:46 ` [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder Tomas Härdin
  2023-09-05 10:43 ` Richard Kern
  2 siblings, 1 reply; 8+ messages in thread
From: Jun Zhao @ 2023-09-04  3:53 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jun Zhao, Jun Zhao

Get the encoder supported properties list, it will be used for
feature support checks.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavcodec/videotoolboxenc.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 5633640a30..8e70915225 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -232,6 +232,7 @@ typedef struct VTEncContext {
     AVClass *class;
     enum AVCodecID codec_id;
     VTCompressionSessionRef session;
+    CFDictionaryRef supported_props;
     CFStringRef ycbcr_matrix;
     CFStringRef color_primaries;
     CFStringRef transfer_function;
@@ -1110,6 +1111,18 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
         return AVERROR_EXTERNAL;
     }
 
+    status = VTCopySupportedPropertyDictionaryForEncoder(avctx->width,
+                                                         avctx->height,
+                                                         codec_type,
+                                                         enc_info,
+                                                         NULL,
+                                                         &vtctx->supported_props);
+
+    if (status != noErr) {
+        av_log(avctx, AV_LOG_ERROR,"Error retrieving the supported property dictionary err=%"PRId64"", (int64_t)status);
+        return AVERROR_EXTERNAL;
+    }
+
     // Dump the init encoder
     {
         CFStringRef encoderID = NULL;
@@ -1656,6 +1669,7 @@ static av_cold int vtenc_init(AVCodecContext *avctx)
     if (vtctx->profile == FF_PROFILE_UNKNOWN)
         vtctx->profile = avctx->profile;
     vtctx->session = NULL;
+    vtctx->supported_props = NULL;
     status = vtenc_configure_encoder(avctx);
     if (status) return status;
 
@@ -2426,6 +2440,11 @@ static int create_cv_pixel_buffer(AVCodecContext   *avctx,
         if (vtstatus == kVTInvalidSessionErr) {
             CFRelease(vtctx->session);
             vtctx->session = NULL;
+            if (vtctx->supported_props) {
+                CFRelease(vtctx->supported_props);
+                vtctx->supported_props = NULL;
+            }
+
             status = vtenc_configure_encoder(avctx);
             if (status == 0)
                 pix_buf_pool = VTCompressionSessionGetPixelBufferPool(vtctx->session);
@@ -2685,6 +2704,10 @@ pe_cleanup:
         CFRelease(vtctx->session);
 
     vtctx->session = NULL;
+    if (vtctx->supported_props) {
+        CFRelease(vtctx->supported_props);
+        vtctx->supported_props = NULL;
+    }
     vtctx->frame_ct_out = 0;
 
     av_assert0(status != 0 || (avctx->extradata && avctx->extradata_size > 0));
@@ -2709,6 +2732,10 @@ static av_cold int vtenc_close(AVCodecContext *avctx)
     pthread_mutex_destroy(&vtctx->lock);
     CFRelease(vtctx->session);
     vtctx->session = NULL;
+    if (vtctx->supported_props) {
+        CFRelease(vtctx->supported_props);
+        vtctx->supported_props = NULL;
+    }
 
     if (vtctx->color_primaries) {
         CFRelease(vtctx->color_primaries);
-- 
2.25.1

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

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder
  2023-09-04  3:53 [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder Jun Zhao
  2023-09-04  3:53 ` [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties Jun Zhao
@ 2023-09-05  7:46 ` Tomas Härdin
  2023-09-05 10:43 ` Richard Kern
  2 siblings, 0 replies; 8+ messages in thread
From: Tomas Härdin @ 2023-09-05  7:46 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

mån 2023-09-04 klockan 11:53 +0800 skrev Jun Zhao:
> Dump the encoder, it's will help debug some case
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavcodec/videotoolboxenc.c | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)

Looks OK

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

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties
  2023-09-04  3:53 ` [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties Jun Zhao
@ 2023-09-05  7:52   ` Tomas Härdin
  2023-09-05  9:36     ` mypopy
  0 siblings, 1 reply; 8+ messages in thread
From: Tomas Härdin @ 2023-09-05  7:52 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

mån 2023-09-04 klockan 11:53 +0800 skrev Jun Zhao:
> Get the encoder supported properties list, it will be used for
> feature support checks.
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavcodec/videotoolboxenc.c | 27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
> 
> diff --git a/libavcodec/videotoolboxenc.c
> b/libavcodec/videotoolboxenc.c
> index 5633640a30..8e70915225 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -232,6 +232,7 @@ typedef struct VTEncContext {
>      AVClass *class;
>      enum AVCodecID codec_id;
>      VTCompressionSessionRef session;
> +    CFDictionaryRef supported_props;
>      CFStringRef ycbcr_matrix;
>      CFStringRef color_primaries;
>      CFStringRef transfer_function;
> @@ -1110,6 +1111,18 @@ static int
> vtenc_create_encoder(AVCodecContext   *avctx,
>          return AVERROR_EXTERNAL;
>      }
>  
> +    status = VTCopySupportedPropertyDictionaryForEncoder(avctx-
> >width,
> +                                                         avctx-
> >height,
> +                                                         codec_type,
> +                                                         enc_info,
> +                                                         NULL,
> +                                                         &vtctx-
> >supported_props);
> +
> +    if (status != noErr) {
> +        av_log(avctx, AV_LOG_ERROR,"Error retrieving the supported
> property dictionary err=%"PRId64"", (int64_t)status);

Missing \n

> +        return AVERROR_EXTERNAL;
> +    }
> +
>      // Dump the init encoder
>      {
>          CFStringRef encoderID = NULL;
> @@ -1656,6 +1669,7 @@ static av_cold int vtenc_init(AVCodecContext
> *avctx)
>      if (vtctx->profile == FF_PROFILE_UNKNOWN)
>          vtctx->profile = avctx->profile;
>      vtctx->session = NULL;
> +    vtctx->supported_props = NULL;

NULLing isn't necessary since priv_data is calloc'd

>      status = vtenc_configure_encoder(avctx);
>      if (status) return status;
>  
> @@ -2426,6 +2440,11 @@ static int
> create_cv_pixel_buffer(AVCodecContext   *avctx,
>          if (vtstatus == kVTInvalidSessionErr) {
>              CFRelease(vtctx->session);
>              vtctx->session = NULL;
> +            if (vtctx->supported_props) {
> +                CFRelease(vtctx->supported_props);
> +                vtctx->supported_props = NULL;
> +            }
> +
>              status = vtenc_configure_encoder(avctx);
>              if (status == 0)
>                  pix_buf_pool =
> VTCompressionSessionGetPixelBufferPool(vtctx->session);
> @@ -2685,6 +2704,10 @@ pe_cleanup:
>          CFRelease(vtctx->session);
>  
>      vtctx->session = NULL;
> +    if (vtctx->supported_props) {
> +        CFRelease(vtctx->supported_props);
> +        vtctx->supported_props = NULL;
> +    }
>      vtctx->frame_ct_out = 0;
>  
>      av_assert0(status != 0 || (avctx->extradata && avctx-
> >extradata_size > 0));
> @@ -2709,6 +2732,10 @@ static av_cold int vtenc_close(AVCodecContext
> *avctx)
>      pthread_mutex_destroy(&vtctx->lock);
>      CFRelease(vtctx->session);
>      vtctx->session = NULL;
> +    if (vtctx->supported_props) {
> +        CFRelease(vtctx->supported_props);
> +        vtctx->supported_props = NULL;
> +    }

Copy-pasting this in three places looks ugly. Moving cleanup of session
and supported_props to a small function would reduce the number of
lines and look prettier.

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

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties
  2023-09-05  7:52   ` Tomas Härdin
@ 2023-09-05  9:36     ` mypopy
  2023-09-05  9:49       ` "zhilizhao(赵志立)"
  0 siblings, 1 reply; 8+ messages in thread
From: mypopy @ 2023-09-05  9:36 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

On Tue, Sep 5, 2023 at 3:52 PM Tomas Härdin <git@haerdin.se> wrote:
>
> mån 2023-09-04 klockan 11:53 +0800 skrev Jun Zhao:
> > Get the encoder supported properties list, it will be used for
> > feature support checks.
> >
> > Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> > ---
> >  libavcodec/videotoolboxenc.c | 27 +++++++++++++++++++++++++++
> >  1 file changed, 27 insertions(+)
> >
> > diff --git a/libavcodec/videotoolboxenc.c
> > b/libavcodec/videotoolboxenc.c
> > index 5633640a30..8e70915225 100644
> > --- a/libavcodec/videotoolboxenc.c
> > +++ b/libavcodec/videotoolboxenc.c
> > @@ -232,6 +232,7 @@ typedef struct VTEncContext {
> >      AVClass *class;
> >      enum AVCodecID codec_id;
> >      VTCompressionSessionRef session;
> > +    CFDictionaryRef supported_props;
> >      CFStringRef ycbcr_matrix;
> >      CFStringRef color_primaries;
> >      CFStringRef transfer_function;
> > @@ -1110,6 +1111,18 @@ static int
> > vtenc_create_encoder(AVCodecContext   *avctx,
> >          return AVERROR_EXTERNAL;
> >      }
> >
> > +    status = VTCopySupportedPropertyDictionaryForEncoder(avctx-
> > >width,
> > +                                                         avctx-
> > >height,
> > +                                                         codec_type,
> > +                                                         enc_info,
> > +                                                         NULL,
> > +                                                         &vtctx-
> > >supported_props);
> > +
> > +    if (status != noErr) {
> > +        av_log(avctx, AV_LOG_ERROR,"Error retrieving the supported
> > property dictionary err=%"PRId64"", (int64_t)status);
>
> Missing \n
Good catch
>
> > +        return AVERROR_EXTERNAL;
> > +    }
> > +
> >      // Dump the init encoder
> >      {
> >          CFStringRef encoderID = NULL;
> > @@ -1656,6 +1669,7 @@ static av_cold int vtenc_init(AVCodecContext
> > *avctx)
> >      if (vtctx->profile == FF_PROFILE_UNKNOWN)
> >          vtctx->profile = avctx->profile;
> >      vtctx->session = NULL;
> > +    vtctx->supported_props = NULL;
>
> NULLing isn't necessary since priv_data is calloc'd
Yes,I know this, just following the old code behaviour,maybe need to
refine the old code
>
> >      status = vtenc_configure_encoder(avctx);
> >      if (status) return status;
> >
> > @@ -2426,6 +2440,11 @@ static int
> > create_cv_pixel_buffer(AVCodecContext   *avctx,
> >          if (vtstatus == kVTInvalidSessionErr) {
> >              CFRelease(vtctx->session);
> >              vtctx->session = NULL;
> > +            if (vtctx->supported_props) {
> > +                CFRelease(vtctx->supported_props);
> > +                vtctx->supported_props = NULL;
> > +            }
> > +
> >              status = vtenc_configure_encoder(avctx);
> >              if (status == 0)
> >                  pix_buf_pool =
> > VTCompressionSessionGetPixelBufferPool(vtctx->session);
> > @@ -2685,6 +2704,10 @@ pe_cleanup:
> >          CFRelease(vtctx->session);
> >
> >      vtctx->session = NULL;
> > +    if (vtctx->supported_props) {
> > +        CFRelease(vtctx->supported_props);
> > +        vtctx->supported_props = NULL;
> > +    }
> >      vtctx->frame_ct_out = 0;
> >
> >      av_assert0(status != 0 || (avctx->extradata && avctx-
> > >extradata_size > 0));
> > @@ -2709,6 +2732,10 @@ static av_cold int vtenc_close(AVCodecContext
> > *avctx)
> >      pthread_mutex_destroy(&vtctx->lock);
> >      CFRelease(vtctx->session);
> >      vtctx->session = NULL;
> > +    if (vtctx->supported_props) {
> > +        CFRelease(vtctx->supported_props);
> > +        vtctx->supported_props = NULL;
> > +    }
>
> Copy-pasting this in three places looks ugly. Moving cleanup of session
> and supported_props to a small function would reduce the number of
> lines and look prettier.
>
It makes more sense.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties
  2023-09-05  9:36     ` mypopy
@ 2023-09-05  9:49       ` "zhilizhao(赵志立)"
  0 siblings, 0 replies; 8+ messages in thread
From: "zhilizhao(赵志立)" @ 2023-09-05  9:49 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> On Sep 5, 2023, at 17:36, mypopy@gmail.com wrote:
> 
> On Tue, Sep 5, 2023 at 3:52 PM Tomas Härdin <git@haerdin.se> wrote:
>> 
>> mån 2023-09-04 klockan 11:53 +0800 skrev Jun Zhao:
>>> Get the encoder supported properties list, it will be used for
>>> feature support checks.
>>> 
>>> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
>>> ---
>>> libavcodec/videotoolboxenc.c | 27 +++++++++++++++++++++++++++
>>> 1 file changed, 27 insertions(+)
>>> 
>>> diff --git a/libavcodec/videotoolboxenc.c
>>> b/libavcodec/videotoolboxenc.c
>>> index 5633640a30..8e70915225 100644
>>> --- a/libavcodec/videotoolboxenc.c
>>> +++ b/libavcodec/videotoolboxenc.c
>>> @@ -232,6 +232,7 @@ typedef struct VTEncContext {
>>>     AVClass *class;
>>>     enum AVCodecID codec_id;
>>>     VTCompressionSessionRef session;
>>> +    CFDictionaryRef supported_props;
>>>     CFStringRef ycbcr_matrix;
>>>     CFStringRef color_primaries;
>>>     CFStringRef transfer_function;
>>> @@ -1110,6 +1111,18 @@ static int
>>> vtenc_create_encoder(AVCodecContext   *avctx,
>>>         return AVERROR_EXTERNAL;
>>>     }
>>> 
>>> +    status = VTCopySupportedPropertyDictionaryForEncoder(avctx-
>>>> width,
>>> +                                                         avctx-
>>>> height,
>>> +                                                         codec_type,
>>> +                                                         enc_info,
>>> +                                                         NULL,
>>> +                                                         &vtctx-
>>>> supported_props);
>>> +
>>> +    if (status != noErr) {
>>> +        av_log(avctx, AV_LOG_ERROR,"Error retrieving the supported
>>> property dictionary err=%"PRId64"", (int64_t)status);
>> 
>> Missing \n
> Good catch
>> 
>>> +        return AVERROR_EXTERNAL;
>>> +    }
>>> +
>>>     // Dump the init encoder
>>>     {
>>>         CFStringRef encoderID = NULL;
>>> @@ -1656,6 +1669,7 @@ static av_cold int vtenc_init(AVCodecContext
>>> *avctx)
>>>     if (vtctx->profile == FF_PROFILE_UNKNOWN)
>>>         vtctx->profile = avctx->profile;
>>>     vtctx->session = NULL;
>>> +    vtctx->supported_props = NULL;
>> 
>> NULLing isn't necessary since priv_data is calloc'd
> Yes,I know this, just following the old code behaviour,maybe need to
> refine the old code

On one hand, calloc() isn’t the same as set these pointers to NULL,
since NULL isn’t always all-zero-bits.

On the other hand, NULL is assumed all-zero-bits everywhere.

Both works for me. I don’t want to enforce any style.

>> 
>>>     status = vtenc_configure_encoder(avctx);
>>>     if (status) return status;
>>> 
>>> @@ -2426,6 +2440,11 @@ static int
>>> create_cv_pixel_buffer(AVCodecContext   *avctx,
>>>         if (vtstatus == kVTInvalidSessionErr) {
>>>             CFRelease(vtctx->session);
>>>             vtctx->session = NULL;
>>> +            if (vtctx->supported_props) {
>>> +                CFRelease(vtctx->supported_props);
>>> +                vtctx->supported_props = NULL;
>>> +            }
>>> +
>>>             status = vtenc_configure_encoder(avctx);
>>>             if (status == 0)
>>>                 pix_buf_pool =
>>> VTCompressionSessionGetPixelBufferPool(vtctx->session);
>>> @@ -2685,6 +2704,10 @@ pe_cleanup:
>>>         CFRelease(vtctx->session);
>>> 
>>>     vtctx->session = NULL;
>>> +    if (vtctx->supported_props) {
>>> +        CFRelease(vtctx->supported_props);
>>> +        vtctx->supported_props = NULL;
>>> +    }
>>>     vtctx->frame_ct_out = 0;
>>> 
>>>     av_assert0(status != 0 || (avctx->extradata && avctx-
>>>> extradata_size > 0));
>>> @@ -2709,6 +2732,10 @@ static av_cold int vtenc_close(AVCodecContext
>>> *avctx)
>>>     pthread_mutex_destroy(&vtctx->lock);
>>>     CFRelease(vtctx->session);
>>>     vtctx->session = NULL;
>>> +    if (vtctx->supported_props) {
>>> +        CFRelease(vtctx->supported_props);
>>> +        vtctx->supported_props = NULL;
>>> +    }
>> 
>> Copy-pasting this in three places looks ugly. Moving cleanup of session
>> and supported_props to a small function would reduce the number of
>> lines and look prettier.
>> 
> It makes more sense.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder
  2023-09-04  3:53 [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder Jun Zhao
  2023-09-04  3:53 ` [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties Jun Zhao
  2023-09-05  7:46 ` [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder Tomas Härdin
@ 2023-09-05 10:43 ` Richard Kern
  2023-09-05 10:47   ` "zhilizhao(赵志立)"
  2 siblings, 1 reply; 8+ messages in thread
From: Richard Kern @ 2023-09-05 10:43 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Jun Zhao, Jun Zhao



> On Sep 3, 2023, at 11:53 PM, Jun Zhao <mypopydev@gmail.com> wrote:
> 
> Dump the encoder, it's will help debug some case
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
> libavcodec/videotoolboxenc.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
> 
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index bfc03787a0..5633640a30 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -1110,6 +1110,26 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
>         return AVERROR_EXTERNAL;
>     }
> 
> +    // Dump the init encoder
> +    {
> +        CFStringRef encoderID = NULL;
> +        status = VTSessionCopyProperty(vtctx->session,
> +                                       kVTCompressionPropertyKey_EncoderID,
> +                                       kCFAllocatorDefault,
> +                                       &encoderID);
> +        if (status == noErr) {
> +            char names[256] = { 0 };
> +
> +            CFStringGetCString(encoderID,
> +                               names,
> +                               255,
Use sizeof(names) - 1 instead of 255. The hard coded value increases the chance of a bug if the size of names is changed. 

> +                               kCFStringEncodingUTF8);
> +            av_log(avctx, AV_LOG_INFO, "Init the encoder: %s\n", names);
This should be logged at the debug level since it doesn’t help users when encoding is successful. 

> +        }
> +        if (encoderID != NULL)
> +            CFRelease(encoderID);
> +    }
> +
>     if (avctx->flags & AV_CODEC_FLAG_QSCALE && !vtenc_qscale_enabled()) {
>         av_log(avctx, AV_LOG_ERROR, "Error: -q:v qscale not available for encoder. Use -b:v bitrate instead.\n");
>         return AVERROR_EXTERNAL;
> -- 
> 2.25.1
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder
  2023-09-05 10:43 ` Richard Kern
@ 2023-09-05 10:47   ` "zhilizhao(赵志立)"
  0 siblings, 0 replies; 8+ messages in thread
From: "zhilizhao(赵志立)" @ 2023-09-05 10:47 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



> On Sep 5, 2023, at 18:43, Richard Kern <kernrj@gmail.com> wrote:
> 
> 
> 
>> On Sep 3, 2023, at 11:53 PM, Jun Zhao <mypopydev@gmail.com> wrote:
>> 
>> Dump the encoder, it's will help debug some case
>> 
>> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
>> ---
>> libavcodec/videotoolboxenc.c | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>> 
>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>> index bfc03787a0..5633640a30 100644
>> --- a/libavcodec/videotoolboxenc.c
>> +++ b/libavcodec/videotoolboxenc.c
>> @@ -1110,6 +1110,26 @@ static int vtenc_create_encoder(AVCodecContext   *avctx,
>>        return AVERROR_EXTERNAL;
>>    }
>> 
>> +    // Dump the init encoder
>> +    {
>> +        CFStringRef encoderID = NULL;

Nit: encoder_id.

>> +        status = VTSessionCopyProperty(vtctx->session,
>> +                                       kVTCompressionPropertyKey_EncoderID,
>> +                                       kCFAllocatorDefault,
>> +                                       &encoderID);
>> +        if (status == noErr) {
>> +            char names[256] = { 0 };
>> +
>> +            CFStringGetCString(encoderID,
>> +                               names,
>> +                               255,
> Use sizeof(names) - 1 instead of 255. The hard coded value increases the chance of a bug if the size of names is changed. 
> 
>> +                               kCFStringEncodingUTF8);
>> +            av_log(avctx, AV_LOG_INFO, "Init the encoder: %s\n", names);
> This should be logged at the debug level since it doesn’t help users when encoding is successful. 
> 
>> +        }
>> +        if (encoderID != NULL)
>> +            CFRelease(encoderID);
>> +    }

How about extract it to a function so the encoder id can be used in error message?

>> +
>>    if (avctx->flags & AV_CODEC_FLAG_QSCALE && !vtenc_qscale_enabled()) {
>>        av_log(avctx, AV_LOG_ERROR, "Error: -q:v qscale not available for encoder. Use -b:v bitrate instead.\n");
>>        return AVERROR_EXTERNAL;
>> -- 
>> 2.25.1
>> 
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@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-request@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-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-05 10:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-04  3:53 [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder Jun Zhao
2023-09-04  3:53 ` [FFmpeg-devel] [PATCH 2/2] lavc/videotoolboxenc: Get the encoder supported properties Jun Zhao
2023-09-05  7:52   ` Tomas Härdin
2023-09-05  9:36     ` mypopy
2023-09-05  9:49       ` "zhilizhao(赵志立)"
2023-09-05  7:46 ` [FFmpeg-devel] [PATCH 1/2] lavc/videotoolboxenc: Dump the encoder Tomas Härdin
2023-09-05 10:43 ` Richard Kern
2023-09-05 10:47   ` "zhilizhao(赵志立)"

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git