88 int *n_datum,
int is_big,
int shift)
95 *lbuf =
read32(ptr, is_big);
99 temp = *lbuf >> shift & 0x3FF;
106 int *n_datum,
int is_big,
int shift)
111 *lbuf =
read32(ptr, is_big);
115 *lbuf = *lbuf << 10 | *lbuf >> shift & 0x3FFFFF;
117 return *lbuf & 0x3FF;
121 int *n_datum,
int is_big)
126 *lbuf =
read32(ptr, is_big);
131 case 7:
return *lbuf & 0xFFF;
132 case 6:
return (*lbuf >> 12) & 0xFFF;
134 uint32_t
c = *lbuf >> 24;
135 *lbuf =
read32(ptr, is_big);
139 case 4:
return (*lbuf >> 4) & 0xFFF;
140 case 3:
return (*lbuf >> 16) & 0xFFF;
142 uint32_t
c = *lbuf >> 28;
143 *lbuf =
read32(ptr, is_big);
147 case 1:
return (*lbuf >> 8) & 0xFFF;
148 default:
return *lbuf >> 20;
158 int buf_size = avpkt->
size;
161 uint32_t header_version,
version = 0;
163 char input_device[33];
166 int magic_num, endian;
168 int w,
h, bits_per_color, descriptor,
elements, packing;
169 int yuv, color_trc, color_spec;
170 int encoding, need_align = 0, unpadded_10bit = 0;
172 unsigned int rgbBuffer = 0;
175 if (avpkt->
size <= 1634) {
185 if (magic_num ==
AV_RL32(
"SDPX")) {
187 }
else if (magic_num ==
AV_RB32(
"SDPX")) {
194 offset =
read32(&buf, endian);
195 if (avpkt->
size <= offset) {
200 header_version =
read32(&buf, 0);
201 if (header_version ==
MKTAG(
'V',
'1',
'.',
'0'))
203 if (header_version ==
MKTAG(
'V',
'2',
'.',
'0'))
210 buf = avpkt->
data + 660;
211 ret =
read32(&buf, endian);
212 if (ret != 0xFFFFFFFF) {
215 "not properly decode.\n");
219 buf = avpkt->
data + 0x304;
235 bits_per_color = buf[0];
237 packing =
read16(&buf, endian);
238 encoding =
read16(&buf, endian);
256 if (offset >= 1724 + 4) {
257 buf = avpkt->
data + 1724;
259 if(i && i != 0xFFFFFFFF) {
261 if (q.
num > 0 && q.
den > 0)
267 if (offset >= 1940 + 4 &&
269 buf = avpkt->
data + 1940;
271 if(i && i != 0xFFFFFFFF) {
273 if (q.
num > 0 && q.
den > 0)
279 if (offset >= 1920 + 4) {
284 buf = avpkt->
data + 1920;
289 if (i != 0xFFFFFFFF) {
292 sizeof(uint32_t) * 4);
296 tc_sd = (uint32_t*)tcside->
data;
307 if (offset >= 1964 + 4) {
308 buf = avpkt->
data + 1952;
311 buf = avpkt->
data + 1964;
314 if (i != 0xFFFFFFFF && j != 0xFFFFFFFF) {
318 if (bits_per_color >= 1 &&
319 minCV == 0.0
f && maxCV == ((1<<bits_per_color) - 1)) {
321 }
else if (bits_per_color >= 8 &&
322 minCV == (1 <<(bits_per_color - 4)) &&
323 maxCV == (235<<(bits_per_color - 8))) {
329 switch (descriptor) {
360 switch (bits_per_color) {
369 stride = (avctx->
width * elements + 2) / 3 * 4;
419 "%d to color_trc.\n", color_trc);
423 switch (color_spec) {
442 "%d to color_primaries.\n", color_spec);
447 switch (color_spec) {
466 "%d to colorspace.\n", color_spec);
477 need_align =
FFALIGN(stride, 4);
478 if (need_align*avctx->
height + (int64_t)offset > avpkt->
size) {
480 if (stride*avctx->
height + (int64_t)offset > avpkt->
size) {
493 switch (1000 * descriptor + 10 * bits_per_color + endian) {
576 input_device[32] =
'\0';
580 if (!memcmp(input_device,
"Scanity", 7) ||
581 !memcmp(creator,
"Lasergraphics Inc.", 18)) {
591 switch (bits_per_color) {
593 for (x = 0; x < avctx->
height; x++) {
594 uint16_t *dst[4] = {(uint16_t*)ptr[0],
598 int shift = elements > 1 ? packing == 1 ? 22 : 20 : packing == 1 ? 2 : 0;
599 for (y = 0; y < avctx->
width; y++) {
602 &n_datum, endian, shift);
605 &n_datum, endian, shift);
608 &n_datum, endian, shift);
611 &n_datum, endian, shift);
615 &n_datum, endian, shift);
624 for (x = 0; x < avctx->
height; x++) {
625 uint16_t *dst[4] = {(uint16_t*)ptr[0],
629 int shift = packing == 1 ? 4 : 0;
630 for (y = 0; y < avctx->
width; y++) {
633 *dst[2]++ =
read16(&buf, endian) >> shift & 0xFFF;
634 *dst[0]++ =
read16(&buf, endian) >> shift & 0xFFF;
636 *dst[1]++ =
read16(&buf, endian) >> shift & 0xFFF;
638 *dst[3]++ =
read16(&buf, endian) >> shift & 0xFFF;
665 for (x = 0; x < avctx->
height; x++) {
670 for (y = 0; y < avctx->
width; y++) {
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_NUM_DATA_POINTERS
static int shift(int a, int b)
static uint16_t read10in32_gray(const uint8_t **ptr, uint32_t *lbuf, int *n_datum, int is_big, int shift)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
"Linear transfer characteristics"
#define AV_PIX_FMT_GBRAP10
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
packed RGB 8:8:8, 24bpp, RGBRGB...
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Timecode which conforms to SMPTE ST 12-1.
#define AV_PIX_FMT_GBRP10
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
#define AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY12
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static unsigned int read16(const uint8_t **ptr, int is_big)
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Structure to hold side data for an AVFrame.
static uint16_t read10in32(const uint8_t **ptr, uint32_t *lbuf, int *n_datum, int is_big, int shift)
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
#define AV_LOG_VERBOSE
Detailed information.
AVDictionary * metadata
metadata.
static unsigned int read32(const uint8_t **ptr, int is_big)
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define av_fourcc2str(fourcc)
#define AV_PIX_FMT_GBRAP12
also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
const char * name
Name of the codec implementation.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
static uint16_t read12in32(const uint8_t **ptr, uint32_t *lbuf, int *n_datum, int is_big)
int width
picture width / height.
static const ElemCat * elements[ELEMENT_COUNT]
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
char * av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field)
Get the timecode string from the SMPTE timecode format.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_LOG_INFO
Standard information.
also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
enum AVColorSpace colorspace
YUV colorspace type.
Rational number (pair of numerator and denominator).
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
#define AV_PIX_FMT_GBRP12
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
Narrow or limited range content.
common internal api header.
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
Y , 16bpp, little-endian.
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
#define MKTAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is st...
#define AV_TIMECODE_STR_SIZE