1 /*
2 * Copyright (c) 2003 Michael Niedermayer
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * ASUS V1/V2 decoder.
24 */
25
28
36
38 #define ASV2_LEVEL_VLC_BITS 10
39
45
47 {
48 static int done = 0;
49
50 if (!done) {
51 done = 1;
52
68 }
69 }
70
71 // FIXME write a reversed bitstream reader to avoid the double reverse
73 {
75 }
76
78 {
80
81 if (code == 3)
83 else
84 return code - 3;
85 }
86
88 {
90
91 if (code == 31)
93 else
94 return code - 31;
95 }
96
98 {
99 int i;
100
102
103 for (i = 0; i < 11; i++) {
105
106 if (ccp) {
107 if (ccp == 16)
108 break;
109 if (ccp < 0 || i >= 10) {
112 }
113
114 if (ccp & 8)
116 if (ccp & 4)
118 if (ccp & 2)
120 if (ccp & 1)
122 }
123 }
124
125 return 0;
126 }
127
129 {
131
133
135
137 if (ccp) {
138 if (ccp & 4)
140 if (ccp & 2)
142 if (ccp & 1)
144 }
145
146 for (i = 1; i < count + 1; i++) {
148
149 if (ccp) {
150 if (ccp & 8)
152 if (ccp & 4)
154 if (ccp & 2)
156 if (ccp & 1)
158 }
159 }
160
161 return 0;
162 }
163
165 {
166 int i, ret;
167
169
171 for (i = 0; i < 6; i++) {
173 return ret;
174 }
175 } else {
176 for (i = 0; i < 6; i++) {
178 return ret;
179 }
180 }
181 return 0;
182 }
183
185 {
188
189 uint8_t *dest_y = frame->
data[0] + (mb_y * 16 * linesize) + mb_x * 16;
192
197
201 }
202 }
203
206 {
209 int buf_size = avpkt->
size;
211 int mb_x, mb_y, ret;
212
213 if (buf_size * 8LL < a->mb_height * a->
mb_width * 13LL)
215
217 return ret;
220
222 buf_size);
225
228 (const uint32_t *) buf, buf_size / 4);
229 } else {
230 int i;
231 for (i = 0; i < buf_size; i++)
233 }
234
236
237 for (mb_y = 0; mb_y < a->
mb_height2; mb_y++) {
238 for (mb_x = 0; mb_x < a->
mb_width2; mb_x++) {
240 return ret;
241
243 }
244 }
245
248 for (mb_y = 0; mb_y < a->
mb_height2; mb_y++) {
250 return ret;
251
253 }
254 }
255
258 for (mb_x = 0; mb_x < a->
mb_width; mb_x++) {
260 return ret;
261
263 }
264 }
265
266 *got_frame = 1;
267
268 emms_c();
269
271 }
272
274 {
277 int i;
278
281 }
282
289
294 else
296 }
297
298 for (i = 0; i < 64; i++) {
300
303 }
304
305 return 0;
306 }
307
309 {
311
314
315 return 0;
316 }
317
318 #if CONFIG_ASV1_DECODER
329 };
330 #endif
331
332 #if CONFIG_ASV2_DECODER
343 };
344 #endif
void(* bswap_buf)(uint32_t *dst, const uint32_t *src, int w)
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
const uint8_t ff_asv_ac_ccp_tab[16][2]
ptrdiff_t const GLvoid * data
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
Memory handling functions.
static av_cold int init(AVCodecContext *avctx)
#define INIT_VLC_STATIC(vlc, bits, a, b, c, d, e, f, g, static_size)
const uint8_t ff_reverse[256]
av_cold void ff_blockdsp_init(BlockDSPContext *c, AVCodecContext *avctx)
void(* clear_blocks)(int16_t *blocks)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
static int asv2_decode_block(ASV1Context *a, int16_t block[64])
unsigned int bitstream_buffer_size
static int get_sbits(GetBitContext *s, int n)
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Macro definitions for various function/variable attributes.
const uint8_t ff_asv2_level_tab[63][2]
static av_cold int decode_init(AVCodecContext *avctx)
uint8_t * bitstream_buffer
static VLC asv2_level_vlc
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
const uint8_t ff_asv_ccp_tab[17][2]
static int asv2_get_level(GetBitContext *gb)
static int get_bits_count(const GetBitContext *s)
const uint8_t ff_asv_dc_ccp_tab[8][2]
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
av_cold void ff_asv_common_init(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int flags
AV_CODEC_FLAG_*.
const char * name
Name of the codec implementation.
#define ASV2_LEVEL_VLC_BITS
uint16_t intra_matrix[64]
ASUS V1/V2 encoder/decoder common data.
static int asv2_get_bits(GetBitContext *gb, int n)
enum AVPictureType pict_type
Picture type of the frame.
static int decode_mb(ASV1Context *a, int16_t block[6][64])
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
uint8_t idct_permutation[64]
IDCT input permutation.
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
const uint16_t ff_mpeg1_default_intra_matrix[256]
static void idct_put(ASV1Context *a, AVFrame *frame, int mb_x, int mb_y)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal api header.
void(* idct_put)(uint8_t *dest, ptrdiff_t line_size, int16_t *block)
block -> idct -> clip to unsigned 8 bit -> dest.
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
VLC_TYPE(* table)[2]
code, bits
static av_cold void init_vlcs(ASV1Context *a)
int key_frame
1 -> keyframe, 0-> not
static int asv1_get_level(GetBitContext *gb)
static int asv1_decode_block(ASV1Context *a, int16_t block[64])
const uint8_t ff_asv_scantab[64]
static av_cold int decode_end(AVCodecContext *avctx)
const uint8_t ff_asv_level_tab[7][2]
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.