[FFmpeg-devel] [PATCH] Fixes avcodec_find_best_pix_fmt() with more than 64 pix fmts defined
Matthew Einhorn
moiein2000 at gmail.com
Fri Aug 26 18:32:13 CEST 2011
On Fri, Aug 26, 2011 at 12:10 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> 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
How else should I chose from two fmts with identical loss? Or should I
return any one of them, or PIX_FMT_NONE? The old function did it this
way (returned the one with smallest loss). Or did you mean about
PIX_FMT_NONE.
>
>
>> + *
>> + * @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
Sorry, forgot the semicolon. Will fix it.
Thanks,Matt
More information about the ffmpeg-devel
mailing list