diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dxr3/dxr3_decode_spu.c | 139 | ||||
-rw-r--r-- | src/dxr3/dxr3_decode_video.c | 290 | ||||
-rw-r--r-- | src/dxr3/dxr3_scr.c | 26 |
3 files changed, 223 insertions, 232 deletions
diff --git a/src/dxr3/dxr3_decode_spu.c b/src/dxr3/dxr3_decode_spu.c index a6acc9a93..d8de66ee9 100644 --- a/src/dxr3/dxr3_decode_spu.c +++ b/src/dxr3/dxr3_decode_spu.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: dxr3_decode_spu.c,v 1.47 2004/06/21 16:19:40 mroi Exp $ + * $Id: dxr3_decode_spu.c,v 1.48 2004/07/11 11:47:10 hadess Exp $ */ /* dxr3 spu decoder plugin. @@ -140,15 +140,80 @@ typedef struct dxr3_spudec_s { } dxr3_spudec_t; /* helper functions */ -static inline int dxr3_present(xine_stream_t *stream); -static inline void dxr3_spudec_handle_event(dxr3_spudec_t *this); /* the NAV functions must be called with the pci_lock held */ static inline void dxr3_spudec_clear_nav_list(dxr3_spudec_t *this); static inline void dxr3_spudec_update_nav(dxr3_spudec_t *this); 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); -static inline void dxr3_swab_clut(int* clut); +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) { + vo_class = (video_driver_class_t *)node->plugin_class; + if (vo_class->get_identifier) + present = (strcmp(vo_class->get_identifier(vo_class), DXR3_VO_ID) == 0); + } + } + llprintf(LOG_SPU, "dxr3 %s\n", present ? "present" : "not present"); + return present; +} + +static inline void dxr3_spudec_handle_event(dxr3_spudec_t *this) +{ + xine_event_t *event; + + 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 */ + this->anamorphic = + (((xine_format_change_data_t *)event->data)->aspect == 3) && + (((xine_format_change_data_t *)event->data)->pan_scan == 0); + llprintf(LOG_BTN, "anamorphic mode %s\n", this->anamorphic ? "on" : "off"); + break; + } + + xine_event_free(event); + } +} + +static inline void dxr3_spudec_clear_nav_list(dxr3_spudec_t *this) +{ + while (this->pci_cur.next) { + pci_node_t *node = this->pci_cur.next->next; + free(this->pci_cur.next); + this->pci_cur.next = node; + } + /* invalidate current timestamp */ + this->pci_cur.pci.hli.hl_gi.hli_s_ptm = (uint32_t)-1; +} + +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)); + dxr3_spudec_process_nav(this); + free(node); + } +} + +static inline void dxr3_swab_clut(int *clut) +{ + int i; + for (i=0; i<16; i++) + clut[i] = bswap_32(clut[i]); +} static void *dxr3_spudec_init_plugin(xine_t *xine, void* data) { @@ -533,67 +598,7 @@ static void dxr3_spudec_set_button(spu_decoder_t *this_gen, int32_t button, int3 } -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) { - vo_class = (video_driver_class_t *)node->plugin_class; - if (vo_class->get_identifier) - present = (strcmp(vo_class->get_identifier(vo_class), DXR3_VO_ID) == 0); - } - } - llprintf(LOG_SPU, "dxr3 %s\n", present ? "present" : "not present"); - return present; -} -static inline void dxr3_spudec_handle_event(dxr3_spudec_t *this) -{ - xine_event_t *event; - - 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 */ - this->anamorphic = - (((xine_format_change_data_t *)event->data)->aspect == 3) && - (((xine_format_change_data_t *)event->data)->pan_scan == 0); - llprintf(LOG_BTN, "anamorphic mode %s\n", this->anamorphic ? "on" : "off"); - break; - } - - xine_event_free(event); - } -} - -static inline void dxr3_spudec_clear_nav_list(dxr3_spudec_t *this) -{ - while (this->pci_cur.next) { - pci_node_t *node = this->pci_cur.next->next; - free(this->pci_cur.next); - this->pci_cur.next = node; - } - /* invalidate current timestamp */ - this->pci_cur.pci.hli.hl_gi.hli_s_ptm = (uint32_t)-1; -} - -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)); - dxr3_spudec_process_nav(this); - free(node); - } -} static void dxr3_spudec_process_nav(dxr3_spudec_t *this) { @@ -702,9 +707,3 @@ static int dxr3_spudec_copy_nav_to_btn(dxr3_spudec_t *this, int32_t mode, em8300 return -1; } -static inline void dxr3_swab_clut(int *clut) -{ - int i; - for (i=0; i<16; i++) - clut[i] = bswap_32(clut[i]); -} diff --git a/src/dxr3/dxr3_decode_video.c b/src/dxr3/dxr3_decode_video.c index d747ec377..9364499dc 100644 --- a/src/dxr3/dxr3_decode_video.c +++ b/src/dxr3/dxr3_decode_video.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: dxr3_decode_video.c,v 1.55 2004/06/13 16:00:17 mroi Exp $ + * $Id: dxr3_decode_video.c,v 1.56 2004/07/11 11:47:10 hadess Exp $ */ /* dxr3 video decoder plugin. @@ -144,10 +144,6 @@ typedef struct dxr3_decoder_s { } dxr3_decoder_t; /* helper functions */ -static inline int dxr3_present(xine_stream_t *stream); -static inline int dxr3_mvcommand(int fd_control, int command); -static inline void parse_mpeg_header(dxr3_decoder_t *this, uint8_t *buffer); -static inline int get_duration(dxr3_decoder_t *this); static void frame_format_change(dxr3_decoder_t *this); /* config callbacks */ @@ -156,6 +152,147 @@ static void dxr3_update_sync_mode(void *this_gen, xine_cfg_entry_t *entry); static void dxr3_update_enhanced_mode(void *this_gen, xine_cfg_entry_t *entry); static void dxr3_update_correct_durations(void *this_gen, xine_cfg_entry_t *entry); +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) { + vo_class = (video_driver_class_t *)node->plugin_class; + if (vo_class->get_identifier) + present = (strcmp(vo_class->get_identifier(vo_class), DXR3_VO_ID) == 0); + } + } +#if LOG_VID + printf("dxr3_decode_video: dxr3 %s\n", present ? "present" : "not present"); +#endif + return present; +} + +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, ®); +} + +static inline void parse_mpeg_header(dxr3_decoder_t *this, uint8_t * buffer) +{ + this->frame_rate_code = buffer[3] & 15; + this->height = (buffer[0] << 16) | + (buffer[1] << 8) | + (buffer[2] << 0); + 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 || + (this->last_width != this->width) || + (this->last_height != this->height) || + (this->last_aspect_code != this->aspect_code)) { + frame_format_change(this); + this->last_width = this->width; + this->last_height = this->height; + this->last_aspect_code = this->aspect_code; + } +} + +static inline 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 */ + break; + case 2: /* 24.000 */ + duration = 3750; + break; + case 3: /* 25.000 */ + duration = this->repeat_first_field ? 5400 : 3600; + break; + case 4: /* 29.970 */ + duration = this->repeat_first_field ? 4505 : 3003; + break; + case 5: /* 30.000 */ + duration = 3000; + break; + case 6: /* 50.000 */ + duration = 1800; + break; + case 7: /* 59.940 */ + duration = 1502; /* actually it's 1501.5 */ + break; + case 8: /* 60.000 */ + duration = 1500; + break; + default: + 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. + * (I have seen such things even on dvds!) + */ + if (this->avg_duration && this->avg_duration < 3300 && duration == 3600) { + if (this->force_duration_window > 0) { + /* we are already in a force_duration window, so we force duration */ + this->force_duration_window = FORCE_DURATION_WINDOW_SIZE; + return 3000; + } + if (this->force_duration_window <= 0 && (this->force_duration_window += 10) > 0) { + /* we just entered a force_duration window, so we start the correction */ + metronom_t *metronom = this->stream->metronom; + int64_t cur_offset; + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + _("dxr3_decode_video: WARNING: correcting frame rate code from PAL to NTSC\n")); + /* those weird streams need an offset, too */ + cur_offset = metronom->get_option(metronom, METRONOM_AV_OFFSET); + metronom->set_option(metronom, METRONOM_AV_OFFSET, cur_offset - 28800); + this->force_duration_window = FORCE_DURATION_WINDOW_SIZE; + return 3000; + } + } + + if (this->force_duration_window == -FORCE_DURATION_WINDOW_SIZE) + /* we are far from a force_duration window */ + return duration; + if (--this->force_duration_window == 0) { + /* we have just left a force_duration window */ + metronom_t *metronom = this->stream->metronom; + int64_t cur_offset; + cur_offset = metronom->get_option(metronom, METRONOM_AV_OFFSET); + metronom->set_option(metronom, METRONOM_AV_OFFSET, cur_offset + 28800); + this->force_duration_window = -FORCE_DURATION_WINDOW_SIZE; + } + } + + return duration; +} static void *dxr3_init_plugin(xine_t *xine, void *data) { @@ -660,149 +797,6 @@ static void dxr3_dispose(video_decoder_t *this_gen) free(this); } - -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) { - vo_class = (video_driver_class_t *)node->plugin_class; - if (vo_class->get_identifier) - present = (strcmp(vo_class->get_identifier(vo_class), DXR3_VO_ID) == 0); - } - } -#if LOG_VID - printf("dxr3_decode_video: dxr3 %s\n", present ? "present" : "not present"); -#endif - return present; -} - -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, ®); -} - -static inline void parse_mpeg_header(dxr3_decoder_t *this, uint8_t * buffer) -{ - this->frame_rate_code = buffer[3] & 15; - this->height = (buffer[0] << 16) | - (buffer[1] << 8) | - (buffer[2] << 0); - 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 || - (this->last_width != this->width) || - (this->last_height != this->height) || - (this->last_aspect_code != this->aspect_code)) { - frame_format_change(this); - this->last_width = this->width; - this->last_height = this->height; - this->last_aspect_code = this->aspect_code; - } -} - -static inline 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 */ - break; - case 2: /* 24.000 */ - duration = 3750; - break; - case 3: /* 25.000 */ - duration = this->repeat_first_field ? 5400 : 3600; - break; - case 4: /* 29.970 */ - duration = this->repeat_first_field ? 4505 : 3003; - break; - case 5: /* 30.000 */ - duration = 3000; - break; - case 6: /* 50.000 */ - duration = 1800; - break; - case 7: /* 59.940 */ - duration = 1502; /* actually it's 1501.5 */ - break; - case 8: /* 60.000 */ - duration = 1500; - break; - default: - 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. - * (I have seen such things even on dvds!) - */ - if (this->avg_duration && this->avg_duration < 3300 && duration == 3600) { - if (this->force_duration_window > 0) { - /* we are already in a force_duration window, so we force duration */ - this->force_duration_window = FORCE_DURATION_WINDOW_SIZE; - return 3000; - } - if (this->force_duration_window <= 0 && (this->force_duration_window += 10) > 0) { - /* we just entered a force_duration window, so we start the correction */ - metronom_t *metronom = this->stream->metronom; - int64_t cur_offset; - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - _("dxr3_decode_video: WARNING: correcting frame rate code from PAL to NTSC\n")); - /* those weird streams need an offset, too */ - cur_offset = metronom->get_option(metronom, METRONOM_AV_OFFSET); - metronom->set_option(metronom, METRONOM_AV_OFFSET, cur_offset - 28800); - this->force_duration_window = FORCE_DURATION_WINDOW_SIZE; - return 3000; - } - } - - if (this->force_duration_window == -FORCE_DURATION_WINDOW_SIZE) - /* we are far from a force_duration window */ - return duration; - if (--this->force_duration_window == 0) { - /* we have just left a force_duration window */ - metronom_t *metronom = this->stream->metronom; - int64_t cur_offset; - cur_offset = metronom->get_option(metronom, METRONOM_AV_OFFSET); - metronom->set_option(metronom, METRONOM_AV_OFFSET, cur_offset + 28800); - this->force_duration_window = -FORCE_DURATION_WINDOW_SIZE; - } - } - - return duration; -} - static void frame_format_change(dxr3_decoder_t *this) { /* inform the dxr3 SPU decoder about the current format, diff --git a/src/dxr3/dxr3_scr.c b/src/dxr3/dxr3_scr.c index 5c9ca39cc..8a9cf1613 100644 --- a/src/dxr3/dxr3_scr.c +++ b/src/dxr3/dxr3_scr.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: dxr3_scr.c,v 1.14 2004/04/10 15:29:57 mroi Exp $ + * $Id: dxr3_scr.c,v 1.15 2004/07/11 11:47:10 hadess Exp $ */ /* dxr3 scr plugin. @@ -48,12 +48,19 @@ static void dxr3_scr_adjust(scr_plugin_t *scr, int64_t vpts); static int dxr3_scr_set_speed(scr_plugin_t *scr, int speed); static void dxr3_scr_exit(scr_plugin_t *scr); -/* helper function */ -static inline int dxr3_mvcommand(int fd_control, int command); - /* config callback */ 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, ®); +} dxr3_scr_t *dxr3_scr_init(xine_t *xine) { @@ -246,16 +253,7 @@ static void dxr3_scr_exit(scr_plugin_t *scr) } -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, ®); -} + static void dxr3_scr_update_priority(void *this_gen, xine_cfg_entry_t *entry) { |