Commit 626e56bf authored by Rafaël Carré's avatar Rafaël Carré
Browse files

demuxers: remove the need for input_thread_t by using the new "meta-preparsed" input variable.

tta & ffmpeg: remove unneeded "meta reader" loading
tta didn't use anyway, and ffmpeg uses information from libavcodec
parent 4f5d55cf
......@@ -30,7 +30,6 @@
#include <vlc_demux.h>
#include <vlc_stream.h>
#include <vlc_meta.h>
#include <vlc_input.h>
/* ffmpeg header */
#ifdef HAVE_FFMPEG_AVFORMAT_H
......@@ -256,35 +255,6 @@ int E_(OpenDemux)( vlc_object_t *p_this )
( p_sys->ic->duration != (int64_t)AV_NOPTS_VALUE ) ?
p_sys->ic->duration * 1000000 / AV_TIME_BASE : -1 );
input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input )
{
if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
{
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
{
vlc_object_release( p_input );
return VLC_ENOMEM;
}
module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 );
if( p_meta )
{
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
vlc_meta_Merge( input_GetItem(p_input)->p_meta,
p_demux_meta->p_meta );
vlc_meta_Delete( p_demux_meta->p_meta );
module_Unneed( p_demux, p_meta );
int i;
for( i = 0; i < p_demux_meta->i_attachments; i++ )
free( p_demux_meta->attachments[i] );
TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
}
free( p_demux->p_private );
}
vlc_object_release( p_input );
}
return VLC_SUCCESS;
}
......
......@@ -155,44 +155,34 @@ static int Open( vlc_object_t * p_this )
}
/* Parse possible id3 header */
input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input )
if( !var_CreateGetBool( p_demux, "meta-preparsed" ) )
{
if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
return VLC_ENOMEM;
if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
{
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
module_Unneed( p_demux, p_id3 );
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
vlc_meta_t *p_meta = p_demux_meta->p_meta;
if( !p_sys->p_meta )
{
vlc_object_release( p_input );
return VLC_ENOMEM;
p_sys->p_meta = p_meta;
}
if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
else if( p_meta )
{
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
vlc_meta_t *p_meta = p_demux_meta->p_meta;
if( !p_sys->p_meta )
{
p_sys->p_meta = p_meta;
}
else if( p_meta )
{
vlc_meta_Merge( p_sys->p_meta, p_meta );
vlc_meta_Delete( p_meta );
}
p_demux->p_private = NULL;
module_Unneed( p_demux, p_id3 );
int i;
for( i = 0; i < p_demux_meta->i_attachments; i++ )
TAB_APPEND_CAST( (input_attachment_t**),
p_sys->i_attachments, p_sys->attachments,
p_demux_meta->attachments[p_demux_meta->i_attachments] );
TAB_CLEAN( p_demux_meta->i_attachments,
p_demux_meta->attachments );
vlc_meta_Merge( p_sys->p_meta, p_meta );
vlc_meta_Delete( p_meta );
}
free( p_demux->p_private );
int i;
for( i = 0; i < p_demux_meta->i_attachments; i++ )
TAB_APPEND_CAST( (input_attachment_t**),
p_sys->i_attachments, p_sys->attachments,
p_demux_meta->attachments[p_demux_meta->i_attachments] );
TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
}
vlc_object_release( p_input );
free( p_demux->p_private );
}
if( p_sys->i_cover_idx < p_sys->i_attachments )
......@@ -216,6 +206,7 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
var_Destroy( p_demux, "meta-preparsed" );
TAB_CLEAN( p_sys->i_seekpoint, p_sys->seekpoint );
int i;
......
......@@ -189,31 +189,23 @@ static int Open( vlc_object_t * p_this )
}
/* Parse possible id3 header */
input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input )
if( !var_CreateGetBool( p_demux, "meta-preparsed" ) )
{
if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
return VLC_ENOMEM;
if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
{
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
{
vlc_object_release( p_input );
return VLC_ENOMEM;
}
if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
{
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
p_sys->p_meta = p_demux_meta->p_meta;
module_Unneed( p_demux, p_id3 );
int i;
for( i = 0; i < p_demux_meta->i_attachments; i++ )
free( p_demux_meta->attachments[i] );
TAB_CLEAN( p_demux_meta->i_attachments,
p_demux_meta->attachments );
}
free( p_demux->p_private );
module_Unneed( p_demux, p_id3 );
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
p_sys->p_meta = p_demux_meta->p_meta;
int i;
for( i = 0; i < p_demux_meta->i_attachments; i++ )
free( p_demux_meta->attachments[i] );
TAB_CLEAN( p_demux_meta->i_attachments,
p_demux_meta->attachments );
}
vlc_object_release( p_input );
free( p_demux->p_private );
}
if( !p_sys->p_meta )
......@@ -233,6 +225,7 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
var_Destroy( p_demux, "meta-preparsed" );
free( p_sys );
}
......
......@@ -27,7 +27,6 @@
#include <vlc/vlc.h>
#include <vlc_demux.h>
#include <vlc_input.h>
#include "vlc_codec.h"
/*****************************************************************************
......@@ -110,32 +109,23 @@ static int Open( vlc_object_t * p_this )
LOAD_PACKETIZER_OR_FAIL( p_sys->p_packetizer, "mp4 audio" );
/* Parse possible id3 header */
input_thread_t *p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input )
if( !var_CreateGetBool( p_demux, "meta-preparsed" ) )
{
if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
return VLC_ENOMEM;
if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
{
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
{
vlc_object_release( p_input );
return VLC_ENOMEM;
}
if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
{
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
p_sys->meta = p_demux_meta->p_meta;
p_demux->p_private = NULL;
module_Unneed( p_demux, p_id3 );
int i;
for( i = 0; i < p_demux_meta->i_attachments; i++ )
free( p_demux_meta->attachments[i] );
TAB_CLEAN( p_demux_meta->i_attachments,
p_demux_meta->attachments );
}
free( p_demux->p_private );
module_Unneed( p_demux, p_id3 );
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
p_sys->meta = p_demux_meta->p_meta;
int i;
/* attachments not supported in this demuxer */
for( i = 0; i < p_demux_meta->i_attachments; i++ )
free( p_demux_meta->attachments[i] );
TAB_CLEAN( p_demux_meta->i_attachments, p_demux_meta->attachments );
}
vlc_object_release( p_input );
free( p_demux->p_private );
}
return VLC_SUCCESS;
}
......@@ -148,6 +138,9 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
var_Destroy( p_demux, "meta-preparsed" );
if( p_sys->meta ) vlc_meta_Delete( p_sys->meta );
DESTROY_PACKETIZER( p_sys->p_packetizer );
free( p_sys );
......
......@@ -28,6 +28,7 @@
#include <vlc/vlc.h>
#include <vlc_demux.h>
#include <vlc_meta.h>
#include <vlc_codec.h>
#include <vlc_input.h>
......@@ -255,32 +256,22 @@ static int Open( vlc_object_t * p_this )
p_sys->p_block_out = p_block_out;
/* Parse possible id3 header */
input_thread_t *p_input = (input_thread_t *)
vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input )
if( !var_CreateGetBool( p_demux, "meta-preparsed" ) )
{
if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
return VLC_ENOMEM;
if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
{
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
{
vlc_object_release( p_input );
return VLC_ENOMEM;
}
if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
{
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
p_sys->meta = p_demux_meta->p_meta;
p_demux->p_private = NULL;
module_Unneed( p_demux, p_id3 );
p_sys->i_attachments = p_demux_meta->i_attachments;
p_sys->attachments = p_demux_meta->attachments;
}
free( p_demux->p_private );
module_Unneed( p_demux, p_id3 );
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
p_sys->meta = p_demux_meta->p_meta;
p_sys->i_attachments = p_demux_meta->i_attachments;
p_sys->attachments = p_demux_meta->attachments;
}
vlc_object_release( p_input );
free( p_demux->p_private );
}
else printf("SKIP\n");
/* */
p_sys->p_packetizer->fmt_out.b_packetized = VLC_TRUE;
vlc_audio_replay_gain_MergeFromMeta( &p_sys->p_packetizer->fmt_out.audio_replay_gain,
......@@ -355,6 +346,8 @@ static void Close( vlc_object_t * p_this )
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
var_Destroy( p_demux, "meta-preparsed" );
DESTROY_PACKETIZER( p_sys->p_packetizer );
if( p_sys->meta ) vlc_meta_Delete( p_sys->meta );
if( p_sys->p_block_out ) block_Release( p_sys->p_block_out );
......
......@@ -26,8 +26,9 @@
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc_input.h>
#include <vlc_demux.h>
#include <vlc_meta.h>
#include <vlc_input.h>
#include <ogg/ogg.h>
......@@ -104,6 +105,9 @@ struct demux_sys_t
/* bitrate */
int i_bitrate;
/* meta data */
vlc_meta_t *meta;
/* attachments */
int i_attachments;
input_attachment_t **attachments;
......@@ -183,7 +187,6 @@ static void Ogg_ReadAnnodexHeader( vlc_object_t *, logical_stream_t *, ogg_packe
static int Open( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t *)p_this;
input_thread_t *p_input;
demux_sys_t *p_sys;
const uint8_t *p_peek;
......@@ -207,32 +210,21 @@ static int Open( vlc_object_t * p_this )
/* Begnning of stream, tell the demux to look for elementary streams. */
p_sys->i_eos = 0;
p_input = (input_thread_t *)vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input )
if( !var_CreateGetBool( p_demux, "meta-preparsed" ) )
{
if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
return VLC_ENOMEM;
module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 );
if( p_meta )
{
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
{
vlc_object_release( p_input );
return VLC_ENOMEM;
}
module_t *p_meta = module_Need( p_demux, "meta reader", NULL, 0 );
if( p_meta )
{
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
vlc_meta_Merge( input_GetItem(p_input)->p_meta,
p_demux_meta->p_meta );
vlc_meta_Delete( p_demux_meta->p_meta );
module_Unneed( p_demux, p_meta );
p_sys->i_attachments = p_demux_meta->i_attachments;
p_sys->attachments = p_demux_meta->attachments;
}
free( p_demux->p_private );
module_Unneed( p_demux, p_meta );
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
p_sys->meta = p_demux_meta->p_meta;
p_sys->i_attachments = p_demux_meta->i_attachments;
p_sys->attachments = p_demux_meta->attachments;
}
vlc_object_release( p_input );
free( p_demux->p_private );
}
/* Initialize the Ogg physical bitstream parser */
......@@ -254,6 +246,9 @@ static void Close( vlc_object_t *p_this )
Ogg_EndOfStream( p_demux );
var_Destroy( p_demux, "meta-preparsed" );
if( p_sys->meta ) vlc_meta_Delete( p_sys->meta );
int i;
for( i = 0; i < p_sys->i_attachments; i++ )
free( p_sys->attachments[i] );
......@@ -406,9 +401,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
int i;
input_attachment_t ***ppp_attach;
int *pi_int;
vlc_meta_t *p_meta;
switch( i_query )
{
case DEMUX_GET_META:
p_meta = (vlc_meta_t *)va_arg( args, vlc_meta_t* );
vlc_meta_Merge( p_meta, p_sys->meta );
return VLC_SUCCESS;
case DEMUX_GET_TIME:
pi64 = (int64_t*)va_arg( args, int64_t * );
*pi64 = p_sys->i_pcr;
......
......@@ -139,39 +139,6 @@ static int Open( vlc_object_t * p_this )
free( p_seektable );
p_sys->i_start = stream_Tell( p_demux->s );
#if 0
/* Parse possible id3 header */
input_thread_t *p_input = (input_thread_t *)
vlc_object_find( p_demux, VLC_OBJECT_INPUT, FIND_PARENT );
if( p_input )
{
if( !( input_GetItem( p_input )->p_meta->i_status & ITEM_PREPARSED ) )
{
p_demux->p_private = malloc( sizeof( demux_meta_t ) );
if( !p_demux->p_private )
{
vlc_object_release( p_input );
return VLC_ENOMEM;
}
if( ( p_id3 = module_Need( p_demux, "meta reader", NULL, 0 ) ) )
{
demux_meta_t *p_demux_meta = (demux_meta_t *)p_demux->p_private;
p_sys->p_meta = p_demux_meta->p_meta;
p_demux->p_private = NULL;
module_Unneed( p_demux, p_id3 );
int i;
for( i = 0; i < p_demux_meta->i_attachments; i++ )
free( p_demux_meta->attachments[i] );
TAB_CLEAN( p_demux_meta->i_attachments,
p_demux_meta->attachments );
}
free( p_demux->p_private );
}
vlc_object_release( p_input );
}
if( !p_sys->p_meta )
p_sys->p_meta = vlc_meta_New();
#endif
return VLC_SUCCESS;
}
......@@ -252,7 +219,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
return VLC_SUCCESS;
}
return VLC_EGENERIC;
case DEMUX_GET_LENGTH:
pi64 = (int64_t*)va_arg( args, int64_t * );
*pi64 = I64C(1000000) * p_sys->i_totalframes * TTA_FRAMETIME;
......@@ -262,7 +229,7 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
pi64 = (int64_t*)va_arg( args, int64_t * );
*pi64 = I64C(1000000) * p_sys->i_currentframe * TTA_FRAMETIME;
return VLC_SUCCESS;
default:
return VLC_EGENERIC;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment