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

Michael Niedermayer michael at niedermayer.cc
Fri Aug 25 19:29:51 EEST 2017


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.

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170825/646152ed/attachment.sig>


More information about the ffmpeg-devel mailing list