X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fdv.c;h=b41d123996844c607ee686f708938ca174005473;hb=38a6242b271fad4917a1c6201ff61e10160c965b;hp=84c306114b6701119c8520342090801d9604a9e2;hpb=8ae21fd95985377603c1a96e0086290fb866ab90;p=ffmpeg diff --git a/libavformat/dv.c b/libavformat/dv.c index 84c306114b6..b41d1239968 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -284,27 +284,23 @@ static int dv_extract_video_info(DVDemuxContext *c, const uint8_t *frame) const uint8_t *vsc_pack; AVCodecContext *avctx; int apt, is16_9; - int size = 0; - - if (c->sys) { - avctx = c->vst->codec; - - avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num, - c->sys->time_base.den); - c->vst->avg_frame_rate = av_inv_q(c->vst->time_base); - - /* finding out SAR is a little bit messy */ - vsc_pack = dv_extract_pack(frame, dv_video_control); - apt = frame[4] & 0x07; - is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || - (!apt && (vsc_pack[2] & 0x07) == 0x07))); - c->vst->sample_aspect_ratio = c->sys->sar[is16_9]; - avctx->bit_rate = av_rescale_q(c->sys->frame_size, - (AVRational) { 8, 1 }, - c->sys->time_base); - size = c->sys->frame_size; - } - return size; + + avctx = c->vst->codec; + + avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num, + c->sys->time_base.den); + c->vst->avg_frame_rate = av_inv_q(c->vst->time_base); + + /* finding out SAR is a little bit messy */ + vsc_pack = dv_extract_pack(frame, dv_video_control); + apt = frame[4] & 0x07; + is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || + (!apt && (vsc_pack[2] & 0x07) == 0x07))); + c->vst->sample_aspect_ratio = c->sys->sar[is16_9]; + avctx->bit_rate = av_rescale_q(c->sys->frame_size, + (AVRational) { 8, 1 }, + c->sys->time_base); + return c->sys->frame_size; } static int dv_extract_timecode(DVDemuxContext* c, const uint8_t* frame, char *tc) @@ -422,13 +418,12 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, int64_t timestamp, int flags) { // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) - const AVDVProfile *sys = av_dv_codec_profile2(c->vst->codec->coded_width, c->vst->codec->coded_height, - c->vst->codec->pix_fmt, c->vst->codec->time_base); + const int frame_size = c->sys->frame_size; int64_t offset; int64_t size = avio_size(s->pb) - s->internal->data_offset; - int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size; + int64_t max_offset = ((size - 1) / frame_size) * frame_size; - offset = sys->frame_size * timestamp; + offset = frame_size * timestamp; if (size >= 0 && offset > max_offset) offset = max_offset;