FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
fitsdec.c File Reference

FITS image decoder. More...

#include "avcodec.h"
#include "internal.h"
#include <float.h>
#include "libavutil/intreadwrite.h"
#include "libavutil/intfloat.h"
#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "fits.h"

Go to the source code of this file.

Data Structures

struct  FITSContext
 

Macros

#define CASE_N(a, t, rd)
 
#define CASE_RGB(cas, dst, type, dref)
 
#define CASE_GRAY(cas, dst, type, t, rd)
 

Functions

static int fill_data_min_max (const uint8_t *ptr8, FITSHeader *header, const uint8_t *end)
 Calculate the data_min and data_max values from the data. More...
 
static int fits_read_header (AVCodecContext *avctx, const uint8_t **ptr, FITSHeader *header, const uint8_t *end, AVDictionary **metadata)
 Read the fits header and store the values in FITSHeader pointed by header. More...
 
static int fits_decode_frame (AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
 

Variables

static const AVOption fits_options []
 
static const AVClass fits_decoder_class
 
AVCodec ff_fits_decoder
 

Detailed Description

FITS image decoder.

Specification: https://fits.gsfc.nasa.gov/fits_standard.html Version 3.0

Support all 2d images alongwith, bzero, bscale and blank keywords. RGBA images are supported as NAXIS3 = 3 or 4 i.e. Planes in RGBA order. Also CTYPE = 'RGB ' should be present. Also to interpret data, values are linearly scaled using min-max scaling but not RGB images.

Definition in file fitsdec.c.

Macro Definition Documentation

#define CASE_N (   a,
  t,
  rd 
)
Value:
case a: \
for (i = 0; i < header->naxisn[1]; i++) { \
for (j = 0; j < header->naxisn[0]; j++) { \
t = rd; \
if (!header->blank_found || t != header->blank) { \
if (t > header->data_max) \
header->data_max = t; \
if (t < header->data_min) \
header->data_min = t; \
} \
ptr8 += abs(a) >> 3; \
} \
} \
break
static const uint8_t header[24]
Definition: sdr2.c:67
if(ret< 0)
Definition: vf_mcdeint.c:279
for(j=16;j >0;--j)

Referenced by fill_data_min_max().

#define CASE_RGB (   cas,
  dst,
  type,
  dref 
)
Value:
case cas: \
for (k = 0; k < header.naxisn[2]; k++) { \
for (i = 0; i < avctx->height; i++) { \
dst = (type *) (p->data[map[k]] + (avctx->height - i - 1) * p->linesize[map[k]]); \
for (j = 0; j < avctx->width; j++) { \
t32 = dref(ptr8); \
if (!header.blank_found || t32 != header.blank) { \
t = t32 * header.bscale + header.bzero; \
} else { \
t = fitsctx->blank_val; \
} \
*dst++ = (type) t; \
ptr8 += cas >> 3; \
} \
} \
} \
break
static const uint8_t header[24]
Definition: sdr2.c:67
GLint GLenum type
Definition: opengl_enc.c:105
const VDPAUPixFmtMap * map
if(ret< 0)
Definition: vf_mcdeint.c:279
for(j=16;j >0;--j)

Referenced by fits_decode_frame().

#define CASE_GRAY (   cas,
  dst,
  type,
  t,
  rd 
)
Value:
case cas: \
for (i = 0; i < avctx->height; i++) { \
dst = (type *) (p->data[0] + (avctx->height-i-1)* p->linesize[0]); \
for (j = 0; j < avctx->width; j++) { \
t = rd; \
if (!header.blank_found || t != header.blank) { \
*dst++ = ((t - header.data_min) * ((1 << (sizeof(type) * 8)) - 1)) / (header.data_max - header.data_min); \
} else { \
*dst++ = fitsctx->blank_val; \
} \
ptr8 += abs(cas) >> 3; \
} \
} \
break
static const uint8_t header[24]
Definition: sdr2.c:67
GLint GLenum type
Definition: opengl_enc.c:105
if(ret< 0)
Definition: vf_mcdeint.c:279
for(j=16;j >0;--j)

Referenced by fits_decode_frame().

Function Documentation

static int fill_data_min_max ( const uint8_t ptr8,
FITSHeader header,
const uint8_t end 
)
static

Calculate the data_min and data_max values from the data.

This is called if the values are not present in the header.

Parameters
ptr8pointer to the data
headerpointer to the header
endpointer to end of packet
Returns
0 if calculated successfully otherwise AVERROR_INVALIDDATA

Definition at line 55 of file fitsdec.c.

Referenced by fits_read_header().

static int fits_read_header ( AVCodecContext avctx,
const uint8_t **  ptr,
FITSHeader header,
const uint8_t end,
AVDictionary **  metadata 
)
static

Read the fits header and store the values in FITSHeader pointed by header.

Parameters
avctxAVCodec context
ptrpointer to pointer to the data
headerpointer to the FITSHeader
endpointer to end of packet
metadatapointer to pointer to AVDictionary to store metadata
Returns
0 if calculated successfully otherwise AVERROR_INVALIDDATA

Definition at line 105 of file fitsdec.c.

Referenced by fits_decode_frame().

static int fits_decode_frame ( AVCodecContext avctx,
void data,
int got_frame,
AVPacket avpkt 
)
static

Definition at line 175 of file fitsdec.c.

Variable Documentation

const AVOption fits_options[]
static
Initial value:
= {
{ "blank_value", "value that is used to replace BLANK pixels in data array", 0x42, AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 65535, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM},
{ NULL },
}
#define NULL
Definition: coverity.c:32
#define AV_OPT_FLAG_VIDEO_PARAM
Definition: opt.h:282
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Definition: opt.h:277

Definition at line 296 of file fitsdec.c.

const AVClass fits_decoder_class
static
Initial value:
= {
.class_name = "FITS decoder",
.item_name = av_default_item_name,
.option = fits_options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:86
av_default_item_name
static const AVOption fits_options[]
Definition: fitsdec.c:296

Definition at line 301 of file fitsdec.c.

AVCodec ff_fits_decoder
Initial value:
= {
.name = "fits",
.priv_data_size = sizeof(FITSContext),
.capabilities = AV_CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Flexible Image Transport System"),
.priv_class = &fits_decoder_class
}
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:42
static int fits_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: fitsdec.c:175
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static const AVClass fits_decoder_class
Definition: fitsdec.c:301
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:1002

Definition at line 308 of file fitsdec.c.