2001-07-22 14:18:56 +00:00
|
|
|
/*
|
2007-07-17 12:57:50 +00:00
|
|
|
* Misc image conversion routines
|
2009-01-19 15:46:40 +00:00
|
|
|
* Copyright (c) 2001, 2002, 2003 Fabrice Bellard
|
2001-07-22 14:18:56 +00:00
|
|
|
*
|
2006-10-07 15:30:46 +00:00
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2002-05-25 22:45:33 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2006-10-07 15:30:46 +00:00
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2001-07-22 14:18:56 +00:00
|
|
|
*
|
2006-10-07 15:30:46 +00:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2001-07-22 14:18:56 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2002-05-25 22:45:33 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-07-22 14:18:56 +00:00
|
|
|
*
|
2002-05-25 22:45:33 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2006-10-07 15:30:46 +00:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2006-01-12 22:43:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-07-22 14:18:56 +00:00
|
|
|
*/
|
2003-03-06 11:32:04 +00:00
|
|
|
|
|
|
|
/**
|
2010-04-20 14:45:34 +00:00
|
|
|
* @file
|
2007-07-17 12:57:50 +00:00
|
|
|
* misc image conversion routines
|
2003-03-06 11:32:04 +00:00
|
|
|
*/
|
|
|
|
|
2001-07-22 14:18:56 +00:00
|
|
|
#include "avcodec.h"
|
2009-11-25 23:52:20 +00:00
|
|
|
#include "libavutil/pixdesc.h"
|
2021-02-26 06:19:42 +01:00
|
|
|
#include "libavutil/pixfmt.h"
|
2001-07-22 14:18:56 +00:00
|
|
|
|
2013-09-09 22:32:03 -06:00
|
|
|
enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list,
|
2012-10-08 20:54:00 +02:00
|
|
|
enum AVPixelFormat src_pix_fmt,
|
2012-07-15 01:50:02 +02:00
|
|
|
int has_alpha, int *loss_ptr){
|
|
|
|
int i;
|
|
|
|
|
2012-10-08 20:54:00 +02:00
|
|
|
enum AVPixelFormat best = AV_PIX_FMT_NONE;
|
2018-03-31 19:37:23 +07:00
|
|
|
int loss;
|
2012-07-15 01:50:02 +02:00
|
|
|
|
2018-03-31 19:37:23 +07:00
|
|
|
for (i=0; pix_fmt_list[i] != AV_PIX_FMT_NONE; i++) {
|
2018-04-03 14:41:33 +02:00
|
|
|
loss = loss_ptr ? *loss_ptr : 0;
|
2021-02-26 07:38:33 +01:00
|
|
|
best = av_find_best_pix_fmt_of_2(best, pix_fmt_list[i], src_pix_fmt, has_alpha, &loss);
|
2018-03-31 19:37:23 +07:00
|
|
|
}
|
2012-07-15 01:50:02 +02:00
|
|
|
|
2018-04-03 14:41:33 +02:00
|
|
|
if (loss_ptr)
|
|
|
|
*loss_ptr = loss;
|
2012-07-15 01:50:02 +02:00
|
|
|
return best;
|
|
|
|
}
|
|
|
|
|