Commit 01095123 authored by Andreas Rheinhardt's avatar Andreas Rheinhardt

avcodec/mpeg12dec: Use VLC symbol table

Possible by using MB_TYPE_CODEC_SPECIFIC for MB_TYPE_ZERO_MV
and due to the MB_TYPE_*_MV flags fitting into an int16_t.
Signed-off-by: 's avatarAndreas Rheinhardt <andreas.rheinhardt@outlook.com>
parent e7d6300c
......@@ -31,14 +31,12 @@
#include "libavutil/avassert.h"
#include "libavutil/thread.h"
#include "avcodec.h"
#include "mpegvideo.h"
#include "mpeg12.h"
#include "mpeg12codecs.h"
#include "mpeg12data.h"
#include "mpeg12dec.h"
#include "mpegutils.h"
#include "rl.h"
#include "startcode.h"
static const uint8_t table_mb_ptype[7][2] = {
{ 3, 5 }, // 0x01 MB_INTRA
......@@ -64,6 +62,30 @@ static const uint8_t table_mb_btype[11][2] = {
{ 2, 5 }, // 0x1E MB_QUANT|MB_FOR|MB_BACK|MB_PAT
};
static const int16_t ptype2mb_type[7] = {
MB_TYPE_INTRA,
MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
MB_TYPE_FORWARD_MV,
MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
MB_TYPE_QUANT | MB_TYPE_INTRA,
MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
};
static const int16_t btype2mb_type[11] = {
MB_TYPE_INTRA,
MB_TYPE_BACKWARD_MV,
MB_TYPE_BACKWARD_MV | MB_TYPE_CBP,
MB_TYPE_FORWARD_MV,
MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
MB_TYPE_BIDIR_MV,
MB_TYPE_BIDIR_MV | MB_TYPE_CBP,
MB_TYPE_QUANT | MB_TYPE_INTRA,
MB_TYPE_QUANT | MB_TYPE_BACKWARD_MV | MB_TYPE_CBP,
MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
MB_TYPE_QUANT | MB_TYPE_BIDIR_MV | MB_TYPE_CBP,
};
av_cold void ff_init_2d_vlc_rl(const uint16_t table_vlc[][2], RL_VLC_ELEM rl_vlc[],
const int8_t table_run[], const uint8_t table_level[],
int n, unsigned static_size, int flags)
......@@ -146,12 +168,14 @@ static av_cold void mpeg12_init_vlcs(void)
&ff_mpeg12_mbPatTable[0][1], 2, 1,
&ff_mpeg12_mbPatTable[0][0], 2, 1, 0);
VLC_INIT_STATIC_TABLE(ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
&table_mb_ptype[0][1], 2, 1,
&table_mb_ptype[0][0], 2, 1, 0);
VLC_INIT_STATIC_TABLE(ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
&table_mb_btype[0][1], 2, 1,
&table_mb_btype[0][0], 2, 1, 0);
VLC_INIT_STATIC_SPARSE_TABLE(ff_mb_ptype_vlc, MB_PTYPE_VLC_BITS, 7,
&table_mb_ptype[0][1], 2, 1,
&table_mb_ptype[0][0], 2, 1,
ptype2mb_type, 2, 2, 0);
VLC_INIT_STATIC_SPARSE_TABLE(ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 11,
&table_mb_btype[0][1], 2, 1,
&table_mb_btype[0][0], 2, 1,
btype2mb_type, 2, 2, 0);
ff_init_2d_vlc_rl(ff_mpeg1_vlc_table, ff_mpeg1_rl_vlc, ff_mpeg12_run,
ff_mpeg12_level, MPEG12_RL_NB_ELEMS,
......
......@@ -93,32 +93,6 @@ typedef struct Mpeg1Context {
int64_t timecode_frame_start; /*< GOP timecode frame start number, in non drop frame format */
} Mpeg1Context;
#define MB_TYPE_ZERO_MV 0x20000000
static const uint32_t ptype2mb_type[7] = {
MB_TYPE_INTRA,
MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
MB_TYPE_FORWARD_MV,
MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
MB_TYPE_QUANT | MB_TYPE_INTRA,
MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP | MB_TYPE_ZERO_MV | MB_TYPE_16x16,
MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
};
static const uint32_t btype2mb_type[11] = {
MB_TYPE_INTRA,
MB_TYPE_BACKWARD_MV,
MB_TYPE_BACKWARD_MV | MB_TYPE_CBP,
MB_TYPE_FORWARD_MV,
MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
MB_TYPE_BIDIR_MV,
MB_TYPE_BIDIR_MV | MB_TYPE_CBP,
MB_TYPE_QUANT | MB_TYPE_INTRA,
MB_TYPE_QUANT | MB_TYPE_BACKWARD_MV | MB_TYPE_CBP,
MB_TYPE_QUANT | MB_TYPE_FORWARD_MV | MB_TYPE_CBP,
MB_TYPE_QUANT | MB_TYPE_BIDIR_MV | MB_TYPE_CBP,
};
/* as H.263, but only 17 codes */
static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred)
{
......@@ -483,7 +457,6 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
"Invalid mb type in P-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = ptype2mb_type[mb_type];
break;
case AV_PICTURE_TYPE_B:
mb_type = get_vlc2(&s->gb, ff_mb_btype_vlc, MB_BTYPE_VLC_BITS, 1);
......@@ -492,7 +465,6 @@ static int mpeg_decode_mb(MpegEncContext *s, int16_t block[12][64])
"Invalid mb type in B-frame at %d %d\n", s->mb_x, s->mb_y);
return AVERROR_INVALIDDATA;
}
mb_type = btype2mb_type[mb_type];
break;
}
ff_tlog(s->avctx, "mb_type=%x\n", mb_type);
......
......@@ -25,6 +25,8 @@
#include "get_bits.h"
#include "mpeg12vlc.h"
#define MB_TYPE_ZERO_MV MB_TYPE_CODEC_SPECIFIC
static inline int decode_dc(GetBitContext *gb, int component)
{
int code, diff;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment