* H.261 encoder.
*/
+#include "libavutil/attributes.h"
#include "avcodec.h"
+#include "mpegutils.h"
#include "mpegvideo.h"
#include "h263.h"
#include "h261.h"
-#include "h261data.h"
int ff_h261_get_picture_format(int width, int height)
{
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;
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);
}
}
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];
}
/* 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) {
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);
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 */
}
}
-void ff_h261_encode_init(MpegEncContext *s)
+av_cold void ff_h261_encode_init(MpegEncContext *s)
{
- static int done = 0;
-
- if (!done) {
- done = 1;
- ff_init_rl(&h261_rl_tcoeff, ff_h261_rl_table_store);
- }
+ ff_h261_common_init();
s->min_qcoeff = -127;
s->max_qcoeff = 127;
AVCodec ff_h261_encoder = {
.name = "h261",
+ .long_name = NULL_IF_CONFIG_SMALL("H.261"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_H261,
.priv_data_size = sizeof(H261Context),
- .init = ff_MPV_encode_init,
- .encode2 = ff_MPV_encode_picture,
- .close = ff_MPV_encode_end,
+ .init = ff_mpv_encode_init,
+ .encode2 = ff_mpv_encode_picture,
+ .close = ff_mpv_encode_end,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE },
- .long_name = NULL_IF_CONFIG_SMALL("H.261"),
.priv_class = &h261_class,
};