1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/*
* Raw Video Codec
* Copyright (c) 2001 Fabrice Bellard
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* 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
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* Raw Video Codec
*/
#include "avcodec.h"
#include "raw.h"
#include "raw_pix_fmt_tags.h"
unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat fmt)
{
const PixelFormatTag *tags = raw_pix_fmt_tags;
while (tags->pix_fmt >= 0) {
if (tags->pix_fmt == fmt)
return tags->fourcc;
tags++;
}
return 0;
}
static const PixelFormatTag pix_fmt_bps_avi[] = {
{ AV_PIX_FMT_PAL8, 1 },
{ 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 },
};
static const PixelFormatTag pix_fmt_bps_mov[] = {
{ AV_PIX_FMT_PAL8, 1 },
{ 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 },
{ AV_PIX_FMT_PAL8, 33 },
{ AV_PIX_FMT_NONE, 0 },
};
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);
}
|