45 #define BITMAPINFOHEADER_SIZE 0x28
46 #define TDSF_HEADER_SIZE 0x56
47 #define TDSB_HEADER_SIZE 0x08
138 #define APPLY_ALPHA(src, new, alpha) \
139 src = (src * (256 - alpha) + new * alpha) >> 8
155 if (x + w > ctx->
width)
174 for (j = 0; j <
h; j++) {
175 for (i = 0; i < w; i++) {
177 APPLY_ALPHA(dst[i * 3 + 0], cursor[i * 4 + 1], alpha);
178 APPLY_ALPHA(dst[i * 3 + 1], cursor[i * 4 + 2], alpha);
179 APPLY_ALPHA(dst[i * 3 + 2], cursor[i * 4 + 3], alpha);
190 int i, j, k,
ret,
bits, cursor_fmt;
199 cursor_fmt = bytestream2_get_le32(&ctx->
gbc);
203 "Invalid cursor position (%d.%d outside %dx%d).\n",
210 "Invalid cursor dimensions %dx%d.\n",
230 switch (cursor_fmt) {
232 for (j = 0; j < ctx->
cursor_h; j++) {
233 for (i = 0; i < ctx->
cursor_w; i += 32) {
234 bits = bytestream2_get_be32(&ctx->
gbc);
235 for (k = 0; k < 32; k++) {
236 dst[0] = !!(bits & 0x80000000);
245 for (j = 0; j < ctx->
cursor_h; j++) {
246 for (i = 0; i < ctx->
cursor_w; i += 32) {
247 bits = bytestream2_get_be32(&ctx->
gbc);
248 for (k = 0; k < 32; k++) {
249 int mask_bit = !!(bits & 0x80000000);
250 switch (dst[0] * 2 + mask_bit) {
281 if (cursor_fmt & 8) {
282 for (j = 0; j < ctx->
cursor_h; j++) {
283 for (i = 0; i < ctx->
cursor_w; i++) {
284 int val = bytestream2_get_be32(&ctx->
gbc);
293 for (j = 0; j < ctx->
cursor_h; j++) {
294 for (i = 0; i < ctx->
cursor_w; i++) {
295 int val = bytestream2_get_be32(&ctx->
gbc);
316 out[0] = av_clip_uint8(Y + ( 91881 * V + 32768 >> 16));
317 out[1] = av_clip_uint8(Y + (-22554 * U - 46802 * V + 32768 >> 16));
318 out[2] = av_clip_uint8(Y + (116130 * U + 32768 >> 16));
323 const uint8_t *srcy,
int srcy_stride,
328 for (line = 0; line <
height; line++) {
329 for (col = 0; col <
width; col++)
331 srcu[col >> 1] - 128, srcv[col >> 1] - 128);
335 srcu += srcuv_stride * (line & 1);
336 srcv += srcuv_stride * (line & 1);
342 int x,
int y,
int w,
int h)
352 jpkt.
size = tile_size;
358 "JPEG decoding error (%d) for (%d) frame.\n",
387 for (i = 0; i < number_tiles; i++) {
394 bytestream2_get_le32(&ctx->
gbc) !=
MKTAG(
'T',
'D',
'S',
'B') ||
400 tile_size = bytestream2_get_le32(&ctx->
gbc);
404 tile_mode = bytestream2_get_le32(&ctx->
gbc);
406 x = bytestream2_get_le32(&ctx->
gbc);
407 y = bytestream2_get_le32(&ctx->
gbc);
408 w = bytestream2_get_le32(&ctx->
gbc) - x;
409 h = bytestream2_get_le32(&ctx->
gbc) -
y;
413 "Invalid tile position (%d.%d outside %dx%d).\n",
419 "Invalid tile size %dx%d\n", w, h);
429 if (tile_mode ==
MKTAG(
'G',
'E',
'P',
'J')) {
434 }
else if (tile_mode ==
MKTAG(
' ',
'W',
'A',
'R')) {
461 w = bytestream2_get_le32(&ctx->
gbc);
462 h = -bytestream2_get_le32(&ctx->
gbc);
464 if (bytestream2_get_le16(&ctx->
gbc) != 1 ||
465 bytestream2_get_le16(&ctx->
gbc) != 24)
497 int action = bytestream2_get_le32(&ctx->
gbc);
501 if (action == 2 || action == 3) {
525 int ret, tag_header, keyframe = 0;
553 tag_header = bytestream2_get_le32(&ctx->
gbc);
555 if (tag_header ==
MKTAG(
'T',
'D',
'S',
'F')) {
562 number_tiles = bytestream2_get_le32(&ctx->
gbc);
565 keyframe = bytestream2_get_le32(&ctx->
gbc) == 0x30;
573 tag_header = bytestream2_get_le32(&ctx->
gbc);
577 if (tag_header ==
MKTAG(
'D',
'T',
'S',
'M')) {
579 int tag_size = bytestream2_get_le32(&ctx->
gbc);
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
const char const char void * val
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int tdsc_decode_tiles(AVCodecContext *avctx, int number_tiles)
This structure describes decoded (raw) audio or video data.
int dct_algo
DCT algorithm, see FF_DCT_* below.
ptrdiff_t const GLvoid * data
#define AV_LOG_WARNING
Something somehow does not look correct.
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.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
static av_cold int tdsc_init(AVCodecContext *avctx)
AVCodecContext * jpeg_avctx
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define BITMAPINFOHEADER_SIZE
static int tdsc_parse_dtsm(AVCodecContext *avctx)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
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 av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
static av_cold int tdsc_close(AVCodecContext *avctx)
static double alpha(void *priv, double x, double y)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt)
Decode the video frame of size avpkt->size from avpkt->data into picture.
int ff_codec_open2_recursive(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Call avcodec_open2 recursively by decrementing counter, unlocking mutex, calling the function and the...
#define AV_EF_EXPLODE
abort decoding on minor error detection
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static int tdsc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, uint8_t *dst, unsigned int size)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static av_always_inline unsigned int bytestream2_get_bytes_left(GetByteContext *g)
const char * name
Name of the codec implementation.
Libavcodec external API header.
static int tdsc_parse_tdsf(AVCodecContext *avctx, int number_tiles)
int av_frame_copy(AVFrame *dst, const AVFrame *src)
Copy the frame data from src to dst.
enum AVPictureType pict_type
Picture type of the frame.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
int width
picture width / height.
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
static int tdsc_decode_jpeg_tile(AVCodecContext *avctx, int tile_size, int x, int y, int w, int h)
packed RGB 8:8:8, 24bpp, BGRBGR...
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static void tdsc_paint_cursor(AVCodecContext *avctx, uint8_t *dst, int stride)
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer...
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
BYTE int const BYTE int int int height
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
GLint GLenum GLboolean GLsizei stride
common internal api header.
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int key_frame
1 -> keyframe, 0-> not
#define APPLY_ALPHA(src, new, alpha)
static void tdsc_yuv2rgb(uint8_t *out, int Y, int U, int V)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
static int tdsc_load_cursor(AVCodecContext *avctx)
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.
#define MKTAG(a, b, c, d)
This structure stores compressed data.