Ticket #1627: bug1627.diff

File bug1627.diff, 2.3 KB (added by quetschke@…, 9 years ago)

Patch to enhance cropdetect

  • libmpcodecs/vf_cropdetect.c

     
    1515    int x1,y1,x2,y2;
    1616    int limit;
    1717    int round;
     18    int reset_count;
    1819    int fno;
    1920};
    2021
     
    5758    mp_image_t *dmpi;
    5859    int bpp=mpi->bpp/8;
    5960    int w,h,x,y,shrink_by;
     61    static int mycount = 0; // Keep track of frames since last crop area reset
    6062
    6163    // hope we'll get DR buffer:
    6264    dmpi=vf_get_image(vf->next,mpi->imgfmt,
     
    7375    dmpi->height=mpi->height;
    7476
    7577if(++vf->priv->fno>2){  // ignore first 2 frames - they may be empty
     78   
     79    // Reset the crop area every reset_count frames, if reset_count is > 0
     80    mycount++;
     81    if(vf->priv->reset_count && mycount >= vf->priv->reset_count){
     82        vf->priv->x1=mpi->w-1;
     83        vf->priv->y1=mpi->h-1;
     84        vf->priv->x2=0;
     85        vf->priv->y2=0;
     86        mycount=0;
     87    }
    7688
    7789    for(y=0;y<vf->priv->y1;y++){
    7890        if(checkline(mpi->planes[0]+mpi->stride[0]*y,bpp,mpi->w,bpp)>vf->priv->limit){
     
    153165    vf->priv=malloc(sizeof(struct vf_priv_s));
    154166    vf->priv->limit=24; // should be option
    155167    vf->priv->round = 0;
    156     if(args) sscanf(args, "%d:%d",
     168    vf->priv->reset_count = 0;
     169    if(args) sscanf(args, "%d:%d:%d",
    157170    &vf->priv->limit,
    158     &vf->priv->round);
     171    &vf->priv->round,
     172    &vf->priv->reset_count);
    159173    return 1;
    160174}
    161175
  • DOCS/man/en/mplayer.1

     
    57755775.PD 1
    57765776.
    57775777.TP
    5778 .B cropdetect[=limit:round]
     5778.B cropdetect[=limit:round[:reset]]
    57795779Calculates necessary cropping parameters and prints the recommended parameters
    57805780to stdout.
    57815781.PD 0
     
    57895789The offset is automatically adjusted to center the video.
    57905790Use 2 to get only even dimensions (needed for 4:2:2 video).
    5791579116 is best when encoding to most video codecs.
     5792.br
     5793.IPs <reset>
     5794Counter that determines after how many frames cropdetect will reset
     5795the previously detected largest video area and start over to detect
     5796the current optimal crop area.  This can be usefull when channel
     5797logos distort the video area.  0 indicates never reset and return
     5798the the largest area encountered during playback. (default: 0).
    57925799.RE
    57935800.PD 1
    57945801.