Re: [libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-10-04 Thread Vittorio Giovara
On Tue, Oct 4, 2016 at 11:50 AM, Hendrik Leppkes  wrote:
> On Tue, Oct 4, 2016 at 5:45 PM, Vittorio Giovara
>  wrote:
>> ---
>>  libavcodec/avcodec.h | 6 --
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index 167525d..a59d7e9 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -5017,12 +5017,14 @@ typedef struct AVBSFContext {
>>  void *priv_data;
>>
>>  /**
>> - * Parameters of the input stream. Set by the caller before 
>> av_bsf_init().
>> + * Parameters of the input stream. This field is allocated in 
>> av_bsf_init(),
>> + * Needs to be initialized by the caller before av_bsf_init().
>>   */
>>  AVCodecParameters *par_in;
>
> This makes no sense to me. The caller inits it but the function then
> allocates it afterwards? Wut?

ops, typo, let me resend
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-10-04 Thread Hendrik Leppkes
On Tue, Oct 4, 2016 at 5:45 PM, Vittorio Giovara
 wrote:
> ---
>  libavcodec/avcodec.h | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 167525d..a59d7e9 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -5017,12 +5017,14 @@ typedef struct AVBSFContext {
>  void *priv_data;
>
>  /**
> - * Parameters of the input stream. Set by the caller before 
> av_bsf_init().
> + * Parameters of the input stream. This field is allocated in 
> av_bsf_init(),
> + * Needs to be initialized by the caller before av_bsf_init().
>   */
>  AVCodecParameters *par_in;

This makes no sense to me. The caller inits it but the function then
allocates it afterwards? Wut?

>
>  /**
> - * Parameters of the output stream. Set by the filter in av_bsf_init().
> + * Parameters of the output stream. This field is allocated in
> + * av_bsf_init(), it is set by the filter in av_bsf_init().
>   */
>  AVCodecParameters *par_out;
>
> --
> 2.10.0
>
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-10-04 Thread Vittorio Giovara
---
 libavcodec/avcodec.h | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 167525d..a59d7e9 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -5017,12 +5017,14 @@ typedef struct AVBSFContext {
 void *priv_data;
 
 /**
- * Parameters of the input stream. Set by the caller before av_bsf_init().
+ * Parameters of the input stream. This field is allocated in 
av_bsf_init(),
+ * Needs to be initialized by the caller before av_bsf_init().
  */
 AVCodecParameters *par_in;
 
 /**
- * Parameters of the output stream. Set by the filter in av_bsf_init().
+ * Parameters of the output stream. This field is allocated in
+ * av_bsf_init(), it is set by the filter in av_bsf_init().
  */
 AVCodecParameters *par_out;
 
-- 
2.10.0

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


Re: [libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-07-21 Thread Vittorio Giovara
On Thu, Jul 21, 2016 at 10:49 AM, Anton Khirnov  wrote:
> Quoting Vittorio Giovara (2016-07-20 21:26:26)
>> ---
>> More compact and typo-free.
>> Vittorio
>>
>>  libavcodec/avcodec.h | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index ace761d..72665ba 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -4985,6 +4985,9 @@ typedef struct AVBSFInternal AVBSFInternal;
>>   * The fields in the struct will only be changed (by the caller or by the
>>   * filter) as described in their documentation, and are to be considered
>>   * immutable otherwise.
>> + *
>> + * @note Input and output AVCodecParameters are allocated in av_bsf_alloc(),
>> + *   they need to be initialized via avcodec_parameters_copy().
>
> This is not correct:
> - you don't have to use specifically avcodec_parameters_copy(), the
>   parameters can also be set manually or through
>   avcodec_parameters_from_context() or through some other functions we
>   may add in the future

OK, but this is absolutely unclear: for example in my case I assigned
par_in to stream->codecpar, and the world crashed when i was either
freeing the format context or the bsf. I think it should be made very
clear not to do that.

> - only the input parameters are filled by the caller. The output
>   parameters are set by the filter, as is already documented.

So what should be done with them? copy back to stream after init?
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-07-21 Thread Anton Khirnov
Quoting Vittorio Giovara (2016-07-20 21:26:26)
> ---
> More compact and typo-free.
> Vittorio
> 
>  libavcodec/avcodec.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index ace761d..72665ba 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -4985,6 +4985,9 @@ typedef struct AVBSFInternal AVBSFInternal;
>   * The fields in the struct will only be changed (by the caller or by the
>   * filter) as described in their documentation, and are to be considered
>   * immutable otherwise.
> + *
> + * @note Input and output AVCodecParameters are allocated in av_bsf_alloc(),
> + *   they need to be initialized via avcodec_parameters_copy().

This is not correct:
- you don't have to use specifically avcodec_parameters_copy(), the
  parameters can also be set manually or through
  avcodec_parameters_from_context() or through some other functions we
  may add in the future
- only the input parameters are filled by the caller. The output
  parameters are set by the filter, as is already documented.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-07-20 Thread Luca Barbato
On 20/07/16 21:26, Vittorio Giovara wrote:
> ---
> More compact and typo-free.
> Vittorio
> 
>  libavcodec/avcodec.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index ace761d..72665ba 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -4985,6 +4985,9 @@ typedef struct AVBSFInternal AVBSFInternal;
>   * The fields in the struct will only be changed (by the caller or by the
>   * filter) as described in their documentation, and are to be considered
>   * immutable otherwise.
> + *
> + * @note Input and output AVCodecParameters are allocated in av_bsf_alloc(),
> + *   they need to be initialized via avcodec_parameters_copy().
>   */
>  typedef struct AVBSFContext {
>  /**
> 

Seems ok to me.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-07-20 Thread Vittorio Giovara
---
More compact and typo-free.
Vittorio

 libavcodec/avcodec.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ace761d..72665ba 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4985,6 +4985,9 @@ typedef struct AVBSFInternal AVBSFInternal;
  * The fields in the struct will only be changed (by the caller or by the
  * filter) as described in their documentation, and are to be considered
  * immutable otherwise.
+ *
+ * @note Input and output AVCodecParameters are allocated in av_bsf_alloc(),
+ *   they need to be initialized via avcodec_parameters_copy().
  */
 typedef struct AVBSFContext {
 /**
-- 
2.9.1

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


Re: [libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-07-20 Thread Luca Barbato
On 20/07/16 21:16, Vittorio Giovara wrote:
> ---
> slightly stronger wording
> Vittorio
> 
>  libavcodec/avcodec.h | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index ace761d..29b6bbc 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -4985,6 +4985,10 @@ typedef struct AVBSFInternal AVBSFInternal;
>   * The fields in the struct will only be changed (by the caller or by the
>   * filter) as described in their documentation, and are to be considered
>   * immutable otherwise.
> + *
> + * @note Input and output AVCodecParameters wwnership will be transferred

s/ww/ow/ ?


> + *   the context after av_bsf_init(), so you may need to use
> + *   avcodec_parameters_copy() to initiaze these fields.
>   */
>  typedef struct AVBSFContext {
>  /**
> 

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


[libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-07-20 Thread Vittorio Giovara
---
slightly stronger wording
Vittorio

 libavcodec/avcodec.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ace761d..29b6bbc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4985,6 +4985,10 @@ typedef struct AVBSFInternal AVBSFInternal;
  * The fields in the struct will only be changed (by the caller or by the
  * filter) as described in their documentation, and are to be considered
  * immutable otherwise.
+ *
+ * @note Input and output AVCodecParameters wwnership will be transferred
+ *   the context after av_bsf_init(), so you may need to use
+ *   avcodec_parameters_copy() to initiaze these fields.
  */
 typedef struct AVBSFContext {
 /**
-- 
2.9.1

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


[libav-devel] [PATCH] lavc: Document in/out AVCodecParameters ownership in AVBSFContext

2016-07-20 Thread Vittorio Giovara
---
 libavcodec/avcodec.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ace761d..a75a245 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -4985,6 +4985,10 @@ typedef struct AVBSFInternal AVBSFInternal;
  * The fields in the struct will only be changed (by the caller or by the
  * filter) as described in their documentation, and are to be considered
  * immutable otherwise.
+ *
+ * @note Input and output AVCodecParameters wwnership will be transferred
+ *   the context after av_bsf_init(), so you may need to use
+ *   avcodec_parameters_copy(), rather than assigning a reference.
  */
 typedef struct AVBSFContext {
 /**
-- 
2.9.1

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