Mercurial > libavcodec.hg
comparison mpegvideo.c @ 8:1b4461b5a7fb libavcodec
Sync with mplayer's stuff
author | nickols_k |
---|---|
date | Mon, 30 Jul 2001 09:04:34 +0000 |
parents | 1d3ac9654178 |
children | 174ef88f619a |
comparison
equal
deleted
inserted
replaced
7:1d3ac9654178 | 8:1b4461b5a7fb |
---|---|
22 #include <string.h> | 22 #include <string.h> |
23 #include "avcodec.h" | 23 #include "avcodec.h" |
24 #include "dsputil.h" | 24 #include "dsputil.h" |
25 #include "mpegvideo.h" | 25 #include "mpegvideo.h" |
26 | 26 |
27 #include "../config.h" | |
28 | |
29 #ifdef ARCH_X86 | |
30 #include "i386/mpegvideo.c" | |
31 #endif | |
32 #ifndef DCT_UNQUANTIZE | |
33 #define DCT_UNQUANTIZE(a,b,c,d) dct_unquantize(a,b,c,d) | |
34 #endif | |
35 | |
27 #define EDGE_WIDTH 16 | 36 #define EDGE_WIDTH 16 |
28 | 37 |
29 /* enable all paranoid tests for rounding, overflows, etc... */ | 38 /* enable all paranoid tests for rounding, overflows, etc... */ |
30 //#define PARANOID | 39 //#define PARANOID |
31 | 40 |
87 int MPV_common_init(MpegEncContext *s) | 96 int MPV_common_init(MpegEncContext *s) |
88 { | 97 { |
89 int c_size, i; | 98 int c_size, i; |
90 UINT8 *pict; | 99 UINT8 *pict; |
91 | 100 |
101 #if defined ( HAVE_MMX ) && defined ( BIN_PORTABILITY ) | |
102 MPV_common_init_mmx(); | |
103 #endif | |
92 s->mb_width = (s->width + 15) / 16; | 104 s->mb_width = (s->width + 15) / 16; |
93 s->mb_height = (s->height + 15) / 16; | 105 s->mb_height = (s->height + 15) / 16; |
94 s->linesize = s->mb_width * 16 + 2 * EDGE_WIDTH; | 106 s->linesize = s->mb_width * 16 + 2 * EDGE_WIDTH; |
95 | 107 |
96 for(i=0;i<3;i++) { | 108 for(i=0;i<3;i++) { |
343 memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */ | 355 memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */ |
344 memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */ | 356 memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */ |
345 } | 357 } |
346 } | 358 } |
347 | 359 |
348 | |
349 /* generic function for encode/decode called before a frame is coded/decoded */ | 360 /* generic function for encode/decode called before a frame is coded/decoded */ |
361 #ifndef ARCH_X86 | |
350 void MPV_frame_start(MpegEncContext *s) | 362 void MPV_frame_start(MpegEncContext *s) |
351 { | 363 { |
352 int i; | 364 int i; |
353 UINT8 *tmp; | 365 UINT8 *tmp; |
354 | 366 |
364 s->next_picture[i] = tmp; | 376 s->next_picture[i] = tmp; |
365 s->current_picture[i] = tmp; | 377 s->current_picture[i] = tmp; |
366 } | 378 } |
367 } | 379 } |
368 } | 380 } |
369 | 381 #endif |
370 /* generic function for encode/decode called after a frame has been coded/decoded */ | 382 /* generic function for encode/decode called after a frame has been coded/decoded */ |
371 void MPV_frame_end(MpegEncContext *s) | 383 void MPV_frame_end(MpegEncContext *s) |
372 { | 384 { |
373 /* draw edge for correct motion prediction if outside */ | 385 /* draw edge for correct motion prediction if outside */ |
374 if (s->pict_type != B_TYPE) { | 386 if (s->pict_type != B_TYPE) { |
619 /* put block[] to dest[] */ | 631 /* put block[] to dest[] */ |
620 static inline void put_dct(MpegEncContext *s, | 632 static inline void put_dct(MpegEncContext *s, |
621 DCTELEM *block, int i, UINT8 *dest, int line_size) | 633 DCTELEM *block, int i, UINT8 *dest, int line_size) |
622 { | 634 { |
623 if (!s->mpeg2) | 635 if (!s->mpeg2) |
624 dct_unquantize(s, block, i, s->qscale); | 636 DCT_UNQUANTIZE(s, block, i, s->qscale); |
625 j_rev_dct (block); | 637 j_rev_dct (block); |
626 put_pixels_clamped(block, dest, line_size); | 638 put_pixels_clamped(block, dest, line_size); |
627 } | 639 } |
628 | 640 |
629 /* add block[] to dest[] */ | 641 /* add block[] to dest[] */ |
630 static inline void add_dct(MpegEncContext *s, | 642 static inline void add_dct(MpegEncContext *s, |
631 DCTELEM *block, int i, UINT8 *dest, int line_size) | 643 DCTELEM *block, int i, UINT8 *dest, int line_size) |
632 { | 644 { |
633 if (s->block_last_index[i] >= 0) { | 645 if (s->block_last_index[i] >= 0) { |
634 if (!s->mpeg2) | 646 if (!s->mpeg2) |
635 dct_unquantize(s, block, i, s->qscale); | 647 DCT_UNQUANTIZE(s, block, i, s->qscale); |
636 j_rev_dct (block); | 648 j_rev_dct (block); |
637 add_pixels_clamped(block, dest, line_size); | 649 add_pixels_clamped(block, dest, line_size); |
638 } | 650 } |
639 } | 651 } |
640 | 652 |
1107 } | 1119 } |
1108 } | 1120 } |
1109 return last_non_zero; | 1121 return last_non_zero; |
1110 } | 1122 } |
1111 | 1123 |
1124 #ifndef HAVE_DCT_UNQUANTIZE | |
1112 static void dct_unquantize(MpegEncContext *s, | 1125 static void dct_unquantize(MpegEncContext *s, |
1113 DCTELEM *block, int n, int qscale) | 1126 DCTELEM *block, int n, int qscale) |
1114 { | 1127 { |
1115 int i, level; | 1128 int i, level; |
1116 const UINT16 *quant_matrix; | 1129 const UINT16 *quant_matrix; |
1170 block[i] = level; | 1183 block[i] = level; |
1171 } | 1184 } |
1172 } | 1185 } |
1173 } | 1186 } |
1174 } | 1187 } |
1175 | 1188 #endif |
1176 | 1189 |
1177 /* rate control */ | 1190 /* rate control */ |
1178 | 1191 |
1179 /* an I frame is I_FRAME_SIZE_RATIO bigger than a P frame */ | 1192 /* an I frame is I_FRAME_SIZE_RATIO bigger than a P frame */ |
1180 #define I_FRAME_SIZE_RATIO 3.0 | 1193 #define I_FRAME_SIZE_RATIO 3.0 |