MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_msmpeg4_encode_block

Function ff_msmpeg4_encode_block

libavcodec/msmpeg4.c:934–1053  ·  view source on GitHub ↗

Encoding of a block. Very similar to MPEG4 except for a different escape coding (same as H263) and more vlc tables. */

Source from the content-addressed store, hash-verified

932 escape coding (same as H263) and more vlc tables.
933 */
934void ff_msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n)
935{
936 int level, run, last, i, j, last_index;
937 int last_non_zero, sign, slevel;
938 int code, run_diff, dc_pred_dir;
939 const RLTable *rl;
940 const uint8_t *scantable;
941
942 if (s->mb_intra) {
943 msmpeg4_encode_dc(s, block[0], n, &dc_pred_dir);
944 i = 1;
945 if (n < 4) {
946 rl = &rl_table[s->rl_table_index];
947 } else {
948 rl = &rl_table[3 + s->rl_chroma_table_index];
949 }
950 run_diff = s->msmpeg4_version>=4;
951 scantable= s->intra_scantable.permutated;
952 } else {
953 i = 0;
954 rl = &rl_table[3 + s->rl_table_index];
955 if(s->msmpeg4_version<=2)
956 run_diff = 0;
957 else
958 run_diff = 1;
959 scantable= s->inter_scantable.permutated;
960 }
961
962 /* recalculate block_last_index for M$ wmv1 */
963 if(s->msmpeg4_version>=4 && s->msmpeg4_version<6 && s->block_last_index[n]>0){
964 for(last_index=63; last_index>=0; last_index--){
965 if(block[scantable[last_index]]) break;
966 }
967 s->block_last_index[n]= last_index;
968 }else
969 last_index = s->block_last_index[n];
970 /* AC coefs */
971 last_non_zero = i - 1;
972 for (; i <= last_index; i++) {
973 j = scantable[i];
974 level = block[j];
975 if (level) {
976 run = i - last_non_zero - 1;
977 last = (i == last_index);
978 sign = 0;
979 slevel = level;
980 if (level < 0) {
981 sign = 1;
982 level = -level;
983 }
984
985 if(level<=MAX_LEVEL && run<=MAX_RUN){
986 s->ac_stats[s->mb_intra][n>3][level][run][last]++;
987 }
988#if 0
989else
990 s->ac_stats[s->mb_intra][n>3][40][63][0]++; //esc3 like
991#endif

Callers 2

ff_wmv2_encode_mbFunction · 0.85
msmpeg4_encode_mbFunction · 0.85

Calls 3

msmpeg4_encode_dcFunction · 0.85
get_rl_indexFunction · 0.85
put_sbitsFunction · 0.85

Tested by

no test coverage detected