Add Opus support

pull/7/head
Kieran Kunhya 2014-05-10 18:13:55 +02:00
rodzic 28333981bb
commit e8d8d6d008
4 zmienionych plików z 45 dodań i 2 usunięć

Wyświetl plik

@ -201,6 +201,9 @@ typedef struct
int aac_profile;
int aac_channel_map;
/* Opus */
int opus_channel_map;
/* ATSC */
/* DVB */

Wyświetl plik

@ -32,6 +32,7 @@
#define DVB_ADAPTATION_FIELD_DATA_DESCRIPTOR 0x70
#define DVB_EAC3_DESCRIPTOR_TAG 0x7a
#define DVB_AAC_DESCRIPTOR_TAG 0x7c
#define DVB_EXTENSION_DESCRIPTOR_TAG 0x7f
/* PIDs */
#define SDT_PID 0x0011

Wyświetl plik

@ -29,7 +29,7 @@
#include "crc/crc.h"
#include <math.h>
static const int steam_type_table[27][2] =
static const int steam_type_table[28][2] =
{
{ LIBMPEGTS_VIDEO_MPEG2, VIDEO_MPEG2 },
{ LIBMPEGTS_VIDEO_AVC, VIDEO_AVC },
@ -57,6 +57,7 @@ static const int steam_type_table[27][2] =
{ LIBMPEGTS_DVB_VBI, PRIVATE_DATA },
{ LIBMPEGTS_ANCILLARY_RDD11, PRIVATE_DATA },
{ LIBMPEGTS_ANCILLARY_2038, PRIVATE_DATA },
{ LIBMPEGTS_AUDIO_OPUS, PRIVATE_DATA },
{ 0 },
};
@ -186,6 +187,15 @@ static void write_iso_lang_descriptor( bs_t *s, ts_int_stream_t *stream )
bs_write(s, 8, stream->audio_type ); // audio_type
}
/** Misc descriptors **/
static void write_opus_descriptor( bs_t *s, ts_int_stream_t *stream )
{
bs_write( s, 8, DVB_EXTENSION_DESCRIPTOR_TAG ); // descriptor_tag
bs_write( s, 8, 0x2 ); // descriptor_length
bs_write( s, 8, 0x80 ); // descriptor_tag_extension (User defined)
bs_write( s, 8, stream->opus_channel_map ); // channel_config_code
}
/**** PCR functions ****/
static int check_pcr( ts_writer_t *w, ts_int_program_t *program )
{
@ -568,6 +578,11 @@ static int write_pmt( ts_writer_t *w, ts_int_program_t *program )
write_registration_descriptor( &q, PRIVATE_DATA_DESCRIPTOR_TAG, 4, "VANC" );
write_anc_data_descriptor( &q );
}
else if( stream->stream_format == LIBMPEGTS_AUDIO_OPUS )
{
write_registration_descriptor( &q, PRIVATE_DATA_DESCRIPTOR_TAG, 4, "Opus" );
write_opus_descriptor( &q, stream );
}
// TODO other stream_type descriptors
@ -1331,6 +1346,21 @@ int ts_setup_302m_stream( ts_writer_t *w, int pid, int bit_depth, int num_channe
return 0;
}
int ts_setup_opus_stream( ts_writer_t *w, int pid, int channel_map )
{
ts_int_stream_t *stream = find_stream( w, pid );
if( !stream )
{
fprintf( stderr, "Invalid PID\n" );
return -1;
}
stream->opus_channel_map = channel_map;
return 0;
}
int ts_setup_dvb_subtitles( ts_writer_t *w, int pid, int has_dds, int num_subtitles, ts_dvb_sub_t *subtitles )
{
if( w->ts_type == TS_TYPE_BLU_RAY )

Wyświetl plik

@ -69,7 +69,7 @@
#define LIBMPEGTS_DVB_VBI 130
/* Misc */
#define LIBMPEGTS_AUDIO_OPUS 160
/**** Stream IDs ****/
/* SMPTE 302M, AC3, DVB subtitles and Teletext use Private Stream 1 */
@ -412,6 +412,15 @@ int ts_setup_mpeg4_aac_stream( ts_writer_t *w, int pid, int profile_and_level, i
int ts_setup_302m_stream( ts_writer_t *w, int pid, int bit_depth, int num_channels );
/* Opus */
#define LIBMPEGTS_CHANNEL_CONFIG_DUAL_MONO 0x00
#define LIBMPEGTS_CHANNEL_CONFIG_MONO 0x01
#define LIBMPEGTS_CHANNEL_CONFIG_STEREO 0x02
int ts_setup_opus_stream( ts_writer_t *w, int pid, int channel_map );
/**** DVB Specific Information ****/
/* DVB Subtitles */