# HG changeset patch # User michael # Date 1083880358 0 # Node ID 0f5aae2cd43f61b0da5901e225f3c9d2cffd9632 # Parent c13fd248e2220dbb044c9be3be9c05acfff2201e vbr audio fix diff -r c13fd248e222 -r 0f5aae2cd43f avidec.c --- a/avidec.c Sun May 02 01:03:55 2004 +0000 +++ b/avidec.c Thu May 06 21:52:38 2004 +0000 @@ -38,6 +38,7 @@ int scale; int rate; int sample_size; /* audio only data */ + int start; int new_frame_offset; /* temporary storage (used during seek) */ int cum_len; /* temporary storage (used during seek) */ @@ -232,11 +233,12 @@ get_le32(pb); /* initial frame */ ast->scale = get_le32(pb); /* scale */ ast->rate = get_le32(pb); - get_le32(pb); /* start */ + ast->start= get_le32(pb); /* start */ length = get_le32(pb); /* length, in samples or bytes */ get_le32(pb); /* buffer size */ get_le32(pb); /* quality */ ast->sample_size = get_le32(pb); /* sample ssize */ +//av_log(NULL, AV_LOG_DEBUG, "%d %d %d %d\n", ast->scale, ast->rate, ast->sample_size, ast->start); st->start_time = 0; if (ast->rate != 0) st->duration = (int64_t)length * AV_TIME_BASE / ast->rate; @@ -419,10 +421,10 @@ ast = st->priv_data; /* XXX: how to handle B frames in avi ? */ - if(st->codec.codec_type == CODEC_TYPE_VIDEO) + if(ast->sample_size) + pkt->pts = ((int64_t)ast->frame_offset * ast->scale* AV_TIME_BASE) / (ast->rate * ast->sample_size); + else pkt->pts = ((int64_t)ast->frame_offset * ast->scale* AV_TIME_BASE) / ast->rate; - else //FIXME this is proably not correct for all weird avis - pkt->pts = ((int64_t)ast->frame_offset * ast->scale* AV_TIME_BASE) / (ast->rate * st->codec.block_align); //printf("%Ld %d %d %d %d\n", pkt->pts, ast->frame_offset, ast->scale, AV_TIME_BASE, ast->rate); pkt->stream_index = n; /* FIXME: We really should read index for that */ @@ -435,11 +437,13 @@ are key frames */ pkt->flags |= PKT_FLAG_KEY; } - ast->frame_offset++; } else { - ast->frame_offset += pkt->size; pkt->flags |= PKT_FLAG_KEY; } + if(ast->sample_size) + ast->frame_offset += pkt->size; + else + ast->frame_offset++; } return size; } @@ -634,7 +638,7 @@ if ((j + 1) < ast->nb_index_entries) j++; /* extract the current frame number */ - if (st->codec.codec_type == CODEC_TYPE_VIDEO) + if (ast->sample_size==0) ast->new_frame_offset = j; else ast->new_frame_offset = ast->index_entries[j].cum_len;