blob: 5c6ab1cce520b8c8c04139f9eee5a4fd34048378 (
plain)
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
|
/*
* Copyright (c) 2015 Kostya Shishkov
* This file is part of Libav.
*
* Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* Libav 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
* General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING.GPLv3. If not see
* <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include "pixformaton.h"
#include "mem.h"
#include "pixdesc.h"
#include "pixfmt.h"
AVPixelFormaton *av_formaton_from_pixfmt(enum AVPixelFormat pix_fmt)
{
AVPixelFormaton *formaton = av_mallocz(sizeof(AVPixelFormaton));
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int i;
if (!formaton)
return NULL;
if (!desc)
goto fail;
formaton->flags = desc->flags;
// XXX luzero disapproves
if (strchr(desc->name, 'j'))
formaton->range = AVCOL_RANGE_JPEG;
else
formaton->range = AVCOL_RANGE_UNSPECIFIED;
formaton->primaries = AVCOL_PRI_UNSPECIFIED;
formaton->transfer = AVCOL_TRC_UNSPECIFIED;
formaton->space = AVCOL_SPC_UNSPECIFIED;
formaton->location = AVCHROMA_LOC_UNSPECIFIED;
formaton->nb_components = desc->nb_components;
for (i = 0; i < formaton->nb_components; i++) {
AVPixelChromaton *chromaton = &formaton->component_desc[i];
const AVComponentDescriptor *comp = &desc->comp[i];
chromaton->plane = comp->plane;
chromaton->next = comp->step;
chromaton->h_sub_log = desc->log2_chroma_w;
chromaton->v_sub_log = desc->log2_chroma_h;
chromaton->offset = comp->offset;
chromaton->shift = comp->shift;
chromaton->depth = comp->depth;
chromaton->packed = 0; // XXX luzero does not remember
}
return formaton;
fail:
av_formaton_free(&formaton);
return NULL;
}
void av_formaton_free(AVPixelFormaton **formaton)
{
if (!formaton || !*formaton)
return;
av_freep(formaton);
}
|