|
|
@ -428,9 +428,6 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) |
|
|
|
avio_rl16(pb); //ds_data_size
|
|
|
|
avio_rl16(pb); //ds_data_size
|
|
|
|
avio_r8(pb); //ds_silence_data
|
|
|
|
avio_r8(pb); //ds_silence_data
|
|
|
|
} |
|
|
|
} |
|
|
|
//printf("Descrambling: ps:%d cs:%d ds:%d s:%d sd:%d\n",
|
|
|
|
|
|
|
|
// asf_st->ds_packet_size, asf_st->ds_chunk_size,
|
|
|
|
|
|
|
|
// asf_st->ds_data_size, asf_st->ds_span, asf_st->ds_silence_data);
|
|
|
|
|
|
|
|
if (asf_st->ds_span > 1) { |
|
|
|
if (asf_st->ds_span > 1) { |
|
|
|
if (!asf_st->ds_chunk_size |
|
|
|
if (!asf_st->ds_chunk_size |
|
|
|
|| (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1) |
|
|
|
|| (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1) |
|
|
@ -451,7 +448,6 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) |
|
|
|
st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */ |
|
|
|
st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */ |
|
|
|
tag1 = avio_rl32(pb); |
|
|
|
tag1 = avio_rl32(pb); |
|
|
|
avio_skip(pb, 20); |
|
|
|
avio_skip(pb, 20); |
|
|
|
// av_log(s, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX);
|
|
|
|
|
|
|
|
if (sizeX > 40) { |
|
|
|
if (sizeX > 40) { |
|
|
|
st->codec->extradata_size = sizeX - 40; |
|
|
|
st->codec->extradata_size = sizeX - 40; |
|
|
|
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); |
|
|
|
st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); |
|
|
@ -697,9 +693,7 @@ static int asf_read_header(AVFormatContext *s) |
|
|
|
uint64_t gpos= avio_tell(pb); |
|
|
|
uint64_t gpos= avio_tell(pb); |
|
|
|
ff_get_guid(pb, &g); |
|
|
|
ff_get_guid(pb, &g); |
|
|
|
gsize = avio_rl64(pb); |
|
|
|
gsize = avio_rl64(pb); |
|
|
|
av_dlog(s, "%08"PRIx64": ", gpos); |
|
|
|
|
|
|
|
print_guid(&g); |
|
|
|
print_guid(&g); |
|
|
|
av_dlog(s, " size=0x%"PRIx64"\n", gsize); |
|
|
|
|
|
|
|
if (!ff_guidcmp(&g, &ff_asf_data_header)) { |
|
|
|
if (!ff_guidcmp(&g, &ff_asf_data_header)) { |
|
|
|
asf->data_object_offset = avio_tell(pb); |
|
|
|
asf->data_object_offset = avio_tell(pb); |
|
|
|
// if not streaming, gsize is not unlimited (how?), and there is enough space in the file..
|
|
|
|
// if not streaming, gsize is not unlimited (how?), and there is enough space in the file..
|
|
|
@ -931,9 +925,6 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ |
|
|
|
} |
|
|
|
} |
|
|
|
asf->packet_frag_timestamp = avio_rl32(pb); // timestamp
|
|
|
|
asf->packet_frag_timestamp = avio_rl32(pb); // timestamp
|
|
|
|
if(asf->packet_replic_size >= 8+38+4){ |
|
|
|
if(asf->packet_replic_size >= 8+38+4){ |
|
|
|
// for(i=0; i<asf->packet_replic_size-8; i++)
|
|
|
|
|
|
|
|
// av_log(s, AV_LOG_DEBUG, "%02X ",avio_r8(pb));
|
|
|
|
|
|
|
|
// av_log(s, AV_LOG_DEBUG, "\n");
|
|
|
|
|
|
|
|
avio_skip(pb, 10); |
|
|
|
avio_skip(pb, 10); |
|
|
|
ts0= avio_rl64(pb); |
|
|
|
ts0= avio_rl64(pb); |
|
|
|
avio_skip(pb, 8);; |
|
|
|
avio_skip(pb, 8);; |
|
|
@ -972,14 +963,12 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ |
|
|
|
asf->packet_padsize -= diff; |
|
|
|
asf->packet_padsize -= diff; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//printf("Fragsize %d\n", asf->packet_frag_size);
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (rsize > asf->packet_size_left) { |
|
|
|
if (rsize > asf->packet_size_left) { |
|
|
|
av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n"); |
|
|
|
av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n"); |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
asf->packet_frag_size = asf->packet_size_left - rsize; |
|
|
|
asf->packet_frag_size = asf->packet_size_left - rsize; |
|
|
|
//printf("Using rest %d %d %d\n", asf->packet_frag_size, asf->packet_size_left, rsize);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (asf->packet_replic_size == 1) { |
|
|
|
if (asf->packet_replic_size == 1) { |
|
|
|
asf->packet_multi_size = asf->packet_frag_size; |
|
|
|
asf->packet_multi_size = asf->packet_frag_size; |
|
|
@ -987,7 +976,6 @@ static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb){ |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
asf->packet_size_left -= rsize; |
|
|
|
asf->packet_size_left -= rsize; |
|
|
|
//printf("___objsize____ %d %d rs:%d\n", asf->packet_obj_size, asf->packet_frag_offset, rsize);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
@ -1013,7 +1001,6 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk |
|
|
|
|| asf->packet_segments < 1) { |
|
|
|
|| asf->packet_segments < 1) { |
|
|
|
//asf->packet_size_left <= asf->packet_padsize) {
|
|
|
|
//asf->packet_size_left <= asf->packet_padsize) {
|
|
|
|
int ret = asf->packet_size_left + asf->packet_padsize; |
|
|
|
int ret = asf->packet_size_left + asf->packet_padsize; |
|
|
|
//printf("PacketLeftSize:%d Pad:%d Pos:%"PRId64"\n", asf->packet_size_left, asf->packet_padsize, avio_tell(pb));
|
|
|
|
|
|
|
|
assert(ret>=0); |
|
|
|
assert(ret>=0); |
|
|
|
/* fail safe */ |
|
|
|
/* fail safe */ |
|
|
|
avio_skip(pb, ret); |
|
|
|
avio_skip(pb, ret); |
|
|
@ -1060,7 +1047,6 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
asf->packet_multi_size -= asf->packet_obj_size; |
|
|
|
asf->packet_multi_size -= asf->packet_obj_size; |
|
|
|
//printf("COMPRESS size %d %d %d ms:%d\n", asf->packet_obj_size, asf->packet_frag_timestamp, asf->packet_size_left, asf->packet_multi_size);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if( /*asf->packet_frag_size == asf->packet_obj_size*/ |
|
|
|
if( /*asf->packet_frag_size == asf->packet_obj_size*/ |
|
|
|
asf_st->frag_offset + asf->packet_frag_size <= asf_st->pkt.size |
|
|
|
asf_st->frag_offset + asf->packet_frag_size <= asf_st->pkt.size |
|
|
@ -1170,8 +1156,6 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk |
|
|
|
int row = off / asf_st->ds_span; |
|
|
|
int row = off / asf_st->ds_span; |
|
|
|
int col = off % asf_st->ds_span; |
|
|
|
int col = off % asf_st->ds_span; |
|
|
|
int idx = row + col * asf_st->ds_packet_size / asf_st->ds_chunk_size; |
|
|
|
int idx = row + col * asf_st->ds_packet_size / asf_st->ds_chunk_size; |
|
|
|
//printf("off:%d row:%d col:%d idx:%d\n", off, row, col, idx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert(offset + asf_st->ds_chunk_size <= asf_st->pkt.size); |
|
|
|
assert(offset + asf_st->ds_chunk_size <= asf_st->pkt.size); |
|
|
|
assert(idx+1 <= asf_st->pkt.size / asf_st->ds_chunk_size); |
|
|
|
assert(idx+1 <= asf_st->pkt.size / asf_st->ds_chunk_size); |
|
|
|
memcpy(newdata + offset, |
|
|
|
memcpy(newdata + offset, |
|
|
@ -1186,7 +1170,6 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk |
|
|
|
} |
|
|
|
} |
|
|
|
asf_st->frag_offset = 0; |
|
|
|
asf_st->frag_offset = 0; |
|
|
|
*pkt= asf_st->pkt; |
|
|
|
*pkt= asf_st->pkt; |
|
|
|
//printf("packet %d %d\n", asf_st->pkt.size, asf->packet_frag_size);
|
|
|
|
|
|
|
|
asf_st->pkt.size = 0; |
|
|
|
asf_st->pkt.size = 0; |
|
|
|
asf_st->pkt.data = 0; |
|
|
|
asf_st->pkt.data = 0; |
|
|
|
asf_st->pkt.side_data_elems = 0; |
|
|
|
asf_st->pkt.side_data_elems = 0; |
|
|
@ -1275,7 +1258,6 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, |
|
|
|
*ppos= pos; |
|
|
|
*ppos= pos; |
|
|
|
avio_seek(s->pb, pos, SEEK_SET); |
|
|
|
avio_seek(s->pb, pos, SEEK_SET); |
|
|
|
|
|
|
|
|
|
|
|
//printf("asf_read_pts\n");
|
|
|
|
|
|
|
|
asf_reset_header(s); |
|
|
|
asf_reset_header(s); |
|
|
|
for(;;){ |
|
|
|
for(;;){ |
|
|
|
if (asf_read_packet(s, pkt) < 0){ |
|
|
|
if (asf_read_packet(s, pkt) < 0){ |
|
|
@ -1303,8 +1285,6 @@ static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
*ppos= pos; |
|
|
|
*ppos= pos; |
|
|
|
//printf("found keyframe at %"PRId64" stream %d stamp:%"PRId64"\n", *ppos, stream_index, pts);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return pts; |
|
|
|
return pts; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|