On Sat, Dec 17, 2011 at 10:12:00PM +0200, доналд овчаров wrote:
> Fixed.
Please stop top-posting and use a mailer that does not break threads.
> --- a/libavcodec/error_resilience.c
> +++ b/libavcodec/error_resilience.c
> @@ -40,26 +40,36 @@
>
> +static void decode_mb(MpegEncContext *s, int ref) {
{ goes on the next line after function declarations, more below.
> + fill_rectangle(&s->current_picture.f.ref_index[0][4 * h->mb_xy], 2,
> 2, 2, ref, 1);
> fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
> - fill_rectangle(h->mv_cache[0][ scan8[0] ], 4, 4, 8,
> pack16to32(s->mv[0][0][0],s->mv[0][0][1]), 4);
> + fill_rectangle( h->mv_cache[0][scan8[0]], 4, 4, 8,
> pack16to32(s->mv[0][0][0],
> +
> s->mv[0][0][1]), 4);
The spaces after the '(' look weird.
> @@ -67,46 +77,49 @@ static void decode_mb(MpegEncContext *s, int ref){
> - }else{
> - *mv_step= 2;
> - *stride= s->b8_stride;
> + *mv_step = 4;
> + *stride = h->b_stride;
> + } else {
> + *mv_step = 2;
> + *stride = s->b8_stride;
Align the '='.
> + if (dc < 0) dc = 0;
> + else if (dc > 2040) dc = 2040;
Break these lines.
> @@ -115,34 +128,33 @@ static void filter181(int16_t *data, int width, int
> height, int stride){
>
> -
> - dc= - prev_dc
> - + data[x + y*stride]*8
> - - data[x + 1 + y*stride];
> - dc= (dc*10923 + 32768)>>16;
> - prev_dc= data[x + y*stride];
> - data[x + y*stride]= dc;
> + dc = - prev_dc
> + + data[x + y * stride] * 8
> + - data[x + 1 + y * stride];
> + dc = (dc * 10923 + 32768) >> 16;
> + prev_dc = data[x + y * stride];
> + data[x + y * stride] = dc;
>
> - dc= - prev_dc
> - + data[x + y *stride]*8
> - - data[x + (y+1)*stride];
> - dc= (dc*10923 + 32768)>>16;
> - prev_dc= data[x + y*stride];
> - data[x + y*stride]= dc;
> + dc = - prev_dc
> + + data[x + y * stride] * 8
> + - data[x + (y+1) * stride];
> + dc = (dc * 10923 + 32768) >> 16;
> + prev_dc = data[x + y * stride];
> + data[x + y * stride] = dc;
> }
> }
> }
> @@ -152,43 +164,43 @@ static void filter181(int16_t *data, int width, int
> height, int stride){
> + int color[4] = {1024,1024,1024,1024};
> + int distance[4] = {9999,9999,9999,9999};
space after comma and inside {}
> - if(IS_INTER(s->current_picture.f.mb_type[mb_index])) continue;
> //inter
> - if(!(error&ER_DC_ERROR)) continue; //dc-ok
> + if (IS_INTER(s->current_picture.f.mb_type[mb_index])) continue;
> //inter
> + if (!(error&ER_DC_ERROR)) continue;
> //dc-ok
Break the lines.
> - if(intra_j==0 || !(error_j&ER_DC_ERROR)){
> - color[1]= dc[j + b_y*stride];
> - distance[1]= b_x-j;
> + if (intra_j == 0 || !(error_j & ER_DC_ERROR)) {
> + color[1] = dc[j + b_y * stride];
> + distance[1] = b_x-j;
space around -
> @@ -236,58 +247,76 @@ static void guess_dc(MpegEncContext *s, int16_t *dc,
> int w, int h, int stride, i
> + int left_status = s->error_status_table[( b_x >> is_luma) +
> + (b_y >> is_luma) *
> s->mb_stride];
> + int right_status = s->error_status_table[((b_x + 1) >> is_luma) +
> + (b_y >> is_luma) *
> s->mb_stride];
> + int left_intra = IS_INTRA(s->current_picture.f.mb_type[( b_x
> >> is_luma) +
> + ( b_y
> >> is_luma) * s->mb_stride]);
> + int right_intra = IS_INTRA(s->current_picture.f.mb_type[((b_x +
> 1) >> is_luma) +
> + ( b_y
> >> is_luma) * s->mb_stride]);
Keep the long lines in this case.
> + if (left_damage) {
> + dst[offset + 7 + y * stride] = cm[dst[offset + 7 + y *
> stride] +
> + ((d * 7) >> 4)];
> + dst[offset + 6 + y * stride] = cm[dst[offset + 6 + y *
> stride] +
> + ((d * 5) >> 4)];
> + dst[offset + 5 + y * stride] = cm[dst[offset + 5 + y *
> stride] +
> + ((d * 3) >> 4)];
> + dst[offset + 4 + y * stride] = cm[dst[offset + 4 + y *
> stride] +
> + ((d * 1) >> 4)];
> }
> - if(right_damage){
> - dst[offset + 8 + y*stride] = cm[dst[offset + 8 +
> y*stride] - ((d*7)>>4)];
> - dst[offset + 9 + y*stride] = cm[dst[offset + 9 +
> y*stride] - ((d*5)>>4)];
> - dst[offset + 10+ y*stride] = cm[dst[offset +10 +
> y*stride] - ((d*3)>>4)];
> - dst[offset + 11+ y*stride] = cm[dst[offset +11 +
> y*stride] - ((d*1)>>4)];
> + if (right_damage) {
> + dst[offset + 8 + y * stride] = cm[dst[offset + 8 + y *
> stride] -
> + ((d * 7) >> 4)];
> + dst[offset + 9 + y * stride] = cm[dst[offset + 9 + y *
> stride] -
> + ((d * 5) >> 4)];
> + dst[offset + 10+ y * stride] = cm[dst[offset + 10 + y *
> stride] -
> + ((d * 3) >> 4)];
> + dst[offset + 11+ y * stride] = cm[dst[offset + 11 + y *
> stride] -
> + ((d * 1) >> 4)];
same
> @@ -299,230 +328,283 @@ static void h_block_filter(MpegEncContext *s, uint8_t
> *dst, int w, int h, int st
> + int top_status = s->error_status_table[(b_x>>is_luma) +
> + ( b_y >> is_luma) * s->mb_stride];
> + int bottom_status = s->error_status_table[(b_x>>is_luma) +
> + ((b_y + 1 ) >> is_luma) * s->mb_stride];
> + int top_intra = IS_INTRA(s->current_picture.f.mb_type[(b_x
> >> is_luma) +
> + ( b_y >> is_luma) * s->mb_stride]);
> + int bottom_intra = IS_INTRA(s->current_picture.f.mb_type[(b_x
> >> is_luma) +
> + ((b_y + 1) >> is_luma) * s->mb_stride]);
> + int top_damage = top_status&ER_MB_ERROR;
> + int bottom_damage = bottom_status&ER_MB_ERROR;
> + int offset = b_x * 8 + b_y * stride * 8;
> +
> + int16_t *top_mv =
> s->current_picture.f.motion_val[0][mvy_stride * b_y +
> +
> mvx_stride * b_x];
> + int16_t *bottom_mv =
> s->current_picture.f.motion_val[0][mvy_stride * (b_y + 1) +
> +
> mvx_stride * b_x];
more
.. more instances below ..
> - if(IS_INTRA(s->current_picture.f.mb_type[mb_xy])) f=MV_FROZEN;
> //intra //FIXME check
> - if(!(error&ER_MV_ERROR)) f=MV_FROZEN; //inter with
> undamaged MV
> + if (IS_INTRA(s->current_picture.f.mb_type[mb_xy])) f = MV_FROZEN;
> + //intra //FIXME check
> + if (!(error&ER_MV_ERROR)) f = MV_FROZEN;
> + //inter with undamaged MV
You misplaced the comments.
> - if((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) || num_avail <=
> mb_width/2){
> - for(mb_y=0; mb_y<s->mb_height; mb_y++){
> - for(mb_x=0; mb_x<s->mb_width; mb_x++){
> - const int mb_xy= mb_x + mb_y*s->mb_stride;
> + if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) ||
> + num_avail <= mb_width / 2)
> + {
{ is not where it should be.
> + int mv_predictor[8][2] = {{0}};
> + int ref[8] = {0};
> + int pred_count = 0;
space inside {}
> - if((mb_x^mb_y^pass)&1) continue;
> + if ((mb_x^mb_y^pass) & 1)
> + continue;
space around ^
> - if(mb_y+1<mb_height && fixed[mb_xy+mb_stride]){
> - mv_predictor[pred_count][0]=
> s->current_picture.f.motion_val[0][mot_index + mot_stride*mot_step][0];
> - mv_predictor[pred_count][1]=
> s->current_picture.f.motion_val[0][mot_index + mot_stride*mot_step][1];
> - ref [pred_count] =
> s->current_picture.f.ref_index[0][4*(mb_xy+s->mb_stride)];
> + if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) {
> + mv_predictor[pred_count][0]=
> + s->current_picture.f.motion_val[0][mot_index +
> mot_stride * mot_step][0];
> + mv_predictor[pred_count][1]=
> + s->current_picture.f.motion_val[0][mot_index +
> mot_stride * mot_step][1];
> + ref [pred_count] =
> + s->current_picture.f.ref_index[0][4 * (mb_xy +
> s->mb_stride)];
space around =
> @@ -537,150 +619,168 @@ skip_mean_and_median:
> static int is_intra_more_likely(MpegEncContext *s){
{ on the next line
> - if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) return 1;
> //no previous frame available -> use spatial prediction
> + if (!s->last_picture_ptr || !s->last_picture_ptr->f.data[0]) return 1;
> + //no previous frame available -> use spatial prediction
You cannot move comments that were to the right of a line after it.
> - undamaged_count=0;
> - for(i=0; i<s->mb_num; i++){
> - const int mb_xy= s->mb_index2xy[i];
> - const int error= s->error_status_table[mb_xy];
> + undamaged_count = 0;
> + for (i = 0; i < s->mb_num; i++) {
> + const int mb_xy = s->mb_index2xy[i];
> + const int error = s->error_status_table[mb_xy];
> if(!((error&ER_DC_ERROR) && (error&ER_MV_ERROR)))
> undamaged_count++;
> }
if (
> //prevent dsp.sad() check, that requires access to the image
> - if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration &&
> s->pict_type == AV_PICTURE_TYPE_I)
> + if (CONFIG_MPEG_XVMC_DECODER &&
> + s->avctx->xvmc_acceleration &&
> + s->pict_type == AV_PICTURE_TYPE_I)
> + {
> return 1;
> + }
Don't add {}, much less in the wrong layout.
> - error= s->error_status_table[mb_xy];
> - if((error&ER_DC_ERROR) && (error&ER_MV_ERROR))
> + error = s->error_status_table[mb_xy];
> + if ((error&ER_DC_ERROR) && (error&ER_MV_ERROR))
space around &, more below
> - if((j%skip_amount) != 0) continue; //skip a few to speed things
> up
> + if ((j%skip_amount) != 0)
> + continue; //skip a few to speed things up
and around %
> @@ -703,112 +805,127 @@ static int is_intra_more_likely(MpegEncContext *s){
>
> - memset(s->error_status_table, ER_MB_ERROR|VP_START|ER_MB_END,
> s->mb_stride*s->mb_height*sizeof(uint8_t));
> - s->error_count= 3*s->mb_num;
> + memset(s->error_status_table, ER_MB_ERROR|VP_START|ER_MB_END,
> + s->mb_stride * s->mb_height * sizeof(uint8_t));
> + s->error_count = 3 * s->mb_num;
space around |, more below
> /**
> * Add a slice.
> * @param endx x component of the last macroblock, can be -1 for the last of
> the previous line
> - * @param status the status at the end (ER_MV_END, ER_AC_ERROR, ...), it is
> assumed that no earlier end or
> + * @param status the status at the end (ER_MV_END, ER_AC_ERROR, ...),
> + * it is assumed that no earlier end or
> * error of the same type occurred
This is not am improvement, you broke vertical alignment.
> + const int start_i = av_clip(startx + starty * s->mb_width , 0,
> s->mb_num - 1);
> + const int end_i = av_clip(endx + endy * s->mb_width , 0,
> s->mb_num);
The spaces before comma are weird.
> - if(start_i > end_i || start_xy > end_xy){
> + if (start_i > end_i || start_xy > end_xy){
space before {
> - int threshold_part[4]= {100,100,100};
> - int threshold= 50;
> + int threshold_part[4] = {100,100,100};
> + int threshold = 50;
space after comma and inside {}
> @@ -1031,91 +1164,98 @@ void ff_er_frame_end(MpegEncContext *s){
>
> - if(IS_INTRA(mb_type) && s->partitioned_frame) continue;
> -// if(error&ER_MV_ERROR) continue; //inter data damaged FIXME is
> this good?
> + if (IS_INTRA(mb_type) && s->partitioned_frame)
> + continue;
> + //if(error&ER_MV_ERROR) continue; //inter data damaged FIXME is
> this good?
Fix the commented-out code as well please.
> /* guess DC for damaged blocks */
> - guess_dc(s, s->dc_val[0], s->mb_width*2, s->mb_height*2, s->b8_stride,
> 1);
> + guess_dc(s, s->dc_val[0], s->mb_width * 2, s->mb_height * 2,
> s->b8_stride, 1);
> guess_dc(s, s->dc_val[1], s->mb_width , s->mb_height , s->mb_stride,
> 0);
> guess_dc(s, s->dc_val[2], s->mb_width , s->mb_height , s->mb_stride,
> 0);
Maintain the vertical alignment and remove space before comma.
> @@ -1125,27 +1265,35 @@ void ff_er_frame_end(MpegEncContext *s){
>
> ec_clean:
> /* clean a few tables */
> - for(i=0; i<s->mb_num; i++){
> - const int mb_xy= s->mb_index2xy[i];
> - int error= s->error_status_table[mb_xy];
> -
> - if(s->pict_type!=AV_PICTURE_TYPE_B &&
> (error&(ER_DC_ERROR|ER_MV_ERROR|ER_AC_ERROR))){
> - s->mbskip_table[mb_xy]=0;
> + for (i = 0; i < s->mb_num; i++) {
> + const int mb_xy = s->mb_index2xy[i];
> + int error = s->error_status_table[mb_xy];
> +
> + if (s->pict_type != AV_PICTURE_TYPE_B &&
> + (error & (ER_DC_ERROR | ER_MV_ERROR | ER_AC_ERROR)))
> + {
> + s->mbskip_table[mb_xy] = 0;
> }
Don't move the '{' to the next line.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel