// pkt->dts += ast->start;
if (ast->sample_size)
pkt->dts /= ast->sample_size;
- av_log(s, AV_LOG_TRACE,
- "dts:%"PRId64" offset:%"PRId64" %d/%d smpl_siz:%d "
- "base:%d st:%d size:%d\n",
- pkt->dts,
- ast->frame_offset,
- ast->scale,
- ast->rate,
- ast->sample_size,
- AV_TIME_BASE,
- avi->stream_index,
- size);
pkt->stream_index = avi->stream_index;
- if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->index_entries) {
AVIndexEntry *e;
int index;
- assert(st->index_entries);
- index = av_index_search_timestamp(st, ast->frame_offset, 0);
+ index = av_index_search_timestamp(st, ast->frame_offset, AVSEEK_FLAG_ANY);
e = &st->index_entries[index];
- if (index >= 0 && e->timestamp == ast->frame_offset)
+ if (index >= 0 && e->timestamp == ast->frame_offset) {
+ if (index == st->nb_index_entries-1) {
+ int key=1;
+ uint32_t state=-1;
+ if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4) {
+ const uint8_t *ptr = pkt->data, *end = ptr + FFMIN(size, 256);
+ while (ptr < end) {
+ ptr = avpriv_find_start_code(ptr, end, &state);
+ if (state == 0x1B6 && ptr < end) {
+ key = !(*ptr & 0xC0);
+ break;
+ }
+ }
+ }
+ if (!key)
+ e->flags &= ~AVINDEX_KEYFRAME;
+ }
if (e->flags & AVINDEX_KEYFRAME)
pkt->flags |= AV_PKT_FLAG_KEY;
+ }
} else {
pkt->flags |= AV_PKT_FLAG_KEY;
}
goto the_end; // maybe truncated file
av_log(s, AV_LOG_TRACE, "movi_end=0x%"PRIx64"\n", avi->movi_end);
for (;;) {
- if (pb->eof_reached)
- break;
tag = avio_rl32(pb);
size = avio_rl32(pb);
+ if (avio_feof(pb))
+ break;
+ next = avio_tell(pb) + size + (size & 1);
- av_log(s, AV_LOG_TRACE, "tag=%c%c%c%c size=0x%x\n",
- tag & 0xff,
- (tag >> 8) & 0xff,
- (tag >> 16) & 0xff,
- (tag >> 24) & 0xff,
- size);
-
if (tag == MKTAG('i', 'd', 'x', '1') &&
avi_read_idx1(s, size) >= 0) {
+ avi->index_loaded=2;
ret = 0;
+ }else if (tag == MKTAG('L', 'I', 'S', 'T')) {
+ uint32_t tag1 = avio_rl32(pb);
+
+ if (tag1 == MKTAG('I', 'N', 'F', 'O'))
+ ff_read_riff_info(s, size - 4);
+ }else if (!ret)
break;
- }
- size += (size & 1);
- if (avio_skip(pb, size) < 0)
+ if (avio_seek(pb, next, SEEK_SET) < 0)
break; // something is wrong here
}
snprintf(key2, sizeof(key2), "%s-%s", key, language);
av_dict_set(&c->fc->metadata, key2, str, 0);
}
+ if (!strcmp(key, "encoder")) {
+ int major, minor, micro;
+ if (sscanf(str, "HandBrake %d.%d.%d", &major, &minor, µ) == 3) {
+ c->handbrake_version = 1000000*major + 1000*minor + micro;
+ }
+ }
}
- av_log(c->fc, AV_LOG_TRACE, "lang \"%3s\" ", language);
- av_log(c->fc, AV_LOG_TRACE, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64"\n",
- key, str, (char*)&atom.type, str_size_alloc, atom.size);
av_freep(&str);
return 0;