FFmpeg: libavcodec/asvdec.c Source File
Go to the documentation of this file. 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
30
35 #include "config_components.h"
41
42 #define CCP_VLC_BITS 5
43 #define DC_CCP_VLC_BITS 4
44 #define AC_CCP_VLC_BITS 6
45 #define ASV1_LEVEL_VLC_BITS 4
46 #define ASV2_LEVEL_VLC_BITS 10
47
53
56
58
67
69 {
85 }
86
88 {
90
93 else
95 }
96
97 // get_vlc2() is big-endian in this file
99 {
102
105
110
112
114 }
115
117 {
119
122 else
124 }
125
127 {
129
131
132 for (
i = 0;
i < 11;
i++) {
134
135 if (ccp) {
136 if (ccp == 16)
137 break;
138 if (ccp < 0 || i >= 10) {
141 }
142
143 if (ccp & 8)
145 if (ccp & 4)
147 if (ccp & 2)
149 if (ccp & 1)
151 }
152 }
153
154 return 0;
155 }
156
158 {
160
162
164
166 if (ccp) {
167 if (ccp & 4)
169 if (ccp & 2)
171 if (ccp & 1)
173 }
174
175 for (
i = 1;
i < count + 1;
i++) {
177
178 if (ccp) {
179 if (ccp & 8)
181 if (ccp & 4)
183 if (ccp & 2)
185 if (ccp & 1)
187 }
188 }
189
190 return 0;
191 }
192
194 {
196
197 a->bdsp.clear_blocks(
block[0]);
198
200 for (
i = 0;
i < 6;
i++) {
203 }
204 } else {
205 for (
i = 0;
i < 6;
i++) {
208 }
209 }
210 return 0;
211 }
212
214 {
215 int16_t(*
block)[64] =
a->block;
216 int linesize =
frame->linesize[0];
217
218 uint8_t *dest_y =
frame->data[0] + (mb_y * 16 * linesize) + mb_x * 16;
219 uint8_t *dest_cb =
frame->data[1] + (mb_y * 8 *
frame->linesize[1]) + mb_x * 8;
220 uint8_t *dest_cr =
frame->data[2] + (mb_y * 8 *
frame->linesize[2]) + mb_x * 8;
221
222 a->idsp.idct_put(dest_y, linesize,
block[0]);
223 a->idsp.idct_put(dest_y + 8, linesize,
block[1]);
224 a->idsp.idct_put(dest_y + 8 * linesize, linesize,
block[2]);
225 a->idsp.idct_put(dest_y + 8 * linesize + 8, linesize,
block[3]);
226
228 a->idsp.idct_put(dest_cb,
frame->linesize[1],
block[4]);
229 a->idsp.idct_put(dest_cr,
frame->linesize[2],
block[5]);
230 }
231 }
232
235 {
238 const uint8_t *buf = avpkt->
data;
239 int buf_size = avpkt->
size;
241
242 if (buf_size * 8LL < c->mb_height *
c->mb_width * 13LL)
244
247
250 buf_size);
251 if (!
a->bitstream_buffer)
253
254 c->bbdsp.bswap_buf((uint32_t *)
a->bitstream_buffer,
255 (const uint32_t *) buf, buf_size / 4);
257 } else {
259 }
262
263 for (
int mb_y = 0; mb_y <
c->mb_height2; mb_y++) {
264 for (
int mb_x = 0; mb_x <
c->mb_width2; mb_x++) {
267
269 }
270 }
271
272 if (
c->mb_width2 !=
c->mb_width) {
273 int mb_x =
c->mb_width2;
274 for (
int mb_y = 0; mb_y <
c->mb_height2; mb_y++) {
277
279 }
280 }
281
282 if (
c->mb_height2 !=
c->mb_height) {
283 int mb_y =
c->mb_height2;
284 for (
int mb_x = 0; mb_x <
c->mb_width; mb_x++) {
287
289 }
290 }
291
292 *got_frame = 1;
293
295 }
296
298 {
302 int inv_qscale;
304
307 }
308
313 a->idsp.idct_permutation);
315
319 inv_qscale = 6;
320 else
321 inv_qscale = 10;
322 }
323
324 for (
i = 0;
i < 64;
i++) {
326
328 inv_qscale;
329 }
330
332
333 return 0;
334 }
335
337 {
339
341 a->bitstream_buffer_size = 0;
342
343 return 0;
344 }
345
346 #if CONFIG_ASV1_DECODER
357 };
358 #endif
359
360 #if CONFIG_ASV2_DECODER
370 };
371 #endif
#define AV_LOG_WARNING
Something somehow does not look correct.
const uint8_t ff_asv_dc_ccp_tab[8][2]
const uint8_t ff_asv_level_tab[7][2]
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
#define ASV2_LEVEL_VLC_BITS
static int get_bits_count(const GetBitContext *s)
static av_cold int decode_init(AVCodecContext *avctx)
This structure describes decoded (raw) audio or video data.
static const uint16_t table[]
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
const uint16_t ff_asv2_level_tab[63][2]
av_cold void ff_permute_scantable(uint8_t dst[64], const uint8_t src[64], const uint8_t permutation[64])
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
unsigned int bitstream_buffer_size
const FFCodec ff_asv1_decoder
const uint8_t ff_asv_scantab[64]
static int asv2_get_level(GetBitContext *gb)
static int ff_thread_once(char *control, void(*routine)(void))
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define ASV1_LEVEL_VLC_BITS
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
uint8_t permutated_scantable[64]
static VLCElem ac_ccp_vlc[64]
#define CLOSE_READER(name, gb)
#define FF_CODEC_DECODE_CB(func)
av_cold void ff_blockdsp_init(BlockDSPContext *c)
static unsigned int get_bits_le(GetBitContext *s, int n)
static int get_sbits(GetBitContext *s, int n)
static void idct_put(ASVDecContext *a, AVFrame *frame, int mb_x, int mb_y)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define SHOW_UBITS_LE(name, gb, num)
static int decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
#define CODEC_LONG_NAME(str)
static int asv1_decode_block(ASVDecContext *a, int16_t block[64])
const uint8_t ff_asv_ac_ccp_tab[16][2]
static av_cold void init_vlcs(void)
#define LAST_SKIP_BITS(name, gb, num)
static int asv2_get_vlc2(GetBitContext *gb, const VLCElem *table, int bits)
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
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
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
#define DECLARE_ALIGNED(n, t, v)
const uint16_t ff_mpeg1_default_intra_matrix[256]
#define OPEN_READER(name, gb)
av_cold void ff_asv_common_init(AVCodecContext *avctx)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static VLCElem asv2_level_vlc[1024]
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...
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int decode_mb(ASVDecContext *a, int16_t block[6][64])
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
uint16_t intra_matrix[64]
main external API structure.
#define UPDATE_CACHE_LE(name, gb)
static av_cold int decode_end(AVCodecContext *avctx)
#define VLC_INIT_STATIC_TABLE(vlc_table, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
static VLCElem ccp_vlc[32]
uint8_t * bitstream_buffer
static VLCElem level_vlc[16]
static int asv2_decode_block(ASVDecContext *a, int16_t block[64])
static int init_get_bits8_le(GetBitContext *s, const uint8_t *buffer, int byte_size)
const uint8_t ff_asv_ccp_tab[17][2]
static void scale(int *out, const int *in, const int w, const int h, const int shift)
This structure stores compressed data.
The exact code depends on how similar the blocks are and how related they are to the block
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static VLCElem dc_ccp_vlc[16]
static int asv1_get_level(GetBitContext *gb)
const FFCodec ff_asv2_decoder
Generated on Fri Aug 22 2025 13:58:10 for FFmpeg by
doxygen
1.8.17