22 #include "libavutil/intreadwrite.h"
23 #include "libavutil/imgutils.h"
45 return value + (value >> 10);
55 int buf_size = avpkt->
size;
60 int magic_num, endian;
62 int w, h,
stride, bits_per_color, descriptor, elements, target_packet_size, source_packet_size;
64 unsigned int rgbBuffer;
66 if (avpkt->
size <= 1634) {
76 if (magic_num ==
AV_RL32(
"SDPX")) {
78 }
else if (magic_num ==
AV_RB32(
"SDPX")) {
85 offset =
read32(&buf, endian);
86 if (avpkt->
size <= offset) {
91 buf = avpkt->
data + 0x304;
102 bits_per_color = buf[0];
108 switch (descriptor) {
120 switch (bits_per_color) {
127 source_packet_size = elements;
128 target_packet_size = elements;
132 target_packet_size = 6;
133 source_packet_size = 4;
142 target_packet_size = 6;
143 source_packet_size = elements * 2;
161 buf = avpkt->
data + offset;
166 if (source_packet_size*avctx->
width*avctx->
height > buf_end - buf) {
170 switch (bits_per_color) {
172 for (x = 0; x < avctx->
height; x++) {
173 uint16_t *dst = (uint16_t*)ptr;
174 for (y = 0; y < avctx->
width; y++) {
175 rgbBuffer =
read32(&buf, endian);
187 if (source_packet_size == target_packet_size) {
188 for (x = 0; x < avctx->
height; x++) {
189 memcpy(ptr, buf, target_packet_size*avctx->
width);
191 buf += source_packet_size*avctx->
width;
194 for (x = 0; x < avctx->
height; x++) {
196 for (y = 0; y < avctx->
width; y++) {
197 memcpy(dst, buf, target_packet_size);
198 dst += target_packet_size;
199 buf += source_packet_size;
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
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.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
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.
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
const char * name
Name of the codec implementation.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
static unsigned int read32(const uint8_t **ptr, int is_big)
#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. ...
static unsigned make_16bit(unsigned value)
Libavcodec external API header.
int width
picture width / height.
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as lit...
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
common internal api header.
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.