Commit 976d26bb authored by Andreas Frisch's avatar Andreas Frisch

make clipinfo data transparent and provide API function to request clipinfo for a given playitem

parent 8c70c773
......@@ -89,7 +89,7 @@ libbluray_la_SOURCES=libbluray/bluray.h \
util/log_control.h \
util/bits.h \
util/logging.h
libbluray_la_HEADERS= libbluray/bluray.h file/filesystem.h util/log_control.h libbluray/keys.h libbluray/decoders/overlay.h libbluray/bdnav/meta_data.h
libbluray_la_HEADERS= libbluray/bluray.h file/filesystem.h util/log_control.h libbluray/keys.h libbluray/decoders/overlay.h libbluray/bdnav/meta_data.h libbluray/bdnav/clpi_data.h
libbluray_la_LDFLAGS= -version-info $(LIB_VERSION_INFO) $(DLOPEN_LDFLAGS) $(LIBXML2_LIBS)
if USING_BDJAVA
......
/*
* This file is part of libbluray
* Copyright (C) 2009-2010 John Stebbins
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#if !defined(_CLPI_DATA_H_)
#define _CLPI_DATA_H_
#include <stdint.h>
typedef struct
{
uint16_t pcr_pid;
uint32_t spn_stc_start;
uint32_t presentation_start_time;
uint32_t presentation_end_time;
} CLPI_STC_SEQ;
typedef struct
{
uint32_t spn_atc_start;
uint8_t num_stc_seq;
uint8_t offset_stc_id;
CLPI_STC_SEQ *stc_seq;
} CLPI_ATC_SEQ;
typedef struct
{
uint8_t num_atc_seq;
CLPI_ATC_SEQ *atc_seq;
} CLPI_SEQ_INFO;
typedef struct
{
uint8_t validity;
uint8_t format_id[5];
} CLPI_TS_TYPE;
typedef struct
{
uint32_t delta;
uint8_t file_id[6];
uint8_t file_code[5];
} CLPI_ATC_DELTA;
typedef struct
{
uint8_t clip_stream_type;
uint8_t application_type;
uint8_t is_atc_delta;
uint32_t ts_recording_rate;
uint32_t num_source_packets;
CLPI_TS_TYPE ts_type_info;
uint8_t atc_delta_count;
CLPI_ATC_DELTA *atc_delta;
} CLPI_CLIP_INFO;
typedef struct
{
uint16_t pid;
uint8_t coding_type;
uint8_t format;
uint8_t rate;
uint8_t aspect;
uint8_t oc_flag;
uint8_t char_code;
uint8_t lang[4];
} CLPI_PROG_STREAM;
typedef struct
{
uint32_t spn_program_sequence_start;
uint16_t program_map_pid;
uint8_t num_streams;
uint8_t num_groups;
CLPI_PROG_STREAM *streams;
} CLPI_PROG;
typedef struct
{
uint8_t num_prog;
CLPI_PROG *progs;
} CLPI_PROG_INFO;
typedef struct
{
int ref_ep_fine_id;
int pts_ep;
uint32_t spn_ep;
} CLPI_EP_COARSE;
typedef struct
{
uint8_t is_angle_change_point;
uint8_t i_end_position_offset;
int pts_ep;
int spn_ep;
} CLPI_EP_FINE;
typedef struct
{
uint16_t pid;
uint8_t ep_stream_type;
int num_ep_coarse;
int num_ep_fine;
uint32_t ep_map_stream_start_addr;
CLPI_EP_COARSE *coarse;
CLPI_EP_FINE *fine;
} CLPI_EP_MAP_ENTRY;
typedef struct
{
uint8_t type;
// ep_map
uint8_t num_stream_pid;
CLPI_EP_MAP_ENTRY *entry;
} CLPI_CPI;
typedef struct clpi_cl {
uint32_t type_indicator;
uint32_t type_indicator2;
uint32_t sequence_info_start_addr;
uint32_t program_info_start_addr;
uint32_t cpi_start_addr;
uint32_t clip_mark_start_addr;
uint32_t ext_data_start_addr;
CLPI_CLIP_INFO clip;
CLPI_SEQ_INFO sequence;
CLPI_PROG_INFO program;
CLPI_CPI cpi;
// skip clip mark & extension data
} CLPI_CL;
#endif // _CLPI_DATA_H_
......@@ -23,6 +23,7 @@
#include "clpi_parse.h"
#include <stdlib.h>
#include <string.h>
#define CLPI_SIG1 ('H' << 24 | 'D' << 16 | 'M' << 8 | 'V')
#define CLPI_SIG2A ('0' << 24 | '2' << 16 | '0' << 8 | '0')
......@@ -625,3 +626,85 @@ clpi_parse(char *path, int verbose)
return cl;
}
CLPI_CL*
clpi_copy(CLPI_CL* dest_cl, CLPI_CL* src_cl)
{
int ii, jj;
if (dest_cl && src_cl) {
dest_cl->clip.clip_stream_type = src_cl->clip.clip_stream_type;
dest_cl->clip.application_type = src_cl->clip.application_type;
dest_cl->clip.is_atc_delta = src_cl->clip.is_atc_delta;
dest_cl->clip.atc_delta_count = src_cl->clip.atc_delta_count;
dest_cl->clip.ts_recording_rate = src_cl->clip.ts_recording_rate;
dest_cl->clip.num_source_packets = src_cl->clip.num_source_packets;
dest_cl->clip.ts_type_info.validity = src_cl->clip.ts_type_info.validity;
memcpy(dest_cl->clip.ts_type_info.format_id, src_cl->clip.ts_type_info.format_id, 5);
dest_cl->clip.atc_delta = malloc(src_cl->clip.atc_delta_count * sizeof(CLPI_ATC_DELTA));
for (ii = 0; ii < src_cl->clip.atc_delta_count; ii++) {
dest_cl->clip.atc_delta[ii].delta = src_cl->clip.atc_delta[ii].delta;
memcpy(dest_cl->clip.atc_delta[ii].file_id, src_cl->clip.atc_delta[ii].file_id, 6);
memcpy(dest_cl->clip.atc_delta[ii].file_code, src_cl->clip.atc_delta[ii].file_code, 5);
}
dest_cl->sequence.num_atc_seq = src_cl->sequence.num_atc_seq;
dest_cl->sequence.atc_seq = malloc(src_cl->sequence.num_atc_seq * sizeof(CLPI_ATC_SEQ));
for (ii = 0; ii < src_cl->sequence.num_atc_seq; ii++) {
dest_cl->sequence.atc_seq[ii].spn_atc_start = src_cl->sequence.atc_seq[ii].spn_atc_start;
dest_cl->sequence.atc_seq[ii].offset_stc_id = src_cl->sequence.atc_seq[ii].offset_stc_id;
dest_cl->sequence.atc_seq[ii].num_stc_seq = src_cl->sequence.atc_seq[ii].num_stc_seq;
dest_cl->sequence.atc_seq[ii].stc_seq = malloc(src_cl->sequence.atc_seq[ii].num_stc_seq * sizeof(CLPI_STC_SEQ));
for (jj = 0; jj < src_cl->sequence.atc_seq[ii].num_stc_seq; jj++) {
dest_cl->sequence.atc_seq[ii].stc_seq[jj].spn_stc_start = src_cl->sequence.atc_seq[ii].stc_seq[jj].spn_stc_start;
dest_cl->sequence.atc_seq[ii].stc_seq[jj].pcr_pid = src_cl->sequence.atc_seq[ii].stc_seq[jj].pcr_pid;
dest_cl->sequence.atc_seq[ii].stc_seq[jj].presentation_start_time = src_cl->sequence.atc_seq[ii].stc_seq[jj].presentation_start_time;
dest_cl->sequence.atc_seq[ii].stc_seq[jj].presentation_end_time = src_cl->sequence.atc_seq[ii].stc_seq[jj].presentation_end_time;
}
}
dest_cl->program.num_prog = src_cl->program.num_prog;
dest_cl->program.progs = malloc(src_cl->program.num_prog * sizeof(CLPI_PROG));
for (ii = 0; ii < src_cl->program.num_prog; ii++) {
dest_cl->program.progs[ii].spn_program_sequence_start = src_cl->program.progs[ii].spn_program_sequence_start;
dest_cl->program.progs[ii].program_map_pid = src_cl->program.progs[ii].program_map_pid;
dest_cl->program.progs[ii].num_streams = src_cl->program.progs[ii].num_streams;
dest_cl->program.progs[ii].num_groups = src_cl->program.progs[ii].num_groups;
dest_cl->program.progs[ii].streams = malloc(src_cl->program.progs[ii].num_streams * sizeof(CLPI_PROG_STREAM));
for (jj = 0; jj < src_cl->program.progs[ii].num_streams; jj++) {
dest_cl->program.progs[ii].streams[jj].coding_type = src_cl->program.progs[ii].streams[jj].coding_type;
dest_cl->program.progs[ii].streams[jj].pid = src_cl->program.progs[ii].streams[jj].pid;
dest_cl->program.progs[ii].streams[jj].format = src_cl->program.progs[ii].streams[jj].format;
dest_cl->program.progs[ii].streams[jj].rate = src_cl->program.progs[ii].streams[jj].rate;
dest_cl->program.progs[ii].streams[jj].aspect = src_cl->program.progs[ii].streams[jj].aspect;
dest_cl->program.progs[ii].streams[jj].oc_flag = src_cl->program.progs[ii].streams[jj].oc_flag;
dest_cl->program.progs[ii].streams[jj].char_code = src_cl->program.progs[ii].streams[jj].char_code;
memcpy(dest_cl->program.progs[ii].streams[jj].lang,src_cl->program.progs[ii].streams[jj].lang,4);
}
}
dest_cl->cpi.num_stream_pid = src_cl->cpi.num_stream_pid;
dest_cl->cpi.entry = malloc(src_cl->cpi.num_stream_pid * sizeof(CLPI_EP_MAP_ENTRY));
for (ii = 0; ii < dest_cl->cpi.num_stream_pid; ii++) {
dest_cl->cpi.entry[ii].pid = src_cl->cpi.entry[ii].pid;
dest_cl->cpi.entry[ii].ep_stream_type = src_cl->cpi.entry[ii].ep_stream_type;
dest_cl->cpi.entry[ii].num_ep_coarse = src_cl->cpi.entry[ii].num_ep_coarse;
dest_cl->cpi.entry[ii].num_ep_fine = src_cl->cpi.entry[ii].num_ep_fine;
dest_cl->cpi.entry[ii].ep_map_stream_start_addr = src_cl->cpi.entry[ii].ep_map_stream_start_addr;
dest_cl->cpi.entry[ii].coarse = malloc(src_cl->cpi.entry[ii].num_ep_coarse * sizeof(CLPI_EP_COARSE));
for (jj = 0; jj < src_cl->cpi.entry[ii].num_ep_coarse; jj++) {
dest_cl->cpi.entry[ii].coarse[jj].ref_ep_fine_id = src_cl->cpi.entry[ii].coarse[jj].ref_ep_fine_id;
dest_cl->cpi.entry[ii].coarse[jj].pts_ep = src_cl->cpi.entry[ii].coarse[jj].pts_ep;
dest_cl->cpi.entry[ii].coarse[jj].spn_ep = src_cl->cpi.entry[ii].coarse[jj].spn_ep;
}
dest_cl->cpi.entry[ii].fine = malloc(src_cl->cpi.entry[ii].num_ep_fine * sizeof(CLPI_EP_FINE));
for (jj = 0; jj < src_cl->cpi.entry[ii].num_ep_fine; jj++) {
dest_cl->cpi.entry[ii].fine[jj].is_angle_change_point = src_cl->cpi.entry[ii].fine[jj].is_angle_change_point;
dest_cl->cpi.entry[ii].fine[jj].i_end_position_offset = src_cl->cpi.entry[ii].fine[jj].i_end_position_offset;
dest_cl->cpi.entry[ii].fine[jj].pts_ep = src_cl->cpi.entry[ii].fine[jj].pts_ep;
dest_cl->cpi.entry[ii].fine[jj].spn_ep = src_cl->cpi.entry[ii].fine[jj].spn_ep;
}
}
return dest_cl;
}
clpi_free(dest_cl);
return NULL;
}
......@@ -20,137 +20,15 @@
#if !defined(_CLPI_PARSE_H_)
#define _CLPI_PARSE_H_
#include <util/attributes.h>
#include "clpi_data.h"
#include "util/attributes.h"
#include <stdint.h>
typedef struct
{
uint16_t pcr_pid;
uint32_t spn_stc_start;
uint32_t presentation_start_time;
uint32_t presentation_end_time;
} CLPI_STC_SEQ;
typedef struct
{
uint32_t spn_atc_start;
uint8_t num_stc_seq;
uint8_t offset_stc_id;
CLPI_STC_SEQ *stc_seq;
} CLPI_ATC_SEQ;
typedef struct
{
uint8_t num_atc_seq;
CLPI_ATC_SEQ *atc_seq;
} CLPI_SEQ_INFO;
typedef struct
{
uint8_t validity;
uint8_t format_id[5];
} CLPI_TS_TYPE;
typedef struct
{
uint32_t delta;
uint8_t file_id[6];
uint8_t file_code[5];
} CLPI_ATC_DELTA;
typedef struct
{
uint8_t clip_stream_type;
uint8_t application_type;
uint8_t is_atc_delta;
uint32_t ts_recording_rate;
uint32_t num_source_packets;
CLPI_TS_TYPE ts_type_info;
uint8_t atc_delta_count;
CLPI_ATC_DELTA *atc_delta;
} CLPI_CLIP_INFO;
typedef struct
{
uint16_t pid;
uint8_t coding_type;
uint8_t format;
uint8_t rate;
uint8_t aspect;
uint8_t oc_flag;
uint8_t char_code;
uint8_t lang[4];
} CLPI_PROG_STREAM;
typedef struct
{
uint32_t spn_program_sequence_start;
uint16_t program_map_pid;
uint8_t num_streams;
uint8_t num_groups;
CLPI_PROG_STREAM *streams;
} CLPI_PROG;
typedef struct
{
uint8_t num_prog;
CLPI_PROG *progs;
} CLPI_PROG_INFO;
typedef struct
{
int ref_ep_fine_id;
int pts_ep;
uint32_t spn_ep;
} CLPI_EP_COARSE;
typedef struct
{
uint8_t is_angle_change_point;
uint8_t i_end_position_offset;
int pts_ep;
int spn_ep;
} CLPI_EP_FINE;
typedef struct
{
uint16_t pid;
uint8_t ep_stream_type;
int num_ep_coarse;
int num_ep_fine;
uint32_t ep_map_stream_start_addr;
CLPI_EP_COARSE *coarse;
CLPI_EP_FINE *fine;
} CLPI_EP_MAP_ENTRY;
typedef struct
{
uint8_t type;
// ep_map
uint8_t num_stream_pid;
CLPI_EP_MAP_ENTRY *entry;
} CLPI_CPI;
typedef struct
{
uint32_t type_indicator;
uint32_t type_indicator2;
uint32_t sequence_info_start_addr;
uint32_t program_info_start_addr;
uint32_t cpi_start_addr;
uint32_t clip_mark_start_addr;
uint32_t ext_data_start_addr;
CLPI_CLIP_INFO clip;
CLPI_SEQ_INFO sequence;
CLPI_PROG_INFO program;
CLPI_CPI cpi;
// skip clip mark & extension data
} CLPI_CL;
BD_PRIVATE uint32_t clpi_lookup_spn(CLPI_CL *cl, uint32_t timestamp, int before, uint8_t stc_id);
BD_PRIVATE uint32_t clpi_access_point(CLPI_CL *cl, uint32_t pkt, int next, int angle_change, uint32_t *time);
BD_PRIVATE CLPI_CL* clpi_parse(char *path, int verbose);
BD_PRIVATE CLPI_CL* clpi_copy(CLPI_CL* dest_cl, CLPI_CL* src_cl);
BD_PRIVATE void clpi_free(CLPI_CL *cl);
#endif // _CLPI_PARSE_H_
......@@ -31,6 +31,7 @@
#include "bdnav/navigation.h"
#include "bdnav/index_parse.h"
#include "bdnav/meta_parse.h"
#include "bdnav/clpi_parse.h"
#include "hdmv/hdmv_vm.h"
#include "decoders/graphics_controller.h"
#include "file/file.h"
......@@ -2095,3 +2096,20 @@ struct meta_dl *bd_get_meta(BLURAY *bd)
return meta_get(bd->meta, NULL);
}
}
struct clpi_cl *bd_get_clpi(BLURAY *bd, unsigned clip_ref)
{
NAV_CLIP *clip;
if (bd->title && clip_ref < bd->title->clip_list.count) {
clip = &bd->title->clip_list.clip[clip_ref];
CLPI_CL *cl = (CLPI_CL*) calloc(1, sizeof(CLPI_CL));
return clpi_copy(cl, clip->cl);
}
return NULL;
}
void bd_free_clpi(struct clpi_cl *cl)
{
clpi_free(cl);
}
......@@ -609,4 +609,24 @@ struct meta_dl;
*/
struct meta_dl *bd_get_meta(BLURAY *bd);
struct clpi_cl;
/**
*
* Get copy of clip information for requested playitem.
*
* @param bd BLURAY objects
* @param clip_ref requested playitem number
* @return pointer to allocated CLPI_CL object on success, NULL on error
*/
struct clpi_cl *bd_get_clpi(BLURAY *bd, unsigned clip_ref);
/**
*
* Free CLPI_CL object
*
* @param cl CLPI_CL objects
*/
void bd_free_clpi(struct clpi_cl *cl);
#endif /* BLURAY_H_ */
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