comparison mpegvideo.c @ 556:762c67fd4078 libavcodec

uvlinesize export has_b_frames mb_skip with more than 2 ip buffers
author michaelni
date Mon, 15 Jul 2002 14:15:10 +0000
parents 3eb6fe38019a
children c1e1be461662
comparison
equal deleted inserted replaced
555:fe951e388d34 556:762c67fd4078
143 143
144 s->mb_width = (s->width + 15) / 16; 144 s->mb_width = (s->width + 15) / 16;
145 s->mb_height = (s->height + 15) / 16; 145 s->mb_height = (s->height + 15) / 16;
146 s->mb_num = s->mb_width * s->mb_height; 146 s->mb_num = s->mb_width * s->mb_height;
147 if(!(s->flags&CODEC_FLAG_DR1)){ 147 if(!(s->flags&CODEC_FLAG_DR1)){
148 s->linesize = s->mb_width * 16 + 2 * EDGE_WIDTH; 148 s->linesize = s->mb_width * 16 + 2 * EDGE_WIDTH;
149 s->uvlinesize = s->mb_width * 8 + EDGE_WIDTH;
149 150
150 for(i=0;i<3;i++) { 151 for(i=0;i<3;i++) {
151 int w, h, shift, pict_start; 152 int w, h, shift, pict_start;
152 153
153 w = s->linesize; 154 w = s->linesize;
154 h = s->mb_height * 16 + 2 * EDGE_WIDTH; 155 h = s->mb_height * 16 + 2 * EDGE_WIDTH;
155 shift = (i == 0) ? 0 : 1; 156 shift = (i == 0) ? 0 : 1;
156 c_size = (w >> shift) * (h >> shift); 157 c_size = (s->linesize>>shift) * (h >> shift);
157 pict_start = (w >> shift) * (EDGE_WIDTH >> shift) + (EDGE_WIDTH >> shift); 158 pict_start = (s->linesize>>shift) * (EDGE_WIDTH >> shift) + (EDGE_WIDTH >> shift);
158 159
159 CHECKED_ALLOCZ(pict, c_size) 160 CHECKED_ALLOCZ(pict, c_size)
160 s->last_picture_base[i] = pict; 161 s->last_picture_base[i] = pict;
161 s->last_picture[i] = pict + pict_start; 162 s->last_picture[i] = pict + pict_start;
162 if(i>0) memset(s->last_picture_base[i], 128, c_size); 163 if(i>0) memset(s->last_picture_base[i], 128, c_size);
173 s->aux_picture_base[i] = pict; 174 s->aux_picture_base[i] = pict;
174 s->aux_picture[i] = pict + pict_start; 175 s->aux_picture[i] = pict + pict_start;
175 if(i>0) memset(s->aux_picture_base[i], 128, c_size); 176 if(i>0) memset(s->aux_picture_base[i], 128, c_size);
176 } 177 }
177 } 178 }
179 s->ip_buffer_count= 2;
178 } 180 }
179 181
180 CHECKED_ALLOCZ(s->edge_emu_buffer, (s->width+32)*2*17); 182 CHECKED_ALLOCZ(s->edge_emu_buffer, (s->width+32)*2*17);
181 183
182 if (s->encoding) { 184 if (s->encoding) {
620 622
621 if(avctx->flags&CODEC_FLAG_DR1){ 623 if(avctx->flags&CODEC_FLAG_DR1){
622 int i; 624 int i;
623 avctx->get_buffer_callback(avctx, s->width, s->height, s->pict_type); 625 avctx->get_buffer_callback(avctx, s->width, s->height, s->pict_type);
624 626
625 s->linesize= avctx->dr_stride; 627 s->linesize = avctx->dr_stride;
628 s->uvlinesize= avctx->dr_uvstride;
629 s->ip_buffer_count= avctx->dr_ip_buffer_count;
626 } 630 }
627 631
628 if (s->pict_type == B_TYPE) { 632 if (s->pict_type == B_TYPE) {
629 for(i=0;i<3;i++) { 633 for(i=0;i<3;i++) {
630 if(avctx->flags&CODEC_FLAG_DR1) 634 if(avctx->flags&CODEC_FLAG_DR1)
662 666
663 /* draw edge for correct motion prediction if outside */ 667 /* draw edge for correct motion prediction if outside */
664 if (s->pict_type != B_TYPE && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) { 668 if (s->pict_type != B_TYPE && !s->intra_only && !(s->flags&CODEC_FLAG_EMU_EDGE)) {
665 if(s->avctx==NULL || s->avctx->codec->id!=CODEC_ID_MPEG4 || s->divx_version>=500){ 669 if(s->avctx==NULL || s->avctx->codec->id!=CODEC_ID_MPEG4 || s->divx_version>=500){
666 draw_edges(s->current_picture[0], s->linesize, s->mb_width*16, s->mb_height*16, EDGE_WIDTH); 670 draw_edges(s->current_picture[0], s->linesize, s->mb_width*16, s->mb_height*16, EDGE_WIDTH);
667 draw_edges(s->current_picture[1], s->linesize/2, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2); 671 draw_edges(s->current_picture[1], s->uvlinesize, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2);
668 draw_edges(s->current_picture[2], s->linesize/2, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2); 672 draw_edges(s->current_picture[2], s->uvlinesize, s->mb_width*8, s->mb_height*8, EDGE_WIDTH/2);
669 }else{ 673 }else{
670 /* mpeg4? / opendivx / xvid */ 674 /* mpeg4? / opendivx / xvid */
671 draw_edges(s->current_picture[0], s->linesize, s->width, s->height, EDGE_WIDTH); 675 draw_edges(s->current_picture[0], s->linesize, s->width, s->height, EDGE_WIDTH);
672 draw_edges(s->current_picture[1], s->linesize/2, s->width/2, s->height/2, EDGE_WIDTH/2); 676 draw_edges(s->current_picture[1], s->uvlinesize, s->width/2, s->height/2, EDGE_WIDTH/2);
673 draw_edges(s->current_picture[2], s->linesize/2, s->width/2, s->height/2, EDGE_WIDTH/2); 677 draw_edges(s->current_picture[2], s->uvlinesize, s->width/2, s->height/2, EDGE_WIDTH/2);
674 } 678 }
675 } 679 }
676 emms_c(); 680 emms_c();
677 681
678 if(s->pict_type!=B_TYPE){ 682 if(s->pict_type!=B_TYPE){
713 break; 717 break;
714 } 718 }
715 //printf("index:%d type:%d strides: %d %d\n", index, s->input_pict_type, pict->linesize[0], s->linesize); 719 //printf("index:%d type:%d strides: %d %d\n", index, s->input_pict_type, pict->linesize[0], s->linesize);
716 if( (index==0 || (s->flags&CODEC_FLAG_INPUT_PRESERVED)) 720 if( (index==0 || (s->flags&CODEC_FLAG_INPUT_PRESERVED))
717 && pict->linesize[0] == s->linesize 721 && pict->linesize[0] == s->linesize
718 && pict->linesize[1] == s->linesize>>1 722 && pict->linesize[1] == s->uvlinesize
719 && pict->linesize[2] == s->linesize>>1){ 723 && pict->linesize[2] == s->uvlinesize){
720 //printf("ptr\n"); 724 //printf("ptr\n");
721 for(i=0; i<3; i++){ 725 for(i=0; i<3; i++){
722 s->coded_order[index].picture[i]= pict->data[i]; 726 s->coded_order[index].picture[i]= pict->data[i];
723 } 727 }
724 }else{ 728 }else{
868 int dest_offset, 872 int dest_offset,
869 UINT8 **ref_picture, int src_offset, 873 UINT8 **ref_picture, int src_offset,
870 int h) 874 int h)
871 { 875 {
872 UINT8 *ptr; 876 UINT8 *ptr;
873 int offset, src_x, src_y, linesize; 877 int offset, src_x, src_y, linesize, uvlinesize;
874 int motion_x, motion_y; 878 int motion_x, motion_y;
875 879
876 if(s->real_sprite_warping_points>1) printf("more than 1 warp point isnt supported\n"); 880 if(s->real_sprite_warping_points>1) printf("more than 1 warp point isnt supported\n");
877 motion_x= s->sprite_offset[0][0]; 881 motion_x= s->sprite_offset[0][0];
878 motion_y= s->sprite_offset[0][1]; 882 motion_y= s->sprite_offset[0][1];
886 src_y = clip(src_y, -16, s->height); 890 src_y = clip(src_y, -16, s->height);
887 if (src_y == s->height) 891 if (src_y == s->height)
888 motion_y =0; 892 motion_y =0;
889 893
890 linesize = s->linesize; 894 linesize = s->linesize;
895 uvlinesize = s->uvlinesize;
891 ptr = ref_picture[0] + (src_y * linesize) + src_x + src_offset; 896 ptr = ref_picture[0] + (src_y * linesize) + src_x + src_offset;
892 897
893 dest_y+=dest_offset; 898 dest_y+=dest_offset;
894 gmc1(dest_y , ptr , linesize, h, motion_x&15, motion_y&15, s->no_rounding); 899 gmc1(dest_y , ptr , linesize, h, motion_x&15, motion_y&15, s->no_rounding);
895 gmc1(dest_y+8, ptr+8, linesize, h, motion_x&15, motion_y&15, s->no_rounding); 900 gmc1(dest_y+8, ptr+8, linesize, h, motion_x&15, motion_y&15, s->no_rounding);
905 motion_x =0; 910 motion_x =0;
906 src_y = clip(src_y, -8, s->height>>1); 911 src_y = clip(src_y, -8, s->height>>1);
907 if (src_y == s->height>>1) 912 if (src_y == s->height>>1)
908 motion_y =0; 913 motion_y =0;
909 914
910 offset = (src_y * linesize>>1) + src_x + (src_offset>>1); 915 offset = (src_y * uvlinesize) + src_x + (src_offset>>1);
911 ptr = ref_picture[1] + offset; 916 ptr = ref_picture[1] + offset;
912 gmc1(dest_cb + (dest_offset>>1), ptr, linesize>>1, h>>1, motion_x&15, motion_y&15, s->no_rounding); 917 gmc1(dest_cb + (dest_offset>>1), ptr, uvlinesize, h>>1, motion_x&15, motion_y&15, s->no_rounding);
913 ptr = ref_picture[2] + offset; 918 ptr = ref_picture[2] + offset;
914 gmc1(dest_cr + (dest_offset>>1), ptr, linesize>>1, h>>1, motion_x&15, motion_y&15, s->no_rounding); 919 gmc1(dest_cr + (dest_offset>>1), ptr, uvlinesize, h>>1, motion_x&15, motion_y&15, s->no_rounding);
915 920
916 return; 921 return;
917 } 922 }
918 923
919 static void emulated_edge_mc(UINT8 *buf, UINT8 *src, int linesize, int block_w, int block_h, 924 static void emulated_edge_mc(UINT8 *buf, UINT8 *src, int linesize, int block_w, int block_h,
1045 dxy &= ~1; 1050 dxy &= ~1;
1046 src_y = clip(src_y, -8, height >> 1); 1051 src_y = clip(src_y, -8, height >> 1);
1047 if (src_y == (height >> 1)) 1052 if (src_y == (height >> 1))
1048 dxy &= ~2; 1053 dxy &= ~2;
1049 1054
1050 offset = (src_y * (linesize >> 1)) + src_x + (src_offset >> 1); 1055 offset = (src_y * s->uvlinesize) + src_x + (src_offset >> 1);
1051 ptr = ref_picture[1] + offset; 1056 ptr = ref_picture[1] + offset;
1052 if(emu){ 1057 if(emu){
1053 emulated_edge_mc(s->edge_emu_buffer, ptr, linesize>>1, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); 1058 emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1);
1054 ptr= s->edge_emu_buffer; 1059 ptr= s->edge_emu_buffer;
1055 } 1060 }
1056 pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); 1061 pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1);
1057 1062
1058 ptr = ref_picture[2] + offset; 1063 ptr = ref_picture[2] + offset;
1059 if(emu){ 1064 if(emu){
1060 emulated_edge_mc(s->edge_emu_buffer, ptr, linesize>>1, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); 1065 emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1);
1061 ptr= s->edge_emu_buffer; 1066 ptr= s->edge_emu_buffer;
1062 } 1067 }
1063 pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); 1068 pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1);
1064 } 1069 }
1065 1070
1066 static inline void qpel_motion(MpegEncContext *s, 1071 static inline void qpel_motion(MpegEncContext *s,
1067 UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr, 1072 UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
1068 int dest_offset, 1073 int dest_offset,
1124 dxy &= ~1; 1129 dxy &= ~1;
1125 src_y = clip(src_y, -8, height >> 1); 1130 src_y = clip(src_y, -8, height >> 1);
1126 if (src_y == (height >> 1)) 1131 if (src_y == (height >> 1))
1127 dxy &= ~2; 1132 dxy &= ~2;
1128 1133
1129 offset = (src_y * (linesize >> 1)) + src_x + (src_offset >> 1); 1134 offset = (src_y * s->uvlinesize) + src_x + (src_offset >> 1);
1130 ptr = ref_picture[1] + offset; 1135 ptr = ref_picture[1] + offset;
1131 if(emu){ 1136 if(emu){
1132 emulated_edge_mc(s->edge_emu_buffer, ptr, linesize>>1, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); 1137 emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1);
1133 ptr= s->edge_emu_buffer; 1138 ptr= s->edge_emu_buffer;
1134 } 1139 }
1135 pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); 1140 pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1);
1136 1141
1137 ptr = ref_picture[2] + offset; 1142 ptr = ref_picture[2] + offset;
1138 if(emu){ 1143 if(emu){
1139 emulated_edge_mc(s->edge_emu_buffer, ptr, linesize>>1, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1); 1144 emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->width>>1, height>>1);
1140 ptr= s->edge_emu_buffer; 1145 ptr= s->edge_emu_buffer;
1141 } 1146 }
1142 pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, linesize >> 1, h >> 1); 1147 pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1);
1143 } 1148 }
1144 1149
1145 1150
1146 static inline void MPV_motion(MpegEncContext *s, 1151 static inline void MPV_motion(MpegEncContext *s,
1147 UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr, 1152 UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
1244 dxy &= ~1; 1249 dxy &= ~1;
1245 src_y = clip(src_y, -8, s->height/2); 1250 src_y = clip(src_y, -8, s->height/2);
1246 if (src_y == s->height/2) 1251 if (src_y == s->height/2)
1247 dxy &= ~2; 1252 dxy &= ~2;
1248 1253
1249 offset = (src_y * (s->linesize >> 1)) + src_x; 1254 offset = (src_y * (s->uvlinesize)) + src_x;
1250 ptr = ref_picture[1] + offset; 1255 ptr = ref_picture[1] + offset;
1251 if(s->flags&CODEC_FLAG_EMU_EDGE){ 1256 if(s->flags&CODEC_FLAG_EMU_EDGE){
1252 if(src_x<0 || src_y<0 || src_x + (dxy &1) + 8 > s->width >>1 1257 if(src_x<0 || src_y<0 || src_x + (dxy &1) + 8 > s->width >>1
1253 || src_y + (dxy>>1) + 8 > s->height>>1){ 1258 || src_y + (dxy>>1) + 8 > s->height>>1){
1254 emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize>>1, 9, 9, src_x, src_y, s->width>>1, s->height>>1); 1259 emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->width>>1, s->height>>1);
1255 ptr= s->edge_emu_buffer; 1260 ptr= s->edge_emu_buffer;
1256 emu=1; 1261 emu=1;
1257 } 1262 }
1258 } 1263 }
1259 pix_op[dxy](dest_cb, ptr, s->linesize >> 1, 8); 1264 pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8);
1260 1265
1261 ptr = ref_picture[2] + offset; 1266 ptr = ref_picture[2] + offset;
1262 if(emu){ 1267 if(emu){
1263 emulated_edge_mc(s->edge_emu_buffer, ptr, s->linesize>>1, 9, 9, src_x, src_y, s->width>>1, s->height>>1); 1268 emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->width>>1, s->height>>1);
1264 ptr= s->edge_emu_buffer; 1269 ptr= s->edge_emu_buffer;
1265 } 1270 }
1266 pix_op[dxy](dest_cr, ptr, s->linesize >> 1, 8); 1271 pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
1267 break; 1272 break;
1268 case MV_TYPE_FIELD: 1273 case MV_TYPE_FIELD:
1269 if (s->picture_structure == PICT_FRAME) { 1274 if (s->picture_structure == PICT_FRAME) {
1270 /* top field */ 1275 /* top field */
1271 mpeg_motion(s, dest_y, dest_cb, dest_cr, 0, 1276 mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
1423 dont touch it for B-frames as they need the skip info from the next p-frame */ 1428 dont touch it for B-frames as they need the skip info from the next p-frame */
1424 if (s->pict_type != B_TYPE) { 1429 if (s->pict_type != B_TYPE) {
1425 UINT8 *mbskip_ptr = &s->mbskip_table[mb_xy]; 1430 UINT8 *mbskip_ptr = &s->mbskip_table[mb_xy];
1426 if (s->mb_skiped) { 1431 if (s->mb_skiped) {
1427 s->mb_skiped = 0; 1432 s->mb_skiped = 0;
1433
1434 (*mbskip_ptr) ++; /* indicate that this time we skiped it */
1435 if(*mbskip_ptr >99) *mbskip_ptr= 99;
1436
1428 /* if previous was skipped too, then nothing to do ! 1437 /* if previous was skipped too, then nothing to do !
1429 skip only during decoding as we might trash the buffers during encoding a bit */ 1438 skip only during decoding as we might trash the buffers during encoding a bit */
1430 if (*mbskip_ptr != 0 && !s->encoding) 1439 if (*mbskip_ptr >= s->ip_buffer_count && !s->encoding)
1431 goto the_end; 1440 goto the_end;
1432 *mbskip_ptr = 1; /* indicate that this time we skiped it */
1433 } else { 1441 } else {
1434 *mbskip_ptr = 0; /* not skipped */ 1442 *mbskip_ptr = 0; /* not skipped */
1435 } 1443 }
1436 } 1444 }
1437 1445
1438 dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize) + mb_x * 16; 1446 dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize) + mb_x * 16;
1439 dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; 1447 dest_cb = s->current_picture[1] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8;
1440 dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; 1448 dest_cr = s->current_picture[2] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8;
1441 1449
1442 if (s->interlaced_dct) { 1450 if (s->interlaced_dct) {
1443 dct_linesize = s->linesize * 2; 1451 dct_linesize = s->linesize * 2;
1444 dct_offset = s->linesize; 1452 dct_offset = s->linesize;
1445 } else { 1453 } else {
1480 add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize); 1488 add_dequant_dct(s, block[1], 1, dest_y + 8, dct_linesize);
1481 add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 1489 add_dequant_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
1482 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 1490 add_dequant_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
1483 1491
1484 if(!(s->flags&CODEC_FLAG_GRAY)){ 1492 if(!(s->flags&CODEC_FLAG_GRAY)){
1485 add_dequant_dct(s, block[4], 4, dest_cb, s->linesize >> 1); 1493 add_dequant_dct(s, block[4], 4, dest_cb, s->uvlinesize);
1486 add_dequant_dct(s, block[5], 5, dest_cr, s->linesize >> 1); 1494 add_dequant_dct(s, block[5], 5, dest_cr, s->uvlinesize);
1487 } 1495 }
1488 } else { 1496 } else {
1489 add_dct(s, block[0], 0, dest_y, dct_linesize); 1497 add_dct(s, block[0], 0, dest_y, dct_linesize);
1490 add_dct(s, block[1], 1, dest_y + 8, dct_linesize); 1498 add_dct(s, block[1], 1, dest_y + 8, dct_linesize);
1491 add_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 1499 add_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
1492 add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 1500 add_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
1493 1501
1494 if(!(s->flags&CODEC_FLAG_GRAY)){ 1502 if(!(s->flags&CODEC_FLAG_GRAY)){
1495 add_dct(s, block[4], 4, dest_cb, s->linesize >> 1); 1503 add_dct(s, block[4], 4, dest_cb, s->uvlinesize);
1496 add_dct(s, block[5], 5, dest_cr, s->linesize >> 1); 1504 add_dct(s, block[5], 5, dest_cr, s->uvlinesize);
1497 } 1505 }
1498 } 1506 }
1499 } else { 1507 } else {
1500 /* dct only in intra block */ 1508 /* dct only in intra block */
1501 put_dct(s, block[0], 0, dest_y, dct_linesize); 1509 put_dct(s, block[0], 0, dest_y, dct_linesize);
1502 put_dct(s, block[1], 1, dest_y + 8, dct_linesize); 1510 put_dct(s, block[1], 1, dest_y + 8, dct_linesize);
1503 put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize); 1511 put_dct(s, block[2], 2, dest_y + dct_offset, dct_linesize);
1504 put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize); 1512 put_dct(s, block[3], 3, dest_y + dct_offset + 8, dct_linesize);
1505 1513
1506 if(!(s->flags&CODEC_FLAG_GRAY)){ 1514 if(!(s->flags&CODEC_FLAG_GRAY)){
1507 put_dct(s, block[4], 4, dest_cb, s->linesize >> 1); 1515 put_dct(s, block[4], 4, dest_cb, s->uvlinesize);
1508 put_dct(s, block[5], 5, dest_cr, s->linesize >> 1); 1516 put_dct(s, block[5], 5, dest_cr, s->uvlinesize);
1509 } 1517 }
1510 } 1518 }
1511 } 1519 }
1512 the_end: 1520 the_end:
1513 emms_c(); //FIXME remove 1521 emms_c(); //FIXME remove
1618 UINT8 *dest_y, *dest_cb, *dest_cr; 1626 UINT8 *dest_y, *dest_cb, *dest_cr;
1619 UINT8 *ptr_y, *ptr_cb, *ptr_cr; 1627 UINT8 *ptr_y, *ptr_cb, *ptr_cr;
1620 int wrap_y, wrap_c; 1628 int wrap_y, wrap_c;
1621 1629
1622 dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize ) + mb_x * 16; 1630 dest_y = s->current_picture[0] + (mb_y * 16 * s->linesize ) + mb_x * 16;
1623 dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; 1631 dest_cb = s->current_picture[1] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8;
1624 dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; 1632 dest_cr = s->current_picture[2] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8;
1625 wrap_y = s->linesize; 1633 wrap_y = s->linesize;
1626 wrap_c = wrap_y>>1; 1634 wrap_c = wrap_y>>1;
1627 ptr_y = s->new_picture[0] + (mb_y * 16 * wrap_y) + mb_x * 16; 1635 ptr_y = s->new_picture[0] + (mb_y * 16 * wrap_y) + mb_x * 16;
1628 ptr_cb = s->new_picture[1] + (mb_y * 8 * wrap_c) + mb_x * 8; 1636 ptr_cb = s->new_picture[1] + (mb_y * 8 * wrap_c) + mb_x * 8;
1629 ptr_cr = s->new_picture[2] + (mb_y * 8 * wrap_c) + mb_x * 8; 1637 ptr_cr = s->new_picture[2] + (mb_y * 8 * wrap_c) + mb_x * 8;
2564 dcb = s->dc_val[1][mb_x+1 + (mb_y+1)*(s->mb_width+2)]; 2572 dcb = s->dc_val[1][mb_x+1 + (mb_y+1)*(s->mb_width+2)];
2565 dcr= s->dc_val[2][mb_x+1 + (mb_y+1)*(s->mb_width+2)]; 2573 dcr= s->dc_val[2][mb_x+1 + (mb_y+1)*(s->mb_width+2)];
2566 for(y=0; y<8; y++){ 2574 for(y=0; y<8; y++){
2567 int x; 2575 int x;
2568 for(x=0; x<8; x++){ 2576 for(x=0; x<8; x++){
2569 dest_cb[x + y*(s->linesize>>1)]= dcb/8; 2577 dest_cb[x + y*(s->uvlinesize)]= dcb/8;
2570 dest_cr[x + y*(s->linesize>>1)]= dcr/8; 2578 dest_cr[x + y*(s->uvlinesize)]= dcr/8;
2571 } 2579 }
2572 } 2580 }
2573 } 2581 }
2574 2582
2575 /** 2583 /**
2620 2628
2621 /* for all MBs from the current one back until the last resync marker */ 2629 /* for all MBs from the current one back until the last resync marker */
2622 for(; mb_y>=0 && mb_y>=s->resync_mb_y; mb_y--){ 2630 for(; mb_y>=0 && mb_y>=s->resync_mb_y; mb_y--){
2623 for(; mb_x>=0; mb_x--){ 2631 for(; mb_x>=0; mb_x--){
2624 uint8_t *dest_y = s->current_picture[0] + (mb_y * 16* s->linesize ) + mb_x * 16; 2632 uint8_t *dest_y = s->current_picture[0] + (mb_y * 16* s->linesize ) + mb_x * 16;
2625 uint8_t *dest_cb = s->current_picture[1] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; 2633 uint8_t *dest_cb = s->current_picture[1] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8;
2626 uint8_t *dest_cr = s->current_picture[2] + (mb_y * 8 * (s->linesize >> 1)) + mb_x * 8; 2634 uint8_t *dest_cr = s->current_picture[2] + (mb_y * 8 * (s->uvlinesize)) + mb_x * 8;
2627 int mb_x_backup= s->mb_x; //FIXME pass xy to mpeg_motion 2635 int mb_x_backup= s->mb_x; //FIXME pass xy to mpeg_motion
2628 int mb_y_backup= s->mb_y; 2636 int mb_y_backup= s->mb_y;
2629 s->mb_x=mb_x; 2637 s->mb_x=mb_x;
2630 s->mb_y=mb_y; 2638 s->mb_y=mb_y;
2631 if(s->mbintra_table[mb_y*s->mb_width + mb_x] && mb_dist<intra_conceal){ 2639 if(s->mbintra_table[mb_y*s->mb_width + mb_x] && mb_dist<intra_conceal){