FFmpeg: libavcodec/indeo2.c Source File
Go to the documentation of this file. 1 /*
2 * Intel Indeo 2 codec
3 * Copyright (c) 2005 Konstantin Shishkov
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
22 /**
23 * @file
24 * Intel Indeo 2 decoder.
25 */
26
29
30 #define BITSTREAM_READER_LE
36
43
44 #define CODE_VLC_BITS 14
46
47 /* Indeo 2 codes are in range 0x01..0x7F and 0x81..0x90 */
49 {
51 }
52
54 int pitch,
const uint8_t *
table)
55 {
57 int j;
59
62
63 /* first line contain absolute values, other lines contain deltas */
66 if (
c >= 0x80) {
/* we have a run */
70 for (
i = 0;
i <
c * 2;
i++)
72 } else { /* copy two values from table */
77 }
78 }
79 dst += pitch;
80
81 for (j = 1; j <
height; j++) {
88 if (
c >= 0x80) {
/* we have a skip */
92 for (
i = 0;
i <
c * 2;
i++) {
93 dst[
out] = dst[
out - pitch];
95 }
96 } else { /* add two deltas from table */
97 int t;
100 t = dst[
out - pitch] + (
table[
c * 2] - 128);
104 t = dst[
out - pitch] + (
table[(
c * 2) + 1] - 128);
108 }
109 }
110 dst += pitch;
111 }
112 return 0;
113 }
114
116 int pitch,
const uint8_t *
table)
117 {
118 int j;
121 int t;
122
125
126 for (j = 0; j <
height; j++) {
132 if (
c >= 0x80) {
/* we have a skip */
135 } else { /* add two deltas from table */
138 t = dst[
out] + (((
table[
c * 2] - 128)*3) >> 2);
142 t = dst[
out] + (((
table[(
c * 2) + 1] - 128)*3) >> 2);
146 }
147 }
148 dst += pitch;
149 }
150 return 0;
151 }
152
154 void *
data,
int *got_frame,
156 {
158 const uint8_t *buf = avpkt->
data;
159 int buf_size = avpkt->
size;
163 int ltab, ctab;
164
167
168 start = 48; /* hardcoded for now */
169
170 if (start >= buf_size) {
173 }
174
175 s->decode_delta = buf[18];
176
177 /* decide whether frame uses deltas or not */
178
181
182 ltab = buf[0x22] & 3;
183 ctab = buf[0x22] >> 2;
184
185 if (ctab > 3) {
188 }
189
190 if (
s->decode_delta) {
/* intraframe */
195
196 /* swapped U and V */
205 } else { /* interframe */
210 /* swapped U and V */
219 }
220
223
224 *got_frame = 1;
225
226 return buf_size;
227 }
228
230 {
234 }
235
237 {
240
242
244
248
250
251 return 0;
252 }
253
255 {
257
259
260 return 0;
261 }
262
274 };
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
const AVCodec ff_indeo2_decoder
static int get_bits_left(GetBitContext *gb)
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 int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int pitch, const uint8_t *table)
#define INIT_VLC_OUTPUT_LE
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.
static const uint8_t ir2_delta_table[4][256]
static const uint16_t table[]
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static av_cold int ir2_decode_end(AVCodecContext *avctx)
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
static const uint8_t ir2_tab[IR2_CODES][2]
static int ff_thread_once(char *control, void(*routine)(void))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
static int ir2_get_code(GetBitContext *gb)
#define INIT_VLC_STATIC_FROM_LENGTHS(vlc, bits, nb_codes, lens, len_wrap, symbols, symbols_wrap, symbols_size, offset, flags, static_size)
static av_cold void ir2_init_static(void)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int pitch, const uint8_t *table)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define i(width, name, range_min, range_max)
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Identical in function to ff_get_buffer(), except it reuses the existing buffer if available.
main external API structure.
static int ir2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static av_cold int ir2_decode_init(AVCodecContext *avctx)
This structure stores compressed data.
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
VLC_TYPE(* table)[2]
code, bits
Generated on Wed Aug 24 2022 21:37:38 for FFmpeg by
doxygen
1.8.17