Mercurial > libavcodec.hg
comparison mpegvideo.c @ 1685:cb09cf265a87 libavcodec
mb type & qp vissualization
author | michael |
---|---|
date | Sat, 13 Dec 2003 01:33:52 +0000 |
parents | 19e781619e3f |
children | 68abbec33289 |
comparison
equal
deleted
inserted
replaced
1684:19e781619e3f | 1685:cb09cf265a87 |
---|---|
1411 } | 1411 } |
1412 av_log(s->avctx, AV_LOG_DEBUG, "\n"); | 1412 av_log(s->avctx, AV_LOG_DEBUG, "\n"); |
1413 } | 1413 } |
1414 } | 1414 } |
1415 | 1415 |
1416 if((s->avctx->debug&FF_DEBUG_VIS_MV) && pict->motion_val){ | 1416 if(s->avctx->debug&(FF_DEBUG_VIS_MV|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)){ |
1417 const int shift= 1 + s->quarter_sample; | 1417 const int shift= 1 + s->quarter_sample; |
1418 int mb_y; | 1418 int mb_y; |
1419 uint8_t *ptr= pict->data[0]; | 1419 uint8_t *ptr= pict->data[0]; |
1420 s->low_delay=0; //needed to see the vectors without trashing the buffers | 1420 s->low_delay=0; //needed to see the vectors without trashing the buffers |
1421 | 1421 |
1422 for(mb_y=0; mb_y<s->mb_height; mb_y++){ | 1422 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
1423 int mb_x; | 1423 int mb_x; |
1424 for(mb_x=0; mb_x<s->mb_width; mb_x++){ | 1424 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
1425 const int mb_index= mb_x + mb_y*s->mb_stride; | 1425 const int mb_index= mb_x + mb_y*s->mb_stride; |
1426 if(IS_8X8(pict->mb_type[mb_index])){ | 1426 if((s->avctx->debug&FF_DEBUG_VIS_MV) && pict->motion_val){ |
1427 if(IS_8X8(pict->mb_type[mb_index])){ | |
1427 int i; | 1428 int i; |
1428 for(i=0; i<4; i++){ | 1429 for(i=0; i<4; i++){ |
1429 int sx= mb_x*16 + 4 + 8*(i&1); | 1430 int sx= mb_x*16 + 4 + 8*(i&1); |
1430 int sy= mb_y*16 + 4 + 8*(i>>1); | 1431 int sy= mb_y*16 + 4 + 8*(i>>1); |
1431 int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2); | 1432 int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2); |
1432 int mx= (pict->motion_val[0][xy][0]>>shift) + sx; | 1433 int mx= (pict->motion_val[0][xy][0]>>shift) + sx; |
1433 int my= (pict->motion_val[0][xy][1]>>shift) + sy; | 1434 int my= (pict->motion_val[0][xy][1]>>shift) + sy; |
1434 draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); | 1435 draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); |
1435 } | 1436 } |
1436 }else if(IS_16X8(pict->mb_type[mb_index])){ | 1437 }else if(IS_16X8(pict->mb_type[mb_index])){ |
1437 int i; | 1438 int i; |
1438 for(i=0; i<2; i++){ | 1439 for(i=0; i<2; i++){ |
1439 int sx=mb_x*16 + 8; | 1440 int sx=mb_x*16 + 8; |
1440 int sy=mb_y*16 + 4 + 8*i; | 1441 int sy=mb_y*16 + 4 + 8*i; |
1441 int xy=1 + mb_x*2 + (mb_y*2 + 1 + i)*(s->mb_width*2 + 2); | 1442 int xy=1 + mb_x*2 + (mb_y*2 + 1 + i)*(s->mb_width*2 + 2); |
1442 int mx=(pict->motion_val[0][xy][0]>>shift) + sx; | 1443 int mx=(pict->motion_val[0][xy][0]>>shift) + sx; |
1443 int my=(pict->motion_val[0][xy][1]>>shift) + sy; | 1444 int my=(pict->motion_val[0][xy][1]>>shift) + sy; |
1444 draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); | 1445 draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); |
1445 } | 1446 } |
1446 }else{ | 1447 }else{ |
1447 int sx= mb_x*16 + 8; | 1448 int sx= mb_x*16 + 8; |
1448 int sy= mb_y*16 + 8; | 1449 int sy= mb_y*16 + 8; |
1449 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); | 1450 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); |
1450 int mx= (pict->motion_val[0][xy][0]>>shift) + sx; | 1451 int mx= (pict->motion_val[0][xy][0]>>shift) + sx; |
1451 int my= (pict->motion_val[0][xy][1]>>shift) + sy; | 1452 int my= (pict->motion_val[0][xy][1]>>shift) + sy; |
1452 draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); | 1453 draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); |
1454 } | |
1455 } | |
1456 if((s->avctx->debug&FF_DEBUG_VIS_QP) && pict->motion_val){ | |
1457 uint64_t c= (pict->qscale_table[mb_index]*128/31) * 0x0101010101010101ULL; | |
1458 int y; | |
1459 for(y=0; y<8; y++){ | |
1460 *(uint64_t*)(pict->data[1] + 8*mb_x + (8*mb_y + y)*pict->linesize[1])= c; | |
1461 *(uint64_t*)(pict->data[2] + 8*mb_x + (8*mb_y + y)*pict->linesize[2])= c; | |
1462 } | |
1463 } | |
1464 if((s->avctx->debug&FF_DEBUG_VIS_MB_TYPE) && pict->motion_val){ | |
1465 int mb_type= pict->mb_type[mb_index]; | |
1466 uint64_t u,v; | |
1467 int y; | |
1468 #define COLOR(theta, r)\ | |
1469 u= (int)(128 + r*cos(theta*3.141592/180));\ | |
1470 v= (int)(128 + r*sin(theta*3.141592/180)); | |
1471 | |
1472 | |
1473 u=v=128; | |
1474 if(IS_PCM(mb_type)){ | |
1475 COLOR(120,48) | |
1476 }else if((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) || IS_INTRA16x16(mb_type)){ | |
1477 COLOR(30,48) | |
1478 }else if(IS_INTRA4x4(mb_type)){ | |
1479 COLOR(90,48) | |
1480 }else if(IS_DIRECT(mb_type) && IS_SKIP(mb_type)){ | |
1481 // COLOR(120,48) | |
1482 }else if(IS_DIRECT(mb_type)){ | |
1483 COLOR(150,48) | |
1484 }else if(IS_GMC(mb_type) && IS_SKIP(mb_type)){ | |
1485 COLOR(170,48) | |
1486 }else if(IS_GMC(mb_type)){ | |
1487 COLOR(190,48) | |
1488 }else if(IS_SKIP(mb_type)){ | |
1489 // COLOR(180,48) | |
1490 }else if(!USES_LIST(mb_type, 1)){ | |
1491 COLOR(240,48) | |
1492 }else if(!USES_LIST(mb_type, 0)){ | |
1493 COLOR(0,48) | |
1494 }else{ | |
1495 assert(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1)); | |
1496 COLOR(300,48) | |
1497 } | |
1498 | |
1499 u*= 0x0101010101010101ULL; | |
1500 v*= 0x0101010101010101ULL; | |
1501 for(y=0; y<8; y++){ | |
1502 *(uint64_t*)(pict->data[1] + 8*mb_x + (8*mb_y + y)*pict->linesize[1])= u; | |
1503 *(uint64_t*)(pict->data[2] + 8*mb_x + (8*mb_y + y)*pict->linesize[2])= v; | |
1504 } | |
1505 | |
1506 //segmentation | |
1507 if(IS_8X8(mb_type) || IS_16X8(mb_type)){ | |
1508 *(uint64_t*)(pict->data[0] + 16*mb_x + 0 + (16*mb_y + 8)*pict->linesize[0])^= 0x8080808080808080ULL; | |
1509 *(uint64_t*)(pict->data[0] + 16*mb_x + 8 + (16*mb_y + 8)*pict->linesize[0])^= 0x8080808080808080ULL; | |
1510 } | |
1511 if(IS_8X8(mb_type) || IS_8X16(mb_type)){ | |
1512 for(y=0; y<16; y++) | |
1513 pict->data[0][16*mb_x + 8 + (16*mb_y + y)*pict->linesize[0]]^= 0x80; | |
1514 } | |
1515 | |
1516 if(IS_INTERLACED(mb_type) && s->codec_id == CODEC_ID_H264){ | |
1517 // hmm | |
1518 } | |
1453 } | 1519 } |
1454 s->mbskip_table[mb_index]=0; | 1520 s->mbskip_table[mb_index]=0; |
1455 } | 1521 } |
1456 } | 1522 } |
1457 } | 1523 } |