From 83e3fe189c4c28bf73fec89587e5fe21b2f7f0b2 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Tue, 8 Feb 2005 11:08:15 +0000 Subject: [PATCH] configure.ac: Add dvdlpcmdec Original commit message from CVS: * configure.ac: Add dvdlpcmdec * ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset), (free_all_buffers), (gst_mpeg2dec_alloc_buffer): Don't push buffers if the src pad isn't negotiated yet. * gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_buffer_to_default_format), (gst_audio_convert_buffer_from_default_format): Add support for 24-bit width. * gst/dvdlpcmdec/.cvsignore: * gst/dvdlpcmdec/Makefile.am: * gst/dvdlpcmdec/gstdvdlpcmdec.c: (gst_dvdlpcmdec_get_type), (gst_dvdlpcmdec_base_init), (gst_dvdlpcmdec_class_init), (gst_dvdlpcm_reset), (gst_dvdlpcmdec_init), (gst_dvdlpcmdec_link), (gst_dvdlpcmdec_chain), (gst_dvdlpcmdec_change_state), (plugin_init): * gst/dvdlpcmdec/gstdvdlpcmdec.h: New decoder for rearranging DVD LPCM into our audio/x-raw-int format. Needs support for the channels maps if someone can find a DVD LPCM track with > 2 channels. * gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_handle_dvd_event), (gst_dvd_demux_send_discont), (gst_dvd_demux_handle_discont), (gst_dvd_demux_get_audio_stream), (gst_dvd_demux_process_private): * gst/mpegstream/gstdvddemux.h: * gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont), (gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_init_stream), (gst_mpeg_demux_send_subbuffer), (gst_mpeg_demux_handle_src_query): * gst/mpegstream/gstmpegdemux.h: * gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_reset), (gst_mpeg_parse_parse_packhead), (gst_mpeg_parse_loop), (gst_mpeg_parse_get_rate), (gst_mpeg_parse_convert_src), (gst_mpeg_parse_handle_src_query), (gst_mpeg_parse_handle_src_event): Use audio/x-dvd-lpcm for LPCM output. Add DTS output. --- ChangeLog | 42 ++++++++++++++++++++ configure.ac | 2 + gst/audioconvert/gstaudioconvert.c | 64 +++++++++++++++++++++++++----- 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0c010d04b2..b5b4744c65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,45 @@ +2005-02-08 Jan Schmidt + + * configure.ac: + Add dvdlpcmdec + + * ext/mpeg2dec/gstmpeg2dec.c: (gst_mpeg2dec_reset), + (free_all_buffers), (gst_mpeg2dec_alloc_buffer): + Don't push buffers if the src pad isn't negotiated yet. + + * gst/audioconvert/gstaudioconvert.c: + (gst_audio_convert_buffer_to_default_format), + (gst_audio_convert_buffer_from_default_format): + Add support for 24-bit width. + + * gst/dvdlpcmdec/.cvsignore: + * gst/dvdlpcmdec/Makefile.am: + * gst/dvdlpcmdec/gstdvdlpcmdec.c: (gst_dvdlpcmdec_get_type), + (gst_dvdlpcmdec_base_init), (gst_dvdlpcmdec_class_init), + (gst_dvdlpcm_reset), (gst_dvdlpcmdec_init), (gst_dvdlpcmdec_link), + (gst_dvdlpcmdec_chain), (gst_dvdlpcmdec_change_state), + (plugin_init): + * gst/dvdlpcmdec/gstdvdlpcmdec.h: + New decoder for rearranging DVD LPCM into our audio/x-raw-int + format. Needs support for the channels maps if someone can find + a DVD LPCM track with > 2 channels. + + * gst/mpegstream/gstdvddemux.c: (gst_dvd_demux_handle_dvd_event), + (gst_dvd_demux_send_discont), (gst_dvd_demux_handle_discont), + (gst_dvd_demux_get_audio_stream), (gst_dvd_demux_process_private): + * gst/mpegstream/gstdvddemux.h: + * gst/mpegstream/gstmpegdemux.c: (gst_mpeg_demux_send_discont), + (gst_mpeg_demux_new_output_pad), (gst_mpeg_demux_init_stream), + (gst_mpeg_demux_send_subbuffer), (gst_mpeg_demux_handle_src_query): + * gst/mpegstream/gstmpegdemux.h: + * gst/mpegstream/gstmpegparse.c: (gst_mpeg_parse_reset), + (gst_mpeg_parse_parse_packhead), (gst_mpeg_parse_loop), + (gst_mpeg_parse_get_rate), (gst_mpeg_parse_convert_src), + (gst_mpeg_parse_handle_src_query), + (gst_mpeg_parse_handle_src_event): + Use audio/x-dvd-lpcm for LPCM output. + Add DTS output. + 2005-02-08 Gergely Nagy Reviewed by: Ronald S. Bultje diff --git a/configure.ac b/configure.ac index 70b349b8e3..870d269a65 100644 --- a/configure.ac +++ b/configure.ac @@ -376,6 +376,7 @@ GST_PLUGINS_ALL="\ cutter \ debug \ deinterlace \ + dvdlpcmdec \ effectv \ equalizer \ festival \ @@ -1956,6 +1957,7 @@ gst/colorspace/Makefile gst/cutter/Makefile gst/debug/Makefile gst/deinterlace/Makefile +gst/dvdlpcmdec/Makefile gst/effectv/Makefile gst/equalizer/Makefile gst/festival/Makefile diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c index bcb898e7af..2926f3b002 100644 --- a/gst/audioconvert/gstaudioconvert.c +++ b/gst/audioconvert/gstaudioconvert.c @@ -113,6 +113,13 @@ GST_STATIC_CAPS ( \ "width = (int) 16, " \ "depth = (int) [ 1, 16 ], " \ "signed = (boolean) { true, false }; " \ + "audio/x-raw-int, " \ + "rate = (int) [ 1, MAX ], " \ + "channels = (int) [ 1, 8 ], " \ + "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \ + "width = (int) 24, " \ + "depth = (int) [ 1, 24 ], " \ + "signed = (boolean) { true, false }; " \ "audio/x-raw-int, " \ "rate = (int) [ 1, MAX ], " \ "channels = (int) [ 1, 8 ], " \ @@ -706,6 +713,23 @@ gst_audio_convert_buffer_to_default_format (GstAudioConvert * this, this->sinkcaps.endianness, GUINT16_FROM_LE, GUINT16_FROM_BE); } break; + case 24: + { + /* Read 24-bits LE/BE into signed 64 host-endian */ + if (this->sinkcaps.endianness == G_LITTLE_ENDIAN) { + cur = src[0] | (src[1] << 8) | (src[2] << 16); + } else { + cur = src[2] | (src[1] << 8) | (src[0] << 16); + } + + /* Sign extend */ + if ((this->sinkcaps.sign) + && (cur & (1 << (this->sinkcaps.depth - 1)))) + cur |= ((gint64) (-1)) ^ ((1 << this->sinkcaps.depth) - 1); + + src -= 3; + } + break; case 32: if (this->sinkcaps.sign) { CONVERT_TO (cur, src, gint32, this->sinkcaps.sign, @@ -747,9 +771,9 @@ gst_audio_convert_buffer_to_default_format (GstAudioConvert * this, return ret; } -#define POPULATE(format, be_func, le_func) G_STMT_START{ \ +#define POPULATE(out, format, be_func, le_func) G_STMT_START{ \ format val; \ - format* p = (format *) dest; \ + format* p = (format *) out; \ int_value >>= (32 - this->srccaps.depth); \ if (this->srccaps.sign) { \ val = (format) int_value; \ @@ -768,7 +792,7 @@ gst_audio_convert_buffer_to_default_format (GstAudioConvert * this, }; \ *p = val; \ p ++; \ - dest = (guint8 *) p; \ + out = (guint8 *) p; \ }G_STMT_END static GstBuffer * @@ -802,23 +826,45 @@ gst_audio_convert_buffer_from_default_format (GstAudioConvert * this, switch (this->srccaps.width) { case 8: if (this->srccaps.sign) { - POPULATE (gint8, GINT8_IDENTITY, GINT8_IDENTITY); + POPULATE (dest, gint8, GINT8_IDENTITY, GINT8_IDENTITY); } else { - POPULATE (guint8, GUINT8_IDENTITY, GUINT8_IDENTITY); + POPULATE (dest, guint8, GUINT8_IDENTITY, GUINT8_IDENTITY); } break; case 16: if (this->srccaps.sign) { - POPULATE (gint16, GINT16_TO_BE, GINT16_TO_LE); + POPULATE (dest, gint16, GINT16_TO_BE, GINT16_TO_LE); } else { - POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE); + POPULATE (dest, guint16, GUINT16_TO_BE, GUINT16_TO_LE); } break; + case 24: + { + guint8 tmp[4]; + guint8 *tmpp = tmp; + + /* Write out big endian array */ + if (this->srccaps.sign) { + POPULATE (tmpp, gint32, GINT32_TO_BE, GINT32_TO_BE); + } else { + POPULATE (tmpp, guint32, GUINT32_TO_BE, GUINT32_TO_BE); + } + + if (this->srccaps.endianness == G_LITTLE_ENDIAN) { + dest[2] = tmp[1]; + dest[1] = tmp[2]; + dest[0] = tmp[3]; + } else { + memcpy (dest, tmp + 1, 3); + } + dest += 3; + } + break; case 32: if (this->srccaps.sign) { - POPULATE (gint32, GINT32_TO_BE, GINT32_TO_LE); + POPULATE (dest, gint32, GINT32_TO_BE, GINT32_TO_LE); } else { - POPULATE (guint32, GUINT32_TO_BE, GUINT32_TO_LE); + POPULATE (dest, guint32, GUINT32_TO_BE, GUINT32_TO_LE); } break; default: