diff options
Diffstat (limited to 'src/post/mosaico/mosaico.c')
-rw-r--r-- | src/post/mosaico/mosaico.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/src/post/mosaico/mosaico.c b/src/post/mosaico/mosaico.c index c9ac9ab4c..ec46e1ca0 100644 --- a/src/post/mosaico/mosaico.c +++ b/src/post/mosaico/mosaico.c @@ -1,23 +1,23 @@ /* * Copyright (C) 2000-2004 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * xine is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA */ - + /* * simple video mosaico plugin */ @@ -44,7 +44,7 @@ static void *mosaico_init_plugin(xine_t *xine, void *); static const post_info_t mosaico_special_info = { XINE_POST_TYPE_VIDEO_COMPOSE }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_POST, 9, "mosaico", XINE_VERSION_CODE, &mosaico_special_info, &mosaico_init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; @@ -84,9 +84,9 @@ struct mosaico_pip_s { }; struct post_mosaico_s { - post_plugin_t post; + post_plugin_t post; xine_post_in_t parameter_input; - + mosaico_pip_t *pip; int64_t vpts_limit; pthread_cond_t vpts_limit_changed; @@ -130,7 +130,7 @@ static void *mosaico_init_plugin(xine_t *xine, void *data) if (!this) return NULL; - + this->class.open_plugin = mosaico_open_plugin; this->class.get_identifier = mosaico_get_identifier; this->class.get_description = mosaico_get_description; @@ -149,17 +149,17 @@ static post_plugin_t *mosaico_open_plugin(post_class_t *class_gen, int inputs, xine_post_in_t *input_api; post_out_t *output; post_video_port_t *port; - static xine_post_api_t post_api = + static xine_post_api_t post_api = { mosaico_set_parameters, mosaico_get_parameters, mosaico_get_param_descr, mosaico_get_help }; int i; - + lprintf("mosaico open\n"); if (inputs < 2 || !this || !video_target || !video_target[0]) { free(this); return NULL; } - + _x_post_init(&this->post, 0, inputs); this->pip = (mosaico_pip_t *)calloc((inputs - 1), sizeof(mosaico_pip_t)); @@ -167,7 +167,7 @@ static post_plugin_t *mosaico_open_plugin(post_class_t *class_gen, int inputs, pthread_cond_init(&this->vpts_limit_changed, NULL); pthread_mutex_init(&this->mutex, NULL); - + /* the port for the background video */ port = _x_post_intercept_video_port(&this->post, video_target[0], &input, &output); port->intercept_frame = mosaico_intercept_frame; @@ -183,7 +183,7 @@ static post_plugin_t *mosaico_open_plugin(post_class_t *class_gen, int inputs, this->pip[i].w = 150; this->pip[i].h = 150; asprintf(&(this->pip[i].input_name), "video in %d", i+1); - + port = _x_post_intercept_video_port(&this->post, video_target[0], &input, NULL); port->new_port.close = mosaico_close; port->intercept_frame = mosaico_intercept_frame; @@ -224,7 +224,7 @@ static void mosaico_class_dispose(post_class_t *class_gen) static void mosaico_dispose(post_plugin_t *this_gen) { post_mosaico_t *this = (post_mosaico_t *)this_gen; - + if (_x_post_dispose(this_gen)) { int i; for (i = 0; i < this->pip_count; i++) @@ -246,7 +246,7 @@ static int mosaico_set_parameters(xine_post_t *this_gen, void *param_gen) { post_mosaico_t *this = (post_mosaico_t *)this_gen; mosaico_parameters_t *param = (mosaico_parameters_t *)param_gen; - + if (param->pip_num > this->pip_count) return 0; this->pip[param->pip_num - 1].x = param->x; this->pip[param->pip_num - 1].y = param->y; @@ -259,7 +259,7 @@ static int mosaico_get_parameters(xine_post_t *this_gen, void *param_gen) { post_mosaico_t *this = (post_mosaico_t *)this_gen; mosaico_parameters_t *param = (mosaico_parameters_t *)param_gen; - + if (param->pip_num > this->pip_count || param->pip_num < 1) param->pip_num = 1; param->x = this->pip[param->pip_num - 1].x; @@ -291,7 +291,7 @@ static void mosaico_close(xine_video_port_t *port_gen, xine_stream_t *stream) for (pip_num = 0; pip_num < this->pip_count; pip_num++) if (this->post.xine_post.video_input[pip_num+1] == port_gen) break; - + pthread_mutex_lock(&this->mutex); free_frame = this->pip[pip_num].frame; this->pip[pip_num].frame = NULL; @@ -320,11 +320,11 @@ static void frame_copy_content(vo_frame_t *to, vo_frame_t *from) case XINE_IMGFMT_YUY2: /* TODO: implement conversion to YV12 or implement support to paste * frames of different types together */ - break; - + break; + case XINE_IMGFMT_YV12: /* Y */ - size = to->pitches[0] * to->height; + size = to->pitches[0] * to->height; xine_fast_memcpy(to->base[0], from->base[0], size); /* U */ @@ -349,7 +349,7 @@ static void frame_paste(post_mosaico_t *this, vo_frame_t *background, int pip_nu unsigned long i, j; if (!this->pip[pip_num].frame) return; - + target_width = this->pip[pip_num].w; target_height = this->pip[pip_num].h; background_width = background->width; @@ -364,8 +364,8 @@ static void frame_paste(post_mosaico_t *this, vo_frame_t *background, int pip_nu switch (this->pip[pip_num].frame->format) { case XINE_IMGFMT_YUY2: /* TODO: implement YUY2 */ - break; - + break; + case XINE_IMGFMT_YV12: /* Y */ target_offset = 0; @@ -382,7 +382,7 @@ static void frame_paste(post_mosaico_t *this, vo_frame_t *background, int pip_nu pos = pos_y * background_width + pos_x; target_width = (target_width + 1) / 2; target_height = (target_height + 1) / 2; - + /* U */ target_offset = 0; for (j = 0; j < target_height; j++, target_offset += (background_width - target_width)) @@ -390,7 +390,7 @@ static void frame_paste(post_mosaico_t *this, vo_frame_t *background, int pip_nu source_offset = ((i * scale_x) >> shift_x) + (((j * scale_y) >> shift_y) * source_width); background->base[1][pos + target_offset] = this->pip[pip_num].frame->base[1][source_offset]; } - + /* V */ target_offset = 0; for (j = 0; j < target_height; j++, target_offset += (background_width - target_width)) @@ -398,7 +398,7 @@ static void frame_paste(post_mosaico_t *this, vo_frame_t *background, int pip_nu source_offset = ((i * scale_x) >> shift_x) + (((j * scale_y) >> shift_y) * source_width); background->base[2][pos + target_offset] = this->pip[pip_num].frame->base[2][source_offset]; } - + break; } } @@ -411,47 +411,47 @@ static int mosaico_draw_background(vo_frame_t *frame, xine_stream_t *stream) int pip_num, skip; pthread_mutex_lock(&this->mutex); - + if (frame->bad_frame) { _x_post_frame_copy_down(frame, frame->next); skip = frame->next->draw(frame->next, stream); _x_post_frame_copy_up(frame, frame->next); - + this->vpts_limit = frame->vpts + frame->duration; if (skip) { this->skip = skip; this->skip_vpts = frame->vpts; } else this->skip = 0; - + pthread_mutex_unlock(&this->mutex); pthread_cond_broadcast(&this->vpts_limit_changed); - + return skip; } - + background = port->original_port->get_frame(port->original_port, frame->width, frame->height, frame->ratio, frame->format, frame->flags | VO_BOTH_FIELDS); _x_post_frame_copy_down(frame, background); frame_copy_content(background, frame); - + for (pip_num = 0; pip_num < this->pip_count; pip_num++) frame_paste(this, background, pip_num); - + skip = background->draw(background, stream); _x_post_frame_copy_up(frame, background); this->vpts_limit = background->vpts + background->duration; background->free(background); - + if (skip) { this->skip = skip; this->skip_vpts = frame->vpts; } else this->skip = 0; - + pthread_mutex_unlock(&this->mutex); pthread_cond_broadcast(&this->vpts_limit_changed); - + return skip; } @@ -465,11 +465,11 @@ static int mosaico_draw(vo_frame_t *frame, xine_stream_t *stream) for (pip_num = 0; pip_num < this->pip_count; pip_num++) if (this->post.xine_post.video_input[pip_num+1] == frame->port) break; _x_assert(pip_num < this->pip_count); - + frame->lock(frame); - + pthread_mutex_lock(&this->mutex); - + /* the original output will never see this frame again */ _x_post_frame_u_turn(frame, stream); while (frame->vpts > this->vpts_limit || !this->vpts_limit) @@ -478,12 +478,12 @@ static int mosaico_draw(vo_frame_t *frame, xine_stream_t *stream) free_frame = this->pip[pip_num].frame; if (port->stream) this->pip[pip_num].frame = frame; - + if (this->skip && frame->vpts <= this->skip_vpts) skip = this->skip; else skip = 0; - + pthread_mutex_unlock(&this->mutex); if (free_frame) @@ -492,6 +492,6 @@ static int mosaico_draw(vo_frame_t *frame, xine_stream_t *stream) /* do not keep this frame when no stream is connected to us, * otherwise, this frame might never get freed */ frame->free(frame); - + return skip; } |