Go to the documentation of this file.
48 #define BITMAPINFOHEADER_SIZE 0x28
49 #define TDSF_HEADER_SIZE 0x56
50 #define TDSB_HEADER_SIZE 0x08
119 if (!
ctx->refframe || !
ctx->jpgframe || !
ctx->jpkt)
125 if (!
ctx->jpeg_avctx)
141 #define APPLY_ALPHA(src, new, alpha) \
142 src = (src * (256 - alpha) + new * alpha) >> 8
148 const uint8_t *cursor =
ctx->cursor;
149 int x =
ctx->cursor_x -
ctx->cursor_hot_x;
150 int y =
ctx->cursor_y -
ctx->cursor_hot_y;
151 int w =
ctx->cursor_w;
152 int h =
ctx->cursor_h;
158 if (x +
w >
ctx->width)
160 if (y +
h >
ctx->height)
170 cursor += -y *
ctx->cursor_stride;
177 for (j = 0; j <
h; j++) {
178 for (
i = 0;
i <
w;
i++) {
179 uint8_t
alpha = cursor[
i * 4];
185 cursor +=
ctx->cursor_stride;
193 int i, j, k,
ret, cursor_fmt;
196 ctx->cursor_hot_x = bytestream2_get_le16(&
ctx->gbc);
197 ctx->cursor_hot_y = bytestream2_get_le16(&
ctx->gbc);
198 ctx->cursor_w = bytestream2_get_le16(&
ctx->gbc);
199 ctx->cursor_h = bytestream2_get_le16(&
ctx->gbc);
202 cursor_fmt = bytestream2_get_le32(&
ctx->gbc);
206 "Invalid cursor position (%d.%d outside %dx%d).\n",
210 if (
ctx->cursor_w < 1 ||
ctx->cursor_w > 256 ||
211 ctx->cursor_h < 1 ||
ctx->cursor_h > 256) {
213 "Invalid cursor dimensions %dx%d.\n",
214 ctx->cursor_w,
ctx->cursor_h);
217 if (
ctx->cursor_hot_x >
ctx->cursor_w ||
218 ctx->cursor_hot_y >
ctx->cursor_h) {
220 ctx->cursor_hot_x,
ctx->cursor_hot_y);
233 switch (cursor_fmt) {
235 for (j = 0; j <
ctx->cursor_h; j++) {
236 for (
i = 0;
i <
ctx->cursor_w;
i += 32) {
237 uint32_t
bits = bytestream2_get_be32(&
ctx->gbc);
238 for (k = 0; k < 32; k++) {
239 dst[0] = !!(
bits & 0x80000000);
247 for (j = 0; j <
ctx->cursor_h; j++) {
248 for (
i = 0;
i <
ctx->cursor_w;
i += 32) {
249 uint32_t
bits = bytestream2_get_be32(&
ctx->gbc);
250 for (k = 0; k < 32; k++) {
251 int mask_bit = !!(
bits & 0x80000000);
252 switch (
dst[0] * 2 + mask_bit) {
282 if (cursor_fmt & 8) {
283 for (j = 0; j <
ctx->cursor_h; j++) {
284 for (
i = 0;
i <
ctx->cursor_w;
i++) {
285 int val = bytestream2_get_be32(&
ctx->gbc);
291 dst +=
ctx->cursor_stride -
ctx->cursor_w * 4;
294 for (j = 0; j <
ctx->cursor_h; j++) {
295 for (
i = 0;
i <
ctx->cursor_w;
i++) {
296 int val = bytestream2_get_be32(&
ctx->gbc);
302 dst +=
ctx->cursor_stride -
ctx->cursor_w * 4;
324 const uint8_t *srcy,
int srcy_stride,
325 const uint8_t *srcu,
const uint8_t *srcv,
330 for (col = 0; col <
width; col++)
332 srcu[col >> 1] - 128, srcv[col >> 1] - 128);
336 srcu += srcuv_stride * (
line & 1);
337 srcv += srcuv_stride * (
line & 1);
343 int x,
int y,
int w,
int h)
350 ctx->jpkt->data =
ctx->tilebuffer;
351 ctx->jpkt->size = tile_size;
361 w >
ctx->jpgframe->width ||
h >
ctx->jpgframe->height) {
363 "JPEG decoding error (%d).\n",
ret);
373 tdsc_blit(
ctx->refframe->data[0] + x * 3 +
ctx->refframe->linesize[0] * y,
374 ctx->refframe->linesize[0],
375 ctx->jpgframe->data[0],
ctx->jpgframe->linesize[0],
376 ctx->jpgframe->data[1],
ctx->jpgframe->data[2],
377 ctx->jpgframe->linesize[1],
w,
h);
391 for (
i = 0;
i < number_tiles;
i++) {
394 int x, y, x2, y2,
w,
h;
398 bytestream2_get_le32(&
ctx->gbc) !=
MKTAG(
'T',
'D',
'S',
'B') ||
404 tile_size = bytestream2_get_le32(&
ctx->gbc);
408 tile_mode = bytestream2_get_le32(&
ctx->gbc);
410 x = bytestream2_get_le32(&
ctx->gbc);
411 y = bytestream2_get_le32(&
ctx->gbc);
412 x2 = bytestream2_get_le32(&
ctx->gbc);
413 y2 = bytestream2_get_le32(&
ctx->gbc);
415 if (x < 0 || y < 0 || x2 <= x || y2 <= y ||
416 x2 >
ctx->width || y2 >
ctx->height
419 "Invalid tile position (%d.%d %d.%d outside %dx%d).\n",
420 x, y, x2, y2,
ctx->width,
ctx->height);
427 if (!
ctx->tilebuffer)
432 if (tile_mode ==
MKTAG(
'G',
'E',
'P',
'J')) {
437 }
else if (tile_mode ==
MKTAG(
' ',
'W',
'A',
'R')) {
438 if (3LL *
w *
h > tile_size)
443 ctx->refframe->linesize[0] * y,
444 ctx->refframe->linesize[0],
ctx->tilebuffer,
459 int ret,
w,
h, init_refframe = !
ctx->refframe->data[0];
467 w = bytestream2_get_le32(&
ctx->gbc);
468 h = -bytestream2_get_le32(&
ctx->gbc);
470 if (bytestream2_get_le16(&
ctx->gbc) != 1 ||
471 bytestream2_get_le16(&
ctx->gbc) != 24)
485 ctx->refframe->width =
ctx->width =
w;
486 ctx->refframe->height =
ctx->height =
h;
503 int action = bytestream2_get_le32(&
ctx->gbc);
507 if (action == 2 || action == 3) {
509 ctx->cursor_x = bytestream2_get_le32(&
ctx->gbc);
510 ctx->cursor_y = bytestream2_get_le32(&
ctx->gbc);
530 int ret, tag_header, keyframe = 0;
535 int deflatelen = avctx->
width * avctx->
height * (3 + 1);
536 if (deflatelen !=
ctx->deflatelen) {
537 ctx->deflatelen =deflatelen;
545 dlen =
ctx->deflatelen;
548 ret = uncompress(
ctx->deflatebuffer, &dlen, avpkt->
data, avpkt->
size);
563 tag_header = bytestream2_get_le32(&
ctx->gbc);
565 if (tag_header ==
MKTAG(
'T',
'D',
'S',
'F')) {
572 number_tiles = bytestream2_get_le32(&
ctx->gbc);
575 keyframe = bytestream2_get_le32(&
ctx->gbc) == 0x30;
583 tag_header = bytestream2_get_le32(&
ctx->gbc);
587 if (tag_header ==
MKTAG(
'D',
'T',
'S',
'M')) {
589 int tag_size = bytestream2_get_le32(&
ctx->gbc);
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
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
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
#define APPLY_ALPHA(src, new, alpha)
static void tdsc_yuv2rgb(uint8_t *out, int Y, int U, int V)
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
const FFCodec ff_mjpeg_decoder
static int tdsc_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *avpkt)
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int ff_set_dimensions(AVCodecContext *s, int width, int height)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
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.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
AVCodec p
The public AVCodec.
int flags
AV_CODEC_FLAG_*.
static double val(void *priv, double ch)
static int tdsc_parse_tdsf(AVCodecContext *avctx, int number_tiles)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
static av_cold int tdsc_init(AVCodecContext *avctx)
static void tdsc_paint_cursor(AVCodecContext *avctx, uint8_t *dst, int stride)
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define FF_CODEC_DECODE_CB(func)
int flags
Flags modifying the (de)muxer behaviour.
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Alias for avcodec_receive_frame_flags(avctx, frame, 0).
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static AVFormatContext * ctx
int64_t max_pixels
The number of pixels per image to maximally accept.
#define CODEC_LONG_NAME(str)
static int tdsc_parse_dtsm(AVCodecContext *avctx)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
@ AV_PICTURE_TYPE_I
Intra.
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
AVCodecContext * jpeg_avctx
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
int flags2
AV_CODEC_FLAG2_*.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
#define i(width, name, range_min, range_max)
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
static int tdsc_decode_tiles(AVCodecContext *avctx, int number_tiles)
const FFCodec ff_tdsc_decoder
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
static int tdsc_load_cursor(AVCodecContext *avctx)
main external API structure.
static int tdsc_decode_jpeg_tile(AVCodecContext *avctx, int tile_size, int x, int y, int w, int h)
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
@ AV_PICTURE_TYPE_P
Predicted.
#define avpriv_request_sample(...)
static const int16_t alpha[]
This structure stores compressed data.
static av_always_inline void tdsc_blit(uint8_t *dst, int dst_stride, const uint8_t *srcy, int srcy_stride, const uint8_t *srcu, const uint8_t *srcv, int srcuv_stride, int width, int height)
int width
picture width / height.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_cold int tdsc_close(AVCodecContext *avctx)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
#define BITMAPINFOHEADER_SIZE
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line