h261: Move shared data tables from a header to a proper C file
This commit is contained in:
parent
b93b27edb0
commit
8a776ad90e
@ -180,8 +180,8 @@ OBJS-$(CONFIG_GIF_DECODER) += gifdec.o lzw.o
|
|||||||
OBJS-$(CONFIG_GIF_ENCODER) += gif.o lzwenc.o
|
OBJS-$(CONFIG_GIF_ENCODER) += gif.o lzwenc.o
|
||||||
OBJS-$(CONFIG_GSM_DECODER) += gsmdec.o gsmdec_data.o msgsmdec.o
|
OBJS-$(CONFIG_GSM_DECODER) += gsmdec.o gsmdec_data.o msgsmdec.o
|
||||||
OBJS-$(CONFIG_GSM_MS_DECODER) += gsmdec.o gsmdec_data.o msgsmdec.o
|
OBJS-$(CONFIG_GSM_MS_DECODER) += gsmdec.o gsmdec_data.o msgsmdec.o
|
||||||
OBJS-$(CONFIG_H261_DECODER) += h261dec.o h261.o
|
OBJS-$(CONFIG_H261_DECODER) += h261dec.o h261data.o h261.o
|
||||||
OBJS-$(CONFIG_H261_ENCODER) += h261enc.o h261.o
|
OBJS-$(CONFIG_H261_ENCODER) += h261enc.o h261data.o h261.o
|
||||||
OBJS-$(CONFIG_H263_DECODER) += h263dec.o h263.o ituh263dec.o \
|
OBJS-$(CONFIG_H263_DECODER) += h263dec.o h263.o ituh263dec.o \
|
||||||
mpeg4video.o mpeg4videodec.o flvdec.o\
|
mpeg4video.o mpeg4videodec.o flvdec.o\
|
||||||
intelh263dec.o
|
intelh263dec.o
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#define AVCODEC_H261_H
|
#define AVCODEC_H261_H
|
||||||
|
|
||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
|
#include "rl.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* H261Context
|
* H261Context
|
||||||
@ -50,6 +51,15 @@ typedef struct H261Context {
|
|||||||
|
|
||||||
extern uint8_t ff_h261_rl_table_store[2][2 * MAX_RUN + MAX_LEVEL + 3];
|
extern uint8_t ff_h261_rl_table_store[2][2 * MAX_RUN + MAX_LEVEL + 3];
|
||||||
|
|
||||||
|
extern const uint8_t ff_h261_mba_code[35];
|
||||||
|
extern const uint8_t ff_h261_mba_bits[35];
|
||||||
|
extern const uint8_t ff_h261_mtype_code[10];
|
||||||
|
extern const uint8_t ff_h261_mtype_bits[10];
|
||||||
|
extern const int ff_h261_mtype_map[10];
|
||||||
|
extern const uint8_t ff_h261_mv_tab[17][2];
|
||||||
|
extern const uint8_t ff_h261_cbp_tab[63][2];
|
||||||
|
extern RLTable ff_h261_rl_tcoeff;
|
||||||
|
|
||||||
void ff_h261_loop_filter(MpegEncContext *s);
|
void ff_h261_loop_filter(MpegEncContext *s);
|
||||||
|
|
||||||
int ff_h261_get_picture_format(int width, int height);
|
int ff_h261_get_picture_format(int width, int height);
|
||||||
|
@ -24,15 +24,13 @@
|
|||||||
* H.261 tables.
|
* H.261 tables.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef AVCODEC_H261DATA_H
|
|
||||||
#define AVCODEC_H261DATA_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "rl.h"
|
||||||
#include "h261.h"
|
#include "h261.h"
|
||||||
|
|
||||||
// H.261 VLC table for macroblock addressing
|
// H.261 VLC table for macroblock addressing
|
||||||
static const uint8_t h261_mba_code[35] = {
|
const uint8_t ff_h261_mba_code[35] = {
|
||||||
1, 3, 2, 3,
|
1, 3, 2, 3,
|
||||||
2, 3, 2, 7,
|
2, 3, 2, 7,
|
||||||
6, 11, 10, 9,
|
6, 11, 10, 9,
|
||||||
@ -46,7 +44,7 @@ static const uint8_t h261_mba_code[35] = {
|
|||||||
1 // (start code)
|
1 // (start code)
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t h261_mba_bits[35] = {
|
const uint8_t ff_h261_mba_bits[35] = {
|
||||||
1, 3, 3, 4,
|
1, 3, 3, 4,
|
||||||
4, 5, 5, 7,
|
4, 5, 5, 7,
|
||||||
7, 8, 8, 8,
|
7, 8, 8, 8,
|
||||||
@ -61,19 +59,19 @@ static const uint8_t h261_mba_bits[35] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// H.261 VLC table for macroblock type
|
// H.261 VLC table for macroblock type
|
||||||
static const uint8_t h261_mtype_code[10] = {
|
const uint8_t ff_h261_mtype_code[10] = {
|
||||||
1, 1, 1, 1,
|
1, 1, 1, 1,
|
||||||
1, 1, 1, 1,
|
1, 1, 1, 1,
|
||||||
1, 1
|
1, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t h261_mtype_bits[10] = {
|
const uint8_t ff_h261_mtype_bits[10] = {
|
||||||
4, 7, 1, 5,
|
4, 7, 1, 5,
|
||||||
9, 8, 10, 3,
|
9, 8, 10, 3,
|
||||||
2, 6
|
2, 6
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int h261_mtype_map[10] = {
|
const int ff_h261_mtype_map[10] = {
|
||||||
MB_TYPE_INTRA4x4,
|
MB_TYPE_INTRA4x4,
|
||||||
MB_TYPE_INTRA4x4 | MB_TYPE_QUANT,
|
MB_TYPE_INTRA4x4 | MB_TYPE_QUANT,
|
||||||
MB_TYPE_CBP,
|
MB_TYPE_CBP,
|
||||||
@ -87,13 +85,13 @@ static const int h261_mtype_map[10] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// H.261 VLC table for motion vectors
|
// H.261 VLC table for motion vectors
|
||||||
static const uint8_t h261_mv_tab[17][2] = {
|
const uint8_t ff_h261_mv_tab[17][2] = {
|
||||||
{ 1, 1 }, { 1, 2 }, { 1, 3 }, { 1, 4 }, { 3, 6 }, { 5, 7 }, { 4, 7 }, { 3, 7 },
|
{ 1, 1 }, { 1, 2 }, { 1, 3 }, { 1, 4 }, { 3, 6 }, { 5, 7 }, { 4, 7 }, { 3, 7 },
|
||||||
{ 11, 9 }, { 10, 9 }, { 9, 9 }, { 17, 10 }, { 16, 10 }, { 15, 10 }, { 14, 10 }, { 13, 10 }, { 12, 10 }
|
{ 11, 9 }, { 10, 9 }, { 9, 9 }, { 17, 10 }, { 16, 10 }, { 15, 10 }, { 14, 10 }, { 13, 10 }, { 12, 10 }
|
||||||
};
|
};
|
||||||
|
|
||||||
// H.261 VLC table for coded block pattern
|
// H.261 VLC table for coded block pattern
|
||||||
static const uint8_t h261_cbp_tab[63][2] = {
|
const uint8_t ff_h261_cbp_tab[63][2] = {
|
||||||
{ 11, 5 }, { 9, 5 }, { 13, 6 }, { 13, 4 }, { 23, 7 }, { 19, 7 }, { 31, 8 }, { 12, 4 },
|
{ 11, 5 }, { 9, 5 }, { 13, 6 }, { 13, 4 }, { 23, 7 }, { 19, 7 }, { 31, 8 }, { 12, 4 },
|
||||||
{ 22, 7 }, { 18, 7 }, { 30, 8 }, { 19, 5 }, { 27, 8 }, { 23, 8 }, { 19, 8 }, { 11, 4 },
|
{ 22, 7 }, { 18, 7 }, { 30, 8 }, { 19, 5 }, { 27, 8 }, { 23, 8 }, { 19, 8 }, { 11, 4 },
|
||||||
{ 21, 7 }, { 17, 7 }, { 29, 8 }, { 17, 5 }, { 25, 8 }, { 21, 8 }, { 17, 8 }, { 15, 6 },
|
{ 21, 7 }, { 17, 7 }, { 29, 8 }, { 17, 5 }, { 25, 8 }, { 21, 8 }, { 17, 8 }, { 15, 6 },
|
||||||
@ -148,12 +146,10 @@ static const int8_t h261_tcoeff_run[64] = {
|
|||||||
20, 21, 22, 23, 24, 25, 26
|
20, 21, 22, 23, 24, 25, 26
|
||||||
};
|
};
|
||||||
|
|
||||||
static RLTable h261_rl_tcoeff = {
|
RLTable ff_h261_rl_tcoeff = {
|
||||||
64,
|
64,
|
||||||
64,
|
64,
|
||||||
h261_tcoeff_vlc,
|
h261_tcoeff_vlc,
|
||||||
h261_tcoeff_run,
|
h261_tcoeff_run,
|
||||||
h261_tcoeff_level,
|
h261_tcoeff_level,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* AVCODEC_H261DATA_H */
|
|
@ -29,7 +29,6 @@
|
|||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
#include "h263.h"
|
#include "h263.h"
|
||||||
#include "h261.h"
|
#include "h261.h"
|
||||||
#include "h261data.h"
|
|
||||||
|
|
||||||
#define H261_MBA_VLC_BITS 9
|
#define H261_MBA_VLC_BITS 9
|
||||||
#define H261_MTYPE_VLC_BITS 6
|
#define H261_MTYPE_VLC_BITS 6
|
||||||
@ -51,19 +50,19 @@ static av_cold void h261_decode_init_vlc(H261Context *h)
|
|||||||
if (!done) {
|
if (!done) {
|
||||||
done = 1;
|
done = 1;
|
||||||
INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35,
|
INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35,
|
||||||
h261_mba_bits, 1, 1,
|
ff_h261_mba_bits, 1, 1,
|
||||||
h261_mba_code, 1, 1, 662);
|
ff_h261_mba_code, 1, 1, 662);
|
||||||
INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
|
INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
|
||||||
h261_mtype_bits, 1, 1,
|
ff_h261_mtype_bits, 1, 1,
|
||||||
h261_mtype_code, 1, 1, 80);
|
ff_h261_mtype_code, 1, 1, 80);
|
||||||
INIT_VLC_STATIC(&h261_mv_vlc, H261_MV_VLC_BITS, 17,
|
INIT_VLC_STATIC(&h261_mv_vlc, H261_MV_VLC_BITS, 17,
|
||||||
&h261_mv_tab[0][1], 2, 1,
|
&ff_h261_mv_tab[0][1], 2, 1,
|
||||||
&h261_mv_tab[0][0], 2, 1, 144);
|
&ff_h261_mv_tab[0][0], 2, 1, 144);
|
||||||
INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
|
INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
|
||||||
&h261_cbp_tab[0][1], 2, 1,
|
&ff_h261_cbp_tab[0][1], 2, 1,
|
||||||
&h261_cbp_tab[0][0], 2, 1, 512);
|
&ff_h261_cbp_tab[0][0], 2, 1, 512);
|
||||||
ff_init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store);
|
ff_init_rl(&ff_h261_rl_tcoeff, ff_h261_rl_table_store);
|
||||||
INIT_VLC_RL(h261_rl_tcoeff, 552);
|
INIT_VLC_RL(ff_h261_rl_tcoeff, 552);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +255,7 @@ static int h261_decode_block(H261Context *h, int16_t *block, int n, int coded)
|
|||||||
{
|
{
|
||||||
MpegEncContext *const s = &h->s;
|
MpegEncContext *const s = &h->s;
|
||||||
int code, level, i, j, run;
|
int code, level, i, j, run;
|
||||||
RLTable *rl = &h261_rl_tcoeff;
|
RLTable *rl = &ff_h261_rl_tcoeff;
|
||||||
const uint8_t *scan_table;
|
const uint8_t *scan_table;
|
||||||
|
|
||||||
/* For the variable length encoding there are two code tables, one being
|
/* For the variable length encoding there are two code tables, one being
|
||||||
@ -377,7 +376,7 @@ static int h261_decode_mb(H261Context *h)
|
|||||||
|
|
||||||
// Read mtype
|
// Read mtype
|
||||||
h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
|
h->mtype = get_vlc2(&s->gb, h261_mtype_vlc.table, H261_MTYPE_VLC_BITS, 2);
|
||||||
h->mtype = h261_mtype_map[h->mtype];
|
h->mtype = ff_h261_mtype_map[h->mtype];
|
||||||
|
|
||||||
// Read mquant
|
// Read mquant
|
||||||
if (IS_QUANT(h->mtype))
|
if (IS_QUANT(h->mtype))
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
#include "h263.h"
|
#include "h263.h"
|
||||||
#include "h261.h"
|
#include "h261.h"
|
||||||
#include "h261data.h"
|
|
||||||
|
|
||||||
int ff_h261_get_picture_format(int width, int height)
|
int ff_h261_get_picture_format(int width, int height)
|
||||||
{
|
{
|
||||||
@ -129,7 +128,7 @@ static void h261_encode_motion(H261Context *h, int val)
|
|||||||
int sign, code;
|
int sign, code;
|
||||||
if (val == 0) {
|
if (val == 0) {
|
||||||
code = 0;
|
code = 0;
|
||||||
put_bits(&s->pb, h261_mv_tab[code][1], h261_mv_tab[code][0]);
|
put_bits(&s->pb, ff_h261_mv_tab[code][1], ff_h261_mv_tab[code][0]);
|
||||||
} else {
|
} else {
|
||||||
if (val > 15)
|
if (val > 15)
|
||||||
val -= 32;
|
val -= 32;
|
||||||
@ -137,7 +136,7 @@ static void h261_encode_motion(H261Context *h, int val)
|
|||||||
val += 32;
|
val += 32;
|
||||||
sign = val < 0;
|
sign = val < 0;
|
||||||
code = sign ? -val : val;
|
code = sign ? -val : val;
|
||||||
put_bits(&s->pb, h261_mv_tab[code][1], h261_mv_tab[code][0]);
|
put_bits(&s->pb, ff_h261_mv_tab[code][1], ff_h261_mv_tab[code][0]);
|
||||||
put_bits(&s->pb, 1, sign);
|
put_bits(&s->pb, 1, sign);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,7 +162,7 @@ static void h261_encode_block(H261Context *h, int16_t *block, int n)
|
|||||||
int level, run, i, j, last_index, last_non_zero, sign, slevel, code;
|
int level, run, i, j, last_index, last_non_zero, sign, slevel, code;
|
||||||
RLTable *rl;
|
RLTable *rl;
|
||||||
|
|
||||||
rl = &h261_rl_tcoeff;
|
rl = &ff_h261_rl_tcoeff;
|
||||||
if (s->mb_intra) {
|
if (s->mb_intra) {
|
||||||
/* DC coef */
|
/* DC coef */
|
||||||
level = block[0];
|
level = block[0];
|
||||||
@ -253,8 +252,9 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* MB is not skipped, encode MBA */
|
/* MB is not skipped, encode MBA */
|
||||||
put_bits(&s->pb, h261_mba_bits[(h->current_mba - h->previous_mba) - 1],
|
put_bits(&s->pb,
|
||||||
h261_mba_code[(h->current_mba - h->previous_mba) - 1]);
|
ff_h261_mba_bits[(h->current_mba - h->previous_mba) - 1],
|
||||||
|
ff_h261_mba_code[(h->current_mba - h->previous_mba) - 1]);
|
||||||
|
|
||||||
/* calculate MTYPE */
|
/* calculate MTYPE */
|
||||||
if (!s->mb_intra) {
|
if (!s->mb_intra) {
|
||||||
@ -272,9 +272,11 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
|
|||||||
if (s->dquant)
|
if (s->dquant)
|
||||||
h->mtype++;
|
h->mtype++;
|
||||||
|
|
||||||
put_bits(&s->pb, h261_mtype_bits[h->mtype], h261_mtype_code[h->mtype]);
|
put_bits(&s->pb,
|
||||||
|
ff_h261_mtype_bits[h->mtype],
|
||||||
|
ff_h261_mtype_code[h->mtype]);
|
||||||
|
|
||||||
h->mtype = h261_mtype_map[h->mtype];
|
h->mtype = ff_h261_mtype_map[h->mtype];
|
||||||
|
|
||||||
if (IS_QUANT(h->mtype)) {
|
if (IS_QUANT(h->mtype)) {
|
||||||
ff_set_qscale(s, s->qscale + s->dquant);
|
ff_set_qscale(s, s->qscale + s->dquant);
|
||||||
@ -294,7 +296,9 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
|
|||||||
|
|
||||||
if (HAS_CBP(h->mtype)) {
|
if (HAS_CBP(h->mtype)) {
|
||||||
assert(cbp > 0);
|
assert(cbp > 0);
|
||||||
put_bits(&s->pb, h261_cbp_tab[cbp - 1][1], h261_cbp_tab[cbp - 1][0]);
|
put_bits(&s->pb,
|
||||||
|
ff_h261_cbp_tab[cbp - 1][1],
|
||||||
|
ff_h261_cbp_tab[cbp - 1][0]);
|
||||||
}
|
}
|
||||||
for (i = 0; i < 6; i++)
|
for (i = 0; i < 6; i++)
|
||||||
/* encode each block */
|
/* encode each block */
|
||||||
@ -313,7 +317,7 @@ void ff_h261_encode_init(MpegEncContext *s)
|
|||||||
|
|
||||||
if (!done) {
|
if (!done) {
|
||||||
done = 1;
|
done = 1;
|
||||||
ff_init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store);
|
ff_init_rl(&ff_h261_rl_tcoeff, ff_h261_rl_table_store);
|
||||||
}
|
}
|
||||||
|
|
||||||
s->min_qcoeff = -127;
|
s->min_qcoeff = -127;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user