diff mbox

[FFmpeg-devel] avcodec: make the avcodec_get_chroma_sub_sample deprecation effective

Message ID 20170825150953.2128-1-jamrial@gmail.com
State Accepted
Commit 2c800eb7375c65ffd56164b03bb035bdb3f1e172
Headers show

Commit Message

James Almer Aug. 25, 2017, 3:09 p.m. UTC
---
 libavcodec/avcodec.h | 16 ++++------------
 libavcodec/version.h |  6 +++---
 2 files changed, 7 insertions(+), 15 deletions(-)

Comments

Ronald S. Bultje Aug. 25, 2017, 3:16 p.m. UTC | #1
Hi,

On Fri, Aug 25, 2017 at 11:09 AM, James Almer <jamrial@gmail.com> wrote:

> ---
>  libavcodec/avcodec.h | 16 ++++------------
>  libavcodec/version.h |  6 +++---
>  2 files changed, 7 insertions(+), 15 deletions(-)


Thanks :)

Ronald
James Almer Aug. 25, 2017, 3:20 p.m. UTC | #2
On 8/25/2017 12:16 PM, Ronald S. Bultje wrote:
> Hi,
> 
> On Fri, Aug 25, 2017 at 11:09 AM, James Almer <jamrial@gmail.com> wrote:
> 
>> ---
>>  libavcodec/avcodec.h | 16 ++++------------
>>  libavcodec/version.h |  6 +++---
>>  2 files changed, 7 insertions(+), 15 deletions(-)
> 
> 
> Thanks :)
> 
> Ronald

Pushed.
Michael Niedermayer Aug. 25, 2017, 4:29 p.m. UTC | #3
On Fri, Aug 25, 2017 at 12:09:53PM -0300, James Almer wrote:
> ---
>  libavcodec/avcodec.h | 16 ++++------------
>  libavcodec/version.h |  6 +++---
>  2 files changed, 7 insertions(+), 15 deletions(-)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index c594993766..655555092a 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -5665,22 +5665,14 @@ int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
>   * @{
>   */
>  
> +#if FF_API_GETCHROMA
>  /**
> - * Utility function to access log2_chroma_w log2_chroma_h from
> - * the pixel format AVPixFmtDescriptor.
> - *
> - * This function asserts that pix_fmt is valid. See av_pix_fmt_get_chroma_sub_sample
> - * for one that returns a failure code and continues in case of invalid
> - * pix_fmts.
> - *
> - * @param[in]  pix_fmt the pixel format
> - * @param[out] h_shift store log2_chroma_w
> - * @param[out] v_shift store log2_chroma_h
> - *
> - * @see av_pix_fmt_get_chroma_sub_sample
> + * @deprecated Use av_pix_fmt_get_chroma_sub_sample
>   */
>  
> +attribute_deprecated
>  void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
> +#endif

As avcodec_get_chroma_sub_sample() is inherently safe while
av_pix_fmt_get_chroma_sub_sample() is not

please make sure every use of av_pix_fmt_get_chroma_sub_sample() has
its return code checked. Either through code review or through adding
an explicit check.
avcodec_get_chroma_sub_sample() cannot fail so it didnt need that.
av_pix_fmt_get_chroma_sub_sample() can fail so its needed to check it
for failure.

Given above, i would favor the API that internally checks and doesnt
require an external check.

[...]
diff mbox

Patch

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index c594993766..655555092a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -5665,22 +5665,14 @@  int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
  * @{
  */
 
+#if FF_API_GETCHROMA
 /**
- * Utility function to access log2_chroma_w log2_chroma_h from
- * the pixel format AVPixFmtDescriptor.
- *
- * This function asserts that pix_fmt is valid. See av_pix_fmt_get_chroma_sub_sample
- * for one that returns a failure code and continues in case of invalid
- * pix_fmts.
- *
- * @param[in]  pix_fmt the pixel format
- * @param[out] h_shift store log2_chroma_w
- * @param[out] v_shift store log2_chroma_h
- *
- * @see av_pix_fmt_get_chroma_sub_sample
+ * @deprecated Use av_pix_fmt_get_chroma_sub_sample
  */
 
+attribute_deprecated
 void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift);
+#endif
 
 /**
  * Return a value representing the fourCC code associated to the
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 7473000579..48e57bd86b 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -60,9 +60,6 @@ 
 #ifndef FF_API_AVCODEC_RESAMPLE
 #define FF_API_AVCODEC_RESAMPLE  FF_API_AUDIO_CONVERT
 #endif
-#ifndef FF_API_GETCHROMA
-#define FF_API_GETCHROMA         (LIBAVCODEC_VERSION_MAJOR < 58)
-#endif
 #ifndef FF_API_MISSING_SAMPLE
 #define FF_API_MISSING_SAMPLE    (LIBAVCODEC_VERSION_MAJOR < 58)
 #endif
@@ -238,6 +235,9 @@ 
 #ifndef FF_API_TAG_STRING
 #define FF_API_TAG_STRING        (LIBAVCODEC_VERSION_MAJOR < 59)
 #endif
+#ifndef FF_API_GETCHROMA
+#define FF_API_GETCHROMA         (LIBAVCODEC_VERSION_MAJOR < 59)
+#endif
 
 
 #endif /* AVCODEC_VERSION_H */