diff --git a/extras/package/rpm/vlc.altlinux.spec b/extras/package/rpm/vlc.altlinux.spec index 33511ad8dc6e96ad1155cc3db93d36cededa0e78..021ca249438ce4e392fe7371359632acc2506f1f 100644 --- a/extras/package/rpm/vlc.altlinux.spec +++ b/extras/package/rpm/vlc.altlinux.spec @@ -1033,7 +1033,6 @@ strfile %buildroot%_gamesdatadir/fortune/vlc %buildroot%_gamesdatadir/fortune/vl %_vlc_pluginsdir/audio_output/libaout_file_plugin.so* %dir %_vlc_pluginsdir/codec -%_vlc_pluginsdir/codec/liba52_plugin.so* %_vlc_pluginsdir/codec/libadpcm_plugin.so* %_vlc_pluginsdir/codec/libaraw_plugin.so* %_vlc_pluginsdir/codec/librawvideo_plugin.so* @@ -1135,7 +1134,7 @@ strfile %buildroot%_gamesdatadir/fortune/vlc %buildroot%_gamesdatadir/fortune/vl #%_vlc_pluginsdir/mux/libmux_ts_plugin.so* %dir %_vlc_pluginsdir/packetizer -#_vlc_pluginsdir/packetizer/libpacketizer_a52_plugin.so* +%_vlc_pluginsdir/packetizer/libpacketizer_a52_plugin.so* %_vlc_pluginsdir/packetizer/libpacketizer_copy_plugin.so* %_vlc_pluginsdir/packetizer/libpacketizer_mpeg4audio_plugin.so* %_vlc_pluginsdir/packetizer/libpacketizer_mpeg4video_plugin.so* diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am index 6703091e124cc953a05843e6efbec7fb8154df6e..ef0aa7436aede7d904d2df552eff98ebcb1e6ac9 100644 --- a/modules/codec/Makefile.am +++ b/modules/codec/Makefile.am @@ -16,9 +16,6 @@ endif libspdif_plugin_la_SOURCES = codec/spdif.c codec_LTLIBRARIES += libspdif_plugin.la -liba52_plugin_la_SOURCES = codec/a52.c codec/a52.h -codec_LTLIBRARIES += liba52_plugin.la - libadpcm_plugin_la_SOURCES = codec/adpcm.c codec_LTLIBRARIES += libadpcm_plugin.la diff --git a/modules/demux/mpeg/es.c b/modules/demux/mpeg/es.c index ba80bb7fd56df5a10794f5e4032f9a0d76b568e6..69785be836d2245fe90127bc49f9c0fbf26d3097 100644 --- a/modules/demux/mpeg/es.c +++ b/modules/demux/mpeg/es.c @@ -37,7 +37,7 @@ #include <vlc_codecs.h> #include <vlc_input.h> -#include "../../codec/a52.h" +#include "../../packetizer/a52.h" #include "../../codec/dts_header.h" /***************************************************************************** diff --git a/modules/packetizer/Makefile.am b/modules/packetizer/Makefile.am index 42edf1f6158e9eab8bc6c6129e56e90df80c0442..2bc1190e6381f0cadda6cddc5fdcc2f4eace2276 100644 --- a/modules/packetizer/Makefile.am +++ b/modules/packetizer/Makefile.am @@ -16,6 +16,7 @@ libpacketizer_hevc_plugin_la_SOURCES = packetizer/hevc.c \ packetizer/hevc_nal.h packetizer/hevc_nal.c \ packetizer/hxxx_nal.h \ packetizer/hxxx_common.c packetizer/hxxx_common.h +libpacketizer_a52_plugin_la_SOURCES = packetizer/a52.c packetizer/a52.h libpacketizer_avparser_plugin_la_SOURCES = packetizer/avparser.c \ packetizer/avparser.h \ @@ -25,7 +26,6 @@ libpacketizer_avparser_plugin_la_SOURCES = packetizer/avparser.c \ libpacketizer_avparser_plugin_la_CFLAGS = $(AVCODEC_CFLAGS) $(AVUTIL_CFLAGS) $(AM_CFLAGS) libpacketizer_avparser_plugin_la_LIBADD = $(AVCODEC_LIBS) $(AVUTIL_LIBS) $(LIBM) - noinst_HEADERS += packetizer/packetizer_helper.h packetizer/startcode_helper.h packetizer_LTLIBRARIES = \ @@ -39,6 +39,7 @@ packetizer_LTLIBRARIES = \ libpacketizer_flac_plugin.la \ libpacketizer_hevc_plugin.la \ libpacketizer_copy_plugin.la \ + libpacketizer_a52_plugin.la \ $(NULL) if HAVE_AVCODEC diff --git a/modules/codec/a52.c b/modules/packetizer/a52.c similarity index 60% rename from modules/codec/a52.c rename to modules/packetizer/a52.c index 044905b8b98033ecbae784ff14f45eecfe18cfe1..25cae8e34a9b4c7380441d6adcc126b883514307 100644 --- a/modules/codec/a52.c +++ b/modules/packetizer/a52.c @@ -1,7 +1,7 @@ /***************************************************************************** * a52.c: parse A/52 audio sync info and packetize the stream ***************************************************************************** - * Copyright (C) 2001-2002 VLC authors and VideoLAN + * Copyright (C) 2001-2016 VLC authors and VideoLAN * $Id$ * * Authors: Stéphane Borel <stef@via.ecp.fr> @@ -38,37 +38,21 @@ #include "a52.h" -#include "../packetizer/packetizer_helper.h" +#include "packetizer_helper.h" -/***************************************************************************** - * Module descriptor - *****************************************************************************/ -static int OpenDecoder ( vlc_object_t * ); -static int OpenPacketizer( vlc_object_t * ); -static void CloseCommon ( vlc_object_t * ); +static int Open( vlc_object_t * ); +static void Close( vlc_object_t * ); vlc_module_begin () - set_description( N_("A/52 parser") ) - set_capability( "decoder", 100 ) - set_callbacks( OpenDecoder, CloseCommon ) - set_category( CAT_INPUT ) - set_subcategory( SUBCAT_INPUT_ACODEC ) - - add_submodule () + set_category(CAT_SOUT) + set_subcategory(SUBCAT_SOUT_PACKETIZER) set_description( N_("A/52 audio packetizer") ) set_capability( "packetizer", 10 ) - set_callbacks( OpenPacketizer, CloseCommon ) + set_callbacks( Open, Close ) vlc_module_end () -/***************************************************************************** - * decoder_sys_t : decoder descriptor - *****************************************************************************/ - struct decoder_sys_t { - /* Module mode */ - bool b_packetizer; - /* * Input properties */ @@ -80,110 +64,64 @@ struct decoder_sys_t * Common properties */ date_t end_date; + bool b_date_set; mtime_t i_pts; vlc_a52_header_t frame; }; -/**************************************************************************** - * Local prototypes - ****************************************************************************/ -static block_t *DecodeBlock ( decoder_t *, block_t ** ); -static void Flush( decoder_t * ); +static void PacketizeFlush( decoder_t *p_dec ) +{ + decoder_sys_t *p_sys = p_dec->p_sys; -static uint8_t *GetOutBuffer ( decoder_t *, block_t ** ); -static block_t *GetAoutBuffer( decoder_t * ); -static block_t *GetSoutBuffer( decoder_t * ); + date_Set( &p_sys->end_date, 0 ); + p_sys->i_state = STATE_NOSYNC; + block_BytestreamEmpty( &p_sys->bytestream ); +} -/***************************************************************************** - * OpenCommon: probe the decoder/packetizer and return score - *****************************************************************************/ -static int OpenCommon( vlc_object_t *p_this, bool b_packetizer ) +static block_t *GetOutBuffer( decoder_t *p_dec ) { - decoder_t *p_dec = (decoder_t*)p_this; - decoder_sys_t *p_sys; - vlc_fourcc_t i_codec; + decoder_sys_t *p_sys = p_dec->p_sys; - switch( p_dec->fmt_in.i_codec ) + if( !p_sys->b_date_set + || p_dec->fmt_out.audio.i_rate != p_sys->frame.i_rate ) { - case VLC_CODEC_A52: - i_codec = VLC_CODEC_A52; - break; - case VLC_CODEC_EAC3: - /* XXX ugly hack, a52 does not support eac3 so no eac3 pass-through - * support */ - if( !b_packetizer ) - return VLC_EGENERIC; - i_codec = VLC_CODEC_EAC3; - break; - default: - return VLC_EGENERIC; - } - - /* Allocate the memory needed to store the decoder's structure */ - if( ( p_dec->p_sys = p_sys = - (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) - return VLC_ENOMEM; - - /* Misc init */ - p_sys->b_packetizer = b_packetizer; - p_sys->i_state = STATE_NOSYNC; - date_Set( &p_sys->end_date, 0 ); - p_sys->i_pts = VLC_TS_INVALID; - - block_BytestreamInit( &p_sys->bytestream ); + msg_Dbg( p_dec, "A/52 channels:%d samplerate:%d bitrate:%d", + p_sys->frame.i_channels, p_sys->frame.i_rate, p_sys->frame.i_bitrate ); - /* Set output properties */ - p_dec->fmt_out.i_cat = AUDIO_ES; - p_dec->fmt_out.i_codec = i_codec; - p_dec->fmt_out.audio.i_rate = 0; /* So end_date gets initialized */ - p_dec->fmt_out.audio.i_bytes_per_frame = 0; + date_Init( &p_sys->end_date, p_sys->frame.i_rate, 1 ); + date_Set( &p_sys->end_date, p_sys->i_pts ); + p_sys->b_date_set = true; + } - /* Set callback */ - if( b_packetizer ) - p_dec->pf_packetize = DecodeBlock; - else - p_dec->pf_decode_audio = DecodeBlock; - p_dec->pf_flush = Flush; - return VLC_SUCCESS; -} + p_dec->fmt_out.audio.i_rate = p_sys->frame.i_rate; + p_dec->fmt_out.audio.i_channels = p_sys->frame.i_channels; + if( p_dec->fmt_out.audio.i_bytes_per_frame < p_sys->frame.i_size ) + p_dec->fmt_out.audio.i_bytes_per_frame = p_sys->frame.i_size; + p_dec->fmt_out.audio.i_frame_length = p_sys->frame.i_samples; -static int OpenDecoder( vlc_object_t *p_this ) -{ - /* HACK: Don't use this codec if we don't have an a52 audio filter */ - if( !module_exists( "a52tofloat32" ) ) - return VLC_EGENERIC; - return OpenCommon( p_this, false ); -} + p_dec->fmt_out.audio.i_original_channels = p_sys->frame.i_channels_conf; + p_dec->fmt_out.audio.i_physical_channels = + p_sys->frame.i_channels_conf & AOUT_CHAN_PHYSMASK; -static int OpenPacketizer( vlc_object_t *p_this ) -{ - return OpenCommon( p_this, true ); -} + p_dec->fmt_out.i_bitrate = p_sys->frame.i_bitrate; -/***************************************************************************** - * Flush: - *****************************************************************************/ -static void Flush( decoder_t *p_dec ) -{ - decoder_sys_t *p_sys = p_dec->p_sys; + block_t *p_block = block_Alloc( p_sys->frame.i_size ); + if( p_block == NULL ) + return NULL; - date_Set( &p_sys->end_date, 0 ); - p_sys->i_state = STATE_NOSYNC; - block_BytestreamEmpty( &p_sys->bytestream ); + p_block->i_nb_samples = p_sys->frame.i_samples; + p_block->i_pts = p_block->i_dts = date_Get( &p_sys->end_date ); + p_block->i_length = + date_Increment( &p_sys->end_date, p_block->i_nb_samples ) - p_block->i_pts; + return p_block; } -/**************************************************************************** - * DecodeBlock: the whole thing - **************************************************************************** - * This function is called just after the thread is launched. - ****************************************************************************/ -static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) +static block_t *PacketizeBlock( decoder_t *p_dec, block_t **pp_block ) { decoder_sys_t *p_sys = p_dec->p_sys; uint8_t p_header[VLC_A52_HEADER_SIZE]; - uint8_t *p_buf; block_t *p_out_buffer; if( !pp_block || !*pp_block ) return NULL; @@ -192,7 +130,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) { if( (*pp_block)->i_flags & BLOCK_FLAG_CORRUPTED ) { - Flush( p_dec ); + PacketizeFlush( p_dec ); block_Release( *pp_block ); *pp_block = NULL; return NULL; @@ -278,8 +216,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) return NULL; } - if( p_sys->b_packetizer && - p_header[0] == 0 && p_header[1] == 0 ) + if( p_header[0] == 0 && p_header[1] == 0 ) { /* A52 wav files and audio CD's use stuffing */ p_sys->i_state = STATE_GET_DATA; @@ -309,7 +246,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) p_sys->i_state = STATE_SEND_DATA; case STATE_SEND_DATA: - if( !(p_buf = GetOutBuffer( p_dec, &p_out_buffer )) ) + if( !(p_out_buffer = GetOutBuffer( p_dec )) ) { //p_dec->b_error = true; return NULL; @@ -317,8 +254,8 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) /* Copy the whole frame into the buffer. When we reach this point * we already know we have enough data available. */ - block_GetBytes( &p_sys->bytestream, - p_buf, __MIN( p_sys->frame.i_size, p_out_buffer->i_buffer ) ); + block_GetBytes( &p_sys->bytestream, p_out_buffer->p_buffer, + __MIN( p_sys->frame.i_size, p_out_buffer->i_buffer ) ); /* Make sure we don't reuse the same pts twice */ if( p_sys->i_pts == p_sys->bytestream.p_block->i_pts ) @@ -334,10 +271,7 @@ static block_t *DecodeBlock( decoder_t *p_dec, block_t **pp_block ) } } -/***************************************************************************** - * CloseCommon: clean up the decoder - *****************************************************************************/ -static void CloseCommon( vlc_object_t *p_this ) +static void Close( vlc_object_t *p_this ) { decoder_t *p_dec = (decoder_t*)p_this; decoder_sys_t *p_sys = p_dec->p_sys; @@ -347,84 +281,47 @@ static void CloseCommon( vlc_object_t *p_this ) free( p_sys ); } -/***************************************************************************** - * GetOutBuffer: - *****************************************************************************/ -static uint8_t *GetOutBuffer( decoder_t *p_dec, block_t **pp_out_buffer ) +static int Open( vlc_object_t *p_this ) { - decoder_sys_t *p_sys = p_dec->p_sys; - uint8_t *p_buf; - - if( p_dec->fmt_out.audio.i_rate != p_sys->frame.i_rate ) - { - msg_Dbg( p_dec, "A/52 channels:%d samplerate:%d bitrate:%d", - p_sys->frame.i_channels, p_sys->frame.i_rate, p_sys->frame.i_bitrate ); - - date_Init( &p_sys->end_date, p_sys->frame.i_rate, 1 ); - date_Set( &p_sys->end_date, p_sys->i_pts ); - } - - p_dec->fmt_out.audio.i_rate = p_sys->frame.i_rate; - p_dec->fmt_out.audio.i_channels = p_sys->frame.i_channels; - if( p_dec->fmt_out.audio.i_bytes_per_frame < p_sys->frame.i_size ) - p_dec->fmt_out.audio.i_bytes_per_frame = p_sys->frame.i_size; - p_dec->fmt_out.audio.i_frame_length = p_sys->frame.i_samples; - - p_dec->fmt_out.audio.i_original_channels = p_sys->frame.i_channels_conf; - p_dec->fmt_out.audio.i_physical_channels = - p_sys->frame.i_channels_conf & AOUT_CHAN_PHYSMASK; - - p_dec->fmt_out.i_bitrate = p_sys->frame.i_bitrate; + decoder_t *p_dec = (decoder_t*)p_this; + decoder_sys_t *p_sys; - if( p_sys->b_packetizer ) - { - block_t *p_sout_buffer = GetSoutBuffer( p_dec ); - p_buf = p_sout_buffer ? p_sout_buffer->p_buffer : NULL; - *pp_out_buffer = p_sout_buffer; - } - else + switch( p_dec->fmt_in.i_codec ) { - block_t *p_aout_buffer = GetAoutBuffer( p_dec ); - p_buf = p_aout_buffer ? p_aout_buffer->p_buffer : NULL; - *pp_out_buffer = p_aout_buffer; + /* TODO case VLC_CODEC_EAC3: */ + case VLC_CODEC_A52: + break; + default: + return VLC_EGENERIC; } - return p_buf; -} - -/***************************************************************************** - * GetAoutBuffer: - *****************************************************************************/ -static block_t *GetAoutBuffer( decoder_t *p_dec ) -{ - decoder_sys_t *p_sys = p_dec->p_sys; + /* Allocate the memory needed to store the decoder's structure */ + if( ( p_dec->p_sys = p_sys = + (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) + return VLC_ENOMEM; - block_t *p_buf = decoder_NewAudioBuffer( p_dec, p_sys->frame.i_samples ); - if( p_buf ) - { - p_buf->i_pts = date_Get( &p_sys->end_date ); - p_buf->i_length = date_Increment( &p_sys->end_date, - p_sys->frame.i_samples ) - p_buf->i_pts; - } + /* Misc init */ + p_sys->i_state = STATE_NOSYNC; + date_Set( &p_sys->end_date, 0 ); + p_sys->i_pts = VLC_TS_INVALID; + p_sys->b_date_set = false; - return p_buf; -} + block_BytestreamInit( &p_sys->bytestream ); -/***************************************************************************** - * GetSoutBuffer: - *****************************************************************************/ -static block_t *GetSoutBuffer( decoder_t *p_dec ) -{ - decoder_sys_t *p_sys = p_dec->p_sys; + /* Set output properties */ + p_dec->fmt_out.i_cat = AUDIO_ES; + p_dec->fmt_out.i_codec = p_dec->fmt_in.i_codec; + p_dec->fmt_out.audio = p_dec->fmt_in.audio; - block_t *p_block = block_Alloc( p_sys->frame.i_size ); - if( p_block ) - { - p_block->i_pts = p_block->i_dts = date_Get( &p_sys->end_date ); - p_block->i_length = - date_Increment( &p_sys->end_date, p_sys->frame.i_samples ) - p_block->i_pts; - } + p_sys->frame.i_rate = p_dec->fmt_out.audio.i_rate; + p_sys->frame.i_channels = p_dec->fmt_out.audio.i_channels; + p_sys->frame.i_size = p_dec->fmt_out.audio.i_bytes_per_frame; + p_sys->frame.i_samples = p_dec->fmt_out.audio.i_frame_length; + p_sys->frame.i_channels_conf = p_dec->fmt_out.audio.i_original_channels; + p_sys->frame.i_bitrate = p_dec->fmt_out.i_bitrate; - return p_block; + /* Set callback */ + p_dec->pf_packetize = PacketizeBlock; + p_dec->pf_flush = PacketizeFlush; + return VLC_SUCCESS; } - diff --git a/modules/codec/a52.h b/modules/packetizer/a52.h similarity index 100% rename from modules/codec/a52.h rename to modules/packetizer/a52.h diff --git a/po/POTFILES.in b/po/POTFILES.in index 6d5801c06df603f4867978ec99baa9722cdd8d6c..3abcf389ee5db526858162e9fb10a2d5a3a8f305 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -332,7 +332,6 @@ modules/audio_output/volume.h modules/audio_output/wasapi.c modules/audio_output/waveout.c modules/audio_output/windows_audio_common.h -modules/codec/a52.c modules/codec/adpcm.c modules/codec/aes3.c modules/codec/araw.c @@ -1001,6 +1000,7 @@ modules/mux/ogg.c modules/mux/wav.c modules/notify/osx_notifications.m modules/notify/notify.c +modules/packetizer/a52.c modules/packetizer/avparser.h modules/packetizer/copy.c modules/packetizer/dirac.c