37 header->image_extension = 0;
40 header->data_min_found = 0;
41 header->data_max_found = 0;
63 for (
i = 0;
i < 8 && ptr8[
i] !=
' ';
i++) {
70 while (
i < 80 && ptr8[
i] ==
' ') {
77 if (ptr8[
i-1] ==
'\'') {
78 for (;
i < 80 && ptr8[
i] !=
'\'';
i++) {
82 }
else if (ptr8[
i-1] ==
'(') {
83 for (;
i < 80 && ptr8[
i] !=
')';
i++) {
88 for (;
i < 80 && ptr8[
i] !=
' ' && ptr8[
i] !=
'/';
i++) {
98 #define CHECK_KEYWORD(key) \
99 if (strcmp(keyword, key)) { \
100 av_log(avcl, AV_LOG_ERROR, "expected %s keyword, found %s = %s\n", key, keyword, value); \
101 return AVERROR_INVALIDDATA; \
104 #define CHECK_VALUE(key, val) \
105 if (sscanf(value, "%d", &header->val) != 1) { \
106 av_log(avcl, AV_LOG_ERROR, "invalid value of %s keyword, %s = %s\n", key, keyword, value); \
107 return AVERROR_INVALIDDATA; \
115 char keyword[10],
value[72],
c;
122 if (
value[0] ==
'F') {
124 }
else if (
value[0] !=
'T') {
134 if (!strcmp(
value,
"'IMAGE '")) {
135 header->image_extension = 1;
148 case 64:
case -64:
break;
170 ret = sscanf(keyword,
"NAXIS%d", &dim_no);
171 if (ret != 1 || dim_no !=
header->naxis_index + 1) {
188 if (!strcmp(keyword,
"BLANK") && sscanf(
value,
"%"SCNd64
"", &t) == 1) {
191 }
else if (!strcmp(keyword,
"BSCALE") && sscanf(
value,
"%lf", &d) == 1) {
195 }
else if (!strcmp(keyword,
"BZERO") && sscanf(
value,
"%lf", &d) == 1) {
197 }
else if (!strcmp(keyword,
"CTYPE3") && !strncmp(
value,
"'RGB", 4)) {
199 }
else if (!strcmp(keyword,
"DATAMAX") && sscanf(
value,
"%lf", &d) == 1) {
200 header->data_max_found = 1;
202 }
else if (!strcmp(keyword,
"DATAMIN") && sscanf(
value,
"%lf", &d) == 1) {
203 header->data_min_found = 1;
205 }
else if (!strcmp(keyword,
"END")) {
207 }
else if (!strcmp(keyword,
"GROUPS") && sscanf(
value,
"%c", &
c) == 1) {
209 }
else if (!strcmp(keyword,
"GCOUNT") && sscanf(
value,
"%"SCNd64
"", &t) == 1) {
210 if (t < 0 || t > INT_MAX)
213 }
else if (!strcmp(keyword,
"PCOUNT") && sscanf(
value,
"%"SCNd64
"", &t) == 1) {
214 if (t < 0 || t > INT_MAX)
Libavcodec external API header.
#define CHECK_VALUE(key, val)
int avpriv_fits_header_init(FITSHeader *header, FITSHeaderState state)
Initialize a single header line.
static int read_keyword_value(const uint8_t *ptr8, char *keyword, char *value)
Extract keyword and value from a header line (80 bytes) and store them in keyword and value strings r...
#define CHECK_KEYWORD(key)
int avpriv_fits_header_parse_line(void *avcl, FITSHeader *header, const uint8_t line[80], AVDictionary ***metadata)
Parse a single header line.
static int dict_set_if_not_null(AVDictionary ***metadata, char *keyword, char *value)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const uint8_t header[24]