Lines Matching refs:ctx
56 * @param[in,out] ctx ptr to the decoder context
60 static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx)
67 ctx->gop_flags = get_bits(&ctx->gb, 8);
69 ctx->gop_hdr_size = (ctx->gop_flags & 1) ? get_bits(&ctx->gb, 16) : 0;
71 if (ctx->gop_flags & IVI5_IS_PROTECTED)
72 ctx->lock_word = get_bits_long(&ctx->gb, 32);
74 tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0;
82 pic_conf.luma_bands = get_bits(&ctx->gb, 2) * 3 + 1;
83 pic_conf.chroma_bands = get_bits1(&ctx->gb) * 3 + 1;
91 pic_size_indx = get_bits(&ctx->gb, 4);
93 pic_conf.pic_height = get_bits(&ctx->gb, 13);
94 pic_conf.pic_width = get_bits(&ctx->gb, 13);
100 if (ctx->gop_flags & 2) {
116 if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf) || ctx->gop_invalid) {
117 result = ff_ivi_init_planes(avctx, ctx->planes, &pic_conf, 0);
122 ctx->pic_conf = pic_conf;
123 ctx->is_scalable = is_scalable;
129 band = &ctx->planes[p].bands[i];
131 band->is_halfpel = get_bits1(&ctx->gb);
133 mb_size = get_bits1(&ctx->gb);
134 blk_size = 8 >> get_bits1(&ctx->gb);
148 if (get_bits1(&ctx->gb)) {
222 if (get_bits(&ctx->gb, 2)) {
231 band1 = &ctx->planes[1].bands[i];
232 band2 = &ctx->planes[2].bands[i];
252 result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width,
261 if (ctx->gop_flags & 8) {
262 if (get_bits(&ctx->gb, 3)) {
267 if (get_bits1(&ctx->gb))
268 skip_bits(&ctx->gb, 24); /* skip transparency fill color */
271 align_get_bits(&ctx->gb);
273 skip_bits(&ctx->gb, 23); /* FIXME: unknown meaning */
276 if (get_bits1(&ctx->gb)) {
278 i = get_bits(&ctx->gb, 16);
282 align_get_bits(&ctx->gb);
311 * @param[in,out] ctx ptr to the decoder context
315 static int decode_pic_hdr(IVI45DecContext *ctx, AVCodecContext *avctx)
319 if (get_bits(&ctx->gb, 5) != 0x1F) {
324 ctx->prev_frame_type = ctx->frame_type;
325 ctx->frame_type = get_bits(&ctx->gb, 3);
326 if (ctx->frame_type >= 5) {
327 av_log(avctx, AV_LOG_ERROR, "Invalid frame type: %d \n", ctx->frame_type);
328 ctx->frame_type = FRAMETYPE_INTRA;
332 ctx->frame_num = get_bits(&ctx->gb, 8);
334 if (ctx->frame_type == FRAMETYPE_INTRA) {
335 if ((ret = decode_gop_header(ctx, avctx)) < 0) {
337 ctx->gop_invalid = 1;
340 ctx->gop_invalid = 0;
343 if (ctx->frame_type == FRAMETYPE_INTER_SCAL && !ctx->is_scalable) {
345 ctx->frame_type = FRAMETYPE_INTER;
349 if (ctx->frame_type != FRAMETYPE_NULL) {
350 ctx->frame_flags = get_bits(&ctx->gb, 8);
352 ctx->pic_hdr_size = (ctx->frame_flags & 1) ? get_bits(&ctx->gb, 24) : 0;
354 ctx->checksum = (ctx->frame_flags & 0x10) ? get_bits(&ctx->gb, 16) : 0;
357 if (ctx->frame_flags & 0x20)
358 skip_hdr_extension(&ctx->gb); /* XXX: untested */
361 ret = ff_ivi_dec_huff_desc(&ctx->gb, ctx->frame_flags & 0x40,
362 IVI_MB_HUFF, &ctx->mb_vlc, avctx);
366 skip_bits(&ctx->gb, 3); /* FIXME: unknown meaning! */
369 align_get_bits(&ctx->gb);
378 * @param[in,out] ctx ptr to the decoder context
383 static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
389 band_flags = get_bits(&ctx->gb, 8);
396 band->data_size = (ctx->frame_flags & 0x80) ? get_bits(&ctx->gb, 24) : 0;
406 band->num_corr = get_bits(&ctx->gb, 8); /* get number of correction pairs */
415 band->corr[i] = get_bits(&ctx->gb, 8);
419 band->rvmap_sel = (band_flags & 0x40) ? get_bits(&ctx->gb, 3) : 8;
422 ret = ff_ivi_dec_huff_desc(&ctx->gb, band_flags & 0x80, IVI_BLK_HUFF,
427 band->checksum_present = get_bits1(&ctx->gb);
429 band->checksum = get_bits(&ctx->gb, 16);
431 band->glob_quant = get_bits(&ctx->gb, 5);
435 align_get_bits(&ctx->gb);
436 skip_hdr_extension(&ctx->gb);
439 align_get_bits(&ctx->gb);
449 * @param[in,out] ctx ptr to the decoder context
455 static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band,
478 mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3);
489 if (get_bits1(&ctx->gb)) {
490 if (ctx->frame_type == FRAMETYPE_INTRA) {
498 if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) {
499 mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
518 } else if (ctx->frame_type == FRAMETYPE_INTRA) {
521 mb->type = get_bits1(&ctx->gb);
525 mb->cbp = get_bits(&ctx->gb, blks_per_mb);
532 (ctx->frame_flags & 8))) {
533 mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
553 mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
556 mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table,
583 align_get_bits(&ctx->gb);
592 * @param[in,out] ctx ptr to the decoder context
594 static void switch_buffers(IVI45DecContext *ctx)
596 switch (ctx->prev_frame_type) {
599 ctx->buf_switch ^= 1;
600 ctx->dst_buf = ctx->buf_switch;
601 ctx->ref_buf = ctx->buf_switch ^ 1;
604 if (!ctx->inter_scal) {
605 ctx->ref2_buf = 2;
606 ctx->inter_scal = 1;
608 FFSWAP(int, ctx->dst_buf, ctx->ref2_buf);
609 ctx->ref_buf = ctx->ref2_buf;
615 switch (ctx->frame_type) {
617 ctx->buf_switch = 0;
620 ctx->inter_scal = 0;
621 ctx->dst_buf = ctx->buf_switch;
622 ctx->ref_buf = ctx->buf_switch ^ 1;
632 static int is_nonnull_frame(IVI45DecContext *ctx)
634 return ctx->frame_type != FRAMETYPE_NULL;
643 IVI45DecContext *ctx = avctx->priv_data;
646 ctx->gop_invalid = 1;
651 memcpy(ctx->rvmap_tabs, ff_ivi_rvmap_tabs, sizeof(ff_ivi_rvmap_tabs));
656 ctx->pic_conf.pic_width = avctx->width;
657 ctx->pic_conf.pic_height = avctx->height;
658 ctx->pic_conf.chroma_width = (avctx->width + 3) >> 2;
659 ctx->pic_conf.chroma_height = (avctx->height + 3) >> 2;
660 ctx->pic_conf.tile_width = avctx->width;
661 ctx->pic_conf.tile_height = avctx->height;
662 ctx->pic_conf.luma_bands = ctx->pic_conf.chroma_bands = 1;
664 result = ff_ivi_init_planes(avctx, ctx->planes, &ctx->pic_conf, 0);
670 ctx->buf_switch = 0;
671 ctx->inter_scal = 0;
673 ctx->decode_pic_hdr = decode_pic_hdr;
674 ctx->decode_band_hdr = decode_band_hdr;
675 ctx->decode_mb_info = decode_mb_info;
676 ctx->switch_buffers = switch_buffers;
677 ctx->is_nonnull_frame = is_nonnull_frame;
679 ctx->is_indeo4 = 0;