comparison msmpeg4.c @ 1070:6da5ae9ee199 libavcodec

more #ifdef CONFIG_ENCODERS patch by (Wolfgang Hesseler <qv at multimediaware dot com>) with modifications by me (s/WOLFGANG/CONFIG_ENCODERS/ and some other fixes)
author michaelni
date Sun, 16 Feb 2003 23:05:38 +0000
parents b32afefe7d33
children 1e39f273ecd6
comparison
equal deleted inserted replaced
1069:8528d0b9e508 1070:6da5ae9ee199
51 #define DEFAULT_INTER_INDEX 3 51 #define DEFAULT_INTER_INDEX 3
52 52
53 static uint32_t v2_dc_lum_table[512][2]; 53 static uint32_t v2_dc_lum_table[512][2];
54 static uint32_t v2_dc_chroma_table[512][2]; 54 static uint32_t v2_dc_chroma_table[512][2];
55 55
56 #ifdef CONFIG_ENCODERS
56 static inline void msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n); 57 static inline void msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n);
58 #endif //CONFIG_ENCODERS
57 static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block, 59 static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block,
58 int n, int coded, const uint8_t *scantable); 60 int n, int coded, const uint8_t *scantable);
59 static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr); 61 static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr);
60 static int msmpeg4_decode_motion(MpegEncContext * s, 62 static int msmpeg4_decode_motion(MpegEncContext * s,
61 int *mx_ptr, int *my_ptr); 63 int *mx_ptr, int *my_ptr);
64 #ifdef CONFIG_ENCODERS
62 static void msmpeg4v2_encode_motion(MpegEncContext * s, int val); 65 static void msmpeg4v2_encode_motion(MpegEncContext * s, int val);
66 #endif //CONFIG_ENCODERS
63 static void init_h263_dc_for_msmpeg4(void); 67 static void init_h263_dc_for_msmpeg4(void);
64 static inline void msmpeg4_memsetw(short *tab, int val, int n); 68 static inline void msmpeg4_memsetw(short *tab, int val, int n);
69 #ifdef CONFIG_ENCODERS
65 static int get_size_of_code(MpegEncContext * s, RLTable *rl, int last, int run, int level, int intra); 70 static int get_size_of_code(MpegEncContext * s, RLTable *rl, int last, int run, int level, int intra);
71 #endif //CONFIG_ENCODERS
66 static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); 72 static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
67 static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); 73 static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
68 static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); 74 static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
69 75
70 extern uint32_t inverse[256]; 76 extern uint32_t inverse[256];
182 inited=1; 188 inited=1;
183 189
184 init_h263_dc_for_msmpeg4(); 190 init_h263_dc_for_msmpeg4();
185 } 191 }
186 } 192 }
193
194 #ifdef CONFIG_ENCODERS
187 195
188 /* build the table which associate a (x,y) motion vector to a vlc */ 196 /* build the table which associate a (x,y) motion vector to a vlc */
189 static void init_mv_table(MVTable *tab) 197 static void init_mv_table(MVTable *tab)
190 { 198 {
191 int i, x, y; 199 int i, x, y;
431 s->flipflop_rounding=1; 439 s->flipflop_rounding=1;
432 put_bits(&s->pb, 1, s->flipflop_rounding); 440 put_bits(&s->pb, 1, s->flipflop_rounding);
433 } 441 }
434 } 442 }
435 443
444 #endif //CONFIG_ENCODERS
445
436 /* predict coded block */ 446 /* predict coded block */
437 static inline int coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr) 447 static inline int coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr)
438 { 448 {
439 int xy, wrap, pred, a, b, c; 449 int xy, wrap, pred, a, b, c;
440 450
457 /* store value */ 467 /* store value */
458 *coded_block_ptr = &s->coded_block[xy]; 468 *coded_block_ptr = &s->coded_block[xy];
459 469
460 return pred; 470 return pred;
461 } 471 }
472
473 #ifdef CONFIG_ENCODERS
462 474
463 static void msmpeg4_encode_motion(MpegEncContext * s, 475 static void msmpeg4_encode_motion(MpegEncContext * s,
464 int mx, int my) 476 int mx, int my)
465 { 477 {
466 int code; 478 int code;
621 633
622 for (i = 0; i < 6; i++) { 634 for (i = 0; i < 6; i++) {
623 msmpeg4_encode_block(s, block[i], i); 635 msmpeg4_encode_block(s, block[i], i);
624 } 636 }
625 } 637 }
638
639 #endif //CONFIG_ENCODERS
626 640
627 /* old ffmpeg msmpeg4v3 mode */ 641 /* old ffmpeg msmpeg4v3 mode */
628 static void ff_old_msmpeg4_dc_scale(MpegEncContext * s) 642 static void ff_old_msmpeg4_dc_scale(MpegEncContext * s)
629 { 643 {
630 if (s->qscale < 5){ 644 if (s->qscale < 5){
815 return pred; 829 return pred;
816 } 830 }
817 831
818 #define DC_MAX 119 832 #define DC_MAX 119
819 833
834 #ifdef CONFIG_ENCODERS
835
820 static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr) 836 static void msmpeg4_encode_dc(MpegEncContext * s, int level, int n, int *dir_ptr)
821 { 837 {
822 int sign, code; 838 int sign, code;
823 int pred; 839 int pred;
824 840
1007 last_non_zero = i; 1023 last_non_zero = i;
1008 } 1024 }
1009 } 1025 }
1010 } 1026 }
1011 1027
1028 #endif //CONFIG_ENCODERS
1029
1012 /****************************************/ 1030 /****************************************/
1013 /* decoding stuff */ 1031 /* decoding stuff */
1014 1032
1015 static VLC mb_non_intra_vlc[4]; 1033 static VLC mb_non_intra_vlc[4];
1016 static VLC mb_intra_vlc; 1034 static VLC mb_intra_vlc;
1389 int i; 1407 int i;
1390 for(i=0;i<n;i++) 1408 for(i=0;i<n;i++)
1391 tab[i] = val; 1409 tab[i] = val;
1392 } 1410 }
1393 1411
1412 #ifdef CONFIG_ENCODERS
1413
1394 static void msmpeg4v2_encode_motion(MpegEncContext * s, int val) 1414 static void msmpeg4v2_encode_motion(MpegEncContext * s, int val)
1395 { 1415 {
1396 int range, bit_size, sign, code, bits; 1416 int range, bit_size, sign, code, bits;
1397 1417
1398 if (val == 0) { 1418 if (val == 0) {
1421 if (bit_size > 0) { 1441 if (bit_size > 0) {
1422 put_bits(&s->pb, bit_size, bits); 1442 put_bits(&s->pb, bit_size, bits);
1423 } 1443 }
1424 } 1444 }
1425 } 1445 }
1446
1447 #endif //CONFIG_ENCODERS
1426 1448
1427 /* this is identical to h263 except that its range is multiplied by 2 */ 1449 /* this is identical to h263 except that its range is multiplied by 2 */
1428 static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code) 1450 static int msmpeg4v2_decode_motion(MpegEncContext * s, int pred, int f_code)
1429 { 1451 {
1430 int code, val, sign, shift; 1452 int code, val, sign, shift;