|
|
@ -30,6 +30,13 @@ |
|
|
|
#include "avcodec.h" |
|
|
|
#include "avcodec.h" |
|
|
|
#include "dsputil.h" |
|
|
|
#include "dsputil.h" |
|
|
|
#include "mpegvideo.h" |
|
|
|
#include "mpegvideo.h" |
|
|
|
|
|
|
|
#include "h264.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
* H264 redefines mb_intra so it is not mistakely used (its uninitialized in h264) |
|
|
|
|
|
|
|
* but error concealment must support both h264 and h263 thus we must undo this |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
#undef mb_intra |
|
|
|
|
|
|
|
|
|
|
|
static void decode_mb(MpegEncContext *s){ |
|
|
|
static void decode_mb(MpegEncContext *s){ |
|
|
|
s->dest[0] = s->current_picture.data[0] + (s->mb_y * 16* s->linesize ) + s->mb_x * 16; |
|
|
|
s->dest[0] = s->current_picture.data[0] + (s->mb_y * 16* s->linesize ) + s->mb_x * 16; |
|
|
@ -39,6 +46,22 @@ static void decode_mb(MpegEncContext *s){ |
|
|
|
MPV_decode_mb(s, s->block); |
|
|
|
MPV_decode_mb(s, s->block); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param stride the number of MVs to get to the next row |
|
|
|
|
|
|
|
* @param mv_step the number of MVs per row or column in a macroblock |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
static void set_mv_strides(MpegEncContext *s, int *mv_step, int *stride){ |
|
|
|
|
|
|
|
if(s->codec_id == CODEC_ID_H264){ |
|
|
|
|
|
|
|
H264Context *h= (void*)s; |
|
|
|
|
|
|
|
assert(s->quarter_sample); |
|
|
|
|
|
|
|
*mv_step= 4; |
|
|
|
|
|
|
|
*stride= h->b_stride; |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
*mv_step= 2; |
|
|
|
|
|
|
|
*stride= s->b8_stride; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* replaces the current MB with a flat dc only version. |
|
|
|
* replaces the current MB with a flat dc only version. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -320,7 +343,9 @@ static void guess_mv(MpegEncContext *s){ |
|
|
|
const int mb_width = s->mb_width; |
|
|
|
const int mb_width = s->mb_width; |
|
|
|
const int mb_height= s->mb_height; |
|
|
|
const int mb_height= s->mb_height; |
|
|
|
int i, depth, num_avail; |
|
|
|
int i, depth, num_avail; |
|
|
|
int mb_x, mb_y; |
|
|
|
int mb_x, mb_y, mot_step, mot_stride; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_mv_strides(s, &mot_step, &mot_stride); |
|
|
|
|
|
|
|
|
|
|
|
num_avail=0; |
|
|
|
num_avail=0; |
|
|
|
for(i=0; i<s->mb_num; i++){ |
|
|
|
for(i=0; i<s->mb_num; i++){ |
|
|
@ -379,8 +404,7 @@ int score_sum=0; |
|
|
|
int j; |
|
|
|
int j; |
|
|
|
int best_score=256*256*256*64; |
|
|
|
int best_score=256*256*256*64; |
|
|
|
int best_pred=0; |
|
|
|
int best_pred=0; |
|
|
|
const int mot_stride= s->b8_stride; |
|
|
|
const int mot_index= (mb_x + mb_y*mot_stride) * mot_step; |
|
|
|
const int mot_index= mb_x*2 + mb_y*2*mot_stride; |
|
|
|
|
|
|
|
int prev_x= s->current_picture.motion_val[0][mot_index][0]; |
|
|
|
int prev_x= s->current_picture.motion_val[0][mot_index][0]; |
|
|
|
int prev_y= s->current_picture.motion_val[0][mot_index][1]; |
|
|
|
int prev_y= s->current_picture.motion_val[0][mot_index][1]; |
|
|
|
|
|
|
|
|
|
|
@ -407,23 +431,23 @@ int score_sum=0; |
|
|
|
none_left=0; |
|
|
|
none_left=0; |
|
|
|
|
|
|
|
|
|
|
|
if(mb_x>0 && fixed[mb_xy-1]){ |
|
|
|
if(mb_x>0 && fixed[mb_xy-1]){ |
|
|
|
mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - 2][0]; |
|
|
|
mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_step][0]; |
|
|
|
mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - 2][1]; |
|
|
|
mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_step][1]; |
|
|
|
pred_count++; |
|
|
|
pred_count++; |
|
|
|
} |
|
|
|
} |
|
|
|
if(mb_x+1<mb_width && fixed[mb_xy+1]){ |
|
|
|
if(mb_x+1<mb_width && fixed[mb_xy+1]){ |
|
|
|
mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + 2][0]; |
|
|
|
mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_step][0]; |
|
|
|
mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + 2][1]; |
|
|
|
mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_step][1]; |
|
|
|
pred_count++; |
|
|
|
pred_count++; |
|
|
|
} |
|
|
|
} |
|
|
|
if(mb_y>0 && fixed[mb_xy-mb_stride]){ |
|
|
|
if(mb_y>0 && fixed[mb_xy-mb_stride]){ |
|
|
|
mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_stride*2][0]; |
|
|
|
mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index - mot_stride*mot_step][0]; |
|
|
|
mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_stride*2][1]; |
|
|
|
mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index - mot_stride*mot_step][1]; |
|
|
|
pred_count++; |
|
|
|
pred_count++; |
|
|
|
} |
|
|
|
} |
|
|
|
if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){ |
|
|
|
if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){ |
|
|
|
mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_stride*2][0]; |
|
|
|
mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index + mot_stride*mot_step][0]; |
|
|
|
mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_stride*2][1]; |
|
|
|
mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index + mot_stride*mot_step][1]; |
|
|
|
pred_count++; |
|
|
|
pred_count++; |
|
|
|
} |
|
|
|
} |
|
|
|
if(pred_count==0) continue; |
|
|
|
if(pred_count==0) continue; |
|
|
|