Merge commit '9200514ad8717c63f82101dc394f4378854325bf'

* commit '9200514ad8717c63f82101dc394f4378854325bf':
  lavf: replace AVStream.codec with AVStream.codecpar

This has been a HUGE effort from:
    - Derek Buitenhuis <derek.buitenhuis@gmail.com>
    - Hendrik Leppkes <h.leppkes@gmail.com>
    - wm4 <nfxjfg@googlemail.com>
    - Clément Bœsch <clement@stupeflix.com>
    - James Almer <jamrial@gmail.com>
    - Michael Niedermayer <michael@niedermayer.cc>
    - Rostislav Pehlivanov <atomnuker@gmail.com>

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
This commit is contained in:
Derek Buitenhuis 2016-04-10 20:58:15 +01:00
commit 6f69f7a8bf
362 changed files with 6553 additions and 6077 deletions

View File

@ -696,6 +696,15 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
}
if (pkt->size == 0 && pkt->side_data_elems == 0)
return;
if (!ost->st->codecpar->extradata && avctx->extradata) {
ost->st->codecpar->extradata = av_malloc(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!ost->st->codecpar->extradata) {
av_log(NULL, AV_LOG_ERROR, "Could not allocate extradata buffer to copy parser data.\n");
exit_program(1);
}
ost->st->codecpar->extradata_size = avctx->extradata_size;
memcpy(ost->st->codecpar->extradata, avctx->extradata, avctx->extradata_size);
}
if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
if (pkt->dts != AV_NOPTS_VALUE &&

View File

@ -2996,6 +2996,8 @@ static int prepare_sdp_description(FFServerStream *stream, uint8_t **pbuffer,
for(i = 0; i < stream->nb_streams; i++) {
avc->streams[i] = &avs[i];
avc->streams[i]->codec = stream->streams[i]->codec;
avcodec_parameters_from_context(stream->streams[i]->codecpar, stream->streams[i]->codec);
avc->streams[i]->codecpar = stream->streams[i]->codecpar;
}
*pbuffer = av_mallocz(2048);
if (!*pbuffer)
@ -3536,6 +3538,8 @@ static AVStream *add_av_stream1(FFServerStream *stream,
fst->priv_data = av_mallocz(sizeof(FeedData));
fst->internal = av_mallocz(sizeof(*fst->internal));
fst->internal->avctx = avcodec_alloc_context3(NULL);
fst->codecpar = avcodec_parameters_alloc();
fst->index = stream->nb_streams;
avpriv_set_pts_info(fst, 33, 1, 90000);
fst->sample_aspect_ratio = codec->sample_aspect_ratio;

View File

@ -175,7 +175,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
snd_pcm_t *h;
snd_pcm_hw_params_t *hw_params;
snd_pcm_uframes_t buffer_size, period_size;
uint64_t layout = ctx->streams[0]->codec->channel_layout;
uint64_t layout = ctx->streams[0]->codecpar->channel_layout;
if (ctx->filename[0] == 0) audio_device = "default";
else audio_device = ctx->filename;

View File

@ -79,11 +79,11 @@ static av_cold int audio_read_header(AVFormatContext *s1)
}
/* take real parameters */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = codec_id;
st->codec->sample_rate = s->sample_rate;
st->codec->channels = s->channels;
st->codec->frame_size = s->frame_size;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = codec_id;
st->codecpar->sample_rate = s->sample_rate;
st->codecpar->channels = s->channels;
st->codecpar->frame_size = s->frame_size;
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
/* microseconds instead of seconds, MHz instead of Hz */
s->timefilter = ff_timefilter_new(1000000.0 / s->sample_rate,

View File

@ -55,20 +55,20 @@ static av_cold int audio_write_header(AVFormatContext *s1)
enum AVCodecID codec_id;
int res;
if (s1->nb_streams != 1 || s1->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
if (s1->nb_streams != 1 || s1->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
av_log(s1, AV_LOG_ERROR, "Only a single audio stream is supported.\n");
return AVERROR(EINVAL);
}
st = s1->streams[0];
sample_rate = st->codec->sample_rate;
codec_id = st->codec->codec_id;
sample_rate = st->codecpar->sample_rate;
codec_id = st->codecpar->codec_id;
res = ff_alsa_open(s1, SND_PCM_STREAM_PLAYBACK, &sample_rate,
st->codec->channels, &codec_id);
if (sample_rate != st->codec->sample_rate) {
st->codecpar->channels, &codec_id);
if (sample_rate != st->codecpar->sample_rate) {
av_log(s1, AV_LOG_ERROR,
"sample rate %d not available, nearest is %d\n",
st->codec->sample_rate, sample_rate);
st->codecpar->sample_rate, sample_rate);
goto fail;
}
avpriv_set_pts_info(st, 64, 1, sample_rate);
@ -124,7 +124,7 @@ static int audio_write_frame(AVFormatContext *s1, int stream_index,
/* ff_alsa_open() should have accepted only supported formats */
if ((flags & AV_WRITE_UNCODED_FRAME_QUERY))
return av_sample_fmt_is_planar(s1->streams[stream_index]->codec->sample_fmt) ?
return av_sample_fmt_is_planar(s1->streams[stream_index]->codecpar->format) ?
AVERROR(EINVAL) : 0;
/* set only used fields */
pkt.data = (*frame)->data[0];

View File

@ -286,14 +286,12 @@ static int grab_read_header(AVFormatContext *s1)
s->per_frame = ((uint64_t)1000000 * framerate.den) / framerate.num;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->pix_fmt = AV_PIX_FMT_YUV420P;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->width = s->width;
st->codec->height = s->height;
st->codec->time_base.den = framerate.num;
st->codec->time_base.num = framerate.den;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->format = AV_PIX_FMT_YUV420P;
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codecpar->width = s->width;
st->codecpar->height = s->height;
st->avg_frame_rate = framerate;
if (bktr_init(s1->filename, s->width, s->height, s->standard,
&s->video_fd, &s->tuner_fd, -1, 0.0) < 0) {

View File

@ -918,7 +918,7 @@ dshow_add_device(AVFormatContext *avctx,
{
struct dshow_ctx *ctx = avctx->priv_data;
AM_MEDIA_TYPE type;
AVCodecContext *codec;
AVCodecParameters *par;
AVStream *st;
int ret = AVERROR(EIO);
@ -933,7 +933,7 @@ dshow_add_device(AVFormatContext *avctx,
libAVPin_ConnectionMediaType(ctx->capture_pin[devtype], &type);
codec = st->codec;
par = st->codecpar;
if (devtype == VideoDevice) {
BITMAPINFOHEADER *bih = NULL;
AVRational time_base;
@ -952,33 +952,34 @@ dshow_add_device(AVFormatContext *avctx,
goto error;
}
codec->time_base = time_base;
codec->codec_type = AVMEDIA_TYPE_VIDEO;
codec->width = bih->biWidth;
codec->height = bih->biHeight;
codec->codec_tag = bih->biCompression;
codec->pix_fmt = dshow_pixfmt(bih->biCompression, bih->biBitCount);
st->avg_frame_rate = av_inv_q(time_base);
par->codec_type = AVMEDIA_TYPE_VIDEO;
par->width = bih->biWidth;
par->height = bih->biHeight;
par->codec_tag = bih->biCompression;
par->format = dshow_pixfmt(bih->biCompression, bih->biBitCount);
if (bih->biCompression == MKTAG('H', 'D', 'Y', 'C')) {
av_log(avctx, AV_LOG_DEBUG, "attempt to use full range for HDYC...\n");
codec->color_range = AVCOL_RANGE_MPEG; // just in case it needs this...
par->color_range = AVCOL_RANGE_MPEG; // just in case it needs this...
}
if (codec->pix_fmt == AV_PIX_FMT_NONE) {
if (par->format == AV_PIX_FMT_NONE) {
const AVCodecTag *const tags[] = { avformat_get_riff_video_tags(), NULL };
codec->codec_id = av_codec_get_id(tags, bih->biCompression);
if (codec->codec_id == AV_CODEC_ID_NONE) {
par->codec_id = av_codec_get_id(tags, bih->biCompression);
if (par->codec_id == AV_CODEC_ID_NONE) {
av_log(avctx, AV_LOG_ERROR, "Unknown compression type. "
"Please report type 0x%X.\n", (int) bih->biCompression);
return AVERROR_PATCHWELCOME;
}
codec->bits_per_coded_sample = bih->biBitCount;
par->bits_per_coded_sample = bih->biBitCount;
} else {
codec->codec_id = AV_CODEC_ID_RAWVIDEO;
par->codec_id = AV_CODEC_ID_RAWVIDEO;
if (bih->biCompression == BI_RGB || bih->biCompression == BI_BITFIELDS) {
codec->bits_per_coded_sample = bih->biBitCount;
codec->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE);
if (codec->extradata) {
codec->extradata_size = 9;
memcpy(codec->extradata, "BottomUp", 9);
par->bits_per_coded_sample = bih->biBitCount;
par->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE);
if (par->extradata) {
par->extradata_size = 9;
memcpy(par->extradata, "BottomUp", 9);
}
}
}
@ -993,11 +994,11 @@ dshow_add_device(AVFormatContext *avctx,
goto error;
}
codec->codec_type = AVMEDIA_TYPE_AUDIO;
codec->sample_fmt = sample_fmt_bits_per_sample(fx->wBitsPerSample);
codec->codec_id = waveform_codec_id(codec->sample_fmt);
codec->sample_rate = fx->nSamplesPerSec;
codec->channels = fx->nChannels;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->format = sample_fmt_bits_per_sample(fx->wBitsPerSample);
par->codec_id = waveform_codec_id(par->format);
par->sample_rate = fx->nSamplesPerSec;
par->channels = fx->nChannels;
}
avpriv_set_pts_info(st, 64, 1, 10000000);

View File

@ -126,13 +126,13 @@ static av_cold int fbdev_read_header(AVFormatContext *avctx)
goto fail;
}
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->width = fbdev->width;
st->codec->height = fbdev->height;
st->codec->pix_fmt = pix_fmt;
st->codec->time_base = av_inv_q(fbdev->framerate_q);
st->codec->bit_rate =
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codecpar->width = fbdev->width;
st->codecpar->height = fbdev->height;
st->codecpar->format = pix_fmt;
st->avg_frame_rate = fbdev->framerate_q;
st->codecpar->bit_rate =
fbdev->width * fbdev->height * fbdev->bytes_per_pixel * av_q2d(fbdev->framerate_q) * 8;
av_log(avctx, AV_LOG_INFO,
@ -140,7 +140,7 @@ static av_cold int fbdev_read_header(AVFormatContext *avctx)
fbdev->width, fbdev->height, fbdev->varinfo.bits_per_pixel,
av_get_pix_fmt_name(pix_fmt),
fbdev->framerate_q.num, fbdev->framerate_q.den,
(int64_t)st->codec->bit_rate);
(int64_t)st->codecpar->bit_rate);
return 0;
fail:

View File

@ -48,7 +48,7 @@ static av_cold int fbdev_write_header(AVFormatContext *h)
int ret, flags = O_RDWR;
const char* device;
if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO) {
if (h->nb_streams != 1 || h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
av_log(fbdev, AV_LOG_ERROR, "Only a single video stream is supported.\n");
return AVERROR(EINVAL);
}
@ -105,11 +105,11 @@ static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
enum AVPixelFormat fb_pix_fmt;
int disp_height;
int bytes_to_copy;
AVCodecContext *codec_ctx = h->streams[0]->codec;
enum AVPixelFormat video_pix_fmt = codec_ctx->pix_fmt;
int video_width = codec_ctx->width;
int video_height = codec_ctx->height;
int bytes_per_pixel = ((codec_ctx->bits_per_coded_sample + 7) >> 3);
AVCodecParameters *par = h->streams[0]->codecpar;
enum AVPixelFormat video_pix_fmt = par->format;
int video_width = par->width;
int video_height = par->height;
int bytes_per_pixel = ((par->bits_per_coded_sample + 7) >> 3);
int src_line_size = video_width * bytes_per_pixel;
int i;

View File

@ -403,10 +403,11 @@ gdigrab_read_header(AVFormatContext *s1)
}
}
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_BMP;
st->codec->time_base = gdigrab->time_base;
st->codec->bit_rate = (gdigrab->header_size + gdigrab->frame_size) * 1/av_q2d(gdigrab->time_base) * 8;
st->avg_frame_rate = av_inv_q(gdigrab->time_base);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_BMP;
st->codecpar->bit_rate = (gdigrab->header_size + gdigrab->frame_size) * 1/av_q2d(gdigrab->time_base) * 8;
return 0;

View File

@ -262,14 +262,14 @@ static int audio_read_header(AVFormatContext *context)
return AVERROR(ENOMEM);
}
stream->codec->codec_type = AVMEDIA_TYPE_AUDIO;
stream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
#if HAVE_BIGENDIAN
stream->codec->codec_id = AV_CODEC_ID_PCM_F32BE;
stream->codecpar->codec_id = AV_CODEC_ID_PCM_F32BE;
#else
stream->codec->codec_id = AV_CODEC_ID_PCM_F32LE;
stream->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
#endif
stream->codec->sample_rate = self->sample_rate;
stream->codec->channels = self->nports;
stream->codecpar->sample_rate = self->sample_rate;
stream->codecpar->channels = self->nports;
avpriv_set_pts_info(stream, 64, 1, 1000000); /* 64 bits pts in us */
return 0;

View File

@ -108,8 +108,8 @@ static int create_subcc_streams(AVFormatContext *avctx)
lavfi->sink_stream_subcc_map[sink_idx] = avctx->nb_streams;
if (!(st = avformat_new_stream(avctx, NULL)))
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_EIA_608;
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_id = AV_CODEC_ID_EIA_608;
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
} else {
lavfi->sink_stream_subcc_map[sink_idx] = -1;
}
@ -314,28 +314,28 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
for (i = 0; i < lavfi->nb_sinks; i++) {
AVFilterLink *link = lavfi->sinks[lavfi->stream_sink_map[i]]->inputs[0];
AVStream *st = avctx->streams[i];
st->codec->codec_type = link->type;
st->codecpar->codec_type = link->type;
avpriv_set_pts_info(st, 64, link->time_base.num, link->time_base.den);
if (link->type == AVMEDIA_TYPE_VIDEO) {
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = link->format;
st->codec->time_base = link->time_base;
st->codec->width = link->w;
st->codec->height = link->h;
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codecpar->format = link->format;
st->avg_frame_rate = av_inv_q(link->time_base);
st->codecpar->width = link->w;
st->codecpar->height = link->h;
st ->sample_aspect_ratio =
st->codec->sample_aspect_ratio = link->sample_aspect_ratio;
st->codecpar->sample_aspect_ratio = link->sample_aspect_ratio;
avctx->probesize = FFMAX(avctx->probesize,
link->w * link->h *
av_get_padded_bits_per_pixel(av_pix_fmt_desc_get(link->format)) *
30);
} else if (link->type == AVMEDIA_TYPE_AUDIO) {
st->codec->codec_id = av_get_pcm_codec(link->format, -1);
st->codec->channels = avfilter_link_get_channels(link);
st->codec->sample_fmt = link->format;
st->codec->sample_rate = link->sample_rate;
st->codec->time_base = link->time_base;
st->codec->channel_layout = link->channel_layout;
if (st->codec->codec_id == AV_CODEC_ID_NONE)
st->codecpar->codec_id = av_get_pcm_codec(link->format, -1);
st->codecpar->channels = avfilter_link_get_channels(link);
st->codecpar->format = link->format;
st->codecpar->sample_rate = link->sample_rate;
st->avg_frame_rate = av_inv_q(link->time_base);
st->codecpar->channel_layout = link->channel_layout;
if (st->codecpar->codec_id == AV_CODEC_ID_NONE)
av_log(avctx, AV_LOG_ERROR,
"Could not find PCM codec for sample format %s.\n",
av_get_sample_fmt_name(link->format));

View File

@ -85,19 +85,19 @@ static av_cold int read_header(AVFormatContext *ctx)
}
cdio_paranoia_modeset(s->paranoia, s->paranoia_mode);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
if (s->drive->bigendianp)
st->codec->codec_id = AV_CODEC_ID_PCM_S16BE;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE;
else
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
st->codec->sample_rate = 44100;
st->codec->channels = 2;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
st->codecpar->sample_rate = 44100;
st->codecpar->channels = 2;
if (s->drive->audio_last_sector != CDIO_INVALID_LSN &&
s->drive->audio_first_sector != CDIO_INVALID_LSN)
st->duration = s->drive->audio_last_sector - s->drive->audio_first_sector;
else if (s->drive->tracks)
st->duration = s->drive->disc_toc[s->drive->tracks].dwStartSector;
avpriv_set_pts_info(st, 64, CDIO_CD_FRAMESIZE_RAW, 2*st->codec->channels*st->codec->sample_rate);
avpriv_set_pts_info(st, 64, CDIO_CD_FRAMESIZE_RAW, 2 * st->codecpar->channels * st->codecpar->sample_rate);
for (i = 0; i < s->drive->tracks; i++) {
char title[16];

View File

@ -171,13 +171,12 @@ static inline int dc1394_read_common(AVFormatContext *c,
goto out;
}
avpriv_set_pts_info(vst, 64, 1, 1000);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
vst->codec->time_base.den = framerate.num;
vst->codec->time_base.num = framerate.den;
vst->codec->width = fmt->width;
vst->codec->height = fmt->height;
vst->codec->pix_fmt = fmt->pix_fmt;
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
vst->codecpar->width = fmt->width;
vst->codecpar->height = fmt->height;
vst->codecpar->format = fmt->pix_fmt;
vst->avg_frame_rate = framerate;
/* packet init */
av_init_packet(&dc1394->packet);
@ -188,7 +187,7 @@ static inline int dc1394_read_common(AVFormatContext *c,
dc1394->current_frame = 0;
vst->codec->bit_rate = av_rescale(dc1394->packet.size * 8, fps->frame_rate, 1000);
vst->codecpar->bit_rate = av_rescale(dc1394->packet.size * 8, fps->frame_rate, 1000);
*select_fps = fps;
*select_fmt = fmt;
out:

View File

@ -128,7 +128,7 @@ static int read_header(AVFormatContext *ctx)
int error = 0;
const char *error_msg;
AVStream *st = NULL;
AVCodecContext *codec = NULL;
AVCodecParameters *par = NULL;
if (ad->list_devices) {
print_al_capture_devices(ctx);
@ -156,11 +156,11 @@ static int read_header(AVFormatContext *ctx)
avpriv_set_pts_info(st, 64, 1, 1000000);
/* Set codec parameters */
codec = st->codec;
codec->codec_type = AVMEDIA_TYPE_AUDIO;
codec->sample_rate = ad->sample_rate;
codec->channels = get_al_format_info(ad->sample_format)->channels;
codec->codec_id = get_al_format_info(ad->sample_format)->codec_id;
par = st->codecpar;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->sample_rate = ad->sample_rate;
par->channels = get_al_format_info(ad->sample_format)->channels;
par->codec_id = get_al_format_info(ad->sample_format)->codec_id;
/* This is needed to read the audio data */
ad->sample_step = (av_get_bits_per_sample(get_al_format_info(ad->sample_format)->codec_id) *

View File

@ -678,11 +678,11 @@ static void opengl_compute_display_area(AVFormatContext *s)
AVRational sar, dar; /* sample and display aspect ratios */
OpenGLContext *opengl = s->priv_data;
AVStream *st = s->streams[0];
AVCodecContext *encctx = st->codec;
AVCodecParameters *par = st->codecpar;
/* compute overlay width and height from the codec context information */
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
dar = av_mul_q(sar, (AVRational){ par->width, par->height });
/* we suppose the screen has a 1/1 sample aspect ratio */
/* fit in the window */
@ -1065,15 +1065,15 @@ static av_cold int opengl_write_header(AVFormatContext *h)
int ret;
if (h->nb_streams != 1 ||
h->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
h->streams[0]->codec->codec_id != AV_CODEC_ID_RAWVIDEO) {
h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
h->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(opengl, AV_LOG_ERROR, "Only a single video stream is supported.\n");
return AVERROR(EINVAL);
}
st = h->streams[0];
opengl->width = st->codec->width;
opengl->height = st->codec->height;
opengl->pix_fmt = st->codec->pix_fmt;
opengl->width = st->codecpar->width;
opengl->height = st->codecpar->height;
opengl->pix_fmt = st->codecpar->format;
if (!opengl->window_width)
opengl->window_width = opengl->width;
if (!opengl->window_height)
@ -1200,7 +1200,7 @@ static uint8_t* opengl_get_plane_pointer(OpenGLContext *opengl, AVPacket *pkt, i
static int opengl_draw(AVFormatContext *h, void *input, int repaint, int is_pkt)
{
OpenGLContext *opengl = h->priv_data;
enum AVPixelFormat pix_fmt = h->streams[0]->codec->pix_fmt;
enum AVPixelFormat pix_fmt = h->streams[0]->codecpar->format;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int ret;

View File

@ -63,10 +63,10 @@ static int audio_read_header(AVFormatContext *s1)
}
/* take real parameters */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s->codec_id;
st->codec->sample_rate = s->sample_rate;
st->codec->channels = s->channels;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = s->codec_id;
st->codecpar->sample_rate = s->sample_rate;
st->codecpar->channels = s->channels;
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
return 0;

View File

@ -49,8 +49,8 @@ static int audio_write_header(AVFormatContext *s1)
int ret;
st = s1->streams[0];
s->sample_rate = st->codec->sample_rate;
s->channels = st->codec->channels;
s->sample_rate = st->codecpar->sample_rate;
s->channels = st->codecpar->channels;
ret = ff_oss_audio_open(s1, 1, s1->filename);
if (ret < 0) {
return AVERROR(EIO);

View File

@ -242,10 +242,10 @@ static av_cold int pulse_read_header(AVFormatContext *s)
pa_threaded_mainloop_unlock(pd->mainloop);
/* take real parameters */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = codec_id;
st->codec->sample_rate = pd->sample_rate;
st->codec->channels = pd->channels;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = codec_id;
st->codecpar->sample_rate = pd->sample_rate;
st->codecpar->channels = pd->channels;
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
pd->timefilter = ff_timefilter_new(1000000.0 / pd->sample_rate,

View File

@ -452,7 +452,7 @@ static av_cold int pulse_write_header(AVFormatContext *h)
PA_STREAM_AUTO_TIMING_UPDATE |
PA_STREAM_NOT_MONOTONIC;
if (h->nb_streams != 1 || h->streams[0]->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
if (h->nb_streams != 1 || h->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) {
av_log(s, AV_LOG_ERROR, "Only a single audio stream is supported.\n");
return AVERROR(EINVAL);
}
@ -468,8 +468,8 @@ static av_cold int pulse_write_header(AVFormatContext *h)
if (s->buffer_duration) {
int64_t bytes = s->buffer_duration;
bytes *= st->codec->channels * st->codec->sample_rate *
av_get_bytes_per_sample(st->codec->sample_fmt);
bytes *= st->codecpar->channels * st->codecpar->sample_rate *
av_get_bytes_per_sample(st->codecpar->format);
bytes /= 1000;
buffer_attributes.tlength = FFMAX(s->buffer_size, av_clip64(bytes, 0, UINT32_MAX - 1));
av_log(s, AV_LOG_DEBUG,
@ -483,9 +483,9 @@ static av_cold int pulse_write_header(AVFormatContext *h)
if (s->minreq)
buffer_attributes.minreq = s->minreq;
sample_spec.format = ff_codec_id_to_pulse_format(st->codec->codec_id);
sample_spec.rate = st->codec->sample_rate;
sample_spec.channels = st->codec->channels;
sample_spec.format = ff_codec_id_to_pulse_format(st->codecpar->codec_id);
sample_spec.rate = st->codecpar->sample_rate;
sample_spec.channels = st->codecpar->channels;
if (!pa_sample_spec_valid(&sample_spec)) {
av_log(s, AV_LOG_ERROR, "Invalid sample spec.\n");
return AVERROR(EINVAL);
@ -494,10 +494,10 @@ static av_cold int pulse_write_header(AVFormatContext *h)
if (sample_spec.channels == 1) {
channel_map.channels = 1;
channel_map.map[0] = PA_CHANNEL_POSITION_MONO;
} else if (st->codec->channel_layout) {
if (av_get_channel_layout_nb_channels(st->codec->channel_layout) != st->codec->channels)
} else if (st->codecpar->channel_layout) {
if (av_get_channel_layout_nb_channels(st->codecpar->channel_layout) != st->codecpar->channels)
return AVERROR(EINVAL);
pulse_map_channels_to_pulse(st->codec->channel_layout, &channel_map);
pulse_map_channels_to_pulse(st->codecpar->channel_layout, &channel_map);
/* Unknown channel is present in channel_layout, let PulseAudio use its default. */
if (channel_map.channels != sample_spec.channels) {
av_log(s, AV_LOG_WARNING, "Unknown channel. Using defaul channel map.\n");
@ -637,9 +637,8 @@ static int pulse_write_packet(AVFormatContext *h, AVPacket *pkt)
s->timestamp += pkt->duration;
} else {
AVStream *st = h->streams[0];
AVCodecContext *codec_ctx = st->codec;
AVRational r = { 1, codec_ctx->sample_rate };
int64_t samples = pkt->size / (av_get_bytes_per_sample(codec_ctx->sample_fmt) * codec_ctx->channels);
AVRational r = { 1, st->codecpar->sample_rate };
int64_t samples = pkt->size / (av_get_bytes_per_sample(st->codecpar->format) * st->codecpar->channels);
s->timestamp += av_rescale_q(samples, r, st->time_base);
}
@ -678,7 +677,7 @@ static int pulse_write_frame(AVFormatContext *h, int stream_index,
/* Planar formats are not supported yet. */
if (flags & AV_WRITE_UNCODED_FRAME_QUERY)
return av_sample_fmt_is_planar(h->streams[stream_index]->codec->sample_fmt) ?
return av_sample_fmt_is_planar(h->streams[stream_index]->codecpar->format) ?
AVERROR(EINVAL) : 0;
pkt.data = (*frame)->data[0];

View File

@ -94,12 +94,12 @@ static void compute_overlay_rect(AVFormatContext *s)
AVRational sar, dar; /* sample and display aspect ratios */
SDLContext *sdl = s->priv_data;
AVStream *st = s->streams[0];
AVCodecContext *encctx = st->codec;
AVCodecParameters *par = st->codecpar;
SDL_Rect *overlay_rect = &sdl->overlay_rect;
/* compute overlay width and height from the codec context information */
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
dar = av_mul_q(sar, (AVRational){ par->width, par->height });
/* we suppose the screen has a 1/1 sample aspect ratio */
if (sdl->window_width && sdl->window_height) {
@ -115,10 +115,10 @@ static void compute_overlay_rect(AVFormatContext *s)
}
} else {
if (sar.num > sar.den) {
overlay_rect->w = encctx->width;
overlay_rect->w = par->width;
overlay_rect->h = av_rescale(overlay_rect->w, dar.den, dar.num);
} else {
overlay_rect->h = encctx->height;
overlay_rect->h = par->height;
overlay_rect->w = av_rescale(overlay_rect->h, dar.num, dar.den);
}
sdl->window_width = overlay_rect->w;
@ -137,7 +137,7 @@ static int event_thread(void *arg)
SDLContext *sdl = s->priv_data;
int flags = SDL_BASE_FLAGS | (sdl->window_fullscreen ? SDL_FULLSCREEN : 0);
AVStream *st = s->streams[0];
AVCodecContext *encctx = st->codec;
AVCodecParameters *par = st->codecpar;
/* initialization */
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
@ -155,19 +155,19 @@ static int event_thread(void *arg)
goto init_end;
}
sdl->overlay = SDL_CreateYUVOverlay(encctx->width, encctx->height,
sdl->overlay = SDL_CreateYUVOverlay(par->width, par->height,
sdl->overlay_fmt, sdl->surface);
if (!sdl->overlay || sdl->overlay->pitches[0] < encctx->width) {
if (!sdl->overlay || sdl->overlay->pitches[0] < par->width) {
av_log(s, AV_LOG_ERROR,
"SDL does not support an overlay with size of %dx%d pixels\n",
encctx->width, encctx->height);
par->width, par->height);
sdl->init_ret = AVERROR(EINVAL);
goto init_end;
}
sdl->init_ret = 0;
av_log(s, AV_LOG_VERBOSE, "w:%d h:%d fmt:%s -> w:%d h:%d\n",
encctx->width, encctx->height, av_get_pix_fmt_name(encctx->pix_fmt),
par->width, par->height, av_get_pix_fmt_name(par->format),
sdl->overlay_rect.w, sdl->overlay_rect.h);
init_end:
@ -234,7 +234,7 @@ static int sdl_write_header(AVFormatContext *s)
{
SDLContext *sdl = s->priv_data;
AVStream *st = s->streams[0];
AVCodecContext *encctx = st->codec;
AVCodecParameters *par = st->codecpar;
int i, ret;
if (!sdl->window_title)
@ -251,15 +251,15 @@ static int sdl_write_header(AVFormatContext *s)
}
if ( s->nb_streams > 1
|| encctx->codec_type != AVMEDIA_TYPE_VIDEO
|| encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {
|| par->codec_type != AVMEDIA_TYPE_VIDEO
|| par->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
ret = AVERROR(EINVAL);
goto fail;
}
for (i = 0; sdl_overlay_pix_fmt_map[i].pix_fmt != AV_PIX_FMT_NONE; i++) {
if (sdl_overlay_pix_fmt_map[i].pix_fmt == encctx->pix_fmt) {
if (sdl_overlay_pix_fmt_map[i].pix_fmt == par->format) {
sdl->overlay_fmt = sdl_overlay_pix_fmt_map[i].overlay_fmt;
break;
}
@ -268,7 +268,7 @@ static int sdl_write_header(AVFormatContext *s)
if (!sdl->overlay_fmt) {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format '%s', choose one of yuv420p, yuyv422, or uyvy422\n",
av_get_pix_fmt_name(encctx->pix_fmt));
av_get_pix_fmt_name(par->format));
ret = AVERROR(EINVAL);
goto fail;
}
@ -315,7 +315,7 @@ fail:
static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt)
{
SDLContext *sdl = s->priv_data;
AVCodecContext *encctx = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
uint8_t *data[4];
int linesize[4];
int i;
@ -324,7 +324,7 @@ static int sdl_write_packet(AVFormatContext *s, AVPacket *pkt)
sdl_write_trailer(s);
return AVERROR(EIO);
}
av_image_fill_arrays(data, linesize, pkt->data, encctx->pix_fmt, encctx->width, encctx->height, 1);
av_image_fill_arrays(data, linesize, pkt->data, par->format, par->width, par->height, 1);
SDL_LockMutex(sdl->mutex);
SDL_FillRect(sdl->surface, &sdl->surface->clip_rect,

View File

@ -46,10 +46,10 @@ static av_cold int audio_read_header(AVFormatContext *s1)
return ret;
/* take real parameters */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s->codec_id;
st->codec->sample_rate = s->sample_rate;
st->codec->channels = s->channels;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = s->codec_id;
st->codecpar->sample_rate = s->sample_rate;
st->codecpar->channels = s->channels;
avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */

View File

@ -35,8 +35,8 @@ static av_cold int audio_write_header(AVFormatContext *s1)
int ret;
st = s1->streams[0];
s->sample_rate = st->codec->sample_rate;
s->channels = st->codec->channels;
s->sample_rate = st->codecpar->sample_rate;
s->channels = st->codecpar->channels;
ret = ff_sndio_open(s1, 1, s1->filename);

View File

@ -938,8 +938,8 @@ static int v4l2_read_header(AVFormatContext *ctx)
if ((res = v4l2_set_parameters(ctx)) < 0)
goto fail;
st->codec->pix_fmt = ff_fmt_v4l2ff(desired_format, codec_id);
s->frame_size = av_image_get_buffer_size(st->codec->pix_fmt,
st->codecpar->format = ff_fmt_v4l2ff(desired_format, codec_id);
s->frame_size = av_image_get_buffer_size(st->codecpar->format,
s->width, s->height, 1);
if ((res = mmap_init(ctx)) ||
@ -948,22 +948,22 @@ static int v4l2_read_header(AVFormatContext *ctx)
s->top_field_first = first_field(s);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = codec_id;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = codec_id;
if (codec_id == AV_CODEC_ID_RAWVIDEO)
st->codec->codec_tag =
avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
st->codecpar->codec_tag =
avcodec_pix_fmt_to_codec_tag(st->codecpar->format);
else if (codec_id == AV_CODEC_ID_H264) {
st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
}
if (desired_format == V4L2_PIX_FMT_YVU420)
st->codec->codec_tag = MKTAG('Y', 'V', '1', '2');
st->codecpar->codec_tag = MKTAG('Y', 'V', '1', '2');
else if (desired_format == V4L2_PIX_FMT_YVU410)
st->codec->codec_tag = MKTAG('Y', 'V', 'U', '9');
st->codec->width = s->width;
st->codec->height = s->height;
st->codecpar->codec_tag = MKTAG('Y', 'V', 'U', '9');
st->codecpar->width = s->width;
st->codecpar->height = s->height;
if (st->avg_frame_rate.den)
st->codec->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
st->codecpar->bit_rate = s->frame_size * av_q2d(st->avg_frame_rate) * 8;
return 0;

View File

@ -33,7 +33,7 @@ static av_cold int write_header(AVFormatContext *s1)
.type = V4L2_BUF_TYPE_VIDEO_OUTPUT
};
V4L2Context *s = s1->priv_data;
AVCodecContext *enc_ctx;
AVCodecParameters *par;
uint32_t v4l2_pixfmt;
if (s1->flags & AVFMT_FLAG_NONBLOCK)
@ -47,19 +47,19 @@ static av_cold int write_header(AVFormatContext *s1)
}
if (s1->nb_streams != 1 ||
s1->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
s1->streams[0]->codec->codec_id != AV_CODEC_ID_RAWVIDEO) {
s1->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
s1->streams[0]->codecpar->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s1, AV_LOG_ERROR,
"V4L2 output device supports only a single raw video stream\n");
return AVERROR(EINVAL);
}
enc_ctx = s1->streams[0]->codec;
par = s1->streams[0]->codecpar;
v4l2_pixfmt = ff_fmt_ff2v4l(enc_ctx->pix_fmt, AV_CODEC_ID_RAWVIDEO);
v4l2_pixfmt = ff_fmt_ff2v4l(par->format, AV_CODEC_ID_RAWVIDEO);
if (!v4l2_pixfmt) { // XXX: try to force them one by one?
av_log(s1, AV_LOG_ERROR, "Unknown V4L2 pixel format equivalent for %s\n",
av_get_pix_fmt_name(enc_ctx->pix_fmt));
av_get_pix_fmt_name(par->format));
return AVERROR(EINVAL);
}
@ -69,10 +69,10 @@ static av_cold int write_header(AVFormatContext *s1)
return res;
}
fmt.fmt.pix.width = enc_ctx->width;
fmt.fmt.pix.height = enc_ctx->height;
fmt.fmt.pix.width = par->width;
fmt.fmt.pix.height = par->height;
fmt.fmt.pix.pixelformat = v4l2_pixfmt;
fmt.fmt.pix.sizeimage = av_image_get_buffer_size(enc_ctx->pix_fmt, enc_ctx->width, enc_ctx->height, 1);
fmt.fmt.pix.sizeimage = av_image_get_buffer_size(par->format, par->width, par->height, 1);
if (ioctl(s->fd, VIDIOC_S_FMT, &fmt) < 0) {
res = AVERROR(errno);

View File

@ -245,7 +245,7 @@ static int vfw_read_close(AVFormatContext *s)
static int vfw_read_header(AVFormatContext *s)
{
struct vfw_ctx *ctx = s->priv_data;
AVCodecContext *codec;
AVCodecParameters *par;
AVStream *st;
int devnum;
int bisize;
@ -377,29 +377,30 @@ static int vfw_read_header(AVFormatContext *s)
if(!ret)
goto fail;
codec = st->codec;
codec->time_base = av_inv_q(framerate_q);
codec->codec_type = AVMEDIA_TYPE_VIDEO;
codec->width = bi->bmiHeader.biWidth;
codec->height = bi->bmiHeader.biHeight;
codec->pix_fmt = vfw_pixfmt(biCompression, biBitCount);
if(codec->pix_fmt == AV_PIX_FMT_NONE) {
codec->codec_id = vfw_codecid(biCompression);
if(codec->codec_id == AV_CODEC_ID_NONE) {
st->avg_frame_rate = framerate_q;
par = st->codecpar;
par->codec_type = AVMEDIA_TYPE_VIDEO;
par->width = bi->bmiHeader.biWidth;
par->height = bi->bmiHeader.biHeight;
par->format = vfw_pixfmt(biCompression, biBitCount);
if (par->format == AV_PIX_FMT_NONE) {
par->codec_id = vfw_codecid(biCompression);
if (par->codec_id == AV_CODEC_ID_NONE) {
av_log(s, AV_LOG_ERROR, "Unknown compression type. "
"Please report verbose (-v 9) debug information.\n");
vfw_read_close(s);
return AVERROR_PATCHWELCOME;
}
codec->bits_per_coded_sample = biBitCount;
par->bits_per_coded_sample = biBitCount;
} else {
codec->codec_id = AV_CODEC_ID_RAWVIDEO;
par->codec_id = AV_CODEC_ID_RAWVIDEO;
if(biCompression == BI_RGB) {
codec->bits_per_coded_sample = biBitCount;
codec->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE);
if (codec->extradata) {
codec->extradata_size = 9;
memcpy(codec->extradata, "BottomUp", 9);
par->bits_per_coded_sample = biBitCount;
par->extradata = av_malloc(9 + AV_INPUT_BUFFER_PADDING_SIZE);
if (par->extradata) {
par->extradata_size = 9;
memcpy(par->extradata, "BottomUp", 9);
}
}
}

View File

@ -355,11 +355,11 @@ static int x11grab_read_header(AVFormatContext *s1)
x11grab->image = image;
x11grab->use_shm = use_shm;
ret = pixfmt_from_image(s1, image, &st->codec->pix_fmt);
ret = pixfmt_from_image(s1, image, &st->codecpar->format);
if (ret < 0)
goto out;
if (st->codec->pix_fmt == AV_PIX_FMT_PAL8) {
if (st->codecpar->format == AV_PIX_FMT_PAL8) {
color_map = DefaultColormap(dpy, screen);
for (i = 0; i < 256; ++i)
color[i].pixel = i;
@ -372,12 +372,13 @@ static int x11grab_read_header(AVFormatContext *s1)
}
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->width = x11grab->width;
st->codec->height = x11grab->height;
st->codec->time_base = x11grab->time_base;
st->codec->bit_rate = x11grab->frame_size * 1 / av_q2d(x11grab->time_base) * 8;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codecpar->width = x11grab->width;
st->codecpar->height = x11grab->height;
st->codecpar->bit_rate = x11grab->frame_size * 1 / av_q2d(x11grab->time_base) * 8;
st->avg_frame_rate = av_inv_q(x11grab->time_base);
out:
av_free(dpyname);

View File

@ -548,13 +548,12 @@ static int create_stream(AVFormatContext *s)
st->avg_frame_rate.num };
c->time_frame = av_gettime();
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->width = c->width;
st->codec->height = c->height;
st->codec->time_base = c->time_base;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codecpar->width = c->width;
st->codecpar->height = c->height;
ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codec->pix_fmt);
ret = pixfmt_from_pixmap_format(s, geo->depth, &st->codecpar->format);
free(geo);

View File

@ -109,22 +109,22 @@ static int xv_write_header(AVFormatContext *s)
XColor fgcolor;
XWindowAttributes window_attrs;
int num_formats = 0, j, tag, ret;
AVCodecContext *encctx = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
if ( s->nb_streams > 1
|| encctx->codec_type != AVMEDIA_TYPE_VIDEO
|| encctx->codec_id != AV_CODEC_ID_RAWVIDEO) {
|| par->codec_type != AVMEDIA_TYPE_VIDEO
|| par->codec_id != AV_CODEC_ID_RAWVIDEO) {
av_log(s, AV_LOG_ERROR, "Only supports one rawvideo stream\n");
return AVERROR(EINVAL);
}
if (!(tag = xv_get_tag_from_format(encctx->pix_fmt))) {
if (!(tag = xv_get_tag_from_format(par->format))) {
av_log(s, AV_LOG_ERROR,
"Unsupported pixel format '%s', only yuv420p, uyvy422, yuyv422 are currently supported\n",
av_get_pix_fmt_name(encctx->pix_fmt));
av_get_pix_fmt_name(par->format));
return AVERROR_PATCHWELCOME;
}
xv->image_format = encctx->pix_fmt;
xv->image_format = par->format;
xv->display = XOpenDisplay(xv->display_name);
if (!xv->display) {
@ -132,12 +132,12 @@ static int xv_write_header(AVFormatContext *s)
return AVERROR(EINVAL);
}
xv->image_width = encctx->width;
xv->image_height = encctx->height;
xv->image_width = par->width;
xv->image_height = par->height;
if (!xv->window_width && !xv->window_height) {
AVRational sar = encctx->sample_aspect_ratio;
xv->window_width = encctx->width;
xv->window_height = encctx->height;
AVRational sar = par->sample_aspect_ratio;
xv->window_width = par->width;
xv->window_height = par->height;
if (sar.num) {
if (sar.num > sar.den)
xv->window_width = av_rescale(xv->window_width, sar.num, sar.den);
@ -189,14 +189,14 @@ static int xv_write_header(AVFormatContext *s)
if (j >= num_formats) {
av_log(s, AV_LOG_ERROR,
"Device does not support pixel format %s, aborting\n",
av_get_pix_fmt_name(encctx->pix_fmt));
av_get_pix_fmt_name(par->format));
ret = AVERROR(EINVAL);
goto fail;
}
xv->gc = XCreateGC(xv->display, xv->window, 0, 0);
xv->image_width = encctx->width;
xv->image_height = encctx->height;
xv->image_width = par->width;
xv->image_height = par->height;
xv->yuv_image = XvShmCreateImage(xv->display, xv->xv_port, tag, 0,
xv->image_width, xv->image_height, &xv->yuv_shminfo);
xv->yuv_shminfo.shmid = shmget(IPC_PRIVATE, xv->yuv_image->data_size,
@ -228,11 +228,11 @@ static void compute_display_area(AVFormatContext *s)
XVContext *xv = s->priv_data;
AVRational sar, dar; /* sample and display aspect ratios */
AVStream *st = s->streams[0];
AVCodecContext *encctx = st->codec;
AVCodecParameters *par = st->codecpar;
/* compute overlay width and height from the codec context information */
sar = st->sample_aspect_ratio.num ? st->sample_aspect_ratio : (AVRational){ 1, 1 };
dar = av_mul_q(sar, (AVRational){ encctx->width, encctx->height });
dar = av_mul_q(sar, (AVRational){ par->width, par->height });
/* we suppose the screen has a 1/1 sample aspect ratio */
/* fit in the window */
@ -321,12 +321,12 @@ static int write_picture(AVFormatContext *s, uint8_t *input_data[4],
static int xv_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *ctx = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
uint8_t *data[4];
int linesize[4];
av_image_fill_arrays(data, linesize, pkt->data, ctx->pix_fmt,
ctx->width, ctx->height, 1);
av_image_fill_arrays(data, linesize, pkt->data, par->format,
par->width, par->height, 1);
return write_picture(s, data, linesize);
}

View File

@ -61,17 +61,17 @@ static int threedostr_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->sample_rate = avio_rb32(s->pb);
st->codec->channels = avio_rb32(s->pb);
if (st->codec->channels <= 0)
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->sample_rate = avio_rb32(s->pb);
st->codecpar->channels = avio_rb32(s->pb);
if (st->codecpar->channels <= 0)
return AVERROR_INVALIDDATA;
codec = avio_rl32(s->pb);
avio_skip(s->pb, 4);
if (ctrl_size == 20 || ctrl_size == 3 || ctrl_size == -1)
st->duration = (avio_rb32(s->pb) - 1) / st->codec->channels;
st->duration = (avio_rb32(s->pb) - 1) / st->codecpar->channels;
else
st->duration = avio_rb32(s->pb) * 16 / st->codec->channels;
st->duration = avio_rb32(s->pb) * 16 / st->codecpar->channels;
size -= 56;
found_shdr = 1;
break;
@ -95,15 +95,15 @@ static int threedostr_read_header(AVFormatContext *s)
switch (codec) {
case MKTAG('S','D','X','2'):
st->codec->codec_id = AV_CODEC_ID_SDX2_DPCM;
st->codec->block_align = 1 * st->codec->channels;
st->codecpar->codec_id = AV_CODEC_ID_SDX2_DPCM;
st->codecpar->block_align = 1 * st->codecpar->channels;
break;
default:
avpriv_request_sample(s, "codec %X", codec);
return AVERROR_PATCHWELCOME;
}
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
@ -142,7 +142,7 @@ static int threedostr_read_packet(AVFormatContext *s, AVPacket *pkt)
ret = av_get_packet(s->pb, pkt, size);
pkt->pos = pos;
pkt->stream_index = 0;
pkt->duration = size / st->codec->channels;
pkt->duration = size / st->codecpar->channels;
size = 0;
found_ssmp = 1;
break;

View File

@ -108,16 +108,16 @@ static int parse_vtrk(AVFormatContext *s,
fourxm->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_4XM;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_4XM;
st->codec->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
st->codecpar->extradata = av_mallocz(4 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = 4;
AV_WL32(st->codec->extradata, AV_RL32(buf + 16));
st->codec->width = AV_RL32(buf + 36);
st->codec->height = AV_RL32(buf + 40);
st->codecpar->extradata_size = 4;
AV_WL32(st->codecpar->extradata, AV_RL32(buf + 16));
st->codecpar->width = AV_RL32(buf + 36);
st->codecpar->height = AV_RL32(buf + 40);
return 0;
}
@ -173,23 +173,23 @@ static int parse_strk(AVFormatContext *s,
fourxm->tracks[track].stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = 0;
st->codec->channels = fourxm->tracks[track].channels;
st->codec->sample_rate = fourxm->tracks[track].sample_rate;
st->codec->bits_per_coded_sample = fourxm->tracks[track].bits;
st->codec->bit_rate = st->codec->channels *
st->codec->sample_rate *
st->codec->bits_per_coded_sample;
st->codec->block_align = st->codec->channels *
st->codec->bits_per_coded_sample;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_tag = 0;
st->codecpar->channels = fourxm->tracks[track].channels;
st->codecpar->sample_rate = fourxm->tracks[track].sample_rate;
st->codecpar->bits_per_coded_sample = fourxm->tracks[track].bits;
st->codecpar->bit_rate = st->codecpar->channels *
st->codecpar->sample_rate *
st->codecpar->bits_per_coded_sample;
st->codecpar->block_align = st->codecpar->channels *
st->codecpar->bits_per_coded_sample;
if (fourxm->tracks[track].adpcm){
st->codec->codec_id = AV_CODEC_ID_ADPCM_4XM;
} else if (st->codec->bits_per_coded_sample == 8) {
st->codec->codec_id = AV_CODEC_ID_PCM_U8;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_4XM;
} else if (st->codecpar->bits_per_coded_sample == 8) {
st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
} else
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
return 0;
}

View File

@ -26,7 +26,7 @@
static int a64_write_header(AVFormatContext *s)
{
AVCodecContext *avctx = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
uint8_t header[5] = {
0x00, //load
0x40, //address
@ -35,20 +35,20 @@ static int a64_write_header(AVFormatContext *s)
0x00 //fps in 50/fps;
};
if (avctx->extradata_size < 4) {
if (par->extradata_size < 4) {
av_log(s, AV_LOG_ERROR, "Missing extradata\n");
return AVERROR_INVALIDDATA;
}
switch (avctx->codec_id) {
switch (par->codec_id) {
case AV_CODEC_ID_A64_MULTI:
header[2] = 0x00;
header[3] = AV_RB32(avctx->extradata+0);
header[3] = AV_RB32(par->extradata+0);
header[4] = 2;
break;
case AV_CODEC_ID_A64_MULTI5:
header[2] = 0x01;
header[3] = AV_RB32(avctx->extradata+0);
header[3] = AV_RB32(par->extradata+0);
header[4] = 3;
break;
default:

View File

@ -84,8 +84,8 @@ static int adts_aac_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s->iformat->raw_codec_id;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = s->iformat->raw_codec_id;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
ff_id3v1_read(s);

View File

@ -173,22 +173,22 @@ static int aa_read_header(AVFormatContext *s)
av_freep(&c->tea_ctx);
return AVERROR(ENOMEM);
}
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
if (!strcmp(codec_name, "mp332")) {
st->codec->codec_id = AV_CODEC_ID_MP3;
st->codec->sample_rate = 22050;
st->codecpar->codec_id = AV_CODEC_ID_MP3;
st->codecpar->sample_rate = 22050;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
st->start_time = 0;
} else if (!strcmp(codec_name, "acelp85")) {
st->codec->codec_id = AV_CODEC_ID_SIPR;
st->codec->block_align = 19;
st->codec->channels = 1;
st->codec->sample_rate = 8500;
st->codecpar->codec_id = AV_CODEC_ID_SIPR;
st->codecpar->block_align = 19;
st->codecpar->channels = 1;
st->codecpar->sample_rate = 8500;
} else if (!strcmp(codec_name, "acelp16")) {
st->codec->codec_id = AV_CODEC_ID_SIPR;
st->codec->block_align = 20;
st->codec->channels = 1;
st->codec->sample_rate = 16000;
st->codecpar->codec_id = AV_CODEC_ID_SIPR;
st->codecpar->block_align = 20;
st->codecpar->channels = 1;
st->codecpar->sample_rate = 16000;
}
/* determine, and jump to audio start offset */

View File

@ -41,24 +41,24 @@ static int acm_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_INTERPLAY_ACM;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_INTERPLAY_ACM;
ff_alloc_extradata(st->codec, 14);
if (!st->codec->extradata)
ff_alloc_extradata(st->codecpar, 14);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
ret = avio_read(s->pb, st->codec->extradata, 14);
ret = avio_read(s->pb, st->codecpar->extradata, 14);
if (ret < 10)
return ret < 0 ? ret : AVERROR_EOF;
st->codec->channels = AV_RL16(st->codec->extradata + 8);
st->codec->sample_rate = AV_RL16(st->codec->extradata + 10);
if (st->codec->channels <= 0 || st->codec->sample_rate <= 0)
st->codecpar->channels = AV_RL16(st->codecpar->extradata + 8);
st->codecpar->sample_rate = AV_RL16(st->codecpar->extradata + 10);
if (st->codecpar->channels <= 0 || st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
st->start_time = 0;
st->duration = AV_RL32(st->codec->extradata + 4) / st->codec->channels;
st->duration = AV_RL32(st->codecpar->extradata + 4) / st->codecpar->channels;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}

View File

@ -75,29 +75,29 @@ static int read_header(AVFormatContext *s)
avio_skip(pb, 16);
size=avio_rl32(pb);
ff_get_wav_header(s, pb, st->codec, size, 0);
ff_get_wav_header(s, pb, st->codecpar, size, 0);
/*
8000Hz (Fine-rec) file format has 10 bytes long
packets with 10ms of sound data in them
*/
if (st->codec->sample_rate != 8000) {
av_log(s, AV_LOG_ERROR, "Sample rate %d is not supported.\n", st->codec->sample_rate);
if (st->codecpar->sample_rate != 8000) {
av_log(s, AV_LOG_ERROR, "Sample rate %d is not supported.\n", st->codecpar->sample_rate);
return AVERROR_INVALIDDATA;
}
st->codec->frame_size=80;
st->codec->channels=1;
st->codecpar->frame_size=80;
st->codecpar->channels=1;
avpriv_set_pts_info(st, 64, 1, 100);
st->codec->codec_id=AV_CODEC_ID_G729;
st->codecpar->codec_id=AV_CODEC_ID_G729;
avio_seek(pb, 257, SEEK_SET);
msec=avio_rl16(pb);
sec=avio_r8(pb);
min=avio_rl32(pb);
st->duration = av_rescale(1000*(min*60+sec)+msec, st->codec->sample_rate, 1000 * st->codec->frame_size);
st->duration = av_rescale(1000*(min*60+sec)+msec, st->codecpar->sample_rate, 1000 * st->codecpar->frame_size);
ctx->bytes_left_in_chunk=CHUNK_SIZE;
@ -113,10 +113,10 @@ static int read_packet(AVFormatContext *s,
ACTContext *ctx = s->priv_data;
AVIOContext *pb = s->pb;
int ret;
int frame_size=s->streams[0]->codec->sample_rate==8000?10:22;
int frame_size=s->streams[0]->codecpar->sample_rate==8000?10:22;
if(s->streams[0]->codec->sample_rate==8000)
if(s->streams[0]->codecpar->sample_rate==8000)
ret=av_new_packet(pkt, 10);
else
ret=av_new_packet(pkt, 11);
@ -124,7 +124,7 @@ static int read_packet(AVFormatContext *s,
if(ret)
return ret;
if(s->streams[0]->codec->sample_rate==4400 && !ctx->second_packet)
if(s->streams[0]->codecpar->sample_rate==4400 && !ctx->second_packet)
{
ret = avio_read(pb, ctx->audio_buffer, frame_size);
@ -147,7 +147,7 @@ static int read_packet(AVFormatContext *s,
ctx->second_packet=1;
}
else if(s->streams[0]->codec->sample_rate==4400 && ctx->second_packet)
else if(s->streams[0]->codecpar->sample_rate==4400 && ctx->second_packet)
{
pkt->data[0]=ctx->audio_buffer[5];
pkt->data[1]=ctx->audio_buffer[17];

View File

@ -53,16 +53,16 @@ static int adp_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ADPCM_DTK;
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codec->channels = 2;
st->codec->sample_rate = 48000;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_DTK;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->channels = 2;
st->codecpar->sample_rate = 48000;
st->start_time = 0;
if (s->pb->seekable)
st->duration = av_get_audio_frame_duration(st->codec, avio_size(s->pb));
st->duration = av_get_audio_frame_duration2(st->codecpar, avio_size(s->pb));
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}

View File

@ -42,39 +42,39 @@ static int ads_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_skip(s->pb, 8);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
codec = avio_rl32(s->pb);
st->codec->sample_rate = avio_rl32(s->pb);
if (st->codec->sample_rate <= 0)
st->codecpar->sample_rate = avio_rl32(s->pb);
if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
st->codec->channels = avio_rl32(s->pb);
if (st->codec->channels <= 0)
st->codecpar->channels = avio_rl32(s->pb);
if (st->codecpar->channels <= 0)
return AVERROR_INVALIDDATA;
align = avio_rl32(s->pb);
if (align <= 0 || align > INT_MAX / st->codec->channels)
if (align <= 0 || align > INT_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
if (codec == 1)
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR;
else
st->codec->codec_id = AV_CODEC_ID_ADPCM_PSX;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX;
st->codec->block_align = st->codec->channels * align;
st->codecpar->block_align = st->codecpar->channels * align;
avio_skip(s->pb, 12);
size = avio_rl32(s->pb);
if (st->codec->codec_id == AV_CODEC_ID_ADPCM_PSX)
st->duration = (size - 0x40) / 16 / st->codec->channels * 28;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
if (st->codecpar->codec_id == AV_CODEC_ID_ADPCM_PSX)
st->duration = (size - 0x40) / 16 / st->codecpar->channels * 28;
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int ads_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *codec = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
int ret;
ret = av_get_packet(s->pb, pkt, codec->block_align);
ret = av_get_packet(s->pb, pkt, par->block_align);
pkt->stream_index = 0;
return ret;
}

View File

@ -97,13 +97,13 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const ui
static int adts_write_header(AVFormatContext *s)
{
ADTSContext *adts = s->priv_data;
AVCodecContext *avc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
if (adts->id3v2tag)
ff_id3v2_write_simple(s, 4, ID3v2_DEFAULT_MAGIC);
if (avc->extradata_size > 0)
return adts_decode_extradata(s, adts, avc->extradata,
avc->extradata_size);
if (par->extradata_size > 0)
return adts_decode_extradata(s, adts, par->extradata,
par->extradata_size);
return 0;
}

View File

@ -50,15 +50,15 @@ static int adx_probe(AVProbeData *p)
static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
{
ADXDemuxerContext *c = s->priv_data;
AVCodecContext *avctx = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
int ret, size;
if (avctx->channels <= 0) {
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", avctx->channels);
if (par->channels <= 0) {
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
return AVERROR_INVALIDDATA;
}
size = BLOCK_SIZE * avctx->channels;
size = BLOCK_SIZE * par->channels;
pkt->pos = avio_tell(s->pb);
pkt->stream_index = 0;
@ -82,37 +82,37 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
static int adx_read_header(AVFormatContext *s)
{
ADXDemuxerContext *c = s->priv_data;
AVCodecContext *avctx;
AVCodecParameters *par;
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avctx = s->streams[0]->codec;
par = s->streams[0]->codecpar;
if (avio_rb16(s->pb) != 0x8000)
return AVERROR_INVALIDDATA;
c->header_size = avio_rb16(s->pb) + 4;
avio_seek(s->pb, -4, SEEK_CUR);
if (ff_get_extradata(avctx, s->pb, c->header_size) < 0)
if (ff_get_extradata(par, s->pb, c->header_size) < 0)
return AVERROR(ENOMEM);
if (avctx->extradata_size < 12) {
if (par->extradata_size < 12) {
av_log(s, AV_LOG_ERROR, "Invalid extradata size.\n");
return AVERROR_INVALIDDATA;
}
avctx->channels = AV_RB8(avctx->extradata + 7);
avctx->sample_rate = AV_RB32(avctx->extradata + 8);
par->channels = AV_RB8 (par->extradata + 7);
par->sample_rate = AV_RB32(par->extradata + 8);
if (avctx->channels <= 0) {
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", avctx->channels);
if (par->channels <= 0) {
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n", par->channels);
return AVERROR_INVALIDDATA;
}
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = s->iformat->raw_codec_id;
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->codec_id = s->iformat->raw_codec_id;
avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, avctx->sample_rate);
avpriv_set_pts_info(st, 64, BLOCK_SAMPLES, par->sample_rate);
return 0;
}

View File

@ -67,29 +67,29 @@ static int aea_read_header(AVFormatContext *s)
/* Parse the amount of channels and skip to pos 2048(0x800) */
avio_skip(s->pb, 264);
st->codec->channels = avio_r8(s->pb);
st->codecpar->channels = avio_r8(s->pb);
avio_skip(s->pb, 1783);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ATRAC1;
st->codec->sample_rate = 44100;
st->codec->bit_rate = 292000;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ATRAC1;
st->codecpar->sample_rate = 44100;
st->codecpar->bit_rate = 292000;
if (st->codec->channels != 1 && st->codec->channels != 2) {
av_log(s,AV_LOG_ERROR,"Channels %d not supported!\n",st->codec->channels);
if (st->codecpar->channels != 1 && st->codecpar->channels != 2) {
av_log(s, AV_LOG_ERROR, "Channels %d not supported!\n", st->codecpar->channels);
return AVERROR_INVALIDDATA;
}
st->codec->channel_layout = (st->codec->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
st->codecpar->channel_layout = (st->codecpar->channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
st->codec->block_align = AT1_SU_SIZE * st->codec->channels;
st->codecpar->block_align = AT1_SU_SIZE * st->codecpar->channels;
return 0;
}
static int aea_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret = av_get_packet(s->pb, pkt, s->streams[0]->codec->block_align);
int ret = av_get_packet(s->pb, pkt, s->streams[0]->codecpar->block_align);
pkt->stream_index = 0;
if (ret <= 0)

View File

@ -35,20 +35,20 @@ static int afc_read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ADPCM_AFC;
st->codec->channels = 2;
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_AFC;
st->codecpar->channels = 2;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
if (ff_alloc_extradata(st->codec, 1))
if (ff_alloc_extradata(st->codecpar, 1))
return AVERROR(ENOMEM);
st->codec->extradata[0] = 8 * st->codec->channels;
st->codecpar->extradata[0] = 8 * st->codecpar->channels;
c->data_end = avio_rb32(s->pb) + 32LL;
st->duration = avio_rb32(s->pb);
st->codec->sample_rate = avio_rb16(s->pb);
st->codecpar->sample_rate = avio_rb16(s->pb);
avio_skip(s->pb, 22);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}

View File

@ -95,7 +95,7 @@ static int get_aiff_header(AVFormatContext *s, int size,
unsigned version)
{
AVIOContext *pb = s->pb;
AVCodecContext *codec = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
AIFFInputContext *aiff = s->priv_data;
int exp;
uint64_t val;
@ -104,10 +104,10 @@ static int get_aiff_header(AVFormatContext *s, int size,
if (size & 1)
size++;
codec->codec_type = AVMEDIA_TYPE_AUDIO;
codec->channels = avio_rb16(pb);
par->codec_type = AVMEDIA_TYPE_AUDIO;
par->channels = avio_rb16(pb);
num_frames = avio_rb32(pb);
codec->bits_per_coded_sample = avio_rb16(pb);
par->bits_per_coded_sample = avio_rb16(pb);
exp = avio_rb16(pb) - 16383 - 63;
val = avio_rb64(pb);
@ -119,29 +119,29 @@ static int get_aiff_header(AVFormatContext *s, int size,
sample_rate = val << exp;
else
sample_rate = (val + (1ULL<<(-exp-1))) >> -exp;
codec->sample_rate = sample_rate;
par->sample_rate = sample_rate;
size -= 18;
/* get codec id for AIFF-C */
if (size < 4) {
version = AIFF;
} else if (version == AIFF_C_VERSION1) {
codec->codec_tag = avio_rl32(pb);
codec->codec_id = ff_codec_get_id(ff_codec_aiff_tags, codec->codec_tag);
if (codec->codec_id == AV_CODEC_ID_NONE) {
par->codec_tag = avio_rl32(pb);
par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag);
if (par->codec_id == AV_CODEC_ID_NONE) {
char tag[32];
av_get_codec_tag_string(tag, sizeof(tag), codec->codec_tag);
av_get_codec_tag_string(tag, sizeof(tag), par->codec_tag);
avpriv_request_sample(s, "unknown or unsupported codec tag: %s", tag);
}
size -= 4;
}
if (version != AIFF_C_VERSION1 || codec->codec_id == AV_CODEC_ID_PCM_S16BE) {
codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
if (version != AIFF_C_VERSION1 || par->codec_id == AV_CODEC_ID_PCM_S16BE) {
par->codec_id = aiff_codec_get_id(par->bits_per_coded_sample);
par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
aiff->block_duration = 1;
} else {
switch (codec->codec_id) {
switch (par->codec_id) {
case AV_CODEC_ID_PCM_F32BE:
case AV_CODEC_ID_PCM_F64BE:
case AV_CODEC_ID_PCM_S16LE:
@ -150,38 +150,38 @@ static int get_aiff_header(AVFormatContext *s, int size,
aiff->block_duration = 1;
break;
case AV_CODEC_ID_ADPCM_IMA_QT:
codec->block_align = 34*codec->channels;
par->block_align = 34 * par->channels;
break;
case AV_CODEC_ID_MACE3:
codec->block_align = 2*codec->channels;
par->block_align = 2 * par->channels;
break;
case AV_CODEC_ID_ADPCM_G726LE:
codec->bits_per_coded_sample = 5;
par->bits_per_coded_sample = 5;
case AV_CODEC_ID_ADPCM_IMA_WS:
case AV_CODEC_ID_ADPCM_G722:
case AV_CODEC_ID_MACE6:
case AV_CODEC_ID_SDX2_DPCM:
codec->block_align = 1*codec->channels;
par->block_align = 1 * par->channels;
break;
case AV_CODEC_ID_GSM:
codec->block_align = 33;
par->block_align = 33;
break;
default:
aiff->block_duration = 1;
break;
}
if (codec->block_align > 0)
aiff->block_duration = av_get_audio_frame_duration(codec,
codec->block_align);
if (par->block_align > 0)
aiff->block_duration = av_get_audio_frame_duration2(par,
par->block_align);
}
/* Block align needs to be computed in all cases, as the definition
* is specific to applications -> here we use the WAVE format definition */
if (!codec->block_align)
codec->block_align = (av_get_bits_per_sample(codec->codec_id) * codec->channels) >> 3;
if (!par->block_align)
par->block_align = (av_get_bits_per_sample(par->codec_id) * par->channels) >> 3;
if (aiff->block_duration) {
codec->bit_rate = codec->sample_rate * (codec->block_align << 3) /
par->bit_rate = par->sample_rate * (par->block_align << 3) /
aiff->block_duration;
}
@ -238,7 +238,7 @@ static int aiff_read_header(AVFormatContext *s)
/* parse different chunks */
size = get_tag(pb, &tag);
if (size == AVERROR_EOF && offset > 0 && st->codec->block_align) {
if (size == AVERROR_EOF && offset > 0 && st->codecpar->block_align) {
av_log(s, AV_LOG_WARNING, "header parser hit EOF\n");
goto got_sound;
}
@ -288,7 +288,7 @@ static int aiff_read_header(AVFormatContext *s)
offset = avio_rb32(pb); /* Offset of sound data */
avio_rb32(pb); /* BlockSize... don't care */
offset += avio_tell(pb); /* Compute absolute data offset */
if (st->codec->block_align && !pb->seekable) /* Assume COMM already parsed */
if (st->codecpar->block_align && !pb->seekable) /* Assume COMM already parsed */
goto got_sound;
if (!pb->seekable) {
av_log(s, AV_LOG_ERROR, "file is not seekable\n");
@ -299,25 +299,25 @@ static int aiff_read_header(AVFormatContext *s)
case MKTAG('w', 'a', 'v', 'e'):
if ((uint64_t)size > (1<<30))
return -1;
if (ff_get_extradata(st->codec, pb, size) < 0)
if (ff_get_extradata(st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
if (st->codec->codec_id == AV_CODEC_ID_QDM2 && size>=12*4 && !st->codec->block_align) {
st->codec->block_align = AV_RB32(st->codec->extradata+11*4);
aiff->block_duration = AV_RB32(st->codec->extradata+9*4);
} else if (st->codec->codec_id == AV_CODEC_ID_QCELP) {
if (st->codecpar->codec_id == AV_CODEC_ID_QDM2 && size>=12*4 && !st->codecpar->block_align) {
st->codecpar->block_align = AV_RB32(st->codecpar->extradata+11*4);
aiff->block_duration = AV_RB32(st->codecpar->extradata+9*4);
} else if (st->codecpar->codec_id == AV_CODEC_ID_QCELP) {
char rate = 0;
if (size >= 25)
rate = st->codec->extradata[24];
rate = st->codecpar->extradata[24];
switch (rate) {
case 'H': // RATE_HALF
st->codec->block_align = 17;
st->codecpar->block_align = 17;
break;
case 'F': // RATE_FULL
default:
st->codec->block_align = 35;
st->codecpar->block_align = 35;
}
aiff->block_duration = 160;
st->codec->bit_rate = st->codec->sample_rate * (st->codec->block_align << 3) /
st->codecpar->bit_rate = st->codecpar->sample_rate * (st->codecpar->block_align << 3) /
aiff->block_duration;
}
break;
@ -326,7 +326,7 @@ static int aiff_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
break;
case 0:
if (offset > 0 && st->codec->block_align) // COMM && SSND
if (offset > 0 && st->codecpar->block_align) // COMM && SSND
goto got_sound;
default: /* Jump */
if (size & 1) /* Always even aligned */
@ -336,13 +336,13 @@ static int aiff_read_header(AVFormatContext *s)
}
got_sound:
if (!st->codec->block_align) {
if (!st->codecpar->block_align) {
av_log(s, AV_LOG_ERROR, "could not find COMM tag or invalid block_align value\n");
return -1;
}
/* Now positioned, get the sound data start and end */
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
st->start_time = 0;
st->duration = st->nb_frames * aiff->block_duration;
@ -368,26 +368,26 @@ static int aiff_read_packet(AVFormatContext *s,
return AVERROR_EOF;
/* Now for that packet */
switch (st->codec->codec_id) {
switch (st->codecpar->codec_id) {
case AV_CODEC_ID_ADPCM_IMA_QT:
case AV_CODEC_ID_GSM:
case AV_CODEC_ID_QDM2:
case AV_CODEC_ID_QCELP:
size = st->codec->block_align;
size = st->codecpar->block_align;
break;
default:
size = (MAX_SIZE / st->codec->block_align) * st->codec->block_align;
size = (MAX_SIZE / st->codecpar->block_align) * st->codecpar->block_align;
}
size = FFMIN(max_size, size);
res = av_get_packet(s->pb, pkt, size);
if (res < 0)
return res;
if (size >= st->codec->block_align)
if (size >= st->codecpar->block_align)
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
/* Only one stream in an AIFF file */
pkt->stream_index = 0;
pkt->duration = (res / st->codec->block_align) * aiff->block_duration;
pkt->duration = (res / st->codecpar->block_align) * aiff->block_duration;
return 0;
}

View File

@ -102,16 +102,16 @@ static int aiff_write_header(AVFormatContext *s)
{
AIFFOutputContext *aiff = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc;
AVCodecParameters *par;
uint64_t sample_rate;
int i, aifc = 0;
aiff->audio_stream_idx = -1;
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (aiff->audio_stream_idx < 0 && st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (aiff->audio_stream_idx < 0 && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
aiff->audio_stream_idx = i;
} else if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO) {
} else if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) {
av_log(s, AV_LOG_ERROR, "AIFF allows only one audio stream and a picture.\n");
return AVERROR(EINVAL);
}
@ -121,12 +121,12 @@ static int aiff_write_header(AVFormatContext *s)
return AVERROR(EINVAL);
}
enc = s->streams[aiff->audio_stream_idx]->codec;
par = s->streams[aiff->audio_stream_idx]->codecpar;
/* First verify if format is ok */
if (!enc->codec_tag)
if (!par->codec_tag)
return -1;
if (enc->codec_tag != MKTAG('N','O','N','E'))
if (par->codec_tag != MKTAG('N','O','N','E'))
aifc = 1;
/* FORM AIFF header */
@ -136,7 +136,7 @@ static int aiff_write_header(AVFormatContext *s)
ffio_wfourcc(pb, aifc ? "AIFC" : "AIFF");
if (aifc) { // compressed audio
if (!enc->block_align) {
if (!par->block_align) {
av_log(s, AV_LOG_ERROR, "block align not set\n");
return -1;
}
@ -146,10 +146,10 @@ static int aiff_write_header(AVFormatContext *s)
avio_wb32(pb, 0xA2805140);
}
if (enc->channels > 2 && enc->channel_layout) {
if (par->channels > 2 && par->channel_layout) {
ffio_wfourcc(pb, "CHAN");
avio_wb32(pb, 12);
ff_mov_write_chan(pb, enc->channel_layout);
ff_mov_write_chan(pb, par->channel_layout);
}
put_meta(s, "title", MKTAG('N', 'A', 'M', 'E'));
@ -160,35 +160,35 @@ static int aiff_write_header(AVFormatContext *s)
/* Common chunk */
ffio_wfourcc(pb, "COMM");
avio_wb32(pb, aifc ? 24 : 18); /* size */
avio_wb16(pb, enc->channels); /* Number of channels */
avio_wb16(pb, par->channels); /* Number of channels */
aiff->frames = avio_tell(pb);
avio_wb32(pb, 0); /* Number of frames */
if (!enc->bits_per_coded_sample)
enc->bits_per_coded_sample = av_get_bits_per_sample(enc->codec_id);
if (!enc->bits_per_coded_sample) {
if (!par->bits_per_coded_sample)
par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id);
if (!par->bits_per_coded_sample) {
av_log(s, AV_LOG_ERROR, "could not compute bits per sample\n");
return -1;
}
if (!enc->block_align)
enc->block_align = (enc->bits_per_coded_sample * enc->channels) >> 3;
if (!par->block_align)
par->block_align = (par->bits_per_coded_sample * par->channels) >> 3;
avio_wb16(pb, enc->bits_per_coded_sample); /* Sample size */
avio_wb16(pb, par->bits_per_coded_sample); /* Sample size */
sample_rate = av_double2int(enc->sample_rate);
sample_rate = av_double2int(par->sample_rate);
avio_wb16(pb, (sample_rate >> 52) + (16383 - 1023));
avio_wb64(pb, UINT64_C(1) << 63 | sample_rate << 11);
if (aifc) {
avio_wl32(pb, enc->codec_tag);
avio_wl32(pb, par->codec_tag);
avio_wb16(pb, 0);
}
if (enc->codec_tag == MKTAG('Q','D','M','2') && enc->extradata_size) {
if (par->codec_tag == MKTAG('Q','D','M','2') && par->extradata_size) {
ffio_wfourcc(pb, "wave");
avio_wb32(pb, enc->extradata_size);
avio_write(pb, enc->extradata, enc->extradata_size);
avio_wb32(pb, par->extradata_size);
avio_write(pb, par->extradata, par->extradata_size);
}
/* Sound data chunk */
@ -199,7 +199,7 @@ static int aiff_write_header(AVFormatContext *s)
avio_wb32(pb, 0); /* Block-size (block align) */
avpriv_set_pts_info(s->streams[aiff->audio_stream_idx], 64, 1,
s->streams[aiff->audio_stream_idx]->codec->sample_rate);
s->streams[aiff->audio_stream_idx]->codecpar->sample_rate);
/* Data is starting here */
avio_flush(pb);
@ -217,7 +217,7 @@ static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret;
AVPacketList *pict_list, *last;
if (s->streams[pkt->stream_index]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
if (s->streams[pkt->stream_index]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
return 0;
/* warn only once for each stream */
@ -256,7 +256,7 @@ static int aiff_write_trailer(AVFormatContext *s)
AVIOContext *pb = s->pb;
AIFFOutputContext *aiff = s->priv_data;
AVPacketList *pict_list = aiff->pict_list;
AVCodecContext *enc = s->streams[aiff->audio_stream_idx]->codec;
AVCodecParameters *par = s->streams[aiff->audio_stream_idx]->codecpar;
/* Chunks sizes must be even */
int64_t file_size, end_size;
@ -269,7 +269,7 @@ static int aiff_write_trailer(AVFormatContext *s)
if (s->pb->seekable) {
/* Number of sample frames */
avio_seek(pb, aiff->frames, SEEK_SET);
avio_wb32(pb, (file_size-aiff->ssnd-12)/enc->block_align);
avio_wb32(pb, (file_size - aiff->ssnd - 12) / par->block_align);
/* Sound Data chunk size */
avio_seek(pb, aiff->ssnd, SEEK_SET);

View File

@ -61,11 +61,11 @@ static int aix_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ADPCM_ADX;
st->codec->sample_rate = avio_rb32(s->pb);
st->codec->channels = avio_r8(s->pb);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_ADX;
st->codecpar->sample_rate = avio_rb32(s->pb);
st->codecpar->channels = avio_r8(s->pb);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
avio_skip(s->pb, 3);
}
@ -77,7 +77,7 @@ static int aix_read_header(AVFormatContext *s)
if (size <= 8)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 8);
ff_get_extradata(s->streams[i]->codec, s->pb, size - 8);
ff_get_extradata(s->streams[i]->codecpar, s->pb, size - 8);
}
return 0;

View File

@ -42,13 +42,13 @@ static const char AMRWB_header[] = "#!AMR-WB\n";
static int amr_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
s->priv_data = NULL;
if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
if (par->codec_id == AV_CODEC_ID_AMR_NB) {
avio_write(pb, AMR_header, sizeof(AMR_header) - 1); /* magic number */
} else if (enc->codec_id == AV_CODEC_ID_AMR_WB) {
} else if (par->codec_id == AV_CODEC_ID_AMR_WB) {
avio_write(pb, AMRWB_header, sizeof(AMRWB_header) - 1); /* magic number */
} else {
return -1;
@ -94,25 +94,25 @@ static int amr_read_header(AVFormatContext *s)
return -1;
}
st->codec->codec_tag = MKTAG('s', 'a', 'w', 'b');
st->codec->codec_id = AV_CODEC_ID_AMR_WB;
st->codec->sample_rate = 16000;
st->codecpar->codec_tag = MKTAG('s', 'a', 'w', 'b');
st->codecpar->codec_id = AV_CODEC_ID_AMR_WB;
st->codecpar->sample_rate = 16000;
} else {
st->codec->codec_tag = MKTAG('s', 'a', 'm', 'r');
st->codec->codec_id = AV_CODEC_ID_AMR_NB;
st->codec->sample_rate = 8000;
st->codecpar->codec_tag = MKTAG('s', 'a', 'm', 'r');
st->codecpar->codec_id = AV_CODEC_ID_AMR_NB;
st->codecpar->sample_rate = 8000;
}
st->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
int read, size = 0, toc, mode;
int64_t pos = avio_tell(s->pb);
AMRContext *amr = s->priv_data;
@ -125,13 +125,13 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
toc = avio_r8(s->pb);
mode = (toc >> 3) & 0x0F;
if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
if (par->codec_id == AV_CODEC_ID_AMR_NB) {
static const uint8_t packed_size[16] = {
12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0
};
size = packed_size[mode] + 1;
} else if (enc->codec_id == AV_CODEC_ID_AMR_WB) {
} else if (par->codec_id == AV_CODEC_ID_AMR_WB) {
static const uint8_t packed_size[16] = {
18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1
};
@ -145,13 +145,13 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt)
if (amr->cumulated_size < UINT64_MAX - size) {
amr->cumulated_size += size;
/* Both AMR formats have 50 frames per second */
s->streams[0]->codec->bit_rate = amr->cumulated_size / ++amr->block_count * 8 * 50;
s->streams[0]->codecpar->bit_rate = amr->cumulated_size / ++amr->block_count * 8 * 50;
}
pkt->stream_index = 0;
pkt->pos = pos;
pkt->data[0] = toc;
pkt->duration = enc->codec_id == AV_CODEC_ID_AMR_NB ? 160 : 320;
pkt->duration = par->codec_id == AV_CODEC_ID_AMR_NB ? 160 : 320;
read = avio_read(s->pb, pkt->data + 1, size - 1);
if (read != size - 1) {

View File

@ -100,11 +100,11 @@ static int read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_ANM;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = avio_rl16(pb);
st->codec->height = avio_rl16(pb);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_ANM;
st->codecpar->codec_tag = 0; /* no fourcc */
st->codecpar->width = avio_rl16(pb);
st->codecpar->height = avio_rl16(pb);
if (avio_r8(pb) != 0)
goto invalid;
avio_skip(pb, 1); /* frame rate multiplier info */
@ -132,12 +132,12 @@ static int read_header(AVFormatContext *s)
avio_skip(pb, 58);
/* color cycling and palette data */
st->codec->extradata_size = 16*8 + 4*256;
st->codec->extradata = av_mallocz(st->codec->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata) {
st->codecpar->extradata_size = 16*8 + 4*256;
st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata) {
return AVERROR(ENOMEM);
}
ret = avio_read(pb, st->codec->extradata, st->codec->extradata_size);
ret = avio_read(pb, st->codecpar->extradata, st->codecpar->extradata_size);
if (ret < 0)
return ret;

View File

@ -46,28 +46,28 @@ static int apc_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_APC;
avio_rl32(pb); /* number of samples */
st->codec->sample_rate = avio_rl32(pb);
st->codecpar->sample_rate = avio_rl32(pb);
/* initial predictor values for adpcm decoder */
if (ff_get_extradata(st->codec, pb, 2 * 4) < 0)
if (ff_get_extradata(st->codecpar, pb, 2 * 4) < 0)
return AVERROR(ENOMEM);
if (avio_rl32(pb)) {
st->codec->channels = 2;
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->channels = 2;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
} else {
st->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
}
st->codec->bits_per_coded_sample = 4;
st->codec->bit_rate = st->codec->bits_per_coded_sample * st->codec->channels
* st->codec->sample_rate;
st->codec->block_align = 1;
st->codecpar->bits_per_coded_sample = 4;
st->codecpar->bit_rate = st->codecpar->bits_per_coded_sample * st->codecpar->channels
* st->codecpar->sample_rate;
st->codecpar->block_align = 1;
return 0;
}

View File

@ -348,23 +348,23 @@ static int ape_read_header(AVFormatContext * s)
total_blocks = (ape->totalframes == 0) ? 0 : ((ape->totalframes - 1) * ape->blocksperframe) + ape->finalframeblocks;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_APE;
st->codec->codec_tag = MKTAG('A', 'P', 'E', ' ');
st->codec->channels = ape->channels;
st->codec->sample_rate = ape->samplerate;
st->codec->bits_per_coded_sample = ape->bps;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_APE;
st->codecpar->codec_tag = MKTAG('A', 'P', 'E', ' ');
st->codecpar->channels = ape->channels;
st->codecpar->sample_rate = ape->samplerate;
st->codecpar->bits_per_coded_sample = ape->bps;
st->nb_frames = ape->totalframes;
st->start_time = 0;
st->duration = total_blocks;
avpriv_set_pts_info(st, 64, 1, ape->samplerate);
if (ff_alloc_extradata(st->codec, APE_EXTRADATA_SIZE))
if (ff_alloc_extradata(st->codecpar, APE_EXTRADATA_SIZE))
return AVERROR(ENOMEM);
AV_WL16(st->codec->extradata + 0, ape->fileversion);
AV_WL16(st->codec->extradata + 2, ape->compressiontype);
AV_WL16(st->codec->extradata + 4, ape->formatflags);
AV_WL16(st->codecpar->extradata + 0, ape->fileversion);
AV_WL16(st->codecpar->extradata + 2, ape->compressiontype);
AV_WL16(st->codecpar->extradata + 4, ape->formatflags);
pts = 0;
for (i = 0; i < ape->totalframes; i++) {

View File

@ -89,16 +89,16 @@ static int ape_tag_read_field(AVFormatContext *s)
}
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = id;
st->attached_pic = pkt;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
} else {
if (ff_get_extradata(st->codec, s->pb, size) < 0)
if (ff_get_extradata(st->codecpar, s->pb, size) < 0)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
st->codecpar->codec_type = AVMEDIA_TYPE_ATTACHMENT;
}
} else {
value = av_malloc(size+1);

View File

@ -122,9 +122,9 @@ end:
return AVPROBE_SCORE_MAX;
}
static int append_extradata(AVCodecContext *s, AVIOContext *pb, int len)
static int append_extradata(AVCodecParameters *par, AVIOContext *pb, int len)
{
int previous_size = s->extradata_size;
int previous_size = par->extradata_size;
int new_size, ret;
uint8_t *new_extradata;
@ -132,13 +132,13 @@ static int append_extradata(AVCodecContext *s, AVIOContext *pb, int len)
return AVERROR_INVALIDDATA;
new_size = previous_size + len;
new_extradata = av_realloc(s->extradata, new_size + AV_INPUT_BUFFER_PADDING_SIZE);
new_extradata = av_realloc(par->extradata, new_size + AV_INPUT_BUFFER_PADDING_SIZE);
if (!new_extradata)
return AVERROR(ENOMEM);
s->extradata = new_extradata;
s->extradata_size = new_size;
par->extradata = new_extradata;
par->extradata_size = new_size;
if ((ret = avio_read(pb, s->extradata + previous_size, len)) < 0)
if ((ret = avio_read(pb, par->extradata + previous_size, len)) < 0)
return ret;
return previous_size;
@ -170,23 +170,23 @@ static int apng_read_header(AVFormatContext *s)
/* set the timebase to something large enough (1/100,000 of second)
* to hopefully cope with all sane frame durations */
avpriv_set_pts_info(st, 64, 1, 100000);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_APNG;
st->codec->width = avio_rb32(pb);
st->codec->height = avio_rb32(pb);
if ((ret = av_image_check_size(st->codec->width, st->codec->height, 0, s)) < 0)
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_APNG;
st->codecpar->width = avio_rb32(pb);
st->codecpar->height = avio_rb32(pb);
if ((ret = av_image_check_size(st->codecpar->width, st->codecpar->height, 0, s)) < 0)
return ret;
/* extradata will contain every chunk up to the first fcTL (excluded) */
st->codec->extradata = av_malloc(len + 12 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
st->codecpar->extradata = av_malloc(len + 12 + AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
st->codec->extradata_size = len + 12;
AV_WB32(st->codec->extradata, len);
AV_WL32(st->codec->extradata+4, tag);
AV_WB32(st->codec->extradata+8, st->codec->width);
AV_WB32(st->codec->extradata+12, st->codec->height);
if ((ret = avio_read(pb, st->codec->extradata+16, 9)) < 0)
st->codecpar->extradata_size = len + 12;
AV_WB32(st->codecpar->extradata, len);
AV_WL32(st->codecpar->extradata+4, tag);
AV_WB32(st->codecpar->extradata+8, st->codecpar->width);
AV_WB32(st->codecpar->extradata+12, st->codecpar->height);
if ((ret = avio_read(pb, st->codecpar->extradata+16, 9)) < 0)
goto fail;
while (!avio_feof(pb)) {
@ -218,11 +218,11 @@ static int apng_read_header(AVFormatContext *s)
switch (tag) {
case MKTAG('a', 'c', 'T', 'L'):
if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
(ret = append_extradata(st->codec, pb, len + 12)) < 0)
(ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
goto fail;
acTL_found = 1;
ctx->num_frames = AV_RB32(st->codec->extradata + ret + 8);
ctx->num_play = AV_RB32(st->codec->extradata + ret + 12);
ctx->num_frames = AV_RB32(st->codecpar->extradata + ret + 8);
ctx->num_play = AV_RB32(st->codecpar->extradata + ret + 12);
av_log(s, AV_LOG_DEBUG, "num_frames: %"PRIu32", num_play: %"PRIu32"\n",
ctx->num_frames, ctx->num_play);
break;
@ -236,15 +236,15 @@ static int apng_read_header(AVFormatContext *s)
return 0;
default:
if ((ret = avio_seek(pb, -8, SEEK_CUR)) < 0 ||
(ret = append_extradata(st->codec, pb, len + 12)) < 0)
(ret = append_extradata(st->codecpar, pb, len + 12)) < 0)
goto fail;
}
}
fail:
if (st->codec->extradata_size) {
av_freep(&st->codec->extradata);
st->codec->extradata_size = 0;
if (st->codecpar->extradata_size) {
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = 0;
}
return ret;
}
@ -298,15 +298,15 @@ static int decode_fctl_chunk(AVFormatContext *s, APNGDemuxContext *ctx, AVPacket
dispose_op,
blend_op);
if (width != s->streams[0]->codec->width ||
height != s->streams[0]->codec->height ||
if (width != s->streams[0]->codecpar->width ||
height != s->streams[0]->codecpar->height ||
x_offset != 0 ||
y_offset != 0) {
if (sequence_number == 0 ||
x_offset >= s->streams[0]->codec->width ||
width > s->streams[0]->codec->width - x_offset ||
y_offset >= s->streams[0]->codec->height ||
height > s->streams[0]->codec->height - y_offset)
x_offset >= s->streams[0]->codecpar->width ||
width > s->streams[0]->codecpar->width - x_offset ||
y_offset >= s->streams[0]->codecpar->height ||
height > s->streams[0]->codecpar->height - y_offset)
return AVERROR_INVALIDDATA;
ctx->is_key_frame = 0;
} else {
@ -400,7 +400,7 @@ static int apng_read_packet(AVFormatContext *s, AVPacket *pkt)
avio_seek(pb, -8, SEEK_CUR);
return AVERROR_EOF;
}
if ((ret = avio_seek(pb, s->streams[0]->codec->extradata_size + 8, SEEK_SET)) < 0)
if ((ret = avio_seek(pb, s->streams[0]->codecpar->extradata_size + 8, SEEK_SET)) < 0)
return ret;
return 0;
default:

View File

@ -80,8 +80,8 @@ static int apng_write_header(AVFormatContext *format_context)
APNGMuxContext *apng = format_context->priv_data;
if (format_context->nb_streams != 1 ||
format_context->streams[0]->codec->codec_type != AVMEDIA_TYPE_VIDEO ||
format_context->streams[0]->codec->codec_id != AV_CODEC_ID_APNG) {
format_context->streams[0]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ||
format_context->streams[0]->codecpar->codec_id != AV_CODEC_ID_APNG) {
av_log(format_context, AV_LOG_ERROR,
"APNG muxer supports only a single video APNG stream.\n");
return AVERROR(EINVAL);
@ -106,7 +106,7 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
APNGMuxContext *apng = format_context->priv_data;
AVIOContext *io_context = format_context->pb;
AVStream *codec_stream = format_context->streams[0];
AVCodecContext *codec_context = codec_stream->codec;
AVCodecParameters *codec_par = codec_stream->codecpar;
av_assert0(apng->prev_packet);
@ -117,13 +117,13 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
av_log(format_context, AV_LOG_INFO, "Only a single frame so saving as a normal PNG.\n");
// Write normal PNG headers without acTL chunk
existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_context->extradata, codec_context->extradata_size);
existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_par->extradata, codec_par->extradata_size);
if (existing_acTL_chunk) {
uint8_t *chunk_after_acTL = existing_acTL_chunk + AV_RB32(existing_acTL_chunk) + 12;
avio_write(io_context, codec_context->extradata, existing_acTL_chunk - codec_context->extradata);
avio_write(io_context, chunk_after_acTL, codec_context->extradata + codec_context->extradata_size - chunk_after_acTL);
avio_write(io_context, codec_par->extradata, existing_acTL_chunk - codec_par->extradata);
avio_write(io_context, chunk_after_acTL, codec_par->extradata + codec_par->extradata_size - chunk_after_acTL);
} else {
avio_write(io_context, codec_context->extradata, codec_context->extradata_size);
avio_write(io_context, codec_par->extradata, codec_par->extradata_size);
}
// Write frame data without fcTL chunk
@ -142,9 +142,9 @@ static void flush_packet(AVFormatContext *format_context, AVPacket *packet)
uint8_t *existing_acTL_chunk;
// Write normal PNG headers
avio_write(io_context, codec_context->extradata, codec_context->extradata_size);
avio_write(io_context, codec_par->extradata, codec_par->extradata_size);
existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_context->extradata, codec_context->extradata_size);
existing_acTL_chunk = apng_find_chunk(MKBETAG('a', 'c', 'T', 'L'), codec_par->extradata, codec_par->extradata_size);
if (!existing_acTL_chunk) {
uint8_t buf[8];
// Write animation control header

View File

@ -58,8 +58,8 @@ static int aqt_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, aqt->frame_rate.den, aqt->frame_rate.num);
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = AV_CODEC_ID_TEXT;
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_id = AV_CODEC_ID_TEXT;
while (!avio_feof(s->pb)) {
char line[4096];

View File

@ -281,8 +281,8 @@ static int asf_read_picture(AVFormatContext *s, int len)
goto fail;
}
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = id;
st->attached_pic = pkt;
st->attached_pic.stream_index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
@ -436,7 +436,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
type = AVMEDIA_TYPE_VIDEO;
} else if (!ff_guidcmp(&g, &ff_asf_jfif_media)) {
type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_MJPEG;
st->codecpar->codec_id = AV_CODEC_ID_MJPEG;
} else if (!ff_guidcmp(&g, &ff_asf_command_stream)) {
type = AVMEDIA_TYPE_DATA;
} else if (!ff_guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) {
@ -470,18 +470,18 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
}
}
st->codec->codec_type = type;
st->codecpar->codec_type = type;
if (type == AVMEDIA_TYPE_AUDIO) {
int ret = ff_get_wav_header(s, pb, st->codec, type_specific_size, 0);
int ret = ff_get_wav_header(s, pb, st->codecpar, type_specific_size, 0);
if (ret < 0)
return ret;
if (is_dvr_ms_audio) {
// codec_id and codec_tag are unreliable in dvr_ms
// files. Set them later by probing stream.
st->request_probe = 1;
st->codec->codec_tag = 0;
st->codecpar->codec_tag = 0;
}
if (st->codec->codec_id == AV_CODEC_ID_AAC)
if (st->codecpar->codec_id == AV_CODEC_ID_AAC)
st->need_parsing = AVSTREAM_PARSE_NONE;
else
st->need_parsing = AVSTREAM_PARSE_FULL;
@ -507,52 +507,52 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
avio_r8(pb);
avio_rl16(pb); /* size */
sizeX = avio_rl32(pb); /* size */
st->codec->width = avio_rl32(pb);
st->codec->height = avio_rl32(pb);
st->codecpar->width = avio_rl32(pb);
st->codecpar->height = avio_rl32(pb);
/* not available for asf */
avio_rl16(pb); /* panes */
st->codec->bits_per_coded_sample = avio_rl16(pb); /* depth */
st->codecpar->bits_per_coded_sample = avio_rl16(pb); /* depth */
tag1 = avio_rl32(pb);
avio_skip(pb, 20);
if (sizeX > 40) {
st->codec->extradata_size = ffio_limit(pb, sizeX - 40);
st->codec->extradata = av_mallocz(st->codec->extradata_size +
st->codecpar->extradata_size = ffio_limit(pb, sizeX - 40);
st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
if (!st->codecpar->extradata)
return AVERROR(ENOMEM);
avio_read(pb, st->codec->extradata, st->codec->extradata_size);
avio_read(pb, st->codecpar->extradata, st->codecpar->extradata_size);
}
/* Extract palette from extradata if bpp <= 8 */
/* This code assumes that extradata contains only palette */
/* This is true for all paletted codecs implemented in libavcodec */
if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
if (st->codecpar->extradata_size && (st->codecpar->bits_per_coded_sample <= 8)) {
#if HAVE_BIGENDIAN
int i;
for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE) / 4; i++)
asf_st->palette[i] = av_bswap32(((uint32_t *)st->codec->extradata)[i]);
for (i = 0; i < FFMIN(st->codecpar->extradata_size, AVPALETTE_SIZE) / 4; i++)
asf_st->palette[i] = av_bswap32(((uint32_t *)st->codecpar->extradata)[i]);
#else
memcpy(asf_st->palette, st->codec->extradata,
FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
memcpy(asf_st->palette, st->codecpar->extradata,
FFMIN(st->codecpar->extradata_size, AVPALETTE_SIZE));
#endif
asf_st->palette_changed = 1;
}
st->codec->codec_tag = tag1;
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1);
st->codecpar->codec_tag = tag1;
st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1);
if (tag1 == MKTAG('D', 'V', 'R', ' ')) {
st->need_parsing = AVSTREAM_PARSE_FULL;
/* issue658 contains wrong w/h and MS even puts a fake seq header
* with wrong w/h in extradata while a correct one is in the stream.
* maximum lameness */
st->codec->width =
st->codec->height = 0;
av_freep(&st->codec->extradata);
st->codec->extradata_size = 0;
st->codecpar->width =
st->codecpar->height = 0;
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = 0;
}
if (st->codec->codec_id == AV_CODEC_ID_H264)
if (st->codecpar->codec_id == AV_CODEC_ID_H264)
st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
if (st->codec->codec_id == AV_CODEC_ID_MPEG4)
if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4)
st->need_parsing = AVSTREAM_PARSE_FULL_ONCE;
}
pos2 = avio_tell(pb);
@ -890,21 +890,21 @@ static int asf_read_header(AVFormatContext *s)
int stream_num = asf->asfid2avid[i];
if (stream_num >= 0) {
AVStream *st = s->streams[stream_num];
if (!st->codec->bit_rate)
st->codec->bit_rate = asf->stream_bitrates[i];
if (!st->codecpar->bit_rate)
st->codecpar->bit_rate = asf->stream_bitrates[i];
if (asf->dar[i].num > 0 && asf->dar[i].den > 0) {
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
asf->dar[i].num, asf->dar[i].den, INT_MAX);
} else if ((asf->dar[0].num > 0) && (asf->dar[0].den > 0) &&
// Use ASF container value if the stream doesn't set AR.
(st->codec->codec_type == AVMEDIA_TYPE_VIDEO))
(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO))
av_reduce(&st->sample_aspect_ratio.num,
&st->sample_aspect_ratio.den,
asf->dar[0].num, asf->dar[0].den, INT_MAX);
av_log(s, AV_LOG_TRACE, "i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
i, st->codec->codec_type, asf->dar[i].num, asf->dar[i].den,
av_log(s, AV_LOG_TRACE, "i=%d, st->codecpar->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
i, st->codecpar->codec_type, asf->dar[i].num, asf->dar[i].den,
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
// copy and convert language codes to the frontend
@ -1316,9 +1316,9 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
av_log(asf, AV_LOG_TRACE, "new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
asf->stream_index, asf->packet_key_frame,
asf_st->pkt.flags & AV_PKT_FLAG_KEY,
s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO,
s->streams[asf->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO,
asf_st->packet_obj_size);
if (s->streams[asf->stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
if (s->streams[asf->stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
asf->packet_key_frame = 1;
if (asf->packet_key_frame)
asf_st->pkt.flags |= AV_PKT_FLAG_KEY;
@ -1371,7 +1371,7 @@ static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
/* test if whole packet is read */
if (asf_st->frag_offset == asf_st->pkt.size) {
// workaround for macroshit radio DVR-MS files
if (s->streams[asf->stream_index]->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
if (s->streams[asf->stream_index]->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO &&
asf_st->pkt.size > 100) {
int i;
for (i = 0; i < asf_st->pkt.size && !asf_st->pkt.data[i]; i++)
@ -1492,7 +1492,7 @@ static void skip_to_key(AVFormatContext *s)
for (i = 0; i < 128; i++) {
int j = asf->asfid2avid[i];
ASFStream *asf_st = &asf->streams[i];
if (j < 0 || s->streams[j]->codec->codec_type != AVMEDIA_TYPE_VIDEO)
if (j < 0 || s->streams[j]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
continue;
asf_st->skip_to_key = 1;

View File

@ -431,8 +431,8 @@ static int asf_read_picture(AVFormatContext *s, int len)
}
st->disposition |= AV_DISPOSITION_ATTACHED_PIC;
st->codec->codec_type = asf_st->type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = id;
st->codecpar->codec_type = asf_st->type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = id;
st->attached_pic = pkt;
st->attached_pic.stream_index = asf_st->index = st->index;
st->attached_pic.flags |= AV_PKT_FLAG_KEY;
@ -695,26 +695,26 @@ static int parse_video_info(AVIOContext *pb, AVStream *st)
uint16_t size;
unsigned int tag;
st->codec->width = avio_rl32(pb);
st->codec->height = avio_rl32(pb);
st->codecpar->width = avio_rl32(pb);
st->codecpar->height = avio_rl32(pb);
avio_skip(pb, 1); // skip reserved flags
size = avio_rl16(pb); // size of the Format Data
tag = ff_get_bmp_header(pb, st, NULL);
st->codec->codec_tag = tag;
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
st->codecpar->codec_tag = tag;
st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag);
if (size > BMP_HEADER_SIZE) {
int ret;
st->codec->extradata_size = size - BMP_HEADER_SIZE;
if (!(st->codec->extradata = av_malloc(st->codec->extradata_size +
st->codecpar->extradata_size = size - BMP_HEADER_SIZE;
if (!(st->codecpar->extradata = av_malloc(st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE))) {
st->codec->extradata_size = 0;
st->codecpar->extradata_size = 0;
return AVERROR(ENOMEM);
}
memset(st->codec->extradata + st->codec->extradata_size , 0,
memset(st->codecpar->extradata + st->codecpar->extradata_size , 0,
AV_INPUT_BUFFER_PADDING_SIZE);
if ((ret = avio_read(pb, st->codec->extradata,
st->codec->extradata_size)) < 0)
if ((ret = avio_read(pb, st->codecpar->extradata,
st->codecpar->extradata_size)) < 0)
return ret;
}
return 0;
@ -773,7 +773,7 @@ static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable *
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 32, 1, 1000); // pts should be dword, in milliseconds
st->codec->codec_type = type;
st->codecpar->codec_type = type;
asf->asf_st[asf->nb_streams] = av_mallocz(sizeof(*asf_st));
if (!asf->asf_st[asf->nb_streams])
return AVERROR(ENOMEM);
@ -790,7 +790,7 @@ static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable *
switch (type) {
case AVMEDIA_TYPE_AUDIO:
asf_st->type = AVMEDIA_TYPE_AUDIO;
if ((ret = ff_get_wav_header(s, pb, st->codec, ts_data_len, 0)) < 0)
if ((ret = ff_get_wav_header(s, pb, st->codecpar, ts_data_len, 0)) < 0)
return ret;
break;
case AVMEDIA_TYPE_VIDEO:
@ -867,7 +867,7 @@ static int asf_read_ext_stream_properties(AVFormatContext *s, const GUIDParseTab
if (st) {
st->start_time = start_time;
st->duration = end_time - start_time;
st->codec->bit_rate = bitrate;
st->codecpar->bit_rate = bitrate;
st->avg_frame_rate.num = 10000000;
st->avg_frame_rate.den = time_per_frame;
}

View File

@ -392,7 +392,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int header_size, n, extra_size, extra_size2, wav_extra_size;
int has_title, has_aspect_ratio = 0;
int metadata_count;
AVCodecContext *enc;
AVCodecParameters *par;
int64_t header_offset, cur_pos, hpos;
int bit_rate;
int64_t duration;
@ -419,14 +419,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
bit_rate = 0;
for (n = 0; n < s->nb_streams; n++) {
AVDictionaryEntry *entry;
enc = s->streams[n]->codec;
par = s->streams[n]->codecpar;
avpriv_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
bit_rate += enc->bit_rate;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0)
bit_rate += par->bit_rate;
if ( par->codec_type == AVMEDIA_TYPE_VIDEO
&& par->sample_aspect_ratio.num > 0
&& par->sample_aspect_ratio.den > 0)
has_aspect_ratio++;
entry = av_dict_get(s->streams[n]->metadata, "language", NULL, 0);
@ -445,7 +445,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
asf->streams[n].stream_language_index = asf->nb_languages;
asf->nb_languages++;
}
if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
if (par->codec_type == AVMEDIA_TYPE_AUDIO)
audio_language_counts[asf->streams[n].stream_language_index]++;
}
} else {
@ -509,7 +509,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
if (audio_language_counts[i]) {
avio_wl16(pb, audio_language_counts[i]);
for (n = 0; n < s->nb_streams; n++)
if (asf->streams[n].stream_language_index == i && s->streams[n]->codec->codec_type == AVMEDIA_TYPE_AUDIO)
if (asf->streams[n].stream_language_index == i && s->streams[n]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, n + 1);
}
}
@ -523,10 +523,10 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
es_pos = put_header(pb, &ff_asf_extended_stream_properties_object);
avio_wl64(pb, 0); /* start time */
avio_wl64(pb, 0); /* end time */
avio_wl32(pb, s->streams[n]->codec->bit_rate); /* data bitrate bps */
avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* data bitrate bps */
avio_wl32(pb, 5000); /* buffer size ms */
avio_wl32(pb, 0); /* initial buffer fullness */
avio_wl32(pb, s->streams[n]->codec->bit_rate); /* peak data bitrate */
avio_wl32(pb, s->streams[n]->codecpar->bit_rate); /* peak data bitrate */
avio_wl32(pb, 5000); /* maximum buffer size ms */
avio_wl32(pb, 0); /* max initial buffer fullness */
avio_wl32(pb, 0); /* max object size */
@ -544,11 +544,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
hpos2 = put_header(pb, &ff_asf_metadata_header);
avio_wl16(pb, 2 * has_aspect_ratio);
for (n = 0; n < s->nb_streams; n++) {
enc = s->streams[n]->codec;
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->sample_aspect_ratio.num > 0
&& enc->sample_aspect_ratio.den > 0) {
AVRational sar = enc->sample_aspect_ratio;
par = s->streams[n]->codecpar;
if ( par->codec_type == AVMEDIA_TYPE_VIDEO
&& par->sample_aspect_ratio.num > 0
&& par->sample_aspect_ratio.den > 0) {
AVRational sar = par->sample_aspect_ratio;
avio_wl16(pb, 0);
// the stream number is set like this below
avio_wl16(pb, n + 1);
@ -620,11 +620,11 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
int64_t es_pos;
// ASFStream *stream = &asf->streams[n];
enc = s->streams[n]->codec;
par = s->streams[n]->codecpar;
asf->streams[n].num = n + 1;
asf->streams[n].seq = 1;
switch (enc->codec_type) {
switch (par->codec_type) {
case AVMEDIA_TYPE_AUDIO:
wav_extra_size = 0;
extra_size = 18 + wav_extra_size;
@ -632,14 +632,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
break;
default:
case AVMEDIA_TYPE_VIDEO:
wav_extra_size = enc->extradata_size;
wav_extra_size = par->extradata_size;
extra_size = 0x33 + wav_extra_size;
extra_size2 = 0;
break;
}
hpos = put_header(pb, &ff_asf_stream_header);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
ff_put_guid(pb, &ff_asf_audio_stream);
ff_put_guid(pb, &ff_asf_audio_conceal_spread);
} else {
@ -653,9 +653,9 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
avio_wl16(pb, n + 1); /* stream number */
avio_wl32(pb, 0); /* ??? */
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
/* WAVEFORMATEX header */
int wavsize = ff_put_wav_header(pb, enc, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
int wavsize = ff_put_wav_header(s, pb, par, FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX);
if (wavsize < 0)
return -1;
@ -667,23 +667,23 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
}
/* ERROR Correction */
avio_w8(pb, 0x01);
if (enc->codec_id == AV_CODEC_ID_ADPCM_G726 || !enc->block_align) {
if (par->codec_id == AV_CODEC_ID_ADPCM_G726 || !par->block_align) {
avio_wl16(pb, 0x0190);
avio_wl16(pb, 0x0190);
} else {
avio_wl16(pb, enc->block_align);
avio_wl16(pb, enc->block_align);
avio_wl16(pb, par->block_align);
avio_wl16(pb, par->block_align);
}
avio_wl16(pb, 0x01);
avio_w8(pb, 0x00);
} else {
avio_wl32(pb, enc->width);
avio_wl32(pb, enc->height);
avio_wl32(pb, par->width);
avio_wl32(pb, par->height);
avio_w8(pb, 2); /* ??? */
avio_wl16(pb, 40 + enc->extradata_size); /* size */
avio_wl16(pb, 40 + par->extradata_size); /* size */
/* BITMAPINFOHEADER header */
ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 1, 0);
ff_put_bmp_header(pb, par, ff_codec_bmp_tags, 1, 0);
}
end_header(pb, hpos);
}
@ -697,17 +697,17 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
const AVCodecDescriptor *codec_desc;
const char *desc;
enc = s->streams[n]->codec;
codec_desc = avcodec_descriptor_get(enc->codec_id);
par = s->streams[n]->codecpar;
codec_desc = avcodec_descriptor_get(par->codec_id);
if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
if (par->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl16(pb, 2);
else if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
else if (par->codec_type == AVMEDIA_TYPE_VIDEO)
avio_wl16(pb, 1);
else
avio_wl16(pb, -1);
if (enc->codec_id == AV_CODEC_ID_WMAV2)
if (par->codec_id == AV_CODEC_ID_WMAV2)
desc = "Windows Media Audio V8";
else
desc = codec_desc ? codec_desc->name : NULL;
@ -732,14 +732,14 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
avio_wl16(pb, 0); /* no parameters */
/* id */
if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
if (par->codec_type == AVMEDIA_TYPE_AUDIO) {
avio_wl16(pb, 2);
avio_wl16(pb, enc->codec_tag);
avio_wl16(pb, par->codec_tag);
} else {
avio_wl16(pb, 4);
avio_wl32(pb, enc->codec_tag);
avio_wl32(pb, par->codec_tag);
}
if (!enc->codec_tag)
if (!par->codec_tag)
return -1;
}
end_header(pb, hpos);
@ -963,7 +963,7 @@ static void put_frame(AVFormatContext *s, ASFStream *stream, AVStream *avst,
PACKET_HEADER_MIN_SIZE - 1;
if (frag_len1 < payload_len &&
avst->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
avst->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
flush_packet(s);
continue;
}
@ -1053,7 +1053,7 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
ASFContext *asf = s->priv_data;
AVIOContext *pb = s->pb;
ASFStream *stream;
AVCodecContext *codec;
AVCodecParameters *par;
uint32_t packet_number;
int64_t pts;
int start_sec;
@ -1061,10 +1061,10 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
int ret;
uint64_t offset = avio_tell(pb);
codec = s->streams[pkt->stream_index]->codec;
par = s->streams[pkt->stream_index]->codecpar;
stream = &asf->streams[pkt->stream_index];
if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
if (par->codec_type == AVMEDIA_TYPE_AUDIO)
flags &= ~AV_PKT_FLAG_KEY;
pts = (pkt->pts != AV_NOPTS_VALUE) ? pkt->pts : pkt->dts;

View File

@ -121,8 +121,8 @@ static int ass_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, 100);
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_id = AV_CODEC_ID_ASS;
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_id = AV_CODEC_ID_ASS;
av_bprint_init(&header, 0, AV_BPRINT_SIZE_UNLIMITED);
av_bprint_init(&line, 0, AV_BPRINT_SIZE_UNLIMITED);
@ -153,7 +153,7 @@ static int ass_read_header(AVFormatContext *s)
sub->duration = duration;
}
res = avpriv_bprint_to_extradata(st->codec, &header);
res = ff_bprint_to_codecpar_extradata(st->codecpar, &header);
if (res < 0)
goto end;

View File

@ -46,16 +46,16 @@ typedef struct ASSContext {
static int write_header(AVFormatContext *s)
{
ASSContext *ass = s->priv_data;
AVCodecContext *avctx = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
if (s->nb_streams != 1 || avctx->codec_id != AV_CODEC_ID_ASS) {
if (s->nb_streams != 1 || par->codec_id != AV_CODEC_ID_ASS) {
av_log(s, AV_LOG_ERROR, "Exactly one ASS/SSA stream is needed.\n");
return AVERROR(EINVAL);
}
avpriv_set_pts_info(s->streams[0], 64, 1, 100);
if (avctx->extradata_size > 0) {
size_t header_size = avctx->extradata_size;
uint8_t *trailer = strstr(avctx->extradata, "\n[Events]");
if (par->extradata_size > 0) {
size_t header_size = par->extradata_size;
uint8_t *trailer = strstr(par->extradata, "\n[Events]");
if (trailer)
trailer = strstr(trailer, "Format:");
@ -63,17 +63,17 @@ static int write_header(AVFormatContext *s)
trailer = strstr(trailer, "\n");
if (trailer++) {
header_size = (trailer - avctx->extradata);
ass->trailer_size = avctx->extradata_size - header_size;
header_size = (trailer - par->extradata);
ass->trailer_size = par->extradata_size - header_size;
if (ass->trailer_size)
ass->trailer = trailer;
}
avio_write(s->pb, avctx->extradata, header_size);
if (avctx->extradata[header_size - 1] != '\n')
avio_write(s->pb, par->extradata, header_size);
if (par->extradata[header_size - 1] != '\n')
avio_write(s->pb, "\r\n", 2);
ass->ssa_mode = !strstr(avctx->extradata, "\n[V4+ Styles]");
if (!strstr(avctx->extradata, "\n[Events]"))
ass->ssa_mode = !strstr(par->extradata, "\n[V4+ Styles]");
if (!strstr(par->extradata, "\n[Events]"))
avio_printf(s->pb, "[Events]\r\nFormat: %s, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text\r\n",
ass->ssa_mode ? "Marked" : "Layer");
}

View File

@ -48,8 +48,8 @@ static int ast_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_skip(s->pb, 8);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = ff_codec_get_id(ff_codec_ast_tags, avio_rb16(s->pb));
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = ff_codec_get_id(ff_codec_ast_tags, avio_rb16(s->pb));
depth = avio_rb16(s->pb);
if (depth != 16) {
@ -57,23 +57,23 @@ static int ast_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
st->codec->channels = avio_rb16(s->pb);
if (!st->codec->channels)
st->codecpar->channels = avio_rb16(s->pb);
if (!st->codecpar->channels)
return AVERROR_INVALIDDATA;
if (st->codec->channels == 2)
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
else if (st->codec->channels == 4)
st->codec->channel_layout = AV_CH_LAYOUT_4POINT0;
if (st->codecpar->channels == 2)
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
else if (st->codecpar->channels == 4)
st->codecpar->channel_layout = AV_CH_LAYOUT_4POINT0;
avio_skip(s->pb, 2);
st->codec->sample_rate = avio_rb32(s->pb);
if (st->codec->sample_rate <= 0)
st->codecpar->sample_rate = avio_rb32(s->pb);
if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
st->start_time = 0;
st->duration = avio_rb32(s->pb);
avio_skip(s->pb, 40);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
@ -90,10 +90,10 @@ static int ast_read_packet(AVFormatContext *s, AVPacket *pkt)
pos = avio_tell(s->pb);
type = avio_rl32(s->pb);
size = avio_rb32(s->pb);
if (size > INT_MAX / s->streams[0]->codec->channels)
if (size > INT_MAX / s->streams[0]->codecpar->channels)
return AVERROR_INVALIDDATA;
size *= s->streams[0]->codec->channels;
size *= s->streams[0]->codecpar->channels;
if ((ret = avio_skip(s->pb, 24)) < 0) // padding
return ret;

View File

@ -37,7 +37,7 @@ typedef struct ASTMuxContext {
#define CHECK_LOOP(type) \
if (ast->loop ## type > 0) { \
ast->loop ## type = av_rescale_rnd(ast->loop ## type, enc->sample_rate, 1000, AV_ROUND_DOWN); \
ast->loop ## type = av_rescale_rnd(ast->loop ## type, par->sample_rate, 1000, AV_ROUND_DOWN); \
if (ast->loop ## type < 0 || ast->loop ## type > UINT_MAX) { \
av_log(s, AV_LOG_ERROR, "Invalid loop" #type " value\n"); \
return AVERROR(EINVAL); \
@ -48,22 +48,22 @@ static int ast_write_header(AVFormatContext *s)
{
ASTMuxContext *ast = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc;
AVCodecParameters *par;
unsigned int codec_tag;
if (s->nb_streams == 1) {
enc = s->streams[0]->codec;
par = s->streams[0]->codecpar;
} else {
av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
return AVERROR(EINVAL);
}
if (enc->codec_id == AV_CODEC_ID_ADPCM_AFC) {
if (par->codec_id == AV_CODEC_ID_ADPCM_AFC) {
av_log(s, AV_LOG_ERROR, "muxing ADPCM AFC is not implemented\n");
return AVERROR_PATCHWELCOME;
}
codec_tag = ff_codec_get_tag(ff_codec_ast_tags, enc->codec_id);
codec_tag = ff_codec_get_tag(ff_codec_ast_tags, par->codec_id);
if (!codec_tag) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
@ -84,9 +84,9 @@ static int ast_write_header(AVFormatContext *s)
avio_wb32(pb, 0); /* File size minus header */
avio_wb16(pb, codec_tag);
avio_wb16(pb, 16); /* Bit depth */
avio_wb16(pb, enc->channels);
avio_wb16(pb, par->channels);
avio_wb16(pb, 0); /* Loop flag */
avio_wb32(pb, enc->sample_rate);
avio_wb32(pb, par->sample_rate);
ast->samples = avio_tell(pb);
avio_wb32(pb, 0); /* Number of samples */
@ -110,8 +110,8 @@ static int ast_write_packet(AVFormatContext *s, AVPacket *pkt)
{
AVIOContext *pb = s->pb;
ASTMuxContext *ast = s->priv_data;
AVCodecContext *enc = s->streams[0]->codec;
int size = pkt->size / enc->channels;
AVCodecParameters *par = s->streams[0]->codecpar;
int size = pkt->size / par->channels;
if (s->streams[0]->nb_frames == 0)
ast->fbs = size;
@ -133,9 +133,9 @@ static int ast_write_trailer(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
ASTMuxContext *ast = s->priv_data;
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
int64_t file_size = avio_tell(pb);
int64_t samples = (file_size - 64 - (32 * s->streams[0]->nb_frames)) / enc->block_align; /* PCM_S16BE_PLANAR */
int64_t samples = (file_size - 64 - (32 * s->streams[0]->nb_frames)) / par->block_align; /* PCM_S16BE_PLANAR */
av_log(s, AV_LOG_DEBUG, "total samples: %"PRId64"\n", samples);

View File

@ -132,16 +132,16 @@ static int au_read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = id;
st->codec->codec_id = codec;
st->codec->channels = channels;
st->codec->sample_rate = rate;
st->codec->bits_per_coded_sample = bps;
st->codec->bit_rate = channels * rate * bps;
st->codec->block_align = FFMAX(bps * st->codec->channels / 8, 1);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_tag = id;
st->codecpar->codec_id = codec;
st->codecpar->channels = channels;
st->codecpar->sample_rate = rate;
st->codecpar->bits_per_coded_sample = bps;
st->codecpar->bit_rate = channels * rate * bps;
st->codecpar->block_align = FFMAX(bps * st->codecpar->channels / 8, 1);
if (data_size != AU_UNKNOWN_SIZE)
st->duration = (((int64_t)data_size)<<3) / (st->codec->channels * (int64_t)bps);
st->duration = (((int64_t)data_size)<<3) / (st->codecpar->channels * (int64_t)bps);
st->start_time = 0;
avpriv_set_pts_info(st, 64, 1, rate);
@ -168,15 +168,15 @@ AVInputFormat ff_au_demuxer = {
static int au_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "only one stream is supported\n");
return AVERROR(EINVAL);
}
enc->codec_tag = ff_codec_get_tag(codec_au_tags, enc->codec_id);
if (!enc->codec_tag) {
par->codec_tag = ff_codec_get_tag(codec_au_tags, par->codec_id);
if (!par->codec_tag) {
av_log(s, AV_LOG_ERROR, "unsupported codec\n");
return AVERROR(EINVAL);
}
@ -184,9 +184,9 @@ static int au_write_header(AVFormatContext *s)
ffio_wfourcc(pb, ".snd"); /* magic number */
avio_wb32(pb, AU_HEADER_SIZE); /* header size */
avio_wb32(pb, AU_UNKNOWN_SIZE); /* data size */
avio_wb32(pb, enc->codec_tag); /* codec ID */
avio_wb32(pb, enc->sample_rate);
avio_wb32(pb, enc->channels);
avio_wb32(pb, par->codec_tag); /* codec ID */
avio_wb32(pb, par->sample_rate);
avio_wb32(pb, par->channels);
avio_wb64(pb, 0); /* annotation field */
avio_flush(pb);

View File

@ -33,7 +33,7 @@ void ff_audio_interleave_close(AVFormatContext *s)
AVStream *st = s->streams[i];
AudioInterleaveContext *aic = st->priv_data;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
av_fifo_freep(&aic->fifo);
}
}
@ -55,9 +55,9 @@ int ff_audio_interleave_init(AVFormatContext *s,
AVStream *st = s->streams[i];
AudioInterleaveContext *aic = st->priv_data;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
aic->sample_size = (st->codec->channels *
av_get_bits_per_sample(st->codec->codec_id)) / 8;
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
aic->sample_size = (st->codecpar->channels *
av_get_bits_per_sample(st->codecpar->codec_id)) / 8;
if (!aic->sample_size) {
av_log(s, AV_LOG_ERROR, "could not compute sample size\n");
return AVERROR(EINVAL);
@ -111,7 +111,7 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
if (pkt) {
AVStream *st = s->streams[pkt->stream_index];
AudioInterleaveContext *aic = st->priv_data;
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
unsigned new_size = av_fifo_size(aic->fifo) + pkt->size;
if (new_size > aic->fifo_size) {
if (av_fifo_realloc2(aic->fifo, new_size) < 0)
@ -131,7 +131,7 @@ int ff_audio_rechunk_interleave(AVFormatContext *s, AVPacket *out, AVPacket *pkt
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
AVPacket new_pkt = { 0 };
while ((ret = interleave_new_audio_packet(s, &new_pkt, i, flush)) > 0) {
if ((ret = ff_interleave_add_packet(s, &new_pkt, compare_ts)) < 0)

View File

@ -872,18 +872,13 @@ typedef struct AVStream {
* encoding: set by the user, replaced by libavformat if left unset
*/
int id;
#if FF_API_LAVF_AVCTX
/**
* Codec context associated with this stream. Allocated and freed by
* libavformat.
*
* - decoding: The demuxer exports codec information stored in the headers
* here.
* - encoding: The user sets codec information, the muxer writes it to the
* output. Mandatory fields as specified in AVCodecContext
* documentation must be set even if this AVCodecContext is
* not actually used for encoding.
* @deprecated use the codecpar struct instead
*/
attribute_deprecated
AVCodecContext *codec;
#endif
void *priv_data;
#if FF_API_LAVF_FRAC
@ -990,6 +985,17 @@ typedef struct AVStream {
int event_flags;
#define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata.
/*
* Codec parameters associated with this stream. Allocated and freed by
* libavformat in avformat_new_stream() and avformat_free_context()
* respectively.
*
* - demuxing: filled by libavformat on stream creation or in
* avformat_find_stream_info()
* - muxing: filled by the caller before avformat_write_header()
*/
AVCodecParameters *codecpar;
/*****************************************************************
* All fields below this line are not part of the public API. They
* may not be used outside of libavformat and can be changed and

View File

@ -385,11 +385,11 @@ static void avi_read_nikon(AVFormatContext *s, uint64_t end)
}
}
static int avi_extract_stream_metadata(AVStream *st)
static int avi_extract_stream_metadata(AVFormatContext *s, AVStream *st)
{
GetByteContext gb;
uint8_t *data = st->codec->extradata;
int data_size = st->codec->extradata_size;
uint8_t *data = st->codecpar->extradata;
int data_size = st->codecpar->extradata_size;
int tag, offset;
if (!data || data_size < 8) {
@ -408,13 +408,13 @@ static int avi_extract_stream_metadata(AVStream *st)
bytestream2_init(&gb, data + offset, data_size - offset);
// decode EXIF tags from IFD, AVI is always little-endian
return avpriv_exif_decode_ifd(st->codec, &gb, 1, 0, &st->metadata);
return avpriv_exif_decode_ifd(s, &gb, 1, 0, &st->metadata);
break;
case MKTAG('C', 'A', 'S', 'I'):
avpriv_request_sample(st->codec, "RIFF stream data tag type CASI (%u)", tag);
avpriv_request_sample(s, "RIFF stream data tag type CASI (%u)", tag);
break;
case MKTAG('Z', 'o', 'r', 'a'):
avpriv_request_sample(st->codec, "RIFF stream data tag type Zora (%u)", tag);
avpriv_request_sample(s, "RIFF stream data tag type Zora (%u)", tag);
break;
default:
break;
@ -456,12 +456,12 @@ static int calculate_bitrate(AVFormatContext *s)
for (j = 0; j < st->nb_index_entries; j++)
len += st->index_entries[j].size;
if (st->nb_index_entries < 2 || st->codec->bit_rate > 0)
if (st->nb_index_entries < 2 || st->codecpar->bit_rate > 0)
continue;
duration = st->index_entries[j-1].timestamp - st->index_entries[0].timestamp;
bitrate = av_rescale(8*len, st->time_base.den, duration * st->time_base.num);
if (bitrate <= INT_MAX && bitrate > 0) {
st->codec->bit_rate = bitrate;
st->codecpar->bit_rate = bitrate;
}
}
return 1;
@ -603,8 +603,8 @@ static int avi_read_header(AVFormatContext *s)
goto fail;
ast = s->streams[0]->priv_data;
av_freep(&s->streams[0]->codec->extradata);
av_freep(&s->streams[0]->codec);
av_freep(&s->streams[0]->codecpar->extradata);
av_freep(&s->streams[0]->codecpar);
if (s->streams[0]->info)
av_freep(&s->streams[0]->info->duration_error);
av_freep(&s->streams[0]->info);
@ -733,17 +733,17 @@ static int avi_read_header(AVFormatContext *s)
if (cur_pos < list_end)
size = FFMIN(size, list_end - cur_pos);
st = s->streams[stream_index];
if (st->codec->codec_type != AVMEDIA_TYPE_UNKNOWN) {
if (st->codecpar->codec_type != AVMEDIA_TYPE_UNKNOWN) {
avio_skip(pb, size);
break;
}
switch (codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (amv_file_format) {
st->codec->width = avih_width;
st->codec->height = avih_height;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_AMV;
st->codecpar->width = avih_width;
st->codecpar->height = avih_height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_AMV;
avio_skip(pb, size);
break;
}
@ -751,40 +751,40 @@ static int avi_read_header(AVFormatContext *s)
if (tag1 == MKTAG('D', 'X', 'S', 'B') ||
tag1 == MKTAG('D', 'X', 'S', 'A')) {
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codec->codec_tag = tag1;
st->codec->codec_id = AV_CODEC_ID_XSUB;
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_tag = tag1;
st->codecpar->codec_id = AV_CODEC_ID_XSUB;
break;
}
if (size > 10 * 4 && size < (1 << 30) && size < avi->fsize) {
if (esize == size-1 && (esize&1)) {
st->codec->extradata_size = esize - 10 * 4;
st->codecpar->extradata_size = esize - 10 * 4;
} else
st->codec->extradata_size = size - 10 * 4;
if (ff_get_extradata(st->codec, pb, st->codec->extradata_size) < 0)
st->codecpar->extradata_size = size - 10 * 4;
if (ff_get_extradata(st->codecpar, pb, st->codecpar->extradata_size) < 0)
return AVERROR(ENOMEM);
}
// FIXME: check if the encoder really did this correctly
if (st->codec->extradata_size & 1)
if (st->codecpar->extradata_size & 1)
avio_r8(pb);
/* Extract palette from extradata if bpp <= 8.
* This code assumes that extradata contains only palette.
* This is true for all paletted codecs implemented in
* FFmpeg. */
if (st->codec->extradata_size &&
(st->codec->bits_per_coded_sample <= 8)) {
int pal_size = (1 << st->codec->bits_per_coded_sample) << 2;
if (st->codecpar->extradata_size &&
(st->codecpar->bits_per_coded_sample <= 8)) {
int pal_size = (1 << st->codecpar->bits_per_coded_sample) << 2;
const uint8_t *pal_src;
pal_size = FFMIN(pal_size, st->codec->extradata_size);
pal_src = st->codec->extradata +
st->codec->extradata_size - pal_size;
pal_size = FFMIN(pal_size, st->codecpar->extradata_size);
pal_src = st->codecpar->extradata +
st->codecpar->extradata_size - pal_size;
/* Exclude the "BottomUp" field from the palette */
if (pal_src - st->codec->extradata >= 9 &&
!memcmp(st->codec->extradata + st->codec->extradata_size - 9, "BottomUp", 9))
if (pal_src - st->codecpar->extradata >= 9 &&
!memcmp(st->codecpar->extradata + st->codecpar->extradata_size - 9, "BottomUp", 9))
pal_src -= 9;
for (i = 0; i < pal_size / 4; i++)
ast->pal[i] = 0xFFU<<24 | AV_RL32(pal_src+4*i);
@ -793,17 +793,17 @@ static int avi_read_header(AVFormatContext *s)
print_tag("video", tag1, 0);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_tag = tag1;
st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags,
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_tag = tag1;
st->codecpar->codec_id = ff_codec_get_id(ff_codec_bmp_tags,
tag1);
/* If codec is not found yet, try with the mov tags. */
if (!st->codec->codec_id) {
if (!st->codecpar->codec_id) {
char tag_buf[32];
av_get_codec_tag_string(tag_buf, sizeof(tag_buf), tag1);
st->codec->codec_id =
st->codecpar->codec_id =
ff_codec_get_id(ff_codec_movvideo_tags, tag1);
if (st->codec->codec_id)
if (st->codecpar->codec_id)
av_log(s, AV_LOG_WARNING,
"mov tag found in avi (fourcc %s)\n",
tag_buf);
@ -812,44 +812,44 @@ static int avi_read_header(AVFormatContext *s)
* for generating correct pts. */
st->need_parsing = AVSTREAM_PARSE_HEADERS;
if (st->codec->codec_id == AV_CODEC_ID_MPEG4 &&
if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4 &&
ast->handler == MKTAG('X', 'V', 'I', 'D'))
st->codec->codec_tag = MKTAG('X', 'V', 'I', 'D');
st->codecpar->codec_tag = MKTAG('X', 'V', 'I', 'D');
if (st->codec->codec_tag == MKTAG('V', 'S', 'S', 'H'))
if (st->codecpar->codec_tag == MKTAG('V', 'S', 'S', 'H'))
st->need_parsing = AVSTREAM_PARSE_FULL;
if (st->codec->codec_id == AV_CODEC_ID_RV40)
if (st->codecpar->codec_id == AV_CODEC_ID_RV40)
st->need_parsing = AVSTREAM_PARSE_NONE;
if (st->codec->codec_tag == 0 && st->codec->height > 0 &&
st->codec->extradata_size < 1U << 30) {
st->codec->extradata_size += 9;
if ((ret = av_reallocp(&st->codec->extradata,
st->codec->extradata_size +
if (st->codecpar->codec_tag == 0 && st->codecpar->height > 0 &&
st->codecpar->extradata_size < 1U << 30) {
st->codecpar->extradata_size += 9;
if ((ret = av_reallocp(&st->codecpar->extradata,
st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE)) < 0) {
st->codec->extradata_size = 0;
st->codecpar->extradata_size = 0;
return ret;
} else
memcpy(st->codec->extradata + st->codec->extradata_size - 9,
memcpy(st->codecpar->extradata + st->codecpar->extradata_size - 9,
"BottomUp", 9);
}
st->codec->height = FFABS(st->codec->height);
st->codecpar->height = FFABS(st->codecpar->height);
// avio_skip(pb, size - 5 * 4);
break;
case AVMEDIA_TYPE_AUDIO:
ret = ff_get_wav_header(s, pb, st->codec, size, 0);
ret = ff_get_wav_header(s, pb, st->codecpar, size, 0);
if (ret < 0)
return ret;
ast->dshow_block_align = st->codec->block_align;
if (ast->sample_size && st->codec->block_align &&
ast->sample_size != st->codec->block_align) {
ast->dshow_block_align = st->codecpar->block_align;
if (ast->sample_size && st->codecpar->block_align &&
ast->sample_size != st->codecpar->block_align) {
av_log(s,
AV_LOG_WARNING,
"sample size (%d) != block align (%d)\n",
ast->sample_size,
st->codec->block_align);
ast->sample_size = st->codec->block_align;
st->codecpar->block_align);
ast->sample_size = st->codecpar->block_align;
}
/* 2-aligned
* (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
@ -861,45 +861,45 @@ static int avi_read_header(AVFormatContext *s)
/* ADTS header is in extradata, AAC without header must be
* stored as exact frames. Parser not needed and it will
* fail. */
if (st->codec->codec_id == AV_CODEC_ID_AAC &&
st->codec->extradata_size)
if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
st->codecpar->extradata_size)
st->need_parsing = AVSTREAM_PARSE_NONE;
// The flac parser does not work with AVSTREAM_PARSE_TIMESTAMPS
if (st->codec->codec_id == AV_CODEC_ID_FLAC)
if (st->codecpar->codec_id == AV_CODEC_ID_FLAC)
st->need_parsing = AVSTREAM_PARSE_NONE;
/* AVI files with Xan DPCM audio (wrongly) declare PCM
* audio in the header but have Axan as stream_code_tag. */
if (ast->handler == AV_RL32("Axan")) {
st->codec->codec_id = AV_CODEC_ID_XAN_DPCM;
st->codec->codec_tag = 0;
st->codecpar->codec_id = AV_CODEC_ID_XAN_DPCM;
st->codecpar->codec_tag = 0;
ast->dshow_block_align = 0;
}
if (amv_file_format) {
st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_AMV;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_AMV;
ast->dshow_block_align = 0;
}
if ((st->codec->codec_id == AV_CODEC_ID_AAC ||
st->codec->codec_id == AV_CODEC_ID_FLAC ||
st->codec->codec_id == AV_CODEC_ID_MP2 ) && ast->dshow_block_align <= 4 && ast->dshow_block_align) {
if ((st->codecpar->codec_id == AV_CODEC_ID_AAC ||
st->codecpar->codec_id == AV_CODEC_ID_FLAC ||
st->codecpar->codec_id == AV_CODEC_ID_MP2 ) && ast->dshow_block_align <= 4 && ast->dshow_block_align) {
av_log(s, AV_LOG_DEBUG, "overriding invalid dshow_block_align of %d\n", ast->dshow_block_align);
ast->dshow_block_align = 0;
}
if (st->codec->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 1024 && ast->sample_size == 1024 ||
st->codec->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 4096 && ast->sample_size == 4096 ||
st->codec->codec_id == AV_CODEC_ID_MP3 && ast->dshow_block_align == 1152 && ast->sample_size == 1152) {
if (st->codecpar->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 1024 && ast->sample_size == 1024 ||
st->codecpar->codec_id == AV_CODEC_ID_AAC && ast->dshow_block_align == 4096 && ast->sample_size == 4096 ||
st->codecpar->codec_id == AV_CODEC_ID_MP3 && ast->dshow_block_align == 1152 && ast->sample_size == 1152) {
av_log(s, AV_LOG_DEBUG, "overriding sample_size\n");
ast->sample_size = 0;
}
break;
case AVMEDIA_TYPE_SUBTITLE:
st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
st->request_probe= 1;
avio_skip(pb, size);
break;
default:
st->codec->codec_type = AVMEDIA_TYPE_DATA;
st->codec->codec_id = AV_CODEC_ID_NONE;
st->codec->codec_tag = 0;
st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
st->codecpar->codec_id = AV_CODEC_ID_NONE;
st->codecpar->codec_tag = 0;
avio_skip(pb, size);
break;
}
@ -907,8 +907,8 @@ static int avi_read_header(AVFormatContext *s)
break;
case MKTAG('s', 't', 'r', 'd'):
if (stream_index >= (unsigned)s->nb_streams
|| s->streams[stream_index]->codec->extradata_size
|| s->streams[stream_index]->codec->codec_tag == MKTAG('H','2','6','4')) {
|| s->streams[stream_index]->codecpar->extradata_size
|| s->streams[stream_index]->codecpar->codec_tag == MKTAG('H','2','6','4')) {
avio_skip(pb, size);
} else {
uint64_t cur_pos = avio_tell(pb);
@ -917,14 +917,14 @@ static int avi_read_header(AVFormatContext *s)
st = s->streams[stream_index];
if (size<(1<<30)) {
if (ff_get_extradata(st->codec, pb, size) < 0)
if (ff_get_extradata(st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
}
if (st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
if (st->codecpar->extradata_size & 1) //FIXME check if the encoder really did this correctly
avio_r8(pb);
ret = avi_extract_stream_metadata(st);
ret = avi_extract_stream_metadata(s, st);
if (ret < 0) {
av_log(s, AV_LOG_WARNING, "could not decoding EXIF data in stream header.\n");
}
@ -1014,8 +1014,8 @@ fail:
if (dict_entry && !strcmp(dict_entry->value, "PotEncoder"))
for (i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i];
if ( st->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO
|| st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)
if ( st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO
|| st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
st->need_parsing = AVSTREAM_PARSE_FULL;
}
@ -1094,8 +1094,7 @@ static int read_gab2_sub(AVFormatContext *s, AVStream *st, AVPacket *pkt)
if (!avformat_open_input(&ast->sub_ctx, "", sub_demuxer, NULL)) {
ff_read_packet(ast->sub_ctx, &ast->sub_pkt);
*st->codec = *ast->sub_ctx->streams[0]->codec;
ast->sub_ctx->streams[0]->codec->extradata = NULL;
avcodec_parameters_copy(st->codecpar, ast->sub_ctx->streams[0]->codecpar);
time_base = ast->sub_ctx->streams[0]->time_base;
avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
}
@ -1232,8 +1231,8 @@ start_sync:
// workaround for broken small-file-bug402.avi
if ( d[2] == 'w' && d[3] == 'b'
&& n == 0
&& st ->codec->codec_type == AVMEDIA_TYPE_VIDEO
&& st1->codec->codec_type == AVMEDIA_TYPE_AUDIO
&& st ->codecpar->codec_type == AVMEDIA_TYPE_VIDEO
&& st1->codecpar->codec_type == AVMEDIA_TYPE_AUDIO
&& ast->prefix == 'd'*256+'c'
&& (d[2]*256+d[3] == ast1->prefix || !ast1->prefix_count)
) {
@ -1443,8 +1442,8 @@ resync:
pkt->flags |= AV_PKT_FLAG_KEY;
if (size < 0)
av_packet_unref(pkt);
} else if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE &&
!st->codec->codec_tag && read_gab2_sub(s, st, pkt)) {
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE &&
!st->codecpar->codec_tag && read_gab2_sub(s, st, pkt)) {
ast->frame_offset++;
avi->stream_index = -1;
ast->remaining = 0;
@ -1468,7 +1467,7 @@ resync:
size);
pkt->stream_index = avi->stream_index;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && st->index_entries) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->index_entries) {
AVIndexEntry *e;
int index;
@ -1479,7 +1478,7 @@ resync:
if (index == st->nb_index_entries-1) {
int key=1;
uint32_t state=-1;
if (st->codec->codec_id == AV_CODEC_ID_MPEG4) {
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);
@ -1557,7 +1556,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
avi->stream_index = -1;
avio_seek(pb, idx1_pos, SEEK_SET);
if (s->nb_streams == 1 && s->streams[0]->codec->codec_tag == AV_RL32("MMES")) {
if (s->nb_streams == 1 && s->streams[0]->codecpar->codec_tag == AV_RL32("MMES")) {
first_packet_pos = 0;
data_offset = avi->movi_list;
}
@ -1661,7 +1660,7 @@ static int check_stream_max_drift(AVFormatContext *s)
max_dts = FFMAX(max_dts, dts);
max_buffer = FFMAX(max_buffer,
av_rescale(dts - min_dts,
st->codec->bit_rate,
st->codecpar->bit_rate,
AV_TIME_BASE));
}
}
@ -1847,7 +1846,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
if (st2->nb_index_entries <= 0)
continue;
// av_assert1(st2->codec->block_align);
// av_assert1(st2->codecpar->block_align);
av_assert0(fabs(av_q2d(st2->time_base) - ast2->scale / (double)ast2->rate) < av_q2d(st2->time_base) * 0.00000001);
index = av_index_search_timestamp(st2,
av_rescale_q(timestamp,
@ -1856,7 +1855,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
FFMAX(ast2->sample_size, 1),
flags |
AVSEEK_FLAG_BACKWARD |
(st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
(st2->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if (index < 0)
index = 0;
ast2->seek_pos = st2->index_entries[index].pos;
@ -1872,7 +1871,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index,
index = av_index_search_timestamp(
st2,
av_rescale_q(timestamp, st->time_base, st2->time_base) * FFMAX(ast2->sample_size, 1),
flags | AVSEEK_FLAG_BACKWARD | (st2->codec->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
flags | AVSEEK_FLAG_BACKWARD | (st2->codecpar->codec_type != AVMEDIA_TYPE_VIDEO ? AVSEEK_FLAG_ANY : 0));
if (index < 0)
index = 0;
while (!avi->non_interleaved && index>0 && st2->index_entries[index-1].pos >= pos_min)

View File

@ -180,21 +180,21 @@ static int avi_write_counters(AVFormatContext *s, int riff_id)
AVIContext *avi = s->priv_data;
int n, au_byterate, au_ssize, au_scale, nb_frames = 0;
int64_t file_size;
AVCodecContext *stream;
AVCodecParameters *par;
file_size = avio_tell(pb);
for (n = 0; n < s->nb_streams; n++) {
AVIStream *avist = s->streams[n]->priv_data;
av_assert0(avist->frames_hdr_strm);
stream = s->streams[n]->codec;
par = s->streams[n]->codecpar;
avio_seek(pb, avist->frames_hdr_strm, SEEK_SET);
ff_parse_specific_params(s->streams[n], &au_byterate, &au_ssize, &au_scale);
if (au_ssize == 0)
avio_wl32(pb, avist->packet_count);
else
avio_wl32(pb, avist->audio_strm_length / au_ssize);
if (stream->codec_type == AVMEDIA_TYPE_VIDEO)
if (par->codec_type == AVMEDIA_TYPE_VIDEO)
nb_frames = FFMAX(nb_frames, avist->packet_count);
}
if (riff_id == 1) {
@ -211,7 +211,7 @@ static void write_odml_master(AVFormatContext *s, int stream_index)
{
AVIOContext *pb = s->pb;
AVStream *st = s->streams[stream_index];
AVCodecContext *enc = st->codec;
AVCodecParameters *par = st->codecpar;
AVIStream *avist = st->priv_data;
unsigned char tag[5];
int j;
@ -225,7 +225,7 @@ static void write_odml_master(AVFormatContext *s, int stream_index)
avio_w8(pb, 0); /* bIndexSubType (0 == frame index) */
avio_w8(pb, 0); /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */
avio_wl32(pb, 0); /* nEntriesInUse (will fill out later on) */
ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, enc->codec_type));
ffio_wfourcc(pb, avi_stream2fourcc(tag, stream_index, par->codec_type));
/* dwChunkId */
avio_wl64(pb, 0); /* dwReserved[3] */
avio_wl32(pb, 0); /* Must be 0. */
@ -239,7 +239,7 @@ static int avi_write_header(AVFormatContext *s)
AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb;
int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale;
AVCodecContext *video_enc;
AVCodecParameters *video_par;
AVStream *video_st = NULL;
int64_t list1, list2, strh, strf;
AVDictionaryEntry *t = NULL;
@ -266,12 +266,12 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, 14 * 4);
bitrate = 0;
video_enc = NULL;
video_par = NULL;
for (n = 0; n < s->nb_streams; n++) {
AVCodecContext *codec = s->streams[n]->codec;
bitrate += codec->bit_rate;
if (codec->codec_type == AVMEDIA_TYPE_VIDEO) {
video_enc = codec;
AVCodecParameters *par = s->streams[n]->codecpar;
bitrate += par->bit_rate;
if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
video_par = par;
video_st = s->streams[n];
}
}
@ -295,9 +295,9 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, 0); /* initial frame */
avio_wl32(pb, s->nb_streams); /* nb streams */
avio_wl32(pb, 1024 * 1024); /* suggested buffer size */
if (video_enc) {
avio_wl32(pb, video_enc->width);
avio_wl32(pb, video_enc->height);
if (video_par) {
avio_wl32(pb, video_par->width);
avio_wl32(pb, video_par->height);
} else {
avio_wl32(pb, 0);
avio_wl32(pb, 0);
@ -310,18 +310,18 @@ static int avi_write_header(AVFormatContext *s)
/* stream list */
for (i = 0; i < n; i++) {
AVStream *st = s->streams[i];
AVCodecContext *enc = st->codec;
AVCodecParameters *par = st->codecpar;
AVIStream *avist = st->priv_data;
list2 = ff_start_tag(pb, "LIST");
ffio_wfourcc(pb, "strl");
/* stream generic header */
strh = ff_start_tag(pb, "strh");
switch (enc->codec_type) {
switch (par->codec_type) {
case AVMEDIA_TYPE_SUBTITLE:
// XSUB subtitles behave like video tracks, other subtitles
// are not (yet) supported.
if (enc->codec_id != AV_CODEC_ID_XSUB) {
if (par->codec_id != AV_CODEC_ID_XSUB) {
av_log(s, AV_LOG_ERROR,
"Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
return AVERROR_PATCHWELCOME;
@ -339,9 +339,9 @@ static int avi_write_header(AVFormatContext *s)
ffio_wfourcc(pb, "dats");
break;
}
if (enc->codec_type == AVMEDIA_TYPE_VIDEO ||
enc->codec_id == AV_CODEC_ID_XSUB)
avio_wl32(pb, enc->codec_tag);
if (par->codec_type == AVMEDIA_TYPE_VIDEO ||
par->codec_id == AV_CODEC_ID_XSUB)
avio_wl32(pb, par->codec_tag);
else
avio_wl32(pb, 1);
avist->strh_flags_offset = avio_tell(pb);
@ -352,14 +352,14 @@ static int avi_write_header(AVFormatContext *s)
ff_parse_specific_params(st, &au_byterate, &au_ssize, &au_scale);
if ( enc->codec_type == AVMEDIA_TYPE_VIDEO
&& enc->codec_id != AV_CODEC_ID_XSUB
if ( par->codec_type == AVMEDIA_TYPE_VIDEO
&& par->codec_id != AV_CODEC_ID_XSUB
&& au_byterate > 1000LL*au_scale) {
au_byterate = 600;
au_scale = 1;
}
avpriv_set_pts_info(st, 64, au_scale, au_byterate);
if (enc->codec_id == AV_CODEC_ID_XSUB)
if (par->codec_id == AV_CODEC_ID_XSUB)
au_scale = au_byterate = 0;
avio_wl32(pb, au_scale); /* scale */
@ -375,57 +375,57 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, 0); /* length, XXX: filled later */
/* suggested buffer size, is set to largest chunk size in avi_write_trailer */
if (enc->codec_type == AVMEDIA_TYPE_VIDEO)
if (par->codec_type == AVMEDIA_TYPE_VIDEO)
avio_wl32(pb, 1024 * 1024);
else if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
else if (par->codec_type == AVMEDIA_TYPE_AUDIO)
avio_wl32(pb, 12 * 1024);
else
avio_wl32(pb, 0);
avio_wl32(pb, -1); /* quality */
avio_wl32(pb, au_ssize); /* sample size */
avio_wl32(pb, 0);
avio_wl16(pb, enc->width);
avio_wl16(pb, enc->height);
avio_wl16(pb, par->width);
avio_wl16(pb, par->height);
ff_end_tag(pb, strh);
if (enc->codec_type != AVMEDIA_TYPE_DATA) {
if (par->codec_type != AVMEDIA_TYPE_DATA) {
int ret, flags;
enum AVPixelFormat pix_fmt;
strf = ff_start_tag(pb, "strf");
switch (enc->codec_type) {
switch (par->codec_type) {
case AVMEDIA_TYPE_SUBTITLE:
/* XSUB subtitles behave like video tracks, other subtitles
* are not (yet) supported. */
if (enc->codec_id != AV_CODEC_ID_XSUB)
if (par->codec_id != AV_CODEC_ID_XSUB)
break;
case AVMEDIA_TYPE_VIDEO:
/* WMP expects RGB 5:5:5 rawvideo in avi to have bpp set to 16. */
if ( !enc->codec_tag
&& enc->codec_id == AV_CODEC_ID_RAWVIDEO
&& enc->pix_fmt == AV_PIX_FMT_RGB555LE
&& enc->bits_per_coded_sample == 15)
enc->bits_per_coded_sample = 16;
if ( !par->codec_tag
&& par->codec_id == AV_CODEC_ID_RAWVIDEO
&& par->format == AV_PIX_FMT_RGB555LE
&& par->bits_per_coded_sample == 15)
par->bits_per_coded_sample = 16;
avist->pal_offset = avio_tell(pb) + 40;
ff_put_bmp_header(pb, enc, ff_codec_bmp_tags, 0, 0);
ff_put_bmp_header(pb, par, ff_codec_bmp_tags, 0, 0);
pix_fmt = avpriv_find_pix_fmt(avpriv_pix_fmt_bps_avi,
enc->bits_per_coded_sample);
if ( !enc->codec_tag
&& enc->codec_id == AV_CODEC_ID_RAWVIDEO
&& enc->pix_fmt != pix_fmt
&& enc->pix_fmt != AV_PIX_FMT_NONE)
par->bits_per_coded_sample);
if ( !par->codec_tag
&& par->codec_id == AV_CODEC_ID_RAWVIDEO
&& par->format != pix_fmt
&& par->format != AV_PIX_FMT_NONE)
av_log(s, AV_LOG_ERROR, "%s rawvideo cannot be written to avi, output file will be unreadable\n",
av_get_pix_fmt_name(enc->pix_fmt));
av_get_pix_fmt_name(par->format));
break;
case AVMEDIA_TYPE_AUDIO:
flags = (avi->write_channel_mask == 0) ? FF_PUT_WAV_HEADER_SKIP_CHANNELMASK : 0;
if ((ret = ff_put_wav_header(pb, enc, flags)) < 0)
if ((ret = ff_put_wav_header(s, pb, par, flags)) < 0)
return ret;
break;
default:
av_log(s, AV_LOG_ERROR,
"Invalid or not supported codec type '%s' found in the input\n",
(char *)av_x_if_null(av_get_media_type_string(enc->codec_type), "?"));
(char *)av_x_if_null(av_get_media_type_string(par->codec_type), "?"));
return AVERROR(EINVAL);
}
ff_end_tag(pb, strf);
@ -433,7 +433,7 @@ static int avi_write_header(AVFormatContext *s)
ff_riff_write_info_tag(s->pb, "strn", t->value);
t = NULL;
}
if (enc->codec_id == AV_CODEC_ID_XSUB
if (par->codec_id == AV_CODEC_ID_XSUB
&& (t = av_dict_get(s->streams[i]->metadata, "language", NULL, 0))) {
const char* langstr = av_convert_lang_to(t->value, AV_LANG_ISO639_1);
t = NULL;
@ -451,13 +451,13 @@ static int avi_write_header(AVFormatContext *s)
write_odml_master(s, i);
}
if (enc->codec_type == AVMEDIA_TYPE_VIDEO &&
if (par->codec_type == AVMEDIA_TYPE_VIDEO &&
st->sample_aspect_ratio.num > 0 &&
st->sample_aspect_ratio.den > 0) {
int vprp = ff_start_tag(pb, "vprp");
AVRational dar = av_mul_q(st->sample_aspect_ratio,
(AVRational) { enc->width,
enc->height });
(AVRational) { par->width,
par->height });
int num, den;
av_reduce(&num, &den, dar.num, dar.den, 0xFFFF);
@ -465,18 +465,18 @@ static int avi_write_header(AVFormatContext *s)
avio_wl32(pb, 0); // video standard = unknown
// TODO: should be avg_frame_rate
avio_wl32(pb, (2LL*st->time_base.den + st->time_base.num - 1) / (2LL * st->time_base.num));
avio_wl32(pb, enc->width);
avio_wl32(pb, enc->height);
avio_wl32(pb, par->width);
avio_wl32(pb, par->height);
avio_wl16(pb, den);
avio_wl16(pb, num);
avio_wl32(pb, enc->width);
avio_wl32(pb, enc->height);
avio_wl32(pb, par->width);
avio_wl32(pb, par->height);
avio_wl32(pb, 1); // progressive FIXME
avio_wl32(pb, enc->height);
avio_wl32(pb, enc->width);
avio_wl32(pb, enc->height);
avio_wl32(pb, enc->width);
avio_wl32(pb, par->height);
avio_wl32(pb, par->width);
avio_wl32(pb, par->height);
avio_wl32(pb, par->width);
avio_wl32(pb, 0);
avio_wl32(pb, 0);
@ -544,7 +544,7 @@ static void update_odml_entry(AVFormatContext *s, int stream_index, int64_t ix,
avio_wl64(pb, ix); /* qwOffset */
avio_wl32(pb, size); /* dwSize */
ff_parse_specific_params(s->streams[stream_index], &au_byterate, &au_ssize, &au_scale);
if (s->streams[stream_index]->codec->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
if (s->streams[stream_index]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && au_ssize > 0) {
uint32_t audio_segm_size = (avist->audio_strm_length - avist->indexes.audio_strm_offset);
if ((audio_segm_size % au_ssize > 0) && !avist->sample_requested) {
avpriv_request_sample(s, "OpenDML index duration for audio packets with partial frames");
@ -586,7 +586,7 @@ static int avi_write_ix(AVFormatContext *s)
AVIStream *avist = s->streams[i]->priv_data;
int64_t ix;
avi_stream2fourcc(tag, i, s->streams[i]->codec->codec_type);
avi_stream2fourcc(tag, i, s->streams[i]->codecpar->codec_type);
ix_tag[3] = '0' + i;
/* Writing AVI OpenDML leaf index chunk */
@ -654,7 +654,7 @@ static int avi_write_idx1(AVFormatContext *s)
ffio_wfourcc(pb, ie->tag);
else {
avi_stream2fourcc(tag, stream_id,
s->streams[stream_id]->codec->codec_type);
s->streams[stream_id]->codecpar->codec_type);
ffio_wfourcc(pb, tag);
}
avio_wl32(pb, ie->flags);
@ -673,11 +673,11 @@ static int avi_write_idx1(AVFormatContext *s)
static int write_skip_frames(AVFormatContext *s, int stream_index, int64_t dts)
{
AVIStream *avist = s->streams[stream_index]->priv_data;
AVCodecContext *enc = s->streams[stream_index]->codec;
AVCodecParameters *par = s->streams[stream_index]->codecpar;
ff_dlog(s, "dts:%s packet_count:%d stream_index:%d\n", av_ts2str(dts), avist->packet_count, stream_index);
while (enc->block_align == 0 && dts != AV_NOPTS_VALUE &&
dts > avist->packet_count && enc->codec_id != AV_CODEC_ID_XSUB && avist->packet_count) {
while (par->block_align == 0 && dts != AV_NOPTS_VALUE &&
dts > avist->packet_count && par->codec_id != AV_CODEC_ID_XSUB && avist->packet_count) {
AVPacket empty_packet;
if (dts - avist->packet_count > 60000) {
@ -699,10 +699,10 @@ static int write_skip_frames(AVFormatContext *s, int stream_index, int64_t dts)
static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
{
const int stream_index = pkt->stream_index;
AVCodecContext *enc = s->streams[stream_index]->codec;
AVCodecParameters *par = s->streams[stream_index]->codecpar;
int ret;
if (enc->codec_id == AV_CODEC_ID_H264 && enc->codec_tag == MKTAG('H','2','6','4') && pkt->size) {
if (par->codec_id == AV_CODEC_ID_H264 && par->codec_tag == MKTAG('H','2','6','4') && pkt->size) {
ret = ff_check_h264_startcode(s, s->streams[stream_index], pkt);
if (ret < 0)
return ret;
@ -714,27 +714,27 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
if (!pkt->size)
return avi_write_packet_internal(s, pkt); /* Passthrough */
if (enc->codec_type == AVMEDIA_TYPE_VIDEO) {
if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
AVIStream *avist = s->streams[stream_index]->priv_data;
AVIOContext *pb = s->pb;
AVPacket *opkt = pkt;
if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0) {
int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
ret = ff_reshuffle_raw_rgb(s, &pkt, enc, expected_stride);
if (par->codec_id == AV_CODEC_ID_RAWVIDEO && par->codec_tag == 0) {
int64_t bpc = par->bits_per_coded_sample != 15 ? par->bits_per_coded_sample : 16;
int expected_stride = ((par->width * bpc + 31) >> 5)*4;
ret = ff_reshuffle_raw_rgb(s, &pkt, par, expected_stride);
if (ret < 0)
return ret;
} else
ret = 0;
if (enc->pix_fmt == AV_PIX_FMT_PAL8) {
if (par->format == AV_PIX_FMT_PAL8) {
int ret2 = ff_get_packet_palette(s, opkt, ret, avist->palette);
if (ret2 < 0)
return ret2;
if (ret2) {
int pal_size = 1 << enc->bits_per_coded_sample;
int pal_size = 1 << par->bits_per_coded_sample;
int pc_tag, i;
av_assert0(enc->bits_per_coded_sample >= 0 && enc->bits_per_coded_sample <= 8);
av_assert0(par->bits_per_coded_sample >= 0 && par->bits_per_coded_sample <= 8);
if (pb->seekable && avist->pal_offset) {
int64_t cur_offset = avio_tell(pb);
@ -749,7 +749,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
}
if (memcmp(avist->palette, avist->old_palette, pal_size * 4)) {
unsigned char tag[5];
avi_stream2fourcc(tag, stream_index, enc->codec_type);
avi_stream2fourcc(tag, stream_index, par->codec_type);
tag[2] = 'p'; tag[3] = 'c';
if (s->pb->seekable) {
int ret;
@ -797,7 +797,7 @@ static int avi_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
AVIContext *avi = s->priv_data;
AVIOContext *pb = s->pb;
AVIStream *avist = s->streams[stream_index]->priv_data;
AVCodecContext *enc = s->streams[stream_index]->codec;
AVCodecParameters *par = s->streams[stream_index]->codecpar;
if (pkt->dts != AV_NOPTS_VALUE)
avist->last_dts = pkt->dts + pkt->duration;
@ -817,10 +817,10 @@ static int avi_write_packet_internal(AVFormatContext *s, AVPacket *pkt)
avi->movi_list = avi_start_new_riff(s, pb, "AVIX", "movi");
}
avi_stream2fourcc(tag, stream_index, enc->codec_type);
avi_stream2fourcc(tag, stream_index, par->codec_type);
if (pkt->flags & AV_PKT_FLAG_KEY)
flags = 0x10;
if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
if (par->codec_type == AVMEDIA_TYPE_AUDIO)
avist->audio_strm_length += size;
if (s->pb->seekable) {
@ -868,15 +868,15 @@ static int avi_write_trailer(AVFormatContext *s)
avio_skip(pb, 16);
for (n = nb_frames = 0; n < s->nb_streams; n++) {
AVCodecContext *stream = s->streams[n]->codec;
AVCodecParameters *par = s->streams[n]->codecpar;
AVIStream *avist = s->streams[n]->priv_data;
if (stream->codec_type == AVMEDIA_TYPE_VIDEO) {
if (par->codec_type == AVMEDIA_TYPE_VIDEO) {
if (nb_frames < avist->packet_count)
nb_frames = avist->packet_count;
} else {
if (stream->codec_id == AV_CODEC_ID_MP2 ||
stream->codec_id == AV_CODEC_ID_MP3)
if (par->codec_id == AV_CODEC_ID_MP2 ||
par->codec_id == AV_CODEC_ID_MP3)
nb_frames += avist->packet_count;
}
}

View File

@ -232,10 +232,10 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
AviSynthContext *avs = s->priv_data;
int planar = 0; // 0: packed, 1: YUV, 2: Y8
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->width = avs->vi->width;
st->codec->height = avs->vi->height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codecpar->width = avs->vi->width;
st->codecpar->height = avs->vi->height;
st->avg_frame_rate = (AVRational) { avs->vi->fps_numerator,
avs->vi->fps_denominator };
@ -247,37 +247,37 @@ static int avisynth_create_stream_video(AVFormatContext *s, AVStream *st)
switch (avs->vi->pixel_type) {
#ifdef USING_AVISYNTH
case AVS_CS_YV24:
st->codec->pix_fmt = AV_PIX_FMT_YUV444P;
st->codecpar->format = AV_PIX_FMT_YUV444P;
planar = 1;
break;
case AVS_CS_YV16:
st->codec->pix_fmt = AV_PIX_FMT_YUV422P;
st->codecpar->format = AV_PIX_FMT_YUV422P;
planar = 1;
break;
case AVS_CS_YV411:
st->codec->pix_fmt = AV_PIX_FMT_YUV411P;
st->codecpar->format = AV_PIX_FMT_YUV411P;
planar = 1;
break;
case AVS_CS_Y8:
st->codec->pix_fmt = AV_PIX_FMT_GRAY8;
st->codecpar->format = AV_PIX_FMT_GRAY8;
planar = 2;
break;
#endif
case AVS_CS_BGR24:
st->codec->pix_fmt = AV_PIX_FMT_BGR24;
st->codecpar->format = AV_PIX_FMT_BGR24;
break;
case AVS_CS_BGR32:
st->codec->pix_fmt = AV_PIX_FMT_RGB32;
st->codecpar->format = AV_PIX_FMT_RGB32;
break;
case AVS_CS_YUY2:
st->codec->pix_fmt = AV_PIX_FMT_YUYV422;
st->codecpar->format = AV_PIX_FMT_YUYV422;
break;
case AVS_CS_YV12:
st->codec->pix_fmt = AV_PIX_FMT_YUV420P;
st->codecpar->format = AV_PIX_FMT_YUV420P;
planar = 1;
break;
case AVS_CS_I420: // Is this even used anywhere?
st->codec->pix_fmt = AV_PIX_FMT_YUV420P;
st->codecpar->format = AV_PIX_FMT_YUV420P;
planar = 1;
break;
default:
@ -307,27 +307,27 @@ static int avisynth_create_stream_audio(AVFormatContext *s, AVStream *st)
{
AviSynthContext *avs = s->priv_data;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->sample_rate = avs->vi->audio_samples_per_second;
st->codec->channels = avs->vi->nchannels;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->sample_rate = avs->vi->audio_samples_per_second;
st->codecpar->channels = avs->vi->nchannels;
st->duration = avs->vi->num_audio_samples;
avpriv_set_pts_info(st, 64, 1, avs->vi->audio_samples_per_second);
switch (avs->vi->sample_type) {
case AVS_SAMPLE_INT8:
st->codec->codec_id = AV_CODEC_ID_PCM_U8;
st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
break;
case AVS_SAMPLE_INT16:
st->codec->codec_id = AV_CODEC_ID_PCM_S16LE;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
break;
case AVS_SAMPLE_INT24:
st->codec->codec_id = AV_CODEC_ID_PCM_S24LE;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S24LE;
break;
case AVS_SAMPLE_INT32:
st->codec->codec_id = AV_CODEC_ID_PCM_S32LE;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
break;
case AVS_SAMPLE_FLOAT:
st->codec->codec_id = AV_CODEC_ID_PCM_F32LE;
st->codecpar->codec_id = AV_CODEC_ID_PCM_F32LE;
break;
default:
av_log(s, AV_LOG_ERROR,
@ -636,7 +636,7 @@ static int avisynth_read_packet(AVFormatContext *s, AVPacket *pkt)
/* If either stream reaches EOF, try to read the other one before
* giving up. */
avisynth_next_stream(s, &st, pkt, &discard);
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
ret = avisynth_read_packet_video(s, pkt, discard);
if (ret == AVERROR_EOF && avs_has_audio(avs->vi)) {
avisynth_next_stream(s, &st, pkt, &discard);
@ -678,7 +678,7 @@ static int avisynth_read_seek(AVFormatContext *s, int stream_index,
samplerate = (AVRational) { avs->vi->audio_samples_per_second, 1 };
st = s->streams[stream_index];
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
/* AviSynth frame counts are signed int. */
if ((timestamp >= avs->vi->num_frames) ||
(timestamp > INT_MAX) ||

View File

@ -46,22 +46,22 @@ static int avr_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4); // magic
avio_skip(s->pb, 8); // sample_name
chan = avio_rb16(s->pb);
if (!chan) {
st->codec->channels = 1;
st->codecpar->channels = 1;
} else if (chan == 0xFFFFu) {
st->codec->channels = 2;
st->codecpar->channels = 2;
} else {
avpriv_request_sample(s, "chan %d", chan);
return AVERROR_PATCHWELCOME;
}
st->codec->bits_per_coded_sample = bps = avio_rb16(s->pb);
st->codecpar->bits_per_coded_sample = bps = avio_rb16(s->pb);
sign = avio_rb16(s->pb);
@ -69,21 +69,21 @@ static int avr_read_header(AVFormatContext *s)
avio_skip(s->pb, 2); // midi
avio_skip(s->pb, 1); // replay speed
st->codec->sample_rate = avio_rb24(s->pb);
st->codecpar->sample_rate = avio_rb24(s->pb);
avio_skip(s->pb, 4 * 3);
avio_skip(s->pb, 2 * 3);
avio_skip(s->pb, 20);
avio_skip(s->pb, 64);
st->codec->codec_id = ff_get_pcm_codec_id(bps, 0, 1, sign);
if (st->codec->codec_id == AV_CODEC_ID_NONE) {
st->codecpar->codec_id = ff_get_pcm_codec_id(bps, 0, 1, sign);
if (st->codecpar->codec_id == AV_CODEC_ID_NONE) {
avpriv_request_sample(s, "Bps %d and sign %d", bps, sign);
return AVERROR_PATCHWELCOME;
}
st->codec->block_align = bps * st->codec->channels / 8;
st->codecpar->block_align = bps * st->codecpar->channels / 8;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}

View File

@ -184,11 +184,11 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
avs->st_video = avformat_new_stream(s, NULL);
if (!avs->st_video)
return AVERROR(ENOMEM);
avs->st_video->codec->codec_type = AVMEDIA_TYPE_VIDEO;
avs->st_video->codec->codec_id = AV_CODEC_ID_AVS;
avs->st_video->codec->width = avs->width;
avs->st_video->codec->height = avs->height;
avs->st_video->codec->bits_per_coded_sample=avs->bits_per_sample;
avs->st_video->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
avs->st_video->codecpar->codec_id = AV_CODEC_ID_AVS;
avs->st_video->codecpar->width = avs->width;
avs->st_video->codecpar->height = avs->height;
avs->st_video->codecpar->bits_per_coded_sample=avs->bits_per_sample;
avs->st_video->nb_frames = avs->nb_frames;
#if FF_API_R_FRAME_RATE
avs->st_video->r_frame_rate =
@ -203,7 +203,7 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
avs->st_audio = avformat_new_stream(s, NULL);
if (!avs->st_audio)
return AVERROR(ENOMEM);
avs->st_audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
avs->st_audio->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
}
avs->remaining_audio_size = size - 4;
size = avs_read_audio_packet(s, pkt);

View File

@ -116,13 +116,13 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
"video packet");
}
avpriv_set_pts_info(st, 64, 185, vid->sample_rate);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_BETHSOFTVID;
st->codec->width = vid->width;
st->codec->height = vid->height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_BETHSOFTVID;
st->codecpar->width = vid->width;
st->codecpar->height = vid->height;
}
st = s->streams[vid->video_index];
npixels = st->codec->width * st->codec->height;
npixels = st->codecpar->width * st->codecpar->height;
vidbuf_start = av_malloc(vidbuf_capacity = BUFFER_PADDING_SIZE);
if(!vidbuf_start)
@ -245,13 +245,13 @@ static int vid_read_packet(AVFormatContext *s,
if (!st)
return AVERROR(ENOMEM);
vid->audio_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_PCM_U8;
st->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codec->bits_per_coded_sample = 8;
st->codec->sample_rate = vid->sample_rate;
st->codec->bit_rate = 8 * st->codec->sample_rate;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->bits_per_coded_sample = 8;
st->codecpar->sample_rate = vid->sample_rate;
st->codecpar->bit_rate = 8 * st->codecpar->sample_rate;
st->start_time = 0;
avpriv_set_pts_info(st, 64, 1, vid->sample_rate);
}

View File

@ -75,38 +75,38 @@ static int bfi_read_header(AVFormatContext * s)
avio_rl32(pb);
fps = avio_rl32(pb);
avio_skip(pb, 12);
vstream->codec->width = avio_rl32(pb);
vstream->codec->height = avio_rl32(pb);
vstream->codecpar->width = avio_rl32(pb);
vstream->codecpar->height = avio_rl32(pb);
/*Load the palette to extradata */
avio_skip(pb, 8);
vstream->codec->extradata = av_malloc(768);
if (!vstream->codec->extradata)
vstream->codecpar->extradata = av_malloc(768);
if (!vstream->codecpar->extradata)
return AVERROR(ENOMEM);
vstream->codec->extradata_size = 768;
avio_read(pb, vstream->codec->extradata,
vstream->codec->extradata_size);
vstream->codecpar->extradata_size = 768;
avio_read(pb, vstream->codecpar->extradata,
vstream->codecpar->extradata_size);
astream->codec->sample_rate = avio_rl32(pb);
astream->codecpar->sample_rate = avio_rl32(pb);
/* Set up the video codec... */
avpriv_set_pts_info(vstream, 32, 1, fps);
vstream->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vstream->codec->codec_id = AV_CODEC_ID_BFI;
vstream->codec->pix_fmt = AV_PIX_FMT_PAL8;
vstream->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vstream->codecpar->codec_id = AV_CODEC_ID_BFI;
vstream->codecpar->format = AV_PIX_FMT_PAL8;
vstream->nb_frames =
vstream->duration = bfi->nframes;
/* Set up the audio codec now... */
astream->codec->codec_type = AVMEDIA_TYPE_AUDIO;
astream->codec->codec_id = AV_CODEC_ID_PCM_U8;
astream->codec->channels = 1;
astream->codec->channel_layout = AV_CH_LAYOUT_MONO;
astream->codec->bits_per_coded_sample = 8;
astream->codec->bit_rate =
astream->codec->sample_rate * astream->codec->bits_per_coded_sample;
astream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
astream->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
astream->codecpar->channels = 1;
astream->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
astream->codecpar->bits_per_coded_sample = 8;
astream->codecpar->bit_rate =
astream->codecpar->sample_rate * astream->codecpar->bits_per_coded_sample;
avio_seek(pb, chunk_header - 3, SEEK_SET);
avpriv_set_pts_info(astream, 64, 1, astream->codec->sample_rate);
avpriv_set_pts_info(astream, 64, 1, astream->codecpar->sample_rate);
return 0;
}

View File

@ -89,7 +89,7 @@ static int read_header(AVFormatContext *s)
if (!vst)
return AVERROR(ENOMEM);
vst->codec->codec_tag = avio_rl32(pb);
vst->codecpar->codec_tag = avio_rl32(pb);
bink->file_size = avio_rl32(pb) + 8;
vst->duration = avio_rl32(pb);
@ -107,8 +107,8 @@ static int read_header(AVFormatContext *s)
avio_skip(pb, 4);
vst->codec->width = avio_rl32(pb);
vst->codec->height = avio_rl32(pb);
vst->codecpar->width = avio_rl32(pb);
vst->codecpar->height = avio_rl32(pb);
fps_num = avio_rl32(pb);
fps_den = avio_rl32(pb);
@ -121,15 +121,15 @@ static int read_header(AVFormatContext *s)
avpriv_set_pts_info(vst, 64, fps_den, fps_num);
vst->avg_frame_rate = av_inv_q(vst->time_base);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_BINKVIDEO;
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codecpar->codec_id = AV_CODEC_ID_BINKVIDEO;
if ((vst->codec->codec_tag & 0xFFFFFF) == MKTAG('K', 'B', '2', 0)) {
if ((vst->codecpar->codec_tag & 0xFFFFFF) == MKTAG('K', 'B', '2', 0)) {
av_log(s, AV_LOG_WARNING, "Bink 2 video is not implemented\n");
vst->codec->codec_id = AV_CODEC_ID_NONE;
vst->codecpar->codec_id = AV_CODEC_ID_NONE;
}
if (ff_get_extradata(vst->codec, pb, 4) < 0)
if (ff_get_extradata(vst->codecpar, pb, 4) < 0)
return AVERROR(ENOMEM);
bink->num_audio_tracks = avio_rl32(pb);
@ -148,23 +148,23 @@ static int read_header(AVFormatContext *s)
ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_tag = 0;
ast->codec->sample_rate = avio_rl16(pb);
avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codecpar->codec_tag = 0;
ast->codecpar->sample_rate = avio_rl16(pb);
avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
flags = avio_rl16(pb);
ast->codec->codec_id = flags & BINK_AUD_USEDCT ?
ast->codecpar->codec_id = flags & BINK_AUD_USEDCT ?
AV_CODEC_ID_BINKAUDIO_DCT : AV_CODEC_ID_BINKAUDIO_RDFT;
if (flags & BINK_AUD_STEREO) {
ast->codec->channels = 2;
ast->codec->channel_layout = AV_CH_LAYOUT_STEREO;
ast->codecpar->channels = 2;
ast->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
} else {
ast->codec->channels = 1;
ast->codec->channel_layout = AV_CH_LAYOUT_MONO;
ast->codecpar->channels = 1;
ast->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
}
if (ff_alloc_extradata(ast->codec, 4))
if (ff_alloc_extradata(ast->codecpar, 4))
return AVERROR(ENOMEM);
AV_WL32(ast->codec->extradata, vst->codec->codec_tag);
AV_WL32(ast->codecpar->extradata, vst->codecpar->codec_tag);
}
for (i = 0; i < bink->num_audio_tracks; i++)
@ -250,7 +250,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
(in bytes). We use this value to calcuate the audio PTS */
if (pkt->size >= 4)
bink->audio_pts[bink->current_track -1] +=
AV_RL32(pkt->data) / (2 * s->streams[bink->current_track]->codec->channels);
AV_RL32(pkt->data) / (2 * s->streams[bink->current_track]->codecpar->channels);
return 0;
} else {
avio_skip(pb, audio_size);

View File

@ -54,12 +54,12 @@ static AVStream * init_stream(AVFormatContext *s)
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return NULL;
st->codec->codec_tag = 0;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_tag = 0;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
if (!bin->width) {
st->codec->width = (80<<3);
st->codec->height = (25<<4);
st->codecpar->width = (80<<3);
st->codecpar->height = (25<<4);
}
avpriv_set_pts_info(st, 60, bin->framerate.den, bin->framerate.num);
@ -74,9 +74,9 @@ static AVStream * init_stream(AVFormatContext *s)
/**
* Given filesize and width, calculate height (assume font_height of 16)
*/
static void calculate_height(AVCodecContext *avctx, uint64_t fsize)
static void calculate_height(AVCodecParameters *par, uint64_t fsize)
{
avctx->height = (fsize / ((avctx->width>>3)*2)) << 4;
par->height = (fsize / ((par->width>>3)*2)) << 4;
}
#endif
@ -119,11 +119,11 @@ static int next_tag_read(AVFormatContext *avctx, uint64_t *fsize)
return 0;
}
static void predict_width(AVCodecContext *avctx, uint64_t fsize, int got_width)
static void predict_width(AVCodecParameters *par, uint64_t fsize, int got_width)
{
/** attempt to guess width */
if (!got_width)
avctx->width = fsize > 4000 ? (160<<3) : (80<<3);
par->width = fsize > 4000 ? (160<<3) : (80<<3);
}
static int bintext_read_header(AVFormatContext *s)
@ -134,12 +134,12 @@ static int bintext_read_header(AVFormatContext *s)
AVStream *st = init_stream(s);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_BINTEXT;
st->codecpar->codec_id = AV_CODEC_ID_BINTEXT;
if (ff_alloc_extradata(st->codec, 2))
if (ff_alloc_extradata(st->codecpar, 2))
return AVERROR(ENOMEM);
st->codec->extradata[0] = 16;
st->codec->extradata[1] = 0;
st->codecpar->extradata[0] = 16;
st->codecpar->extradata[1] = 0;
if (pb->seekable) {
int got_width = 0;
@ -147,8 +147,8 @@ static int bintext_read_header(AVFormatContext *s)
if (ff_sauce_read(s, &bin->fsize, &got_width, 0) < 0)
next_tag_read(s, &bin->fsize);
if (!bin->width) {
predict_width(st->codec, bin->fsize, got_width);
calculate_height(st->codec, bin->fsize);
predict_width(st->codecpar, bin->fsize, got_width);
calculate_height(st->codecpar, bin->fsize);
}
avio_seek(pb, 0, SEEK_SET);
}
@ -179,30 +179,30 @@ static int xbin_read_header(AVFormatContext *s)
return AVERROR(ENOMEM);
avio_skip(pb, 5);
st->codec->width = avio_rl16(pb)<<3;
st->codec->height = avio_rl16(pb);
st->codecpar->width = avio_rl16(pb)<<3;
st->codecpar->height = avio_rl16(pb);
fontheight = avio_r8(pb);
st->codec->height *= fontheight;
st->codecpar->height *= fontheight;
flags = avio_r8(pb);
st->codec->extradata_size = 2;
st->codecpar->extradata_size = 2;
if ((flags & BINTEXT_PALETTE))
st->codec->extradata_size += 48;
st->codecpar->extradata_size += 48;
if ((flags & BINTEXT_FONT))
st->codec->extradata_size += fontheight * (flags & 0x10 ? 512 : 256);
st->codec->codec_id = flags & 4 ? AV_CODEC_ID_XBIN : AV_CODEC_ID_BINTEXT;
st->codecpar->extradata_size += fontheight * (flags & 0x10 ? 512 : 256);
st->codecpar->codec_id = flags & 4 ? AV_CODEC_ID_XBIN : AV_CODEC_ID_BINTEXT;
if (ff_alloc_extradata(st->codec, st->codec->extradata_size))
if (ff_alloc_extradata(st->codecpar, st->codecpar->extradata_size))
return AVERROR(ENOMEM);
st->codec->extradata[0] = fontheight;
st->codec->extradata[1] = flags;
if (avio_read(pb, st->codec->extradata + 2, st->codec->extradata_size - 2) < 0)
st->codecpar->extradata[0] = fontheight;
st->codecpar->extradata[1] = flags;
if (avio_read(pb, st->codecpar->extradata + 2, st->codecpar->extradata_size - 2) < 0)
return AVERROR(EIO);
if (pb->seekable) {
bin->fsize = avio_size(pb) - 9 - st->codec->extradata_size;
bin->fsize = avio_size(pb) - 9 - st->codecpar->extradata_size;
ff_sauce_read(s, &bin->fsize, NULL, 0);
avio_seek(pb, 9 + st->codec->extradata_size, SEEK_SET);
avio_seek(pb, 9 + st->codecpar->extradata_size, SEEK_SET);
}
return 0;
@ -222,28 +222,28 @@ static int adf_read_header(AVFormatContext *s)
st = init_stream(s);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_BINTEXT;
st->codecpar->codec_id = AV_CODEC_ID_BINTEXT;
if (ff_alloc_extradata(st->codec, 2 + 48 + 4096))
if (ff_alloc_extradata(st->codecpar, 2 + 48 + 4096))
return AVERROR(ENOMEM);
st->codec->extradata[0] = 16;
st->codec->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
st->codecpar->extradata[0] = 16;
st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
if (avio_read(pb, st->codec->extradata + 2, 24) < 0)
if (avio_read(pb, st->codecpar->extradata + 2, 24) < 0)
return AVERROR(EIO);
avio_skip(pb, 144);
if (avio_read(pb, st->codec->extradata + 2 + 24, 24) < 0)
if (avio_read(pb, st->codecpar->extradata + 2 + 24, 24) < 0)
return AVERROR(EIO);
if (avio_read(pb, st->codec->extradata + 2 + 48, 4096) < 0)
if (avio_read(pb, st->codecpar->extradata + 2 + 48, 4096) < 0)
return AVERROR(EIO);
if (pb->seekable) {
int got_width = 0;
bin->fsize = avio_size(pb) - 1 - 192 - 4096;
st->codec->width = 80<<3;
st->codecpar->width = 80<<3;
ff_sauce_read(s, &bin->fsize, &got_width, 0);
if (!bin->width)
calculate_height(st->codec, bin->fsize);
calculate_height(st->codecpar, bin->fsize);
avio_seek(pb, 1 + 192 + 4096, SEEK_SET);
}
return 0;
@ -277,24 +277,24 @@ static int idf_read_header(AVFormatContext *s)
st = init_stream(s);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_id = AV_CODEC_ID_IDF;
st->codecpar->codec_id = AV_CODEC_ID_IDF;
if (ff_alloc_extradata(st->codec, 2 + 48 + 4096))
if (ff_alloc_extradata(st->codecpar, 2 + 48 + 4096))
return AVERROR(ENOMEM);
st->codec->extradata[0] = 16;
st->codec->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
st->codecpar->extradata[0] = 16;
st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
avio_seek(pb, avio_size(pb) - 4096 - 48, SEEK_SET);
if (avio_read(pb, st->codec->extradata + 2 + 48, 4096) < 0)
if (avio_read(pb, st->codecpar->extradata + 2 + 48, 4096) < 0)
return AVERROR(EIO);
if (avio_read(pb, st->codec->extradata + 2, 48) < 0)
if (avio_read(pb, st->codecpar->extradata + 2, 48) < 0)
return AVERROR(EIO);
bin->fsize = avio_size(pb) - 12 - 4096 - 48;
ff_sauce_read(s, &bin->fsize, &got_width, 0);
if (!bin->width)
calculate_height(st->codec, bin->fsize);
calculate_height(st->codecpar, bin->fsize);
avio_seek(pb, 12, SEEK_SET);
return 0;
}

View File

@ -55,11 +55,11 @@ static int read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id=AV_CODEC_ID_G729;
st->codec->sample_rate=8000;
st->codec->block_align = 16;
st->codec->channels=1;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id=AV_CODEC_ID_G729;
st->codecpar->sample_rate=8000;
st->codecpar->block_align = 16;
st->codecpar->channels=1;
avpriv_set_pts_info(st, 64, 1, 100);
return 0;
@ -117,16 +117,16 @@ AVInputFormat ff_bit_demuxer = {
#if CONFIG_MUXERS
static int write_header(AVFormatContext *s)
{
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
if ((enc->codec_id != AV_CODEC_ID_G729) || enc->channels != 1) {
if ((par->codec_id != AV_CODEC_ID_G729) || par->channels != 1) {
av_log(s, AV_LOG_ERROR,
"only codec g729 with 1 channel is supported by this format\n");
return AVERROR(EINVAL);
}
enc->bits_per_coded_sample = 16;
enc->block_align = (enc->bits_per_coded_sample * enc->channels) >> 3;
par->bits_per_coded_sample = 16;
par->block_align = (par->bits_per_coded_sample * par->channels) >> 3;
return 0;
}

View File

@ -47,20 +47,20 @@ static int bmv_read_header(AVFormatContext *s)
st = avformat_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_BMV_VIDEO;
st->codec->width = 640;
st->codec->height = 429;
st->codec->pix_fmt = AV_PIX_FMT_PAL8;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_BMV_VIDEO;
st->codecpar->width = 640;
st->codecpar->height = 429;
st->codecpar->format = AV_PIX_FMT_PAL8;
avpriv_set_pts_info(st, 16, 1, 12);
ast = avformat_new_stream(s, 0);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_id = AV_CODEC_ID_BMV_AUDIO;
ast->codec->channels = 2;
ast->codec->channel_layout = AV_CH_LAYOUT_STEREO;
ast->codec->sample_rate = 22050;
ast->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codecpar->codec_id = AV_CODEC_ID_BMV_AUDIO;
ast->codecpar->channels = 2;
ast->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
ast->codecpar->sample_rate = 22050;
avpriv_set_pts_info(ast, 16, 1, 22050);
c->get_next = 1;

View File

@ -46,16 +46,16 @@ static int read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_ADPCM_MS;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_MS;
avio_rl32(s->pb);
avio_rl32(s->pb);
st->codec->sample_rate = avio_rl32(s->pb);
st->codec->channels = avio_rl32(s->pb);
st->codecpar->sample_rate = avio_rl32(s->pb);
st->codecpar->channels = avio_rl32(s->pb);
s->internal->data_offset = avio_rl32(s->pb);
avio_r8(s->pb);
st->codec->block_align = st->codec->channels * avio_rl32(s->pb);
st->codecpar->block_align = st->codecpar->channels * avio_rl32(s->pb);
avio_seek(s->pb, s->internal->data_offset, SEEK_SET);
@ -66,7 +66,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVStream *st = s->streams[0];
return av_get_packet(s->pb, pkt, st->codec->block_align);
return av_get_packet(s->pb, pkt, st->codecpar->block_align);
}
AVInputFormat ff_boa_demuxer = {

View File

@ -99,7 +99,7 @@ static int read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
avio_skip(s->pb, 4);
@ -197,15 +197,15 @@ static int read_header(AVFormatContext *s)
}
loop = avio_r8(s->pb); // loop flag
st->codec->codec_id = codec;
st->codec->channels = avio_r8(s->pb);
if (!st->codec->channels)
st->codecpar->codec_id = codec;
st->codecpar->channels = avio_r8(s->pb);
if (!st->codecpar->channels)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, 1); // padding
st->codec->sample_rate = bfstm ? read32(s) : read16(s);
if (st->codec->sample_rate <= 0)
st->codecpar->sample_rate = bfstm ? read32(s) : read16(s);
if (st->codecpar->sample_rate <= 0)
return AVERROR_INVALIDDATA;
if (!bfstm)
@ -214,7 +214,7 @@ static int read_header(AVFormatContext *s)
if (loop) {
if (av_dict_set_int(&s->metadata, "loop_start",
av_rescale(read32(s), AV_TIME_BASE,
st->codec->sample_rate),
st->codecpar->sample_rate),
0) < 0)
return AVERROR(ENOMEM);
} else {
@ -223,7 +223,7 @@ static int read_header(AVFormatContext *s)
st->start_time = 0;
st->duration = read32(s);
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
if (!bfstm)
start = read32(s);
@ -235,14 +235,14 @@ static int read_header(AVFormatContext *s)
}
b->block_size = read32(s);
if (b->block_size > UINT32_MAX / st->codec->channels)
if (b->block_size > UINT32_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
b->samples_per_block = read32(s);
b->last_block_used_bytes = read32(s);
b->last_block_samples = read32(s);
b->last_block_size = read32(s);
if (b->last_block_size > UINT32_MAX / st->codec->channels)
if (b->last_block_size > UINT32_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
if (b->last_block_used_bytes > b->last_block_size)
return AVERROR_INVALIDDATA;
@ -255,16 +255,16 @@ static int read_header(AVFormatContext *s)
if (!bfstm)
toffset = read32(s) + 16LL;
else
toffset = toffset + read32(s) + st->codec->channels * 8 - 8;
toffset = toffset + read32(s) + st->codecpar->channels * 8 - 8;
if (toffset > size)
return AVERROR_INVALIDDATA;
avio_skip(s->pb, pos + toffset - avio_tell(s->pb));
b->table = av_mallocz(32 * st->codec->channels);
b->table = av_mallocz(32 * st->codecpar->channels);
if (!b->table)
return AVERROR(ENOMEM);
for (ch = 0; ch < st->codec->channels; ch++) {
for (ch = 0; ch < st->codecpar->channels; ch++) {
if (avio_read(s->pb, b->table + ch * 32, 32) != 32) {
ret = AVERROR_INVALIDDATA;
goto fail;
@ -295,7 +295,7 @@ static int read_header(AVFormatContext *s)
codec != AV_CODEC_ID_ADPCM_THP_LE)
goto skip;
asize = b->block_count * st->codec->channels * 4;
asize = b->block_count * st->codecpar->channels * 4;
if (size < asize) {
ret = AVERROR_INVALIDDATA;
goto fail;
@ -357,7 +357,7 @@ fail:
static int read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *codec = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
BRSTMDemuxContext *b = s->priv_data;
uint32_t samples, size, skip = 0;
int ret, i;
@ -385,8 +385,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
}
if (codec->codec_id == AV_CODEC_ID_ADPCM_THP ||
codec->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
if (par->codec_id == AV_CODEC_ID_ADPCM_THP ||
par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
uint8_t *dst;
if (!b->adpc) {
@ -394,30 +394,30 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_INVALIDDATA;
}
if (!b->table) {
b->table = av_mallocz(32 * codec->channels);
b->table = av_mallocz(32 * par->channels);
if (!b->table)
return AVERROR(ENOMEM);
}
if (size > (INT_MAX - 32 - 4) ||
(32 + 4 + size) > (INT_MAX / codec->channels) ||
(32 + 4 + size) * codec->channels > INT_MAX - 8)
(32 + 4 + size) > (INT_MAX / par->channels) ||
(32 + 4 + size) * par->channels > INT_MAX - 8)
return AVERROR_INVALIDDATA;
if (av_new_packet(pkt, 8 + (32 + 4 + size) * codec->channels) < 0)
if (av_new_packet(pkt, 8 + (32 + 4 + size) * par->channels) < 0)
return AVERROR(ENOMEM);
dst = pkt->data;
if (codec->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
bytestream_put_le32(&dst, size * codec->channels);
if (par->codec_id == AV_CODEC_ID_ADPCM_THP_LE) {
bytestream_put_le32(&dst, size * par->channels);
bytestream_put_le32(&dst, samples);
} else {
bytestream_put_be32(&dst, size * codec->channels);
bytestream_put_be32(&dst, size * par->channels);
bytestream_put_be32(&dst, samples);
}
bytestream_put_buffer(&dst, b->table, 32 * codec->channels);
bytestream_put_buffer(&dst, b->adpc + 4 * codec->channels *
(b->current_block - 1), 4 * codec->channels);
bytestream_put_buffer(&dst, b->table, 32 * par->channels);
bytestream_put_buffer(&dst, b->adpc + 4 * par->channels *
(b->current_block - 1), 4 * par->channels);
for (i = 0; i < codec->channels; i++) {
for (i = 0; i < par->channels; i++) {
ret = avio_read(s->pb, dst, size);
dst += size;
avio_skip(s->pb, skip);
@ -428,7 +428,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
}
pkt->duration = samples;
} else {
size *= codec->channels;
size *= par->channels;
ret = av_get_packet(s->pb, pkt, size);
}
@ -449,7 +449,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
timestamp /= b->samples_per_block;
ret = avio_seek(s->pb, b->data_start + timestamp * b->block_size *
st->codec->channels, SEEK_SET);
st->codecpar->channels, SEEK_SET);
if (ret < 0)
return ret;

View File

@ -83,10 +83,10 @@ static int read_header(AVFormatContext *s)
if (!video)
return AVERROR(ENOMEM);
video->codec->codec_type = AVMEDIA_TYPE_VIDEO;
video->codec->codec_id = AV_CODEC_ID_C93;
video->codec->width = 320;
video->codec->height = 192;
video->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
video->codecpar->codec_id = AV_CODEC_ID_C93;
video->codecpar->width = 320;
video->codecpar->height = 192;
/* 4:3 320x200 with 8 empty lines */
video->sample_aspect_ratio = (AVRational) { 5, 6 };
avpriv_set_pts_info(video, 64, 2, 25);
@ -120,7 +120,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
c93->audio = avformat_new_stream(s, NULL);
if (!c93->audio)
return AVERROR(ENOMEM);
c93->audio->codec->codec_type = AVMEDIA_TYPE_AUDIO;
c93->audio->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
}
avio_skip(pb, 26); /* VOC header */
ret = ff_voc_get_packet(s, pkt, c93->audio, datasize - 26);

View File

@ -69,29 +69,29 @@ static int read_desc_chunk(AVFormatContext *s)
return AVERROR(ENOMEM);
/* parse format description */
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->sample_rate = av_int2double(avio_rb64(pb));
st->codec->codec_tag = avio_rl32(pb);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->sample_rate = av_int2double(avio_rb64(pb));
st->codecpar->codec_tag = avio_rl32(pb);
flags = avio_rb32(pb);
caf->bytes_per_packet = avio_rb32(pb);
st->codec->block_align = caf->bytes_per_packet;
st->codecpar->block_align = caf->bytes_per_packet;
caf->frames_per_packet = avio_rb32(pb);
st->codec->channels = avio_rb32(pb);
st->codec->bits_per_coded_sample = avio_rb32(pb);
st->codecpar->channels = avio_rb32(pb);
st->codecpar->bits_per_coded_sample = avio_rb32(pb);
/* calculate bit rate for constant size packets */
if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) {
st->codec->bit_rate = (uint64_t)st->codec->sample_rate * (uint64_t)caf->bytes_per_packet * 8
st->codecpar->bit_rate = (uint64_t)st->codecpar->sample_rate * (uint64_t)caf->bytes_per_packet * 8
/ (uint64_t)caf->frames_per_packet;
} else {
st->codec->bit_rate = 0;
st->codecpar->bit_rate = 0;
}
/* determine codec */
if (st->codec->codec_tag == MKTAG('l','p','c','m'))
st->codec->codec_id = ff_mov_get_lpcm_codec_id(st->codec->bits_per_coded_sample, (flags ^ 0x2) | 0x4);
if (st->codecpar->codec_tag == MKTAG('l','p','c','m'))
st->codecpar->codec_id = ff_mov_get_lpcm_codec_id(st->codecpar->bits_per_coded_sample, (flags ^ 0x2) | 0x4);
else
st->codec->codec_id = ff_codec_get_id(ff_codec_caf_tags, st->codec->codec_tag);
st->codecpar->codec_id = ff_codec_get_id(ff_codec_caf_tags, st->codecpar->codec_tag);
return 0;
}
@ -104,7 +104,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE)
return -1;
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
if (st->codecpar->codec_id == AV_CODEC_ID_AAC) {
/* The magic cookie format for AAC is an mp4 esds atom.
The lavc AAC decoder requires the data from the codec specific
description as extradata input. */
@ -113,13 +113,13 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
strt = avio_tell(pb);
ff_mov_read_esds(s, pb);
skip = size - (avio_tell(pb) - strt);
if (skip < 0 || !st->codec->extradata ||
st->codec->codec_id != AV_CODEC_ID_AAC) {
if (skip < 0 || !st->codecpar->extradata ||
st->codecpar->codec_id != AV_CODEC_ID_AAC) {
av_log(s, AV_LOG_ERROR, "invalid AAC magic cookie\n");
return AVERROR_INVALIDDATA;
}
avio_skip(pb, skip);
} else if (st->codec->codec_id == AV_CODEC_ID_ALAC) {
} else if (st->codecpar->codec_id == AV_CODEC_ID_ALAC) {
#define ALAC_PREAMBLE 12
#define ALAC_HEADER 36
#define ALAC_NEW_KUKI 24
@ -134,8 +134,8 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
return AVERROR_INVALIDDATA;
}
av_freep(&st->codec->extradata);
if (ff_alloc_extradata(st->codec, ALAC_HEADER))
av_freep(&st->codecpar->extradata);
if (ff_alloc_extradata(st->codecpar, ALAC_HEADER))
return AVERROR(ENOMEM);
/* For the old style cookie, we skip 12 bytes, then read 36 bytes.
@ -145,30 +145,30 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
if (!memcmp(&preamble[4], "frmaalac", 8)) {
if (size < ALAC_PREAMBLE + ALAC_HEADER) {
av_log(s, AV_LOG_ERROR, "invalid ALAC magic cookie\n");
av_freep(&st->codec->extradata);
av_freep(&st->codecpar->extradata);
return AVERROR_INVALIDDATA;
}
if (avio_read(pb, st->codec->extradata, ALAC_HEADER) != ALAC_HEADER) {
if (avio_read(pb, st->codecpar->extradata, ALAC_HEADER) != ALAC_HEADER) {
av_log(s, AV_LOG_ERROR, "failed to read kuki header\n");
av_freep(&st->codec->extradata);
av_freep(&st->codecpar->extradata);
return AVERROR_INVALIDDATA;
}
avio_skip(pb, size - ALAC_PREAMBLE - ALAC_HEADER);
} else {
AV_WB32(st->codec->extradata, 36);
memcpy(&st->codec->extradata[4], "alac", 4);
AV_WB32(&st->codec->extradata[8], 0);
memcpy(&st->codec->extradata[12], preamble, 12);
if (avio_read(pb, &st->codec->extradata[24], ALAC_NEW_KUKI - 12) != ALAC_NEW_KUKI - 12) {
AV_WB32(st->codecpar->extradata, 36);
memcpy(&st->codecpar->extradata[4], "alac", 4);
AV_WB32(&st->codecpar->extradata[8], 0);
memcpy(&st->codecpar->extradata[12], preamble, 12);
if (avio_read(pb, &st->codecpar->extradata[24], ALAC_NEW_KUKI - 12) != ALAC_NEW_KUKI - 12) {
av_log(s, AV_LOG_ERROR, "failed to read new kuki header\n");
av_freep(&st->codec->extradata);
av_freep(&st->codecpar->extradata);
return AVERROR_INVALIDDATA;
}
avio_skip(pb, size - ALAC_NEW_KUKI);
}
} else {
av_freep(&st->codec->extradata);
if (ff_get_extradata(st->codec, pb, size) < 0)
av_freep(&st->codecpar->extradata);
if (ff_get_extradata(st->codecpar, pb, size) < 0)
return AVERROR(ENOMEM);
}
@ -323,7 +323,7 @@ static int read_header(AVFormatContext *s)
if (caf->data_size > 0)
st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet;
} else if (st->nb_index_entries && st->duration > 0) {
st->codec->bit_rate = st->codec->sample_rate * caf->data_size * 8 /
st->codecpar->bit_rate = st->codecpar->sample_rate * caf->data_size * 8 /
st->duration;
} else {
av_log(s, AV_LOG_ERROR, "Missing packet table. It is required when "
@ -331,7 +331,7 @@ static int read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
st->start_time = 0;
/* position the stream at the start of data */

View File

@ -102,19 +102,19 @@ static uint32_t samples_per_packet(enum AVCodecID codec_id, int channels, int bl
static int caf_write_header(AVFormatContext *s)
{
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
CAFContext *caf = s->priv_data;
AVDictionaryEntry *t = NULL;
unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, enc->codec_id);
unsigned int codec_tag = ff_codec_get_tag(ff_codec_caf_tags, par->codec_id);
int64_t chunk_size = 0;
int frame_size = enc->frame_size;
int frame_size = par->frame_size;
if (s->nb_streams != 1) {
av_log(s, AV_LOG_ERROR, "CAF files have exactly one stream\n");
return AVERROR(EINVAL);
}
switch (enc->codec_id) {
switch (par->codec_id) {
case AV_CODEC_ID_AAC:
av_log(s, AV_LOG_ERROR, "muxing codec currently unsupported\n");
return AVERROR_PATCHWELCOME;
@ -125,13 +125,13 @@ static int caf_write_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
if (!enc->block_align && !pb->seekable) {
if (!par->block_align && !pb->seekable) {
av_log(s, AV_LOG_ERROR, "Muxing variable packet size not supported on non seekable output\n");
return AVERROR_INVALIDDATA;
}
if (enc->codec_id != AV_CODEC_ID_MP3 || frame_size != 576)
frame_size = samples_per_packet(enc->codec_id, enc->channels, enc->block_align);
if (par->codec_id != AV_CODEC_ID_MP3 || frame_size != 576)
frame_size = samples_per_packet(par->codec_id, par->channels, par->block_align);
ffio_wfourcc(pb, "caff"); //< mFileType
avio_wb16(pb, 1); //< mFileVersion
@ -139,26 +139,26 @@ static int caf_write_header(AVFormatContext *s)
ffio_wfourcc(pb, "desc"); //< Audio Description chunk
avio_wb64(pb, 32); //< mChunkSize
avio_wb64(pb, av_double2int(enc->sample_rate)); //< mSampleRate
avio_wb64(pb, av_double2int(par->sample_rate)); //< mSampleRate
avio_wl32(pb, codec_tag); //< mFormatID
avio_wb32(pb, codec_flags(enc->codec_id)); //< mFormatFlags
avio_wb32(pb, enc->block_align); //< mBytesPerPacket
avio_wb32(pb, codec_flags(par->codec_id)); //< mFormatFlags
avio_wb32(pb, par->block_align); //< mBytesPerPacket
avio_wb32(pb, frame_size); //< mFramesPerPacket
avio_wb32(pb, enc->channels); //< mChannelsPerFrame
avio_wb32(pb, av_get_bits_per_sample(enc->codec_id)); //< mBitsPerChannel
avio_wb32(pb, par->channels); //< mChannelsPerFrame
avio_wb32(pb, av_get_bits_per_sample(par->codec_id)); //< mBitsPerChannel
if (enc->channel_layout) {
if (par->channel_layout) {
ffio_wfourcc(pb, "chan");
avio_wb64(pb, 12);
ff_mov_write_chan(pb, enc->channel_layout);
ff_mov_write_chan(pb, par->channel_layout);
}
if (enc->codec_id == AV_CODEC_ID_ALAC) {
if (par->codec_id == AV_CODEC_ID_ALAC) {
ffio_wfourcc(pb, "kuki");
avio_wb64(pb, 12 + enc->extradata_size);
avio_wb64(pb, 12 + par->extradata_size);
avio_write(pb, "\0\0\0\14frmaalac", 12);
avio_write(pb, enc->extradata, enc->extradata_size);
} else if (enc->codec_id == AV_CODEC_ID_AMR_NB) {
avio_write(pb, par->extradata, par->extradata_size);
} else if (par->codec_id == AV_CODEC_ID_AMR_NB) {
ffio_wfourcc(pb, "kuki");
avio_wb64(pb, 29);
avio_write(pb, "\0\0\0\14frmasamr", 12);
@ -169,10 +169,10 @@ static int caf_write_header(AVFormatContext *s)
avio_wb16(pb, 0x81FF); /* Mode set (all modes for AMR_NB) */
avio_w8(pb, 0x00); /* Mode change period (no restriction) */
avio_w8(pb, 0x01); /* Frames per sample */
} else if (enc->codec_id == AV_CODEC_ID_QDM2) {
} else if (par->codec_id == AV_CODEC_ID_QDM2) {
ffio_wfourcc(pb, "kuki");
avio_wb64(pb, enc->extradata_size);
avio_write(pb, enc->extradata, enc->extradata_size);
avio_wb64(pb, par->extradata_size);
avio_write(pb, par->extradata, par->extradata_size);
}
ff_standardize_creation_time(s);
@ -204,7 +204,7 @@ static int caf_write_packet(AVFormatContext *s, AVPacket *pkt)
CAFContext *caf = s->priv_data;
avio_write(s->pb, pkt->data, pkt->size);
if (!s->streams[0]->codec->block_align) {
if (!s->streams[0]->codecpar->block_align) {
void *pkt_sizes = caf->pkt_sizes;
int i, alloc_size = caf->size_entries_used + 5;
if (alloc_size < 0) {
@ -233,7 +233,7 @@ static int caf_write_trailer(AVFormatContext *s)
{
CAFContext *caf = s->priv_data;
AVIOContext *pb = s->pb;
AVCodecContext *enc = s->streams[0]->codec;
AVCodecParameters *par = s->streams[0]->codecpar;
if (pb->seekable) {
int64_t file_size = avio_tell(pb);
@ -241,11 +241,11 @@ static int caf_write_trailer(AVFormatContext *s)
avio_seek(pb, caf->data, SEEK_SET);
avio_wb64(pb, file_size - caf->data - 8);
avio_seek(pb, file_size, SEEK_SET);
if (!enc->block_align) {
if (!par->block_align) {
ffio_wfourcc(pb, "pakt");
avio_wb64(pb, caf->size_entries_used + 24);
avio_wb64(pb, caf->packets); ///< mNumberPackets
avio_wb64(pb, caf->packets * samples_per_packet(enc->codec_id, enc->channels, enc->block_align)); ///< mNumberValidFrames
avio_wb64(pb, caf->packets * samples_per_packet(par->codec_id, par->channels, par->block_align)); ///< mNumberValidFrames
avio_wb32(pb, 0); ///< mPrimingFrames
avio_wb32(pb, 0); ///< mRemainderFrames
avio_write(pb, caf->pkt_sizes, caf->size_entries_used);

View File

@ -39,8 +39,8 @@ static int read_header(AVFormatContext *s)
if (!vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codec->codec_id = AV_CODEC_ID_CDGRAPHICS;
vst->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
vst->codecpar->codec_id = AV_CODEC_ID_CDGRAPHICS;
/// 75 sectors/sec * 4 packets/sector = 300 packets/sec
avpriv_set_pts_info(vst, 32, 1, 300);

View File

@ -150,17 +150,17 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = 0;
st->codec->codec_id = AV_CODEC_ID_PCM_S8;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_tag = 0;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S8;
if (cdxl->header[1] & 0x10) {
st->codec->channels = 2;
st->codec->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->channels = 2;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
} else {
st->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
}
st->codec->sample_rate = cdxl->sample_rate;
st->codecpar->sample_rate = cdxl->sample_rate;
st->start_time = 0;
cdxl->audio_stream_index = st->index;
avpriv_set_pts_info(st, 64, 1, cdxl->sample_rate);
@ -179,11 +179,11 @@ static int cdxl_read_packet(AVFormatContext *s, AVPacket *pkt)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_tag = 0;
st->codec->codec_id = AV_CODEC_ID_CDXL;
st->codec->width = width;
st->codec->height = height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_tag = 0;
st->codecpar->codec_id = AV_CODEC_ID_CDXL;
st->codecpar->width = width;
st->codecpar->height = height;
if (audio_size + video_size && cdxl->filesize > 0) {
frames = cdxl->filesize / (audio_size + video_size);

View File

@ -85,17 +85,17 @@ static int write_header(AVFormatContext *s)
st = s->streams[0];
if (st->codec->channels > 2) {
if (st->codecpar->channels > 2) {
av_log(s, AV_LOG_ERROR, "Only up to 2 channels are supported\n");
goto fail;
}
if (st->codec->sample_rate < 1000) {
if (st->codecpar->sample_rate < 1000) {
av_log(s, AV_LOG_ERROR, "Sampling rate must be at least 1000\n");
goto fail;
}
if (!chromaprint_start(cpr->ctx, st->codec->sample_rate, st->codec->channels)) {
if (!chromaprint_start(cpr->ctx, st->codecpar->sample_rate, st->codecpar->channels)) {
av_log(s, AV_LOG_ERROR, "Failed to start chromaprint\n");
goto fail;
}

View File

@ -101,9 +101,9 @@ static int cine_read_header(AVFormatContext *avctx)
st = avformat_new_stream(avctx, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->codec_tag = 0;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codecpar->codec_tag = 0;
/* CINEFILEHEADER structure */
avio_skip(pb, 4); // Type, Headersize
@ -127,8 +127,8 @@ static int cine_read_header(AVFormatContext *avctx)
/* BITMAPINFOHEADER structure */
avio_seek(pb, offImageHeader, SEEK_SET);
avio_skip(pb, 4); //biSize
st->codec->width = avio_rl32(pb);
st->codec->height = avio_rl32(pb);
st->codecpar->width = avio_rl32(pb);
st->codecpar->height = avio_rl32(pb);
if (avio_rl16(pb) != 1) // biPlanes
return AVERROR_INVALIDDATA;
@ -144,7 +144,7 @@ static int cine_read_header(AVFormatContext *avctx)
vflip = 0;
break;
case 0x100: /* BI_PACKED */
st->codec->codec_tag = MKTAG('B', 'I', 'T', 0);
st->codecpar->codec_tag = MKTAG('B', 'I', 'T', 0);
vflip = 1;
break;
default:
@ -167,8 +167,8 @@ static int cine_read_header(AVFormatContext *avctx)
avio_skip(pb, 616); // Binning .. bFlipH
if (!avio_rl32(pb) ^ vflip) {
st->codec->extradata = av_strdup("BottomUp");
st->codec->extradata_size = 9;
st->codecpar->extradata = av_strdup("BottomUp");
st->codecpar->extradata_size = 9;
}
avio_skip(pb, 4); // Grid
@ -193,17 +193,17 @@ static int cine_read_header(AVFormatContext *avctx)
set_metadata_float(&st->metadata, "wbgain[0].b", av_int2float(avio_rl32(pb)), 1);
avio_skip(pb, 36); // WBGain[1].. WBView
st->codec->bits_per_coded_sample = avio_rl32(pb);
st->codecpar->bits_per_coded_sample = avio_rl32(pb);
if (compression == CC_RGB) {
if (biBitCount == 8) {
st->codec->pix_fmt = AV_PIX_FMT_GRAY8;
st->codecpar->format = AV_PIX_FMT_GRAY8;
} else if (biBitCount == 16) {
st->codec->pix_fmt = AV_PIX_FMT_GRAY16LE;
st->codecpar->format = AV_PIX_FMT_GRAY16LE;
} else if (biBitCount == 24) {
st->codec->pix_fmt = AV_PIX_FMT_BGR24;
st->codecpar->format = AV_PIX_FMT_BGR24;
} else if (biBitCount == 48) {
st->codec->pix_fmt = AV_PIX_FMT_BGR48LE;
st->codecpar->format = AV_PIX_FMT_BGR48LE;
} else {
avpriv_request_sample(avctx, "unsupported biBitCount %i", biBitCount);
return AVERROR_INVALIDDATA;
@ -212,9 +212,9 @@ static int cine_read_header(AVFormatContext *avctx)
switch (CFA & 0xFFFFFF) {
case CFA_BAYER:
if (biBitCount == 8) {
st->codec->pix_fmt = AV_PIX_FMT_BAYER_GBRG8;
st->codecpar->format = AV_PIX_FMT_BAYER_GBRG8;
} else if (biBitCount == 16) {
st->codec->pix_fmt = AV_PIX_FMT_BAYER_GBRG16LE;
st->codecpar->format = AV_PIX_FMT_BAYER_GBRG16LE;
} else {
avpriv_request_sample(avctx, "unsupported biBitCount %i", biBitCount);
return AVERROR_INVALIDDATA;
@ -222,9 +222,9 @@ static int cine_read_header(AVFormatContext *avctx)
break;
case CFA_BAYERFLIP:
if (biBitCount == 8) {
st->codec->pix_fmt = AV_PIX_FMT_BAYER_RGGB8;
st->codecpar->format = AV_PIX_FMT_BAYER_RGGB8;
} else if (biBitCount == 16) {
st->codec->pix_fmt = AV_PIX_FMT_BAYER_RGGB16LE;
st->codecpar->format = AV_PIX_FMT_BAYER_RGGB16LE;
} else {
avpriv_request_sample(avctx, "unsupported biBitCount %i", biBitCount);
return AVERROR_INVALIDDATA;

View File

@ -35,6 +35,7 @@ typedef enum ConcatMatchMode {
typedef struct ConcatStream {
AVBitStreamFilterContext *bsf;
AVCodecContext *avctx;
int out_stream_index;
} ConcatStream;
@ -164,19 +165,28 @@ static int copy_stream_props(AVStream *st, AVStream *source_st)
{
int ret;
if (st->codec->codec_id || !source_st->codec->codec_id) {
if (st->codec->extradata_size < source_st->codec->extradata_size) {
ret = ff_alloc_extradata(st->codec,
source_st->codec->extradata_size);
if (st->codecpar->codec_id || !source_st->codecpar->codec_id) {
if (st->codecpar->extradata_size < source_st->codecpar->extradata_size) {
if (st->codecpar->extradata) {
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = 0;
}
ret = ff_alloc_extradata(st->codecpar,
source_st->codecpar->extradata_size);
if (ret < 0)
return ret;
}
memcpy(st->codec->extradata, source_st->codec->extradata,
source_st->codec->extradata_size);
memcpy(st->codecpar->extradata, source_st->codecpar->extradata,
source_st->codecpar->extradata_size);
return 0;
}
if ((ret = avcodec_copy_context(st->codec, source_st->codec)) < 0)
if ((ret = avcodec_parameters_copy(st->codecpar, source_st->codecpar)) < 0)
return ret;
/* We don't want to carry around MP4-style extradata, since we are usoign a bsf anyway. */
if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
av_freep(&st->codecpar->extradata);
st->codecpar->extradata_size = 0;
}
st->r_frame_rate = source_st->r_frame_rate;
st->avg_frame_rate = source_st->avg_frame_rate;
st->time_base = source_st->time_base;
@ -192,9 +202,10 @@ static int detect_stream_specific(AVFormatContext *avf, int idx)
AVStream *st = cat->avf->streams[idx];
ConcatStream *cs = &cat->cur_file->streams[idx];
AVBitStreamFilterContext *bsf;
int ret;
if (cat->auto_convert && st->codec->codec_id == AV_CODEC_ID_H264 &&
(st->codec->extradata_size < 4 || AV_RB32(st->codec->extradata) != 1)) {
if (cat->auto_convert && st->codecpar->codec_id == AV_CODEC_ID_H264 &&
(st->codecpar->extradata_size < 4 || AV_RB32(st->codecpar->extradata) != 1)) {
av_log(cat->avf, AV_LOG_INFO,
"Auto-inserting h264_mp4toannexb bitstream filter\n");
if (!(bsf = av_bitstream_filter_init("h264_mp4toannexb"))) {
@ -203,6 +214,17 @@ static int detect_stream_specific(AVFormatContext *avf, int idx)
return AVERROR_BSF_NOT_FOUND;
}
cs->bsf = bsf;
cs->avctx = avcodec_alloc_context3(NULL);
if (!cs->avctx)
return AVERROR(ENOMEM);
ret = avcodec_parameters_to_context(cs->avctx, st->codecpar);
if (ret < 0) {
avcodec_free_context(&cs->avctx);
return ret;
}
}
return 0;
}
@ -338,15 +360,21 @@ static int open_file(AVFormatContext *avf, unsigned fileno)
static int concat_read_close(AVFormatContext *avf)
{
ConcatContext *cat = avf->priv_data;
unsigned i;
unsigned i, j;
if (cat->avf)
avformat_close_input(&cat->avf);
for (i = 0; i < cat->nb_files; i++) {
av_freep(&cat->files[i].url);
for (j = 0; j < cat->avf->nb_streams; j++) {
if (cat->files[i].streams[j].avctx)
avcodec_free_context(&cat->files[i].streams[j].avctx);
if (cat->files[i].streams[j].bsf)
av_bitstream_filter_close(cat->files[i].streams[j].bsf);
}
av_freep(&cat->files[i].streams);
av_dict_free(&cat->files[i].metadata);
}
if (cat->avf)
avformat_close_input(&cat->avf);
av_freep(&cat->files);
return 0;
}
@ -499,7 +527,8 @@ static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
av_assert0(cs->out_stream_index >= 0);
for (bsf = cs->bsf; bsf; bsf = bsf->next) {
pkt2 = *pkt;
ret = av_bitstream_filter_filter(bsf, st->codec, NULL,
ret = av_bitstream_filter_filter(bsf, cs->avctx, NULL,
&pkt2.data, &pkt2.size,
pkt->data, pkt->size,
!!(pkt->flags & AV_PKT_FLAG_KEY));
@ -507,6 +536,21 @@ static int filter_packet(AVFormatContext *avf, ConcatStream *cs, AVPacket *pkt)
av_packet_unref(pkt);
return ret;
}
if (cs->avctx->extradata_size > st->codecpar->extradata_size) {
int eret;
if (st->codecpar->extradata)
av_freep(&st->codecpar->extradata);
eret = ff_alloc_extradata(st->codecpar, cs->avctx->extradata_size);
if (eret < 0) {
av_packet_unref(pkt);
return AVERROR(ENOMEM);
}
st->codecpar->extradata_size = cs->avctx->extradata_size;
memcpy(st->codecpar->extradata, cs->avctx->extradata, cs->avctx->extradata_size);
}
av_assert0(pkt2.buf);
if (ret == 0 && pkt2.data != pkt->data) {
if ((ret = av_copy_packet(&pkt2, pkt)) < 0) {

View File

@ -109,19 +109,19 @@ static int dash_write(void *opaque, uint8_t *buf, int buf_size)
}
// RFC 6381
static void set_codec_str(AVFormatContext *s, AVCodecContext *codec,
static void set_codec_str(AVFormatContext *s, AVCodecParameters *par,
char *str, int size)
{
const AVCodecTag *tags[2] = { NULL, NULL };
uint32_t tag;
if (codec->codec_type == AVMEDIA_TYPE_VIDEO)
if (par->codec_type == AVMEDIA_TYPE_VIDEO)
tags[0] = ff_codec_movvideo_tags;
else if (codec->codec_type == AVMEDIA_TYPE_AUDIO)
else if (par->codec_type == AVMEDIA_TYPE_AUDIO)
tags[0] = ff_codec_movaudio_tags;
else
return;
tag = av_codec_get_tag(tags, codec->codec_id);
tag = av_codec_get_tag(tags, par->codec_id);
if (!tag)
return;
if (size < 5)
@ -132,17 +132,17 @@ static void set_codec_str(AVFormatContext *s, AVCodecContext *codec,
if (!strcmp(str, "mp4a") || !strcmp(str, "mp4v")) {
uint32_t oti;
tags[0] = ff_mp4_obj_type;
oti = av_codec_get_tag(tags, codec->codec_id);
oti = av_codec_get_tag(tags, par->codec_id);
if (oti)
av_strlcatf(str, size, ".%02x", oti);
else
return;
if (tag == MKTAG('m', 'p', '4', 'a')) {
if (codec->extradata_size >= 2) {
int aot = codec->extradata[0] >> 3;
if (par->extradata_size >= 2) {
int aot = par->extradata[0] >> 3;
if (aot == 31)
aot = ((AV_RB16(codec->extradata) >> 5) & 0x3f) + 32;
aot = ((AV_RB16(par->extradata) >> 5) & 0x3f) + 32;
av_strlcatf(str, size, ".%d", aot);
}
} else if (tag == MKTAG('m', 'p', '4', 'v')) {
@ -151,8 +151,8 @@ static void set_codec_str(AVFormatContext *s, AVCodecContext *codec,
}
} else if (!strcmp(str, "avc1")) {
uint8_t *tmpbuf = NULL;
uint8_t *extradata = codec->extradata;
int extradata_size = codec->extradata_size;
uint8_t *extradata = par->extradata;
int extradata_size = par->extradata_size;
if (!extradata_size)
return;
if (extradata[0] != 1) {
@ -515,10 +515,10 @@ static int write_manifest(AVFormatContext *s, int final)
AVStream *st = s->streams[i];
OutputStream *os = &c->streams[i];
if (st->codec->codec_type != AVMEDIA_TYPE_VIDEO)
if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
continue;
avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"%s\"%s width=\"%d\" height=\"%d\"", i, os->codec_str, os->bandwidth_str, st->codec->width, st->codec->height);
avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"video/mp4\" codecs=\"%s\"%s width=\"%d\" height=\"%d\"", i, os->codec_str, os->bandwidth_str, st->codecpar->width, st->codecpar->height);
if (st->avg_frame_rate.num)
avio_printf(out, " frameRate=\"%d/%d\"", st->avg_frame_rate.num, st->avg_frame_rate.den);
avio_printf(out, ">\n");
@ -534,11 +534,11 @@ static int write_manifest(AVFormatContext *s, int final)
AVStream *st = s->streams[i];
OutputStream *os = &c->streams[i];
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO)
if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
continue;
avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"audio/mp4\" codecs=\"%s\"%s audioSamplingRate=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codec->sample_rate);
avio_printf(out, "\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n", st->codec->channels);
avio_printf(out, "\t\t\t<Representation id=\"%d\" mimeType=\"audio/mp4\" codecs=\"%s\"%s audioSamplingRate=\"%d\">\n", i, os->codec_str, os->bandwidth_str, st->codecpar->sample_rate);
avio_printf(out, "\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n", st->codecpar->channels);
output_segment_list(&c->streams[i], out, c);
avio_printf(out, "\t\t\t</Representation>\n");
}
@ -598,9 +598,7 @@ static int dash_write_header(AVFormatContext *s)
AVDictionary *opts = NULL;
char filename[1024];
os->bit_rate = s->streams[i]->codec->bit_rate ?
s->streams[i]->codec->bit_rate :
s->streams[i]->codec->rc_max_rate;
os->bit_rate = s->streams[i]->codecpar->bit_rate;
if (os->bit_rate) {
snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
" bandwidth=\"%d\"", os->bit_rate);
@ -630,7 +628,7 @@ static int dash_write_header(AVFormatContext *s)
ret = AVERROR(ENOMEM);
goto fail;
}
avcodec_copy_context(st->codec, s->streams[i]->codec);
avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
st->time_base = s->streams[i]->time_base;
ctx->avoid_negative_ts = s->avoid_negative_ts;
@ -670,7 +668,7 @@ static int dash_write_header(AVFormatContext *s)
// already before being handed to this muxer, so we don't have mismatches
// between the MPD and the actual segments.
s->avoid_negative_ts = ctx->avoid_negative_ts;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
AVRational avg_frame_rate = s->streams[i]->avg_frame_rate;
if (avg_frame_rate.num > 0) {
if (av_cmp_q(avg_frame_rate, c->min_frame_rate) < 0)
@ -681,11 +679,11 @@ static int dash_write_header(AVFormatContext *s)
c->ambiguous_frame_rate = 1;
}
c->has_video = 1;
} else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
} else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
c->has_audio = 1;
}
set_codec_str(s, st->codec, os->codec_str, sizeof(os->codec_str));
set_codec_str(s, st->codecpar, os->codec_str, sizeof(os->codec_str));
os->first_pts = AV_NOPTS_VALUE;
os->max_pts = AV_NOPTS_VALUE;
os->last_dts = AV_NOPTS_VALUE;
@ -774,24 +772,24 @@ static void find_index_range(AVFormatContext *s, const char *full_path,
}
static int update_stream_extradata(AVFormatContext *s, OutputStream *os,
AVCodecContext *codec)
AVCodecParameters *par)
{
uint8_t *extradata;
if (os->ctx->streams[0]->codec->extradata_size || !codec->extradata_size)
if (os->ctx->streams[0]->codecpar->extradata_size || !par->extradata_size)
return 0;
extradata = av_malloc(codec->extradata_size);
extradata = av_malloc(par->extradata_size);
if (!extradata)
return AVERROR(ENOMEM);
memcpy(extradata, codec->extradata, codec->extradata_size);
memcpy(extradata, par->extradata, par->extradata_size);
os->ctx->streams[0]->codec->extradata = extradata;
os->ctx->streams[0]->codec->extradata_size = codec->extradata_size;
os->ctx->streams[0]->codecpar->extradata = extradata;
os->ctx->streams[0]->codecpar->extradata_size = par->extradata_size;
set_codec_str(s, codec, os->codec_str, sizeof(os->codec_str));
set_codec_str(s, par, os->codec_str, sizeof(os->codec_str));
return 0;
}
@ -817,7 +815,7 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
// Flush all audio streams as well, in sync with video keyframes,
// but not the other video streams.
if (stream >= 0 && i != stream) {
if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO)
if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
continue;
// Make sure we don't flush audio streams multiple times, when
// all video streams are flushed one at a time.
@ -896,7 +894,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
int64_t seg_end_duration = (os->segment_index) * (int64_t) c->min_seg_duration;
int ret;
ret = update_stream_extradata(s, os, st->codec);
ret = update_stream_extradata(s, os, st->codecpar);
if (ret < 0)
return ret;
@ -921,7 +919,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
if (os->first_pts == AV_NOPTS_VALUE)
os->first_pts = pkt->pts;
if ((!c->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) &&
if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
pkt->flags & AV_PKT_FLAG_KEY && os->packets_written &&
av_compare_ts(pkt->pts - os->first_pts, st->time_base,
seg_end_duration, AV_TIME_BASE_Q) >= 0) {

View File

@ -26,15 +26,15 @@ static int daud_header(AVFormatContext *s) {
AVStream *st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_PCM_S24DAUD;
st->codec->codec_tag = MKTAG('d', 'a', 'u', 'd');
st->codec->channels = 6;
st->codec->channel_layout = AV_CH_LAYOUT_5POINT1;
st->codec->sample_rate = 96000;
st->codec->bit_rate = 3 * 6 * 96000 * 8;
st->codec->block_align = 3 * 6;
st->codec->bits_per_coded_sample = 24;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S24DAUD;
st->codecpar->codec_tag = MKTAG('d', 'a', 'u', 'd');
st->codecpar->channels = 6;
st->codecpar->channel_layout = AV_CH_LAYOUT_5POINT1;
st->codecpar->sample_rate = 96000;
st->codecpar->bit_rate = 3 * 6 * 96000 * 8;
st->codecpar->block_align = 3 * 6;
st->codecpar->bits_per_coded_sample = 24;
return 0;
}

View File

@ -23,8 +23,8 @@
static int daud_write_header(struct AVFormatContext *s)
{
AVCodecContext *codec = s->streams[0]->codec;
if (codec->channels!=6 || codec->sample_rate!=96000)
AVCodecParameters *par = s->streams[0]->codecpar;
if (par->channels!=6 || par->sample_rate!=96000)
return -1;
return 0;
}

View File

@ -39,35 +39,35 @@ static int dcstr_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->channels = avio_rl32(s->pb);
st->codec->sample_rate = avio_rl32(s->pb);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->channels = avio_rl32(s->pb);
st->codecpar->sample_rate = avio_rl32(s->pb);
codec = avio_rl32(s->pb);
align = avio_rl32(s->pb);
avio_skip(s->pb, 4);
st->duration = avio_rl32(s->pb);
st->codec->channels *= avio_rl32(s->pb);
if (!align || align > INT_MAX / st->codec->channels)
st->codecpar->channels *= avio_rl32(s->pb);
if (!align || align > INT_MAX / st->codecpar->channels)
return AVERROR_INVALIDDATA;
st->codec->block_align = align * st->codec->channels;
st->codecpar->block_align = align * st->codecpar->channels;
switch (codec) {
case 4: st->codec->codec_id = AV_CODEC_ID_ADPCM_AICA; break;
case 16: st->codec->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR; break;
case 4: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_AICA; break;
case 16: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR; break;
default: avpriv_request_sample(s, "codec %X", codec);
return AVERROR_PATCHWELCOME;
}
avio_skip(s->pb, 0x800 - avio_tell(s->pb));
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
return 0;
}
static int dcstr_read_packet(AVFormatContext *s, AVPacket *pkt)
{
AVCodecContext *codec = s->streams[0]->codec;
return av_get_packet(s->pb, pkt, codec->block_align);
AVCodecParameters *par = s->streams[0]->codecpar;
return av_get_packet(s->pb, pkt, par->block_align);
}
AVInputFormat ff_dcstr_demuxer = {

View File

@ -56,10 +56,10 @@ static int dfa_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_DFA;
st->codec->width = avio_rl16(pb);
st->codec->height = avio_rl16(pb);
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_DFA;
st->codecpar->width = avio_rl16(pb);
st->codecpar->height = avio_rl16(pb);
mspf = avio_rl32(pb);
if (!mspf) {
av_log(s, AV_LOG_WARNING, "Zero FPS reported, defaulting to 10\n");
@ -69,9 +69,9 @@ static int dfa_read_header(AVFormatContext *s)
avio_skip(pb, 128 - 16); // padding
st->duration = frames;
if (ff_alloc_extradata(st->codec, 2))
if (ff_alloc_extradata(st->codecpar, 2))
return AVERROR(ENOMEM);
AV_WL16(st->codec->extradata, version);
AV_WL16(st->codecpar->extradata, version);
if (version == 0x100)
st->sample_aspect_ratio = (AVRational){2, 1};

View File

@ -99,29 +99,29 @@ static int dsf_read_header(AVFormatContext *s)
channel_type = avio_rl32(pb);
if (channel_type < FF_ARRAY_ELEMS(dsf_channel_layout))
st->codec->channel_layout = dsf_channel_layout[channel_type];
if (!st->codec->channel_layout)
st->codecpar->channel_layout = dsf_channel_layout[channel_type];
if (!st->codecpar->channel_layout)
avpriv_request_sample(s, "channel type %i", channel_type);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->channels = avio_rl32(pb);
st->codec->sample_rate = avio_rl32(pb) / 8;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->channels = avio_rl32(pb);
st->codecpar->sample_rate = avio_rl32(pb) / 8;
switch(avio_rl32(pb)) {
case 1: st->codec->codec_id = AV_CODEC_ID_DSD_LSBF_PLANAR; break;
case 8: st->codec->codec_id = AV_CODEC_ID_DSD_MSBF_PLANAR; break;
case 1: st->codecpar->codec_id = AV_CODEC_ID_DSD_LSBF_PLANAR; break;
case 8: st->codecpar->codec_id = AV_CODEC_ID_DSD_MSBF_PLANAR; break;
default:
avpriv_request_sample(s, "unknown most significant bit");
return AVERROR_INVALIDDATA;
}
avio_skip(pb, 8);
st->codec->block_align = avio_rl32(pb);
if (st->codec->block_align > INT_MAX / st->codec->channels) {
st->codecpar->block_align = avio_rl32(pb);
if (st->codecpar->block_align > INT_MAX / st->codecpar->channels) {
avpriv_request_sample(s, "block_align overflow");
return AVERROR_INVALIDDATA;
}
st->codec->block_align *= st->codec->channels;
st->codecpar->block_align *= st->codecpar->channels;
avio_skip(pb, 4);
/* data chunk */
@ -145,7 +145,7 @@ static int dsf_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_EOF;
pkt->stream_index = 0;
return av_get_packet(pb, pkt, FFMIN(dsf->data_end - pos, st->codec->block_align));
return av_get_packet(pb, pkt, FFMIN(dsf->data_end - pos, st->codecpar->block_align));
}
AVInputFormat ff_dsf_demuxer = {

View File

@ -116,11 +116,11 @@ static int cin_read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 32, 1, 12);
cin->video_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_DSICINVIDEO;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = hdr->video_frame_width;
st->codec->height = hdr->video_frame_height;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_DSICINVIDEO;
st->codecpar->codec_tag = 0; /* no fourcc */
st->codecpar->width = hdr->video_frame_width;
st->codecpar->height = hdr->video_frame_height;
/* initialize the audio decoder stream */
st = avformat_new_stream(s, NULL);
@ -129,14 +129,14 @@ static int cin_read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 32, 1, 22050);
cin->audio_stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_DSICINAUDIO;
st->codec->codec_tag = 0; /* no tag */
st->codec->channels = 1;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codec->sample_rate = 22050;
st->codec->bits_per_coded_sample = 8;
st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_coded_sample * st->codec->channels;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_DSICINAUDIO;
st->codecpar->codec_tag = 0; /* no tag */
st->codecpar->channels = 1;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->sample_rate = 22050;
st->codecpar->bits_per_coded_sample = 8;
st->codecpar->bit_rate = st->codecpar->sample_rate * st->codecpar->bits_per_coded_sample * st->codecpar->channels;
return 0;
}

View File

@ -144,22 +144,22 @@ static int dss_read_header(AVFormatContext *s)
ctx->audio_codec = avio_r8(pb);
if (ctx->audio_codec == DSS_ACODEC_DSS_SP) {
st->codec->codec_id = AV_CODEC_ID_DSS_SP;
st->codec->sample_rate = 11025;
st->codecpar->codec_id = AV_CODEC_ID_DSS_SP;
st->codecpar->sample_rate = 11025;
} else if (ctx->audio_codec == DSS_ACODEC_G723_1) {
st->codec->codec_id = AV_CODEC_ID_G723_1;
st->codec->sample_rate = 8000;
st->codecpar->codec_id = AV_CODEC_ID_G723_1;
st->codecpar->sample_rate = 8000;
} else {
avpriv_request_sample(s, "Support for codec %x in DSS",
ctx->audio_codec);
return AVERROR_PATCHWELCOME;
}
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->channel_layout = AV_CH_LAYOUT_MONO;
st->codec->channels = 1;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->channel_layout = AV_CH_LAYOUT_MONO;
st->codecpar->channels = 1;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
st->start_time = 0;
/* Jump over header */
@ -235,7 +235,7 @@ static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->duration = 264;
pkt->pos = pos;
pkt->stream_index = 0;
s->bit_rate = 8LL * ctx->packet_size * st->codec->sample_rate * 512 / (506 * pkt->duration);
s->bit_rate = 8LL * ctx->packet_size * st->codecpar->sample_rate * 512 / (506 * pkt->duration);
if (ctx->counter < 0) {
int size2 = ctx->counter + read_size;
@ -299,7 +299,7 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->data[0] = byte;
offset = 1;
pkt->duration = 240;
s->bit_rate = 8LL * size * st->codec->sample_rate * 512 / (506 * pkt->duration);
s->bit_rate = 8LL * size * st->codecpar->sample_rate * 512 / (506 * pkt->duration);
pkt->stream_index = 0;

View File

@ -60,8 +60,8 @@ static int dtshd_read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_DTS;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = AV_CODEC_ID_DTS;
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
while (!avio_feof(pb)) {

View File

@ -440,14 +440,24 @@ static void dump_stream_format(AVFormatContext *ic, int i,
AVStream *st = ic->streams[i];
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
char *separator = ic->dump_separator;
char **codec_separator = av_opt_ptr(st->codec->av_class, st->codec, "dump_separator");
int use_format_separator = !*codec_separator;
AVCodecContext *avctx;
int ret;
avctx = avcodec_alloc_context3(NULL);
if (!avctx)
return;
ret = avcodec_parameters_to_context(avctx, st->codecpar);
if (ret < 0) {
avcodec_free_context(&avctx);
return;
}
if (separator)
av_opt_set(avctx, "dump_separator", separator, 0);
avcodec_string(buf, sizeof(buf), avctx, is_output);
avcodec_free_context(&avctx);
if (use_format_separator)
*codec_separator = av_strdup(separator);
avcodec_string(buf, sizeof(buf), st->codec, is_output);
if (use_format_separator)
av_freep(codec_separator);
av_log(NULL, AV_LOG_INFO, " Stream #%d:%d", index, i);
/* the pid is an important information, so we display it */
@ -460,35 +470,32 @@ static void dump_stream_format(AVFormatContext *ic, int i,
st->time_base.num, st->time_base.den);
av_log(NULL, AV_LOG_INFO, ": %s", buf);
if (st->sample_aspect_ratio.num && // default
av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {
if (st->sample_aspect_ratio.num &&
av_cmp_q(st->sample_aspect_ratio, st->codecpar->sample_aspect_ratio)) {
AVRational display_aspect_ratio;
av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
st->codec->width * (int64_t)st->sample_aspect_ratio.num,
st->codec->height * (int64_t)st->sample_aspect_ratio.den,
st->codecpar->width * (int64_t)st->sample_aspect_ratio.num,
st->codecpar->height * (int64_t)st->sample_aspect_ratio.den,
1024 * 1024);
av_log(NULL, AV_LOG_INFO, ", SAR %d:%d DAR %d:%d",
st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
display_aspect_ratio.num, display_aspect_ratio.den);
}
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
int fps = st->avg_frame_rate.den && st->avg_frame_rate.num;
int tbr = st->r_frame_rate.den && st->r_frame_rate.num;
int tbn = st->time_base.den && st->time_base.num;
int tbc = st->codec->time_base.den && st->codec->time_base.num;
if (fps || tbr || tbn || tbc)
if (fps || tbr || tbn)
av_log(NULL, AV_LOG_INFO, "%s", separator);
if (fps)
print_fps(av_q2d(st->avg_frame_rate), tbr || tbn || tbc ? "fps, " : "fps");
print_fps(av_q2d(st->avg_frame_rate), tbr || tbn ? "fps, " : "fps");
if (tbr)
print_fps(av_q2d(st->r_frame_rate), tbn || tbc ? "tbr, " : "tbr");
print_fps(av_q2d(st->r_frame_rate), tbn ? "tbr, " : "tbr");
if (tbn)
print_fps(1 / av_q2d(st->time_base), tbc ? "tbn, " : "tbn");
if (tbc)
print_fps(1 / av_q2d(st->codec->time_base), "tbc");
print_fps(1 / av_q2d(st->time_base), "tbn");
}
if (st->disposition & AV_DISPOSITION_DEFAULT)

View File

@ -259,8 +259,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame)
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;
@ -268,10 +268,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame)
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;
@ -282,10 +282,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame)
static int dv_extract_video_info(DVDemuxContext *c, const uint8_t *frame)
{
const uint8_t *vsc_pack;
AVCodecContext *avctx;
AVCodecParameters *par;
int apt, is16_9;
avctx = c->vst->codec;
par = c->vst->codecpar;
avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
c->sys->time_base.den);
@ -297,7 +297,7 @@ static int dv_extract_video_info(DVDemuxContext *c, const uint8_t *frame)
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,
par->bit_rate = av_rescale_q(c->sys->frame_size,
(AVRational) { 8, 1 },
c->sys->time_base);
return c->sys->frame_size;
@ -336,9 +336,9 @@ DVDemuxContext *avpriv_dv_init_demux(AVFormatContext *s)
}
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;
@ -380,7 +380,7 @@ int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
c->audio_pkt[i].pos = pos;
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)
@ -439,7 +439,7 @@ void ff_dv_offset_reset(DVDemuxContext *c, int64_t frame_offset)
if (c->ach) {
if (c->sys) {
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 });
} else
av_log(c->fctx, AV_LOG_ERROR, "cannot adjust audio bytes\n");
}

View File

@ -105,13 +105,13 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
case dv_audio_source: /* AAUX source pack */
va_start(ap, buf);
channel = va_arg(ap, int);
if (c->ast[channel]->codec->sample_rate == 44100) {
if (c->ast[channel]->codecpar->sample_rate == 44100) {
audio_type = 1;
} else if (c->ast[channel]->codec->sample_rate == 32000)
} else if (c->ast[channel]->codecpar->sample_rate == 32000)
audio_type = 2;
buf[1] = (1 << 7) | /* locked mode -- SMPTE only supports locked mode */
(1 << 6) | /* reserved -- always 1 */
(dv_audio_frame_size(c->sys, c->frames, c->ast[channel]->codec->sample_rate) -
(dv_audio_frame_size(c->sys, c->frames, c->ast[channel]->codecpar->sample_rate) -
c->sys->audio_min_samples[audio_type]);
/* # of samples */
buf[2] = (0 << 7) | /* multi-stereo */
@ -186,7 +186,7 @@ static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t* bu
static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t* frame_ptr)
{
int i, j, d, of, size;
size = 4 * dv_audio_frame_size(c->sys, c->frames, c->ast[channel]->codec->sample_rate);
size = 4 * dv_audio_frame_size(c->sys, c->frames, c->ast[channel]->codecpar->sample_rate);
frame_ptr += channel * c->sys->difseg_size * 150 * 80;
for (i = 0; i < c->sys->difseg_size; i++) {
frame_ptr += 6 * 80; /* skip DIF segment header */
@ -238,20 +238,21 @@ static void dv_inject_metadata(DVMuxContext *c, uint8_t* frame)
* The following 3 functions constitute our interface to the world
*/
static int dv_assemble_frame(DVMuxContext *c, AVStream* st,
static int dv_assemble_frame(AVFormatContext *s,
DVMuxContext *c, AVStream* st,
uint8_t* data, int data_size, uint8_t** frame)
{
int i, reqasize;
*frame = &c->frame_buf[0];
switch (st->codec->codec_type) {
switch (st->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO:
/* FIXME: we have to have more sensible approach than this one */
if (c->has_video)
av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
av_log(s, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
if (data_size != c->sys->frame_size) {
av_log(st->codec, AV_LOG_ERROR, "Unexpected frame size, %d != %d\n",
av_log(s, AV_LOG_ERROR, "Unexpected frame size, %d != %d\n",
data_size, c->sys->frame_size);
return AVERROR(ENOSYS);
}
@ -264,10 +265,10 @@ static int dv_assemble_frame(DVMuxContext *c, AVStream* st,
/* FIXME: we have to have more sensible approach than this one */
if (av_fifo_size(c->audio_data[i]) + data_size >= 100*MAX_AUDIO_FRAME_SIZE)
av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
av_log(s, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
av_fifo_generic_write(c->audio_data[i], data, data_size, NULL);
reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, st->codec->sample_rate);
reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, st->codecpar->sample_rate);
/* Let us see if we've got enough audio for one DV frame. */
c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i);
@ -283,7 +284,7 @@ static int dv_assemble_frame(DVMuxContext *c, AVStream* st,
c->has_audio = 0;
for (i=0; i < c->n_ast; i++) {
dv_inject_audio(c, i, *frame);
reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, c->ast[i]->codec->sample_rate);
reqasize = 4 * dv_audio_frame_size(c->sys, c->frames, c->ast[i]->codecpar->sample_rate);
av_fifo_drain(c->audio_data[i], reqasize);
c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i);
}
@ -313,7 +314,7 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s)
/* We have to sort out where audio and where video stream is */
for (i=0; i<s->nb_streams; i++) {
switch (s->streams[i]->codec->codec_type) {
switch (s->streams[i]->codecpar->codec_type) {
case AVMEDIA_TYPE_VIDEO:
if (vst) return NULL;
vst = s->streams[i];
@ -328,28 +329,28 @@ static DVMuxContext* dv_init_mux(AVFormatContext* s)
}
/* Some checks -- DV format is very picky about its incoming streams */
if (!vst || vst->codec->codec_id != AV_CODEC_ID_DVVIDEO)
if (!vst || vst->codecpar->codec_id != AV_CODEC_ID_DVVIDEO)
goto bail_out;
for (i=0; i<c->n_ast; i++) {
if (c->ast[i]) {
if(c->ast[i]->codec->codec_id != AV_CODEC_ID_PCM_S16LE ||
c->ast[i]->codec->channels != 2)
if(c->ast[i]->codecpar->codec_id != AV_CODEC_ID_PCM_S16LE ||
c->ast[i]->codecpar->channels != 2)
goto bail_out;
if (c->ast[i]->codec->sample_rate != 48000 &&
c->ast[i]->codec->sample_rate != 44100 &&
c->ast[i]->codec->sample_rate != 32000 )
if (c->ast[i]->codecpar->sample_rate != 48000 &&
c->ast[i]->codecpar->sample_rate != 44100 &&
c->ast[i]->codecpar->sample_rate != 32000 )
goto bail_out;
}
}
c->sys = av_dv_codec_profile2(vst->codec->width, vst->codec->height,
vst->codec->pix_fmt, vst->codec->time_base);
c->sys = av_dv_codec_profile2(vst->codecpar->width, vst->codecpar->height,
vst->codecpar->format, vst->time_base);
if (!c->sys)
goto bail_out;
if ((c->sys->time_base.den != 25 && c->sys->time_base.den != 50) || c->sys->time_base.num != 1) {
if (c->ast[0] && c->ast[0]->codec->sample_rate != 48000)
if (c->ast[0] && c->ast[0]->codecpar->sample_rate != 48000)
goto bail_out;
if (c->ast[1] && c->ast[1]->codec->sample_rate != 48000)
if (c->ast[1] && c->ast[1]->codecpar->sample_rate != 48000)
goto bail_out;
}
@ -420,7 +421,7 @@ static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt)
uint8_t* frame;
int fsize;
fsize = dv_assemble_frame(s->priv_data, s->streams[pkt->stream_index],
fsize = dv_assemble_frame(s, s->priv_data, s->streams[pkt->stream_index],
pkt->data, pkt->size, &frame);
if (fsize > 0) {
avio_write(s->pb, frame, fsize);

View File

@ -106,11 +106,11 @@ static int dxa_read_header(AVFormatContext *s)
ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
ret = ff_get_wav_header(s, pb, ast->codec, fsize, 0);
ret = ff_get_wav_header(s, pb, ast->codecpar, fsize, 0);
if (ret < 0)
return ret;
if (ast->codec->sample_rate > 0)
avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate);
if (ast->codecpar->sample_rate > 0)
avpriv_set_pts_info(ast, 64, 1, ast->codecpar->sample_rate);
// find 'data' chunk
while(avio_tell(pb) < c->vidpos && !avio_feof(pb)){
tag = avio_rl32(pb);
@ -119,18 +119,18 @@ static int dxa_read_header(AVFormatContext *s)
avio_skip(pb, fsize);
}
c->bpc = (fsize + c->frames - 1) / c->frames;
if(ast->codec->block_align)
c->bpc = ((c->bpc + ast->codec->block_align - 1) / ast->codec->block_align) * ast->codec->block_align;
if(ast->codecpar->block_align)
c->bpc = ((c->bpc + ast->codecpar->block_align - 1) / ast->codecpar->block_align) * ast->codecpar->block_align;
c->bytes_left = fsize;
c->wavpos = avio_tell(pb);
avio_seek(pb, c->vidpos, SEEK_SET);
}
/* now we are ready: build format streams */
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_DXA;
st->codec->width = w;
st->codec->height = h;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = AV_CODEC_ID_DXA;
st->codecpar->width = w;
st->codecpar->height = h;
av_reduce(&den, &num, den, num, (1UL<<31)-1);
avpriv_set_pts_info(st, 33, num, den);
/* flags & 0x80 means that image is interlaced,
@ -138,7 +138,7 @@ static int dxa_read_header(AVFormatContext *s)
* either way set true height
*/
if(flags & 0xC0){
st->codec->height >>= 1;
st->codecpar->height >>= 1;
}
c->readvid = !c->has_sound;
c->vidpos = avio_tell(pb);

View File

@ -70,12 +70,12 @@ static int cdata_read_header(AVFormatContext *s)
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->codec_id = AV_CODEC_ID_ADPCM_EA_XAS;
st->codec->channels = cdata->channels;
st->codec->channel_layout = channel_layout;
st->codec->sample_rate = sample_rate;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_tag = 0; /* no fourcc */
st->codecpar->codec_id = AV_CODEC_ID_ADPCM_EA_XAS;
st->codecpar->channels = cdata->channels;
st->codecpar->channel_layout = channel_layout;
st->codecpar->sample_rate = sample_rate;
avpriv_set_pts_info(st, 64, 1, sample_rate);
cdata->audio_pts = 0;

View File

@ -499,14 +499,14 @@ static int init_video_stream(AVFormatContext *s, VideoProperties *video)
if (!st)
return AVERROR(ENOMEM);
video->stream_index = st->index;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = video->codec;
st->codecpar->codec_type = AVMEDIA_TYPE_VIDEO;
st->codecpar->codec_id = video->codec;
// parsing is necessary to make FFmpeg generate correct timestamps
if (st->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)
if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)
st->need_parsing = AVSTREAM_PARSE_HEADERS;
st->codec->codec_tag = 0; /* no fourcc */
st->codec->width = video->width;
st->codec->height = video->height;
st->codecpar->codec_tag = 0; /* no fourcc */
st->codecpar->width = video->width;
st->codecpar->height = video->height;
st->duration = st->nb_frames = video->nb_frames;
if (video->time_base.num)
avpriv_set_pts_info(st, 64, video->time_base.num, video->time_base.den);
@ -551,17 +551,17 @@ static int ea_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 33, 1, ea->sample_rate);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = ea->audio_codec;
st->codec->codec_tag = 0; /* no tag */
st->codec->channels = ea->num_channels;
st->codec->sample_rate = ea->sample_rate;
st->codec->bits_per_coded_sample = ea->bytes * 8;
st->codec->bit_rate = st->codec->channels *
st->codec->sample_rate *
st->codec->bits_per_coded_sample / 4;
st->codec->block_align = st->codec->channels *
st->codec->bits_per_coded_sample;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = ea->audio_codec;
st->codecpar->codec_tag = 0; /* no tag */
st->codecpar->channels = ea->num_channels;
st->codecpar->sample_rate = ea->sample_rate;
st->codecpar->bits_per_coded_sample = ea->bytes * 8;
st->codecpar->bit_rate = st->codecpar->channels *
st->codecpar->sample_rate *
st->codecpar->bits_per_coded_sample / 4;
st->codecpar->block_align = st->codecpar->channels *
st->codecpar->bits_per_coded_sample;
ea->audio_stream_index = st->index;
st->start_time = 0;
}

View File

@ -66,15 +66,15 @@ static int epaf_read_header(AVFormatContext *s)
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->channels = channels;
st->codec->sample_rate = sample_rate;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->channels = channels;
st->codecpar->sample_rate = sample_rate;
switch (codec) {
case 0:
st->codec->codec_id = le ? AV_CODEC_ID_PCM_S16LE : AV_CODEC_ID_PCM_S16BE;
st->codecpar->codec_id = le ? AV_CODEC_ID_PCM_S16LE : AV_CODEC_ID_PCM_S16BE;
break;
case 2:
st->codec->codec_id = AV_CODEC_ID_PCM_S8;
st->codecpar->codec_id = AV_CODEC_ID_PCM_S8;
break;
case 1:
avpriv_request_sample(s, "24-bit Paris PCM format");
@ -82,10 +82,10 @@ static int epaf_read_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
st->codec->bits_per_coded_sample = av_get_bits_per_sample(st->codec->codec_id);
st->codec->block_align = st->codec->bits_per_coded_sample * st->codec->channels / 8;
st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id);
st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8;
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
if (avio_skip(s->pb, 2024) < 0)
return AVERROR_INVALIDDATA;

Some files were not shown because too many files have changed in this diff Show More