aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2013-04-04 14:56:01 +0200
committerDiego Biurrun <diego@biurrun.de>2013-04-10 13:32:04 +0200
commit8a776ad90e00ab2b98e8683ac6182d641a383c3a (patch)
tree4671a446d30fcc2dbd313b66cc928bdb4134be5f
parentb93b27edb0455287f49182fbf11b68e575f59225 (diff)
downloadffmpeg-8a776ad90e00ab2b98e8683ac6182d641a383c3a.tar.gz
h261: Move shared data tables from a header to a proper C file
-rw-r--r--libavcodec/Makefile4
-rw-r--r--libavcodec/h261.h10
-rw-r--r--libavcodec/h261data.c (renamed from libavcodec/h261data.h)22
-rw-r--r--libavcodec/h261dec.c25
-rw-r--r--libavcodec/h261enc.c24
5 files changed, 47 insertions, 38 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index e6379a515d..2e7487c749 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -180,8 +180,8 @@ OBJS-$(CONFIG_GIF_DECODER) += gifdec.o lzw.o
OBJS-$(CONFIG_GIF_ENCODER) += gif.o lzwenc.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_H261_DECODER) += h261dec.o h261.o
-OBJS-$(CONFIG_H261_ENCODER) += h261enc.o h261.o
+OBJS-$(CONFIG_H261_DECODER) += h261dec.o h261data.o h261.o
+OBJS-$(CONFIG_H261_ENCODER) += h261enc.o h261data.o h261.o
OBJS-$(CONFIG_H263_DECODER) += h263dec.o h263.o ituh263dec.o \
mpeg4video.o mpeg4videodec.o flvdec.o\
intelh263dec.o
diff --git a/libavcodec/h261.h b/libavcodec/h261.h
index df9cbe8ac0..a1a0a415bb 100644
--- a/libavcodec/h261.h
+++ b/libavcodec/h261.h
@@ -29,6 +29,7 @@
#define AVCODEC_H261_H
#include "mpegvideo.h"
+#include "rl.h"
/**
* H261Context
@@ -50,6 +51,15 @@ typedef struct H261Context {
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);
int ff_h261_get_picture_format(int width, int height);
diff --git a/libavcodec/h261data.h b/libavcodec/h261data.c
index eb5ee06b37..eb8e64a5ce 100644
--- a/libavcodec/h261data.h
+++ b/libavcodec/h261data.c
@@ -24,15 +24,13 @@
* H.261 tables.
*/
-#ifndef AVCODEC_H261DATA_H
-#define AVCODEC_H261DATA_H
-
#include <stdint.h>
+#include "rl.h"
#include "h261.h"
// 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,
2, 3, 2, 7,
6, 11, 10, 9,
@@ -46,7 +44,7 @@ static const uint8_t h261_mba_code[35] = {
1 // (start code)
};
-static const uint8_t h261_mba_bits[35] = {
+const uint8_t ff_h261_mba_bits[35] = {
1, 3, 3, 4,
4, 5, 5, 7,
7, 8, 8, 8,
@@ -61,19 +59,19 @@ static const uint8_t h261_mba_bits[35] = {
};
// 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
};
-static const uint8_t h261_mtype_bits[10] = {
+const uint8_t ff_h261_mtype_bits[10] = {
4, 7, 1, 5,
9, 8, 10, 3,
2, 6
};
-static const int h261_mtype_map[10] = {
+const int ff_h261_mtype_map[10] = {
MB_TYPE_INTRA4x4,
MB_TYPE_INTRA4x4 | MB_TYPE_QUANT,
MB_TYPE_CBP,
@@ -87,13 +85,13 @@ static const int h261_mtype_map[10] = {
};
// 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 },
{ 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
-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 },
{ 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 },
@@ -148,12 +146,10 @@ static const int8_t h261_tcoeff_run[64] = {
20, 21, 22, 23, 24, 25, 26
};
-static RLTable h261_rl_tcoeff = {
+RLTable ff_h261_rl_tcoeff = {
64,
64,
h261_tcoeff_vlc,
h261_tcoeff_run,
h261_tcoeff_level,
};
-
-#endif /* AVCODEC_H261DATA_H */
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
index b13d779a65..699f7cf8ef 100644
--- a/libavcodec/h261dec.c
+++ b/libavcodec/h261dec.c
@@ -29,7 +29,6 @@
#include "mpegvideo.h"
#include "h263.h"
#include "h261.h"
-#include "h261data.h"
#define H261_MBA_VLC_BITS 9
#define H261_MTYPE_VLC_BITS 6
@@ -51,19 +50,19 @@ static av_cold void h261_decode_init_vlc(H261Context *h)
if (!done) {
done = 1;
INIT_VLC_STATIC(&h261_mba_vlc, H261_MBA_VLC_BITS, 35,
- h261_mba_bits, 1, 1,
- h261_mba_code, 1, 1, 662);
+ ff_h261_mba_bits, 1, 1,
+ ff_h261_mba_code, 1, 1, 662);
INIT_VLC_STATIC(&h261_mtype_vlc, H261_MTYPE_VLC_BITS, 10,
- h261_mtype_bits, 1, 1,
- h261_mtype_code, 1, 1, 80);
+ ff_h261_mtype_bits, 1, 1,
+ ff_h261_mtype_code, 1, 1, 80);
INIT_VLC_STATIC(&h261_mv_vlc, H261_MV_VLC_BITS, 17,
- &h261_mv_tab[0][1], 2, 1,
- &h261_mv_tab[0][0], 2, 1, 144);
+ &ff_h261_mv_tab[0][1], 2, 1,
+ &ff_h261_mv_tab[0][0], 2, 1, 144);
INIT_VLC_STATIC(&h261_cbp_vlc, H261_CBP_VLC_BITS, 63,
- &h261_cbp_tab[0][1], 2, 1,
- &h261_cbp_tab[0][0], 2, 1, 512);
- ff_init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store);
- INIT_VLC_RL(h261_rl_tcoeff, 552);
+ &ff_h261_cbp_tab[0][1], 2, 1,
+ &ff_h261_cbp_tab[0][0], 2, 1, 512);
+ ff_init_rl(&ff_h261_rl_tcoeff, ff_h261_rl_table_store);
+ 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;
int code, level, i, j, run;
- RLTable *rl = &h261_rl_tcoeff;
+ RLTable *rl = &ff_h261_rl_tcoeff;
const uint8_t *scan_table;
/* 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
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
if (IS_QUANT(h->mtype))
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
index ccc1fd279c..c866776a57 100644
--- a/libavcodec/h261enc.c
+++ b/libavcodec/h261enc.c
@@ -29,7 +29,6 @@
#include "mpegvideo.h"
#include "h263.h"
#include "h261.h"
-#include "h261data.h"
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;
if (val == 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 {
if (val > 15)
val -= 32;
@@ -137,7 +136,7 @@ static void h261_encode_motion(H261Context *h, int val)
val += 32;
sign = val < 0;
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);
}
}
@@ -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;
RLTable *rl;
- rl = &h261_rl_tcoeff;
+ rl = &ff_h261_rl_tcoeff;
if (s->mb_intra) {
/* DC coef */
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 */
- put_bits(&s->pb, h261_mba_bits[(h->current_mba - h->previous_mba) - 1],
- h261_mba_code[(h->current_mba - h->previous_mba) - 1]);
+ put_bits(&s->pb,
+ ff_h261_mba_bits[(h->current_mba - h->previous_mba) - 1],
+ ff_h261_mba_code[(h->current_mba - h->previous_mba) - 1]);
/* calculate MTYPE */
if (!s->mb_intra) {
@@ -272,9 +272,11 @@ void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64],
if (s->dquant)
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)) {
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)) {
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++)
/* encode each block */
@@ -313,7 +317,7 @@ void ff_h261_encode_init(MpegEncContext *s)
if (!done) {
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;