Mercurial > libavcodec.hg
comparison mpegvideo.c @ 1064:b32afefe7d33 libavcodec
* UINTX -> uintx_t INTX -> intx_t
author | kabi |
---|---|
date | Tue, 11 Feb 2003 16:35:48 +0000 |
parents | 890b9fb44e84 |
children | 6da5ae9ee199 |
comparison
equal
deleted
inserted
replaced
1063:fdeac9642346 | 1064:b32afefe7d33 |
---|---|
38 DCTELEM *block, int n, int qscale); | 38 DCTELEM *block, int n, int qscale); |
39 static void dct_unquantize_mpeg2_c(MpegEncContext *s, | 39 static void dct_unquantize_mpeg2_c(MpegEncContext *s, |
40 DCTELEM *block, int n, int qscale); | 40 DCTELEM *block, int n, int qscale); |
41 static void dct_unquantize_h263_c(MpegEncContext *s, | 41 static void dct_unquantize_h263_c(MpegEncContext *s, |
42 DCTELEM *block, int n, int qscale); | 42 DCTELEM *block, int n, int qscale); |
43 static void draw_edges_c(UINT8 *buf, int wrap, int width, int height, int w); | 43 static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w); |
44 static int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); | 44 static int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); |
45 static int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); | 45 static int dct_quantize_trellis_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); |
46 | 46 |
47 void (*draw_edges)(UINT8 *buf, int wrap, int width, int height, int w)= draw_edges_c; | 47 void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w)= draw_edges_c; |
48 | 48 |
49 | 49 |
50 /* enable all paranoid tests for rounding, overflows, etc... */ | 50 /* enable all paranoid tests for rounding, overflows, etc... */ |
51 //#define PARANOID | 51 //#define PARANOID |
52 | 52 |
83 static const uint8_t h263_chroma_roundtab[16] = { | 83 static const uint8_t h263_chroma_roundtab[16] = { |
84 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 84 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
85 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, | 85 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, |
86 }; | 86 }; |
87 | 87 |
88 static UINT16 (*default_mv_penalty)[MAX_MV*2+1]=NULL; | 88 static uint16_t (*default_mv_penalty)[MAX_MV*2+1]=NULL; |
89 static UINT8 default_fcode_tab[MAX_MV*2+1]; | 89 static uint8_t default_fcode_tab[MAX_MV*2+1]; |
90 | 90 |
91 enum PixelFormat ff_yuv420p_list[2]= {PIX_FMT_YUV420P, -1}; | 91 enum PixelFormat ff_yuv420p_list[2]= {PIX_FMT_YUV420P, -1}; |
92 | 92 |
93 static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[64], uint16_t (*qmat16_bias)[64], | 93 static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[64], uint16_t (*qmat16_bias)[64], |
94 const UINT16 *quant_matrix, int bias, int qmin, int qmax) | 94 const uint16_t *quant_matrix, int bias, int qmin, int qmax) |
95 { | 95 { |
96 int qscale; | 96 int qscale; |
97 | 97 |
98 for(qscale=qmin; qscale<=qmax; qscale++){ | 98 for(qscale=qmin; qscale<=qmax; qscale++){ |
99 int i; | 99 int i; |
103 /* 16 <= qscale * quant_matrix[i] <= 7905 */ | 103 /* 16 <= qscale * quant_matrix[i] <= 7905 */ |
104 /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ | 104 /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ |
105 /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ | 105 /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ |
106 /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ | 106 /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ |
107 | 107 |
108 qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / | 108 qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / |
109 (qscale * quant_matrix[j])); | 109 (qscale * quant_matrix[j])); |
110 } | 110 } |
111 } else if (s->fdct == fdct_ifast) { | 111 } else if (s->fdct == fdct_ifast) { |
112 for(i=0;i<64;i++) { | 112 for(i=0;i<64;i++) { |
113 const int j= s->idct_permutation[i]; | 113 const int j= s->idct_permutation[i]; |
114 /* 16 <= qscale * quant_matrix[i] <= 7905 */ | 114 /* 16 <= qscale * quant_matrix[i] <= 7905 */ |
115 /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ | 115 /* 19952 <= aanscales[i] * qscale * quant_matrix[i] <= 249205026 */ |
116 /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ | 116 /* (1<<36)/19952 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= (1<<36)/249205026 */ |
117 /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ | 117 /* 3444240 >= (1<<36)/(aanscales[i] * qscale * quant_matrix[i]) >= 275 */ |
118 | 118 |
119 qmat[qscale][i] = (int)((UINT64_C(1) << (QMAT_SHIFT + 14)) / | 119 qmat[qscale][i] = (int)((uint64_t_C(1) << (QMAT_SHIFT + 14)) / |
120 (aanscales[i] * qscale * quant_matrix[j])); | 120 (aanscales[i] * qscale * quant_matrix[j])); |
121 } | 121 } |
122 } else { | 122 } else { |
123 for(i=0;i<64;i++) { | 123 for(i=0;i<64;i++) { |
124 const int j= s->idct_permutation[i]; | 124 const int j= s->idct_permutation[i]; |
125 /* We can safely suppose that 16 <= quant_matrix[i] <= 255 | 125 /* We can safely suppose that 16 <= quant_matrix[i] <= 255 |
126 So 16 <= qscale * quant_matrix[i] <= 7905 | 126 So 16 <= qscale * quant_matrix[i] <= 7905 |
127 so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905 | 127 so (1<<19) / 16 >= (1<<19) / (qscale * quant_matrix[i]) >= (1<<19) / 7905 |
128 so 32768 >= (1<<19) / (qscale * quant_matrix[i]) >= 67 | 128 so 32768 >= (1<<19) / (qscale * quant_matrix[i]) >= 67 |
129 */ | 129 */ |
130 qmat[qscale][i] = (int)((UINT64_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j])); | 130 qmat[qscale][i] = (int)((uint64_t_C(1) << QMAT_SHIFT) / (qscale * quant_matrix[j])); |
131 // qmat [qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]); | 131 // qmat [qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[i]); |
132 qmat16[qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]); | 132 qmat16[qscale][i] = (1 << QMAT_SHIFT_MMX) / (qscale * quant_matrix[j]); |
133 | 133 |
134 if(qmat16[qscale][i]==0 || qmat16[qscale][i]==128*256) qmat16[qscale][i]=128*256-1; | 134 if(qmat16[qscale][i]==0 || qmat16[qscale][i]==128*256) qmat16[qscale][i]=128*256-1; |
135 qmat16_bias[qscale][i]= ROUNDED_DIV(bias<<(16-QUANT_BIAS_SHIFT), qmat16[qscale][i]); | 135 qmat16_bias[qscale][i]= ROUNDED_DIV(bias<<(16-QUANT_BIAS_SHIFT), qmat16[qscale][i]); |
145 perror("malloc");\ | 145 perror("malloc");\ |
146 goto fail;\ | 146 goto fail;\ |
147 }\ | 147 }\ |
148 } | 148 } |
149 | 149 |
150 void ff_init_scantable(MpegEncContext *s, ScanTable *st, const UINT8 *src_scantable){ | 150 void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scantable){ |
151 int i; | 151 int i; |
152 int end; | 152 int end; |
153 | 153 |
154 st->scantable= src_scantable; | 154 st->scantable= src_scantable; |
155 | 155 |
172 } | 172 } |
173 | 173 |
174 /* XXX: those functions should be suppressed ASAP when all IDCTs are | 174 /* XXX: those functions should be suppressed ASAP when all IDCTs are |
175 converted */ | 175 converted */ |
176 // *FIXME* this is ugly hack using local static | 176 // *FIXME* this is ugly hack using local static |
177 static void (*ff_put_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size); | 177 static void (*ff_put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size); |
178 static void (*ff_add_pixels_clamped)(const DCTELEM *block, UINT8 *pixels, int line_size); | 178 static void (*ff_add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size); |
179 static void ff_jref_idct_put(UINT8 *dest, int line_size, DCTELEM *block) | 179 static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block) |
180 { | 180 { |
181 j_rev_dct (block); | 181 j_rev_dct (block); |
182 ff_put_pixels_clamped(block, dest, line_size); | 182 ff_put_pixels_clamped(block, dest, line_size); |
183 } | 183 } |
184 static void ff_jref_idct_add(UINT8 *dest, int line_size, DCTELEM *block) | 184 static void ff_jref_idct_add(uint8_t *dest, int line_size, DCTELEM *block) |
185 { | 185 { |
186 j_rev_dct (block); | 186 j_rev_dct (block); |
187 ff_add_pixels_clamped(block, dest, line_size); | 187 ff_add_pixels_clamped(block, dest, line_size); |
188 } | 188 } |
189 | 189 |
310 s->uvlinesize= pic->linesize[1]; | 310 s->uvlinesize= pic->linesize[1]; |
311 } | 311 } |
312 | 312 |
313 if(pic->qscale_table==NULL){ | 313 if(pic->qscale_table==NULL){ |
314 if (s->encoding) { | 314 if (s->encoding) { |
315 CHECKED_ALLOCZ(pic->mb_var , s->mb_num * sizeof(INT16)) | 315 CHECKED_ALLOCZ(pic->mb_var , s->mb_num * sizeof(int16_t)) |
316 CHECKED_ALLOCZ(pic->mc_mb_var, s->mb_num * sizeof(INT16)) | 316 CHECKED_ALLOCZ(pic->mc_mb_var, s->mb_num * sizeof(int16_t)) |
317 CHECKED_ALLOCZ(pic->mb_mean , s->mb_num * sizeof(INT8)) | 317 CHECKED_ALLOCZ(pic->mb_mean , s->mb_num * sizeof(int8_t)) |
318 CHECKED_ALLOCZ(pic->mb_cmp_score, s->mb_num * sizeof(int32_t)) | 318 CHECKED_ALLOCZ(pic->mb_cmp_score, s->mb_num * sizeof(int32_t)) |
319 } | 319 } |
320 | 320 |
321 CHECKED_ALLOCZ(pic->mbskip_table , s->mb_num * sizeof(UINT8)+1) //the +1 is for the slice end check | 321 CHECKED_ALLOCZ(pic->mbskip_table , s->mb_num * sizeof(uint8_t)+1) //the +1 is for the slice end check |
322 CHECKED_ALLOCZ(pic->qscale_table , s->mb_num * sizeof(UINT8)) | 322 CHECKED_ALLOCZ(pic->qscale_table , s->mb_num * sizeof(uint8_t)) |
323 pic->qstride= s->mb_width; | 323 pic->qstride= s->mb_width; |
324 } | 324 } |
325 | 325 |
326 //it might be nicer if the application would keep track of these but it would require a API change | 326 //it might be nicer if the application would keep track of these but it would require a API change |
327 memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1); | 327 memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1); |
403 | 403 |
404 if (s->encoding) { | 404 if (s->encoding) { |
405 int mv_table_size= (s->mb_width+2)*(s->mb_height+2); | 405 int mv_table_size= (s->mb_width+2)*(s->mb_height+2); |
406 | 406 |
407 /* Allocate MV tables */ | 407 /* Allocate MV tables */ |
408 CHECKED_ALLOCZ(s->p_mv_table , mv_table_size * 2 * sizeof(INT16)) | 408 CHECKED_ALLOCZ(s->p_mv_table , mv_table_size * 2 * sizeof(int16_t)) |
409 CHECKED_ALLOCZ(s->b_forw_mv_table , mv_table_size * 2 * sizeof(INT16)) | 409 CHECKED_ALLOCZ(s->b_forw_mv_table , mv_table_size * 2 * sizeof(int16_t)) |
410 CHECKED_ALLOCZ(s->b_back_mv_table , mv_table_size * 2 * sizeof(INT16)) | 410 CHECKED_ALLOCZ(s->b_back_mv_table , mv_table_size * 2 * sizeof(int16_t)) |
411 CHECKED_ALLOCZ(s->b_bidir_forw_mv_table , mv_table_size * 2 * sizeof(INT16)) | 411 CHECKED_ALLOCZ(s->b_bidir_forw_mv_table , mv_table_size * 2 * sizeof(int16_t)) |
412 CHECKED_ALLOCZ(s->b_bidir_back_mv_table , mv_table_size * 2 * sizeof(INT16)) | 412 CHECKED_ALLOCZ(s->b_bidir_back_mv_table , mv_table_size * 2 * sizeof(int16_t)) |
413 CHECKED_ALLOCZ(s->b_direct_mv_table , mv_table_size * 2 * sizeof(INT16)) | 413 CHECKED_ALLOCZ(s->b_direct_mv_table , mv_table_size * 2 * sizeof(int16_t)) |
414 | 414 |
415 //FIXME should be linesize instead of s->width*2 but that isnt known before get_buffer() | 415 //FIXME should be linesize instead of s->width*2 but that isnt known before get_buffer() |
416 CHECKED_ALLOCZ(s->me.scratchpad, s->width*2*16*3*sizeof(uint8_t)) | 416 CHECKED_ALLOCZ(s->me.scratchpad, s->width*2*16*3*sizeof(uint8_t)) |
417 | 417 |
418 CHECKED_ALLOCZ(s->me.map , ME_MAP_SIZE*sizeof(uint32_t)) | 418 CHECKED_ALLOCZ(s->me.map , ME_MAP_SIZE*sizeof(uint32_t)) |
427 CHECKED_ALLOCZ(s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int)); | 427 CHECKED_ALLOCZ(s->ac_stats, 2*2*(MAX_LEVEL+1)*(MAX_RUN+1)*2*sizeof(int)); |
428 } | 428 } |
429 CHECKED_ALLOCZ(s->avctx->stats_out, 256); | 429 CHECKED_ALLOCZ(s->avctx->stats_out, 256); |
430 } | 430 } |
431 | 431 |
432 CHECKED_ALLOCZ(s->error_status_table, s->mb_num*sizeof(UINT8)) | 432 CHECKED_ALLOCZ(s->error_status_table, s->mb_num*sizeof(uint8_t)) |
433 | 433 |
434 if (s->out_format == FMT_H263 || s->encoding) { | 434 if (s->out_format == FMT_H263 || s->encoding) { |
435 int size; | 435 int size; |
436 /* Allocate MB type table */ | 436 /* Allocate MB type table */ |
437 CHECKED_ALLOCZ(s->mb_type , s->mb_num * sizeof(UINT8)) | 437 CHECKED_ALLOCZ(s->mb_type , s->mb_num * sizeof(uint8_t)) |
438 | 438 |
439 /* MV prediction */ | 439 /* MV prediction */ |
440 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); | 440 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); |
441 CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(INT16)); | 441 CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(int16_t)); |
442 } | 442 } |
443 | 443 |
444 if(s->codec_id==CODEC_ID_MPEG4){ | 444 if(s->codec_id==CODEC_ID_MPEG4){ |
445 /* interlaced direct mode decoding tables */ | 445 /* interlaced direct mode decoding tables */ |
446 CHECKED_ALLOCZ(s->field_mv_table, s->mb_num*2*2 * sizeof(INT16)) | 446 CHECKED_ALLOCZ(s->field_mv_table, s->mb_num*2*2 * sizeof(int16_t)) |
447 CHECKED_ALLOCZ(s->field_select_table, s->mb_num*2* sizeof(INT8)) | 447 CHECKED_ALLOCZ(s->field_select_table, s->mb_num*2* sizeof(int8_t)) |
448 } | 448 } |
449 /* 4mv b frame decoding table */ | 449 /* 4mv b frame decoding table */ |
450 //note this is needed for h263 without b frames too (segfault on damaged streams otherwise) | 450 //note this is needed for h263 without b frames too (segfault on damaged streams otherwise) |
451 CHECKED_ALLOCZ(s->co_located_type_table, s->mb_num * sizeof(UINT8)) | 451 CHECKED_ALLOCZ(s->co_located_type_table, s->mb_num * sizeof(uint8_t)) |
452 if (s->out_format == FMT_H263) { | 452 if (s->out_format == FMT_H263) { |
453 /* ac values */ | 453 /* ac values */ |
454 CHECKED_ALLOCZ(s->ac_val[0], yc_size * sizeof(INT16) * 16); | 454 CHECKED_ALLOCZ(s->ac_val[0], yc_size * sizeof(int16_t) * 16); |
455 s->ac_val[1] = s->ac_val[0] + y_size; | 455 s->ac_val[1] = s->ac_val[0] + y_size; |
456 s->ac_val[2] = s->ac_val[1] + c_size; | 456 s->ac_val[2] = s->ac_val[1] + c_size; |
457 | 457 |
458 /* cbp values */ | 458 /* cbp values */ |
459 CHECKED_ALLOCZ(s->coded_block, y_size); | 459 CHECKED_ALLOCZ(s->coded_block, y_size); |
460 | 460 |
461 /* divx501 bitstream reorder buffer */ | 461 /* divx501 bitstream reorder buffer */ |
462 CHECKED_ALLOCZ(s->bitstream_buffer, BITSTREAM_BUFFER_SIZE); | 462 CHECKED_ALLOCZ(s->bitstream_buffer, BITSTREAM_BUFFER_SIZE); |
463 | 463 |
464 /* cbp, ac_pred, pred_dir */ | 464 /* cbp, ac_pred, pred_dir */ |
465 CHECKED_ALLOCZ(s->cbp_table , s->mb_num * sizeof(UINT8)) | 465 CHECKED_ALLOCZ(s->cbp_table , s->mb_num * sizeof(uint8_t)) |
466 CHECKED_ALLOCZ(s->pred_dir_table, s->mb_num * sizeof(UINT8)) | 466 CHECKED_ALLOCZ(s->pred_dir_table, s->mb_num * sizeof(uint8_t)) |
467 } | 467 } |
468 | 468 |
469 if (s->h263_pred || s->h263_plus || !s->encoding) { | 469 if (s->h263_pred || s->h263_plus || !s->encoding) { |
470 /* dc values */ | 470 /* dc values */ |
471 //MN: we need these for error resilience of intra-frames | 471 //MN: we need these for error resilience of intra-frames |
472 CHECKED_ALLOCZ(s->dc_val[0], yc_size * sizeof(INT16)); | 472 CHECKED_ALLOCZ(s->dc_val[0], yc_size * sizeof(int16_t)); |
473 s->dc_val[1] = s->dc_val[0] + y_size; | 473 s->dc_val[1] = s->dc_val[0] + y_size; |
474 s->dc_val[2] = s->dc_val[1] + c_size; | 474 s->dc_val[2] = s->dc_val[1] + c_size; |
475 for(i=0;i<yc_size;i++) | 475 for(i=0;i<yc_size;i++) |
476 s->dc_val[0][i] = 1024; | 476 s->dc_val[0][i] = 1024; |
477 } | 477 } |
714 static int done=0; | 714 static int done=0; |
715 if(!done){ | 715 if(!done){ |
716 int i; | 716 int i; |
717 done=1; | 717 done=1; |
718 | 718 |
719 default_mv_penalty= av_mallocz( sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1) ); | 719 default_mv_penalty= av_mallocz( sizeof(uint16_t)*(MAX_FCODE+1)*(2*MAX_MV+1) ); |
720 memset(default_mv_penalty, 0, sizeof(UINT16)*(MAX_FCODE+1)*(2*MAX_MV+1)); | 720 memset(default_mv_penalty, 0, sizeof(uint16_t)*(MAX_FCODE+1)*(2*MAX_MV+1)); |
721 memset(default_fcode_tab , 0, sizeof(UINT8)*(2*MAX_MV+1)); | 721 memset(default_fcode_tab , 0, sizeof(uint8_t)*(2*MAX_MV+1)); |
722 | 722 |
723 for(i=-16; i<16; i++){ | 723 for(i=-16; i<16; i++){ |
724 default_fcode_tab[i + MAX_MV]= 1; | 724 default_fcode_tab[i + MAX_MV]= 1; |
725 } | 725 } |
726 } | 726 } |
810 return 0; | 810 return 0; |
811 } | 811 } |
812 | 812 |
813 void init_rl(RLTable *rl) | 813 void init_rl(RLTable *rl) |
814 { | 814 { |
815 INT8 max_level[MAX_RUN+1], max_run[MAX_LEVEL+1]; | 815 int8_t max_level[MAX_RUN+1], max_run[MAX_LEVEL+1]; |
816 UINT8 index_run[MAX_RUN+1]; | 816 uint8_t index_run[MAX_RUN+1]; |
817 int last, run, level, start, end, i; | 817 int last, run, level, start, end, i; |
818 | 818 |
819 /* compute max_level[], max_run[] and index_run[] */ | 819 /* compute max_level[], max_run[] and index_run[] */ |
820 for(last=0;last<2;last++) { | 820 for(last=0;last<2;last++) { |
821 if (last == 0) { | 821 if (last == 0) { |
848 } | 848 } |
849 } | 849 } |
850 | 850 |
851 /* draw the edges of width 'w' of an image of size width, height */ | 851 /* draw the edges of width 'w' of an image of size width, height */ |
852 //FIXME check that this is ok for mpeg4 interlaced | 852 //FIXME check that this is ok for mpeg4 interlaced |
853 static void draw_edges_c(UINT8 *buf, int wrap, int width, int height, int w) | 853 static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w) |
854 { | 854 { |
855 UINT8 *ptr, *last_line; | 855 uint8_t *ptr, *last_line; |
856 int i; | 856 int i; |
857 | 857 |
858 last_line = buf + (height - 1) * wrap; | 858 last_line = buf + (height - 1) * wrap; |
859 for(i=0;i<w;i++) { | 859 for(i=0;i<w;i++) { |
860 /* top and bottom */ | 860 /* top and bottom */ |
1322 | 1322 |
1323 return pbBufPtr(&s->pb) - s->pb.buf; | 1323 return pbBufPtr(&s->pb) - s->pb.buf; |
1324 } | 1324 } |
1325 | 1325 |
1326 static inline void gmc1_motion(MpegEncContext *s, | 1326 static inline void gmc1_motion(MpegEncContext *s, |
1327 UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr, | 1327 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, |
1328 int dest_offset, | 1328 int dest_offset, |
1329 UINT8 **ref_picture, int src_offset) | 1329 uint8_t **ref_picture, int src_offset) |
1330 { | 1330 { |
1331 UINT8 *ptr; | 1331 uint8_t *ptr; |
1332 int offset, src_x, src_y, linesize, uvlinesize; | 1332 int offset, src_x, src_y, linesize, uvlinesize; |
1333 int motion_x, motion_y; | 1333 int motion_x, motion_y; |
1334 int emu=0; | 1334 int emu=0; |
1335 | 1335 |
1336 motion_x= s->sprite_offset[0][0]; | 1336 motion_x= s->sprite_offset[0][0]; |
1410 | 1410 |
1411 return; | 1411 return; |
1412 } | 1412 } |
1413 | 1413 |
1414 static inline void gmc_motion(MpegEncContext *s, | 1414 static inline void gmc_motion(MpegEncContext *s, |
1415 UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr, | 1415 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, |
1416 int dest_offset, | 1416 int dest_offset, |
1417 UINT8 **ref_picture, int src_offset) | 1417 uint8_t **ref_picture, int src_offset) |
1418 { | 1418 { |
1419 UINT8 *ptr; | 1419 uint8_t *ptr; |
1420 int linesize, uvlinesize; | 1420 int linesize, uvlinesize; |
1421 const int a= s->sprite_warping_accuracy; | 1421 const int a= s->sprite_warping_accuracy; |
1422 int ox, oy; | 1422 int ox, oy; |
1423 | 1423 |
1424 linesize = s->linesize; | 1424 linesize = s->linesize; |
1473 a+1, (1<<(2*a+1)) - s->no_rounding, | 1473 a+1, (1<<(2*a+1)) - s->no_rounding, |
1474 s->h_edge_pos>>1, s->v_edge_pos>>1); | 1474 s->h_edge_pos>>1, s->v_edge_pos>>1); |
1475 } | 1475 } |
1476 | 1476 |
1477 | 1477 |
1478 void ff_emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int block_w, int block_h, | 1478 void ff_emulated_edge_mc(MpegEncContext *s, uint8_t *src, int linesize, int block_w, int block_h, |
1479 int src_x, int src_y, int w, int h){ | 1479 int src_x, int src_y, int w, int h){ |
1480 int x, y; | 1480 int x, y; |
1481 int start_y, start_x, end_y, end_x; | 1481 int start_y, start_x, end_y, end_x; |
1482 UINT8 *buf= s->edge_emu_buffer; | 1482 uint8_t *buf= s->edge_emu_buffer; |
1483 | 1483 |
1484 if(src_y>= h){ | 1484 if(src_y>= h){ |
1485 src+= (h-1-src_y)*linesize; | 1485 src+= (h-1-src_y)*linesize; |
1486 src_y=h-1; | 1486 src_y=h-1; |
1487 }else if(src_y<=-block_h){ | 1487 }else if(src_y<=-block_h){ |
1536 } | 1536 } |
1537 | 1537 |
1538 | 1538 |
1539 /* apply one mpeg motion vector to the three components */ | 1539 /* apply one mpeg motion vector to the three components */ |
1540 static inline void mpeg_motion(MpegEncContext *s, | 1540 static inline void mpeg_motion(MpegEncContext *s, |
1541 UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr, | 1541 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, |
1542 int dest_offset, | 1542 int dest_offset, |
1543 UINT8 **ref_picture, int src_offset, | 1543 uint8_t **ref_picture, int src_offset, |
1544 int field_based, op_pixels_func (*pix_op)[4], | 1544 int field_based, op_pixels_func (*pix_op)[4], |
1545 int motion_x, int motion_y, int h) | 1545 int motion_x, int motion_y, int h) |
1546 { | 1546 { |
1547 UINT8 *ptr; | 1547 uint8_t *ptr; |
1548 int dxy, offset, mx, my, src_x, src_y, height, v_edge_pos, linesize, uvlinesize; | 1548 int dxy, offset, mx, my, src_x, src_y, height, v_edge_pos, linesize, uvlinesize; |
1549 int emu=0; | 1549 int emu=0; |
1550 #if 0 | 1550 #if 0 |
1551 if(s->quarter_sample) | 1551 if(s->quarter_sample) |
1552 { | 1552 { |
1626 } | 1626 } |
1627 pix_op[1][dxy](dest_cr + (dest_offset >> 1), ptr, uvlinesize, h >> 1); | 1627 pix_op[1][dxy](dest_cr + (dest_offset >> 1), ptr, uvlinesize, h >> 1); |
1628 } | 1628 } |
1629 | 1629 |
1630 static inline void qpel_motion(MpegEncContext *s, | 1630 static inline void qpel_motion(MpegEncContext *s, |
1631 UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr, | 1631 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, |
1632 int dest_offset, | 1632 int dest_offset, |
1633 UINT8 **ref_picture, int src_offset, | 1633 uint8_t **ref_picture, int src_offset, |
1634 int field_based, op_pixels_func (*pix_op)[4], | 1634 int field_based, op_pixels_func (*pix_op)[4], |
1635 qpel_mc_func (*qpix_op)[16], | 1635 qpel_mc_func (*qpix_op)[16], |
1636 int motion_x, int motion_y, int h) | 1636 int motion_x, int motion_y, int h) |
1637 { | 1637 { |
1638 UINT8 *ptr; | 1638 uint8_t *ptr; |
1639 int dxy, offset, mx, my, src_x, src_y, height, v_edge_pos, linesize, uvlinesize; | 1639 int dxy, offset, mx, my, src_x, src_y, height, v_edge_pos, linesize, uvlinesize; |
1640 int emu=0; | 1640 int emu=0; |
1641 | 1641 |
1642 dxy = ((motion_y & 3) << 2) | (motion_x & 3); | 1642 dxy = ((motion_y & 3) << 2) | (motion_x & 3); |
1643 src_x = s->mb_x * 16 + (motion_x >> 2); | 1643 src_x = s->mb_x * 16 + (motion_x >> 2); |
1733 return -(h263_chroma_roundtab[x & 0xf] + ((x >> 3) & ~1)); | 1733 return -(h263_chroma_roundtab[x & 0xf] + ((x >> 3) & ~1)); |
1734 } | 1734 } |
1735 } | 1735 } |
1736 | 1736 |
1737 static inline void MPV_motion(MpegEncContext *s, | 1737 static inline void MPV_motion(MpegEncContext *s, |
1738 UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr, | 1738 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, |
1739 int dir, UINT8 **ref_picture, | 1739 int dir, uint8_t **ref_picture, |
1740 op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16]) | 1740 op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16]) |
1741 { | 1741 { |
1742 int dxy, offset, mx, my, src_x, src_y, motion_x, motion_y; | 1742 int dxy, offset, mx, my, src_x, src_y, motion_x, motion_y; |
1743 int mb_x, mb_y, i; | 1743 int mb_x, mb_y, i; |
1744 UINT8 *ptr, *dest; | 1744 uint8_t *ptr, *dest; |
1745 int emu=0; | 1745 int emu=0; |
1746 | 1746 |
1747 mb_x = s->mb_x; | 1747 mb_x = s->mb_x; |
1748 mb_y = s->mb_y; | 1748 mb_y = s->mb_y; |
1749 | 1749 |
1914 } | 1914 } |
1915 | 1915 |
1916 | 1916 |
1917 /* put block[] to dest[] */ | 1917 /* put block[] to dest[] */ |
1918 static inline void put_dct(MpegEncContext *s, | 1918 static inline void put_dct(MpegEncContext *s, |
1919 DCTELEM *block, int i, UINT8 *dest, int line_size) | 1919 DCTELEM *block, int i, uint8_t *dest, int line_size) |
1920 { | 1920 { |
1921 s->dct_unquantize(s, block, i, s->qscale); | 1921 s->dct_unquantize(s, block, i, s->qscale); |
1922 s->idct_put (dest, line_size, block); | 1922 s->idct_put (dest, line_size, block); |
1923 } | 1923 } |
1924 | 1924 |
1925 /* add block[] to dest[] */ | 1925 /* add block[] to dest[] */ |
1926 static inline void add_dct(MpegEncContext *s, | 1926 static inline void add_dct(MpegEncContext *s, |
1927 DCTELEM *block, int i, UINT8 *dest, int line_size) | 1927 DCTELEM *block, int i, uint8_t *dest, int line_size) |
1928 { | 1928 { |
1929 if (s->block_last_index[i] >= 0) { | 1929 if (s->block_last_index[i] >= 0) { |
1930 s->idct_add (dest, line_size, block); | 1930 s->idct_add (dest, line_size, block); |
1931 } | 1931 } |
1932 } | 1932 } |
1933 | 1933 |
1934 static inline void add_dequant_dct(MpegEncContext *s, | 1934 static inline void add_dequant_dct(MpegEncContext *s, |
1935 DCTELEM *block, int i, UINT8 *dest, int line_size) | 1935 DCTELEM *block, int i, uint8_t *dest, int line_size) |
1936 { | 1936 { |
1937 if (s->block_last_index[i] >= 0) { | 1937 if (s->block_last_index[i] >= 0) { |
1938 s->dct_unquantize(s, block, i, s->qscale); | 1938 s->dct_unquantize(s, block, i, s->qscale); |
1939 | 1939 |
1940 s->idct_add (dest, line_size, block); | 1940 s->idct_add (dest, line_size, block); |
1952 s->dc_val[0][xy ] = | 1952 s->dc_val[0][xy ] = |
1953 s->dc_val[0][xy + 1 ] = | 1953 s->dc_val[0][xy + 1 ] = |
1954 s->dc_val[0][xy + wrap] = | 1954 s->dc_val[0][xy + wrap] = |
1955 s->dc_val[0][xy + 1 + wrap] = 1024; | 1955 s->dc_val[0][xy + 1 + wrap] = 1024; |
1956 /* ac pred */ | 1956 /* ac pred */ |
1957 memset(s->ac_val[0][xy ], 0, 32 * sizeof(INT16)); | 1957 memset(s->ac_val[0][xy ], 0, 32 * sizeof(int16_t)); |
1958 memset(s->ac_val[0][xy + wrap], 0, 32 * sizeof(INT16)); | 1958 memset(s->ac_val[0][xy + wrap], 0, 32 * sizeof(int16_t)); |
1959 if (s->msmpeg4_version>=3) { | 1959 if (s->msmpeg4_version>=3) { |
1960 s->coded_block[xy ] = | 1960 s->coded_block[xy ] = |
1961 s->coded_block[xy + 1 ] = | 1961 s->coded_block[xy + 1 ] = |
1962 s->coded_block[xy + wrap] = | 1962 s->coded_block[xy + wrap] = |
1963 s->coded_block[xy + 1 + wrap] = 0; | 1963 s->coded_block[xy + 1 + wrap] = 0; |
1966 wrap = s->block_wrap[4]; | 1966 wrap = s->block_wrap[4]; |
1967 xy = s->mb_x + 1 + (s->mb_y + 1) * wrap; | 1967 xy = s->mb_x + 1 + (s->mb_y + 1) * wrap; |
1968 s->dc_val[1][xy] = | 1968 s->dc_val[1][xy] = |
1969 s->dc_val[2][xy] = 1024; | 1969 s->dc_val[2][xy] = 1024; |
1970 /* ac pred */ | 1970 /* ac pred */ |
1971 memset(s->ac_val[1][xy], 0, 16 * sizeof(INT16)); | 1971 memset(s->ac_val[1][xy], 0, 16 * sizeof(int16_t)); |
1972 memset(s->ac_val[2][xy], 0, 16 * sizeof(INT16)); | 1972 memset(s->ac_val[2][xy], 0, 16 * sizeof(int16_t)); |
1973 | 1973 |
1974 s->mbintra_table[s->mb_x + s->mb_y*s->mb_width]= 0; | 1974 s->mbintra_table[s->mb_x + s->mb_y*s->mb_width]= 0; |
1975 } | 1975 } |
1976 | 1976 |
1977 /* generic function called after a macroblock has been parsed by the | 1977 /* generic function called after a macroblock has been parsed by the |
2051 s->motion_val[xy + 1 + wrap][1] = motion_y; | 2051 s->motion_val[xy + 1 + wrap][1] = motion_y; |
2052 } | 2052 } |
2053 } | 2053 } |
2054 | 2054 |
2055 if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc | 2055 if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc |
2056 UINT8 *dest_y, *dest_cb, *dest_cr; | 2056 uint8_t *dest_y, *dest_cb, *dest_cr; |
2057 int dct_linesize, dct_offset; | 2057 int dct_linesize, dct_offset; |
2058 op_pixels_func (*op_pix)[4]; | 2058 op_pixels_func (*op_pix)[4]; |
2059 qpel_mc_func (*op_qpix)[16]; | 2059 qpel_mc_func (*op_qpix)[16]; |
2060 | 2060 |
2061 /* avoid copy if macroblock skipped in last frame too */ | 2061 /* avoid copy if macroblock skipped in last frame too */ |
2063 s->current_picture.mbskip_table[mb_xy]= s->mb_skiped; | 2063 s->current_picture.mbskip_table[mb_xy]= s->mb_skiped; |
2064 } | 2064 } |
2065 | 2065 |
2066 /* skip only during decoding as we might trash the buffers during encoding a bit */ | 2066 /* skip only during decoding as we might trash the buffers during encoding a bit */ |
2067 if(!s->encoding){ | 2067 if(!s->encoding){ |
2068 UINT8 *mbskip_ptr = &s->mbskip_table[mb_xy]; | 2068 uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy]; |
2069 const int age= s->current_picture.age; | 2069 const int age= s->current_picture.age; |
2070 | 2070 |
2071 assert(age); | 2071 assert(age); |
2072 | 2072 |
2073 if (s->mb_skiped) { | 2073 if (s->mb_skiped) { |
2325 | 2325 |
2326 s->dquant+= newq - s->qscale; | 2326 s->dquant+= newq - s->qscale; |
2327 s->qscale= newq; | 2327 s->qscale= newq; |
2328 } | 2328 } |
2329 #if 0 | 2329 #if 0 |
2330 static int pix_vcmp16x8(UINT8 *s, int stride){ //FIXME move to dsputil & optimize | 2330 static int pix_vcmp16x8(uint8_t *s, int stride){ //FIXME move to dsputil & optimize |
2331 int score=0; | 2331 int score=0; |
2332 int x,y; | 2332 int x,y; |
2333 | 2333 |
2334 for(y=0; y<7; y++){ | 2334 for(y=0; y<7; y++){ |
2335 for(x=0; x<16; x+=4){ | 2335 for(x=0; x<16; x+=4){ |
2340 } | 2340 } |
2341 | 2341 |
2342 return score; | 2342 return score; |
2343 } | 2343 } |
2344 | 2344 |
2345 static int pix_diff_vcmp16x8(UINT8 *s1, UINT8*s2, int stride){ //FIXME move to dsputil & optimize | 2345 static int pix_diff_vcmp16x8(uint8_t *s1, uint8_t*s2, int stride){ //FIXME move to dsputil & optimize |
2346 int score=0; | 2346 int score=0; |
2347 int x,y; | 2347 int x,y; |
2348 | 2348 |
2349 for(y=0; y<7; y++){ | 2349 for(y=0; y<7; y++){ |
2350 for(x=0; x<16; x++){ | 2350 for(x=0; x<16; x++){ |
2357 return score; | 2357 return score; |
2358 } | 2358 } |
2359 #else | 2359 #else |
2360 #define SQ(a) ((a)*(a)) | 2360 #define SQ(a) ((a)*(a)) |
2361 | 2361 |
2362 static int pix_vcmp16x8(UINT8 *s, int stride){ //FIXME move to dsputil & optimize | 2362 static int pix_vcmp16x8(uint8_t *s, int stride){ //FIXME move to dsputil & optimize |
2363 int score=0; | 2363 int score=0; |
2364 int x,y; | 2364 int x,y; |
2365 | 2365 |
2366 for(y=0; y<7; y++){ | 2366 for(y=0; y<7; y++){ |
2367 for(x=0; x<16; x+=4){ | 2367 for(x=0; x<16; x+=4){ |
2372 } | 2372 } |
2373 | 2373 |
2374 return score; | 2374 return score; |
2375 } | 2375 } |
2376 | 2376 |
2377 static int pix_diff_vcmp16x8(UINT8 *s1, UINT8*s2, int stride){ //FIXME move to dsputil & optimize | 2377 static int pix_diff_vcmp16x8(uint8_t *s1, uint8_t*s2, int stride){ //FIXME move to dsputil & optimize |
2378 int score=0; | 2378 int score=0; |
2379 int x,y; | 2379 int x,y; |
2380 | 2380 |
2381 for(y=0; y<7; y++){ | 2381 for(y=0; y<7; y++){ |
2382 for(x=0; x<16; x++){ | 2382 for(x=0; x<16; x++){ |
2392 #endif | 2392 #endif |
2393 | 2393 |
2394 void ff_draw_horiz_band(MpegEncContext *s){ | 2394 void ff_draw_horiz_band(MpegEncContext *s){ |
2395 if ( s->avctx->draw_horiz_band | 2395 if ( s->avctx->draw_horiz_band |
2396 && (s->last_picture.data[0] || s->low_delay) ) { | 2396 && (s->last_picture.data[0] || s->low_delay) ) { |
2397 UINT8 *src_ptr[3]; | 2397 uint8_t *src_ptr[3]; |
2398 int y, h, offset; | 2398 int y, h, offset; |
2399 y = s->mb_y * 16; | 2399 y = s->mb_y * 16; |
2400 h = s->height - y; | 2400 h = s->height - y; |
2401 if (h > 16) | 2401 if (h > 16) |
2402 h = 16; | 2402 h = 16; |
2452 s->y_dc_scale= s->y_dc_scale_table[ s->qscale ]; | 2452 s->y_dc_scale= s->y_dc_scale_table[ s->qscale ]; |
2453 s->c_dc_scale= s->c_dc_scale_table[ s->qscale ]; | 2453 s->c_dc_scale= s->c_dc_scale_table[ s->qscale ]; |
2454 } | 2454 } |
2455 | 2455 |
2456 if (s->mb_intra) { | 2456 if (s->mb_intra) { |
2457 UINT8 *ptr; | 2457 uint8_t *ptr; |
2458 int wrap_y; | 2458 int wrap_y; |
2459 int emu=0; | 2459 int emu=0; |
2460 | 2460 |
2461 wrap_y = s->linesize; | 2461 wrap_y = s->linesize; |
2462 ptr = s->new_picture.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16; | 2462 ptr = s->new_picture.data[0] + (mb_y * 16 * wrap_y) + mb_x * 16; |
2507 s->dsp.get_pixels(s->block[5], ptr, wrap_c); | 2507 s->dsp.get_pixels(s->block[5], ptr, wrap_c); |
2508 } | 2508 } |
2509 }else{ | 2509 }else{ |
2510 op_pixels_func (*op_pix)[4]; | 2510 op_pixels_func (*op_pix)[4]; |
2511 qpel_mc_func (*op_qpix)[16]; | 2511 qpel_mc_func (*op_qpix)[16]; |
2512 UINT8 *dest_y, *dest_cb, *dest_cr; | 2512 uint8_t *dest_y, *dest_cb, *dest_cr; |
2513 UINT8 *ptr_y, *ptr_cb, *ptr_cr; | 2513 uint8_t *ptr_y, *ptr_cb, *ptr_cr; |
2514 int wrap_y, wrap_c; | 2514 int wrap_y, wrap_c; |
2515 int emu=0; | 2515 int emu=0; |
2516 | 2516 |
2517 dest_y = s->current_picture.data[0] + (mb_y * 16 * s->linesize ) + mb_x * 16; | 2517 dest_y = s->current_picture.data[0] + (mb_y * 16 * s->linesize ) + mb_x * 16; |
2518 dest_cb = s->current_picture.data[1] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; | 2518 dest_cb = s->current_picture.data[1] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8; |
2712 } | 2712 } |
2713 | 2713 |
2714 return 0; | 2714 return 0; |
2715 } | 2715 } |
2716 | 2716 |
2717 void ff_copy_bits(PutBitContext *pb, UINT8 *src, int length) | 2717 void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length) |
2718 { | 2718 { |
2719 int bytes= length>>4; | 2719 int bytes= length>>4; |
2720 int bits= length&15; | 2720 int bits= length&15; |
2721 int i; | 2721 int i; |
2722 | 2722 |
2844 { | 2844 { |
2845 int mb_x, mb_y, pdif = 0; | 2845 int mb_x, mb_y, pdif = 0; |
2846 int i; | 2846 int i; |
2847 int bits; | 2847 int bits; |
2848 MpegEncContext best_s, backup_s; | 2848 MpegEncContext best_s, backup_s; |
2849 UINT8 bit_buf[2][3000]; | 2849 uint8_t bit_buf[2][3000]; |
2850 UINT8 bit_buf2[2][3000]; | 2850 uint8_t bit_buf2[2][3000]; |
2851 UINT8 bit_buf_tex[2][3000]; | 2851 uint8_t bit_buf_tex[2][3000]; |
2852 PutBitContext pb[2], pb2[2], tex_pb[2]; | 2852 PutBitContext pb[2], pb2[2], tex_pb[2]; |
2853 | 2853 |
2854 for(i=0; i<2; i++){ | 2854 for(i=0; i<2; i++){ |
2855 init_put_bits(&pb [i], bit_buf [i], 3000, NULL, NULL); | 2855 init_put_bits(&pb [i], bit_buf [i], 3000, NULL, NULL); |
2856 init_put_bits(&pb2 [i], bit_buf2 [i], 3000, NULL, NULL); | 2856 init_put_bits(&pb2 [i], bit_buf2 [i], 3000, NULL, NULL); |
2933 } | 2933 } |
2934 } | 2934 } |
2935 }else /* if(s->pict_type == I_TYPE) */{ | 2935 }else /* if(s->pict_type == I_TYPE) */{ |
2936 /* I-Frame */ | 2936 /* I-Frame */ |
2937 //FIXME do we need to zero them? | 2937 //FIXME do we need to zero them? |
2938 memset(s->motion_val[0], 0, sizeof(INT16)*(s->mb_width*2 + 2)*(s->mb_height*2 + 2)*2); | 2938 memset(s->motion_val[0], 0, sizeof(int16_t)*(s->mb_width*2 + 2)*(s->mb_height*2 + 2)*2); |
2939 memset(s->p_mv_table , 0, sizeof(INT16)*(s->mb_width+2)*(s->mb_height+2)*2); | 2939 memset(s->p_mv_table , 0, sizeof(int16_t)*(s->mb_width+2)*(s->mb_height+2)*2); |
2940 memset(s->mb_type , MB_TYPE_INTRA, sizeof(UINT8)*s->mb_width*s->mb_height); | 2940 memset(s->mb_type , MB_TYPE_INTRA, sizeof(uint8_t)*s->mb_width*s->mb_height); |
2941 | 2941 |
2942 if(!s->fixed_qscale){ | 2942 if(!s->fixed_qscale){ |
2943 /* finding spatial complexity for I-frame rate control */ | 2943 /* finding spatial complexity for I-frame rate control */ |
2944 for(mb_y=0; mb_y < s->mb_height; mb_y++) { | 2944 for(mb_y=0; mb_y < s->mb_height; mb_y++) { |
2945 for(mb_x=0; mb_x < s->mb_width; mb_x++) { | 2945 for(mb_x=0; mb_x < s->mb_width; mb_x++) { |
2960 } | 2960 } |
2961 emms_c(); | 2961 emms_c(); |
2962 | 2962 |
2963 if(s->scene_change_score > 0 && s->pict_type == P_TYPE){ | 2963 if(s->scene_change_score > 0 && s->pict_type == P_TYPE){ |
2964 s->pict_type= I_TYPE; | 2964 s->pict_type= I_TYPE; |
2965 memset(s->mb_type , MB_TYPE_INTRA, sizeof(UINT8)*s->mb_width*s->mb_height); | 2965 memset(s->mb_type , MB_TYPE_INTRA, sizeof(uint8_t)*s->mb_width*s->mb_height); |
2966 //printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum); | 2966 //printf("Scene change detected, encoding as I Frame %d %d\n", s->current_picture.mb_var_sum, s->current_picture.mc_mb_var_sum); |
2967 } | 2967 } |
2968 | 2968 |
2969 if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) { | 2969 if(s->pict_type==P_TYPE || s->pict_type==S_TYPE) { |
2970 s->f_code= ff_get_best_fcode(s, s->p_mv_table, MB_TYPE_INTER); | 2970 s->f_code= ff_get_best_fcode(s, s->p_mv_table, MB_TYPE_INTER); |
3504 | 3504 |
3505 static int dct_quantize_trellis_c(MpegEncContext *s, | 3505 static int dct_quantize_trellis_c(MpegEncContext *s, |
3506 DCTELEM *block, int n, | 3506 DCTELEM *block, int n, |
3507 int qscale, int *overflow){ | 3507 int qscale, int *overflow){ |
3508 const int *qmat; | 3508 const int *qmat; |
3509 const UINT8 *scantable= s->intra_scantable.scantable; | 3509 const uint8_t *scantable= s->intra_scantable.scantable; |
3510 int max=0; | 3510 int max=0; |
3511 unsigned int threshold1, threshold2; | 3511 unsigned int threshold1, threshold2; |
3512 int bias=0; | 3512 int bias=0; |
3513 int run_tab[65]; | 3513 int run_tab[65]; |
3514 int level_tab[65]; | 3514 int level_tab[65]; |
3754 DCTELEM *block, int n, | 3754 DCTELEM *block, int n, |
3755 int qscale, int *overflow) | 3755 int qscale, int *overflow) |
3756 { | 3756 { |
3757 int i, j, level, last_non_zero, q; | 3757 int i, j, level, last_non_zero, q; |
3758 const int *qmat; | 3758 const int *qmat; |
3759 const UINT8 *scantable= s->intra_scantable.scantable; | 3759 const uint8_t *scantable= s->intra_scantable.scantable; |
3760 int bias; | 3760 int bias; |
3761 int max=0; | 3761 int max=0; |
3762 unsigned int threshold1, threshold2; | 3762 unsigned int threshold1, threshold2; |
3763 | 3763 |
3764 s->fdct (block); | 3764 s->fdct (block); |
3821 | 3821 |
3822 static void dct_unquantize_mpeg1_c(MpegEncContext *s, | 3822 static void dct_unquantize_mpeg1_c(MpegEncContext *s, |
3823 DCTELEM *block, int n, int qscale) | 3823 DCTELEM *block, int n, int qscale) |
3824 { | 3824 { |
3825 int i, level, nCoeffs; | 3825 int i, level, nCoeffs; |
3826 const UINT16 *quant_matrix; | 3826 const uint16_t *quant_matrix; |
3827 | 3827 |
3828 nCoeffs= s->block_last_index[n]; | 3828 nCoeffs= s->block_last_index[n]; |
3829 | 3829 |
3830 if (s->mb_intra) { | 3830 if (s->mb_intra) { |
3831 if (n < 4) | 3831 if (n < 4) |
3884 | 3884 |
3885 static void dct_unquantize_mpeg2_c(MpegEncContext *s, | 3885 static void dct_unquantize_mpeg2_c(MpegEncContext *s, |
3886 DCTELEM *block, int n, int qscale) | 3886 DCTELEM *block, int n, int qscale) |
3887 { | 3887 { |
3888 int i, level, nCoeffs; | 3888 int i, level, nCoeffs; |
3889 const UINT16 *quant_matrix; | 3889 const uint16_t *quant_matrix; |
3890 | 3890 |
3891 if(s->alternate_scan) nCoeffs= 63; | 3891 if(s->alternate_scan) nCoeffs= 63; |
3892 else nCoeffs= s->block_last_index[n]; | 3892 else nCoeffs= s->block_last_index[n]; |
3893 | 3893 |
3894 if (s->mb_intra) { | 3894 if (s->mb_intra) { |