comparison libmpcodecs/vf_remove_logo.c @ 19066:26a30496ec96

marks several function without a prototype which arent used outside its sourcefile as static, Patch by Stefan Huehner - stefan AT huehner-org
author reynaldo
date Thu, 13 Jul 2006 20:59:18 +0000
parents 6a08d0dabca8
children 36589811e5d0
comparison
equal deleted inserted replaced
19065:26ed3fcd5cd4 19066:26a30496ec96
172 * 172 *
173 * Mallocs memory, and checks to make sure it was successfully allocated. Because 173 * Mallocs memory, and checks to make sure it was successfully allocated. Because
174 * of how MPlayer works, it cannot safely halt execution, but at least the user 174 * of how MPlayer works, it cannot safely halt execution, but at least the user
175 * will get an error message before the segfault happens. 175 * will get an error message before the segfault happens.
176 */ 176 */
177 void * safe_malloc(int size) 177 static void * safe_malloc(int size)
178 { 178 {
179 void * answer = malloc(size); 179 void * answer = malloc(size);
180 if (answer == NULL) 180 if (answer == NULL)
181 mp_msg(MSGT_VFILTER, MSGL_ERR, "Unable to allocate memory in vf_remove_logo.c\n"); 181 mp_msg(MSGT_VFILTER, MSGL_ERR, "Unable to allocate memory in vf_remove_logo.c\n");
182 182
192 * The bounding rectangle is calculated by testing successive lines (from the four 192 * The bounding rectangle is calculated by testing successive lines (from the four
193 * sides of the rectangle) until no more can be removed without removing logo 193 * sides of the rectangle) until no more can be removed without removing logo
194 * pixels. The results are returned by reference to posx1, posy1, posx2, and 194 * pixels. The results are returned by reference to posx1, posy1, posx2, and
195 * posy2. 195 * posy2.
196 */ 196 */
197 197 static void calculate_bounding_rectangle(int * posx1, int * posy1, int * posx2, int * posy2, pgm_structure * filter)
198 void calculate_bounding_rectangle(int * posx1, int * posy1, int * posx2, int * posy2, pgm_structure * filter)
199 { 198 {
200 int x; /* Temporary variables to run */ 199 int x; /* Temporary variables to run */
201 int y; /* through each row or column. */ 200 int y; /* through each row or column. */
202 int start_x; 201 int start_x;
203 int start_y; 202 int start_y;
262 * \param vf Data structure which stores our persistant data, and is to be freed. 261 * \param vf Data structure which stores our persistant data, and is to be freed.
263 * 262 *
264 * We call this function when our filter is done. It will free the memory 263 * We call this function when our filter is done. It will free the memory
265 * allocated to the masks and leave the variables in a safe state. 264 * allocated to the masks and leave the variables in a safe state.
266 */ 265 */
267 void destroy_masks(vf_instance_t * vf) 266 static void destroy_masks(vf_instance_t * vf)
268 { 267 {
269 int a, b; 268 int a, b;
270 269
271 /* Load values from the vf->priv struct for faster dereferencing. */ 270 /* Load values from the vf->priv struct for faster dereferencing. */
272 int * * * mask = ((vf_priv_s *)vf->priv)->mask; 271 int * * * mask = ((vf_priv_s *)vf->priv)->mask;
299 * 298 *
300 * This creates an array of progressively larger masks and calculates their 299 * This creates an array of progressively larger masks and calculates their
301 * values. The values will not change during program execution once this function 300 * values. The values will not change during program execution once this function
302 * is done. 301 * is done.
303 */ 302 */
304 void initialize_masks(vf_instance_t * vf) 303 static void initialize_masks(vf_instance_t * vf)
305 { 304 {
306 int a, b, c; 305 int a, b, c;
307 306
308 /* Load values from the vf->priv struct for faster dereferencing. */ 307 /* Load values from the vf->priv struct for faster dereferencing. */
309 int * * * mask = ((vf_priv_s *)vf->priv)->mask; 308 int * * * mask = ((vf_priv_s *)vf->priv)->mask;
347 * the logo and is the manhattan distance (|dx| + |dy|) for pixels inside of the 346 * the logo and is the manhattan distance (|dx| + |dy|) for pixels inside of the
348 * logo. This will overestimate the distance, but that is safe, and is far easier 347 * logo. This will overestimate the distance, but that is safe, and is far easier
349 * to implement than a proper pythagorean distance since I'm using a modified 348 * to implement than a proper pythagorean distance since I'm using a modified
350 * erosion algorithm to compute the distances. 349 * erosion algorithm to compute the distances.
351 */ 350 */
352 void convert_mask_to_strength_mask(vf_instance_t * vf, pgm_structure * mask) 351 static void convert_mask_to_strength_mask(vf_instance_t * vf, pgm_structure * mask)
353 { 352 {
354 int x, y; /* Used by our for loops to go through every single pixel in the picture one at a time. */ 353 int x, y; /* Used by our for loops to go through every single pixel in the picture one at a time. */
355 int has_anything_changed = 1; /* Used by the main while() loop to know if anything changed on the last erosion. */ 354 int has_anything_changed = 1; /* Used by the main while() loop to know if anything changed on the last erosion. */
356 int current_pass = 0; /* How many times we've gone through the loop. Used in the in-place erosion algorithm 355 int current_pass = 0; /* How many times we've gone through the loop. Used in the in-place erosion algorithm
357 and to get us max_mask_size later on. */ 356 and to get us max_mask_size later on. */
428 * 427 *
429 * This function is the core of the filter. It takes a pixel that is inside the 428 * This function is the core of the filter. It takes a pixel that is inside the
430 * logo and blurs it. It does so by finding the average of all the pixels within 429 * logo and blurs it. It does so by finding the average of all the pixels within
431 * the mask and outside of the logo. 430 * the mask and outside of the logo.
432 */ 431 */
433 void get_blur(const vf_instance_t * const vf, unsigned int * const value_out, const pgm_structure * const logo_mask, 432 static void get_blur(const vf_instance_t * const vf, unsigned int * const value_out, const pgm_structure * const logo_mask,
434 const mp_image_t * const image, const int x, const int y, const int plane) 433 const mp_image_t * const image, const int x, const int y, const int plane)
435 { 434 {
436 int mask_size; /* Mask size tells how large a circle to use. The radius is about (slightly larger than) mask size. */ 435 int mask_size; /* Mask size tells how large a circle to use. The radius is about (slightly larger than) mask size. */
437 /* Get values from vf->priv for faster dereferencing. */ 436 /* Get values from vf->priv for faster dereferencing. */
438 int * * * mask = ((vf_priv_s *)vf->priv)->mask; 437 int * * * mask = ((vf_priv_s *)vf->priv)->mask;
484 } 483 }
485 484
486 /** 485 /**
487 * \brief Free a pgm_structure. Undoes load_pgm(...). 486 * \brief Free a pgm_structure. Undoes load_pgm(...).
488 */ 487 */
489 void destroy_pgm(pgm_structure * to_be_destroyed) 488 static void destroy_pgm(pgm_structure * to_be_destroyed)
490 { 489 {
491 if (to_be_destroyed == NULL) 490 if (to_be_destroyed == NULL)
492 return; /* Don't do anything if a NULL pointer was passed it. */ 491 return; /* Don't do anything if a NULL pointer was passed it. */
493 492
494 /* Internally allocated memory. */ 493 /* Internally allocated memory. */
501 /* Free the actual struct instance. This is done here and not by the calling function. */ 500 /* Free the actual struct instance. This is done here and not by the calling function. */
502 free(to_be_destroyed); 501 free(to_be_destroyed);
503 } 502 }
504 503
505 /** \brief Helper function for load_pgm(...) to skip whitespace. */ 504 /** \brief Helper function for load_pgm(...) to skip whitespace. */
506 void load_pgm_skip(FILE *f) { 505 static void load_pgm_skip(FILE *f) {
507 int c, comment = 0; 506 int c, comment = 0;
508 do { 507 do {
509 c = fgetc(f); 508 c = fgetc(f);
510 if (c == '#') 509 if (c == '#')
511 comment = 1; 510 comment = 1;
531 * Can load either raw pgm (P5) or raw ppm (P6) image files as a binary image. 530 * Can load either raw pgm (P5) or raw ppm (P6) image files as a binary image.
532 * While a pgm file will be loaded normally (greyscale), the only thing that is 531 * While a pgm file will be loaded normally (greyscale), the only thing that is
533 * guaranteed with ppm is that all zero (R = 0, G = 0, B = 0) pixels will remain 532 * guaranteed with ppm is that all zero (R = 0, G = 0, B = 0) pixels will remain
534 * zero, and non-zero pixels will remain non-zero. 533 * zero, and non-zero pixels will remain non-zero.
535 */ 534 */
536 pgm_structure * load_pgm(const char * file_name) 535 static pgm_structure * load_pgm(const char * file_name)
537 { 536 {
538 int maximum_greyscale_value; 537 int maximum_greyscale_value;
539 FILE * input; 538 FILE * input;
540 int pnm_number; 539 int pnm_number;
541 pgm_structure * new_pgm = (pgm_structure *) safe_malloc (sizeof(pgm_structure)); 540 pgm_structure * new_pgm = (pgm_structure *) safe_malloc (sizeof(pgm_structure));
592 * halving the dimensions halves the distance. This function rounds up, because 591 * halving the dimensions halves the distance. This function rounds up, because
593 * a downwards rounding error could cause the filter to fail, but an upwards 592 * a downwards rounding error could cause the filter to fail, but an upwards
594 * rounding error will only cause a minor amount of excess blur in the chroma 593 * rounding error will only cause a minor amount of excess blur in the chroma
595 * planes. 594 * planes.
596 */ 595 */
597 pgm_structure * generate_half_size_image(vf_instance_t * vf, pgm_structure * input_image) 596 static pgm_structure * generate_half_size_image(vf_instance_t * vf, pgm_structure * input_image)
598 { 597 {
599 int x, y; 598 int x, y;
600 pgm_structure * new_pgm = (pgm_structure *) safe_malloc (sizeof(pgm_structure)); 599 pgm_structure * new_pgm = (pgm_structure *) safe_malloc (sizeof(pgm_structure));
601 int has_anything_changed = 1; 600 int has_anything_changed = 1;
602 int current_pass; 601 int current_pass;