42#define V2_INTRA_CBPC_VLC_BITS 3
43#define V2_MB_TYPE_VLC_BITS 7
47#define DEFAULT_INTER_INDEX 3
62 *dc_val_ptr= &
h->last_dc[
i];
82 ff_dlog(
h->c.avctx,
"MV code %d at %d %d pred: %d\n",
113 uint32_t *
const mb_type_ptr = &
h->c.cur_pic.mb_type[
h->c.mb_x +
h->c.mb_y*
h->c.mb_stride];
121 h->c.block_last_index[
i] = -1;
124 h->c.mv[0][0][0] = 0;
125 h->c.mv[0][0][1] = 0;
132 if (
h->c.msmpeg4_version == MSMP4_V2)
138 code,
h->c.mb_x,
h->c.mb_y);
142 h->c.mb_intra =
code >>2;
147 if (
h->c.msmpeg4_version == MSMP4_V2)
153 cbp,
h->c.mb_x,
h->c.mb_y);
158 if (!
h->c.mb_intra) {
164 cbp,
h->c.mb_x,
h->c.mb_y);
169 if (
h->c.msmpeg4_version == MSMP4_V1 || (cbp&3) != 3)
178 h->c.mv[0][0][0] =
mx;
179 h->c.mv[0][0][1] =
my;
183 if (
h->c.msmpeg4_version == MSMP4_V2) {
204 h->c.bdsp.clear_blocks(
h->block[0]);
205 for (
i = 0;
i < 6;
i++) {
209 h->c.mb_x,
h->c.mb_y,
i);
221 uint32_t *
const mb_type_ptr = &
h->c.cur_pic.mb_type[
h->c.mb_x +
h->c.mb_y*
h->c.mb_stride];
232 h->c.block_last_index[
i] = -1;
235 h->c.mv[0][0][0] = 0;
236 h->c.mv[0][0][1] = 0;
246 h->c.mb_intra = (
~code & 0x40) >> 6;
261 cbp |=
val << (5 -
i);
265 if (!
h->c.mb_intra) {
275 h->c.mv[0][0][0] =
mx;
276 h->c.mv[0][0][1] =
my;
279 ff_dlog(
h->c.avctx,
"I at %d %d %d %06X\n",
h->c.mb_x,
h->c.mb_y,
280 ((cbp & 3) ? 1 : 0) +((cbp & 0x3C)? 2 : 0),
284 if (
h->c.inter_intra_pred) {
287 h->c.ac_pred,
h->c.h263_aic_dir,
h->c.mb_x,
h->c.mb_y);
295 h->c.bdsp.clear_blocks(
h->block[0]);
296 for (
i = 0;
i < 6;
i++) {
300 h->c.mb_x,
h->c.mb_y,
i);
311 static VLCElem vlc_buf[3714 + 2694 + 1636 + 2648 + 1532 + 2488];
349 for (
unsigned i = 0;
i < 4;
i++) {
373 if (
get_bits_left(&
h->gb) * 8LL < (
h->c.width+15)/16 * ((
h->c.height+15)/16))
376 if (
h->c.msmpeg4_version == MSMP4_V1) {
392 h->c.chroma_qscale =
h->c.qscale =
get_bits(&
h->gb, 5);
393 if (
h->c.qscale == 0) {
400 if (
h->c.msmpeg4_version == MSMP4_V1) {
406 h->slice_height =
code;
414 h->slice_height =
h->c.mb_height / (
code - 0x16);
417 switch (
h->c.msmpeg4_version) {
445 h->c.inter_intra_pred= 0;
448 av_unreachable(
"msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
450 h->c.no_rounding = 1;
460 switch (
h->c.msmpeg4_version) {
463 if (
h->c.msmpeg4_version == MSMP4_V1)
497 h->c.inter_intra_pred =
h->c.width*
h->c.height < 320*240 &&
501 av_unreachable(
"msmpeg4_decode_picture_header() only used by MSMP4V1-3, WMV1");
515 h->c.no_rounding ^= 1;
517 h->c.no_rounding = 0;
521 h->c.inter_intra_pred,
h->c.width,
h->c.height);
533 int length =
h->c.msmpeg4_version >= MSMP4_V3 ? 17 : 16;
539 if (
h->c.msmpeg4_version >= MSMP4_V3)
544 else if(
left<length+8)
547 if (
h->c.msmpeg4_version != MSMP4_V2)
563 if (
h->c.msmpeg4_version <= MSMP4_V2) {
583 }
else if (
level != 0) {
589 if (
h->c.msmpeg4_version == MSMP4_V1) {
603 *dc_val =
level *
h->c.y_dc_scale;
605 *dc_val =
level *
h->c.c_dc_scale;
613 int n,
int coded,
const uint8_t *scan_table)
617 int dc_pred_dir = -1;
631 if (
h->c.inter_intra_pred)
636 if (
level > 256 *
h->c.y_dc_scale) {
638 if (!
h->c.inter_intra_pred)
643 if (
level > 256 *
h->c.c_dc_scale) {
645 if (!
h->c.inter_intra_pred)
651 run_diff =
h->c.msmpeg4_version >= MSMP4_WMV1;
657 if (dc_pred_dir == 0)
658 scan_table =
h->permutated_intra_v_scantable;
660 scan_table =
h->permutated_intra_h_scantable;
662 scan_table =
h->c.intra_scantable.permutated;
666 qmul =
h->c.qscale << 1;
667 qadd = (
h->c.qscale - 1) | 1;
671 if (
h->c.msmpeg4_version == MSMP4_V2)
677 h->c.block_last_index[n] =
i;
681 scan_table =
h->c.inter_scantable.permutated;
693 if (
h->c.msmpeg4_version == MSMP4_V1 || (cache&0x80000000)==0) {
694 if (
h->c.msmpeg4_version == MSMP4_V1 || (cache&0x40000000)==0) {
696 if (
h->c.msmpeg4_version != MSMP4_V1)
699 if (
h->c.msmpeg4_version <= MSMP4_V3) {
709 ff_dlog(
h->c.avctx,
"ESC-3 %X at %d %d\n",
711 if (
h->c.qscale < 8) {
771 if (((
i + 192 == 64 &&
level / qmul == -1) ||
775 h->c.mb_x,
h->c.mb_y);
780 h->c.mb_x,
h->c.mb_y);
797 h->c.block_last_index[n] =
i;
848 h->c.dct_unquantize_inter =
NULL;
853 h->permutated_intra_v_scantable);
855 switch (
h->c.msmpeg4_version) {
867 av_unreachable(
"List contains all cases using ff_msmpeg4_decode_init()");
870 h->slice_height =
h->c.mb_height;
878 .p.name =
"msmpeg4v1",
893 .p.name =
"msmpeg4v2",
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
static double val(void *priv, double ch)
const FFCodec ff_wmv1_decoder
const FFCodec ff_msmpeg4v2_decoder
const FFCodec ff_msmpeg4v1_decoder
const FFCodec ff_msmpeg4v3_decoder
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
Libavcodec external API header.
#define FF_DEBUG_PICT_INFO
static int BS_FUNC decode012(BSCTX *bc)
Return decoded truncated unary code for the values 0, 1, 2.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
#define i(width, name, range_min, range_max)
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define AV_EF_BITSTREAM
detect bitstream specification deviations
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
int(* init)(AVBSFContext *ctx)
static struct @346255127015250356166251341105367306144006377143 state
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
#define GET_CACHE(name, gb)
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
#define SKIP_CACHE(name, gb, num)
#define CLOSE_READER(name, gb)
static int get_bits_left(GetBitContext *gb)
#define SHOW_UBITS(name, gb, num)
static unsigned int get_bits1(GetBitContext *s)
#define SHOW_SBITS(name, gb, num)
#define OPEN_READER(name, gb)
static void skip_bits(GetBitContext *s, int n)
#define SKIP_BITS(name, gb, num)
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
#define UPDATE_CACHE(name, gb)
#define LAST_SKIP_BITS(name, gb, num)
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define SKIP_COUNTER(name, gb, num)
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
#define AV_CODEC_CAP_DRAW_HORIZ_BAND
Decoder can use draw_horiz_band callback.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_P
Predicted.
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
VLCElem ff_h263_inter_MCBPC_vlc[]
VLCElem ff_h263_cbpy_vlc[]
#define INTRA_MCBPC_VLC_BITS
VLCElem ff_h263_intra_MCBPC_vlc[]
#define INTER_MCBPC_VLC_BITS
static int shift(int a, int b)
av_cold int ff_h263_decode_init(AVCodecContext *avctx)
int ff_h263_decode_frame(AVCodecContext *avctx, AVFrame *pict, int *got_frame, AVPacket *avpkt)
static int ff_thread_once(char *control, void(*routine)(void))
static const VLCElem * rl_vlc[2]
static const VLCElem * mv_vlc[2][16]
void ff_mpeg4_pred_ac(H263DecContext *const h, int16_t *block, int n, int dir)
Predict the ac.
#define MB_TYPE_FORWARD_MV
#define MV_TYPE_16X16
1 vector for the whole mb
av_cold int ff_mpv_decode_close(AVCodecContext *avctx)
mpegvideo decoder header.
int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr)
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
av_cold void ff_msmpeg4_common_init(MPVContext *const s, uint8_t permutated_intra_h_scantable[64], uint8_t permutated_intra_v_scantable[64])
av_cold void ff_msmp4_vc1_vlcs_init_once(void)
VLCElem ff_msmp4_mb_i_vlc[536]
const VLCElem * ff_msmp4_dc_vlc[2][2]
#define MSMP4_DC_VLC_BITS
#define MSMP4_MB_INTRA_VLC_BITS
const uint16_t ff_msmp4_mv_table0[MSMPEG4_MV_TABLES_NB_ELEMS]
The entries are of the form (8 << mvx) | mvy. Escape value is zero.
uint32_t ff_v2_dc_chroma_table[512][2]
const uint8_t ff_msmp4_mv_table0_lens[MSMPEG4_MV_TABLES_NB_ELEMS]
const uint16_t ff_msmp4_mv_table1[MSMPEG4_MV_TABLES_NB_ELEMS]
uint32_t ff_v2_dc_lum_table[512][2]
RLTable ff_rl_table[NB_RL_TABLES]
const uint8_t ff_v2_mb_type[8][2]
const uint8_t ff_table_inter_intra[4][2]
const uint32_t(*const [WMV2_INTER_CBP_TABLE_COUNT] ff_wmv2_inter_table)[2]
const uint8_t ff_msmp4_mv_table1_lens[MSMPEG4_MV_TABLES_NB_ELEMS]
const uint8_t ff_v2_intra_cbpc[4][2]
#define MSMPEG4_MV_TABLES_NB_ELEMS
static av_cold void msmpeg4_decode_init_static(void)
static int msmpeg4v34_decode_mb(H263DecContext *const h)
av_cold int ff_msmpeg4_decode_init(AVCodecContext *avctx)
static VLCElem v2_dc_chroma_vlc[1506]
static const VLCElem * mv_tables[2]
static int msmpeg4v1_pred_dc(H263DecContext *const h, int n, int32_t **dc_val_ptr)
int ff_msmpeg4_decode_block(MSMP4DecContext *const ms, int16_t *block, int n, int coded, const uint8_t *scan_table)
static int msmpeg4_decode_picture_header(H263DecContext *const h)
#define DEFAULT_INTER_INDEX
static VLCElem v2_mb_type_vlc[128]
static VLCElem v2_dc_lum_vlc[1472]
#define V2_INTRA_CBPC_VLC_BITS
VLCElem ff_inter_intra_vlc[8]
void ff_msmpeg4_decode_motion(MSMP4DecContext *const ms, int *mx_ptr, int *my_ptr)
int ff_msmpeg4_decode_ext_header(H263DecContext *const h, int buf_size)
static int msmpeg4v12_decode_mb(H263DecContext *const h)
#define V2_MB_TYPE_VLC_BITS
static VLCElem v2_intra_cbpc_vlc[8]
static int msmpeg4_decode_dc(MSMP4DecContext *const ms, int n, int *dir_ptr)
const VLCElem * ff_mb_non_intra_vlc[4]
static int msmpeg4v2_decode_motion(H263DecContext *const h, int pred, int f_code)
#define INTER_INTRA_VLC_BITS
#define MB_NON_INTRA_VLC_BITS
static MSMP4DecContext * mpv_to_msmpeg4(H263DecContext *const h)
#define VLC_INIT_RL(rl, static_size)
#define INIT_FIRST_VLC_RL(rl, static_size)
static const float pred[4]
main external API structure.
int width
picture width / height.
int rl_chroma_table_index
int8_t * max_run[2]
encoding & decoding
RL_VLC_ELEM * rl_vlc[32]
decoding only
int8_t * max_level[2]
encoding & decoding
For static VLCs, the number of bits can often be hardcoded at each get_vlc2() callsite.
av_cold const VLCElem * ff_vlc_init_tables_from_lengths(VLCInitState *state, int nb_bits, int nb_codes, const int8_t *lens, int lens_wrap, const void *symbols, int symbols_wrap, int symbols_size, int offset, int flags)
av_cold const VLCElem * ff_vlc_init_tables_sparse(VLCInitState *state, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags)
#define VLC_INIT_STATIC_TABLE(vlc_table, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
#define VLC_INIT_STATE(_table)