28#define BITSTREAM_READER_LE
69 s->jpeg_avctx->flags = avctx->
flags;
70 s->jpeg_avctx->flags2 = avctx->
flags2;
90 a0 = bytestream2_get_le32(gb);
91 a1 = bytestream2_get_le32(gb);
92 a2 = bytestream2_get_le32(gb);
93 a3 = bytestream2_get_le32(gb);
176 int ret,
bps, hflip = 0, vflip = 0;
186 char codec_name[1024];
187 uint32_t
key, length;
191 key = bytestream2_get_le32(gb);
192 length = bytestream2_get_le32(gb);
199 if (bytestream2_get_le32(gb) !=
MKTAG(
'D',
'V',
'C',
'C'))
205 width = bytestream2_get_le32(gb);
206 height = bytestream2_get_le32(gb);
207 s->color_model = bytestream2_get_le32(gb);
208 if (bytestream2_get_le32(gb) != 1)
219 if (bytestream2_get_le32(gb) != 0)
223 int read_len =
FFMIN(length,
sizeof(codec_name) - 1);
227 if (strncmp(codec_name,
"cintel_craw", read_len))
235 s->data_size = length;
240 hflip = bytestream2_get_byte(gb) != 0;
246 vflip = bytestream2_get_byte(gb) != 0;
260 for (
int i = 0;
i < 4;
i++)
261 s->tile_size[
i] = bytestream2_get_le64(gb);
270 switch (
s->color_model) {
290 switch (
s->color_model) {
311 for (
int i = 0;
i < 4;
i++) {
312 if (
s->tile_size[
i] >=
s->data_size)
316 if (
s->tile_size[0] +
s->tile_size[1] +
s->tile_size[2] +
s->tile_size[3] !=
321 if (!
s->data || !
s->data_size)
332 if (!compressed &&
s->color_model == 45) {
333 uint16_t *
dst = (uint16_t *)p->data[0];
338 }
else if (!compressed) {
346 for (
int y = 0; y < avctx->
height; y++) {
347 uint16_t *
dst = (uint16_t *)(p->data[0] + y * p->linesize[0]);
352 for (
int x = 0; x < avctx->
width; x++)
360 s->jpkt->data = (uint8_t *)
s->data +
offset;
361 s->jpkt->size =
s->tile_size[
tile];
371 s->jpeg_avctx->width * 2 != avctx->
width ||
372 s->jpeg_avctx->height * 2 != avctx->
height) {
375 "JPEG decoding error (%d).\n", ret);
378 "JPEG invalid format.\n");
389 for (
int y = 0; y <
s->jpeg_avctx->height; y++) {
390 const int hw =
s->jpgframe->width / 2;
391 uint16_t *
dst = (uint16_t *)(p->data[0] + (y * 2) * p->linesize[0] +
tile * hw * 2);
392 const uint16_t *
src = (
const uint16_t *)(
s->jpgframe->data[0] + y *
s->jpgframe->linesize[0]);
396 dst += p->linesize[0] / 2;
405 if (hflip || vflip) {
407 sizeof(
int32_t) * 9, &rotation);
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFCodec ff_mjpeg_decoder
const FFCodec ff_cri_decoder
Libavcodec external API header.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
static int FUNC tile(CodedBitstreamContext *ctx, RWContext *rw, APVRawTile *current, int tile_idx, uint32_t tile_size)
#define i(width, name, range_min, range_max)
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static void unpack_10bit(GetByteContext *gb, uint16_t *dst, int shift, int w, int h, ptrdiff_t stride)
static av_cold int cri_decode_init(AVCodecContext *avctx)
static int cri_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
static av_cold int cri_decode_close(AVCodecContext *avctx)
int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, size_t size, AVFrameSideData **psd)
Wrapper around av_frame_new_side_data, which rejects side data overridden by the demuxer.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
#define AV_EF_EXPLODE
abort decoding on minor error detection
int(* init)(AVBSFContext *ctx)
bitstream reader API header.
static int get_bits_left(GetBitContext *gb)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Alias for avcodec_receive_frame_flags(avctx, frame, 0).
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
@ AVDISCARD_ALL
discard all
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
@ AV_FRAME_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure clockwise rotation by the specified angle (in de...
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
static int shift(int a, int b)
Multithreading API for decoders.
#define MKTAG(a, b, c, d)
#define AV_PIX_FMT_BAYER_GRBG16
#define AV_PIX_FMT_BAYER_BGGR16
#define AV_PIX_FMT_BAYER_RGGB16
#define AV_PIX_FMT_BAYER_GBRG16
#define AV_PIX_FMT_GRAY16
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int flags2
AV_CODEC_FLAG2_*.
int64_t max_pixels
The number of pixels per image to maximally accept.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
int flags
AV_CODEC_FLAG_*.
enum AVDiscard skip_frame
Skip decoding for selected frames.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
AVCodecContext * jpeg_avctx
static double a0(void *priv, double x, double y)
static double a3(void *priv, double x, double y)
static double a2(void *priv, double x, double y)
static double a1(void *priv, double x, double y)