#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_filter.h>
+#include "filter_picture.h"
/*****************************************************************************
* Module descriptor
video_format_FixRgb( &p_filter->fmt_in.video );
#if 0
- msg_Dbg( p_filter, "chroma: %4.4s -> %4.4s\n",
+ msg_Dbg( p_filter, "chroma: %4.4s -> %4.4s",
(char *)&p_filter->fmt_in.video.i_chroma,
(char *)&p_filter->fmt_out.video.i_chroma );
#endif
/***********************************************************************
* Utils
***********************************************************************/
-static inline uint8_t vlc_uint8( int v )
-{
- if( v > 255 )
- return 255;
- else if( v < 0 )
- return 0;
- return v;
-}
-
#define MAX_TRANS 255
#define TRANS_BITS 8
return (t * a) / 255;
}
-static inline void yuv_to_rgb( int *r, int *g, int *b,
- uint8_t y1, uint8_t u1, uint8_t v1 )
-{
- /* macros used for YUV pixel conversions */
-# define SCALEBITS 10
-# define ONE_HALF (1 << (SCALEBITS - 1))
-# define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
- int y, cb, cr, r_add, g_add, b_add;
-
- cb = u1 - 128;
- cr = v1 - 128;
- r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;
- g_add = - FIX(0.34414*255.0/224.0) * cb
- - FIX(0.71414*255.0/224.0) * cr + ONE_HALF;
- b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;
- y = (y1 - 16) * FIX(255.0/219.0);
- *r = vlc_uint8( (y + r_add) >> SCALEBITS );
- *g = vlc_uint8( (y + g_add) >> SCALEBITS );
- *b = vlc_uint8( (y + b_add) >> SCALEBITS );
-#undef FIX
-#undef ONE_HALF
-#undef SCALEBITS
-}
-
-static inline void rgb_to_yuv( uint8_t *y, uint8_t *u, uint8_t *v,
- int r, int g, int b )
-{
- *y = ( ( ( 66 * r + 129 * g + 25 * b + 128 ) >> 8 ) + 16 );
- *u = ( ( -38 * r - 74 * g + 112 * b + 128 ) >> 8 ) + 128 ;
- *v = ( ( 112 * r - 94 * g - 18 * b + 128 ) >> 8 ) + 128 ;
-}
-
static uint8_t *vlc_plane_start( int *pi_pitch,
const picture_t *p_picture,
int i_plane,
int i_x, i_y, i_trans = 0;
bool b_even_scanline = i_y_offset % 2;
+ bool b_swap_up = vlc_fourcc_AreUVPlanesSwapped( p_filter->fmt_out.video.i_chroma,
+ VLC_CODEC_I420 );
p_dst_y = vlc_plane_start( &i_dst_pitch, p_dst, Y_PLANE,
i_x_offset, i_y_offset, &p_filter->fmt_out.video, 1 );
- p_dst_u = vlc_plane_start( NULL, p_dst, U_PLANE,
+ p_dst_u = vlc_plane_start( NULL, p_dst, b_swap_up ? V_PLANE : U_PLANE,
i_x_offset, i_y_offset, &p_filter->fmt_out.video, 2 );
- p_dst_v = vlc_plane_start( NULL, p_dst, V_PLANE,
+ p_dst_v = vlc_plane_start( NULL, p_dst, b_swap_up ? U_PLANE : V_PLANE,
i_x_offset, i_y_offset, &p_filter->fmt_out.video, 2 );
p_src_y = vlc_plane_start( &i_src_pitch, p_src, Y_PLANE,
else
{
int i_rindex, i_gindex, i_bindex;
- uint32_t i_rmask, i_gmask, i_bmask;
-
- i_rmask = p_filter->fmt_out.video.i_rmask;
- i_gmask = p_filter->fmt_out.video.i_gmask;
- i_bmask = p_filter->fmt_out.video.i_bmask;
-
vlc_rgb_index( &i_rindex, &i_gindex, &i_bindex, &p_filter->fmt_out.video );
/* Draw until we reach the bottom of the subtitle */
return;
}
-
+ bool b_swap_up = vlc_fourcc_AreUVPlanesSwapped( p_filter->fmt_out.video.i_chroma,
+ VLC_CODEC_I420 );
i_dst_pitch = p_dst->p[Y_PLANE].i_pitch;
p_dst_y = p_dst->p[Y_PLANE].p_pixels + i_x_offset +
p_filter->fmt_out.video.i_x_offset +
p_dst->p[Y_PLANE].i_pitch *
( i_y_offset + p_filter->fmt_out.video.i_y_offset );
- p_dst_u = p_dst->p[U_PLANE].p_pixels + i_x_offset/2 +
+ const int i_u_plane = b_swap_up ? V_PLANE : U_PLANE;
+ p_dst_u = p_dst->p[i_u_plane].p_pixels + i_x_offset/2 +
p_filter->fmt_out.video.i_x_offset/2 +
( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
- p_dst->p[U_PLANE].i_pitch;
- p_dst_v = p_dst->p[V_PLANE].p_pixels + i_x_offset/2 +
+ p_dst->p[i_u_plane].i_pitch;
+ const int i_v_plane = b_swap_up ? U_PLANE : V_PLANE;
+ p_dst_v = p_dst->p[i_v_plane].p_pixels + i_x_offset/2 +
p_filter->fmt_out.video.i_x_offset/2 +
( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
- p_dst->p[V_PLANE].i_pitch;
+ p_dst->p[i_v_plane].i_pitch;
p_src_y = vlc_plane_start( &i_src_pitch, p_src, Y_PLANE,
0, 0, &p_filter->fmt_in.video, 1 );
int i_y;
bool b_even_scanline = i_y_offset % 2;
+ bool b_swap_up = vlc_fourcc_AreUVPlanesSwapped( p_filter->fmt_out.video.i_chroma,
+ VLC_CODEC_I420 );
i_dst_pitch = p_dst->p[Y_PLANE].i_pitch;
p_dst_y = p_dst->p[Y_PLANE].p_pixels + i_x_offset +
p_filter->fmt_out.video.i_x_offset +
p_dst->p[Y_PLANE].i_pitch *
( i_y_offset + p_filter->fmt_out.video.i_y_offset );
- p_dst_u = p_dst->p[U_PLANE].p_pixels + i_x_offset/2 +
+ const int i_u_plane = b_swap_up ? V_PLANE : U_PLANE;
+ p_dst_u = p_dst->p[i_u_plane].p_pixels + i_x_offset/2 +
p_filter->fmt_out.video.i_x_offset/2 +
( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
- p_dst->p[U_PLANE].i_pitch;
- p_dst_v = p_dst->p[V_PLANE].p_pixels + i_x_offset/2 +
+ p_dst->p[i_u_plane].i_pitch;
+ const int i_v_plane = b_swap_up ? U_PLANE : V_PLANE;
+ p_dst_v = p_dst->p[i_v_plane].p_pixels + i_x_offset/2 +
p_filter->fmt_out.video.i_x_offset/2 +
( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
- p_dst->p[V_PLANE].i_pitch;
+ p_dst->p[i_v_plane].i_pitch;
p_src_y = vlc_plane_start( &i_src_pitch, p_src, Y_PLANE,
0, 0, &p_filter->fmt_in.video, 1 );
int i_x, i_y, i_trans;
bool b_even_scanline = i_y_offset % 2;
+ bool b_swap_up = vlc_fourcc_AreUVPlanesSwapped( p_filter->fmt_out.video.i_chroma,
+ VLC_CODEC_I420 );
i_dst_pitch = p_dst->p[Y_PLANE].i_pitch;
p_dst_y = p_dst->p[Y_PLANE].p_pixels + i_x_offset +
p_filter->fmt_out.video.i_x_offset +
p_dst->p[Y_PLANE].i_pitch *
( i_y_offset + p_filter->fmt_out.video.i_y_offset );
- p_dst_u = p_dst->p[U_PLANE].p_pixels + i_x_offset/2 +
+ const int i_u_plane = b_swap_up ? V_PLANE : U_PLANE;
+ p_dst_u = p_dst->p[i_u_plane].p_pixels + i_x_offset/2 +
p_filter->fmt_out.video.i_x_offset/2 +
( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
- p_dst->p[U_PLANE].i_pitch;
- p_dst_v = p_dst->p[V_PLANE].p_pixels + i_x_offset/2 +
+ p_dst->p[i_u_plane].i_pitch;
+ const int i_v_plane = b_swap_up ? U_PLANE : V_PLANE;
+ p_dst_v = p_dst->p[i_v_plane].p_pixels + i_x_offset/2 +
p_filter->fmt_out.video.i_x_offset/2 +
( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
- p_dst->p[V_PLANE].i_pitch;
+ p_dst->p[i_v_plane].i_pitch;
i_src_pitch = p_src_pic->p->i_pitch;
p_src = p_src_pic->p->p_pixels + p_filter->fmt_in.video.i_x_offset +
uint8_t y, u, v;
bool b_even_scanline = i_y_offset % 2;
-
+ bool b_swap_up = vlc_fourcc_AreUVPlanesSwapped( p_filter->fmt_out.video.i_chroma,
+ VLC_CODEC_I420 );
i_dst_pitch = p_dst->p[Y_PLANE].i_pitch;
p_dst_y = p_dst->p[Y_PLANE].p_pixels + i_x_offset +
p_filter->fmt_out.video.i_x_offset +
p_dst->p[Y_PLANE].i_pitch *
( i_y_offset + p_filter->fmt_out.video.i_y_offset );
- p_dst_u = p_dst->p[U_PLANE].p_pixels + i_x_offset/2 +
+ const int i_u_plane = b_swap_up ? V_PLANE : U_PLANE;
+ p_dst_u = p_dst->p[i_u_plane].p_pixels + i_x_offset/2 +
p_filter->fmt_out.video.i_x_offset/2 +
( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
- p_dst->p[U_PLANE].i_pitch;
- p_dst_v = p_dst->p[V_PLANE].p_pixels + i_x_offset/2 +
+ p_dst->p[i_u_plane].i_pitch;
+ const int i_v_plane = b_swap_up ? U_PLANE : V_PLANE;
+ p_dst_v = p_dst->p[i_v_plane].p_pixels + i_x_offset/2 +
p_filter->fmt_out.video.i_x_offset/2 +
( i_y_offset + p_filter->fmt_out.video.i_y_offset ) / 2 *
- p_dst->p[V_PLANE].i_pitch;
+ p_dst->p[i_v_plane].i_pitch;
i_src_pix_pitch = p_src_pic->p->i_pixel_pitch;
i_src_pitch = p_src_pic->p->i_pitch;