Merge branch 'pr/n35_anshul1912'

This commit is contained in:
cfsmp3 2014-05-26 16:20:29 +02:00
commit e68ba47b13
9 changed files with 1539 additions and 1193 deletions

View File

@ -205,6 +205,7 @@ spupng_write_ccbuffer(struct spupng_t *sp, struct eia608_screen* data,
int row;
int empty_buf = 1;
char str[256] = "";
for (row = 0; row < 15; row++)
{
if (data->row_used[row])
@ -233,19 +234,7 @@ spupng_write_ccbuffer(struct spupng_t *sp, struct eia608_screen* data,
sp->pngfile, strerror(errno));
}
fclose(sp->fppng);
fprintf(sp->fpxml, "<spu start=\"%.3f\"", ((double)ms_start) / 1000);
dbg_print(CCX_DMT_608, "<spu start=\"%.3f\"", ((double)ms_start) / 1000);
fprintf(sp->fpxml, " end=\"%.3f\"", ((double)ms_end) / 1000);
dbg_print(CCX_DMT_608, " end=\"%.3f\"", ((double)ms_end) / 1000);
fprintf(sp->fpxml, " image=\"%s\"", sp->pngfile);
dbg_print(CCX_DMT_608, " image=\"%s\"", sp->pngfile);
fprintf(sp->fpxml, " xoffset=\"%d\"", sp->xOffset);
dbg_print(CCX_DMT_608, " xoffset=\"%d\"", sp->xOffset);
fprintf(sp->fpxml, " yoffset=\"%d\"", sp->yOffset);
dbg_print(CCX_DMT_608, " yoffset=\"%d\"", sp->yOffset);
fprintf(sp->fpxml, ">\n<!--\n");
dbg_print(CCX_DMT_608, ">\n<!--\n");
write_sputag(sp,ms_start,ms_end);
for (row = 0; row < ROWS; row++)
{
if (data->row_used[row])
@ -270,15 +259,12 @@ spupng_write_ccbuffer(struct spupng_t *sp, struct eia608_screen* data,
break;
}
}
fprintf(sp->fpxml, "%s\n", subline);
dbg_print(CCX_DMT_608, "%s\n", subline);
strncat(str,(const char*)subline,256);
strncat(str,"\n",256);
}
}
fprintf(sp->fpxml, "--></spu>\n");
dbg_print(CCX_DMT_608, "--></spu>\n");
fflush(sp->fpxml);
write_spucomment(sp,str);
return 1;
}
int write_cc_buffer_as_spupng(struct eia608_screen *data,struct s_context_cc608 *context)

View File

@ -256,4 +256,7 @@ enum cxx_code_type
#define CCX_TXT_IN_USE 2 // Positive autodetected, or forced, etc
#define CCX_OF_TYPE_TEXT 1
#define CCX_OF_TYPE_IMAGE 2
#endif

File diff suppressed because it is too large Load Diff

View File

@ -18,6 +18,7 @@
#define MAX_LANGUAGE_PER_DESC 5
#include "ccextractor.h"
#ifdef __cplusplus
extern "C"
{
@ -35,7 +36,6 @@ struct dvb_config
unsigned short ancillary_id[MAX_LANGUAGE_PER_DESC];
};
/**
* @param composition_id composition-page_id found in Subtitle descriptors
* associated with subtitle stream in the PMT
@ -47,7 +47,7 @@ struct dvb_config
* @return DVB context kept as void* for abstraction
*
*/
void* dvbsub_init_decoder(int composition_id,int ancillary_id);
void* dvbsub_init_decoder(int composition_id, int ancillary_id);
int dvbsub_close_decoder(void *dvb_ctx);
@ -61,9 +61,8 @@ int dvbsub_close_decoder(void *dvb_ctx);
*
* @return -1 on error
*/
int dvbsub_decode(void *dvb_ctx,
void *data, int *data_size,
const unsigned char *buf,int buf_size);
int dvbsub_decode(void *dvb_ctx, void *data, int *data_size,
const unsigned char *buf, int buf_size);
/**
* @func parse_dvb_description
*
@ -74,8 +73,19 @@ int dvbsub_decode(void *dvb_ctx,
* @return return -1 if invalid data found other wise 0 if everything goes well
* errno is set is to EINVAL if invalid data is found
*/
int parse_dvb_description (struct dvb_config* cfg,unsigned char*data,unsigned int len);
int parse_dvb_description(struct dvb_config* cfg, unsigned char*data,
unsigned int len);
/*
* @func dvbsub_set_write the output structure in dvb
* set ccx_s_write structure in dvb_ctx
*
* @param dvb_ctx context of dvb which was returned by dvbsub_init_decoder
*
* @param out output context returned by init_write
*
*/
void dvbsub_set_write(void *dvb_ctx, struct ccx_s_write *out);
#ifdef __cplusplus
}
#endif

View File

@ -292,3 +292,38 @@ void draw_char_indexed(uint8_t * canvas, int rowstride, uint8_t * pen,
unicode_ccfont2(unicode, italic),
underline * (3 << 24) /* cell row 24, 25 */);
}
void write_sputag(struct spupng_t *sp,LLONG ms_start,LLONG ms_end)
{
fprintf(sp->fpxml, "<spu start=\"%.3f\"", ((double)ms_start) / 1000);
fprintf(sp->fpxml, " end=\"%.3f\"", ((double)ms_end) / 1000);
fprintf(sp->fpxml, " image=\"%s\"", sp->pngfile);
fprintf(sp->fpxml, " xoffset=\"%d\"", sp->xOffset);
fprintf(sp->fpxml, " yoffset=\"%d\"", sp->yOffset);
fprintf(sp->fpxml, ">\n");
fprintf(sp->fpxml, "</spu>\n");
}
void write_spucomment(struct spupng_t *sp,const char *str)
{
fprintf(sp->fpxml, "<!--\n");
fprintf(sp->fpxml, "%s\n", str);
fprintf(sp->fpxml, "-->\n");
}
int get_spupng_subtype(void)
{
return (1 << CCX_OF_TYPE_TEXT)|(1<<CCX_OF_TYPE_IMAGE);
}
char* get_spupng_filename(void *ctx)
{
struct spupng_t *sp = (struct spupng_t *)ctx;
sprintf(sp->pngfile, "%s/sub%04d.png", sp->dirname, sp->fileIndex);
return sp->pngfile;
}
void inc_spupng_fileindex(void *ctx)
{
struct spupng_t *sp = (struct spupng_t *)ctx;
sp->fileIndex++;
}

View File

@ -27,4 +27,8 @@ void write_spumux_header(struct ccx_s_write *out);
void write_spumux_footer(struct ccx_s_write *out);
void draw_char_indexed(uint8_t * canvas, int rowstride, uint8_t * pen,
int unicode, int italic, int underline);
void write_sputag(struct spupng_t *sp,LLONG ms_start,LLONG ms_end);
void write_spucomment(struct spupng_t *sp,const char *str);
char* get_spupng_filename(void *ctx);
void inc_spupng_fileindex(void *ctx);
#endif

View File

@ -171,6 +171,40 @@ int detect_myth( void )
return 0;
}
int read_pts_pes(unsigned char*header, int len)
{
unsigned int peslen = 0;
LLONG bits_9;
unsigned int bits_10;
unsigned int bits_11;
unsigned int bits_12;
unsigned int bits_13;
//function used only to set start time
if(pts_set)
return -1;
//it might not be pes packet
if (!(header[0] == 0 && header[1] == 0 && header[2] == 1))
return -1;
peslen = header[4] << 8 | header[5];
if (header[7] & 0x80)
{
bits_9 = ((LLONG) header[9] & 0x0E) << 29; // PTS 32..30 - Must be LLONG to prevent overflow
bits_10 = header[10] << 22; // PTS 29..22
bits_11 = (header[11] & 0xFE) << 14; // PTS 21..15
bits_12 = header[12] << 7; // PTS 14-7
bits_13 = header[13] >> 1; // PTS 6-0
}
else
return -1;
current_pts = bits_9 | bits_10 | bits_11 | bits_12 | bits_13;
pts_set = 1;
return 0;
}
/* Read and evaluate the current video PES header. The function returns
* the length of the payload if successful, otherwise -1 is returned

View File

@ -366,6 +366,15 @@ long ts_readstream(void)
haup_capbuflen = haup_newcapbuflen;
}
/*
* if dvb subtitle is selected then start time taken from first PTS
* of any stream
*/
if ( cap_stream_type == CCX_STREAM_TYPE_PRIVATE_MPEG2 && cxx_dvb_context && !pts_set)
{
if(read_pts_pes(payload.start,payload.length) == 0)
set_fts();
}
// Check for PID with captions. Note that in Hauppauge mode we also process the video stream because
// we need the timing from its PES header, which isn't included in Hauppauge's packets

View File

@ -210,13 +210,21 @@ int parse_PMT (int pos)
ccx_options.ts_cappid = newcappid = elementary_PID;
cap_stream_type=CCX_STREAM_TYPE_UNKNOWNSTREAM;
}
if(IS_FEASIBLE(ccx_options.codec,ccx_options.nocodec,CCX_CODEC_DVB) && !ccx_options.ts_cappid && ccx_stream_type == CCX_STREAM_TYPE_PRIVATE_MPEG2)
if(IS_FEASIBLE(ccx_options.codec,ccx_options.nocodec,CCX_CODEC_DVB) &&
!ccx_options.ts_cappid &&
ccx_stream_type == CCX_STREAM_TYPE_PRIVATE_MPEG2 &&
ES_info_length )
{
unsigned char *es_info = payload_start + i + 5;
for (desc_len = 0;(payload_start + i + 5 + ES_info_length) - es_info ;es_info += desc_len)
{
enum ccx_mpeg_descriptor descriptor_tag = (enum ccx_mpeg_descriptor)(*es_info++);
desc_len = (*es_info++);
if(ccx_options.write_format != CCX_OF_SPUPNG )
{
mprint ("DVB subtitle only support spupng type as output\n");
continue;
}
if(CCX_MPEG_DSC_DVB_SUBTITLE == descriptor_tag)
{
struct dvb_config cnf;
@ -227,6 +235,7 @@ int parse_PMT (int pos)
cxx_dvb_context = dvbsub_init_decoder(cnf.composition_id[0],cnf.ancillary_id[0]);
if (cxx_dvb_context == NULL)
break;
dvbsub_set_write(cxx_dvb_context,&wbout1);
ccx_options.ts_cappid = newcappid = elementary_PID;
cap_stream_type = newcap_stream_type = ccx_stream_type;
}