Initialize cinfo with codec

Signed-off-by: Anshul Maheshwari <er.anshul.maheshwari@gmail.com>
This commit is contained in:
Anshul Maheshwari
2015-07-23 17:45:26 +05:30
parent 08df39c3d4
commit c5dfd52eb9
7 changed files with 48 additions and 31 deletions

View File

@@ -217,6 +217,7 @@ struct lib_cc_decode* init_cc_decode (struct ccx_decoders_common_settings_t *set
return NULL;
ctx->avc_ctx = init_avc();
ctx->codec = setting->codec;
if(setting->codec == CCX_CODEC_ATSC_CC)
{
@@ -238,6 +239,11 @@ struct lib_cc_decode* init_cc_decode (struct ccx_decoders_common_settings_t *set
setting->output_format
);
}
else
{
ctx->context_cc608_field_1 = NULL;
ctx->context_cc608_field_2 = NULL;
}
ctx->private_data = setting->private_data;
ctx->fix_padding = setting->fix_padding;
ctx->write_format = setting->output_format;
@@ -275,27 +281,30 @@ struct lib_cc_decode* init_cc_decode (struct ccx_decoders_common_settings_t *set
void flush_cc_decode(struct lib_cc_decode *ctx, struct cc_subtitle *sub)
{
if (ctx->extract != 2)
if(ctx->codec == CCX_CODEC_ATSC_CC)
{
if (ctx->write_format==CCX_OF_SMPTETT || ctx->write_format==CCX_OF_SAMI ||
ctx->write_format==CCX_OF_SRT || ctx->write_format==CCX_OF_TRANSCRIPT
|| ctx->write_format==CCX_OF_SPUPNG )
if (ctx->extract != 2)
{
flush_608_context(ctx->context_cc608_field_1, sub);
if (ctx->write_format==CCX_OF_SMPTETT || ctx->write_format==CCX_OF_SAMI ||
ctx->write_format==CCX_OF_SRT || ctx->write_format==CCX_OF_TRANSCRIPT
|| ctx->write_format==CCX_OF_SPUPNG )
{
flush_608_context(ctx->context_cc608_field_1, sub);
}
else if(ctx->write_format == CCX_OF_RCWT)
{
// Write last header and data
writercwtdata (ctx, NULL, sub);
}
}
else if(ctx->write_format == CCX_OF_RCWT)
if (ctx->extract != 1)
{
// Write last header and data
writercwtdata (ctx, NULL, sub);
}
}
if (ctx->extract != 1)
{
if (ctx->write_format == CCX_OF_SMPTETT || ctx->write_format == CCX_OF_SAMI ||
ctx->write_format == CCX_OF_SRT || ctx->write_format == CCX_OF_TRANSCRIPT
|| ctx->write_format == CCX_OF_SPUPNG )
{
flush_608_context(ctx->context_cc608_field_2, sub);
if (ctx->write_format == CCX_OF_SMPTETT || ctx->write_format == CCX_OF_SAMI ||
ctx->write_format == CCX_OF_SRT || ctx->write_format == CCX_OF_TRANSCRIPT
|| ctx->write_format == CCX_OF_SPUPNG )
{
flush_608_context(ctx->context_cc608_field_2, sub);
}
}
}

View File

@@ -125,6 +125,7 @@ struct lib_cc_decode
int program_number;
struct list_head list;
struct ccx_common_timing_ctx *timing;
enum ccx_code_type codec;
struct avc_ctx *avc_ctx;

View File

@@ -550,9 +550,10 @@ void delete_datalist(struct demuxer_data *list)
}
}
void process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, struct demuxer_data *data_node)
int process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, struct demuxer_data *data_node)
{
LLONG got; // Means 'consumed' from buffer actually
int ret = 0;
static LLONG last_pts = 0x01FFFFFFFFLL;
struct cc_subtitle *dec_sub = &dec_ctx->dec_sub;
@@ -576,7 +577,9 @@ void process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, st
else if (data_node->bufferdatatype == CCX_TELETEXT)
{
//telxcc_update_gt(dec_ctx->private_data, ctx->demux_ctx->global_timestamp);
tlt_process_pes_packet (dec_ctx->private_data, data_node->buffer, data_node->len, dec_sub);
ret = tlt_process_pes_packet (dec_ctx->private_data, data_node->buffer, data_node->len, dec_sub);
if(ret == CCX_EINVAL)
return ret;
set_encoder_rcwt_fileformat(enc_ctx, 2);
got = data_node->len;
}
@@ -653,6 +656,7 @@ void process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, st
encode_sub(enc_ctx, dec_sub);
dec_sub->got_output = 0;
}
return CCX_OK;
}
void general_loop(struct lib_ccx_ctx *ctx)
{
@@ -724,7 +728,9 @@ void general_loop(struct lib_ccx_ctx *ctx)
dec_ctx = update_decoder_list_cinfo(ctx, cinfo);
if(data_node->pts != CCX_NOPTS)
set_current_pts(dec_ctx->timing, data_node->pts);
process_data(enc_ctx, dec_ctx, data_node);
ret = process_data(enc_ctx, dec_ctx, data_node);
if( ret != CCX_OK)
break;
}
else
{

View File

@@ -167,10 +167,10 @@ void dinit_libraries( struct lib_ccx_ctx **ctx)
if(dec_ctx)
{
flush_cc_decode(dec_ctx, &dec_ctx->dec_sub);
if (&dec_ctx->dec_sub.got_output)
if (dec_ctx->dec_sub.got_output == CCX_TRUE)
{
encode_sub(enc_ctx, &dec_ctx->dec_sub);
dec_ctx->dec_sub.got_output = 0;
dec_ctx->dec_sub.got_output = CCX_FALSE;
}
list_del(&dec_ctx->list);
dinit_cc_decode(&dec_ctx);

View File

@@ -1014,7 +1014,7 @@ int tlt_process_pes_packet(void *codec, uint8_t *buffer, uint16_t size, struct c
if(!ctx)
{
mprint("Teletext: Context cant be NULL, use telxcc_init");
mprint("Teletext: Context cant be NULL, use telxcc_init\n");
return CCX_EINVAL;
}

View File

@@ -11,7 +11,6 @@ int need_capInfo(struct ccx_demuxer *ctx, int program_number)
if(ctx->ts_allprogram == CCX_TRUE)
{
int found_pn = CCX_FALSE;
list_for_each_entry(iter, &ctx->cinfo_tree.pg_stream, pg_stream, struct cap_info)
{
if (iter->program_number == program_number)
@@ -64,6 +63,7 @@ int get_programme_number(struct ccx_demuxer *ctx, int pid)
if(iter->pid == pid)
return iter->program_number;
}
return CCX_UNKNOWN;
}
int get_best_sib_stream(struct cap_info* program)
@@ -180,6 +180,7 @@ int update_capinfo(struct ccx_demuxer *ctx, int pid, enum ccx_stream_type stream
tmp->capbuflen = 0;
tmp->capbufsize = 0;
tmp->ignore = 0;
tmp->codec_private_data = private_data;
return CCX_OK;
}
}

View File

@@ -331,8 +331,8 @@ int parse_PMT (struct ccx_demuxer *ctx, struct ts_payload *payload, unsigned cha
if (ptr == NULL)
break;
update_capinfo(ctx, elementary_PID, ccx_stream_type, CCX_CODEC_TELETEXT, program_number, ptr);
mprint ("VBI/teletext stream ID %u (0x%x) for SID %u (0x%x)\n",
elementary_PID, elementary_PID, program_number, program_number);
//mprint ("VBI/teletext stream ID %u (0x%x) for SID %u (0x%x)\n",
// elementary_PID, elementary_PID, program_number, program_number);
}
}
@@ -344,16 +344,16 @@ int parse_PMT (struct ccx_demuxer *ctx, struct ts_payload *payload, unsigned cha
if (descriptor_tag == 0x45)
{
update_capinfo(ctx, elementary_PID, ccx_stream_type, CCX_CODEC_ATSC_CC, program_number, NULL);
mprint ("VBI stream ID %u (0x%x) for SID %u (0x%x) - teletext is disabled, will be processed as closed captions.\n",
elementary_PID, elementary_PID, program_number, program_number);
//mprint ("VBI stream ID %u (0x%x) for SID %u (0x%x) - teletext is disabled, will be processed as closed captions.\n",
// elementary_PID, elementary_PID, program_number, program_number);
}
}
if (ccx_stream_type==CCX_STREAM_TYPE_VIDEO_H264 || ccx_stream_type==CCX_STREAM_TYPE_VIDEO_MPEG2)
{
update_capinfo(ctx, elementary_PID, ccx_stream_type, CCX_CODEC_ATSC_CC, program_number, NULL);
mprint ("Decode captions from program %d - %s stream [0x%02x] - PID: %u\n",
program_number , desc[ccx_stream_type], ccx_stream_type, elementary_PID);
//mprint ("Decode captions from program %d - %s stream [0x%02x] - PID: %u\n",
// program_number , desc[ccx_stream_type], ccx_stream_type, elementary_PID);
}
if(need_capInfo_for_pid(ctx, elementary_PID) == CCX_TRUE)
@@ -682,7 +682,7 @@ void process_ccx_mpeg_descriptor (unsigned char *data, unsigned length)
break;
if (data[0]>=0x40 && data[0]<=0xFF) // User private
break;
mprint ("Still unsupported MPEG descriptor type=%d (%02X)\n",data[0],data[0]);
//mprint ("Still unsupported MPEG descriptor type=%d (%02X)\n",data[0],data[0]);
break;
}
}