1cabdff1aSopenharmony_ci/* 2cabdff1aSopenharmony_ci * RV30/40 decoder common data declarations 3cabdff1aSopenharmony_ci * Copyright (c) 2007 Mike Melanson, Konstantin Shishkov 4cabdff1aSopenharmony_ci * 5cabdff1aSopenharmony_ci * This file is part of FFmpeg. 6cabdff1aSopenharmony_ci * 7cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or 8cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 9cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either 10cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 11cabdff1aSopenharmony_ci * 12cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful, 13cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 14cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15cabdff1aSopenharmony_ci * Lesser General Public License for more details. 16cabdff1aSopenharmony_ci * 17cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 18cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software 19cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20cabdff1aSopenharmony_ci */ 21cabdff1aSopenharmony_ci 22cabdff1aSopenharmony_ci/** 23cabdff1aSopenharmony_ci * @file 24cabdff1aSopenharmony_ci * RV30 and RV40 decoder common data declarations 25cabdff1aSopenharmony_ci */ 26cabdff1aSopenharmony_ci 27cabdff1aSopenharmony_ci#ifndef AVCODEC_RV34_H 28cabdff1aSopenharmony_ci#define AVCODEC_RV34_H 29cabdff1aSopenharmony_ci 30cabdff1aSopenharmony_ci#include "libavutil/mem_internal.h" 31cabdff1aSopenharmony_ci 32cabdff1aSopenharmony_ci#include "avcodec.h" 33cabdff1aSopenharmony_ci#include "mpegvideo.h" 34cabdff1aSopenharmony_ci 35cabdff1aSopenharmony_ci#include "h264pred.h" 36cabdff1aSopenharmony_ci#include "rv34dsp.h" 37cabdff1aSopenharmony_ci 38cabdff1aSopenharmony_ci#define MB_TYPE_SEPARATE_DC 0x01000000 39cabdff1aSopenharmony_ci#define IS_SEPARATE_DC(a) ((a) & MB_TYPE_SEPARATE_DC) 40cabdff1aSopenharmony_ci 41cabdff1aSopenharmony_ci/** 42cabdff1aSopenharmony_ci * RV30 and RV40 Macroblock types 43cabdff1aSopenharmony_ci */ 44cabdff1aSopenharmony_cienum RV40BlockTypes{ 45cabdff1aSopenharmony_ci RV34_MB_TYPE_INTRA, ///< Intra macroblock 46cabdff1aSopenharmony_ci RV34_MB_TYPE_INTRA16x16, ///< Intra macroblock with DCs in a separate 4x4 block 47cabdff1aSopenharmony_ci RV34_MB_P_16x16, ///< P-frame macroblock, one motion frame 48cabdff1aSopenharmony_ci RV34_MB_P_8x8, ///< P-frame macroblock, 8x8 motion compensation partitions 49cabdff1aSopenharmony_ci RV34_MB_B_FORWARD, ///< B-frame macroblock, forward prediction 50cabdff1aSopenharmony_ci RV34_MB_B_BACKWARD, ///< B-frame macroblock, backward prediction 51cabdff1aSopenharmony_ci RV34_MB_SKIP, ///< Skipped block 52cabdff1aSopenharmony_ci RV34_MB_B_DIRECT, ///< Bidirectionally predicted B-frame macroblock, no motion vectors 53cabdff1aSopenharmony_ci RV34_MB_P_16x8, ///< P-frame macroblock, 16x8 motion compensation partitions 54cabdff1aSopenharmony_ci RV34_MB_P_8x16, ///< P-frame macroblock, 8x16 motion compensation partitions 55cabdff1aSopenharmony_ci RV34_MB_B_BIDIR, ///< Bidirectionally predicted B-frame macroblock, two motion vectors 56cabdff1aSopenharmony_ci RV34_MB_P_MIX16x16, ///< P-frame macroblock with DCs in a separate 4x4 block, one motion vector 57cabdff1aSopenharmony_ci RV34_MB_TYPES 58cabdff1aSopenharmony_ci}; 59cabdff1aSopenharmony_ci 60cabdff1aSopenharmony_ci/** 61cabdff1aSopenharmony_ci * VLC tables used by the decoder 62cabdff1aSopenharmony_ci * 63cabdff1aSopenharmony_ci * Intra frame VLC sets do not contain some of those tables. 64cabdff1aSopenharmony_ci */ 65cabdff1aSopenharmony_citypedef struct RV34VLC{ 66cabdff1aSopenharmony_ci VLC cbppattern[2]; ///< VLCs used for pattern of coded block patterns decoding 67cabdff1aSopenharmony_ci VLC cbp[2][4]; ///< VLCs used for coded block patterns decoding 68cabdff1aSopenharmony_ci VLC first_pattern[4]; ///< VLCs used for decoding coefficients in the first subblock 69cabdff1aSopenharmony_ci VLC second_pattern[2]; ///< VLCs used for decoding coefficients in the subblocks 2 and 3 70cabdff1aSopenharmony_ci VLC third_pattern[2]; ///< VLCs used for decoding coefficients in the last subblock 71cabdff1aSopenharmony_ci VLC coefficient; ///< VLCs used for decoding big coefficients 72cabdff1aSopenharmony_ci}RV34VLC; 73cabdff1aSopenharmony_ci 74cabdff1aSopenharmony_ci/** essential slice information */ 75cabdff1aSopenharmony_citypedef struct SliceInfo{ 76cabdff1aSopenharmony_ci int type; ///< slice type (intra, inter) 77cabdff1aSopenharmony_ci int quant; ///< quantizer used for this slice 78cabdff1aSopenharmony_ci int vlc_set; ///< VLCs used for this slice 79cabdff1aSopenharmony_ci int start, end; ///< start and end macroblocks of the slice 80cabdff1aSopenharmony_ci int width; ///< coded width 81cabdff1aSopenharmony_ci int height; ///< coded height 82cabdff1aSopenharmony_ci int pts; ///< frame timestamp 83cabdff1aSopenharmony_ci}SliceInfo; 84cabdff1aSopenharmony_ci 85cabdff1aSopenharmony_ci/** decoder context */ 86cabdff1aSopenharmony_citypedef struct RV34DecContext{ 87cabdff1aSopenharmony_ci MpegEncContext s; 88cabdff1aSopenharmony_ci RV34DSPContext rdsp; 89cabdff1aSopenharmony_ci int8_t *intra_types_hist;///< old block types, used for prediction 90cabdff1aSopenharmony_ci int8_t *intra_types; ///< block types 91cabdff1aSopenharmony_ci int intra_types_stride;///< block types array stride 92cabdff1aSopenharmony_ci const uint8_t *luma_dc_quant_i;///< luma subblock DC quantizer for intraframes 93cabdff1aSopenharmony_ci const uint8_t *luma_dc_quant_p;///< luma subblock DC quantizer for interframes 94cabdff1aSopenharmony_ci 95cabdff1aSopenharmony_ci RV34VLC *cur_vlcs; ///< VLC set used for current frame decoding 96cabdff1aSopenharmony_ci H264PredContext h; ///< functions for 4x4 and 16x16 intra block prediction 97cabdff1aSopenharmony_ci SliceInfo si; ///< current slice information 98cabdff1aSopenharmony_ci 99cabdff1aSopenharmony_ci int *mb_type; ///< internal macroblock types 100cabdff1aSopenharmony_ci int block_type; ///< current block type 101cabdff1aSopenharmony_ci int luma_vlc; ///< which VLC set will be used for decoding of luma blocks 102cabdff1aSopenharmony_ci int chroma_vlc; ///< which VLC set will be used for decoding of chroma blocks 103cabdff1aSopenharmony_ci int is16; ///< current block has additional 16x16 specific features or not 104cabdff1aSopenharmony_ci int dmv[4][2]; ///< differential motion vectors for the current macroblock 105cabdff1aSopenharmony_ci 106cabdff1aSopenharmony_ci int rv30; ///< indicates which RV variant is currently decoded 107cabdff1aSopenharmony_ci int max_rpr; 108cabdff1aSopenharmony_ci 109cabdff1aSopenharmony_ci int cur_pts, last_pts, next_pts; 110cabdff1aSopenharmony_ci int scaled_weight; 111cabdff1aSopenharmony_ci int weight1, weight2; ///< B-frame distance fractions (0.14) used in motion compensation 112cabdff1aSopenharmony_ci int mv_weight1, mv_weight2; 113cabdff1aSopenharmony_ci 114cabdff1aSopenharmony_ci int orig_width, orig_height; 115cabdff1aSopenharmony_ci 116cabdff1aSopenharmony_ci uint16_t *cbp_luma; ///< CBP values for luma subblocks 117cabdff1aSopenharmony_ci uint8_t *cbp_chroma; ///< CBP values for chroma subblocks 118cabdff1aSopenharmony_ci uint16_t *deblock_coefs; ///< deblock coefficients for each macroblock 119cabdff1aSopenharmony_ci 120cabdff1aSopenharmony_ci /** 8x8 block available flags (for MV prediction) */ 121cabdff1aSopenharmony_ci DECLARE_ALIGNED(8, uint32_t, avail_cache)[3*4]; 122cabdff1aSopenharmony_ci 123cabdff1aSopenharmony_ci /** temporary blocks for RV4 weighted MC */ 124cabdff1aSopenharmony_ci uint8_t *tmp_b_block_y[2]; 125cabdff1aSopenharmony_ci uint8_t *tmp_b_block_uv[4]; 126cabdff1aSopenharmony_ci uint8_t *tmp_b_block_base; 127cabdff1aSopenharmony_ci 128cabdff1aSopenharmony_ci int (*parse_slice_header)(struct RV34DecContext *r, GetBitContext *gb, SliceInfo *si); 129cabdff1aSopenharmony_ci int (*decode_mb_info)(struct RV34DecContext *r); 130cabdff1aSopenharmony_ci int (*decode_intra_types)(struct RV34DecContext *r, GetBitContext *gb, int8_t *dst); 131cabdff1aSopenharmony_ci void (*loop_filter)(struct RV34DecContext *r, int row); 132cabdff1aSopenharmony_ci}RV34DecContext; 133cabdff1aSopenharmony_ci 134cabdff1aSopenharmony_ci/** 135cabdff1aSopenharmony_ci * common decoding functions 136cabdff1aSopenharmony_ci */ 137cabdff1aSopenharmony_ciint ff_rv34_get_start_offset(GetBitContext *gb, int blocks); 138cabdff1aSopenharmony_ciint ff_rv34_decode_init(AVCodecContext *avctx); 139cabdff1aSopenharmony_ciint ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *frame, 140cabdff1aSopenharmony_ci int *got_frame, AVPacket *avpkt); 141cabdff1aSopenharmony_ciint ff_rv34_decode_end(AVCodecContext *avctx); 142cabdff1aSopenharmony_ciint ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); 143cabdff1aSopenharmony_ci 144cabdff1aSopenharmony_ci#endif /* AVCODEC_RV34_H */ 145