Lines Matching defs:ctx

108     MimicContext *ctx = avctx->priv_data;
111 av_freep(&ctx->swap_buf);
112 ctx->swap_buf_size = 0;
114 for (i = 0; i < FF_ARRAY_ELEMS(ctx->frames); i++) {
115 if (ctx->frames[i].f)
116 ff_thread_release_ext_buffer(avctx, &ctx->frames[i]);
117 av_frame_free(&ctx->frames[i].f);
132 MimicContext *ctx = avctx->priv_data;
135 ctx->prev_index = 0;
136 ctx->cur_index = 15;
138 ff_blockdsp_init(&ctx->bdsp, avctx);
139 ff_bswapdsp_init(&ctx->bbdsp);
140 ff_hpeldsp_init(&ctx->hdsp, avctx->flags);
141 ff_idctdsp_init(&ctx->idsp, avctx);
142 ff_init_scantable(ctx->idsp.idct_permutation, &ctx->scantable, col_zag);
144 for (i = 0; i < FF_ARRAY_ELEMS(ctx->frames); i++) {
145 ctx->frames[i].f = av_frame_alloc();
146 if (!ctx->frames[i].f)
217 static int vlc_decode_block(MimicContext *ctx, int num_coeffs, int qscale)
219 int16_t *block = ctx->dct_block;
222 ctx->bdsp.clear_block(block);
224 block[0] = get_bits(&ctx->gb, 8) << 3;
231 vlc = get_vlc2(&ctx->gb, block_vlc.table, MIMIC_VLC_BITS, 3);
244 value = get_bits(&ctx->gb, num_bits);
255 block[ctx->scantable.permutated[pos]] = coeff;
261 static int decode(MimicContext *ctx, int quality, int num_coeffs,
270 const int stride = ctx->frames[ctx->cur_index ].f->linesize[plane];
271 const uint8_t *src = ctx->frames[ctx->prev_index].f->data[plane];
272 uint8_t *dst = ctx->frames[ctx->cur_index ].f->data[plane];
274 for (y = 0; y < ctx->num_vblocks[plane]; y++) {
275 for (x = 0; x < ctx->num_hblocks[plane]; x++) {
280 if (is_iframe || get_bits1(&ctx->gb) == is_chroma) {
284 if (is_chroma || is_iframe || !get_bits1(&ctx->gb)) {
285 if ((ret = vlc_decode_block(ctx, num_coeffs,
287 av_log(ctx->avctx, AV_LOG_ERROR, "Error decoding "
291 ctx->idsp.idct_put(dst, stride, ctx->dct_block);
293 unsigned int backref = get_bits(&ctx->gb, 4);
294 int index = (ctx->cur_index + backref) & 15;
295 uint8_t *p = ctx->frames[index].f->data[0];
297 if (index != ctx->cur_index && p) {
298 ff_thread_await_progress(&ctx->frames[index],
301 ctx->frames[ctx->prev_index].f->data[plane];
302 ctx->hdsp.put_pixels_tab[1][0](dst, p, stride, 8);
304 av_log(ctx->avctx, AV_LOG_ERROR,
309 ff_thread_await_progress(&ctx->frames[ctx->prev_index],
311 ctx->hdsp.put_pixels_tab[1][0](dst, src, stride, 8);
316 src += (stride - ctx->num_hblocks[plane]) << 3;
317 dst += (stride - ctx->num_hblocks[plane]) << 3;
319 ff_thread_report_progress(&ctx->frames[ctx->cur_index],
348 MimicContext *ctx = avctx->priv_data;
370 if (!ctx->avctx) {
383 ctx->avctx = avctx;
386 ctx->num_vblocks[i] = AV_CEIL_RSHIFT(height, 3 + !!i);
387 ctx->num_hblocks[i] = width >> (3 + !!i);
389 } else if (width != ctx->avctx->width || height != ctx->avctx->height) {
394 if (is_pframe && !ctx->frames[ctx->prev_index].f->data[0]) {
399 ff_thread_release_ext_buffer(avctx, &ctx->frames[ctx->cur_index]);
400 ctx->frames[ctx->cur_index].f->pict_type = is_pframe ? AV_PICTURE_TYPE_P :
402 if ((res = ff_thread_get_ext_buffer(avctx, &ctx->frames[ctx->cur_index],
406 ctx->next_prev_index = ctx->cur_index;
407 ctx->next_cur_index = (ctx->cur_index - 1) & 15;
411 av_fast_padded_malloc(&ctx->swap_buf, &ctx->swap_buf_size, swap_buf_size);
412 if (!ctx->swap_buf)
415 ctx->bbdsp.bswap_buf(ctx->swap_buf,
418 init_get_bits(&ctx->gb, ctx->swap_buf, swap_buf_size << 3);
420 res = decode(ctx, quality, num_coeffs, !is_pframe);
421 ff_thread_report_progress(&ctx->frames[ctx->cur_index], INT_MAX, 0);
424 ff_thread_release_ext_buffer(avctx, &ctx->frames[ctx->cur_index]);
428 if ((res = av_frame_ref(rframe, ctx->frames[ctx->cur_index].f)) < 0)
434 ctx->prev_index = ctx->next_prev_index;
435 ctx->cur_index = ctx->next_cur_index;