Go to the documentation of this file.
56 tab->table_mv_index = table_mv_index;
63 x =
tab->table_mvx[
i];
64 y =
tab->table_mvy[
i];
65 tab->table_mv_index[(x << 6) | y] =
i;
83 int run_diff= intra ? 0 : 1;
123 static uint16_t mv_index_tables[2][4096];
130 for (
int last = 0; last < 2; last++) {
143 if (
s->msmpeg4_version >= MSMP4_WMV1) {
144 s->min_qcoeff = -255;
156 int best = 0, best_size = INT_MAX;
157 int chroma_best = 0, best_chroma_size = INT_MAX;
172 const int last_size=
size + chroma_size;
173 for(last=0; last<2; last++){
187 if(last_size ==
size+chroma_size)
break;
194 if(chroma_size<best_chroma_size){
195 best_chroma_size= chroma_size;
204 s->rl_table_index = best;
205 s->rl_chroma_table_index= chroma_best;
207 if(
s->pict_type !=
s->last_non_b_pict_type){
208 s->rl_table_index= 2;
210 s->rl_chroma_table_index= 1;
212 s->rl_chroma_table_index= 2;
228 if (
s->msmpeg4_version <= MSMP4_V2) {
229 s->rl_table_index = 2;
230 s->rl_chroma_table_index = 2;
233 s->dc_table_index = 1;
234 s->mv_table_index = 1;
235 s->use_skip_mb_code = 1;
236 s->per_mb_rl_table = 0;
237 if (
s->msmpeg4_version == MSMP4_WMV1)
239 ff_dlog(
s,
"%d %"PRId64
" %d %d %d\n",
s->pict_type,
s->bit_rate,
240 s->inter_intra_pred,
s->width,
s->height);
243 s->slice_height=
s->mb_height/1;
244 put_bits(&
s->pb, 5, 0x16 +
s->mb_height/
s->slice_height);
246 if (
s->msmpeg4_version == MSMP4_WMV1) {
252 if (
s->msmpeg4_version > MSMP4_V2) {
253 if(!
s->per_mb_rl_table){
263 if (
s->msmpeg4_version == MSMP4_WMV1 &&
s->bit_rate >
MBAC_BITRATE)
266 if (
s->msmpeg4_version > MSMP4_V2) {
267 if(!
s->per_mb_rl_table)
276 s->esc3_level_length= 0;
277 s->esc3_run_length= 0;
284 if (
s->avctx->framerate.num > 0 &&
s->avctx->framerate.den > 0)
285 fps =
s->avctx->framerate.num /
s->avctx->framerate.den;
288 fps =
s->avctx->time_base.den /
s->avctx->time_base.num
289 #if FF_API_TICKS_PER_FRAME
290 /
FFMAX(
s->avctx->ticks_per_frame, 1)
300 if (
s->msmpeg4_version >= MSMP4_V3)
341 if (
s->slice_height && (
s->mb_y %
s->slice_height) == 0) {
342 if (
s->msmpeg4_version < MSMP4_WMV1) {
345 s->first_slice_line = 1;
347 s->first_slice_line = 0;
361 bit_size =
s->f_code - 1;
362 range = 1 << bit_size;
386 int16_t
block[6][64],
387 int motion_x,
int motion_y)
389 int cbp, coded_cbp,
i;
397 for (
i = 0;
i < 6;
i++) {
398 if (
s->block_last_index[
i] >= 0)
401 if (
s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
409 if (
s->use_skip_mb_code)
412 if (
s->msmpeg4_version <= MSMP4_V2) {
416 if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
443 for (
i = 0;
i < 6;
i++) {
450 for (
int i = 0;
i < 6;
i++) {
451 int val = (
s->block_last_index[
i] >= 1);
452 cbp |=
val << (5 -
i);
454 if (
s->msmpeg4_version <= MSMP4_V2) {
459 if (
s->use_skip_mb_code)
473 coded_cbp = cbp & 0x3;
474 for (
int i = 0;
i < 4;
i++) {
475 uint8_t *coded_block;
477 int val = (
s->block_last_index[
i] >= 1);
480 coded_cbp |=
val << (5 -
i);
486 if (
s->use_skip_mb_code)
493 if(
s->inter_intra_pred){
500 for (
i = 0;
i < 6;
i++) {
518 *dc_val =
level *
s->y_dc_scale;
520 *dc_val =
level *
s->c_dc_scale;
526 if (
s->msmpeg4_version <= MSMP4_V2) {
564 int last_non_zero, sign, slevel;
565 int code, run_diff, dc_pred_dir;
567 const uint8_t *scantable;
577 run_diff =
s->msmpeg4_version >= MSMP4_WMV1;
578 scantable=
s->intra_scantable.permutated;
582 run_diff =
s->msmpeg4_version > MSMP4_V2;
583 scantable=
s->inter_scantable.permutated;
587 if (
s->msmpeg4_version >= MSMP4_WMV1 &&
s->block_last_index[n] > 0) {
588 for(last_index=63; last_index>=0; last_index--){
589 if(
block[scantable[last_index]])
break;
591 s->block_last_index[n]= last_index;
593 last_index =
s->block_last_index[n];
595 last_non_zero =
i - 1;
596 for (;
i <= last_index;
i++) {
600 run =
i - last_non_zero - 1;
601 last = (
i == last_index);
613 ms->
ac_stats[
s->mb_intra][n > 3][40][63][0]++;
633 if (
s->msmpeg4_version == MSMP4_WMV1 &&
code == rl->
n)
641 if (
s->msmpeg4_version >= MSMP4_WMV1) {
642 if(
s->esc3_level_length==0){
643 s->esc3_level_length=8;
644 s->esc3_run_length= 6;
679 .
p.
name =
"msmpeg4v2",
#define FF_ENABLE_DEPRECATION_WARNINGS
const uint32_t ff_msmp4_dc_tables[2][2][120][2]
AVPixelFormat
Pixel format.
const AVClass ff_mpv_enc_class
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
static int get_bits_diff(MpegEncContext *s)
void ff_msmpeg4_handle_slices(MpegEncContext *s)
static void align_put_bits(PutBitContext *s)
Pad the bitstream with zeros up to the next byte boundary.
const FFCodec ff_msmpeg4v3_encoder
static const int8_t mv[256][2]
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
av_cold void ff_msmpeg4_common_init(MpegEncContext *s)
void ff_msmpeg4_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y)
RLTable ff_rl_table[NB_RL_TABLES]
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pic_arg, int *got_packet)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t mx
AVCodec p
The public AVCodec.
int16_t * ff_h263_pred_motion(MpegEncContext *s, int block, int dir, int *px, int *py)
av_cold void ff_msmpeg4_encode_init(MpegEncContext *s)
static const struct twinvq_data tab
const FFCodec ff_wmv1_encoder
static double val(void *priv, double ch)
#define FF_CODEC_ENCODE_CB(func)
unsigned ac_stats[2][2][MAX_LEVEL+1][MAX_RUN+1][2]
[mb_intra][isChroma][level][run][last]
int n
number of entries of table_vlc minus 1
static int ff_thread_once(char *control, void(*routine)(void))
int8_t * max_level[2]
encoding & decoding
static int get_rl_index(const RLTable *rl, int last, int run, int level)
#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_assert0(cond)
assert() equivalent, that is always enabled.
static void find_best_tables(MSMPEG4EncContext *ms)
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
void ff_msmpeg4_encode_motion(MpegEncContext *s, int mx, int my)
#define CODEC_LONG_NAME(str)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t my
const uint16_t(* table_vlc)[2]
const uint32_t ff_table_mb_non_intra[128][2]
const uint8_t ff_v2_mb_type[8][2]
uint32_t ff_v2_dc_lum_table[512][2]
@ AV_PICTURE_TYPE_I
Intra.
const uint16_t ff_msmp4_mb_i_table[64][2]
uint32_t ff_v2_dc_chroma_table[512][2]
av_cold int ff_mpv_encode_end(AVCodecContext *avctx)
const FFCodec ff_msmpeg4v2_encoder
int(* init)(AVBSFContext *ctx)
void ff_mpeg4_clean_buffers(MpegEncContext *s)
static av_cold void init_mv_table(MVTable *tab, uint16_t table_mv_index[4096])
const uint8_t ff_h263_cbpy_tab[16][2]
void ff_msmpeg4_encode_ext_header(MpegEncContext *s)
static uint8_t rl_length[NB_RL_TABLES][MAX_LEVEL+1][MAX_RUN+1][2]
int ff_msmpeg4_pred_dc(MpegEncContext *s, int n, int16_t **dc_val_ptr, int *dir_ptr)
const uint8_t ff_v2_intra_cbpc[4][2]
static void msmpeg4_encode_dc(MpegEncContext *s, int level, int n, int *dir_ptr)
void ff_msmpeg4_encode_picture_header(MpegEncContext *s)
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
static int get_size_of_code(const RLTable *rl, int last, int run, int level, int intra)
int8_t * max_run[2]
encoding & decoding
const char * name
Name of the codec implementation.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
static const float pred[4]
const uint8_t ff_mvtab[33][2]
static av_cold void msmpeg4_encode_init_static(void)
void ff_msmpeg4_encode_block(MpegEncContext *s, int16_t *block, int n)
void ff_msmpeg4_code012(PutBitContext *pb, int n)
const uint8_t ff_table_inter_intra[4][2]
#define FF_DISABLE_DEPRECATION_WARNINGS
static void msmpeg4v2_encode_motion(MpegEncContext *s, int val)
@ AV_PICTURE_TYPE_P
Predicted.
av_cold int ff_mpv_encode_init(AVCodecContext *avctx)
#define MSMPEG4_MV_TABLES_NB_ELEMS
The exact code depends on how similar the blocks are and how related they are to the block
int ff_msmpeg4_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)