mirror of
https://github.com/CCExtractor/ccextractor.git
synced 2026-02-12 21:22:41 +00:00
Init DVD sub decoder
This commit is contained in:
@@ -219,6 +219,7 @@ enum ccx_bufferdata_type
|
||||
CCX_ISDB_SUBTITLE = 8,
|
||||
/* BUffer where cc data contain 3 byte cc_valid ccdata 1 ccdata 2 */
|
||||
CCX_RAW_TYPE = 9,
|
||||
CCX_DVD_SUBTITLE =10,
|
||||
};
|
||||
|
||||
enum ccx_frame_type
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef CCX_CCEXTRACTOR_COMPILE_H
|
||||
#define CCX_CCEXTRACTOR_COMPILE_H
|
||||
#define GIT_COMMIT "30e2c7117caebedb8243bb20cace378c83f6fdd7"
|
||||
#define GIT_COMMIT "4cafcc053e144c86037bb96cd5f30051ac42d46c"
|
||||
#define COMPILE_DATE "2016-06-16"
|
||||
#endif
|
||||
|
||||
37
src/lib_ccx/dvd_subtitle_decoder.c
Normal file
37
src/lib_ccx/dvd_subtitle_decoder.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dvd_subtitle_decoder.h"
|
||||
#include "ccx_common_common.h"
|
||||
|
||||
|
||||
struct dvd_cc_data
|
||||
{
|
||||
unsigned char *buffer; // Buffer to store packet data
|
||||
int pos; //position in the buffer
|
||||
uint16_t size_spu; //total size of spu packet
|
||||
uint16_t size_data; //size of data in the packet, offset to control packet
|
||||
};
|
||||
|
||||
|
||||
int process_spu(unsigned char *buff, int length)
|
||||
{
|
||||
struct dvd_cc_data *data;
|
||||
|
||||
data->buffer = buff;
|
||||
data->size_spu = (data->buffer[0] << 8) | data->buffer[1];
|
||||
if(data->size_spu != length)
|
||||
{
|
||||
//TODO: Might be data spread over multiple packets, check for it
|
||||
dbg_print(CCX_DMT_VERBOSE, "SPU size mismatch");
|
||||
return -1;
|
||||
}
|
||||
|
||||
data->size_data = (data->buffer[2] << 8) | data->buffer[3];
|
||||
if(data->size_data > data->size_spu)
|
||||
{
|
||||
dbg_print(CCX_DMT_VERBOSE, "Invalid SPU Packet");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
6
src/lib_ccx/dvd_subtitle_decoder.h
Normal file
6
src/lib_ccx/dvd_subtitle_decoder.h
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* @param buffer buffer containing the spu packet data
|
||||
* @param length Length of the data buffer received
|
||||
* @return -1 on error
|
||||
*/
|
||||
int process_spu( unsigned char *buffer, int length);
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "ccx_decoders_isdb.h"
|
||||
#include "ffmpeg_intgr.h"
|
||||
#include "ccx_gxf.h"
|
||||
#include "dvd_subtitle_decoder.h"
|
||||
|
||||
unsigned int rollover_bits = 0; // The PTS rolls over every 26 hours and that can happen in the middle of a stream.
|
||||
int end_of_file=0; // End of file?
|
||||
@@ -157,6 +158,7 @@ int ps_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data ** ppdata)
|
||||
result=1;
|
||||
continue;
|
||||
}
|
||||
//PES Header
|
||||
//Private Stream 1 (non MPEG audio , subpictures)
|
||||
else if (nextheader[3] == 0xBD)
|
||||
{
|
||||
@@ -192,6 +194,7 @@ int ps_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data ** ppdata)
|
||||
if( nextheader[7] >= 0x20 && nextheader[7] < 0x40)
|
||||
{
|
||||
dbg_print(CCX_DMT_VERBOSE, "Subtitle found Stream id:%02x\n", nextheader[7]);
|
||||
dbg_print(CCX_DMT_VERBOSE, "data->len: %d\n", data->len);
|
||||
result = buffered_read(ctx->demux_ctx, data->buffer + data->len, datalen);
|
||||
ctx->demux_ctx->past += datalen;
|
||||
if(result != datalen)
|
||||
@@ -203,16 +206,20 @@ int ps_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data ** ppdata)
|
||||
{
|
||||
payload_read+=(int) result;
|
||||
}
|
||||
data->len+=result;
|
||||
//FIXME: Temporary bypass
|
||||
data->bufferdatatype = CCX_DVD_SUBTITLE;
|
||||
|
||||
data->len+=result;
|
||||
dbg_print(CCX_DMT_VERBOSE, "data->len: %d\n", data->len);
|
||||
enough = 1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
data->bufferdatatype = CCX_PES;
|
||||
//Non Subtitle packet
|
||||
buffered_skip(ctx->demux_ctx, datalen);
|
||||
ctx->demux_ctx->past += (packetlength-4- nextheader[6]);
|
||||
ctx->demux_ctx->past += datalen;
|
||||
// fake a result value as something was skipped
|
||||
result=1;
|
||||
|
||||
@@ -244,6 +251,7 @@ int ps_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data ** ppdata)
|
||||
mprint("Do not skip over, search for next.\n");
|
||||
headerlen = 2;
|
||||
}
|
||||
data->bufferdatatype = CCX_PES;
|
||||
|
||||
// Skip over it
|
||||
buffered_skip (ctx->demux_ctx, (int) headerlen);
|
||||
@@ -284,6 +292,8 @@ int ps_getmoredata(struct lib_ccx_ctx *ctx, struct demuxer_data ** ppdata)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
data->bufferdatatype = CCX_PES;
|
||||
|
||||
result = buffered_read (ctx->demux_ctx, data->buffer+data->len, want);
|
||||
ctx->demux_ctx->past=ctx->demux_ctx->past+result;
|
||||
@@ -642,6 +652,10 @@ int process_data(struct encoder_ctx *enc_ctx, struct lib_cc_decode *dec_ctx, str
|
||||
dec_ctx->in_bufferdatatype = CCX_PES;
|
||||
got = process_m2v (dec_ctx, data_node->buffer, data_node->len, dec_sub);
|
||||
}
|
||||
else if (data_node->bufferdatatype = CCX_DVD_SUBTITLE)
|
||||
{
|
||||
got = process_spu (data_node->buffer, data_node->len);
|
||||
}
|
||||
else if (data_node->bufferdatatype == CCX_TELETEXT)
|
||||
{
|
||||
//telxcc_update_gt(dec_ctx->private_data, ctx->demux_ctx->global_timestamp);
|
||||
@@ -831,6 +845,7 @@ void general_loop(struct lib_ccx_ctx *ctx)
|
||||
position_sanity_check(ctx->demux_ctx->infd);
|
||||
if(!ctx->multiprogram)
|
||||
{
|
||||
printf("not multiprogram\n");
|
||||
struct cap_info* cinfo = NULL;
|
||||
struct encoder_ctx *enc_ctx = NULL;
|
||||
int pid = get_best_stream(ctx->demux_ctx);
|
||||
@@ -879,7 +894,7 @@ void general_loop(struct lib_ccx_ctx *ctx)
|
||||
}
|
||||
isdb_set_global_time(dec_ctx, tstamp);
|
||||
}
|
||||
|
||||
printf("%d\n", data_node->bufferdatatype);
|
||||
ret = process_data(enc_ctx, dec_ctx, data_node);
|
||||
if( ret != CCX_OK)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user