Ticket #1641: bug_1641.diff
| File bug_1641.diff, 3.5 KB (added by , 16 years ago) |
|---|
-
libmpcodecs/vf_cropdetect.c
92 92 dmpi->height=mpi->height; 93 93 94 94 if(++vf->priv->fno>0){ // ignore first 2 frames - they may be empty 95 int round_sig = 1; 95 96 96 97 // Reset the crop area every reset_count frames, if reset_count is > 0 97 98 if(vf->priv->reset_count > 0 && vf->priv->fno > vf->priv->reset_count){ … … 130 131 } 131 132 } 132 133 133 // round x and y (up), important for yuv colorspaces 134 // make sure they stay rounded! 135 x=(vf->priv->x1+1)&(~1); 136 y=(vf->priv->y1+1)&(~1); 134 if (vf->priv->round < 0) 135 round_sig = -1; 137 136 137 x = vf->priv->x1; 138 y = vf->priv->y1; 139 140 // make sure x and y are rounded to even number 141 if (x%2) 142 x += round_sig; 143 if (y%2) 144 y += round_sig; 145 138 146 w = vf->priv->x2 - x + 1; 139 147 h = vf->priv->y2 - y + 1; 140 148 141 // w and h must be divisible by 2 as well because of yuv 142 // colorspace problems. 143 if (vf->priv->round <= 1) 144 vf->priv->round = 16; 145 if (vf->priv->round % 2) 146 vf->priv->round *= 2; 149 // w and h must be divisible by 2 because of yuv colorspace problems. 150 // This is always true as round is even number != 0 147 151 148 shrink_by = w % vf->priv->round; 152 // Modulus with negative divisor is implementation-defined, avoid 153 // problems. 154 shrink_by = w % abs(vf->priv->round); 155 if (shrink_by && vf->priv->round < 0) 156 shrink_by += vf->priv->round; 157 149 158 w -= shrink_by; 150 x += (shrink_by / 2 + 1) & ~1;159 x += shrink_by / 2; 151 160 152 shrink_by = h % vf->priv->round; 161 shrink_by = h % abs(vf->priv->round); 162 if (shrink_by && vf->priv->round < 0) 163 shrink_by += vf->priv->round; 164 153 165 h -= shrink_by; 154 y += (shrink_by / 2 + 1) & ~1;166 y += shrink_by / 2; 155 167 168 // make sure x and y stay rounded to even number 169 x = (x%2 ? x+round_sig : x); 170 y = (y%2 ? y+round_sig : y); 171 156 172 mp_msg(MSGT_VFILTER, MSGL_INFO, MSGTR_MPCODECS_CropArea, 157 173 vf->priv->x1,vf->priv->x2, 158 174 vf->priv->y1,vf->priv->y2, … … 175 191 //===========================================================================// 176 192 177 193 static int open(vf_instance_t *vf, char* args){ 194 int round_sig = 1; 178 195 vf->config=config; 179 196 vf->put_image=put_image; 180 197 vf->query_format=query_format; … … 186 203 &vf->priv->limit, 187 204 &vf->priv->round, 188 205 &vf->priv->reset_count); 206 207 if (vf->priv->round < 0) 208 round_sig = -1; 209 210 if (abs(vf->priv->round) <= 1) 211 vf->priv->round = 16*round_sig; 212 if (vf->priv->round % 2) 213 vf->priv->round += round_sig; // Increase by one, keep sign 214 189 215 return 1; 190 216 } 191 217 -
DOCS/man/en/mplayer.1
5805 5805 Value which the width/\:height should be divisible by (default: 16). 5806 5806 The offset is automatically adjusted to center the video. 5807 5807 Use 2 to get only even dimensions (needed for 4:2:2 video). 5808 16 is best when encoding to most video codecs. 5808 16 is best when encoding to most video codecs. Usually the crop values 5809 for width and height are rounded down to avoid black bars, but a round up 5810 mode can be forced by choosing a negative round value. This will leave 5811 black borders around the picture and is therefore not optimal for compression 5812 efficiency, but it will avoid that picture information is lost. 5809 5813 .br 5810 5814 .IPs <reset> 5811 5815 Counter that determines after how many frames cropdetect will reset
