2003-03-16 21:03:20 +00:00
|
|
|
/*
|
|
|
|
|
* Raw Video Codec
|
2009-01-19 15:46:40 +00:00
|
|
|
* Copyright (c) 2001 Fabrice Bellard
|
2003-03-16 21:03:20 +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
|
2003-03-16 21:03:20 +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.
|
2003-03-16 21:03:20 +00:00
|
|
|
*
|
2006-10-07 15:30:46 +00:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2003-03-16 21:03:20 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2003-03-16 21:03:20 +00:00
|
|
|
*/
|
2005-12-17 18:14:38 +00:00
|
|
|
|
2003-03-16 21:03:20 +00:00
|
|
|
/**
|
2010-04-20 14:45:34 +00:00
|
|
|
* @file
|
2003-03-16 21:03:20 +00:00
|
|
|
* Raw Video Codec
|
|
|
|
|
*/
|
2005-12-17 18:14:38 +00:00
|
|
|
|
2003-03-16 21:03:20 +00:00
|
|
|
#include "avcodec.h"
|
2007-07-09 16:26:11 +00:00
|
|
|
#include "raw.h"
|
2025-03-28 17:15:22 +01:00
|
|
|
#include "raw_pix_fmt_tags.h"
|
2014-08-07 01:22:48 -03:00
|
|
|
|
2012-10-06 12:10:34 +02:00
|
|
|
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
|
2003-05-07 19:01:45 +00:00
|
|
|
{
|
2021-03-01 18:34:26 +01:00
|
|
|
const PixelFormatTag *tags = raw_pix_fmt_tags;
|
2003-05-07 19:01:45 +00:00
|
|
|
while (tags->pix_fmt >= 0) {
|
|
|
|
|
if (tags->pix_fmt == fmt)
|
2005-12-22 01:10:11 +00:00
|
|
|
return tags->fourcc;
|
|
|
|
|
tags++;
|
2003-05-07 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2014-04-11 23:35:11 +02:00
|
|
|
|
2021-03-01 18:34:26 +01:00
|
|
|
static const PixelFormatTag pix_fmt_bps_avi[] = {
|
2016-01-28 06:15:29 +01:00
|
|
|
{ AV_PIX_FMT_PAL8, 1 },
|
2014-04-11 23:35:11 +02:00
|
|
|
{ AV_PIX_FMT_PAL8, 2 },
|
|
|
|
|
{ AV_PIX_FMT_PAL8, 4 },
|
|
|
|
|
{ AV_PIX_FMT_PAL8, 8 },
|
|
|
|
|
{ AV_PIX_FMT_RGB444LE, 12 },
|
|
|
|
|
{ AV_PIX_FMT_RGB555LE, 15 },
|
|
|
|
|
{ AV_PIX_FMT_RGB555LE, 16 },
|
|
|
|
|
{ AV_PIX_FMT_BGR24, 24 },
|
|
|
|
|
{ AV_PIX_FMT_BGRA, 32 },
|
|
|
|
|
{ AV_PIX_FMT_NONE, 0 },
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-01 18:34:26 +01:00
|
|
|
static const PixelFormatTag pix_fmt_bps_mov[] = {
|
2016-01-17 22:27:52 +01:00
|
|
|
{ AV_PIX_FMT_PAL8, 1 },
|
2014-04-11 23:35:11 +02:00
|
|
|
{ AV_PIX_FMT_PAL8, 2 },
|
|
|
|
|
{ AV_PIX_FMT_PAL8, 4 },
|
|
|
|
|
{ AV_PIX_FMT_PAL8, 8 },
|
|
|
|
|
{ AV_PIX_FMT_RGB555BE, 16 },
|
|
|
|
|
{ AV_PIX_FMT_RGB24, 24 },
|
|
|
|
|
{ AV_PIX_FMT_ARGB, 32 },
|
2016-01-17 22:27:52 +01:00
|
|
|
{ AV_PIX_FMT_PAL8, 33 },
|
2014-04-11 23:35:11 +02:00
|
|
|
{ AV_PIX_FMT_NONE, 0 },
|
|
|
|
|
};
|
2021-03-01 18:34:26 +01:00
|
|
|
|
|
|
|
|
static enum AVPixelFormat find_pix_fmt(const PixelFormatTag *tags,
|
|
|
|
|
unsigned int fourcc)
|
|
|
|
|
{
|
|
|
|
|
while (tags->pix_fmt != AV_PIX_FMT_NONE) {
|
|
|
|
|
if (tags->fourcc == fourcc)
|
|
|
|
|
return tags->pix_fmt;
|
|
|
|
|
tags++;
|
|
|
|
|
}
|
|
|
|
|
return AV_PIX_FMT_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum AVPixelFormat avpriv_pix_fmt_find(enum PixelFormatTagLists list,
|
|
|
|
|
unsigned fourcc)
|
|
|
|
|
{
|
|
|
|
|
const PixelFormatTag *tags;
|
|
|
|
|
|
|
|
|
|
switch (list) {
|
|
|
|
|
case PIX_FMT_LIST_RAW:
|
|
|
|
|
tags = raw_pix_fmt_tags;
|
|
|
|
|
break;
|
|
|
|
|
case PIX_FMT_LIST_AVI:
|
|
|
|
|
tags = pix_fmt_bps_avi;
|
|
|
|
|
break;
|
|
|
|
|
case PIX_FMT_LIST_MOV:
|
|
|
|
|
tags = pix_fmt_bps_mov;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return find_pix_fmt(tags, fourcc);
|
|
|
|
|
}
|