From ef87deba4368a837c5c6316b1b9df9b3d3518929 Mon Sep 17 00:00:00 2001 From: Martin Jacobs Date: Sun, 7 Feb 2010 13:46:15 +0100 Subject: Fix Flash video with aac not playing audio (HTTP etc.) --- src/demuxers/demux_flv.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/demuxers/demux_flv.c b/src/demuxers/demux_flv.c index 6b5a72a1b..c421e6053 100644 --- a/src/demuxers/demux_flv.c +++ b/src/demuxers/demux_flv.c @@ -473,6 +473,12 @@ static int read_flv_packet(demux_flv_t *this, int preview) { buf->type = buf_type; fifo->put(fifo, buf); this->got_audio_header = 1; + if (!INPUT_IS_SEEKABLE(this->input)) { + /* stop preview processing immediately, this enables libfaad to + * initialize even without INPUT_CAP_SEEKABLE of input stream. + */ + preview = 0; + } } break; -- cgit v1.2.3 From f4dbf0e8545c541966feabc366d231e985a9e59a Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Fri, 12 Feb 2010 20:37:55 +0000 Subject: DXR3 compatibility fix for newer versions of the em8300 driver. --- src/dxr3/compat.c | 28 ++++++++++ src/dxr3/dxr3_decode_spu.c | 18 ++++--- src/dxr3/dxr3_decode_video.c | 4 +- src/dxr3/em8300.h | 120 +++++++++++++++++++++++++++++++++++++------ src/dxr3/video_out_dxr3.c | 12 +++-- src/dxr3/video_out_dxr3.h | 6 +++ 6 files changed, 158 insertions(+), 30 deletions(-) create mode 100644 src/dxr3/compat.c (limited to 'src') diff --git a/src/dxr3/compat.c b/src/dxr3/compat.c new file mode 100644 index 000000000..a4722f923 --- /dev/null +++ b/src/dxr3/compat.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2010 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 + */ + +/* For compatibility with em8300 < 0.18.0 */ +int dxr3_compat_ioctl (int fd, int rq, void *arg) +{ + int ret = ioctl (fd, rq, arg); + if (ret < 0 && errno == EINVAL || errno == ENOTTY) + ret = ioctl (fd, rq & 0xFF, arg); + return ret; +} diff --git a/src/dxr3/dxr3_decode_spu.c b/src/dxr3/dxr3_decode_spu.c index 7682455eb..e3d4f969b 100644 --- a/src/dxr3/dxr3_decode_spu.c +++ b/src/dxr3/dxr3_decode_spu.c @@ -60,6 +60,8 @@ #include "video_out_dxr3.h" #include "dxr3.h" +#include "compat.c" + #define MAX_SPU_STREAMS 32 @@ -336,7 +338,7 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) if (buf->content[0] == 0) /* cheap endianess detection */ 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)) + if (dxr3_spu_setpalette(this->fd_spu, buf->content)) 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 */ @@ -405,7 +407,7 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) this->menu = 0; this->button_filter = 1; pthread_mutex_lock(&this->dxr3_vo->spu_device_lock); - ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, NULL); + dxr3_spu_button(this->fd_spu, NULL); write(this->fd_spu, empty_spu, sizeof(empty_spu)); pthread_mutex_unlock(&this->dxr3_vo->spu_device_lock); } @@ -523,14 +525,14 @@ static void dxr3_spudec_decode_data(spu_decoder_t *this_gen, buf_element_t *buf) 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)) + if (dxr3_spu_setpts(this->fd_spu, &vpts32)) 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)) + if (dxr3_spu_setpalette(this->fd_spu, this->clut)) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set CLUT (%s)\n", strerror(errno)); this->dxr3_vo->clut_cluttered = 0; @@ -586,7 +588,7 @@ static void dxr3_spudec_dispose(spu_decoder_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 */ - ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, NULL); + dxr3_spu_button(this->fd_spu, NULL); write(this->fd_spu, empty_spu, sizeof(empty_spu)); close(this->fd_spu); this->fd_spu = 0; @@ -623,7 +625,7 @@ static void dxr3_spudec_set_button(spu_decoder_t *this_gen, int32_t button, int3 if (mode > 0 && !this->button_filter && (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)) + if (dxr3_spu_button(this->fd_spu, &btn)) 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); @@ -654,7 +656,7 @@ 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)) + if (dxr3_spu_button(this->fd_spu, &btn)) 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); @@ -676,7 +678,7 @@ 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)) + if (dxr3_spu_button(this->fd_spu, &btn)) 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); diff --git a/src/dxr3/dxr3_decode_video.c b/src/dxr3/dxr3_decode_video.c index 75a371566..132998a72 100644 --- a/src/dxr3/dxr3_decode_video.c +++ b/src/dxr3/dxr3_decode_video.c @@ -49,6 +49,8 @@ #include "video_out_dxr3.h" #include "dxr3.h" +#include "compat.c" + /* once activated, we wait for this amount of missing pan&scan info * before disabling it again */ #define PAN_SCAN_WINDOW_SIZE 50 @@ -592,7 +594,7 @@ static void dxr3_decode_data(video_decoder_t *this_gen, buf_element_t *buf) (this->sync_every_frame || buf->pts)) { uint32_t vpts32 = vpts; /* update the dxr3's current pts value */ - if (ioctl(this->fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vpts32)) + if (dxr3_video_setpts(this->fd_video, &vpts32)) xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_video: set video pts failed (%s)\n", strerror(errno)); } diff --git a/src/dxr3/em8300.h b/src/dxr3/em8300.h index b862f1d49..f65ceb6f6 100644 --- a/src/dxr3/em8300.h +++ b/src/dxr3/em8300.h @@ -1,3 +1,32 @@ +/* + * em8300.h + * + * Copyright (C) 2000 Henrik Johansson + * (C) 2000 Ze'ev Maor + * (C) 2001 Rick Haines + * (C) 2001 Edward Salley + * (C) 2001 Jeremy T. Braun + * (C) 2001 Ralph Zimmermann + * (C) 2001 Daniel Chassot + * (C) 2002 Michael Hunold + * (C) 2002-2003 David Holm + * (C) 2003-2008 Nicolas Boullis + * + * This program 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. + * + * This program 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 St, Fifth Floor, Boston, MA 02110-1301 USA + */ + #ifndef LINUX_EM8300_H #define LINUX_EM8300_H @@ -85,13 +114,13 @@ typedef struct { #define EM8300_OVERLAY_SIGNAL_WITH_VGA 2 #define EM8300_OVERLAY_VGA_ONLY 3 -#define EM8300_IOCTL_VIDEO_SETPTS 1 +#define EM8300_IOCTL_VIDEO_SETPTS _IOW('C',1,int) #define EM8300_IOCTL_VIDEO_GETSCR _IOR('C',2,unsigned) #define EM8300_IOCTL_VIDEO_SETSCR _IOW('C',2,unsigned) -#define EM8300_IOCTL_SPU_SETPTS 1 -#define EM8300_IOCTL_SPU_SETPALETTE 2 -#define EM8300_IOCTL_SPU_BUTTON 3 +#define EM8300_IOCTL_SPU_SETPTS _IOW('C',1,int) +#define EM8300_IOCTL_SPU_SETPALETTE _IOW('C',2,unsigned[16]) +#define EM8300_IOCTL_SPU_BUTTON _IOW('C',3,em8300_button_t) #define EM8300_ASPECTRATIO_4_3 0 #define EM8300_ASPECTRATIO_16_9 1 @@ -196,6 +225,25 @@ typedef struct { #define EM8300_MAJOR 121 #define EM8300_LOGNAME "em8300" +extern int major; + +#include +#include /* ulong, uint32_t */ +#include /* struct i2c_adapter */ +#include /* struct i2c_algo_bit_data */ +#include /* struct timeval */ +#include /* wait_queue_head_t */ +#include /* struct list_head */ + +#if defined(CONFIG_SND) || defined(CONFIG_SND_MODULE) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#define snd_card_t struct snd_card +#else +#include +#include +#include +#endif +#endif struct dicom_s { int luma; @@ -232,6 +280,31 @@ struct em8300_audio_s { int enable_bits; }; +struct em8300_model_config_s { + int use_bt865; + int dicom_other_pal; + int dicom_fix; + int dicom_control; + int bt865_ucode_timeout; + int activate_loopback; +}; + +struct adv717x_model_config_s { + int pixelport_16bit; + int pixelport_other_pal; + int pixeldata_adjust_ntsc; + int pixeldata_adjust_pal; +}; + +struct bt865_model_config_s { +}; + +struct em8300_config_s { + struct em8300_model_config_s model; + struct adv717x_model_config_s adv717x_model; + struct bt865_model_config_s bt865_model; +}; + struct em8300_s { char name[40]; @@ -250,12 +323,8 @@ struct em8300_s int playmode; - /* Sysfs */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,46) - struct class_device classdev; - struct class_device classdev_mv; - struct class_device classdev_ma; - struct class_device classdev_sp; +#if defined(CONFIG_SND) || defined(CONFIG_SND_MODULE) + snd_card_t *alsa_card; #endif /* Fifos */ @@ -291,6 +360,7 @@ struct em8300_s /* I2C clients */ int encoder_type; struct i2c_client *encoder; + struct i2c_client *eeprom; /* Microcode registers */ unsigned ucode_regs[MAX_UCODE_REGISTER]; @@ -318,14 +388,17 @@ struct em8300_s int audio_mode; int pcm_mode; int dsp_num; -/* */ - int dword_DB4; - unsigned char byte_D90[24]; + /* Channel status for S/PDIF */ + unsigned int channel_status_pos; + unsigned char channel_status[24]; + enum { NONE, OSS, ALSA } audio_driver_style; + struct semaphore audio_driver_style_lock; /* Video */ int video_mode; int video_playmode; int aspect_ratio; + int zoom; uint32_t video_pts; uint32_t video_lastpts; int video_ptsvalid,video_offset,video_count; @@ -375,10 +448,23 @@ struct em8300_s struct list_head memory; #endif + /* Checksum for the on-board eeprom */ + u8 *eeprom_checksum; + + int model; + + struct em8300_config_s config; + /* To support different options for different cards */ unsigned int card_nr; }; +#if defined(CONFIG_SND) || defined(CONFIG_SND_MODULE) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16) +#undef snd_card_t +#endif +#endif + #define TIMEDIFF(a,b) a.tv_usec - b.tv_usec + \ 1000000 * (a.tv_sec - b.tv_sec) @@ -388,7 +474,8 @@ struct em8300_s */ /* em8300_i2c.c */ -int em8300_i2c_init(struct em8300_s *em); +int em8300_i2c_init1(struct em8300_s *em); +int em8300_i2c_init2(struct em8300_s *em); void em8300_i2c_exit(struct em8300_s *em); void em8300_clockgen_write(struct em8300_s *em, int abyte); @@ -408,7 +495,8 @@ ssize_t em8300_audio_write(struct em8300_s *em, const char * buf, int mpegaudio_command(struct em8300_s *em, int cmd); /* em8300_ucode.c */ -int em8300_ucode_upload(struct em8300_s *em, void *ucode_user, int ucode_size); +void em8300_ucode_upload(struct em8300_s *em, void *ucode, int ucode_size); +void em8300_require_ucode(struct em8300_s *em); /* em8300_misc.c */ int em8300_setregblock(struct em8300_s *em, int offset, int val, int len); @@ -453,7 +541,7 @@ void em8300_spu_release(struct em8300_s *em); int em8300_control_ioctl(struct em8300_s *em, int cmd, unsigned long arg); int em8300_ioctl_setvideomode(struct em8300_s *em, int mode); int em8300_ioctl_setaspectratio(struct em8300_s *em, int ratio); -void em8300_ioctl_getstatus(struct em8300_s *em, char *usermsg); +int em8300_ioctl_getstatus(struct em8300_s *em, char *usermsg); int em8300_ioctl_init(struct em8300_s *em, em8300_microcode_t *useruc); void em8300_ioctl_enable_videoout(struct em8300_s *em, int mode); int em8300_ioctl_setplaymode(struct em8300_s *em, int mode); diff --git a/src/dxr3/video_out_dxr3.c b/src/dxr3/video_out_dxr3.c index 3d38e6640..f4121f59c 100644 --- a/src/dxr3/video_out_dxr3.c +++ b/src/dxr3/video_out_dxr3.c @@ -66,6 +66,8 @@ #include "dxr3.h" #include "video_out_dxr3.h" +#include "compat.c" + /* the amount of extra time we give the card for decoding */ #define DECODE_PIPE_PREBUFFER 10000 @@ -872,7 +874,7 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) 0x00, 0x01, 0x06, 0x00, 0x04, 0x00, 0x07, 0xFF, 0x00, 0x01, 0x00, 0x20, 0x02, 0xFF }; /* just clear any previous spu */ - ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, NULL); + dxr3_spu_button(this->fd_spu, NULL); write(this->fd_spu, empty_spu, sizeof(empty_spu)); pthread_mutex_unlock(&this->spu_device_lock); return; @@ -884,7 +886,7 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) this->spu_enc->color[6] = this->spu_enc->hili_color[2]; 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)) + if (dxr3_spu_setpalette(this->fd_spu, this->spu_enc->color)) xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "video_out_dxr3: failed to set CLUT (%s)\n", strerror(errno)); this->clut_cluttered = 1; @@ -907,7 +909,7 @@ static void dxr3_overlay_end(vo_driver_t *this_gen, vo_frame_t *frame_gen) btn.right = this->spu_enc->overlay->x + this->spu_enc->overlay->hili_right - 1; 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)) + if (dxr3_spu_button(this->fd_spu, &btn)) xprintf(this->class->xine, XINE_VERBOSITY_DEBUG, "dxr3_decode_spu: failed to set spu button (%s)\n", strerror(errno)); @@ -997,7 +999,7 @@ static void dxr3_display_frame(vo_driver_t *this_gen, vo_frame_t *frame_gen) } /* inform the card on the timing */ - if (ioctl(this->fd_video, EM8300_IOCTL_VIDEO_SETPTS, &vpts32)) + if (dxr3_video_setpts(this->fd_video, &vpts32)) 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 @@ -1252,7 +1254,7 @@ static void dxr3_dispose(vo_driver_t *this_gen) 0x00, 0x01, 0x06, 0x00, 0x04, 0x00, 0x07, 0xFF, 0x00, 0x01, 0x00, 0x20, 0x02, 0xFF }; /* clear any remaining spu */ - ioctl(this->fd_spu, EM8300_IOCTL_SPU_BUTTON, NULL); + dxr3_spu_button(this->fd_spu, NULL); write(this->fd_spu, empty_spu, sizeof(empty_spu)); close(this->fd_spu); } diff --git a/src/dxr3/video_out_dxr3.h b/src/dxr3/video_out_dxr3.h index 4dce49f4d..12cc3b76f 100644 --- a/src/dxr3/video_out_dxr3.h +++ b/src/dxr3/video_out_dxr3.h @@ -174,3 +174,9 @@ int dxr3_lavc_init(dxr3_driver_t *, plugin_node_t *); /* spu encoder functions */ spu_encoder_t *dxr3_spu_encoder_init(void); void dxr3_spu_encode(spu_encoder_t *); + +#define dxr3_video_setpts(fd,arg) dxr3_compat_ioctl((fd), EM8300_IOCTL_VIDEO_SETPTS, (arg)) +#define dxr3_spu_setpts(fd,arg) dxr3_compat_ioctl((fd), EM8300_IOCTL_SPU_SETPTS, (arg)) +#define dxr3_spu_setpalette(fd,arg) dxr3_compat_ioctl((fd), EM8300_IOCTL_SPU_SETPALETTE, (arg)) +#define dxr3_spu_button(fd,arg) dxr3_compat_ioctl((fd), EM8300_IOCTL_SPU_BUTTON, (arg)) +int dxr3_compat_ioctl (int, int, void *); -- cgit v1.2.3 From 1aa9a2e68b20f0f929f02bcae3a15e74c768079b Mon Sep 17 00:00:00 2001 From: Aoi Shinkai Date: Sun, 10 Jan 2010 00:36:02 +0900 Subject: Fix LPCM 24bit byte stream I have LCPM 24bit DVD. When I played it on xine, sound was noisy noise. I found that LCPM 24bit byte stream is _not_ the same as WAVE 24bit byte stream. --- src/libxineadec/xine_lpcm_decoder.c | 42 ++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/libxineadec/xine_lpcm_decoder.c b/src/libxineadec/xine_lpcm_decoder.c index 630d5a120..7438e26e6 100644 --- a/src/libxineadec/xine_lpcm_decoder.c +++ b/src/libxineadec/xine_lpcm_decoder.c @@ -269,29 +269,33 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { uint8_t *d = (uint8_t *)audio_buffer->mem; int n = buf_size; - while (n >= 3) { + while (n >= 12) { if ( stream_be ) { - if ( stream_be == this->cpu_be ) { - *d++ = s[0]; - *d++ = s[1]; - } else { - *d++ = s[1]; - *d++ = s[0]; - } + if ( stream_be == this->cpu_be ) { + *d++ = s[0]; + *d++ = s[1]; + *d++ = s[2]; + *d++ = s[3]; + *d++ = s[4]; + *d++ = s[5]; + *d++ = s[6]; + *d++ = s[7]; + } else { + *d++ = s[1]; + *d++ = s[0]; + *d++ = s[3]; + *d++ = s[2]; + *d++ = s[5]; + *d++ = s[4]; + *d++ = s[7]; + *d++ = s[6]; + } } else { - if ( stream_be == this->cpu_be ) { - *d++ = s[1]; - *d++ = s[2]; - } - else - { - *d++ = s[2]; - *d++ = s[1]; - } + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "lpcm_decoder: I don't know what should decode lpcm 24bit little endian byte stream"); } - s += 3; - n -= 3; + s += 12; + n -= 12; } if ( (d - (uint8_t*)audio_buffer->mem)/2*3 < buf_size ) -- cgit v1.2.3 From 96e0741443a7e7ccb3720ddbdce59d83a596363e Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Mon, 22 Feb 2010 19:37:03 +0000 Subject: Swap round if/while in LPCM 24-bit handling. This will reduce logspam with little-endian streams, which Can't Happen anyway. --- src/libxineadec/xine_lpcm_decoder.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/libxineadec/xine_lpcm_decoder.c b/src/libxineadec/xine_lpcm_decoder.c index 7438e26e6..6f4e71003 100644 --- a/src/libxineadec/xine_lpcm_decoder.c +++ b/src/libxineadec/xine_lpcm_decoder.c @@ -269,8 +269,8 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { uint8_t *d = (uint8_t *)audio_buffer->mem; int n = buf_size; - while (n >= 12) { - if ( stream_be ) { + if ( stream_be ) { + while (n >= 12) { if ( stream_be == this->cpu_be ) { *d++ = s[0]; *d++ = s[1]; @@ -290,12 +290,11 @@ static void lpcm_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { *d++ = s[7]; *d++ = s[6]; } - } else { - xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "lpcm_decoder: I don't know what should decode lpcm 24bit little endian byte stream"); + s += 12; + n -= 12; } - - s += 12; - n -= 12; + } else { + xprintf(this->stream->xine, XINE_VERBOSITY_DEBUG, "lpcm_decoder: I don't know what should decode lpcm 24bit little endian byte stream"); } if ( (d - (uint8_t*)audio_buffer->mem)/2*3 < buf_size ) -- cgit v1.2.3 From 4e697948c4646cf4a5a2fd06490db034b1ae076c Mon Sep 17 00:00:00 2001 From: Christopher Martin Date: Sun, 21 Feb 2010 09:43:00 -0500 Subject: WMAPro support Rename "wmav3" to "wmapro" in xine-lib's internals to line up xine-lib's nomenclature with what everyone else calls it and knows it as. [Tweaked by ds to avoid API change.] Tell xine-lib that when it finds wmapro, look to ffmpeg. ffmpeg's wmapro decoder is unique in that it puts out samples that are floats, not 16-bit ints. These need to be converted. This requires external ffmpeg. --- src/combined/ffmpeg/ff_audio_decoder.c | 43 ++++++++++++++++++++++++---------- src/combined/ffmpeg/ffmpeg_decoder.c | 1 + src/combined/ffmpeg/xine_audio.list | 1 + src/libw32dll/w32codec.c | 6 ++--- src/xine-engine/buffer.h | 3 ++- src/xine-engine/buffer_types.c | 4 ++-- 6 files changed, 40 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/combined/ffmpeg/ff_audio_decoder.c b/src/combined/ffmpeg/ff_audio_decoder.c index bd3ada69d..26e1ac168 100644 --- a/src/combined/ffmpeg/ff_audio_decoder.c +++ b/src/combined/ffmpeg/ff_audio_decoder.c @@ -94,6 +94,7 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) int out; audio_buffer_t *audio_buffer; int bytes_to_send; + unsigned int codec_type = buf->type & 0xFFFF0000; if ( (buf->decoder_flags & BUF_FLAG_HEADER) && !(buf->decoder_flags & BUF_FLAG_SPECIAL) ) { @@ -105,10 +106,8 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) if (buf->decoder_flags & BUF_FLAG_FRAME_END) { size_t i; - unsigned int codec_type; xine_waveformatex *audio_header; - codec_type = buf->type & 0xFFFF0000; this->codec = NULL; for(i = 0; i < sizeof(ff_audio_lookup)/sizeof(ff_codec_t); i++) @@ -228,7 +227,7 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) } } - /* Current ffmpeg audio decoders always use 16 bits/sample + /* Current ffmpeg audio decoders usually use 16 bits/sample * buf->decoder_info[2] can't be used as it doesn't refer to the output * bits/sample for some codecs (e.g. MS ADPCM) */ this->audio_bits = 16; @@ -346,14 +345,36 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) return; } - if ((decode_buffer_size - out) > audio_buffer->mem_size) - bytes_to_send = audio_buffer->mem_size; - else - bytes_to_send = decode_buffer_size - out; - /* fill up this buffer */ - xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[out], - bytes_to_send); + if (codec_type == BUF_AUDIO_WMAPRO) { + /* the above codecs output float samples, not 16-bit integers */ + int bytes_per_sample = sizeof(float); + if (((decode_buffer_size - out) * 2 / bytes_per_sample) > audio_buffer->mem_size) + bytes_to_send = audio_buffer->mem_size * bytes_per_sample / 2; + else + bytes_to_send = decode_buffer_size - out; + + int16_t *int_buffer = calloc(1, bytes_to_send * 2 / bytes_per_sample); + int i; + for (i = 0; i < (bytes_to_send / bytes_per_sample); i++) { + float *float_sample = (float *)&this->decode_buffer[i * bytes_per_sample + out]; + int_buffer[i] = (int16_t)lrintf(*float_sample * 32768.); + } + + out += bytes_to_send; + bytes_to_send = bytes_to_send * 2 / bytes_per_sample; + xine_fast_memcpy(audio_buffer->mem, int_buffer, bytes_to_send); + free(int_buffer); + } else { + if ((decode_buffer_size - out) > audio_buffer->mem_size) + bytes_to_send = audio_buffer->mem_size; + else + bytes_to_send = decode_buffer_size - out; + + xine_fast_memcpy(audio_buffer->mem, &this->decode_buffer[out], bytes_to_send); + out += bytes_to_send; + } + /* byte count / 2 (bytes / sample) / channels */ audio_buffer->num_frames = bytes_to_send / 2 / this->audio_channels; @@ -361,8 +382,6 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) buf->pts = 0; /* only first buffer gets the real pts */ this->stream->audio_out->put_buffer (this->stream->audio_out, audio_buffer, this->stream); - - out += bytes_to_send; } this->size -= bytes_consumed; diff --git a/src/combined/ffmpeg/ffmpeg_decoder.c b/src/combined/ffmpeg/ffmpeg_decoder.c index 6d0bfa432..adf0dad78 100644 --- a/src/combined/ffmpeg/ffmpeg_decoder.c +++ b/src/combined/ffmpeg/ffmpeg_decoder.c @@ -228,6 +228,7 @@ void avcodec_register_all(void) REGISTER_DECODER(WAVPACK, wavpack); REGISTER_DECODER(WMAV1, wmav1); REGISTER_DECODER(WMAV2, wmav2); + REGISTER_DECODER(WMAPRO, wmapro); REGISTER_DECODER(WS_SND1, ws_snd1); /* pcm codecs */ diff --git a/src/combined/ffmpeg/xine_audio.list b/src/combined/ffmpeg/xine_audio.list index 4b6932474..9ec727bf1 100644 --- a/src/combined/ffmpeg/xine_audio.list +++ b/src/combined/ffmpeg/xine_audio.list @@ -6,6 +6,7 @@ config=MP3ADU= WMAV1 WMAV1 MS Windows Media Audio 1 WMAV2 WMAV2 MS Windows Media Audio 2 +WMAPRO WMAPRO MS Windows Media Audio Professional 14_4 RA_144 Real 14.4 28_8 RA_288 Real 28.8 MPEG MP3 MP3 diff --git a/src/libw32dll/w32codec.c b/src/libw32dll/w32codec.c index 32cd7db29..715b10ff4 100644 --- a/src/libw32dll/w32codec.c +++ b/src/libw32dll/w32codec.c @@ -1086,11 +1086,11 @@ static char* get_auds_codec_name(w32a_decoder_t *this, int buf_type) { _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, "Windows Media Audio v2 (win32)"); return "divxa32.acm"; - case BUF_AUDIO_WMAV3: + case BUF_AUDIO_WMAPRO: this->driver_type = DRIVER_DMO; this->guid=&wma3_clsid; _x_meta_info_set_utf8(this->stream, XINE_META_INFO_AUDIOCODEC, - "Windows Media Audio v3 (win32)"); + "Windows Media Audio Professional (win32)"); return "wma9dmod.dll"; case BUF_AUDIO_WMALL: this->driver_type = DRIVER_DMO; @@ -1693,7 +1693,7 @@ static const decoder_info_t dec_info_video = { }; static uint32_t audio_types[] = { - BUF_AUDIO_WMAV1, BUF_AUDIO_WMAV2, BUF_AUDIO_WMAV3, BUF_AUDIO_MSADPCM, + BUF_AUDIO_WMAV1, BUF_AUDIO_WMAV2, BUF_AUDIO_WMAPRO, BUF_AUDIO_MSADPCM, BUF_AUDIO_MSIMAADPCM, BUF_AUDIO_MSGSM, BUF_AUDIO_IMC, BUF_AUDIO_LH, BUF_AUDIO_VOXWARE, BUF_AUDIO_ACELPNET, BUF_AUDIO_VIVOG723, BUF_AUDIO_WMAV, BUF_AUDIO_WMALL, diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index 42302b30f..3b25c732e 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -232,7 +232,8 @@ extern "C" { #define BUF_AUDIO_14_4 0x03230000 #define BUF_AUDIO_28_8 0x03240000 #define BUF_AUDIO_SIPRO 0x03250000 -#define BUF_AUDIO_WMAV3 0x03260000 +#define BUF_AUDIO_WMAPRO 0x03260000 +#define BUF_AUDIO_WMAV3 BUF_AUDIO_WMAPRO #define BUF_AUDIO_INTERPLAY 0x03270000 #define BUF_AUDIO_XA_ADPCM 0x03280000 #define BUF_AUDIO_WESTWOOD 0x03290000 diff --git a/src/xine-engine/buffer_types.c b/src/xine-engine/buffer_types.c index 51e688f7e..33a09b907 100644 --- a/src/xine-engine/buffer_types.c +++ b/src/xine-engine/buffer_types.c @@ -859,8 +859,8 @@ static const audio_db_t audio_db[] = { { 0x162, 0 }, - BUF_AUDIO_WMAV3, - "Windows Media Audio v3" + BUF_AUDIO_WMAPRO, + "Windows Media Audio Professional" }, { { -- cgit v1.2.3 From 87db48cae2e7875af646327143e09e1c4cd230ad Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Tue, 23 Feb 2010 21:58:55 +0000 Subject: Prevent discard_{frames,buffers} from going negative. Based on patches from Roger Scott . --- src/xine-engine/audio_out.c | 5 ++++- src/xine-engine/video_out.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 4f68b8975..985520759 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -1889,8 +1889,11 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value /* recursive discard buffers setting */ if(value) this->discard_buffers++; - else + else if (this->discard_buffers) this->discard_buffers--; + else + xprintf (this->xine, XINE_VERBOSITY_DEBUG, + "ao_set_property: discard_buffers is already zero\n"); ret = this->discard_buffers; diff --git a/src/xine-engine/video_out.c b/src/xine-engine/video_out.c index 0b6d8f7a1..d06e82afa 100644 --- a/src/xine-engine/video_out.c +++ b/src/xine-engine/video_out.c @@ -1469,8 +1469,11 @@ static int vo_set_property (xine_video_port_t *this_gen, int property, int value pthread_mutex_lock(&this->display_img_buf_queue->mutex); if(value) this->discard_frames++; - else + else if (this->discard_frames) this->discard_frames--; + else + xprintf (this->xine, XINE_VERBOSITY_DEBUG, + "vo_set_property: discard_frames is already zero\n"); pthread_mutex_unlock(&this->display_img_buf_queue->mutex); ret = this->discard_frames; -- cgit v1.2.3 From 7d4c68e4ba6932bfd300a9dc12d7e11b9cfb555d Mon Sep 17 00:00:00 2001 From: Roger Scott Date: Tue, 15 Sep 2009 10:19:22 +1030 Subject: Add locking for when adjusting audio frame discarding. --- src/xine-engine/audio_out.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 985520759..0a141e014 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -1887,6 +1887,7 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value case AO_PROP_DISCARD_BUFFERS: /* recursive discard buffers setting */ + pthread_mutex_lock(&this->flush_audio_driver_lock); if(value) this->discard_buffers++; else if (this->discard_buffers) @@ -1894,6 +1895,7 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value else xprintf (this->xine, XINE_VERBOSITY_DEBUG, "ao_set_property: discard_buffers is already zero\n"); + pthread_mutex_unlock(&this->flush_audio_driver_lock); ret = this->discard_buffers; -- cgit v1.2.3