#include "dv.h"
struct DVDemuxContext {
- const DVprofile* sys; /* Current DV profile. E.g.: 525/60, 625/50 */
+ const AVDVProfile* sys; /* Current DV profile. E.g.: 525/60, 625/50 */
AVFormatContext* fctx;
AVStream* vst;
AVStream* ast[4];
* are converted into 16bit linear ones.
*/
static int dv_extract_audio(uint8_t *frame, uint8_t **ppcm,
- const DVprofile *sys)
+ const AVDVProfile *sys)
{
int size, chan, i, j, d, of, smpls, freq, quant, half_ch;
uint16_t lc, rc;
if (!c->ast[i])
break;
avpriv_set_pts_info(c->ast[i], 64, 1, 30000);
- c->ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO;
- c->ast[i]->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
+ c->ast[i]->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ c->ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
av_init_packet(&c->audio_pkt[i]);
c->audio_pkt[i].size = 0;
c->audio_pkt[i].stream_index = c->ast[i]->index;
c->audio_pkt[i].flags |= AV_PKT_FLAG_KEY;
}
- c->ast[i]->codec->sample_rate = dv_audio_frequency[freq];
- c->ast[i]->codec->channels = 2;
- c->ast[i]->codec->channel_layout = AV_CH_LAYOUT_STEREO;
- c->ast[i]->codec->bit_rate = 2 * dv_audio_frequency[freq] * 16;
+ c->ast[i]->codecpar->sample_rate = dv_audio_frequency[freq];
+ c->ast[i]->codecpar->channels = 2;
+ c->ast[i]->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
+ c->ast[i]->codecpar->bit_rate = 2 * dv_audio_frequency[freq] * 16;
c->ast[i]->start_time = 0;
}
c->ach = i;
static int dv_extract_video_info(DVDemuxContext *c, uint8_t *frame)
{
const uint8_t *vsc_pack;
- AVCodecContext *avctx;
int apt, is16_9;
int size = 0;
if (c->sys) {
- avctx = c->vst->codec;
+ AVCodecParameters *par = c->vst->codecpar;
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);
- if (!avctx->width) {
- avctx->width = c->sys->width;
- avctx->height = c->sys->height;
+ if (!par->width) {
+ par->width = c->sys->width;
+ par->height = c->sys->height;
}
- avctx->pix_fmt = c->sys->pix_fmt;
+ par->format = c->sys->pix_fmt;
/* finding out SAR is a little bit messy */
vsc_pack = dv_extract_pack(frame, dv_video_control);
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);
+ par->bit_rate = av_rescale_q(c->sys->frame_size,
+ (AVRational) { 8, 1 },
+ c->sys->time_base);
size = c->sys->frame_size;
}
return size;
}
c->fctx = s;
- c->vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
- c->vst->codec->codec_id = AV_CODEC_ID_DVVIDEO;
- c->vst->codec->bit_rate = 25000000;
+ c->vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
+ c->vst->codecpar->codec_id = AV_CODEC_ID_DVVIDEO;
+ c->vst->codecpar->bit_rate = 25000000;
c->vst->start_time = 0;
return c;
uint8_t *ppcm[5] = { 0 };
if (buf_size < DV_PROFILE_BYTES ||
- !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) ||
+ !(c->sys = av_dv_frame_profile(c->sys, buf, buf_size)) ||
buf_size < c->sys->frame_size) {
return -1; /* Broken frame, or not enough data */
}
for (i = 0; i < c->ach; i++) {
c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000 * 8 /
- c->ast[i]->codec->bit_rate;
+ c->ast[i]->codecpar->bit_rate;
ppcm[i] = c->audio_buf[i];
}
if (c->ach)
int64_t timestamp, int flags)
{
// FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
- const DVprofile *sys = avpriv_dv_codec_profile(c->vst->codec);
+ const AVDVProfile *sys = av_dv_codec_profile(c->vst->codecpar->width, c->vst->codecpar->height,
+ c->vst->codecpar->format);
int64_t offset;
- int64_t size = avio_size(s->pb) - s->data_offset;
+ int64_t size = avio_size(s->pb) - s->internal->data_offset;
int64_t max_offset = ((size - 1) / sys->frame_size) * sys->frame_size;
offset = sys->frame_size * timestamp;
else if (offset < 0)
offset = 0;
- return offset + s->data_offset;
+ return offset + s->internal->data_offset;
}
void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
c->frames = frame_offset;
if (c->ach)
c->abytes = av_rescale_q(c->frames, c->sys->time_base,
- (AVRational) { 8, c->ast[0]->codec->bit_rate });
+ (AVRational) { 8, c->ast[0]->codecpar->bit_rate });
c->audio_pkt[0].size = c->audio_pkt[1].size = 0;
c->audio_pkt[2].size = c->audio_pkt[3].size = 0;
avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0)
return AVERROR(EIO);
- c->dv_demux->sys = avpriv_dv_frame_profile(c->dv_demux->sys,
- c->buf,
- DV_PROFILE_BYTES);
+ c->dv_demux->sys = av_dv_frame_profile(c->dv_demux->sys,
+ c->buf,
+ DV_PROFILE_BYTES);
if (!c->dv_demux->sys) {
av_log(s, AV_LOG_ERROR,
"Can't determine profile of DV input stream.\n");