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;
84 int run_diff= intra ? 0 : 1;
124 static uint16_t mv_index_tables[2][4096];
131 for (
int last = 0; last < 2; last++) {
144 if (
s->msmpeg4_version >= 4) {
145 s->min_qcoeff = -255;
157 int best = 0, best_size = INT_MAX;
158 int chroma_best = 0, best_chroma_size = INT_MAX;
173 const int last_size=
size + chroma_size;
174 for(last=0; last<2; last++){
188 if(last_size ==
size+chroma_size)
break;
195 if(chroma_size<best_chroma_size){
196 best_chroma_size= chroma_size;
205 s->rl_table_index = best;
206 s->rl_chroma_table_index= chroma_best;
208 if(
s->pict_type !=
s->last_non_b_pict_type){
209 s->rl_table_index= 2;
211 s->rl_chroma_table_index= 1;
213 s->rl_chroma_table_index= 2;
229 if(
s->msmpeg4_version<=2){
230 s->rl_table_index = 2;
231 s->rl_chroma_table_index = 2;
234 s->dc_table_index = 1;
235 s->mv_table_index = 1;
236 s->use_skip_mb_code = 1;
237 s->per_mb_rl_table = 0;
238 if(
s->msmpeg4_version==4)
240 ff_dlog(
s,
"%d %"PRId64
" %d %d %d\n",
s->pict_type,
s->bit_rate,
241 s->inter_intra_pred,
s->width,
s->height);
244 s->slice_height=
s->mb_height/1;
245 put_bits(&
s->pb, 5, 0x16 +
s->mb_height/
s->slice_height);
247 if(
s->msmpeg4_version==4){
253 if(
s->msmpeg4_version>2){
254 if(!
s->per_mb_rl_table){
267 if(
s->msmpeg4_version>2){
268 if(!
s->per_mb_rl_table)
277 s->esc3_level_length= 0;
278 s->esc3_run_length= 0;
285 if (
s->avctx->framerate.num > 0 &&
s->avctx->framerate.den > 0)
286 fps =
s->avctx->framerate.num /
s->avctx->framerate.den;
289 fps =
s->avctx->time_base.den /
s->avctx->time_base.num
290 #if FF_API_TICKS_PER_FRAME
291 /
FFMAX(
s->avctx->ticks_per_frame, 1)
301 if (
s->msmpeg4_version >= 3)
329 code =
mv->table_mv_index[(mx << 6) | my];
342 if (
s->slice_height && (
s->mb_y %
s->slice_height) == 0) {
343 if(
s->msmpeg4_version < 4){
346 s->first_slice_line = 1;
348 s->first_slice_line = 0;
362 bit_size =
s->f_code - 1;
363 range = 1 << bit_size;
387 int16_t
block[6][64],
388 int motion_x,
int motion_y)
390 int cbp, coded_cbp,
i;
392 uint8_t *coded_block;
399 for (
i = 0;
i < 6;
i++) {
400 if (
s->block_last_index[
i] >= 0)
403 if (
s->use_skip_mb_code && (cbp | motion_x | motion_y) == 0) {
412 if (
s->use_skip_mb_code)
415 if(
s->msmpeg4_version<=2){
419 if((cbp&3) != 3) coded_cbp= cbp ^ 0x3C;
446 for (
i = 0;
i < 6;
i++) {
454 for (
i = 0;
i < 6;
i++) {
456 val = (
s->block_last_index[
i] >= 1);
457 cbp |=
val << (5 -
i);
464 coded_cbp |=
val << (5 -
i);
467 if(
s->msmpeg4_version<=2){
472 if (
s->use_skip_mb_code)
487 if (
s->use_skip_mb_code)
494 if(
s->inter_intra_pred){
501 for (
i = 0;
i < 6;
i++) {
519 *dc_val =
level *
s->y_dc_scale;
521 *dc_val =
level *
s->c_dc_scale;
527 if(
s->msmpeg4_version<=2){
565 int last_non_zero, sign, slevel;
566 int code, run_diff, dc_pred_dir;
568 const uint8_t *scantable;
578 run_diff =
s->msmpeg4_version>=4;
579 scantable=
s->intra_scantable.permutated;
583 if(
s->msmpeg4_version<=2)
587 scantable=
s->inter_scantable.permutated;
591 if (
s->msmpeg4_version >= 4 &&
s->block_last_index[n] > 0) {
592 for(last_index=63; last_index>=0; last_index--){
593 if(
block[scantable[last_index]])
break;
595 s->block_last_index[n]= last_index;
597 last_index =
s->block_last_index[n];
599 last_non_zero =
i - 1;
600 for (;
i <= last_index;
i++) {
604 run =
i - last_non_zero - 1;
605 last = (
i == last_index);
617 ms->
ac_stats[
s->mb_intra][n > 3][40][63][0]++;
637 if (
s->msmpeg4_version == 4 &&
code == rl->
n)
645 if(
s->msmpeg4_version>=4){
646 if(
s->esc3_level_length==0){
647 s->esc3_level_length=8;
648 s->esc3_run_length= 6;
683 .
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)
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)
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.
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)