#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include <limits.h>
#include <vlc_common.h>
#include <vlc_plugin.h>
*****************************************************************************/
static void HFlip(int *sx, int *sy, int w, int h, int dx, int dy)
{
+ VLC_UNUSED( h );
*sx = w - 1 - dx;
*sy = dy;
}
static void VFlip(int *sx, int *sy, int w, int h, int dx, int dy)
{
+ VLC_UNUSED( w );
*sx = dx;
*sy = h - 1 - dy;
}
static void R90(int *sx, int *sy, int w, int h, int dx, int dy)
{
+ VLC_UNUSED( h );
*sx = dy;
*sy = w - 1 - dx;
}
}
static void R270(int *sx, int *sy, int w, int h, int dx, int dy)
{
+ VLC_UNUSED( w );
*sx = h - 1 - dy;
*sy = dx;
}
static void Planar(plane_t *dst, const plane_t *src, convert_t f)
{
- for (int y = 0; y < src->i_visible_lines; y++) {
- for (int x = 0; x < src->i_visible_pitch; x++) {
+ for (int y = 0; y < dst->i_visible_lines; y++) {
+ for (int x = 0; x < dst->i_visible_pitch; x++) {
int sx, sy;
f(&sx, &sy, dst->i_visible_pitch, dst->i_visible_lines, x, y);
dst->p_pixels[y * dst->i_pitch + x] = src->p_pixels[sy * src->i_pitch + sx];
char name[8];
bool is_rotated;
convert_t convert;
+ convert_t iconvert;
void (*planar)(plane_t *dst, const plane_t *src);
} transform_description_t;
static const transform_description_t descriptions[] = {
- { "90", true, R90, PlanarR90, },
- { "180", false, R180, PlanarR180, },
- { "270", true, R270, PlanarR270, },
- { "hflip", false, HFlip, PlanarHFlip, },
- { "vflip", false, VFlip, PlanarVFlip, },
+ { "90", true, R90, R270, PlanarR90, },
+ { "180", false, R180, R180, PlanarR180, },
+ { "270", true, R270, R90, PlanarR270, },
+ { "hflip", false, HFlip, HFlip, PlanarHFlip, },
+ { "vflip", false, VFlip, VFlip, PlanarVFlip, },
- { "", false, NULL, NULL, }
+ { "", false, NULL, NULL, NULL, }
};
struct filter_sys_t {
static int Mouse(filter_t *filter, vlc_mouse_t *mouse,
const vlc_mouse_t *mold, const vlc_mouse_t *mnew)
{
+ VLC_UNUSED( mold );
+
const video_format_t *fmt = &filter->fmt_out.video;
const transform_description_t *dsc = filter->p_sys->dsc;
static int Open(vlc_object_t *object)
{
filter_t *filter = (filter_t *)object;
+ const video_format_t *src = &filter->fmt_in.video;
+ video_format_t *dst = &filter->fmt_out.video;
const vlc_chroma_description_t *chroma =
- vlc_fourcc_GetChromaDescription(filter->fmt_in.video.i_chroma);
+ vlc_fourcc_GetChromaDescription(src->i_chroma);
if (!chroma || chroma->plane_count < 3) {
- msg_Err(filter, "Unsupported chroma (%4.4s)",
- (char*)&filter->fmt_in.video.i_chroma);
+ msg_Err(filter, "Unsupported chroma (%4.4s)", (char*)&src->i_chroma);
/* TODO support packed and rgb */
return VLC_EGENERIC;
}
free(type_name);
if (sys->dsc->is_rotated) {
- /* TODO */
- msg_Err(filter, "Rotation mode not yet supported");
- free(sys);
- return VLC_EGENERIC;
+ if (!filter->b_allow_fmt_out_change) {
+ msg_Err(filter, "Format change is not allowed");
+ free(sys);
+ return VLC_EGENERIC;
+ }
+
+ dst->i_width = src->i_height;
+ dst->i_visible_width = src->i_visible_height;
+ dst->i_height = src->i_width;
+ dst->i_visible_height = src->i_visible_width;
+ dst->i_sar_num = src->i_sar_den;
+ dst->i_sar_den = src->i_sar_num;
+ }
+
+ dst->i_x_offset = INT_MAX;
+ dst->i_y_offset = INT_MAX;
+ for (int i = 0; i < 2; i++) {
+ int tx, ty;
+ sys->dsc->iconvert(&tx, &ty,
+ src->i_width, src->i_height,
+ src->i_x_offset + i * (src->i_visible_width - 1),
+ src->i_y_offset + i * (src->i_visible_height - 1));
+ dst->i_x_offset = __MIN(dst->i_x_offset, (unsigned)(1 + tx));
+ dst->i_y_offset = __MIN(dst->i_y_offset, (unsigned)(1 + ty));
}
filter->p_sys = sys;
}
#if 0
-/*****************************************************************************
- * Init: initialize Transform video thread output method
- *****************************************************************************/
-static int Init( vout_thread_t *p_vout )
-{
- video_format_t fmt;
-
- I_OUTPUTPICTURES = 0;
- memset( &fmt, 0, sizeof(video_format_t ) );
-
- /* Initialize the output structure */
- p_vout->output.i_chroma = p_vout->render.i_chroma;
- p_vout->output.i_width = p_vout->render.i_width;
- p_vout->output.i_height = p_vout->render.i_height;
- p_vout->output.i_aspect = p_vout->render.i_aspect;
- p_vout->fmt_out = p_vout->fmt_in;
- fmt = p_vout->fmt_out;
-
- /* Try to open the real video output */
- msg_Dbg( p_vout, "spawning the real video output" );
-
- if( p_vout->p_sys->b_rotation )
- {
- fmt.i_width = p_vout->fmt_out.i_height;
- fmt.i_visible_width = p_vout->fmt_out.i_visible_height;
- fmt.i_x_offset = p_vout->fmt_out.i_y_offset;
-
- fmt.i_height = p_vout->fmt_out.i_width;
- fmt.i_visible_height = p_vout->fmt_out.i_visible_width;
- fmt.i_y_offset = p_vout->fmt_out.i_x_offset;
-
- fmt.i_sar_num = p_vout->fmt_out.i_sar_den;
- fmt.i_sar_den = p_vout->fmt_out.i_sar_num;
- }
-
- p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
-
- /* Everything failed */
- if( p_vout->p_sys->p_vout == NULL )
- {
- msg_Err( p_vout, "cannot open vout, aborting" );
- return VLC_EGENERIC;
- }
-
- vout_filter_AllocateDirectBuffers( p_vout, VOUT_MAX_PICTURES );
-
- vout_filter_AddChild( p_vout, p_vout->p_sys->p_vout, MouseEvent );
-
- return VLC_SUCCESS;
-}
static void FilterI422( vout_thread_t *p_vout,
const picture_t *p_pic, picture_t *p_outpic )
{