40#define H261_MAX_RUN 26
41#define H261_MAX_LEVEL 15
42#define H261_ESC_LEN (6 + 6 + 8)
43#define MV_TAB_OFFSET 32
78 temp_ref =
s->picture_number * 30000LL *
s->c.avctx->time_base.num /
79 (1001LL *
s->c.avctx->time_base.den);
92 h->gob_number =
h->format - 1;
104 if (
h->format == H261_QCIF) {
114 s->c.last_mv[0][0][0] = 0;
115 s->c.last_mv[0][0][1] = 0;
121 int index =
s->c.mb_x +
s->c.mb_y *
s->c.mb_width;
123 if (
index % 11 == 0) {
126 s->c.last_mv[0][0][0] = 0;
127 s->c.last_mv[0][0][1] = 0;
132 if (
h->format == H261_CIF) {
137 s->c.mb_x += 11 * (
index % 2);
152static inline int get_cbp(
const int block_last_index[6])
156 for (
i = 0;
i < 6;
i++)
157 if (block_last_index[
i] >= 0)
170 int level,
run,
i, j, last_index, last_non_zero;
181 else if (
level < 1) {
190 }
else if ((
block[0] == 1 ||
block[0] == -1) &&
191 (
s->c.block_last_index[n] > -1)) {
200 last_index =
s->c.block_last_index[n];
201 last_non_zero =
i - 1;
202 for (;
i <= last_index;
i++) {
203 j =
s->c.intra_scantable.permutated[
i];
206 run =
i - last_non_zero - 1;
228 int motion_x,
int motion_y)
233 int mvd, mv_diff_x, mv_diff_y,
i, cbp;
239 if (!
s->c.mb_intra) {
241 cbp =
get_cbp(
s->c.block_last_index);
244 mvd = motion_x | motion_y;
246 if ((cbp | mvd) == 0) {
249 s->c.last_mv[0][0][0] = 0;
250 s->c.last_mv[0][0][1] = 0;
251 s->c.qscale -=
s->dquant;
263 if (!
s->c.mb_intra) {
266 if (mvd ||
s->loop_filter)
275 if (
s->dquant && cbp) {
278 s->c.qscale -=
s->dquant;
292 mv_diff_x = (motion_x >> 1) -
s->c.last_mv[0][0][0];
293 mv_diff_y = (motion_y >> 1) -
s->c.last_mv[0][0][1];
294 s->c.last_mv[0][0][0] = (motion_x >> 1);
295 s->c.last_mv[0][0][1] = (motion_y >> 1);
306 for (
i = 0;
i < 6;
i++)
311 s->c.last_mv[0][0][0] = 0;
312 s->c.last_mv[0][0][1] = 0;
338 for (ptrdiff_t
i = 1;;
i++) {
360 h->format = H261_QCIF;
361 }
else if (avctx->
width == 352 && avctx->
height == 288) {
362 h->format = H261_CIF;
365 "The specified picture size of %dx%d is not valid for the "
366 "H.261 codec.\nValid sizes are 176x144, 352x288\n",
373 s->min_qcoeff = -127;
static double val(void *priv, double ch)
static const char *const format[]
const FFCodec ff_h261_encoder
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_PICTURE_TYPE_I
Intra.
const uint16_t ff_h261_mtype_map[10]
const uint8_t ff_h261_mv_tab[17][2]
const uint8_t ff_h261_mtype_bits[10]
const uint8_t ff_h261_mtype_code[10]
const int8_t ff_h261_tcoeff_run[64]
const int8_t ff_h261_tcoeff_level[64]
const uint8_t ff_h261_mba_code[35]
const uint8_t ff_h261_cbp_tab[63][2]
const uint16_t ff_h261_tcoeff_vlc[65][2]
const uint8_t ff_h261_mba_bits[35]
static av_cold void h261_encode_init_static(void)
static int h261_encode_picture_header(MPVMainEncContext *const m)
static uint8_t mv_penalty[MAX_FCODE+1][MAX_DMV *2+1]
static void h261_encode_mb(MPVEncContext *const s, int16_t block[6][64], int motion_x, int motion_y)
static void h261_encode_block(H261EncContext *h, int16_t *block, int n)
Encode an 8x8 block.
static uint8_t h261_mv_codes[64][2]
static struct VLCLUT vlc_lut[H261_MAX_RUN+1][32/*0..2 *H261_MAX_LEN are used */]
static void h261_encode_motion(PutBitContext *pb, int val)
static int get_cbp(const int block_last_index[6])
static uint8_t uni_h261_rl_len_last[64 *128]
static uint8_t uni_h261_rl_len[64 *128]
void ff_h261_reorder_mb_index(MPVEncContext *const s)
static av_cold int h261_encode_init(AVCodecContext *avctx)
static void h261_encode_gob_header(MPVEncContext *const s, int mb_line)
Encode a group of blocks header.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
Macro definitions for various function/variable attributes.
static int ff_thread_once(char *control, void(*routine)(void))
void ff_set_qscale(MpegEncContext *s, int qscale)
set qscale and update qscale dependent variables.
void ff_init_block_index(MpegEncContext *s)
static void ff_update_block_index(MpegEncContext *s, int bits_per_raw_sample, int lowres, int chroma_x_shift)
const AVClass ff_mpv_enc_class
av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet)
av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
#define UNI_AC_ENC_INDEX(run, level)
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static void put_bits_assume_flushed(const PutBitContext *s)
Inform the compiler that a PutBitContext is flushed (i.e.
#define FF_ARRAY_ELEMS(a)
main external API structure.
int width
picture width / height.