1 /*
2 * CamStudio decoder
3 * Copyright (c) 2006 Reimar Doeffinger
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 #include <stdio.h>
22 #include <stdlib.h>
23
27
28 #if CONFIG_ZLIB
29 #include <zlib.h>
30 #endif
32
39
42 int i, src_stride =
FFALIGN(linelen, 4);
44 dst += (height - 1) * f->
linesize[0];
45 for (i = height; i; i--) {
46 memcpy(dst, src, linelen);
47 src += src_stride;
49 }
50 }
51
54 int i, j, src_stride =
FFALIGN(linelen, 4);
56 dst += (height - 1) * f->
linesize[0];
57 for (i = height; i; i--) {
58 for (j = linelen; j; j--)
59 *dst++ += *src++;
60 src += src_stride - linelen;
62 }
63 }
64
68 int buf_size = avpkt->
size;
70 int ret;
71
72 if (buf_size < 2) {
75 }
76
78 return ret;
79
80 // decompress data
81 switch ((buf[0] >> 1) & 7) {
82 case 0: { // lzo compression
87 }
88 break;
89 }
90 case 1: { // zlib compression
91 #if CONFIG_ZLIB
93 if (uncompress(c->
decomp_buf, &dlen, &buf[2], buf_size - 2) != Z_OK) {
96 }
97 break;
98 #else
101 #endif
102 }
103 default:
106 }
107
108 // flip upside down, add difference frame
109 if (buf[0] & 1) { // keyframe
114 } else {
119 }
120
121 *got_frame = 1;
123 return ret;
124
125 return buf_size;
126 }
127
135 default:
137 "CamStudio codec error: invalid depth %i bpp\n",
140 }
150 }
154 return 0;
155 }
156
161 return 0;
162 }
163
174 };
static void add_frame_default(AVFrame *f, const uint8_t *src, int linelen, int height)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
static av_cold int init(AVCodecContext *avctx)
packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined ...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
Identical in function to av_frame_make_writable(), except it uses ff_get_buffer() to allocate the buf...
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static av_cold int decode_end(AVCodecContext *avctx)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define AV_LZO_OUTPUT_PADDING
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
unsigned char * decomp_buf
const char * name
Name of the codec implementation.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
int av_lzo1x_decode(void *out, int *outlen, const void *in, int *inlen)
Decodes LZO 1x compressed data.
packed RGB 8:8:8, 24bpp, BGRBGR...
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
common internal and external API header
static av_cold int decode_init(AVCodecContext *avctx)
int key_frame
1 -> keyframe, 0-> not
static void copy_frame_default(AVFrame *f, const uint8_t *src, int linelen, int height)
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.