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