/*
- * MPEG4 encoder.
+ * MPEG-4 encoder
* Copyright (c) 2000,2001 Fabrice Bellard
* Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at>
*
#include "mpeg4video.h"
/* The uni_DCtab_* tables below contain unified bits+length tables to encode DC
- * differences in mpeg4. Unified in the sense that the specification specifies
+ * differences in MPEG-4. Unified in the sense that the specification specifies
* this encoding in several steps. */
static uint8_t uni_DCtab_lum_len[512];
static uint8_t uni_DCtab_chrom_len[512];
//#define UNI_MPEG4_ENC_INDEX(last, run, level) ((last) * 128 * 64 + (run) + (level) * 64)
#define UNI_MPEG4_ENC_INDEX(last, run, level) ((last) * 128 * 64 + (run) * 128 + (level))
-/* mpeg4
+/* MPEG-4
* inter
* max level: 24/6
* max run: 53/63
}
/**
- * Return the optimal value (0 or 1) for the ac_pred element for the given MB in mpeg4.
+ * Return the optimal value (0 or 1) for the ac_pred element for the given MB in MPEG-4.
* This function will also update s->block_last_index and s->ac_val.
* @param[in,out] block MB coefficients, these will be updated if 1 is returned
* @param[in] dir ac prediction direction for each 8x8 block
}
/**
- * modify mb_type & qscale so that encoding is acually possible in mpeg4
+ * modify mb_type & qscale so that encoding is actually possible in MPEG-4
*/
void ff_clean_mpeg4_qscales(MpegEncContext *s)
{
if (s->pict_type == AV_PICTURE_TYPE_B) {
int odd = 0;
/* ok, come on, this isn't funny anymore, there's more code for
- * handling this mpeg4 mess than for the actual adaptive quantization */
+ * handling this MPEG-4 mess than for the actual adaptive quantization */
for (i = 0; i < s->mb_num; i++) {
int mb_xy = s->mb_index2xy[i];
*/
static inline void mpeg4_encode_dc(PutBitContext *s, int level, int n)
{
-#if 1
/* DC will overflow if level is outside the [-255,255] range. */
level += 256;
if (n < 4) {
/* chrominance */
put_bits(s, uni_DCtab_chrom_len[level], uni_DCtab_chrom_bits[level]);
}
-#else
- int size, v;
- /* find number of bits */
- size = 0;
- v = abs(level);
- while (v) {
- v >>= 1;
- size++;
- }
-
- if (n < 4) {
- /* luminance */
- put_bits(&s->pb, ff_mpeg4_DCtab_lum[size][1], ff_mpeg4_DCtab_lum[size][0]);
- } else {
- /* chrominance */
- put_bits(&s->pb, ff_mpeg4_DCtab_chrom[size][1], ff_mpeg4_DCtab_chrom[size][0]);
- }
-
- /* encode remaining bits */
- if (size > 0) {
- if (level < 0)
- level = (-level) ^ ((1 << size) - 1);
- put_bits(&s->pb, size, level);
- if (size > 8)
- put_bits(&s->pb, 1, 1);
- }
-#endif
}
static inline int mpeg4_get_dc_length(int level, int n)
const int last_index = s->block_last_index[n];
if (s->mb_intra) { // Note gcc (3.2.1 at least) will optimize this away
- /* mpeg4 based DC predictor */
+ /* MPEG-4 based DC predictor */
mpeg4_encode_dc(dc_pb, intra_dc, n);
if (last_index < 1)
return;
int len = 0;
if (s->mb_intra) { // Note gcc (3.2.1 at least) will optimize this away
- /* mpeg4 based DC predictor */
+ /* MPEG-4 based DC predictor */
len += mpeg4_get_dc_length(intra_dc, n);
if (last_index < 1)
return len;
assert((s->dquant & 1) == 0);
assert(mb_type >= 0);
- /* nothing to do if this MB was skipped in the next P Frame */
+ /* nothing to do if this MB was skipped in the next P-frame */
if (s->next_picture.mbskip_table[s->mb_y * s->mb_stride + s->mb_x]) { // FIXME avoid DCT & ...
s->skip_count++;
s->mv[0][0][0] =
if ((cbp | motion_x | motion_y | s->dquant) == 0 &&
s->mv_type == MV_TYPE_16X16) {
- /* check if the B frames can skip it too, as we must skip it
+ /* Check if the B-frames can skip it too, as we must skip it
* if we skip here why didn't they just compress
* the skip-mb bits instead of reusing them ?! */
if (s->max_b_frames > 0) {
}
/**
- * add mpeg4 stuffing bits (01...1)
+ * add MPEG-4 stuffing bits (01...1)
*/
void ff_mpeg4_stuffing(PutBitContext *pbc)
{
put_bits(&s->pb, 2, 0); /* sprite enable */
put_bits(&s->pb, 1, 0); /* not 8 bit == false */
- put_bits(&s->pb, 1, s->mpeg_quant); /* quant type= (0=h263 style)*/
+ put_bits(&s->pb, 1, s->mpeg_quant); /* quant type = (0 = H.263 style) */
if (s->mpeg_quant) {
ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);
}
}
-/* write mpeg4 VOP header */
+/* write MPEG-4 VOP header */
void ff_mpeg4_encode_picture_header(MpegEncContext *s, int picture_number)
{
int time_incr;
.encode2 = ff_mpv_encode_picture,
.close = ff_mpv_encode_end,
.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE },
- .capabilities = CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
+ .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS,
.priv_class = &mpeg4enc_class,
};