61 for (i = 0; i < 8 && ptr8[i] !=
' '; i++) {
68 while (i < 80 && ptr8[i] ==
' ') {
75 if (ptr8[i-1] ==
'\'') {
76 for (; i < 80 && ptr8[i] !=
'\''; i++) {
80 }
else if (ptr8[i-1] ==
'(') {
81 for (; i < 80 && ptr8[i] !=
')'; i++) {
86 for (; i < 80 && ptr8[i] !=
' ' && ptr8[i] !=
'/'; i++) {
96 #define CHECK_KEYWORD(key) \ 97 if (strcmp(keyword, key)) { \ 98 av_log(avcl, AV_LOG_ERROR, "expected %s keyword, found %s = %s\n", key, keyword, value); \ 99 return AVERROR_INVALIDDATA; \ 102 #define CHECK_VALUE(key, val) \ 103 if (sscanf(value, "%d", &header->val) != 1) { \ 104 av_log(avcl, AV_LOG_ERROR, "invalid value of %s keyword, %s = %s\n", key, keyword, value); \ 105 return AVERROR_INVALIDDATA; \ 113 char keyword[10],
value[72],
c;
116 switch (header->
state) {
120 if (value[0] ==
'F') {
122 }
else if (value[0] !=
'T') {
123 av_log(avcl,
AV_LOG_ERROR,
"invalid value of SIMPLE keyword, SIMPLE = %c\n", value[0]);
132 if (!strcmp(value,
"'IMAGE '")) {
157 ret = sscanf(keyword,
"NAXIS%d", &dim_no);
158 if (ret != 1 || dim_no != header->
naxis_index + 1) {
175 if (!strcmp(keyword,
"BLANK") && sscanf(value,
"%"SCNd64
"", &t) == 1) {
178 }
else if (!strcmp(keyword,
"BSCALE") && sscanf(value,
"%lf", &d) == 1) {
180 }
else if (!strcmp(keyword,
"BZERO") && sscanf(value,
"%lf", &d) == 1) {
182 }
else if (!strcmp(keyword,
"CTYPE3") && !strncmp(value,
"'RGB", 4)) {
184 }
else if (!strcmp(keyword,
"DATAMAX") && sscanf(value,
"%lf", &d) == 1) {
187 }
else if (!strcmp(keyword,
"DATAMIN") && sscanf(value,
"%lf", &d) == 1) {
190 }
else if (!strcmp(keyword,
"END")) {
192 }
else if (!strcmp(keyword,
"GROUPS") && sscanf(value,
"%c", &c) == 1) {
193 header->
groups = (c ==
'T');
194 }
else if (!strcmp(keyword,
"GCOUNT") && sscanf(value,
"%"SCNd64
"", &t) == 1) {
196 }
else if (!strcmp(keyword,
"PCOUNT") && sscanf(value,
"%"SCNd64
"", &t) == 1) {
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int dict_set_if_not_null(AVDictionary ***metadata, char *keyword, char *value)
#define CHECK_KEYWORD(key)
static const uint8_t header[24]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int avpriv_fits_header_init(FITSHeader *header, FITSHeaderState state)
Initialize a single header line.
Libavcodec external API header.
int avpriv_fits_header_parse_line(void *avcl, FITSHeader *header, const uint8_t line[80], AVDictionary ***metadata)
Parse a single header line.
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 CHECK_VALUE(key, val)
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...