Lines Matching defs:ctx
84 static inline void put_blocks(HQXContext *ctx, int plane,
90 int lsize = ctx->pic->linesize[plane];
91 uint8_t *p = ctx->pic->data[plane] + x * 2;
93 ctx->hqxdsp.idct_put((uint16_t *)(p + y * lsize),
95 ctx->hqxdsp.idct_put((uint16_t *)(p + (y + (ilace ? 1 : 8)) * lsize),
154 static int hqx_decode_422(HQXContext *ctx, int slice_no, int x, int y)
156 HQXSlice *slice = &ctx->slice[slice_no];
163 if (ctx->interlaced)
171 int vlc_index = ctx->dcb - 9;
174 ret = decode_block(gb, &ctx->dc_vlc[vlc_index], quants,
175 ctx->dcb, slice->block[i], &last_dc);
180 put_blocks(ctx, 0, x, y, flag, slice->block[0], slice->block[2], hqx_quant_luma);
181 put_blocks(ctx, 0, x + 8, y, flag, slice->block[1], slice->block[3], hqx_quant_luma);
182 put_blocks(ctx, 2, x >> 1, y, flag, slice->block[4], slice->block[5], hqx_quant_chroma);
183 put_blocks(ctx, 1, x >> 1, y, flag, slice->block[6], slice->block[7], hqx_quant_chroma);
188 static int hqx_decode_422a(HQXContext *ctx, int slice_no, int x, int y)
190 HQXSlice *slice = &ctx->slice[slice_no];
198 cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
205 if (ctx->interlaced)
219 int vlc_index = ctx->dcb - 9;
220 ret = decode_block(gb, &ctx->dc_vlc[vlc_index], quants,
221 ctx->dcb, slice->block[i], &last_dc);
228 put_blocks(ctx, 3, x, y, flag, slice->block[ 0], slice->block[ 2], hqx_quant_luma);
229 put_blocks(ctx, 3, x + 8, y, flag, slice->block[ 1], slice->block[ 3], hqx_quant_luma);
230 put_blocks(ctx, 0, x, y, flag, slice->block[ 4], slice->block[ 6], hqx_quant_luma);
231 put_blocks(ctx, 0, x + 8, y, flag, slice->block[ 5], slice->block[ 7], hqx_quant_luma);
232 put_blocks(ctx, 2, x >> 1, y, flag, slice->block[ 8], slice->block[ 9], hqx_quant_chroma);
233 put_blocks(ctx, 1, x >> 1, y, flag, slice->block[10], slice->block[11], hqx_quant_chroma);
238 static int hqx_decode_444(HQXContext *ctx, int slice_no, int x, int y)
240 HQXSlice *slice = &ctx->slice[slice_no];
247 if (ctx->interlaced)
255 int vlc_index = ctx->dcb - 9;
258 ret = decode_block(gb, &ctx->dc_vlc[vlc_index], quants,
259 ctx->dcb, slice->block[i], &last_dc);
264 put_blocks(ctx, 0, x, y, flag, slice->block[0], slice->block[ 2], hqx_quant_luma);
265 put_blocks(ctx, 0, x + 8, y, flag, slice->block[1], slice->block[ 3], hqx_quant_luma);
266 put_blocks(ctx, 2, x, y, flag, slice->block[4], slice->block[ 6], hqx_quant_chroma);
267 put_blocks(ctx, 2, x + 8, y, flag, slice->block[5], slice->block[ 7], hqx_quant_chroma);
268 put_blocks(ctx, 1, x, y, flag, slice->block[8], slice->block[10], hqx_quant_chroma);
269 put_blocks(ctx, 1, x + 8, y, flag, slice->block[9], slice->block[11], hqx_quant_chroma);
274 static int hqx_decode_444a(HQXContext *ctx, int slice_no, int x, int y)
276 HQXSlice *slice = &ctx->slice[slice_no];
284 cbp = get_vlc2(gb, ctx->cbp_vlc.table, HQX_CBP_VLC_BITS, 1);
291 if (ctx->interlaced)
302 int vlc_index = ctx->dcb - 9;
303 ret = decode_block(gb, &ctx->dc_vlc[vlc_index], quants,
304 ctx->dcb, slice->block[i], &last_dc);
311 put_blocks(ctx, 3, x, y, flag, slice->block[ 0], slice->block[ 2], hqx_quant_luma);
312 put_blocks(ctx, 3, x + 8, y, flag, slice->block[ 1], slice->block[ 3], hqx_quant_luma);
313 put_blocks(ctx, 0, x, y, flag, slice->block[ 4], slice->block[ 6], hqx_quant_luma);
314 put_blocks(ctx, 0, x + 8, y, flag, slice->block[ 5], slice->block[ 7], hqx_quant_luma);
315 put_blocks(ctx, 2, x, y, flag, slice->block[ 8], slice->block[10], hqx_quant_chroma);
316 put_blocks(ctx, 2, x + 8, y, flag, slice->block[ 9], slice->block[11], hqx_quant_chroma);
317 put_blocks(ctx, 1, x, y, flag, slice->block[12], slice->block[14], hqx_quant_chroma);
318 put_blocks(ctx, 1, x + 8, y, flag, slice->block[13], slice->block[15], hqx_quant_chroma);
327 static int decode_slice(HQXContext *ctx, int slice_no)
329 int mb_w = (ctx->width + 15) >> 4;
330 int mb_h = (ctx->height + 15) >> 4;
373 ctx->decode_func(ctx, slice_no, mb_x * 16, mb_y * 16);
383 HQXContext *ctx = avctx->priv_data;
384 uint32_t *slice_off = ctx->slice_off;
389 slice_off[slice_no + 1] > ctx->data_size) {
390 av_log(avctx, AV_LOG_ERROR, "Invalid slice size %d.\n", ctx->data_size);
394 ret = init_get_bits8(&ctx->slice[slice_no].gb,
395 ctx->src + slice_off[slice_no],
400 return decode_slice(ctx, slice_no);
406 HQXContext *ctx = avctx->priv_data;
433 ctx->data_size = avpkt->size - data_start;
434 ctx->src = src;
435 ctx->pic = frame;
437 if (ctx->data_size < HQX_HEADER_SIZE) {
446 ctx->interlaced = !(src[2] & 0x80);
447 ctx->format = src[2] & 7;
448 ctx->dcb = (src[3] & 3) + 8;
449 ctx->width = AV_RB16(src + 4);
450 ctx->height = AV_RB16(src + 6);
452 ctx->slice_off[i] = AV_RB24(src + 8 + i * 3);
454 if (ctx->dcb == 8) {
455 av_log(avctx, AV_LOG_ERROR, "Invalid DC precision %d.\n", ctx->dcb);
458 ret = av_image_check_size(ctx->width, ctx->height, 0, avctx);
461 ctx->width, ctx->height);
465 avctx->coded_width = FFALIGN(ctx->width, 16);
466 avctx->coded_height = FFALIGN(ctx->height, 16);
467 avctx->width = ctx->width;
468 avctx->height = ctx->height;
479 switch (ctx->format) {
482 ctx->decode_func = hqx_decode_422;
486 ctx->decode_func = hqx_decode_444;
490 ctx->decode_func = hqx_decode_422a;
494 ctx->decode_func = hqx_decode_444a;
497 av_log(avctx, AV_LOG_ERROR, "Invalid format: %d.\n", ctx->format);
507 ctx->pic->key_frame = 1;
508 ctx->pic->pict_type = AV_PICTURE_TYPE_I;
518 HQXContext *ctx = avctx->priv_data;
520 ff_free_vlc(&ctx->cbp_vlc);
522 ff_free_vlc(&ctx->dc_vlc[i]);
530 HQXContext *ctx = avctx->priv_data;
532 ff_hqxdsp_init(&ctx->hqxdsp);
534 return ff_hqx_init_vlcs(ctx);