Commit 368ca651 authored by michael's avatar michael

mb type & qp vissualization


git-svn-id: file:///var/local/repositories/ffmpeg/trunk@2603 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 17a6931a
...@@ -1140,6 +1140,8 @@ typedef struct AVCodecContext { ...@@ -1140,6 +1140,8 @@ typedef struct AVCodecContext {
#define FF_DEBUG_ER 0x00000400 #define FF_DEBUG_ER 0x00000400
#define FF_DEBUG_MMCO 0x00000800 #define FF_DEBUG_MMCO 0x00000800
#define FF_DEBUG_BUGS 0x00001000 #define FF_DEBUG_BUGS 0x00001000
#define FF_DEBUG_VIS_QP 0x00002000
#define FF_DEBUG_VIS_MB_TYPE 0x00004000
/** /**
* error. * error.
......
...@@ -1413,7 +1413,7 @@ void ff_print_debug_info(MpegEncContext *s, Picture *pict){ ...@@ -1413,7 +1413,7 @@ void ff_print_debug_info(MpegEncContext *s, Picture *pict){
} }
} }
if((s->avctx->debug&FF_DEBUG_VIS_MV) && pict->motion_val){ if(s->avctx->debug&(FF_DEBUG_VIS_MV|FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)){
const int shift= 1 + s->quarter_sample; const int shift= 1 + s->quarter_sample;
int mb_y; int mb_y;
uint8_t *ptr= pict->data[0]; uint8_t *ptr= pict->data[0];
...@@ -1423,6 +1423,7 @@ void ff_print_debug_info(MpegEncContext *s, Picture *pict){ ...@@ -1423,6 +1423,7 @@ void ff_print_debug_info(MpegEncContext *s, Picture *pict){
int mb_x; int mb_x;
for(mb_x=0; mb_x<s->mb_width; mb_x++){ for(mb_x=0; mb_x<s->mb_width; mb_x++){
const int mb_index= mb_x + mb_y*s->mb_stride; const int mb_index= mb_x + mb_y*s->mb_stride;
if((s->avctx->debug&FF_DEBUG_VIS_MV) && pict->motion_val){
if(IS_8X8(pict->mb_type[mb_index])){ if(IS_8X8(pict->mb_type[mb_index])){
int i; int i;
for(i=0; i<4; i++){ for(i=0; i<4; i++){
...@@ -1451,6 +1452,71 @@ void ff_print_debug_info(MpegEncContext *s, Picture *pict){ ...@@ -1451,6 +1452,71 @@ void ff_print_debug_info(MpegEncContext *s, Picture *pict){
int my= (pict->motion_val[0][xy][1]>>shift) + sy; int my= (pict->motion_val[0][xy][1]>>shift) + sy;
draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);
} }
}
if((s->avctx->debug&FF_DEBUG_VIS_QP) && pict->motion_val){
uint64_t c= (pict->qscale_table[mb_index]*128/31) * 0x0101010101010101ULL;
int y;
for(y=0; y<8; y++){
*(uint64_t*)(pict->data[1] + 8*mb_x + (8*mb_y + y)*pict->linesize[1])= c;
*(uint64_t*)(pict->data[2] + 8*mb_x + (8*mb_y + y)*pict->linesize[2])= c;
}
}
if((s->avctx->debug&FF_DEBUG_VIS_MB_TYPE) && pict->motion_val){
int mb_type= pict->mb_type[mb_index];
uint64_t u,v;
int y;
#define COLOR(theta, r)\
u= (int)(128 + r*cos(theta*3.141592/180));\
v= (int)(128 + r*sin(theta*3.141592/180));
u=v=128;
if(IS_PCM(mb_type)){
COLOR(120,48)
}else if((IS_INTRA(mb_type) && IS_ACPRED(mb_type)) || IS_INTRA16x16(mb_type)){
COLOR(30,48)
}else if(IS_INTRA4x4(mb_type)){
COLOR(90,48)
}else if(IS_DIRECT(mb_type) && IS_SKIP(mb_type)){
// COLOR(120,48)
}else if(IS_DIRECT(mb_type)){
COLOR(150,48)
}else if(IS_GMC(mb_type) && IS_SKIP(mb_type)){
COLOR(170,48)
}else if(IS_GMC(mb_type)){
COLOR(190,48)
}else if(IS_SKIP(mb_type)){
// COLOR(180,48)
}else if(!USES_LIST(mb_type, 1)){
COLOR(240,48)
}else if(!USES_LIST(mb_type, 0)){
COLOR(0,48)
}else{
assert(USES_LIST(mb_type, 0) && USES_LIST(mb_type, 1));
COLOR(300,48)
}
u*= 0x0101010101010101ULL;
v*= 0x0101010101010101ULL;
for(y=0; y<8; y++){
*(uint64_t*)(pict->data[1] + 8*mb_x + (8*mb_y + y)*pict->linesize[1])= u;
*(uint64_t*)(pict->data[2] + 8*mb_x + (8*mb_y + y)*pict->linesize[2])= v;
}
//segmentation
if(IS_8X8(mb_type) || IS_16X8(mb_type)){
*(uint64_t*)(pict->data[0] + 16*mb_x + 0 + (16*mb_y + 8)*pict->linesize[0])^= 0x8080808080808080ULL;
*(uint64_t*)(pict->data[0] + 16*mb_x + 8 + (16*mb_y + 8)*pict->linesize[0])^= 0x8080808080808080ULL;
}
if(IS_8X8(mb_type) || IS_8X16(mb_type)){
for(y=0; y<16; y++)
pict->data[0][16*mb_x + 8 + (16*mb_y + y)*pict->linesize[0]]^= 0x80;
}
if(IS_INTERLACED(mb_type) && s->codec_id == CODEC_ID_H264){
// hmm
}
}
s->mbskip_table[mb_index]=0; s->mbskip_table[mb_index]=0;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment