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