[FFmpeg-devel] [PATCH] Fixes avcodec_find_best_pix_fmt() with more than 64 pix fmts defined

Michael Niedermayer michaelni at gmx.at
Fri Aug 26 18:10:54 CEST 2011


On Sun, Aug 21, 2011 at 04:19:14PM -0400, Matthew Einhorn wrote:
> On Sun, Aug 21, 2011 at 2:56 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
[...]
> ---
>  libavcodec/avcodec.h    |   34 ++++++++++++++++++++++++++++++++
>  libavcodec/imgconvert.c |   49 ++++++++++++++++++++++++++++++++++------------
>  2 files changed, 70 insertions(+), 13 deletions(-)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 4f0ed2d..6578d5d 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -3511,6 +3511,40 @@ int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_
>  enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
>                                int has_alpha, int *loss_ptr);
>  
> +/**
> + * Find the best pixel format to convert to given a certain source pixel
> + * format and a selection of two destination pixel formats. When converting from
> + * one pixel format to another, information loss may occur.  For example, when converting
> + * from RGB24 to GRAY, the color information will be lost. Similarly, other losses occur when
> + * converting from some formats to other formats. avcodec_find_best_pix_fmt2() selects which of
> + * the given pixel formats should be used to suffer the least amount of loss.
> + *
> + * If one of the destination formats is PIX_FMT_NONE the other pixel format (if valid) will be

> + * returned. If two destination pixel formats have similar losses, the one with smallest
> + * average bit depth will be chosen.

It is probably better not to restrict the API this way


> + *
> + * @code
> + * src_pix_fmt = PIX_FMT_YUV420P;
> + * dst_pix_fmt1= PIX_FMT_RGB24;
> + * dst_pix_fmt2= PIX_FMT_GRAY8;
> + * dst_pix_fmt3= PIX_FMT_RGB8;
> + * loss= FF_LOSS_CHROMA; // don't care about chroma loss, so chroma loss will be ignored.
> + * dst_pix_fmt = avcodec_find_best_pix_fmt2(dst_pix_fmt1, dst_pix_fmt2, src_pix_fmt, alpha, &loss);
> + * dst_pix_fmt = avcodec_find_best_pix_fmt2(dst_pix_fmt, dst_pix_fmt3, src_pix_fmt, alpha, &loss);
> + * @endcode
> + *
> + * @param[in] dst_pix_fmt1 One of the two destination pixel formats to choose from
> + * @param[in] dst_pix_fmt2 The other of the two destination pixel formats to choose from
> + * @param[in] src_pix_fmt Source pixel format
> + * @param[in] has_alpha Whether the source pixel format alpha channel is used.
> + * @param[in, out] loss_ptr Combination of loss flags. In: selects which of the losses to ignore, i.e.
> + *                               NULL or value of zero means we care about all losses. Out: the loss
> + *                               that occurs when converting from src to selected dst pixel format.
> + * @return The best pixel format to convert to or -1 if none was found.
> + */
> +enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2,
> +                                            enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr)
> +
>  #define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */

this doesnt compile

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20110826/e20ef201/attachment.asc>


More information about the ffmpeg-devel mailing list