Changeset 1360a812c7f40bf8e5c2caaaffaab6cf4aaa8271
- Timestamp:
- 02/02/07 21:51:11
(2 years ago)
- Author:
- Antoine Cellerier <dionoea@videolan.org>
- git-committer:
- Antoine Cellerier <dionoea@videolan.org> 1170449471 +0000
- git-parent:
[0a40fae13a6daf6e924f83c10b3064f72087ae7a]
- git-author:
- Antoine Cellerier <dionoea@videolan.org> 1170449471 +0000
- Message:
Copy clip_uint8() function from ffmpeg and replace where applicable for video filters.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r4ce5cc2 |
r1360a81 |
|
| 628 | 628 | } |
|---|
| 629 | 629 | |
|---|
| | 630 | /* function imported from libavutil/common.h */ |
|---|
| | 631 | static inline uint8_t clip_uint8_vlc( int32_t a ) |
|---|
| | 632 | { |
|---|
| | 633 | if( a&(~255) ) return (-a)>>31; |
|---|
| | 634 | else return a; |
|---|
| | 635 | } |
|---|
| | 636 | |
|---|
| 630 | 637 | /* Malloc with automatic error */ |
|---|
| 631 | 638 | #define MALLOC_VOID( var, type ) { var = (type*)malloc( sizeof( type) ); \ |
|---|
| rd3fe7f2 |
r1360a81 |
|
| 106 | 106 | { |
|---|
| 107 | 107 | }; |
|---|
| 108 | | |
|---|
| 109 | | inline static int32_t clip( int32_t a ) |
|---|
| 110 | | { |
|---|
| 111 | | return (a > 255) ? 255 : (a < 0) ? 0 : a; |
|---|
| 112 | | } |
|---|
| 113 | 108 | |
|---|
| 114 | 109 | /***************************************************************************** |
|---|
| … | … | |
| 260 | 255 | for( i = 0 ; i < 256 ; i++ ) |
|---|
| 261 | 256 | { |
|---|
| 262 | | pi_gamma[ i ] = clip( pow(i / 255.0, f_gamma) * 255.0); |
|---|
| | 257 | pi_gamma[ i ] = clip_uint8_vlc( pow(i / 255.0, f_gamma) * 255.0); |
|---|
| 263 | 258 | } |
|---|
| 264 | 259 | |
|---|
| … | … | |
| 266 | 261 | for( i = 0 ; i < 256 ; i++ ) |
|---|
| 267 | 262 | { |
|---|
| 268 | | pi_luma[ i ] = pi_gamma[clip( i_lum + i_cont * i / 256)]; |
|---|
| | 263 | pi_luma[ i ] = pi_gamma[clip_uint8_vlc( i_lum + i_cont * i / 256)]; |
|---|
| 269 | 264 | } |
|---|
| 270 | 265 | } |
|---|
| … | … | |
| 344 | 339 | #define WRITE_UV_CLIP() \ |
|---|
| 345 | 340 | i_u = *p_in++ ; i_v = *p_in_v++ ; \ |
|---|
| 346 | | *p_out++ = clip( (( ((i_u * i_cos + i_v * i_sin - i_x) >> 8) \ |
|---|
| | 341 | *p_out++ = clip_uint8_vlc( (( ((i_u * i_cos + i_v * i_sin - i_x) >> 8) \ |
|---|
| 347 | 342 | * i_sat) >> 8) + 128); \ |
|---|
| 348 | | *p_out_v++ = clip( (( ((i_v * i_cos - i_u * i_sin - i_y) >> 8) \ |
|---|
| | 343 | *p_out_v++ = clip_uint8_vlc( (( ((i_v * i_cos - i_u * i_sin - i_y) >> 8) \ |
|---|
| 349 | 344 | * i_sat) >> 8) + 128) |
|---|
| 350 | 345 | |
|---|
| rae6af36 |
r1360a81 |
|
| 419 | 419 | { |
|---|
| 420 | 420 | FOR |
|---|
| 421 | | if( a>>8 ) |
|---|
| 422 | | p_outpix[y*i_dst_pitch+x] = 255; |
|---|
| 423 | | else |
|---|
| 424 | | p_outpix[y*i_dst_pitch+x] = (uint8_t)a; |
|---|
| | 421 | p_outpix[y*i_dst_pitch+x] = clip_uint8( a ); |
|---|
| 425 | 422 | }} |
|---|
| 426 | 423 | } |
|---|
| r9ed0ed0 |
r1360a81 |
|
| 41 | 41 | #ifdef SYS_MINGW32 |
|---|
| 42 | 42 | #include <windows.h> |
|---|
| 43 | | #else |
|---|
| 44 | | #include <X11/Xlib.h> |
|---|
| | 43 | #else |
|---|
| | 44 | #include <X11/Xlib.h> |
|---|
| 45 | 45 | #endif |
|---|
| 46 | 46 | #define GAMMA 1 |
|---|
| … | … | |
| 368 | 368 | #ifdef OVERLAP |
|---|
| 369 | 369 | p_vout->p_sys->i_offset_x = var_CreateGetInteger( p_vout, "offset-x" ); |
|---|
| 370 | | if (p_vout->p_sys->i_col > 2) p_vout->p_sys->i_offset_x = 0; // offset-x is used in case of 2x1 wall & autocrop |
|---|
| | 370 | if (p_vout->p_sys->i_col > 2) p_vout->p_sys->i_offset_x = 0; // offset-x is used in case of 2x1 wall & autocrop |
|---|
| 371 | 371 | p_vout->p_sys->b_autocrop = !(var_CreateGetInteger( p_vout, "crop-ratio" ) == 0); |
|---|
| 372 | 372 | if (!p_vout->p_sys->b_autocrop) p_vout->p_sys->b_autocrop = var_CreateGetInteger( p_vout, "autocrop" ); |
|---|
| … | … | |
| 384 | 384 | p_vout->p_sys->i_ratio_max = var_CreateGetInteger( p_vout, "autocrop-ratio-max" ); // in crop module with autocrop ... |
|---|
| 385 | 385 | p_vout->p_sys->i_ratio = var_CreateGetInteger( p_vout, "crop-ratio" ); // in crop module with manual ratio ... |
|---|
| 386 | | |
|---|
| | 386 | |
|---|
| 387 | 387 | p_vout->p_sys->a_2 = d_p * p_vout->p_sys->bz_begin - (double)(d_p * d_p / (d_p - 1)) * p_vout->p_sys->bz_middle + (double)(d_p / (d_p - 1)) * p_vout->p_sys->bz_end; |
|---|
| 388 | 388 | p_vout->p_sys->a_1 = -(d_p + 1) * p_vout->p_sys->bz_begin + (double)(d_p * d_p / (d_p - 1)) * p_vout->p_sys->bz_middle - (double)(1 / (d_p - 1)) * p_vout->p_sys->bz_end; |
|---|
| … | … | |
| 499 | 499 | |
|---|
| 500 | 500 | #ifdef PACKED_YUV |
|---|
| 501 | | /***************************************************************************** |
|---|
| 502 | | * Clip: clip an 32 bits int in 8 bits |
|---|
| 503 | | *****************************************************************************/ |
|---|
| 504 | | inline static int32_t clip( int32_t a ) |
|---|
| 505 | | { |
|---|
| 506 | | return (a > 255) ? 255 : (a < 0) ? 0 : a; |
|---|
| 507 | | } |
|---|
| 508 | 501 | |
|---|
| 509 | 502 | /***************************************************************************** |
|---|
| … | … | |
| 517 | 510 | |
|---|
| 518 | 511 | if (input < 0.5) |
|---|
| 519 | | return clip((255 * pow(2 * input, gamma)) / 2); |
|---|
| | 512 | return clip_uint8((255 * pow(2 * input, gamma)) / 2); |
|---|
| 520 | 513 | else |
|---|
| 521 | | return clip(255 * (1 - pow(2 * (1 - input), gamma) / 2)); |
|---|
| | 514 | return clip_uint8(255 * (1 - pow(2 * (1 - input), gamma) / 2)); |
|---|
| 522 | 515 | |
|---|
| 523 | 516 | } |
|---|
| … | … | |
| 544 | 537 | i_window_width = GetSystemMetrics(SM_CXSCREEN); |
|---|
| 545 | 538 | i_window_height = GetSystemMetrics(SM_CYSCREEN); |
|---|
| 546 | | #else |
|---|
| | 539 | #else |
|---|
| 547 | 540 | Display *p_display = XOpenDisplay( "" ); |
|---|
| 548 | 541 | if (p_vout->p_sys->b_xinerama) |
|---|
| … | … | |
| 555 | 548 | i_window_width = DisplayWidth(p_display, 0); |
|---|
| 556 | 549 | i_window_height = DisplayHeight(p_display, 0); |
|---|
| 557 | | } |
|---|
| 558 | | XCloseDisplay( p_display ); |
|---|
| 559 | | free(p_display); |
|---|
| | 550 | } |
|---|
| | 551 | XCloseDisplay( p_display ); |
|---|
| | 552 | free(p_display); |
|---|
| 560 | 553 | #endif |
|---|
| 561 | 554 | var_SetInteger( p_vout, "width", i_window_width); |
|---|