diff options
Diffstat (limited to 'src/dxr3')
-rw-r--r-- | src/dxr3/Makefile.am | 6 | ||||
-rw-r--r-- | src/dxr3/dxr3.h | 10 | ||||
-rw-r--r-- | src/dxr3/dxr3_decode_spu.c | 152 | ||||
-rw-r--r-- | src/dxr3/dxr3_decode_video.c | 178 | ||||
-rw-r--r-- | src/dxr3/dxr3_mpeg_encoders.c | 136 | ||||
-rw-r--r-- | src/dxr3/dxr3_scr.c | 58 | ||||
-rw-r--r-- | src/dxr3/dxr3_scr.h | 16 | ||||
-rw-r--r-- | src/dxr3/dxr3_spu_encoder.c | 38 | ||||
-rw-r--r-- | src/dxr3/em8300.h | 48 | ||||
-rw-r--r-- | src/dxr3/video_out_dxr3.c | 304 | ||||
-rw-r--r-- | src/dxr3/video_out_dxr3.h | 30 |
11 files changed, 488 insertions, 488 deletions
diff --git a/src/dxr3/Makefile.am b/src/dxr3/Makefile.am index 3c2cbafbc..f6beb521a 100644 --- a/src/dxr3/Makefile.am +++ b/src/dxr3/Makefile.am @@ -6,7 +6,7 @@ AM_CFLAGS = $(X_CFLAGS) $(LIBFAME_CFLAGS) if HAVE_DXR3 dxr3_modules = xineplug_decode_dxr3_video.la \ xineplug_decode_dxr3_spu.la \ - xineplug_vo_out_dxr3.la + xineplug_vo_out_dxr3.la endif if HAVE_X11 link_x_libs = $(X_LIBS) -lXext @@ -18,7 +18,7 @@ if HAVE_LIBRTE link_rte = -lrte endif -xineplug_LTLIBRARIES = $(dxr3_modules) +xineplug_LTLIBRARIES = $(dxr3_modules) xineplug_decode_dxr3_video_la_SOURCES = dxr3_decode_video.c xineplug_decode_dxr3_video_la_LIBADD = $(XINE_LIB) $(LTLIBINTL) @@ -41,7 +41,7 @@ xineplug_vo_out_dxr3_la_SOURCES = \ dxr3_mpeg_encoders.c \ dxr3_spu_encoder.c \ dxr3_scr.c \ - video_out_dxr3.c + video_out_dxr3.c xineplug_vo_out_dxr3_la_LIBADD = $(XINE_LIB) $(link_fame) $(link_rte) $(link_x_libs) $(LTLIBINTL) $(DYNAMIC_LD_LIBS) -lm xineplug_vo_out_dxr3_la_CFLAGS = $(VISIBILITY_FLAG) $(AM_CFLAGS) diff --git a/src/dxr3/dxr3.h b/src/dxr3/dxr3.h index f08ddcd04..78e74a7b4 100644 --- a/src/dxr3/dxr3.h +++ b/src/dxr3/dxr3.h @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 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 diff --git a/src/dxr3/dxr3_decode_spu.c b/src/dxr3/dxr3_decode_spu.c index 82c8f8da0..7682455eb 100644 --- a/src/dxr3/dxr3_decode_spu.c +++ b/src/dxr3/dxr3_decode_spu.c @@ -1,18 +1,18 @@ -/* +/* * 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 @@ -21,7 +21,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif - + /* dxr3 spu decoder plugin. * Accepts the spu data from xine and sends it directly to the * corresponding dxr3 device. Also handles dvd menu button highlights. @@ -76,7 +76,7 @@ static const decoder_info_t dxr3_spudec_info = { }; 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_SPU_DECODER, 16, "dxr3-spudec", XINE_VERSION_CODE, &dxr3_spudec_info, &dxr3_spudec_init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; @@ -114,7 +114,7 @@ struct pci_node_s { typedef struct dxr3_spudec_class_s { spu_decoder_class_t spu_decoder_class; - + int instance; /* we allow only one instance of this plugin */ } dxr3_spudec_class_t; @@ -124,10 +124,10 @@ typedef struct dxr3_spudec_s { xine_stream_t *stream; dxr3_driver_t *dxr3_vo; /* we need to talk to the video out */ xine_event_queue_t *event_queue; - + int devnum; int fd_spu; /* to access the dxr3 spu device */ - + dxr3_spu_stream_state_t spu_stream_state[MAX_SPU_STREAMS]; uint32_t clut[16]; /* the current color lookup table */ int menu; /* are we in a menu? */ @@ -135,7 +135,7 @@ typedef struct dxr3_spudec_s { pci_node_t pci_cur; /* a list of PCI packs, with the list head being current */ pthread_mutex_t pci_lock; uint32_t buttonN; /* currently highlighted button */ - + int anamorphic; /* this is needed to detect anamorphic menus */ } dxr3_spudec_t; @@ -154,7 +154,7 @@ static inline int dxr3_present(xine_stream_t *stream) plugin_node_t *node; video_driver_class_t *vo_class; int present = 0; - + if (stream->video_driver && stream->video_driver->node) { node = (plugin_node_t *)stream->video_driver->node; if (node->plugin_class) { @@ -181,7 +181,7 @@ static inline void dxr3_spudec_clear_nav_list(dxr3_spudec_t *this) static inline void dxr3_spudec_update_nav(dxr3_spudec_t *this) { metronom_clock_t *clock = this->stream->xine->clock; - + if (this->pci_cur.next && this->pci_cur.next->vpts <= clock->get_current_time(clock)) { pci_node_t *node = this->pci_cur.next; xine_fast_memcpy(&this->pci_cur, this->pci_cur.next, sizeof(pci_node_t)); @@ -201,17 +201,17 @@ static inline void dxr3_swab_clut(int *clut) static void *dxr3_spudec_init_plugin(xine_t *xine, void* data) { dxr3_spudec_class_t *this; - + this = calloc(1, sizeof(dxr3_spudec_class_t)); if (!this) return NULL; - + this->spu_decoder_class.open_plugin = dxr3_spudec_open_plugin; this->spu_decoder_class.get_identifier = dxr3_spudec_get_identifier; this->spu_decoder_class.get_description = dxr3_spudec_get_description; this->spu_decoder_class.dispose = dxr3_spudec_class_dispose; - + this->instance = 0; - + return &this->spu_decoder_class; } @@ -221,20 +221,20 @@ static spu_decoder_t *dxr3_spudec_open_plugin(spu_decoder_class_t *class_gen, xi dxr3_spudec_t *this; dxr3_spudec_class_t *class = (dxr3_spudec_class_t *)class_gen; char tmpstr[128]; - + if (class->instance) return NULL; if (!dxr3_present(stream)) return NULL; - + this = calloc(1, sizeof(dxr3_spudec_t)); if (!this) return NULL; - + this->spu_decoder.decode_data = dxr3_spudec_decode_data; this->spu_decoder.reset = dxr3_spudec_reset; this->spu_decoder.discontinuity = dxr3_spudec_discontinuity; this->spu_decoder.dispose = dxr3_spudec_dispose; this->spu_decoder.get_interact_info = dxr3_spudec_interact_info; this->spu_decoder.set_button = dxr3_spudec_set_button; - + this->class = class; this->stream = stream; /* We need to talk to dxr3 video out to coordinate spus and overlays */ @@ -243,7 +243,7 @@ static spu_decoder_t *dxr3_spudec_open_plugin(spu_decoder_class_t *class_gen, xi this->devnum = stream->xine->config->register_num(stream->xine->config, CONF_KEY, 0, CONF_NAME, CONF_HELP, 10, NULL, NULL); - + pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); if (this->dxr3_vo->fd_spu) this->fd_spu = this->dxr3_vo->fd_spu; @@ -251,7 +251,7 @@ static spu_decoder_t *dxr3_spudec_open_plugin(spu_decoder_class_t *class_gen, xi /* open dxr3 spu device */ snprintf(tmpstr, sizeof(tmpstr), "/dev/em8300_sp-%d", this->devnum); if ((this->fd_spu = open(tmpstr, O_WRONLY)) < 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("dxr3_decode_spu: Failed to open spu device %s (%s)\n"), tmpstr, strerror(errno)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); free(this); @@ -263,19 +263,19 @@ static spu_decoder_t *dxr3_spudec_open_plugin(spu_decoder_class_t *class_gen, xi this->dxr3_vo->fd_spu = this->fd_spu; } pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); - + this->menu = 0; this->button_filter = 1; this->pci_cur.pci.hli.hl_gi.hli_ss = 0; this->pci_cur.next = NULL; this->buttonN = 1; - + this->anamorphic = 0; - + pthread_mutex_init(&this->pci_lock, NULL); - + class->instance = 1; - + return &this->spu_decoder; } @@ -303,11 +303,11 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) dxr3_spu_stream_state_t *state = &this->spu_stream_state[stream_id]; uint32_t spu_channel = this->stream->spu_channel; xine_event_t *event; - + /* handle queued events */ while ((event = xine_event_get(this->event_queue))) { llprintf(LOG_SPU, "event caught: SPU_FD = %i\n",this->fd_spu); - + switch (event->type) { case XINE_EVENT_FRAME_FORMAT_CHANGE: /* we are in anamorphic mode, if the frame is 16:9, but not pan&scan'ed */ @@ -317,17 +317,17 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) llprintf(LOG_BTN, "anamorphic mode %s\n", this->anamorphic ? "on" : "off"); break; } - + xine_event_free(event); } - + /* check, if we need to process the next PCI from the list */ pthread_mutex_lock(&this->pci_lock); dxr3_spudec_update_nav(this); pthread_mutex_unlock(&this->pci_lock); - + if ( (buf->type & 0xffff0000) != BUF_SPU_DVD || - !(buf->decoder_flags & BUF_FLAG_SPECIAL) || + !(buf->decoder_flags & BUF_FLAG_SPECIAL) || buf->decoder_info[1] != BUF_SPECIAL_SPU_DVD_SUBTYPE ) return; @@ -337,7 +337,7 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) dxr3_swab_clut((int *)buf->content); pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_SETPALETTE, buf->content)) - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set CLUT (%s)\n", strerror(errno)); /* remember clut, when video out places some overlay we may need to restore it */ memcpy(this->clut, buf->content, 16 * sizeof(uint32_t)); @@ -347,20 +347,20 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) } if (buf->decoder_info[2] == SPU_DVD_SUBTYPE_NAV) { uint8_t *p = buf->content; - + llprintf(LOG_BTN, "got NAV packet\n"); pthread_mutex_lock(&this->pci_lock); - + /* just watch out for menus */ if (p[3] == 0xbf && p[6] == 0x00) { /* Private stream 2 */ pci_t pci; - + navRead_PCI(&pci, p + 7); llprintf(LOG_BTN, "PCI packet hli_ss is %d\n", pci.hli.hl_gi.hli_ss); - + if (pci.hli.hl_gi.hli_ss == 1) { /* menu ahead */ - + /* NAV packets contain start and end presentation timestamps, which tell the * application, when the highlight information in the NAV is supposed to be valid. * We handle these timestamps only in a very stripped-down way: We keep a list @@ -389,7 +389,7 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) dxr3_spudec_process_nav(this); } } - + if ((pci.hli.hl_gi.hli_ss == 0) && (this->pci_cur.pci.hli.hl_gi.hli_ss == 1)) { /* this is (or: should be, I hope I got this right) a subpicture plane, that hides all menu buttons */ @@ -413,7 +413,7 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) pthread_mutex_unlock(&this->pci_lock); return; } - + /* We parse the SPUs command and end sequence here for two reasons: * 1. Look for the display duration entry in the spu packets. * If the spu is a menu button highlight pane, this entry must not exist, @@ -494,7 +494,7 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) if (state->spu_length < 0) state->spu_length = 0; state->bytes_passed += buf->size; } - + /* filter unwanted streams */ if (buf->decoder_flags & BUF_FLAG_PREVIEW) { llprintf(LOG_SPU, "Dropping SPU channel %d. Preview data\n", stream_id); @@ -512,43 +512,43 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) /* We used to filter for SPU forcing here as well, but this does not work * this way with the DXR3, because we have to evaluate the SPU command sequence * to detect, if a particular SPU is forced or not. See the parsing code above. */ - + pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); - + /* write sync timestamp to the card */ if (buf->pts) { int64_t vpts; uint32_t vpts32; - + vpts = this->stream->metronom->got_spu_packet(this->stream->metronom, buf->pts); llprintf(LOG_PTS, "pts = %" PRId64 " vpts = %" PRIu64 "\n", buf->pts, vpts); vpts32 = vpts; if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_SETPTS, &vpts32)) - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: spu setpts failed (%s)\n", strerror(errno)); } - + /* has video out tampered with our palette */ if (this->dxr3_vo->clut_cluttered) { if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_SETPALETTE, this->clut)) - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set CLUT (%s)\n", strerror(errno)); this->dxr3_vo->clut_cluttered = 0; } - + /* write spu data to the card */ llprintf(LOG_SPU, "write: SPU_FD = %i\n",this->fd_spu); written = write(this->fd_spu, buf->content, buf->size); if (written < 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: spu device write failed (%s)\n", strerror(errno)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); return; } if (written != buf->size) - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: Could only write %zd of %d spu bytes.\n", written, buf->size); - + pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); } @@ -556,7 +556,7 @@ static void dxr3_spudec_reset(spu_decoder_t *this_gen) { dxr3_spudec_t *this = (dxr3_spudec_t *)this_gen; int i; - + for (i = 0; i < MAX_SPU_STREAMS; i++) this->spu_stream_state[i].spu_length = 0; pthread_mutex_lock(&this->pci_lock); @@ -567,7 +567,7 @@ static void dxr3_spudec_reset(spu_decoder_t *this_gen) static void dxr3_spudec_discontinuity(spu_decoder_t *this_gen) { dxr3_spudec_t *this = (dxr3_spudec_t *)this_gen; - + pthread_mutex_lock(&this->pci_lock); dxr3_spudec_clear_nav_list(this); pthread_mutex_unlock(&this->pci_lock); @@ -582,7 +582,7 @@ static void dxr3_spudec_dispose(spu_decoder_t *this_gen) 0x00, 0x01, 0x06, 0x00, 0x04, 0x00, 0x07, 0xFF, 0x00, 0x01, 0x00, 0x20, 0x02, 0xFF }; dxr3_spudec_t *this = (dxr3_spudec_t *)this_gen; - + llprintf(LOG_SPU, "close: SPU_FD = %i\n",this->fd_spu); pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); /* clear any remaining spu */ @@ -592,7 +592,7 @@ static void dxr3_spudec_dispose(spu_decoder_t *this_gen) this->fd_spu = 0; this->dxr3_vo->fd_spu = 0; pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); - + dxr3_spudec_clear_nav_list(this); xine_event_dispose_queue(this->event_queue); pthread_mutex_destroy(&this->pci_lock); @@ -603,7 +603,7 @@ static void dxr3_spudec_dispose(spu_decoder_t *this_gen) static int dxr3_spudec_interact_info(spu_decoder_t *this_gen, void *data) { dxr3_spudec_t *this = (dxr3_spudec_t *)this_gen; - + pthread_mutex_lock(&this->pci_lock); dxr3_spudec_update_nav(this); memcpy(data, &this->pci_cur.pci, sizeof(pci_t)); @@ -615,7 +615,7 @@ static void dxr3_spudec_set_button(spu_decoder_t *this_gen, int32_t button, int3 { dxr3_spudec_t *this = (dxr3_spudec_t *)this_gen; em8300_button_t btn; - + llprintf(LOG_BTN, "setting button\n"); this->buttonN = button; pthread_mutex_lock(&this->pci_lock); @@ -624,7 +624,7 @@ static void dxr3_spudec_set_button(spu_decoder_t *this_gen, int32_t button, int3 (dxr3_spudec_copy_nav_to_btn(this, mode - 1, &btn ) > 0)) { pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, &btn)) - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); } @@ -639,7 +639,7 @@ static void dxr3_spudec_set_button(spu_decoder_t *this_gen, int32_t button, int3 static void dxr3_spudec_process_nav(dxr3_spudec_t *this) { em8300_button_t btn; - + this->menu = 1; this->button_filter = 0; if (this->pci_cur.pci.hli.hl_gi.fosl_btnn > 0) { @@ -655,15 +655,15 @@ static void dxr3_spudec_process_nav(dxr3_spudec_t *this) if ((dxr3_spudec_copy_nav_to_btn(this, 0, &btn ) > 0)) { pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, &btn)) - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); } else { /* current button does not exist -> use another one */ xine_event_t event; - + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("requested button not available\n")); - + if (this->buttonN > this->pci_cur.pci.hli.hl_gi.btn_ns) this->buttonN = this->pci_cur.pci.hli.hl_gi.btn_ns; else @@ -673,11 +673,11 @@ static void dxr3_spudec_process_nav(dxr3_spudec_t *this) event.data = &this->buttonN; event.data_length = sizeof(this->buttonN); xine_event_send(this->stream, &event); - + if ((dxr3_spudec_copy_nav_to_btn(this, 0, &btn ) > 0)) { pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, &btn)) - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); } else { @@ -689,10 +689,10 @@ static void dxr3_spudec_process_nav(dxr3_spudec_t *this) static int dxr3_spudec_copy_nav_to_btn(dxr3_spudec_t *this, int32_t mode, em8300_button_t *btn) { btni_t *button_ptr = NULL; - + if ((this->buttonN <= 0) || (this->buttonN > this->pci_cur.pci.hli.hl_gi.btn_ns)) return -1; - + /* choosing a button from a matching button group */ if (this->anamorphic && !this->dxr3_vo->widescreen_enabled && @@ -700,7 +700,7 @@ static int dxr3_spudec_copy_nav_to_btn(dxr3_spudec_t *this, int32_t mode, em8300 this->stream->spu_channel_letterbox != this->stream->spu_channel && this->stream->spu_channel_letterbox >= 0) { unsigned int btns_per_group = 36 / this->pci_cur.pci.hli.hl_gi.btngr_ns; - + /* use a letterbox button group for letterboxed anamorphic menus on tv out */ if (!button_ptr && this->pci_cur.pci.hli.hl_gi.btngr_ns >= 1 && (this->pci_cur.pci.hli.hl_gi.btngr1_dsp_ty & 2)) button_ptr = &this->pci_cur.pci.hli.btnit[0 * btns_per_group + this->buttonN - 1]; @@ -708,13 +708,13 @@ static int dxr3_spudec_copy_nav_to_btn(dxr3_spudec_t *this, int32_t mode, em8300 button_ptr = &this->pci_cur.pci.hli.btnit[1 * btns_per_group + this->buttonN - 1]; if (!button_ptr && this->pci_cur.pci.hli.hl_gi.btngr_ns >= 3 && (this->pci_cur.pci.hli.hl_gi.btngr3_dsp_ty & 2)) button_ptr = &this->pci_cur.pci.hli.btnit[2 * btns_per_group + this->buttonN - 1]; - + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "No suitable letterbox button group found.\n"); _x_assert(button_ptr); - + } else { unsigned int btns_per_group = 36 / this->pci_cur.pci.hli.hl_gi.btngr_ns; - + /* otherwise use a normal 4:3 or widescreen button group */ if (!button_ptr && this->pci_cur.pci.hli.hl_gi.btngr_ns >= 1 && !(this->pci_cur.pci.hli.hl_gi.btngr1_dsp_ty & 6)) button_ptr = &this->pci_cur.pci.hli.btnit[0 * btns_per_group + this->buttonN - 1]; @@ -722,14 +722,14 @@ static int dxr3_spudec_copy_nav_to_btn(dxr3_spudec_t *this, int32_t mode, em8300 button_ptr = &this->pci_cur.pci.hli.btnit[1 * btns_per_group + this->buttonN - 1]; if (!button_ptr && this->pci_cur.pci.hli.hl_gi.btngr_ns >= 3 && !(this->pci_cur.pci.hli.hl_gi.btngr3_dsp_ty & 6)) button_ptr = &this->pci_cur.pci.hli.btnit[2 * btns_per_group + this->buttonN - 1]; - + } if (!button_ptr) { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: No suitable menu button group found, using group 1.\n"); button_ptr = &this->pci_cur.pci.hli.btnit[this->buttonN - 1]; } - + if(button_ptr->btn_coln != 0) { llprintf(LOG_BTN, "normal button clut, mode %d\n", mode); btn->color = (this->pci_cur.pci.hli.btn_colit.btn_coli[button_ptr->btn_coln-1][mode] >> 16); @@ -739,7 +739,7 @@ static int dxr3_spudec_copy_nav_to_btn(dxr3_spudec_t *this, int32_t mode, em8300 btn->right = button_ptr->x_end; btn->bottom = button_ptr->y_end; return 1; - } + } return -1; } diff --git a/src/dxr3/dxr3_decode_video.c b/src/dxr3/dxr3_decode_video.c index e68ba2b5c..75a371566 100644 --- a/src/dxr3/dxr3_decode_video.c +++ b/src/dxr3/dxr3_decode_video.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 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 @@ -21,7 +21,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif - + /* dxr3 video decoder plugin. * Accepts the video data from xine and sends it directly to the * corresponding dxr3 device. Takes precedence over the libmpeg2 @@ -77,7 +77,7 @@ static const decoder_info_t dxr3_video_decoder_info = { }; 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_VIDEO_DECODER, 18, "dxr3-mpeg2", XINE_VERSION_CODE, &dxr3_video_decoder_info, &dxr3_init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; @@ -99,9 +99,9 @@ static void dxr3_dispose(video_decoder_t *this_gen); /* plugin structures */ typedef struct dxr3_decoder_class_s { video_decoder_class_t video_decoder_class; - + int instance; /* we allow only one instance of this plugin */ - + metronom_clock_t *clock; /* used for syncing */ } dxr3_decoder_class_t; @@ -110,11 +110,11 @@ typedef struct dxr3_decoder_s { dxr3_decoder_class_t *class; xine_stream_t *stream; dxr3_scr_t *scr; /* shortcut to the scr plugin in the dxr3 video out */ - + int devnum; int fd_control; int fd_video; /* to access the dxr3 devices */ - + int have_header_info; int sequence_open; int width; @@ -123,26 +123,26 @@ typedef struct dxr3_decoder_s { int aspect_code; int frame_rate_code; int repeat_first_field; /* mpeg stream header data */ - + int force_aspect; /* when input plugin has better info, we are forced */ int force_pan_scan; /* to use a certain aspect or to do pan&scan */ - + int use_panscan; int panscan_smart_change; int afd_smart_change; int afd_code; /* use pan&scan info if present in stream */ - + int last_width; int last_height; int last_aspect_code; /* used to detect changes for event sending */ - + unsigned int dts_offset[3]; int sync_every_frame; int sync_retry; int enhanced_mode; int resync_window; int skip_count; /* syncing parameters */ - + int correct_durations; int64_t last_vpts; int force_duration_window; @@ -168,7 +168,7 @@ static inline int dxr3_present(xine_stream_t *stream) plugin_node_t *node; video_driver_class_t *vo_class; int present = 0; - + if (stream->video_driver && stream->video_driver->node) { node = (plugin_node_t *)stream->video_driver->node; if (node->plugin_class) { @@ -184,11 +184,11 @@ static inline int dxr3_present(xine_stream_t *stream) static inline int dxr3_mvcommand(int fd_control, int command) { em8300_register_t reg; - + reg.microcode_register = 1; reg.reg = 0; reg.val = command; - + return ioctl(fd_control, EM8300_IOCTL_WRITEREG, ®); } @@ -196,19 +196,19 @@ static inline int dxr3_mvcommand(int fd_control, int command) static void *dxr3_init_plugin(xine_t *xine, void *data) { dxr3_decoder_class_t *this; - + this = calloc(1, sizeof (dxr3_decoder_class_t)); if (!this) return NULL; - + this->video_decoder_class.open_plugin = dxr3_open_plugin; this->video_decoder_class.get_identifier = dxr3_get_identifier; this->video_decoder_class.get_description = dxr3_get_description; this->video_decoder_class.dispose = dxr3_class_dispose; - + this->instance = 0; - + this->clock = xine->clock; - + return &this->video_decoder_class; } @@ -220,40 +220,40 @@ static video_decoder_t *dxr3_open_plugin(video_decoder_class_t *class_gen, xine_ dxr3_decoder_class_t *class = (dxr3_decoder_class_t *)class_gen; config_values_t *cfg; char tmpstr[128]; - + if (class->instance) return NULL; if (!dxr3_present(stream)) return NULL; - + this = calloc(1, sizeof (dxr3_decoder_t)); if (!this) return NULL; - + cfg = stream->xine->config; - + this->video_decoder.decode_data = dxr3_decode_data; this->video_decoder.reset = dxr3_reset; this->video_decoder.discontinuity = dxr3_discontinuity; this->video_decoder.flush = dxr3_flush; this->video_decoder.dispose = dxr3_dispose; - + this->class = class; this->stream = stream; this->scr = NULL; - + this->devnum = cfg->register_num(cfg, CONF_KEY, 0, CONF_NAME, CONF_HELP, 10, NULL, NULL); - + snprintf(tmpstr, sizeof(tmpstr), "/dev/em8300-%d", this->devnum); llprintf(LOG_VID, "Entering video init, devname=%s.\n",tmpstr); - + /* open later, because dxr3_video_out might have it open until we request a frame */ this->fd_video = -1; - + if ((this->fd_control = open(tmpstr, O_WRONLY)) < 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("dxr3_decode_video: Failed to open control device %s (%s)\n"), tmpstr, strerror(errno)); free(this); return NULL; } - + this->use_panscan = cfg->register_enum(cfg, "dxr3.use_panscan", 0, panscan_types, _("use Pan & Scan info"), _("\"Pan & Scan\" is a special display mode which is sometimes used in MPEG " @@ -266,14 +266,14 @@ static video_decoder_t *dxr3_open_plugin(video_decoder_class_t *class_gen, xine_ "Enable Pan & Scan based on information embedded in DVB streams. This makes " "use of the Active Format Descriptor (AFD) used in some European DVB channels."), 10, dxr3_update_panscan, this); - + this->dts_offset[0] = 21600; this->dts_offset[1] = 21600; this->dts_offset[2] = 21600; - + this->force_duration_window = -FORCE_DURATION_WINDOW_SIZE; this->last_vpts = this->class->clock->get_current_time(this->class->clock); - + this->sync_every_frame = cfg->register_bool(cfg, "dxr3.playback.sync_every_frame", 0, _("try to sync video every frame"), _("Tries to set a synchronization timestamp for every frame. " @@ -292,14 +292,14 @@ static video_decoder_t *dxr3_open_plugin(video_decoder_class_t *class_gen, xine_ "correction for NTSC streams erroneously labeled as PAL " "streams is implemented. Enable only, when you encounter such streams."), 0, dxr3_update_correct_durations, this); - + /* the dxr3 needs a longer prebuffering to have time for its internal decoding */ this->stream->metronom->set_option(this->stream->metronom, METRONOM_PREBUFFER, 90000); - + (stream->video_out->open) (stream->video_out, stream); - + class->instance = 1; - + return &this->video_decoder; } @@ -317,7 +317,7 @@ static void dxr3_class_dispose(video_decoder_class_t *class_gen) { free(class_gen); } - + static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) { @@ -328,9 +328,9 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) vo_frame_t *img; uint8_t *buffer, byte; uint32_t shift; - + vpts = 0; - + /* handle aspect hints from xine-dvdnav */ if (buf->decoder_flags & BUF_FLAG_SPECIAL) { if (buf->decoder_info[1] == BUF_SPECIAL_ASPECT) { @@ -342,12 +342,12 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) this->force_pan_scan = 0; frame_format_change(this); - + this->last_aspect_code = this->aspect_code; } return; } - + /* parse frames in the buffer handed in, evaluate headers, * send frames to video_out and handle some syncing */ @@ -361,7 +361,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) } /* header code of some kind found */ shift = 0xffffff00; - + if (byte == 0xb2) { /* check for AFD data */ if (buffer + 5 < buf->content + buf->size) { @@ -450,7 +450,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) continue; if (buf->decoder_flags & BUF_FLAG_PREVIEW) continue; - + /* pretend like we have decoded a frame */ img = this->stream->video_out->get_frame(this->stream->video_out, this->width, this->height, this->ratio, @@ -458,20 +458,20 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) img->pts = buf->pts; img->bad_frame = 0; img->duration = get_duration(this); - + skip = img->draw(img, this->stream); - + if (skip <= 0) { /* don't skip */ vpts = img->vpts; /* copy so we can free img */ - + if (this->correct_durations) { /* calculate an average frame duration from metronom's vpts values */ this->avg_duration = this->avg_duration * 0.9 + (vpts - this->last_vpts) * 0.1; llprintf(LOG_PTS, "average frame duration %d\n", this->avg_duration); } - + if (this->skip_count) this->skip_count--; - + if (this->resync_window == 0 && this->scr && this->enhanced_mode && !this->scr->scanning) { /* we are in sync, so we can lock the stream now */ @@ -488,7 +488,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) llprintf(LOG_VID, "%d frames to skip\n", skip); vpts = 0; this->avg_duration = 0; - + /* handle frame skip conditions */ if (this->scr && !this->scr->scanning) this->skip_count += skip; if (this->skip_count > SKIP_TOLERANCE) { @@ -500,7 +500,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) this->skip_count = 0; this->resync_window = 0; } - + if (this->scr && this->scr->scanning) this->resync_window = 0; if (this->resync_window == 0 && this->scr && this->enhanced_mode && !this->scr->scanning) { @@ -519,7 +519,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) img->free(img); /* if sync_every_frame was disabled, decrease the counter - * for a retry + * for a retry * (it might be due to crappy studio logos and stuff * so we should give the main movie a chance) */ @@ -531,7 +531,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) } } if (buf->decoder_flags & BUF_FLAG_PREVIEW) return; - + /* ensure video device is open * (we open it late because on occasion the dxr3 video out driver * wants to open it) @@ -541,15 +541,15 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) metronom_clock_t *clock = this->class->clock; char tmpstr[128]; int64_t time; - + /* open the device for the decoder */ snprintf (tmpstr, sizeof(tmpstr), "/dev/em8300_mv-%d", this->devnum); if ((this->fd_video = open(tmpstr, O_WRONLY)) < 0) { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - _("dxr3_decode_video: Failed to open video device %s (%s)\n"), tmpstr, strerror(errno)); + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + _("dxr3_decode_video: Failed to open video device %s (%s)\n"), tmpstr, strerror(errno)); return; } - + /* We may want to issue a SETPTS, so make sure the scr plugin * is running and registered. Unfortuantely wa cannot do this * earlier, because the dxr3's internal scr gets confused @@ -562,11 +562,11 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) this->scr->scr_plugin.start(&this->scr->scr_plugin, time); clock->register_scr(clock, &this->scr->scr_plugin); } - + /* update the pts timestamp in the card, which tags the data we write to it */ if (vpts) { int64_t delay; - + /* The PTS values written to the DXR3 must be modified based on the difference * between stream's PTS and DTS (decoder timestamp). We receive this * difference via decoder_info */ @@ -582,7 +582,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) llprintf(LOG_PTS, "PTS to DTS correction: %d\n", this->dts_offset[1]); } vpts -= this->dts_offset[2]; - + delay = vpts - this->class->clock->get_current_time( this->class->clock); llprintf(LOG_PTS, "SETPTS got %" PRId64 "\n", vpts); @@ -596,7 +596,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_video: set video pts failed (%s)\n", strerror(errno)); } - + if (delay >= 90000) /* frame more than 1 sec ahead */ xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_video: WARNING: vpts %" PRId64 " is %.02f seconds ahead of time!\n", @@ -606,7 +606,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) } else if (buf->pts) llprintf(LOG_PTS, "skip buf->pts = %" PRId64 " (no vpts)\n", buf->pts); - + /* now write the content to the dxr3 mpeg device and, in a dramatic * break with open source tradition, check the return value */ @@ -617,7 +617,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) _("dxr3_decode_video: write to device would block. flushing\n")); dxr3_flush(this_gen); } else { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("dxr3_decode_video: video device write failed (%s)\n"), strerror(errno)); } return; @@ -630,7 +630,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) static void dxr3_reset(video_decoder_t *this_gen) { dxr3_decoder_t *this = (dxr3_decoder_t *)this_gen; - + this->sequence_open = 0; } @@ -638,10 +638,10 @@ static void dxr3_discontinuity(video_decoder_t *this_gen) { } -static void dxr3_flush(video_decoder_t *this_gen) +static void dxr3_flush(video_decoder_t *this_gen) { dxr3_decoder_t *this = (dxr3_decoder_t *)this_gen; - + if (this->sequence_open && ++this->sequence_open > 5 && _x_stream_info_get(this->stream, XINE_STREAM_INFO_VIDEO_HAS_STILL)) { /* The dxr3 needs a sequence end code for still menus to work correctly @@ -659,18 +659,18 @@ static void dxr3_dispose(video_decoder_t *this_gen) { dxr3_decoder_t *this = (dxr3_decoder_t *)this_gen; metronom_clock_t *clock = this->class->clock; - + if (this->scr) clock->unregister_scr(clock, &this->scr->scr_plugin); - + dxr3_mvcommand(this->fd_control, MVCOMMAND_FLUSHBUF); - + if (this->fd_video >= 0) close(this->fd_video); close(this->fd_control); - + this->stream->video_out->close(this->stream->video_out, this->stream); this->class->instance = 0; - + free(this); } @@ -684,11 +684,11 @@ static void parse_mpeg_header(dxr3_decoder_t *this, uint8_t * buffer) this->width = ((this->height >> 12) + 15) & ~15; this->height = ((this->height & 0xfff) + 15) & ~15; this->aspect_code = buffer[3] >> 4; - + this->have_header_info = 1; - + if (this->force_aspect) this->aspect_code = this->force_aspect; - + /* when width, height or aspect changes, * we have to send an event for dxr3 spu decoder */ if (!this->last_width || !this->last_height || !this->last_aspect_code || @@ -705,7 +705,7 @@ static void parse_mpeg_header(dxr3_decoder_t *this, uint8_t * buffer) static int get_duration(dxr3_decoder_t *this) { int duration; - + switch (this->frame_rate_code) { case 1: /* 23.976 */ duration = 3754; /* actually it's 3753.75 */ @@ -732,19 +732,19 @@ static int get_duration(dxr3_decoder_t *this) duration = 1500; break; default: - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, _("dxr3_decode_video: WARNING: unknown frame rate code %d\n"), this->frame_rate_code); duration = 0; break; } - + /* update stream metadata */ _x_stream_info_set(this->stream, XINE_STREAM_INFO_FRAME_DURATION, duration); - + if (this->correct_durations && duration) { /* we set an initial average frame duration here */ if (!this->avg_duration) this->avg_duration = duration; - + /* Apply a correction to the framerate-code if metronom * insists on a different frame duration. * The code below is for NTCS streams labeled as PAL streams. @@ -769,7 +769,7 @@ static int get_duration(dxr3_decoder_t *this) return 3000; } } - + if (this->force_duration_window == -FORCE_DURATION_WINDOW_SIZE) /* we are far from a force_duration window */ return duration; @@ -782,7 +782,7 @@ static int get_duration(dxr3_decoder_t *this) this->force_duration_window = -FORCE_DURATION_WINDOW_SIZE; } } - + return duration; } @@ -801,7 +801,7 @@ static void frame_format_change(dxr3_decoder_t *this) data.aspect = this->aspect_code; data.pan_scan = this->force_pan_scan; xine_event_send(this->stream, &event); - + /* update ratio */ switch (this->aspect_code) { case 2: @@ -817,12 +817,12 @@ static void frame_format_change(dxr3_decoder_t *this) if (this->have_header_info) this->ratio = (double)this->width / (double)this->height; } - + /* update stream metadata */ _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_WIDTH, this->width); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_HEIGHT, this->height); _x_stream_info_set(this->stream, XINE_STREAM_INFO_VIDEO_RATIO, 10000 * this->ratio); - + _x_meta_info_set_utf8(this->stream, XINE_META_INFO_VIDEOCODEC, "MPEG (DXR3)"); } diff --git a/src/dxr3/dxr3_mpeg_encoders.c b/src/dxr3/dxr3_mpeg_encoders.c index 0077a465b..8ca48c6ae 100644 --- a/src/dxr3/dxr3_mpeg_encoders.c +++ b/src/dxr3/dxr3_mpeg_encoders.c @@ -1,26 +1,26 @@ -/* +/* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a unix 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 */ - + /* mpeg encoders for the dxr3 video out plugin. * supports the libfame and librte mpeg encoder libraries. - */ + */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -51,7 +51,7 @@ #include "xineutils.h" #include "video_out_dxr3.h" -/* buffer size for encoded mpeg1 stream; will hold one intra frame +/* buffer size for encoded mpeg1 stream; will hold one intra frame * at 640x480 typical sizes are <50 kB. 512 kB should be plenty */ #define DEFAULT_BUFFER_SIZE 512*1024 @@ -67,7 +67,7 @@ static int rte_on_unneeded(dxr3_driver_t *drv); static int rte_on_close(dxr3_driver_t *drv); /* helper function */ -static void mp1e_callback(rte_context *context, void *data, ssize_t size, +static void mp1e_callback(rte_context *context, void *data, ssize_t size, void *user_data); /* encoder structure */ @@ -103,7 +103,7 @@ typedef struct { } fame_data_t; /* helper function */ -static int fame_prepare_frame(fame_data_t *this, dxr3_driver_t *drv, +static int fame_prepare_frame(fame_data_t *this, dxr3_driver_t *drv, dxr3_frame_t *frame); #endif @@ -118,15 +118,15 @@ static int lavc_on_close(dxr3_driver_t *drv); int dxr3_rte_init(dxr3_driver_t *drv) { rte_data_t* this; - + if (!rte_init()) { xprintf(drv->class->xine, XINE_VERBOSITY_LOG, _("dxr3_mpeg_encoder: failed to init librte\n")); return 0; } - + this = calloc(1, sizeof(rte_data_t)); if (!this) return 0; - + this->encoder_data.type = ENC_RTE; this->encoder_data.on_update_format = rte_on_update_format; this->encoder_data.on_frame_copy = NULL; @@ -134,7 +134,7 @@ int dxr3_rte_init(dxr3_driver_t *drv) this->encoder_data.on_unneeded = rte_on_unneeded; this->encoder_data.on_close = rte_on_close; this->context = 0; - + drv->enc = &this->encoder_data; return 1; } @@ -142,7 +142,7 @@ int dxr3_rte_init(dxr3_driver_t *drv) static int rte_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) { rte_data_t *this = (rte_data_t *)drv->enc; - rte_context *context; + rte_context *context; rte_codec *codec; double fps; @@ -152,13 +152,13 @@ static int rte_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) rte_context_destroy(this->context); this->context = 0; } - + if ((frame->vo_frame.pitches[0] % 16 != 0) || (frame->oheight % 16 != 0)) { - xprintf(drv->class->xine, XINE_VERBOSITY_LOG, + xprintf(drv->class->xine, XINE_VERBOSITY_LOG, _("dxr3_mpeg_encoder: rte only handles video dimensions which are multiples of 16\n")); return 0; } - + this->width = frame->vo_frame.pitches[0]; this->height = frame->oheight; @@ -172,7 +172,7 @@ static int rte_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) #if LOG_ENC rte_set_verbosity(context, 2); #endif - + /* get mpeg codec handle */ codec = rte_codec_set(context, RTE_STREAM_VIDEO, 0, "mpeg1_video"); if (!codec) { @@ -181,26 +181,26 @@ static int rte_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) this->context = 0; return 0; } - + this->rte_bitrate = drv->class->xine->config->register_range(drv->class->xine->config, "dxr3.encoding.rte_bitrate", 10000, 1000, 20000, - _("rte mpeg output bitrate (kbit/s)"), + _("rte mpeg output bitrate (kbit/s)"), _("The bitrate the mpeg encoder library librte should use for DXR3's encoding mode. " "Higher values will increase quality and CPU usage."), 10, NULL, NULL); this->rte_bitrate *= 1000; /* config in kbit/s, rte wants bit/s */ - - /* FIXME: this needs to be replaced with a codec option call. + + /* FIXME: this needs to be replaced with a codec option call. * However, there seems to be none for the colour format! - * So we'll use the deprecated set_video_parameters instead. + * So we'll use the deprecated set_video_parameters instead. * Alternative is to manually set context->video_format (RTE_YU... ) * and context->video_bytes (= width * height * bytes/pixel) */ - rte_set_video_parameters(context, + rte_set_video_parameters(context, (frame->vo_frame.format == XINE_IMGFMT_YV12 ? RTE_YUV420 : RTE_YUYV), - context->width, context->height, + context->width, context->height, context->video_rate, context->output_video_bits, context->gop_sequence); - + /* Now set a whole bunch of codec options * If I understand correctly, virtual_frame_rate is the frame rate * of the source (can be anything), while coded_frame_rate must be @@ -208,27 +208,27 @@ static int rte_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) */ fps = 90000.0 / frame->vo_frame.duration; if (!rte_option_set(codec, "virtual_frame_rate", fps)) - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: WARNING: rte_option_set failed; virtual_frame_rate = %g.\n", fps); if (!rte_option_set(codec, "coded_frame_rate", fps)) - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: WARNING: rte_option_set failed; coded_frame_rate = %g.\n", fps); if (!rte_option_set(codec, "bit_rate", (int)this->rte_bitrate)) xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: WARNING: rte_option_set failed; bit_rate = %d.\n", (int)this->rte_bitrate); if (!rte_option_set(codec, "gop_sequence", "I")) - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: WARNING: rte_option_set failed; gop_sequence = \"I\".\n"); /* just to be sure, disable motion comp (not needed in I frames) */ if (!rte_option_set(codec, "motion_compensation", 0)) xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: WARNING: rte_option_set failed; motion_compensation = 0.\n"); - + rte_set_input(context, RTE_VIDEO, RTE_PUSH, FALSE, NULL, NULL, NULL); rte_set_output(context, mp1e_callback, NULL, NULL); - + if (!rte_init_context(context)) { - xprintf(drv->class->xine, XINE_VERBOSITY_LOG, + xprintf(drv->class->xine, XINE_VERBOSITY_LOG, _("dxr3_mpeg_encoder: cannot init the context: %s\n"), context->error); rte_context_destroy(context); this->context = 0; @@ -236,7 +236,7 @@ static int rte_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) } /* do the sync'ing and start encoding */ if (!rte_start_encoding(context)) { - xprintf(drv->class->xine, XINE_VERBOSITY_LOG, + xprintf(drv->class->xine, XINE_VERBOSITY_LOG, _("dxr3_mpeg_encoder: cannot start encoding: %s\n"), context->error); rte_context_destroy(context); this->context = 0; @@ -244,11 +244,11 @@ static int rte_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) } this->rte_ptr = rte_push_video_data(context, NULL, 0); if (!this->rte_ptr) { - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: failed to get encoder buffer pointer.\n"); return 0; } - + return 1; } @@ -274,7 +274,7 @@ static int rte_on_display_frame(dxr3_driver_t *drv, dxr3_frame_t *frame) static int rte_on_unneeded(dxr3_driver_t *drv) { rte_data_t *this = (rte_data_t *)drv->enc; - + if (this->context) { rte_stop(this->context); rte_context_destroy(this->context); @@ -297,15 +297,15 @@ static void mp1e_callback(rte_context *context, void *data, ssize_t size, void * dxr3_driver_t *drv = (dxr3_driver_t *)user_data; char tmpstr[128]; ssize_t written; - + written = write(drv->fd_video, data, size); if (written < 0) { - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: video device write failed (%s)\n", strerror(errno)); return; } if (written != size) - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: Could only write %d of %d mpeg bytes.\n", written, size); } #endif @@ -315,10 +315,10 @@ static void mp1e_callback(rte_context *context, void *data, ssize_t size, void * int dxr3_fame_init(dxr3_driver_t *drv) { fame_data_t *this; - + this = calloc(1, sizeof(fame_data_t)); if (!this) return 0; - + this->encoder_data.type = ENC_FAME; this->encoder_data.on_update_format = fame_on_update_format; this->encoder_data.on_frame_copy = NULL; @@ -326,36 +326,36 @@ int dxr3_fame_init(dxr3_driver_t *drv) this->encoder_data.on_unneeded = fame_on_unneeded; this->encoder_data.on_close = fame_on_close; this->context = 0; - + drv->enc = &this->encoder_data; return 1; } -static int fame_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) +static int fame_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) { fame_data_t *this = (fame_data_t *)drv->enc; fame_parameters_t init_fp = FAME_PARAMETERS_INITIALIZER; double fps; - if (this->buf) free(this->buf); + if (this->buf) free(this->buf); this->buf = 0; this->out[0] = this->out[1] = this->out[2] = 0; - + /* if YUY2 and dimensions changed, we need to re-allocate the * internal YV12 buffer */ if (frame->vo_frame.format == XINE_IMGFMT_YUY2) { int image_size = frame->vo_frame.width * frame->oheight; - this->out[0] = xine_xmalloc_aligned(16, image_size * 3/2, + this->out[0] = xine_xmalloc_aligned(16, image_size * 3/2, (void *)&this->buf); - this->out[1] = this->out[0] + image_size; - this->out[2] = this->out[1] + image_size/4; + this->out[1] = this->out[0] + image_size; + this->out[2] = this->out[1] + image_size/4; /* fill with black (yuv 16,128,128) */ memset(this->out[0], 16, image_size); memset(this->out[1], 128, image_size/4); memset(this->out[2], 128, image_size/4); - lprintf("Using YUY2->YV12 conversion\n"); + lprintf("Using YUY2->YV12 conversion\n"); } if (this->context) { @@ -363,18 +363,18 @@ static int fame_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) fame_close(this->context); this->context = 0; } - + this->context = fame_open(); if (!this->context) { - xprintf(drv->class->xine, XINE_VERBOSITY_LOG, + xprintf(drv->class->xine, XINE_VERBOSITY_LOG, _("dxr3_mpeg_encoder: Couldn't start the FAME library\n")); return 0; } - + if (!this->buffer) this->buffer = (unsigned char *)malloc(DEFAULT_BUFFER_SIZE); if (!this->buffer) { - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: Couldn't allocate temp buffer for mpeg data\n"); return 0; } @@ -406,23 +406,23 @@ static int fame_on_update_format(dxr3_driver_t *drv, dxr3_frame_t *frame) if (fps < 23.988) { /* NTSC-FILM */ lprintf("setting mpeg output framerate to NTSC-FILM (23.976 Hz)\n"); this->fp.frame_rate_num = 24000; - this->fp.frame_rate_den = 1001; + this->fp.frame_rate_den = 1001; } else if (fps < 24.5) { /* FILM */ lprintf("setting mpeg output framerate to FILM (24 Hz)\n"); this->fp.frame_rate_num = 24; - this->fp.frame_rate_den = 1; + this->fp.frame_rate_den = 1; } else if (fps < 27.485) { /* PAL */ lprintf("setting mpeg output framerate to PAL (25 Hz)\n"); this->fp.frame_rate_num = 25; - this->fp.frame_rate_den = 1; + this->fp.frame_rate_den = 1; } else { /* NTSC */ lprintf("setting mpeg output framerate to NTSC (29.97 Hz)\n"); this->fp.frame_rate_num = 30000; this->fp.frame_rate_den = 1001; } - + fame_init (this->context, &this->fp, this->buffer, DEFAULT_BUFFER_SIZE); - + return 1; } @@ -448,17 +448,17 @@ static int fame_on_display_frame(dxr3_driver_t *drv, dxr3_frame_t *frame) size = fame_encode_frame(this->context, &this->yuv, NULL); #endif - frame->vo_frame.free(&frame->vo_frame); - + frame->vo_frame.free(&frame->vo_frame); + written = write(drv->fd_video, this->buffer, size); if (written < 0) { - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: video device write failed (%s)\n", strerror(errno)); return 0; } if (written != size) - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: Could only write %d of %d mpeg bytes.\n", written, size); return 1; @@ -467,7 +467,7 @@ static int fame_on_display_frame(dxr3_driver_t *drv, dxr3_frame_t *frame) static int fame_on_unneeded(dxr3_driver_t *drv) { fame_data_t *this = (fame_data_t *)drv->enc; - + if (this->context) { fame_close(this->context); this->context = 0; @@ -494,7 +494,7 @@ static int fame_prepare_frame(fame_data_t *this, dxr3_driver_t *drv, dxr3_frame_ if (frame->vo_frame.format == XINE_IMGFMT_YUY2) { /* need YUY2->YV12 conversion */ if (!(this->out[0] && this->out[1] && this->out[2]) ) { - xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(drv->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_mpeg_encoder: Internal YV12 buffer not created.\n"); return 0; } @@ -544,13 +544,13 @@ int dxr3_lavc_init(dxr3_driver_t *drv, plugin_node_t *node) void *ffmpeg; int (*init)(dxr3_driver_t *); int result; - + ffmpeg = dlopen(node->file->filename, RTLD_LAZY); if (!ffmpeg) return 0; - + init = dlsym(ffmpeg, "dxr3_encoder_init"); if (!init) return 0; - + result = init(drv); /* the close function is implemented here, because it will call dlclose() * and that should not be done be the library we are closing... */ diff --git a/src/dxr3/dxr3_scr.c b/src/dxr3/dxr3_scr.c index c95ab00a7..dd0ea5840 100644 --- a/src/dxr3/dxr3_scr.c +++ b/src/dxr3/dxr3_scr.c @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 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 @@ -55,11 +55,11 @@ static void dxr3_scr_update_priority(void *this_gen, xine_cfg_entry_t *entry) static inline int dxr3_mvcommand(int fd_control, int command) { em8300_register_t reg; - + reg.microcode_register = 1; reg.reg = 0; reg.val = command; - + return ioctl(fd_control, EM8300_IOCTL_WRITEREG, ®); } @@ -69,21 +69,21 @@ dxr3_scr_t *dxr3_scr_init(xine_t *xine) dxr3_scr_t *this; int devnum; char tmpstr[128]; - + this = calloc(1, sizeof(dxr3_scr_t)); - + devnum = xine->config->register_num(xine->config, CONF_KEY, 0, CONF_NAME, CONF_HELP, 10, NULL, NULL); snprintf(tmpstr, sizeof(tmpstr), "/dev/em8300-%d", devnum); if ((this->fd_control = open(tmpstr, O_WRONLY)) < 0) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "dxr3_scr: Failed to open control device %s (%s)\n", tmpstr, strerror(errno)); free(this); return NULL; } - + this->xine = xine; - + this->scr_plugin.interface_version = 3; this->scr_plugin.get_priority = dxr3_scr_get_priority; this->scr_plugin.start = dxr3_scr_start; @@ -91,7 +91,7 @@ dxr3_scr_t *dxr3_scr_init(xine_t *xine) this->scr_plugin.adjust = dxr3_scr_adjust; this->scr_plugin.set_fine_speed = dxr3_scr_set_speed; this->scr_plugin.exit = dxr3_scr_exit; - + this->priority = xine->config->register_num( xine->config, "dxr3.scr_priority", 10, _("SCR plugin priority"), _("Priority of the DXR3 SCR plugin. Values less than 5 mean that the " @@ -102,9 +102,9 @@ dxr3_scr_t *dxr3_scr_init(xine_t *xine) this->last_pts = 0; this->scanning = 0; this->sync = 0; - + pthread_mutex_init(&this->mutex, NULL); - + lprintf("init complete\n"); return this; } @@ -120,7 +120,7 @@ static void dxr3_scr_start(scr_plugin_t *scr, int64_t vpts) { dxr3_scr_t *this = (dxr3_scr_t *)scr; uint32_t vpts32 = vpts >> 1; - + pthread_mutex_lock(&this->mutex); this->last_pts = vpts32; this->offset = vpts - ((int64_t)vpts32 << 1); @@ -140,7 +140,7 @@ static int64_t dxr3_scr_get_current(scr_plugin_t *scr) dxr3_scr_t *this = (dxr3_scr_t *)scr; uint32_t pts; int64_t current; - + pthread_mutex_lock(&this->mutex); if (ioctl(this->fd_control, EM8300_IOCTL_SCR_GET, &pts)) xprintf(this->xine, XINE_VERBOSITY_DEBUG, "dxr3_scr: get current failed (%s)\n", strerror(errno)); @@ -152,7 +152,7 @@ static int64_t dxr3_scr_get_current(scr_plugin_t *scr) this->last_pts = pts; current = ((int64_t)pts << 1) + this->offset; pthread_mutex_unlock(&this->mutex); - + return current; } @@ -161,7 +161,7 @@ static void dxr3_scr_adjust(scr_plugin_t *scr, int64_t vpts) dxr3_scr_t *this = (dxr3_scr_t *)scr; uint32_t current_pts32; int32_t offset32; - + pthread_mutex_lock(&this->mutex); if (ioctl(this->fd_control, EM8300_IOCTL_SCR_GET, ¤t_pts32)) xprintf(this->xine, XINE_VERBOSITY_DEBUG, "dxr3_scr: adjust get failed (%s)\n", strerror(errno)); @@ -187,7 +187,7 @@ static int dxr3_scr_set_speed(scr_plugin_t *scr, int speed) int playmode; pthread_mutex_lock(&this->mutex); - + em_speed = 0x900LL * (int64_t)speed / XINE_FINE_SPEED_NORMAL; switch (em_speed) { case 0: @@ -200,24 +200,24 @@ static int dxr3_scr_set_speed(scr_plugin_t *scr, int speed) playmode = MVCOMMAND_SYNC; else playmode = MVCOMMAND_START; - break; + break; default: playmode = MVCOMMAND_START; } - + if (dxr3_mvcommand(this->fd_control, playmode)) xprintf(this->xine, XINE_VERBOSITY_DEBUG, "dxr3_scr: failed to playmode (%s)\n", strerror(errno)); - + if(em_speed > 0x900) this->scanning = 1; else this->scanning = 0; - + if (ioctl(this->fd_control, EM8300_IOCTL_SCR_SETSPEED, &em_speed)) xprintf(this->xine, XINE_VERBOSITY_DEBUG, "dxr3_scr: failed to set speed (%s)\n", strerror(errno)); - + pthread_mutex_unlock(&this->mutex); - + lprintf("speed set to mode %d\n", speed); return speed; } @@ -225,7 +225,7 @@ static int dxr3_scr_set_speed(scr_plugin_t *scr, int speed) static void dxr3_scr_exit(scr_plugin_t *scr) { dxr3_scr_t *this = (dxr3_scr_t *)scr; - + close(this->fd_control); pthread_mutex_destroy(&this->mutex); free(this); @@ -237,8 +237,8 @@ static void dxr3_scr_exit(scr_plugin_t *scr) static void dxr3_scr_update_priority(void *this_gen, xine_cfg_entry_t *entry) { dxr3_scr_t *this = (dxr3_scr_t *)this_gen; - + this->priority = entry->num_value; - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "dxr3_scr: setting scr priority to %d\n", entry->num_value); } diff --git a/src/dxr3/dxr3_scr.h b/src/dxr3/dxr3_scr.h index d0e155c27..612f16ccb 100644 --- a/src/dxr3/dxr3_scr.h +++ b/src/dxr3/dxr3_scr.h @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2003 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 @@ -25,11 +25,11 @@ typedef struct dxr3_scr_s { scr_plugin_t scr_plugin; pthread_mutex_t mutex; - + xine_t *xine; - + int fd_control; /* to access the dxr3 control device */ - + int priority; int64_t offset; /* difference between real scr and internal dxr3 clock */ uint32_t last_pts; /* last known value of internal dxr3 clock to detect wrap around */ diff --git a/src/dxr3/dxr3_spu_encoder.c b/src/dxr3/dxr3_spu_encoder.c index 2517063ac..4eb506e8c 100644 --- a/src/dxr3/dxr3_spu_encoder.c +++ b/src/dxr3/dxr3_spu_encoder.c @@ -1,18 +1,18 @@ -/* +/* * 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 @@ -68,7 +68,7 @@ static void write_nibble(spu_encoder_t *this, int *offset, int *higher_nibble spu_encoder_t *dxr3_spu_encoder_init(void) { spu_encoder_t *this; - + this = (spu_encoder_t *)malloc(sizeof(spu_encoder_t)); this->target = NULL; this->need_reencode = 0; @@ -94,7 +94,7 @@ void dxr3_spu_encode(spu_encoder_t *this) static void convert_palette(spu_encoder_t *this) { int i, y, cb, cr, r, g, b; - + if (!this->overlay->rgb_clut) { for (i = 0; i < OVL_PALETTE_SIZE; i++) { y = (this->overlay->color[i] >> 16) & 0xff; @@ -137,7 +137,7 @@ static void create_histogram(spu_encoder_t *this) { rle_elem_t *rle; int i, x, y, len, part; - + for (i = 0; i < OVL_PALETTE_SIZE; i++) this->map[i] = this->clip_map[i] = 0; x = y = 0; @@ -180,14 +180,14 @@ static void generate_clut(spu_encoder_t *this) { int i, max, spu_color; double dist, diff; - + /* find first maximum -> first spu color */ max = 0; for (i = 1; i < OVL_PALETTE_SIZE; i++) if (this->map[i] > this->map[max]) max = i; this->color[0] = this->overlay->color[max]; this->trans[0] = this->overlay->trans[max]; - + for (spu_color = 1; spu_color < 4; spu_color++) { /* modify histogram and find next maximum -> next spu color */ max = 0; @@ -221,7 +221,7 @@ static void generate_clut(spu_encoder_t *this) if (this->clip_map[i] > this->clip_map[max]) max = i; this->hili_color[0] = this->overlay->hili_color[max]; this->hili_trans[0] = this->overlay->hili_trans[max]; - + for (spu_color = 1; spu_color < 4; spu_color++) { /* modify histogram and find next maximum -> next spu color */ max = 0; @@ -252,7 +252,7 @@ static void map_colors(spu_encoder_t *this) { int i, min, spu_color; double dist, diff, min_dist; - + /* for all colors in overlay palette find closest spu color */ for (i = 0; i < OVL_PALETTE_SIZE; i++) { min = 0; @@ -299,7 +299,7 @@ static void map_colors(spu_encoder_t *this) static void convert_clut(spu_encoder_t *this) { int i, r, g, b, y, cb, cr; - + for (i = 0; i < 4; i++) { r = (this->color[i] >> 16) & 0xff; g = (this->color[i] >> 8) & 0xff; @@ -311,7 +311,7 @@ static void convert_clut(spu_encoder_t *this) } for (i = 4; i < 16; i++) this->color[i] = 0x00008080; - + for (i = 0; i < 4; i++) { r = (this->hili_color[i] >> 16) & 0xff; g = (this->hili_color[i] >> 8) & 0xff; @@ -330,15 +330,15 @@ static void convert_overlay(spu_encoder_t *this) int offset = 0, field_start[2]; rle_elem_t *rle; int field, i, len, part, x, y, higher_nibble = 1; - + /* size will be determined later */ write_byte(this, &offset, 0x00); write_byte(this, &offset, 0x00); - + /* control sequence pointer will be determined later */ write_byte(this, &offset, 0x00); write_byte(this, &offset, 0x00); - + for (field = 0; field < 2; field++) { write_byte(this, &offset, 0x00); write_byte(this, &offset, 0x00); @@ -373,10 +373,10 @@ static void convert_overlay(spu_encoder_t *this) } } } - + /* we should be byte aligned here */ _x_assert(higher_nibble); - + /* control sequence starts here */ this->target[2] = offset >> 8; this->target[3] = offset & 0xff; diff --git a/src/dxr3/em8300.h b/src/dxr3/em8300.h index 44fd8cac3..b862f1d49 100644 --- a/src/dxr3/em8300.h +++ b/src/dxr3/em8300.h @@ -186,7 +186,7 @@ typedef struct { #define IRQSTATUS_AUDIO_FIFO 0x8 #define ENCODER_UNKNOWN 0 -#define ENCODER_ADV7175 1 +#define ENCODER_ADV7175 1 #define ENCODER_ADV7170 2 #define ENCODER_BT865 3 @@ -235,21 +235,21 @@ struct em8300_audio_s { struct em8300_s { char name[40]; - + int chip_revision; int pci_revision; - + int inuse[4]; int nonblock[4]; int ucodeloaded; - + struct pci_dev *dev; ulong adr; volatile unsigned *mem; ulong memsize; - + int playmode; - + /* Sysfs */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,46) struct class_device classdev; @@ -263,7 +263,7 @@ struct em8300_s struct fifo_s *mafifo; struct fifo_s *spfifo; int mtrr_reg; - + /* DICOM */ int dicom_vertoffset; int dicom_horizoffset; @@ -272,47 +272,47 @@ struct em8300_s int dicom_saturation; int dicom_tvout; struct displaybuffer_info_s dbuf_info; - + /* I2C */ int i2c_pin_reg; int i2c_oe_reg; - + /* different between revision 1 and revision 2 boards */ int mystery_divisor; - + /* I2C bus 1*/ struct i2c_algo_bit_data i2c_data_1; struct i2c_adapter i2c_ops_1; - + /* I2C bus 2*/ struct i2c_algo_bit_data i2c_data_2; struct i2c_adapter i2c_ops_2; - + /* I2C clients */ int encoder_type; struct i2c_client *encoder; - + /* Microcode registers */ unsigned ucode_regs[MAX_UCODE_REGISTER]; int var_ucode_reg1; /* These are registers that differ */ int var_ucode_reg2; /* between versions 1 and 2 of the board */ int var_ucode_reg3; /* " */ - + /* Interrupt */ unsigned irqmask; - + /* Clockgenerator */ int clockgen; int clockgen_overlaymode; int clockgen_tvmode; - + /* Timing measurement */ struct timeval tv, last_status_time; long irqtimediff; int irqcount; int frames; int scr; - + /* Audio */ struct em8300_audio_s audio; int audio_mode; @@ -321,7 +321,7 @@ struct em8300_s /* */ int dword_DB4; unsigned char byte_D90[24]; - + /* Video */ int video_mode; int video_playmode; @@ -330,7 +330,7 @@ struct em8300_s uint32_t video_lastpts; int video_ptsvalid,video_offset,video_count; int video_ptsfifo_ptr; -#if LINUX_VERSION_CODE < 0x020314 +#if LINUX_VERSION_CODE < 0x020314 struct wait_queue *video_ptsfifo_wait; struct wait_queue *vbi_wait; #else @@ -340,20 +340,20 @@ struct em8300_s int video_ptsfifo_waiting; int video_first; int var_video_value; - + /* Sub Picture */ int sp_pts, sp_ptsvalid, sp_count; int sp_ptsfifo_ptr; -#if LINUX_VERSION_CODE < 0x020314 +#if LINUX_VERSION_CODE < 0x020314 struct wait_queue *sp_ptsfifo_wait; #else wait_queue_head_t sp_ptsfifo_wait; #endif int sp_ptsfifo_waiting; int sp_mode; - + int linecounter; - + /* EM9010 overlay processor */ int overlay_enabled; int overlay_mode; @@ -373,7 +373,7 @@ struct em8300_s #if LINUX_VERSION_CODE > KERNEL_VERSION(2,4,0) /* Memory exported via mmap() */ struct list_head memory; -#endif +#endif /* To support different options for different cards */ unsigned int card_nr; diff --git a/src/dxr3/video_out_dxr3.c b/src/dxr3/video_out_dxr3.c index 189824183..3d38e6640 100644 --- a/src/dxr3/video_out_dxr3.c +++ b/src/dxr3/video_out_dxr3.c @@ -1,28 +1,28 @@ -/* +/* * Copyright (C) 2000-2003 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 */ - -/* mpeg1 encoding video out plugin for the dxr3. + +/* mpeg1 encoding video out plugin for the dxr3. * - * modifications to the original dxr3 video out plugin by + * modifications to the original dxr3 video out plugin by * Mike Lampard <mlampard at users.sourceforge.net> - * this first standalone version by + * this first standalone version by * Harm van der Heijden <hrm at users.sourceforge.net> */ @@ -90,7 +90,7 @@ static const vo_info_t vo_info_dxr3_aa = { }; const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ #ifdef HAVE_X11 { PLUGIN_VIDEO_OUT, 21, "dxr3", XINE_VERSION_CODE, &vo_info_dxr3_x11, &dxr3_x11_init_plugin }, #endif @@ -149,7 +149,7 @@ static void dxr3_update_enhanced_mode(void *this_gen, xine_cfg_entry_t *e static void *dxr3_x11_init_plugin(xine_t *xine, void *visual_gen) { dxr3_driver_class_t *this = dxr3_vo_init_plugin(xine, visual_gen); - + if (!this) return NULL; this->visual_type = XINE_VISUAL_TYPE_X11; return &this->video_driver_class; @@ -159,7 +159,7 @@ static void *dxr3_x11_init_plugin(xine_t *xine, void *visual_gen) static void *dxr3_aa_init_plugin(xine_t *xine, void *visual_gen) { dxr3_driver_class_t *this = dxr3_vo_init_plugin(xine, visual_gen); - + if (!this) return NULL; this->visual_type = XINE_VISUAL_TYPE_AA; return &this->video_driver_class; @@ -168,10 +168,10 @@ static void *dxr3_aa_init_plugin(xine_t *xine, void *visual_gen) static dxr3_driver_class_t *dxr3_vo_init_plugin(xine_t *xine, void *visual_gen) { dxr3_driver_class_t *this; - + this = calloc(1, sizeof(dxr3_driver_class_t)); if (!this) return NULL; - + this->devnum = xine->config->register_num(xine->config, CONF_KEY, 0, CONF_NAME, CONF_HELP, 10, NULL, NULL); @@ -179,13 +179,13 @@ static dxr3_driver_class_t *dxr3_vo_init_plugin(xine_t *xine, void *visual_gen) this->video_driver_class.get_identifier = dxr3_vo_get_identifier; this->video_driver_class.get_description = dxr3_vo_get_description; this->video_driver_class.dispose = dxr3_vo_class_dispose; - + this->xine = xine; - + this->instance = 0; - + this->scr = dxr3_scr_init(xine); - + return this; } @@ -202,7 +202,7 @@ static char *dxr3_vo_get_description(video_driver_class_t *class_gen) static void dxr3_vo_class_dispose(video_driver_class_t *class_gen) { dxr3_driver_class_t *class = (dxr3_driver_class_t *)class_gen; - + if(class->scr) class->scr->scr_plugin.exit(&class->scr->scr_plugin); free(class_gen); @@ -229,12 +229,12 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v static const char const *tv_modes[] = { "ntsc", "pal", "pal60" , "default", NULL }; int list_id, list_size; xine_sarray_t *plugin_list; - + if (class->instance) return NULL; - + this = calloc(1, sizeof(dxr3_driver_t)); if (!this) return NULL; - + this->vo_driver.get_capabilities = dxr3_get_capabilities; this->vo_driver.alloc_frame = dxr3_alloc_frame; this->vo_driver.update_frame_format = dxr3_update_frame_format; @@ -248,13 +248,13 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v this->vo_driver.get_property_min_max = dxr3_get_property_min_max; this->vo_driver.gui_data_exchange = dxr3_gui_data_exchange; this->vo_driver.dispose = dxr3_dispose; - + pthread_mutex_init(&this->video_device_lock, NULL); pthread_mutex_init(&this->spu_device_lock, NULL); - + _x_vo_scale_init(&this->scale, 0, 0, config); _x_alphablend_init(&this->alphablend_extra_data, class->xine); - + this->class = class; this->swap_fields = config->register_bool(config, "dxr3.encoding.swap_fields", 0, _("swap odd and even lines"), @@ -271,7 +271,7 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v _("use smooth play mode for mpeg encoder playback"), _("Enabling this option will utilise a smoother play mode for non-MPEG content."), 20, dxr3_update_enhanced_mode, this); - + snprintf(tmpstr, sizeof(tmpstr), "/dev/em8300-%d", class->devnum); llprintf(LOG_VID, "Entering video init, devname = %s.\n", tmpstr); if ((this->fd_control = open(tmpstr, O_WRONLY)) < 0) { @@ -281,10 +281,10 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v return 0; } - + snprintf (tmpstr, sizeof(tmpstr), "/dev/em8300_mv-%d", class->devnum); if ((this->fd_video = open (tmpstr, O_WRONLY | O_SYNC )) < 0) { - xprintf(this->class->xine, XINE_VERBOSITY_LOG, + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: Failed to open video device %s (%s)\n"), tmpstr, strerror(errno)); return 0; } @@ -342,45 +342,45 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v "but xine support for them is outdated, so these might fail to work."), 0, NULL, NULL); if ((strcmp(available_encoders[encoder], "libavcodec") == 0) && !dxr3_lavc_init(this, node)) { - xprintf(this->class->xine, XINE_VERBOSITY_LOG, + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: Mpeg encoder libavcodec failed to init.\n")); return 0; } #ifdef HAVE_LIBRTE if ((strcmp(available_encoders[encoder], "rte") == 0) && !dxr3_rte_init(this)) { - xprintf(this->class->xine, XINE_VERBOSITY_LOG, + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: Mpeg encoder rte failed to init.\n")); return 0; } #endif #ifdef HAVE_LIBFAME if ((strcmp(available_encoders[encoder], "fame") == 0) && !dxr3_fame_init(this)) { - xprintf(this->class->xine, XINE_VERBOSITY_LOG, + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: Mpeg encoder fame failed to init.\n")); return 0; } #endif if (strcmp(available_encoders[encoder], "none") == 0) - xprintf(this->class->xine, XINE_VERBOSITY_LOG, + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: Mpeg encoding disabled.\n" "video_out_dxr3: that's ok, you don't need it for mpeg video like DVDs, but\n" "video_out_dxr3: you will not be able to play non-mpeg content using this video out\n" "video_out_dxr3: driver. See the README.dxr3 for details on configuring an encoder.\n")); } else - xprintf(this->class->xine, XINE_VERBOSITY_LOG, + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: No mpeg encoder compiled in.\n" "video_out_dxr3: that's ok, you don't need it for mpeg video like DVDs, but\n" "video_out_dxr3: you will not be able to play non-mpeg content using this video out\n" "video_out_dxr3: driver. See the README.dxr3 for details on configuring an encoder.\n")); - + /* init aspect */ this->aspect = dxr3_set_property(&this->vo_driver, VO_PROP_ASPECT_RATIO, XINE_VO_ASPECT_4_3); - + /* init brightness/contrast/saturation */ dxr3_set_property(&this->vo_driver, VO_PROP_BRIGHTNESS, 500); dxr3_set_property(&this->vo_driver, VO_PROP_CONTRAST , 500); dxr3_set_property(&this->vo_driver, VO_PROP_SATURATION, 500); - + /* overlay or tvout? */ confnum = config->register_enum(config, "dxr3.output.mode", 0, videoout_modes, _("video output mode (TV or overlay)"), @@ -446,7 +446,7 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v _("Removes one pixel line from the top and bottom of the overlay. Enable this, if " "you see green lines at the top or bottom of the overlay."), 10, NULL, NULL); } else { - xprintf(this->class->xine, XINE_VERBOSITY_LOG, + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: please run autocal, overlay disabled\n")); this->overlay_enabled = 0; this->tv_switchable = 0; @@ -454,7 +454,7 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v } #endif } - + /* init tvmode */ confnum = config->register_enum(config, "dxr3.output.tvmode", 3, tv_modes, _("preferred tv mode"), _("Selects the TV mode to be used by the DXR3. The values mean:\n\n" @@ -478,50 +478,50 @@ static vo_driver_t *dxr3_vo_open_plugin(video_driver_class_t *class_gen, const v } if (this->tv_mode != EM8300_VIDEOMODE_DEFAULT) if (ioctl(this->fd_control, EM8300_IOCTL_SET_VIDEOMODE, &this->tv_mode)) - xprintf(this->class->xine, XINE_VERBOSITY_LOG, + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: setting video mode failed.\n")); - + #ifdef HAVE_X11 /* initialize overlay */ if (this->overlay_enabled) { em8300_overlay_screen_t scr; int value; XColor dummy; - + this->overlay.fd_control = this->fd_control; - + /* allocate keycolor */ this->key.red = ((this->overlay.colorkey >> 16) & 0xff) * 256; this->key.green = ((this->overlay.colorkey >> 8) & 0xff) * 256; this->key.blue = ((this->overlay.colorkey ) & 0xff) * 256; XAllocColor(this->display, DefaultColormap(this->display, 0), &this->key); - + /* allocate black for output area borders */ XAllocNamedColor(this->display, DefaultColormap(this->display, 0), "black", &this->black, &dummy); - + /* set the screen */ scr.xsize = this->overlay.screen_xres; scr.ysize = this->overlay.screen_yres; if (ioctl(this->fd_control, EM8300_IOCTL_OVERLAY_SETSCREEN, &scr)) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: setting the overlay screen failed.\n"); - + if (dxr3_overlay_set_keycolor(&this->overlay) != 0) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: setting the overlay key colour failed.\n"); if (dxr3_overlay_set_attributes(&this->overlay) != 0) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: setting an overlay attribute failed.\n"); - + /* finally switch to overlay mode */ value = EM8300_OVERLAY_MODE_OVERLAY; if (ioctl(this->fd_control, EM8300_IOCTL_OVERLAY_SETMODE, &value) != 0) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: switching to overlay mode failed.\n"); } #endif - + return &this->vo_driver; } @@ -535,9 +535,9 @@ static vo_frame_t *dxr3_alloc_frame(vo_driver_t *this_gen) { dxr3_frame_t *frame; dxr3_driver_t *this = (dxr3_driver_t *)this_gen; - + frame = calloc(1, sizeof(dxr3_frame_t)); - + pthread_mutex_init(&frame->vo_frame.mutex, NULL); if (this->enc && this->enc->on_frame_copy) { @@ -559,7 +559,7 @@ static void dxr3_frame_proc_frame(vo_frame_t *frame_gen) /* we reduce the vpts to give the card some extra decoding time */ if (frame_gen->format != XINE_IMGFMT_DXR3 && !frame_gen->proc_called) frame_gen->vpts -= DECODE_PIPE_PREBUFFER; - + frame_gen->proc_called = 1; } @@ -567,11 +567,11 @@ static void dxr3_frame_proc_slice(vo_frame_t *frame_gen, uint8_t **src) { dxr3_frame_t *frame = (dxr3_frame_t *)frame_gen; dxr3_driver_t *this = (dxr3_driver_t *)frame_gen->driver; - + /* we reduce the vpts to give the card some extra decoding time */ if (frame_gen->format != XINE_IMGFMT_DXR3 && !frame_gen->proc_called) frame_gen->vpts -= DECODE_PIPE_PREBUFFER; - + frame_gen->proc_called = 1; if (frame_gen->format != XINE_IMGFMT_DXR3 && this->enc && this->enc->on_frame_copy) @@ -586,7 +586,7 @@ static void dxr3_frame_field(vo_frame_t *vo_img, int which_field) static void dxr3_frame_dispose(vo_frame_t *frame_gen) { dxr3_frame_t *frame = (dxr3_frame_t *)frame_gen; - + if (frame->mem) free(frame->mem); pthread_mutex_destroy(&frame_gen->mutex); free(frame); @@ -595,8 +595,8 @@ static void dxr3_frame_dispose(vo_frame_t *frame_gen) static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_gen, uint32_t width, uint32_t height, double ratio, int format, int flags) { - dxr3_driver_t *this = (dxr3_driver_t *)this_gen; - dxr3_frame_t *frame = (dxr3_frame_t *)frame_gen; + dxr3_driver_t *this = (dxr3_driver_t *)this_gen; + dxr3_frame_t *frame = (dxr3_frame_t *)frame_gen; uint32_t oheight; if (format == XINE_IMGFMT_DXR3) { /* talking to dxr3 decoder */ @@ -605,7 +605,7 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge pthread_mutex_lock(&this->video_device_lock); if (this->fd_video >= 0) { metronom_clock_t *clock = this->class->xine->clock; - + clock->unregister_scr(clock, &this->class->scr->scr_plugin); close(this->fd_video); this->fd_video = -1; @@ -613,10 +613,10 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge this->need_update = 1; } pthread_mutex_unlock(&this->video_device_lock); - + /* for mpeg source, we don't have to do much. */ this->video_width = 0; - + frame->vo_frame.width = width; frame->vo_frame.height = height; frame->vo_frame.ratio = ratio; @@ -626,23 +626,23 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge else frame->aspect = XINE_VO_ASPECT_ANAMORPHIC; frame->pan_scan = flags & VO_PAN_SCAN_FLAG; - + if (frame->mem) { free(frame->mem); frame->mem = NULL; frame->real_base[0] = frame->real_base[1] = frame->real_base[2] = NULL; frame_gen->base[0] = frame_gen->base[1] = frame_gen->base[2] = NULL; } - + return; } /* the following is for the mpeg encoding part only */ - + if (!this->add_bars) /* don't add black bars; assume source is in 4:3 */ ratio = 4.0/3.0; - + frame->vo_frame.ratio = ratio; frame->pan_scan = 0; frame->aspect = this->video_aspect; @@ -653,18 +653,18 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge metronom_clock_t *clock = this->class->xine->clock; char tmpstr[128]; int64_t time; - + /* open the device for the encoder */ snprintf(tmpstr, sizeof(tmpstr), "/dev/em8300_mv-%d", this->class->devnum); if ((this->fd_video = open(tmpstr, O_WRONLY)) < 0) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: Failed to open video device %s (%s)\n", tmpstr, strerror(errno)); - + /* start the scr plugin */ time = clock->get_current_time(clock); this->class->scr->scr_plugin.start(&this->class->scr->scr_plugin, time); clock->register_scr(clock, &this->class->scr->scr_plugin); - + this->scale.force_redraw = 1; } pthread_mutex_unlock(&this->video_device_lock); @@ -684,20 +684,20 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge /* still too high, use full height */ oheight = height; } - + /* use next multiple of 16 */ oheight = ((oheight - 1) | 15) + 1; /* Tell the viewers about the aspect ratio stuff. */ if (oheight - height > 0) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: adding %d black lines to get %s aspect ratio.\n", oheight - height, frame->aspect == XINE_VO_ASPECT_4_3 ? "4:3" : "16:9"); - /* make top black bar multiple of 16, - * so old and new macroblocks overlap */ + /* make top black bar multiple of 16, + * so old and new macroblocks overlap */ this->top_bar = ((oheight - height) / 32) * 16; - + this->video_width = width; this->video_iheight = height; this->video_oheight = oheight; @@ -708,27 +708,27 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge if (!this->enc) { /* no encoder plugin! Let's bug the user! */ - xprintf(this->class->xine, XINE_VERBOSITY_LOG, + xprintf(this->class->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: Need an mpeg encoder to play non-mpeg videos on dxr3\n" "video_out_dxr3: Read the README.dxr3 for details.\n")); } } /* if dimensions changed, we need to re-allocate frame memory */ - if ((frame->vo_frame.width != width) || (frame->vo_frame.height != height) || + if ((frame->vo_frame.width != width) || (frame->vo_frame.height != height) || (frame->oheight != oheight) || (frame->vo_frame.format != format)) { if (frame->mem) { free (frame->mem); frame->mem = NULL; } - + if (format == XINE_IMGFMT_YUY2) { int i, image_size; - + /* calculate pitch and size including black bars */ frame->vo_frame.pitches[0] = 32 * ((width + 15) / 16); image_size = frame->vo_frame.pitches[0] * oheight; - + /* planar format, only base[0] */ /* add one extra line for field swap stuff */ frame->real_base[0] = xine_xmalloc_aligned(16, image_size + frame->vo_frame.pitches[0], @@ -749,7 +749,7 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge } else { /* XINE_IMGFMT_YV12 */ int image_size_y, image_size_u, image_size_v; - + /* calculate pitches and sizes including black bars */ frame->vo_frame.pitches[0] = 16*((width + 15) / 16); frame->vo_frame.pitches[1] = 8*((width + 15) / 16); @@ -771,7 +771,7 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge frame->vo_frame.base[0] = frame->real_base[0] + frame->vo_frame.pitches[0] * this->top_bar; frame->vo_frame.base[1] = frame->real_base[1] + frame->vo_frame.pitches[1] * this->top_bar / 2; frame->vo_frame.base[2] = frame->real_base[2] + frame->vo_frame.pitches[2] * this->top_bar / 2; - + /* fill with black (yuv 16,128,128) */ memset(frame->real_base[0], 16, image_size_y); memset(frame->real_base[1], 128, image_size_u); @@ -780,12 +780,12 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge } if (this->swap_fields != frame->swap_fields) { - if (this->swap_fields) + if (this->swap_fields) frame->vo_frame.base[0] -= frame->vo_frame.pitches[0]; - else + else frame->vo_frame.base[0] += frame->vo_frame.pitches[0]; } - + frame->vo_frame.width = width; frame->vo_frame.height = height; frame->oheight = oheight; @@ -795,20 +795,20 @@ static void dxr3_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_ge static void dxr3_overlay_begin(vo_driver_t *this_gen, vo_frame_t *frame_gen, int changed) { dxr3_driver_t *this = (dxr3_driver_t *)this_gen; - + /* special treatment is only necessary for mpeg frames */ if (frame_gen->format != XINE_IMGFMT_DXR3) return; - + if (!this->spu_enc) this->spu_enc = dxr3_spu_encoder_init(); - + if (!changed) { this->spu_enc->need_reencode = 0; return; } - + this->spu_enc->need_reencode = 1; this->spu_enc->overlay = NULL; - + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; } @@ -817,10 +817,10 @@ static void dxr3_overlay_blend(vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { dxr3_driver_t *this = (dxr3_driver_t *)this_gen; - + if (frame_gen->format != XINE_IMGFMT_DXR3) { dxr3_frame_t *frame = (dxr3_frame_t *)frame_gen; - + if (overlay->rle) { if (frame_gen->format == XINE_IMGFMT_YV12) _x_blend_yuv(frame->vo_frame.base, overlay, @@ -844,26 +844,26 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) em8300_button_t btn; char tmpstr[128]; ssize_t written; - + if (frame_gen->format != XINE_IMGFMT_DXR3) return; if (!this->spu_enc->need_reencode) return; - + dxr3_spu_encode(this->spu_enc); pthread_mutex_lock(&this->spu_device_lock); - + /* try to open the dxr3 spu device */ if (!this->fd_spu) { snprintf (tmpstr, sizeof(tmpstr), "/dev/em8300_sp-%d", this->class->devnum); if ((this->fd_spu = open (tmpstr, O_WRONLY)) < 0) { - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: Failed to open spu device %s (%s)\n" "video_out_dxr3: Overlays are not available\n", tmpstr, strerror(errno)); pthread_mutex_unlock(&this->spu_device_lock); return; } } - + if (!this->spu_enc->overlay) { uint8_t empty_spu[] = { 0x00, 0x26, 0x00, 0x08, 0x80, 0x00, 0x00, 0x80, @@ -877,7 +877,7 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) pthread_mutex_unlock(&this->spu_device_lock); return; } - + /* copy clip palette */ this->spu_enc->color[4] = this->spu_enc->hili_color[0]; this->spu_enc->color[5] = this->spu_enc->hili_color[1]; @@ -885,16 +885,16 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) this->spu_enc->color[7] = this->spu_enc->hili_color[3]; /* set palette */ if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_SETPALETTE, this->spu_enc->color)) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: failed to set CLUT (%s)\n", strerror(errno)); this->clut_cluttered = 1; /* write spu */ written = write(this->fd_spu, this->spu_enc->target, this->spu_enc->size); if (written < 0) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: spu device write failed (%s)\n", strerror(errno)); else if (written != this->spu_enc->size) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: Could only write %zd of %d spu bytes.\n", written, this->spu_enc->size); /* set clipping */ btn.color = 0x7654; @@ -908,9 +908,9 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) btn.top = this->spu_enc->overlay->y + this->spu_enc->overlay->hili_top; btn.bottom = this->spu_enc->overlay->y + this->spu_enc->overlay->hili_bottom - 2; if (ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, &btn)) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno)); - + pthread_mutex_unlock(&this->spu_device_lock); } @@ -968,22 +968,22 @@ static void dxr3_display_frame(vo_driver_t *this_gen, vo_frame_t *frame_gen) } } #endif - + if (frame_gen->format != XINE_IMGFMT_DXR3 && this->enc && this->enc->on_display_frame) { - + pthread_mutex_lock(&this->video_device_lock); if (this->fd_video < 0) { /* no need to encode, when the device is already reserved for the decoder */ frame_gen->free(frame_gen); } else { uint32_t vpts32 = (uint32_t)(frame_gen->vpts + DECODE_PIPE_PREBUFFER); - + if (this->need_update) { /* we cannot do this earlier, because vo_frame.duration is only valid here */ if (this->enc && this->enc->on_update_format) { /* set the dxr3 playmode */ if (this->enc->on_update_format(this, frame) && this->enhanced_mode) { - em8300_register_t reg; + em8300_register_t reg; reg.microcode_register = 1; reg.reg = 0; reg.val = MVCOMMAND_SYNC; @@ -995,19 +995,19 @@ static void dxr3_display_frame(vo_driver_t *this_gen, vo_frame_t *frame_gen) } this->need_update = 0; } - + /* inform the card on the timing */ if (ioctl(this->fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vpts32)) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: set video pts failed (%s)\n", strerror(errno)); - /* for non-mpeg, the encoder plugin is responsible for calling + /* for non-mpeg, the encoder plugin is responsible for calling * frame_gen->free(frame_gen) ! */ this->enc->on_display_frame(this, frame); } pthread_mutex_unlock(&this->video_device_lock); - + } else { - + if (this->need_update) { /* we do not need the mpeg encoders any more */ if (this->enc && this->enc->on_unneeded) @@ -1015,7 +1015,7 @@ static void dxr3_display_frame(vo_driver_t *this_gen, vo_frame_t *frame_gen) this->need_update = 0; } frame_gen->free(frame_gen); - + } } @@ -1023,11 +1023,11 @@ static int dxr3_redraw_needed(vo_driver_t *this_gen) { dxr3_driver_t *this = (dxr3_driver_t *)this_gen; -#ifdef HAVE_X11 +#ifdef HAVE_X11 if (this->overlay_enabled) dxr3_overlay_update(this); #endif - + return 0; } @@ -1055,7 +1055,7 @@ static int dxr3_get_property(vo_driver_t *this_gen, int property) case VO_PROP_WINDOW_HEIGHT: return this->scale.gui_height; } - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: property %d not implemented.\n", property); return 0; } @@ -1086,7 +1086,7 @@ static int dxr3_set_property(vo_driver_t *this_gen, int property, int value) /* We should send an anamorphic hint to widescreen tvs, so they * can switch to 16:9 mode. But the dxr3 cannot do this. */ break; - + switch(value) { case XINE_VO_ASPECT_SQUARE: case XINE_VO_ASPECT_4_3: @@ -1102,13 +1102,13 @@ static int dxr3_set_property(vo_driver_t *this_gen, int property, int value) } if (ioctl(this->fd_control, EM8300_IOCTL_SET_ASPECTRATIO, &val)) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: failed to set aspect ratio (%s)\n", strerror(errno)); - + this->scale.force_redraw = 1; break; case VO_PROP_COLORKEY: - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: VO_PROP_COLORKEY not implemented!"); this->overlay.colorkey = value; break; @@ -1143,16 +1143,16 @@ static int dxr3_set_property(vo_driver_t *this_gen, int property, int value) } #endif if (ioctl(this->fd_control, EM8300_IOCTL_SET_VIDEOMODE, &this->tv_mode)) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: setting video mode failed (%s)\n", strerror(errno)); break; } if (bcs_changed) if (ioctl(this->fd_control, EM8300_IOCTL_SETBCS, &this->bcs)) - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: bcs set failed (%s)\n", strerror(errno)); - + return value; } @@ -1261,7 +1261,7 @@ static void dxr3_dispose(vo_driver_t *this_gen) pthread_mutex_destroy(&this->spu_device_lock); _x_alphablend_free(&this->alphablend_extra_data); - + free(this); } @@ -1297,7 +1297,7 @@ static void gather_screen_vars(dxr3_driver_t *this, const x11_visual_t *vis) this->overlay.screen_depth = DisplayPlanes(this->display, scrn); this->scale.frame_output_cb = (void *)vis->frame_output_cb; - + llprintf(LOG_OVR, "xres: %d, yres: %d, depth: %d\n", this->overlay.screen_xres, this->overlay.screen_yres, this->overlay.screen_depth); } @@ -1309,9 +1309,9 @@ static void gather_screen_vars(dxr3_driver_t *this, const x11_visual_t *vis) #define TYPE_FLOAT 4 struct lut_entry { - char *name; - int type; - void *ptr; + char *name; + int type; + void *ptr; }; /* dxr3_overlay_read_state helper function */ @@ -1319,7 +1319,7 @@ static int lookup_parameter(struct lut_entry *lut, char *name, void **ptr, int *type) { int i; - + for (i = 0; lut[i].name; i++) if (strcmp(name, lut[i].name) == 0) { *ptr = lut[i].ptr; @@ -1359,11 +1359,11 @@ static int dxr3_overlay_read_state(dxr3_overlay_t *this) * (used by .overlay/res file) */ setlocale(LC_NUMERIC, "C"); - asprintf(&fname, "%s/.overlay/res_%dx%dx%d", getenv("HOME"), + asprintf(&fname, "%s/.overlay/res_%dx%dx%d", getenv("HOME"), this->screen_xres, this->screen_yres, this->screen_depth); llprintf(LOG_OVR, "attempting to open %s\n", fname); if (!(fp = fopen(fname, "r"))) { - xprintf(this->xine, XINE_VERBOSITY_LOG, + xprintf(this->xine, XINE_VERBOSITY_LOG, _("video_out_dxr3: ERROR Reading overlay init file. Run autocal!\n")); free(fname); return -1; @@ -1402,11 +1402,11 @@ static int dxr3_overlay_read_state(dxr3_overlay_t *this) } } } - + fclose(fp); /* restore original locale */ setlocale(LC_NUMERIC, loc); - + return 0; } @@ -1441,7 +1441,7 @@ static int dxr3_overlay_set_keycolor(dxr3_overlay_t *this) attr.attribute = EM9010_ATTRIBUTE_KEYCOLOR_LOWER; attr.value = overlay_limit; if ((ret = ioctl(this->fd_control, EM8300_IOCTL_OVERLAY_SET_ATTRIBUTE, &attr)) < 0) { - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: WARNING: error setting overlay lower limit attribute\n"); return ret; } @@ -1454,7 +1454,7 @@ static int dxr3_overlay_set_keycolor(dxr3_overlay_t *this) attr.attribute = EM9010_ATTRIBUTE_KEYCOLOR_UPPER; attr.value = overlay_limit; if ((ret = ioctl(this->fd_control, EM8300_IOCTL_OVERLAY_SET_ATTRIBUTE, &attr)) < 0) - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: WARNING: error setting overlay upper limit attribute\n"); return ret; } @@ -1462,7 +1462,7 @@ static int dxr3_overlay_set_keycolor(dxr3_overlay_t *this) static int dxr3_overlay_set_attributes(dxr3_overlay_t *this) { em8300_attribute_t attr; - + attr.attribute = EM9010_ATTRIBUTE_XOFFSET; attr.value = this->xoffset; if(ioctl(this->fd_control, EM8300_IOCTL_OVERLAY_SET_ATTRIBUTE, &attr) == -1) @@ -1489,9 +1489,9 @@ static void dxr3_overlay_update(dxr3_driver_t *this) { if (_x_vo_scale_redraw_needed(&this->scale)) { em8300_overlay_window_t win; - + _x_vo_scale_compute_output_size(&this->scale); - + /* fill video window with keycolor */ XLockDisplay(this->display); XSetForeground(this->display, this->gc, this->black.pixel); @@ -1504,24 +1504,24 @@ static void dxr3_overlay_update(dxr3_driver_t *this) this->scale.output_width, this->scale.output_height - 2 * this->overlay.shrink); XFlush(this->display); XUnlockDisplay(this->display); - + win.xpos = this->scale.output_xoffset + this->scale.gui_win_x; win.ypos = this->scale.output_yoffset + this->scale.gui_win_y; win.width = this->scale.output_width; win.height = this->scale.output_height; - + if (this->pan_scan) { win.xpos -= win.width / 6; win.width *= 4; win.width /= 3; } - + /* is some part of the picture visible? */ if (win.xpos + win.width < 0) return; if (win.ypos + win.height < 0) return; if (win.xpos > this->overlay.screen_xres) return; if (win.ypos > this->overlay.screen_yres) return; - + ioctl(this->fd_control, EM8300_IOCTL_OVERLAY_SETWINDOW, &win); } } @@ -1530,20 +1530,20 @@ static void dxr3_overlay_update(dxr3_driver_t *this) static void dxr3_zoomTV(dxr3_driver_t *this) { em8300_register_t frame, visible, update; - + /* change left bound */ frame.microcode_register = 1; frame.reg = 93; // dicom frame left frame.val = 0x10; - + visible.microcode_register = 1; visible.reg = 97; // dicom visible left visible.val = 0x10; - + update.microcode_register = 1; update.reg = 65; // dicom_update update.val = 1; - + ioctl(this->fd_control, EM8300_IOCTL_WRITEREG, &frame); ioctl(this->fd_control, EM8300_IOCTL_WRITEREG, &visible); ioctl(this->fd_control, EM8300_IOCTL_WRITEREG, &update); @@ -1552,15 +1552,15 @@ static void dxr3_zoomTV(dxr3_driver_t *this) frame.microcode_register = 1; frame.reg = 94; // dicom frame right frame.val = 0x10; - + visible.microcode_register = 1; visible.reg = 98; // dicom visible right visible.val = 968; - + update.microcode_register = 1; update.reg = 65; // dicom_update update.val = 1; - + ioctl(this->fd_control, EM8300_IOCTL_WRITEREG, &frame); ioctl(this->fd_control, EM8300_IOCTL_WRITEREG, &visible); ioctl(this->fd_control, EM8300_IOCTL_WRITEREG, &update); @@ -1571,7 +1571,7 @@ static void dxr3_update_add_bars(void *data, xine_cfg_entry_t *entry) { dxr3_driver_t *this = (dxr3_driver_t *)data; this->add_bars = entry->num_value; - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: setting add_bars to correct aspect ratio to %s\n", (this->add_bars ? "on" : "off")); } @@ -1579,7 +1579,7 @@ static void dxr3_update_swap_fields(void *data, xine_cfg_entry_t *entry) { dxr3_driver_t *this = (dxr3_driver_t *)data; this->swap_fields = entry->num_value; - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: setting swap fields to %s\n", (this->swap_fields ? "on" : "off")); } @@ -1587,6 +1587,6 @@ static void dxr3_update_enhanced_mode(void *data, xine_cfg_entry_t *entry) { dxr3_driver_t *this = (dxr3_driver_t *)data; this->enhanced_mode = entry->num_value; - xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: setting enhanced encoding playback to %s\n", (this->enhanced_mode ? "on" : "off")); } diff --git a/src/dxr3/video_out_dxr3.h b/src/dxr3/video_out_dxr3.h index 0297204dd..4dce49f4d 100644 --- a/src/dxr3/video_out_dxr3.h +++ b/src/dxr3/video_out_dxr3.h @@ -1,18 +1,18 @@ -/* +/* * Copyright (C) 2000-2001 the xine project - * + * * This file is part of xine, a unix 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 @@ -48,7 +48,7 @@ struct coeff { typedef struct dxr3_overlay_s { xine_t *xine; - + int fd_control; int xoffset; @@ -70,12 +70,12 @@ typedef struct dxr3_overlay_s { typedef struct dxr3_driver_class_s { video_driver_class_t video_driver_class; xine_t *xine; - + int visual_type; int instance; /* we allow only one instance of this plugin */ - + int devnum; - + dxr3_scr_t *scr; /* to provide dxr3 clocking */ } dxr3_driver_class_t; @@ -89,11 +89,11 @@ typedef struct dxr3_driver_s { pthread_mutex_t spu_device_lock; int fd_spu; /* to access the relevant dxr3 devices */ int clut_cluttered; /* to tell spu decoder that it has to restore the palette */ - + int enhanced_mode; int swap_fields; /* swap fields */ int add_bars; /* add black bars to correct a.r. */ - + int aspect; int tv_mode; int pan_scan; @@ -105,14 +105,14 @@ typedef struct dxr3_driver_s { encoder_data_t *enc; /* mpeg encoder data */ spu_encoder_t *spu_enc; /* spu encoder */ int need_update; /* the mpeg encoder needs to be updated */ - + uint32_t video_iheight; /* input height (before adding black bars) */ uint32_t video_oheight; /* output height (after adding black bars) */ uint32_t video_width; double video_ratio; int video_aspect; int top_bar; /* the height of the upper black bar */ - + vo_scale_t scale; alphablend_t alphablend_extra_data; @@ -143,10 +143,10 @@ struct encoder_data_s { int (*on_display_frame)(dxr3_driver_t *, dxr3_frame_t *); int (*on_unneeded)(dxr3_driver_t *); int (*on_close)(dxr3_driver_t *); - + /* this is only used by the libavcodec encoder */ void *handle; -}; +}; struct spu_encoder_s { vo_overlay_t *overlay; |